Skip to content

Commit 708c693

Browse files
committed
Update Unit test
1 parent c914ecf commit 708c693

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

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

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

1515
import com.fasterxml.jackson.core.JsonProcessingException;
16-
import com.fasterxml.jackson.databind.JsonMappingException;
1716
import com.fasterxml.jackson.databind.ObjectMapper;
1817

1918
import io.asfjava.ui.core.GeneratorFactoryInitializer;
@@ -186,6 +185,7 @@ public void testGenerate_Password() throws JsonProcessingException {
186185

187186
String json = new ObjectMapper().writeValueAsString(ui);
188187
Assert.assertThat(json, hasJsonPath("$.schema.properties.password.title", equalTo("Password")));
188+
Assert.assertThat(json, hasJsonPath("$.schema.properties.password.pattern", equalTo("[a-z]")));
189189
Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='password')]", hasSize(1)));
190190
Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='password')].description", hasItem("This is password")));
191191
Assert.assertThat(json,
@@ -204,6 +204,7 @@ public void testGenerate_Password_WithFieldAddonLeft() throws JsonProcessingExce
204204
String json = new ObjectMapper().writeValueAsString(ui);
205205
Assert.assertThat(json, hasJsonPath("$.schema.properties.password.title",equalTo("Password")));
206206
Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='password')]",hasSize(1)));
207+
Assert.assertThat(json, hasJsonPath("$.schema.properties.password.pattern", equalTo("[a-z]")));
207208
Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='password')].description",hasItem("This is password")));
208209
Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='password')].placeholder",hasItem("Please set you password")));
209210
Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='password')].validationMessage",hasItem("this is a validation msg")));
@@ -221,6 +222,7 @@ public void testGenerate_Password_WithFieldAddonRight() throws JsonProcessingExc
221222
String json = new ObjectMapper().writeValueAsString(ui);
222223
Assert.assertThat(json, hasJsonPath("$.schema.properties.password.title",equalTo("Password")));
223224
Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='password')]",hasSize(1)));
225+
Assert.assertThat(json, hasJsonPath("$.schema.properties.password.pattern", equalTo("[a-z]")));
224226
Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='password')].description",hasItem("This is password")));
225227
Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='password')].placeholder",hasItem("Please set you password")));
226228
Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='password')].validationMessage",hasItem("this is a validation msg")));
@@ -256,6 +258,8 @@ public void testGenerate_TextArea_WithFieldAddOnLeft() throws JsonProcessingExce
256258
String json = new ObjectMapper().writeValueAsString(ui);
257259
Assert.assertThat(json, hasJsonPath("$.schema.properties.address.title", equalTo("Address")));
258260
Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='address')]", hasSize(1)));
261+
Assert.assertThat(json, hasJsonPath("$.schema.properties.address.minLenght", equalTo(6)));
262+
Assert.assertThat(json, hasJsonPath("$.schema.properties.address.maxLenght", equalTo(10)));
259263
Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='address')].description", hasItem("This is textarea")));
260264
Assert.assertThat(json,
261265
hasJsonPath("$.form[?(@.key=='address')].placeholder", hasItem("Fill your address please")));
@@ -276,13 +280,13 @@ public void testGenerate_TextArea_WithFieldAddOnRight() throws JsonProcessingExc
276280
String json = new ObjectMapper().writeValueAsString(ui);
277281
Assert.assertThat(json, hasJsonPath("$.schema.properties.address.title", equalTo("Address")));
278282
Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='address')]", hasSize(1)));
283+
Assert.assertThat(json, hasJsonPath("$.schema.properties.address.minLenght", equalTo(6)));
284+
Assert.assertThat(json, hasJsonPath("$.schema.properties.address.maxLenght", equalTo(10)));
279285
Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='address')].description", hasItem("This is textarea")));
280286
Assert.assertThat(json,
281287
hasJsonPath("$.form[?(@.key=='address')].placeholder", hasItem("Fill your address please")));
282288
Assert.assertThat(json,
283289
hasJsonPath("$.form[?(@.key=='address')].validationMessage", hasItem("this is a validation msg")));
284-
// Assert.assertThat(json,
285-
// hasJsonPath("$.form[?(@.key=='password')].type",hasItem("textArea")));
286290
Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='address')].notitle", hasItem(true)));
287291
Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='address')].readonly", hasItem(true)));
288292
Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='address')].fieldAddonRight", hasItem("@")));
@@ -387,12 +391,12 @@ public void testGenerate_TabbedFormed() throws JsonProcessingException{
387391
Assert.assertThat(json, hasJsonPath("$.form[?(@.tabs)].tabs[?(@.title=='Contact')].items[*]",hasSize(1)));
388392
Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='webSite')]"));
389393
}
390-
391394
}
395+
392396

393397
class TextFieldForm implements Serializable {
394398

395-
@TextField(title = "First Name", placeHolder = "Your first name", pattern = "[a-z]", noTitle = true, validationMessage = "this is a validation msg", description = "This is a description for your first name field", readOnly = true)
399+
@TextField(title = "First Name", placeHolder = "Your first name", pattern = "[a-z]",minLenght=6,maxLenght=10, noTitle = true, validationMessage = "this is a validation msg", description = "This is a description for your first name field", readOnly = true)
396400
private String firstName;
397401

398402
public String getFirstName() {
@@ -403,7 +407,7 @@ public String getFirstName() {
403407

404408
class TextFieldFormRight implements Serializable {
405409

406-
@TextField(title = "First Name", placeHolder = "Your first name", fieldAddonRight = "@", pattern = "[a-z]", noTitle = true, validationMessage = "this is a validation msg", description = "This is a description for your first name field")
410+
@TextField(title = "First Name", placeHolder = "Your first name", fieldAddonRight = "@", pattern = "[a-z]",minLenght=6,maxLenght=10, noTitle = true, validationMessage = "this is a validation msg", description = "This is a description for your first name field")
407411
private String firstName;
408412

409413
public String getFirstName() {
@@ -474,7 +478,7 @@ public Double getNumber() {
474478

475479
class PasswordForm implements Serializable {
476480

477-
@Password(title = "Password", placeHolder = "Please set you password", description = "This is password", noTitle = true, validationMessage = "this is a validation msg", readOnly = true)
481+
@Password(title = "Password", placeHolder = "Please set you password", pattern = "[a-z]", description = "This is password", noTitle = true, validationMessage = "this is a validation msg", readOnly = true)
478482
private String password;
479483

480484
public String getPassword() {
@@ -484,7 +488,7 @@ public String getPassword() {
484488

485489
class PasswordForm2 implements Serializable {
486490

487-
@Password(title = "Password", placeHolder = "Please set you password", fieldAddonRight = "@", description = "This is password", noTitle = true, validationMessage = "this is a validation msg", readOnly = true)
491+
@Password(title = "Password", placeHolder = "Please set you password", pattern = "[a-z]",minLenght=6,maxLenght=10, fieldAddonRight = "@", description = "This is password", noTitle = true, validationMessage = "this is a validation msg", readOnly = true)
488492
private String password;
489493

490494
public String getPassword() {
@@ -494,7 +498,7 @@ public String getPassword() {
494498

495499
class PasswordForm3 implements Serializable {
496500

497-
@Password(title = "Password", placeHolder = "Please set you password", fieldAddonLeft = "@", description = "This is password", noTitle = true, validationMessage = "this is a validation msg", readOnly = true)
501+
@Password(title = "Password", placeHolder = "Please set you password", pattern = "[a-z]",minLenght=6,maxLenght=10, fieldAddonLeft = "@", description = "This is password", noTitle = true, validationMessage = "this is a validation msg", readOnly = true)
498502
private String password;
499503

500504
public String getPassword() {
@@ -504,7 +508,7 @@ public String getPassword() {
504508

505509
class TextAreaForm2 implements Serializable {
506510

507-
@TextArea(title = "Address", placeHolder = "Fill your address please", fieldAddonLeft = "@", description = "This is textarea", noTitle = true, validationMessage = "this is a validation msg", readOnly = true)
511+
@TextArea(title = "Address", placeHolder = "Fill your address please", fieldAddonLeft = "@",minLenght=6,maxLenght=10, description = "This is textarea", noTitle = true, validationMessage = "this is a validation msg", readOnly = true)
508512
private String address;
509513

510514
public String getAddress() {
@@ -514,7 +518,7 @@ public String getAddress() {
514518

515519
class TextAreaForm3 implements Serializable {
516520

517-
@TextArea(title = "Address", placeHolder = "Fill your address please",fieldAddonRight = "@", description = "This is textarea", noTitle = true, validationMessage = "this is a validation msg", readOnly = true)
521+
@TextArea(title = "Address", placeHolder = "Fill your address please",fieldAddonRight = "@",minLenght=6,maxLenght=10, description = "This is textarea", noTitle = true, validationMessage = "this is a validation msg", readOnly = true)
518522
private String address;
519523

520524
public String getAddress() {
@@ -524,7 +528,7 @@ public String getAddress() {
524528

525529
class TextAreaForm implements Serializable {
526530

527-
@TextArea(title = "Address", placeHolder = "Fill your address please", description = "This is textarea", noTitle = true, validationMessage = "this is a validation msg", readOnly = true)
531+
@TextArea(title = "Address", placeHolder = "Fill your address please", description = "This is textarea",minLenght=6,maxLenght=10, noTitle = true, validationMessage = "this is a validation msg", readOnly = true)
528532
private String address;
529533

530534
public String getAddress() {

0 commit comments

Comments
 (0)