9
9
import static com .relogiclabs .json .schema .message .ErrorCode .MAXI03 ;
10
10
import static com .relogiclabs .json .schema .message .ErrorCode .MINI01 ;
11
11
import static com .relogiclabs .json .schema .message .ErrorCode .MINI03 ;
12
+ import static com .relogiclabs .json .schema .message .ErrorCode .NEGI01 ;
13
+ import static com .relogiclabs .json .schema .message .ErrorCode .NEGI02 ;
14
+ import static com .relogiclabs .json .schema .message .ErrorCode .POSI01 ;
15
+ import static com .relogiclabs .json .schema .message .ErrorCode .POSI02 ;
12
16
import static org .junit .jupiter .api .Assertions .assertEquals ;
13
17
import static org .junit .jupiter .api .Assertions .assertThrows ;
14
18
@@ -111,7 +115,7 @@ public void When_WrongJsonWithNestedMaximumNumberInArray_ExceptionThrown() {
111
115
}
112
116
113
117
@ Test
114
- public void When_NestedMaximumFloatInObject_ValidTrue () {
118
+ public void When_NestedMaximumWrongFloatInObject_ExceptionThrown () {
115
119
var schema =
116
120
"""
117
121
@maximum*(100) #float*
@@ -132,7 +136,7 @@ public void When_NestedMaximumFloatInObject_ValidTrue() {
132
136
}
133
137
134
138
@ Test
135
- public void When_NestedMinimumExclusiveFloatInObject_ValidTrue () {
139
+ public void When_NestedMinimumExclusiveWrongFloatInObject_ExceptionThrown () {
136
140
var schema =
137
141
"""
138
142
@minimum*(100, true) #float*
@@ -153,7 +157,7 @@ public void When_NestedMinimumExclusiveFloatInObject_ValidTrue() {
153
157
}
154
158
155
159
@ Test
156
- public void When_NestedMaximumExclusiveFloatInObject_ValidTrue () {
160
+ public void When_NestedMaximumExclusiveWrongFloatInObject_ExceptionThrown () {
157
161
var schema =
158
162
"""
159
163
@maximum*(100, true) #float*
@@ -172,4 +176,72 @@ public void When_NestedMaximumExclusiveFloatInObject_ValidTrue() {
172
176
assertEquals (MAXI03 , exception .getCode ());
173
177
exception .printStackTrace ();
174
178
}
179
+
180
+ @ Test
181
+ public void When_NestedPositiveWithWrongNumberInArray_ExceptionThrown () {
182
+ var schema =
183
+ """
184
+ @positive* #number*
185
+ """ ;
186
+ var json =
187
+ """
188
+ [1, 100.5, -500]
189
+ """ ;
190
+ JsonSchema .isValid (schema , json );
191
+ var exception = assertThrows (JsonSchemaException .class ,
192
+ () -> JsonAssert .isValid (schema , json ));
193
+ assertEquals (POSI01 , exception .getCode ());
194
+ exception .printStackTrace ();
195
+ }
196
+
197
+ @ Test
198
+ public void When_NestedPositiveReferenceWithWrongNumberInArray_ExceptionThrown () {
199
+ var schema =
200
+ """
201
+ @positive*(0) #number*
202
+ """ ;
203
+ var json =
204
+ """
205
+ [0, 100, 0.1, -1]
206
+ """ ;
207
+ JsonSchema .isValid (schema , json );
208
+ var exception = assertThrows (JsonSchemaException .class ,
209
+ () -> JsonAssert .isValid (schema , json ));
210
+ assertEquals (POSI02 , exception .getCode ());
211
+ exception .printStackTrace ();
212
+ }
213
+
214
+ @ Test
215
+ public void When_NestedNegativeWithWrongNumberInArray_ExceptionThrown () {
216
+ var schema =
217
+ """
218
+ @negative* #number*
219
+ """ ;
220
+ var json =
221
+ """
222
+ [-100, -500, -0.1, 0]
223
+ """ ;
224
+ JsonSchema .isValid (schema , json );
225
+ var exception = assertThrows (JsonSchemaException .class ,
226
+ () -> JsonAssert .isValid (schema , json ));
227
+ assertEquals (NEGI01 , exception .getCode ());
228
+ exception .printStackTrace ();
229
+ }
230
+
231
+ @ Test
232
+ public void When_NestedNegativeReferenceWithWrongNumberInArray_ExceptionThrown () {
233
+ var schema =
234
+ """
235
+ @negative*(0) #number*
236
+ """ ;
237
+ var json =
238
+ """
239
+ [-100, -500, -0.01, 1]
240
+ """ ;
241
+ JsonSchema .isValid (schema , json );
242
+ var exception = assertThrows (JsonSchemaException .class ,
243
+ () -> JsonAssert .isValid (schema , json ));
244
+ assertEquals (NEGI02 , exception .getCode ());
245
+ exception .printStackTrace ();
246
+ }
175
247
}
0 commit comments