@@ -78,7 +78,8 @@ public void testGenerate_textField_WithFieldAddonLeft() throws JsonProcessingExc
78
78
Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='firstName')].fieldAddonLeft" ,hasItem ("@" )));
79
79
80
80
}
81
-
81
+
82
+
82
83
@ Test
83
84
public void testGenerate_Number () throws JsonProcessingException {
84
85
UiForm ui = UiFormSchemaGenerator .get ().generate (NumberForm .class );
@@ -93,6 +94,38 @@ public void testGenerate_Number() throws JsonProcessingException {
93
94
Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='number')].readonly" ,hasItem (true )));
94
95
95
96
}
97
+
98
+ @ Test
99
+ public void testGenerate_Number_WithRightAddon () throws JsonProcessingException {
100
+ UiForm ui = UiFormSchemaGenerator .get ().generate (NumberForm2 .class );
101
+ String json = new ObjectMapper ().writeValueAsString (ui );
102
+ //Assert.assertThat(json, hasJsonPath("$.schema.properties.number.title",equalTo("Number")));
103
+ Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='number')]" ,hasSize (1 )));
104
+ Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='number')].description" ,hasItem ("This is a number" )));
105
+ Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='number')].placeholder" ,hasItem ("Number of children" )));
106
+ Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='number')].validationMessage" ,hasItem ("this is a validation msg" )));
107
+ Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='number')].type" ,hasItem ("number" )));
108
+ Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='number')].notitle" ,hasItem (true )));
109
+ Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='number')].readonly" ,hasItem (true )));
110
+ Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='number')].fieldAddonRight" ,hasItem ("@" )));
111
+
112
+ }
113
+
114
+ @ Test
115
+ public void testGenerate_Number_WithLeftAddon () throws JsonProcessingException {
116
+ UiForm ui = UiFormSchemaGenerator .get ().generate (NumberForm3 .class );
117
+ String json = new ObjectMapper ().writeValueAsString (ui );
118
+ //Assert.assertThat(json, hasJsonPath("$.schema.properties.number.title",equalTo("Number")));
119
+ Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='number')]" ,hasSize (1 )));
120
+ Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='number')].description" ,hasItem ("This is a number" )));
121
+ Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='number')].placeholder" ,hasItem ("Number of children" )));
122
+ Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='number')].validationMessage" ,hasItem ("this is a validation msg" )));
123
+ Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='number')].type" ,hasItem ("number" )));
124
+ Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='number')].notitle" ,hasItem (true )));
125
+ Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='number')].readonly" ,hasItem (true )));
126
+ Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='number')].fieldAddonLeft" ,hasItem ("@" )));
127
+
128
+ }
96
129
97
130
@ Test
98
131
public void testGenerate_Password () throws JsonProcessingException {
@@ -108,6 +141,40 @@ public void testGenerate_Password() throws JsonProcessingException {
108
141
Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='password')].notitle" ,hasItem (true )));
109
142
Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='password')].readonly" ,hasItem (true )));
110
143
}
144
+
145
+ @ Test
146
+ public void testGenerate_Password_WithFieldAddonLeft () throws JsonProcessingException {
147
+ UiForm ui = UiFormSchemaGenerator .get ().generate (PasswordForm3 .class );
148
+
149
+ String json = new ObjectMapper ().writeValueAsString (ui );
150
+ Assert .assertThat (json , hasJsonPath ("$.schema.properties.password.title" ,equalTo ("Password" )));
151
+ Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='password')]" ,hasSize (1 )));
152
+ Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='password')].description" ,hasItem ("This is password" )));
153
+ Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='password')].placeholder" ,hasItem ("Please set you password" )));
154
+ Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='password')].validationMessage" ,hasItem ("this is a validation msg" )));
155
+ Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='password')].type" ,hasItem ("password" )));
156
+ Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='password')].notitle" ,hasItem (true )));
157
+ Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='password')].readonly" ,hasItem (true )));
158
+ Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='password')].fieldAddonLeft" ,hasItem ("@" )));
159
+
160
+ }
161
+
162
+ @ Test
163
+ public void testGenerate_Password_WithFieldAddonRight () throws JsonProcessingException {
164
+ UiForm ui = UiFormSchemaGenerator .get ().generate (PasswordForm2 .class );
165
+
166
+ String json = new ObjectMapper ().writeValueAsString (ui );
167
+ Assert .assertThat (json , hasJsonPath ("$.schema.properties.password.title" ,equalTo ("Password" )));
168
+ Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='password')]" ,hasSize (1 )));
169
+ Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='password')].description" ,hasItem ("This is password" )));
170
+ Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='password')].placeholder" ,hasItem ("Please set you password" )));
171
+ Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='password')].validationMessage" ,hasItem ("this is a validation msg" )));
172
+ Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='password')].type" ,hasItem ("password" )));
173
+ Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='password')].notitle" ,hasItem (true )));
174
+ Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='password')].readonly" ,hasItem (true )));
175
+ Assert .assertThat (json , hasJsonPath ("$.form[?(@.key=='password')].fieldAddonRight" ,hasItem ("@" )));
176
+
177
+ }
111
178
112
179
@ Test
113
180
public void testGenerate_TextArea () throws JsonProcessingException {
@@ -243,6 +310,26 @@ public Integer getNumber() {
243
310
}
244
311
}
245
312
313
+ class NumberForm2 implements Serializable {
314
+
315
+ @ Number (title = "Number of children" , placeHolder = "Number of children" , fieldAddonRight = "@" , description = "This is a number" , noTitle = true , validationMessage = "this is a validation msg" , readOnly = true )
316
+ private Integer number ;
317
+
318
+ public Integer getNumber () {
319
+ return number ;
320
+ }
321
+ }
322
+
323
+ class NumberForm3 implements Serializable {
324
+
325
+ @ Number (title = "Number of children" , placeHolder = "Number of children" , fieldAddonLeft = "@" , description = "This is a number" , noTitle = true , validationMessage = "this is a validation msg" , readOnly = true )
326
+ private Integer number ;
327
+
328
+ public Integer getNumber () {
329
+ return number ;
330
+ }
331
+ }
332
+
246
333
class PasswordForm implements Serializable {
247
334
248
335
@ Password (title = "Password" , placeHolder = "Please set you password" , description = "This is password" , noTitle = true , validationMessage = "this is a validation msg" , readOnly = true )
@@ -253,6 +340,26 @@ public String getPassword() {
253
340
}
254
341
}
255
342
343
+ class PasswordForm2 implements Serializable {
344
+
345
+ @ Password (title = "Password" , placeHolder = "Please set you password" , fieldAddonRight = "@" , description = "This is password" , noTitle = true , validationMessage = "this is a validation msg" , readOnly = true )
346
+ private String password ;
347
+
348
+ public String getPassword () {
349
+ return password ;
350
+ }
351
+ }
352
+
353
+ class PasswordForm3 implements Serializable {
354
+
355
+ @ Password (title = "Password" , placeHolder = "Please set you password" , fieldAddonLeft = "@" , description = "This is password" , noTitle = true , validationMessage = "this is a validation msg" , readOnly = true )
356
+ private String password ;
357
+
358
+ public String getPassword () {
359
+ return password ;
360
+ }
361
+ }
362
+
256
363
class TextAreaForm implements Serializable {
257
364
258
365
@ TextArea (title = "Address" , placeHolder = "Fill your address please" , description = "This is textarea" , noTitle = true , validationMessage = "this is a validation msg" , readOnly = true )
0 commit comments