@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"));
  }
  @Test
  public void getFieldConfigList() throws Exception {
    // default, empty
    assertTrue(group.getFieldConfigList().isEmpty());

    // field name is null
    try {
      initForm(createFieldList(new FieldConfigImpl()));
      fail();
    } catch (IllegalArgumentException e) {
      assertThat(e, exception("name"));
    }

    // set fields
    initForm(createFieldList(field1, field2, field3));

    assertEquals(3, group.getFieldConfigList().size());
    assertArrayEquals(new Object[] {field1, field2, field3}, group.getFieldConfigList().toArray());

    // set null
    initForm((List<FieldConfigImpl>) null);
    assertEquals(3, group.getFieldConfigList().size());

    // set empty
    initForm(new ArrayList<FieldConfigImpl>());
    assertEquals(0, group.getFieldConfigList().size());

    // unmodifiable
    try {
      group.getFieldConfigList().clear();
      fail();
    } catch (UnsupportedOperationException e) {
    }

    // set duplicated fields
    try {
      initForm(createFieldList(field1, field2, field1));
      fail();
    } catch (IllegalArgumentException e) {
      assertThat(e, exception("Duplicated field name: \"group1.fiELd1\""));
    }
  }