Ejemplo n.º 1
0
  @Test
  public void extend_overrideField() throws Exception {
    field3.setName("field1"); // group2.field1 overrides group1.field1

    group1 = new GroupConfigImpl();
    group1.setName("group1");
    group1.setFieldConfigImplList(createFieldList(field1));
    group1.afterPropertiesSet();

    group2 = new GroupConfigImpl();
    group2.setName("group2");
    group2.setFieldConfigImplList(createFieldList(field2, field3));
    group2.setParentGroup("group1");
    group2.afterPropertiesSet();

    formConfig.setGroupConfigImplList(createGroupList(group1, group2));
    formConfig.afterPropertiesSet();

    assertEquals(1, group1.getFieldConfigList().size());
    assertSame(field1, group1.getFieldConfig("field1"));

    assertEquals(2, group2.getFieldConfigList().size());
    assertSame(field3, group2.getFieldConfig("field1"));
    assertSame(field2, group2.getFieldConfig("field2"));
  }
Ejemplo n.º 2
0
  @Test
  public void getParentGroup() {
    // no key
    assertNull(group.getParentGroup());

    // empty key
    group.setParentGroup("");
    assertNull(group.getParentGroup());

    group.setParentGroup("  ");
    assertNull(group.getParentGroup());

    // normal key
    group.setParentGroup("  hello ");
    assertEquals("hello", group.getParentGroup());
  }
Ejemplo n.º 3
0
  private void assertPostOnly(Boolean parentValue, Boolean overrideValue, boolean expectedValue)
      throws Exception {
    init();

    if (parentValue != null) {
      group1.setPostOnly(parentValue);
    }

    group1.afterPropertiesSet();

    if (overrideValue != null) {
      group2.setPostOnly(overrideValue);
    }

    group2.setParentGroup("group1");
    group2.afterPropertiesSet();

    formConfig.setGroupConfigImplList(createGroupList(group1, group2));
    formConfig.afterPropertiesSet();

    assertEquals(expectedValue, group2.isPostOnly());
  }