Skip to content

Commit c914ecf

Browse files
committed
2 parents e78677f + a37f1a2 commit c914ecf

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/test/java/io/asfjava/ui/core/schema/UiFormSchemaGeneratorTest.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.junit.Test;
1414

1515
import com.fasterxml.jackson.core.JsonProcessingException;
16+
import com.fasterxml.jackson.databind.JsonMappingException;
1617
import com.fasterxml.jackson.databind.ObjectMapper;
1718

1819
import io.asfjava.ui.core.GeneratorFactoryInitializer;
@@ -21,6 +22,7 @@
2122
import io.asfjava.ui.core.form.Number;
2223
import io.asfjava.ui.core.form.Password;
2324
import io.asfjava.ui.core.form.RadioBox;
25+
import io.asfjava.ui.core.form.Tab;
2426
import io.asfjava.ui.core.form.TextArea;
2527
import io.asfjava.ui.core.form.TextField;
2628
import io.asfjava.ui.dto.UiForm;
@@ -371,6 +373,20 @@ public void testGenerate_ComboBox_WithCustomValuesContainer() throws JsonProcess
371373
hasJsonPath("$.form[?(@.key=='gender')].titleMap[?(@.name=='Female')].value", hasItem("female")));
372374

373375
}
376+
377+
@Test
378+
public void testGenerate_TabbedFormed() throws JsonProcessingException{
379+
UiForm ui = UiFormSchemaGenerator.get().generate(TabbedForm.class);
380+
381+
String json = new ObjectMapper().writeValueAsString(ui);
382+
Assert.assertThat(json, hasJsonPath("$.form[?(@.tabs)]"));
383+
Assert.assertThat(json, hasJsonPath("$.form[?(@.tabs)].tabs[*]", hasSize(2)));
384+
Assert.assertThat(json, hasJsonPath("$.form[?(@.tabs)].tabs[0].title",hasItem("Info")));
385+
Assert.assertThat(json, hasJsonPath("$.form[?(@.tabs)].tabs[1].title",hasItem("Contact")));
386+
Assert.assertThat(json, hasJsonPath("$.form[?(@.tabs)].tabs[?(@.title=='Info')].items[*]",hasSize(2)));
387+
Assert.assertThat(json, hasJsonPath("$.form[?(@.tabs)].tabs[?(@.title=='Contact')].items[*]",hasSize(1)));
388+
Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='webSite')]"));
389+
}
374390

375391
}
376392

@@ -565,3 +581,21 @@ public String getGender() {
565581
return gender;
566582
}
567583
}
584+
585+
class TabbedForm implements Serializable{
586+
587+
@Tab(title = "Info", index = 1)
588+
@TextField(title = "First Name", placeHolder = "Your first name", description = "This is a description for your first name field")
589+
private String firstName;
590+
591+
@Tab(title = "Info", index = 1)
592+
@TextField(title = "Last Name", placeHolder = "Your last name")
593+
private String lastName;
594+
595+
@Tab(title = "Contact", index = 2)
596+
@TextField(title = "eMail", placeHolder = "Your email", pattern = "^\\S+@\\S+$", validationMessage = "Your mail must be in this format [email protected]", description = "This is Text Field with pattern and validation message")
597+
private String email;
598+
599+
@TextField(title = "Pesonal Website",fieldAddonLeft="http://", description = "This is TextField with fieldAddonLeft")
600+
private String webSite;
601+
}

0 commit comments

Comments
 (0)