templates.util.SafeDateTest.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}.${utilFolderName};
<#assign importList = ["com.github.javafaker.Faker", "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}SafeDateTest {
private Faker faker;
@<#if junit == 'junit5'>BeforeEach<#else>Before
void setUp() {
faker = new Faker();
}
@Test
void testCreate() {
<#if junit == 'junit5'>Assertions<#else>Assert.assertNotNull(new ${prefixUtilityName}SafeDate());
}
@Test
void testInputNull() {
<#if junit == 'junit5'>Assertions<#else>Assert.assertNull(${prefixUtilityName}SafeDate.process(null));
}
@Test
void testInputNotNull() {
java.util.Date date = faker.date().birthday();
java.util.Date result = ${prefixUtilityName}SafeDate.process(date);
<#if junit == 'junit5'>Assertions<#else>Assert.assertNotNull(result);
<#if junit == 'junit5'>Assertions<#else>Assert.assertNotSame(date, result);
<#if junit == 'junit5'>Assertions<#else>Assert.assertEquals(date, result);
}
}