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

templates.innerBuilderTestt Maven / Gradle / Ivy

Go to download

JavaForger can create source code from templates using existing java classes as input.

There is a newer version: 2.0.1
Show newest version
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}());


  }

  @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}());


  }

<#include "/test/common/createAndFillBuilderWithStaticFields.javat">




© 2015 - 2025 Weber Informatics LLC | Privacy Policy