diff --git a/src/test/java/io/asfjava/ui/core/schema/UiFormSchemaGeneratorTest.java b/src/test/java/io/asfjava/ui/core/schema/UiFormSchemaGeneratorTest.java index e8ac0ed..18e3727 100644 --- a/src/test/java/io/asfjava/ui/core/schema/UiFormSchemaGeneratorTest.java +++ b/src/test/java/io/asfjava/ui/core/schema/UiFormSchemaGeneratorTest.java @@ -13,6 +13,7 @@ import org.junit.Test; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import io.asfjava.ui.core.GeneratorFactoryInitializer; @@ -21,6 +22,7 @@ import io.asfjava.ui.core.form.Number; import io.asfjava.ui.core.form.Password; import io.asfjava.ui.core.form.RadioBox; +import io.asfjava.ui.core.form.Tab; import io.asfjava.ui.core.form.TextArea; import io.asfjava.ui.core.form.TextField; import io.asfjava.ui.dto.UiForm; @@ -331,6 +333,20 @@ public void testGenerate_ComboBox_WithCustomValuesContainer() throws JsonProcess hasJsonPath("$.form[?(@.key=='gender')].titleMap[?(@.name=='Female')].value", hasItem("female"))); } + + @Test + public void testGenerate_TabbedFormed() throws JsonProcessingException{ + UiForm ui = UiFormSchemaGenerator.get().generate(TabbedForm.class); + + String json = new ObjectMapper().writeValueAsString(ui); + Assert.assertThat(json, hasJsonPath("$.form[?(@.tabs)]")); + Assert.assertThat(json, hasJsonPath("$.form[?(@.tabs)].tabs[*]", hasSize(2))); + Assert.assertThat(json, hasJsonPath("$.form[?(@.tabs)].tabs[0].title",hasItem("Info"))); + Assert.assertThat(json, hasJsonPath("$.form[?(@.tabs)].tabs[1].title",hasItem("Contact"))); + Assert.assertThat(json, hasJsonPath("$.form[?(@.tabs)].tabs[?(@.title=='Info')].items[*]",hasSize(2))); + Assert.assertThat(json, hasJsonPath("$.form[?(@.tabs)].tabs[?(@.title=='Contact')].items[*]",hasSize(1))); + Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='webSite')]")); + } } @@ -505,3 +521,21 @@ public String getGender() { return gender; } } + +class TabbedForm implements Serializable{ + + @Tab(title = "Info", index = 1) + @TextField(title = "First Name", placeHolder = "Your first name", description = "This is a description for your first name field") + private String firstName; + + @Tab(title = "Info", index = 1) + @TextField(title = "Last Name", placeHolder = "Your last name") + private String lastName; + + @Tab(title = "Contact", index = 2) + @TextField(title = "eMail", placeHolder = "Your email", pattern = "^\\S+@\\S+$", validationMessage = "Your mail must be in this format jhondoe@example.com", description = "This is Text Field with pattern and validation message") + private String email; + + @TextField(title = "Pesonal Website",fieldAddonLeft="http://", description = "This is TextField with fieldAddonLeft") + private String webSite; +}