use of com.networknt.status.Status in project light-rest-4j by networknt.
the class ArrayParameterValidatorTest method validate_withTooManyValues_shouldFail_whenMaxItemsSpecified.
@Test
public void validate_withTooManyValues_shouldFail_whenMaxItemsSpecified() {
Status status = classUnderTest.validate("1,2,3,4,5,6", arrayParam(true, "csv", 3, 5, null, new IntegerProperty()));
Assert.assertNotNull(status);
// request parameter collection too many items
Assert.assertEquals("ERR11006", status.getCode());
}
use of com.networknt.status.Status in project light-rest-4j by networknt.
the class ArrayParameterValidatorTest method validate_withInvalidParameter_shouldFail.
@Test
public void validate_withInvalidParameter_shouldFail() {
Status status = classUnderTest.validate("1,2.1,3", intArrayParam(true, "csv"));
Assert.assertNotNull(status);
// validator schema
Assert.assertEquals("ERR11004", status.getCode());
}
use of com.networknt.status.Status in project light-rest-4j by networknt.
the class ArrayParameterValidatorTest method validate_withCollection_shouldFail_whenNotMultiFormat.
@Test
public void validate_withCollection_shouldFail_whenNotMultiFormat() {
Status status = classUnderTest.validate(asList("1", "2", "3"), intArrayParam(true, "csv"));
Assert.assertNotNull(status);
// request parameter collection invalid format
Assert.assertEquals("ERR11005", status.getCode());
}
use of com.networknt.status.Status in project light-rest-4j by networknt.
the class ArrayParameterValidatorTest method validate_withTooFewValues_shouldFail_whenMinItemsSpecified.
@Test
public void validate_withTooFewValues_shouldFail_whenMinItemsSpecified() {
Status status = classUnderTest.validate("1,2", arrayParam(true, "csv", 3, 5, null, new IntegerProperty()));
Assert.assertNotNull(status);
// request parameter collection too few items
Assert.assertEquals("ERR11007", status.getCode());
}
use of com.networknt.status.Status in project light-rest-4j by networknt.
the class ArrayParameterValidatorTest method validate_withNullValue_shouldFail_whenRequired.
@Test
public void validate_withNullValue_shouldFail_whenRequired() {
Status status = classUnderTest.validate((String) null, intArrayParam(true, "csv"));
Assert.assertNotNull(status);
// request parameter missing
Assert.assertEquals("ERR11001", status.getCode());
}
Aggregations