templates.repository.sp.SqlQueryImplTest.ftl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of autoplsp Show documentation
Show all versions of autoplsp Show documentation
Maven plugin to generate Java classes from StoredProcedure and Functions in Database
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());
}
}