All Downloads are FREE. Search and download functionalities are using the official Maven repository.

templates.util.CheckResultImplTest.ftl Maven / Gradle / Ivy

package ${javaPackage}.${utilFolderName};
<#assign importList = ["java.sql.SQLException", "java.util.Map", "java.util.HashMap"]>
<#assign importList = importList + ["org.mockito.Mock", "org.mockito.Mockito"]>
<#if junit == 'junit5'>
<#assign importList = importList + ["org.junit.jupiter.api.extension.ExtendWith", "org.mockito.junit.jupiter.MockitoExtension", "org.junit.jupiter.api.Assertions", "org.junit.jupiter.api.BeforeEach", "org.junit.jupiter.api.Test"]>
<#else>
<#assign importList = importList + ["org.junit.runner.RunWith", "org.mockito.runners.MockitoJUnitRunner", "org.junit.Assert", "org.junit.Before", "org.junit.Test"]>

<#assign importList = importList + ["org.mockito.ArgumentCaptor", "org.mockito.Captor", "org.mockito.Mock", "org.mockito.Mockito"]>

<#list importSort(importList) as import>
<#if previousImportMatch?? && !import?starts_with(previousImportMatch)>


import ${import};
<#assign previousImportMatch = import?keep_before_last(".") >

<#if importList?has_content>


<#if junit == 'junit5'>
@ExtendWith(MockitoExtension.class)
<#else>
@RunWith(MockitoJUnitRunner.class)

class ${prefixUtilityName}CheckResultImplTest {

    private ${prefixUtilityName}CheckResult checkResult;

    @<#if junit == 'junit5'>BeforeEach<#else>Before
    void setUp() {
        checkResult = new ${prefixUtilityName}CheckResultImpl();
    }

    @Test
    void testInputNull() throws SQLException {
        checkResult.check(null);
    }

    @Test
    void testInputNotNullFail() throws SQLException {
        Map map = new HashMap<<#if !diamond>String, Object>();
        checkResult.check(map);
    }

    @Test<#if junit != 'junit5'>(expected = SQLException.class)
    void testInputResponseError()<#if junit != 'junit5'> throws SQLException {
        Map map = new HashMap<<#if !diamond>String, Object>();

        map.put("${outParameterCode}", 1${successCode}1);
        map.put("${outParameterMessage}", "ERROR");

        <#if junit == 'junit5'>Assertions.assertThrows(SQLException.class,() -> checkResult.check(map)<#if junit == 'junit5'>);
    }

    @Test
    void testInputOk() throws SQLException {
        Map map = new HashMap<<#if !diamond>String, Object>();

        map.put("${outParameterCode}", ${successCode});
        map.put("${outParameterMessage}", "OK");

        checkResult.check(map);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy