|
13 | 13 | import org.junit.Test;
|
14 | 14 |
|
15 | 15 | import com.fasterxml.jackson.core.JsonProcessingException;
|
| 16 | +import com.fasterxml.jackson.databind.JsonMappingException; |
16 | 17 | import com.fasterxml.jackson.databind.ObjectMapper;
|
17 | 18 |
|
18 | 19 | import io.asfjava.ui.core.GeneratorFactoryInitializer;
|
|
21 | 22 | import io.asfjava.ui.core.form.Number;
|
22 | 23 | import io.asfjava.ui.core.form.Password;
|
23 | 24 | import io.asfjava.ui.core.form.RadioBox;
|
| 25 | +import io.asfjava.ui.core.form.Tab; |
24 | 26 | import io.asfjava.ui.core.form.TextArea;
|
25 | 27 | import io.asfjava.ui.core.form.TextField;
|
26 | 28 | import io.asfjava.ui.dto.UiForm;
|
@@ -331,6 +333,20 @@ public void testGenerate_ComboBox_WithCustomValuesContainer() throws JsonProcess
|
331 | 333 | hasJsonPath("$.form[?(@.key=='gender')].titleMap[?(@.name=='Female')].value", hasItem("female")));
|
332 | 334 |
|
333 | 335 | }
|
| 336 | + |
| 337 | + @Test |
| 338 | + public void testGenerate_TabbedFormed() throws JsonProcessingException{ |
| 339 | + UiForm ui = UiFormSchemaGenerator.get().generate(TabbedForm.class); |
| 340 | + |
| 341 | + String json = new ObjectMapper().writeValueAsString(ui); |
| 342 | + Assert.assertThat(json, hasJsonPath("$.form[?(@.tabs)]")); |
| 343 | + Assert.assertThat(json, hasJsonPath("$.form[?(@.tabs)].tabs[*]", hasSize(2))); |
| 344 | + Assert.assertThat(json, hasJsonPath("$.form[?(@.tabs)].tabs[0].title",hasItem("Info"))); |
| 345 | + Assert.assertThat(json, hasJsonPath("$.form[?(@.tabs)].tabs[1].title",hasItem("Contact"))); |
| 346 | + Assert.assertThat(json, hasJsonPath("$.form[?(@.tabs)].tabs[?(@.title=='Info')].items[*]",hasSize(2))); |
| 347 | + Assert.assertThat(json, hasJsonPath("$.form[?(@.tabs)].tabs[?(@.title=='Contact')].items[*]",hasSize(1))); |
| 348 | + Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='webSite')]")); |
| 349 | + } |
334 | 350 |
|
335 | 351 | }
|
336 | 352 |
|
@@ -505,3 +521,21 @@ public String getGender() {
|
505 | 521 | return gender;
|
506 | 522 | }
|
507 | 523 | }
|
| 524 | + |
| 525 | +class TabbedForm implements Serializable{ |
| 526 | + |
| 527 | + @Tab(title = "Info", index = 1) |
| 528 | + @TextField(title = "First Name", placeHolder = "Your first name", description = "This is a description for your first name field") |
| 529 | + private String firstName; |
| 530 | + |
| 531 | + @Tab(title = "Info", index = 1) |
| 532 | + @TextField(title = "Last Name", placeHolder = "Your last name") |
| 533 | + private String lastName; |
| 534 | + |
| 535 | + @Tab(title = "Contact", index = 2) |
| 536 | + @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") |
| 537 | + private String email; |
| 538 | + |
| 539 | + @TextField(title = "Pesonal Website",fieldAddonLeft="http://", description = "This is TextField with fieldAddonLeft") |
| 540 | + private String webSite; |
| 541 | +} |
0 commit comments