Beispiel #1
0
  private void initForm(List<FieldConfigImpl> fieldList) throws Exception {
    group.setFieldConfigImplList(fieldList);
    group.afterPropertiesSet();

    formConfig.setGroupConfigImplList(createGroupList(group));
    formConfig.afterPropertiesSet();
  }
Beispiel #2
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"));
  }
Beispiel #3
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\""));
    }
  }
Beispiel #4
0
  @Test
  public void import_fieldNotFound() throws Exception {
    group2.setImports(createImportList(new ImportImpl("group1", "notExistField")));

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

    try {
      formConfig.afterPropertiesSet();
      fail();
    } catch (IllegalArgumentException e) {
      assertThat(e, exception("Field \"group1.notExistField\" not found"));
    }
  }
Beispiel #5
0
  @Test
  public void isPostOnly() throws Exception {
    // default, no form config
    assertTrue(group.isPostOnly());

    // default, with form config
    initForm(createFieldList(field1));

    formConfig.setPostOnlyByDefault(false);
    assertFalse(group.isPostOnly());

    formConfig.setPostOnlyByDefault(true);
    assertTrue(group.isPostOnly());

    // set value
    group.setPostOnly(false);
    assertFalse(group.isPostOnly());
  }
Beispiel #6
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());
  }