Skip to content

Commit 92d4391

Browse files
committed
✅ added test case for tabbed form
1 parent a2b83bd commit 92d4391

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;
@@ -331,6 +333,20 @@ public void testGenerate_ComboBox_WithCustomValuesContainer() throws JsonProcess
331333
hasJsonPath("$.form[?(@.key=='gender')].titleMap[?(@.name=='Female')].value", hasItem("female")));
332334

333335
}
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+
}
334350

335351
}
336352

@@ -505,3 +521,21 @@ public String getGender() {
505521
return gender;
506522
}
507523
}
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

Comments
 (0)