package com.celements.model.classes.fields;

import static org.junit.Assert.*;
import static org.mutabilitydetector.unittesting.MutabilityAssert.*;

import org.junit.Before;
import org.junit.Test;

import com.celements.common.test.AbstractComponentTest;
import com.celements.model.classes.TestClassDefinition;
import com.xpn.xwiki.objects.classes.BooleanClass;

public class BooleanFieldTest extends AbstractComponentTest {

  private BooleanField field;

  String displayType = "displayType";
  Integer defaultValue = 5;

  @Before
  public void prepareTest() throws Exception {
    field = new BooleanField.Builder(TestClassDefinition.NAME, "name").displayType(
        displayType).defaultValue(defaultValue).build();
  }

  @Test
  public void test_immutability() {
    assertImmutable(BooleanField.class);
  }

  @Test
  public void test_getters() throws Exception {
    assertEquals(displayType, field.getDisplayType());
    assertEquals(defaultValue, field.getDefaultValue());
  }

  @Test
  public void test_getXField() throws Exception {
    assertTrue(field.getXField() instanceof BooleanClass);
    BooleanClass xField = (BooleanClass) field.getXField();
    assertEquals(field.getName(), xField.getName());
    assertEquals(displayType, xField.getDisplayType());
    assertEquals(defaultValue, (Integer) xField.getDefaultValue());
  }

  @Test
  public void test_serialize() throws Exception {
    assertNull(field.serialize(null));
    assertEquals(1, field.serialize(true));
    assertEquals(0, field.serialize(false));
  }

  @Test
  public void test_resolve() throws Exception {
    assertNull(field.resolve(null));
    assertEquals(true, field.resolve(1));
    assertEquals(true, field.resolve(5));
    assertEquals(false, field.resolve(0));
  }
}

@@ -449,16 +449,53 @@
 field;%0A%0A
+  String displayFormType = %22select%22;%0A
   String
@@ -524,16 +524,16 @@
 yType%22;%0A
-
   Intege
@@ -742,16 +742,49 @@
 tValue).
+displayFormType(displayFormType).
 build();
@@ -1039,32 +1039,95 @@
 efaultValue());%0A
+    assertEquals(displayFormType, field.getDisplayFormType());%0A
   %7D%0A%0A  @Test%0A  p
@@ -1393,32 +1393,32 @@
 DisplayType());%0A
-
     assertEquals
@@ -1465,24 +1465,88 @@
 ltValue());%0A
+    assertEquals(displayFormType, xField.getDisplayFormType());%0A
   %7D%0A%0A  @Test

add displayFormType to tests