|
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;
|
@@ -371,6 +373,20 @@ public void testGenerate_ComboBox_WithCustomValuesContainer() throws JsonProcess
|
371 | 373 | hasJsonPath("$.form[?(@.key=='gender')].titleMap[?(@.name=='Female')].value", hasItem("female")));
|
372 | 374 |
|
373 | 375 | }
|
| 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 | + } |
374 | 390 |
|
375 | 391 | }
|
376 | 392 |
|
@@ -565,3 +581,21 @@ public String getGender() {
|
565 | 581 | return gender;
|
566 | 582 | }
|
567 | 583 | }
|
| 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