예제 #1
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());
  }
예제 #2
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());
  }