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

templates.repository.sp.SqlQueryImplTest.ftl Maven / Gradle / Ivy

Go to download

Maven plugin to generate Java classes from StoredProcedure and Functions in Database

There is a newer version: 1.8.20
Show newest version
package ${javaPackage}.${repositoryFolderName}.sp;
<#assign importList = ["org.springframework.jdbc.core.JdbcTemplate", "javax.sql.DataSource"]>
<#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.Test"]>
<#else>
<#assign importList = importList + ["org.junit.runner.RunWith", "org.mockito.runners.MockitoJUnitRunner", "org.junit.Assert", "org.junit.Test"]>

<#assign importList = importList + ["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 ${proc.className}SqlQueryImplTest {

    @Mock
    private DataSource dataSourceMock;

    @Mock
    private JdbcTemplate jdbcTemplateMock;

    @Test
    void should_check_${proc.constantFullName?lower_case}_sql_query_data_source() {

        Mockito.when(jdbcTemplateMock.getDataSource()).thenReturn(dataSourceMock);

        ${proc.className}SqlQueryImpl sp = new ${proc.className}SqlQueryImpl(jdbcTemplateMock);

        <#if junit == 'junit5'>Assertions<#else>Assert.assertSame(dataSourceMock, sp.getJdbcTemplate().getDataSource());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy