99import static com .relogiclabs .json .schema .message .ErrorCode .MAXI03 ;
1010import static com .relogiclabs .json .schema .message .ErrorCode .MINI01 ;
1111import 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 ;
1216import static org .junit .jupiter .api .Assertions .assertEquals ;
1317import static org .junit .jupiter .api .Assertions .assertThrows ;
1418
@@ -111,7 +115,7 @@ public void When_WrongJsonWithNestedMaximumNumberInArray_ExceptionThrown() {
111115 }
112116
113117 @ Test
114- public void When_NestedMaximumFloatInObject_ValidTrue () {
118+ public void When_NestedMaximumWrongFloatInObject_ExceptionThrown () {
115119 var schema =
116120 """
117121 @maximum*(100) #float*
@@ -132,7 +136,7 @@ public void When_NestedMaximumFloatInObject_ValidTrue() {
132136 }
133137
134138 @ Test
135- public void When_NestedMinimumExclusiveFloatInObject_ValidTrue () {
139+ public void When_NestedMinimumExclusiveWrongFloatInObject_ExceptionThrown () {
136140 var schema =
137141 """
138142 @minimum*(100, true) #float*
@@ -153,7 +157,7 @@ public void When_NestedMinimumExclusiveFloatInObject_ValidTrue() {
153157 }
154158
155159 @ Test
156- public void When_NestedMaximumExclusiveFloatInObject_ValidTrue () {
160+ public void When_NestedMaximumExclusiveWrongFloatInObject_ExceptionThrown () {
157161 var schema =
158162 """
159163 @maximum*(100, true) #float*
@@ -172,4 +176,72 @@ public void When_NestedMaximumExclusiveFloatInObject_ValidTrue() {
172176 assertEquals (MAXI03 , exception .getCode ());
173177 exception .printStackTrace ();
174178 }
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+ }
175247}
0 commit comments