Search in sources :

Example 16 with Status

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());
}
Also used : Status(com.networknt.status.Status) IntegerProperty(io.swagger.models.properties.IntegerProperty) Test(org.junit.Test)

Example 17 with Status

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());
}
Also used : Status(com.networknt.status.Status) Test(org.junit.Test)

Example 18 with Status

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());
}
Also used : Status(com.networknt.status.Status) Test(org.junit.Test)

Example 19 with Status

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());
}
Also used : Status(com.networknt.status.Status) IntegerProperty(io.swagger.models.properties.IntegerProperty) Test(org.junit.Test)

Example 20 with Status

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());
}
Also used : Status(com.networknt.status.Status) Test(org.junit.Test)

Aggregations

Status (com.networknt.status.Status)71 Test (org.junit.Test)45 Http2Client (com.networknt.client.Http2Client)19 ClientException (com.networknt.exception.ClientException)19 URI (java.net.URI)19 CountDownLatch (java.util.concurrent.CountDownLatch)19 AtomicReference (java.util.concurrent.atomic.AtomicReference)19 ClientConnection (io.undertow.client.ClientConnection)17 ClientRequest (io.undertow.client.ClientRequest)17 ClientResponse (io.undertow.client.ClientResponse)17 IOException (java.io.IOException)12 FrameworkException (com.networknt.exception.FrameworkException)9 HttpString (io.undertow.util.HttpString)7 IntegerProperty (io.swagger.models.properties.IntegerProperty)4 BigDecimal (java.math.BigDecimal)4 HashMap (java.util.HashMap)4 JsonParseException (com.fasterxml.jackson.core.JsonParseException)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 JsonSchema (com.networknt.schema.JsonSchema)3 ValidationMessage (com.networknt.schema.ValidationMessage)3