예제 #1
0
  @Before
  public void init() throws Exception {
    formConfig = new FormConfigImpl();

    field1 = new FieldConfigImpl();
    field1.setName("fiELd1");

    field2 = new FieldConfigImpl();
    field2.setName("field2");

    field3 = new FieldConfigImpl();
    field3.setName("FIELD3");

    field4 = new FieldConfigImpl();
    field4.setName("field4");

    group = new GroupConfigImpl();
    group.setName("group1");

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

    group2 = new GroupConfigImpl();
    group2.setName("group2");
    group2.setFieldConfigImplList(createFieldList(field2));

    group3 = new GroupConfigImpl();
    group3.setName("group3");
    group3.setFieldConfigImplList(createFieldList(field3));

    group4 = new GroupConfigImpl();
    group4.setName("group4");
    group4.setFieldConfigImplList(createFieldList(field4));
  }
예제 #2
0
  private void import_dupFields(boolean importAll) throws Exception {
    init();

    List<Import> imports;
    field3.setName("field1"); // group2.field1 duped with 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));

    if (importAll) {
      imports = createImportList(new ImportImpl("group1", null));
    } else {
      imports = createImportList(new ImportImpl("group1", "field1"));
    }

    group2.setImports(imports);
    group2.afterPropertiesSet();

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

    try {
      formConfig.afterPropertiesSet();
      fail();
    } catch (IllegalArgumentException e) {
      assertThat(e, exception("Duplicated field name: \"group2.field1\""));
    }
  }
예제 #3
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"));
  }
예제 #4
0
  @Test
  public void initFieldConfig() throws Exception {
    // no groups
    try {
      initForm((List<FieldConfigImpl>) null);
      fail();
    } catch (IllegalArgumentException e) {
      assertThat(e, exception("no fields"));
    }

    initForm(createFieldList(field1, field2, field3));

    // field.getGroupConfig()
    assertSame(group, field1.getGroupConfig());
    assertSame(group, field2.getGroupConfig());
    assertSame(group, field3.getGroupConfig());

    // field keys
    assertEquals("f", field1.getKey());
    assertEquals("fi", field2.getKey());
    assertEquals("fie", field3.getKey());
  }