templates.innerBuilderTestt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of JavaForger Show documentation
Show all versions of JavaForger Show documentation
JavaForger can create source code from templates using existing java classes as input.
import org.junit.Assert;
import org.junit.Test;
<#include "/test/common/imports.javat">
<#include "/test/common/staticFieldInit.javat">
@Test
public void test${class.name}_minimum() {
${class.name} ${class.name.lowerFirst} = ${class.name}.builder().build();
<#list fields as field>
<#if field.noInit == "null">
Assert.assertNull("Unexpected ${field.name}", ${class.name.lowerFirst}.${field.getter}());
<#elseif field.type == "boolean">
Assert.assertFalse("Unexpected ${field.name}", ${class.name.lowerFirst}.${field.getter}());
<#elseif field.collection>
Assert.assertTrue("Unexpected ${field.name}", ${class.name.lowerFirst}.${field.getter}().isEmpty());
<#else>
Assert.assertEquals("Unexpected ${field.name}", ${field.noInit}, ${class.name.lowerFirst}.${field.getter}());
#if>
#list>
}
@Test
public void test${class.name}_maximum() {
${class.name} ${class.name.lowerFirst} = createAndFillBuilder().build();
<#list fields as field>
<#if field.type == "boolean">
Assert.assertTrue("Unexpected ${field.name}", ${class.name.lowerFirst}.${field.getter}());
<#else>
Assert.assertEquals("Unexpected ${field.name}", ${field.name.snakeCase}, ${class.name.lowerFirst}.${field.getter}());
#if>
#list>
}
<#include "/test/common/createAndFillBuilderWithStaticFields.javat">
© 2015 - 2025 Weber Informatics LLC | Privacy Policy