Пример #1
0
  @Test
  public void test_build_withName() {

    FieldBuilderImpl fieldBuilder = new FieldBuilderImpl(FLists.create(1, 2, 3));

    fieldBuilder.withName("ids");

    assertEquals("ids", fieldBuilder.getName());
    assertNull(fieldBuilder.getEntityClass());

    fieldBuilder.withName("");

    assertEquals("", fieldBuilder.getName());
    assertNull(fieldBuilder.getEntityClass());

    fieldBuilder.withName(null);

    assertNull(fieldBuilder.getName());
    assertNull(fieldBuilder.getEntityClass());

    fieldBuilder = new FieldBuilderImpl(new int[] {1, 3, 5});
    fieldBuilder.withNameAndType("data", ExampleEntity.class);

    assertEquals("data", fieldBuilder.getName());
    assertEquals(ExampleEntity.class, fieldBuilder.getEntityClass());
  }
Пример #2
0
  @Test
  public void test_condition() {
    FieldBuilderImpl fieldBuilder = new FieldBuilderImpl(FLists.create(1, 2, 3));

    fieldBuilder.withName("ids");

    assertFalse(fieldBuilder.hasCondition());
    assertTrue(fieldBuilder.conditionMatched());

    fieldBuilder.withName("ids").when(1 > 2);
    ;
    assertTrue(fieldBuilder.hasCondition());
    assertFalse(fieldBuilder.conditionMatched());

    fieldBuilder.withName("ids").when(1 < 2);
    ;
    assertTrue(fieldBuilder.hasCondition());
    assertTrue(fieldBuilder.conditionMatched());

    int age = 15;
    fieldBuilder.withName("ids").unless(age < 18);
    ;
    assertTrue(fieldBuilder.hasCondition());
    assertFalse(fieldBuilder.conditionMatched());
  }
Пример #3
0
  @Test
  public void test_collection_value() {
    FieldBuilderImpl fieldBuilder = new FieldBuilderImpl(FLists.create(1, 2, 3));
    assertTrue(fieldBuilder.isCollectionValue());

    fieldBuilder = new FieldBuilderImpl(new int[] {1, 3, 5});
    assertTrue(fieldBuilder.isValueIterable());

    fieldBuilder = new FieldBuilderImpl(null);
    assertFalse(fieldBuilder.isCollectionValue());
  }
Пример #4
0
  @Test
  public void test_has_entity_type() {
    FieldBuilderImpl fieldBuilder = new FieldBuilderImpl(FLists.create(1, 2, 3));

    assertFalse(fieldBuilder.hasEntityType());

    fieldBuilder.withNameAndType("name", DetailedUserEntity.class);
    assertTrue(fieldBuilder.hasEntityType());

    fieldBuilder = new FieldBuilderImpl(new HashMap());

    assertFalse(fieldBuilder.hasEntityType());

    fieldBuilder.withNameAndType("name", DetailedUserEntity.class);
    assertFalse(fieldBuilder.hasEntityType());
  }