Search in sources :

Example 56 with Status

use of com.networknt.status.Status in project light-rest-4j by networknt.

the class ArrayParameterValidatorTest method validate_withNonUniqueValues_shouldFail_whenUniqueSpecified.

@Test
public void validate_withNonUniqueValues_shouldFail_whenUniqueSpecified() {
    Status status = classUnderTest.validate("1,2,1", arrayParam(true, "csv", null, null, true, new IntegerProperty()));
    Assert.assertNotNull(status);
    // request parameter collection duplicate items
    Assert.assertEquals("ERR11008", status.getCode());
}
Also used : Status(com.networknt.status.Status) IntegerProperty(io.swagger.models.properties.IntegerProperty) Test(org.junit.Test)

Example 57 with Status

use of com.networknt.status.Status in project light-rest-4j by networknt.

the class ArrayParameterValidatorTest method validate_withEnumValues_shouldFail_whenValueDoesntMatchEnum.

@Test
public void validate_withEnumValues_shouldFail_whenValueDoesntMatchEnum() {
    Status status = classUnderTest.validate("1,2,1,4", enumeratedArrayParam(true, "csv", new IntegerProperty(), "1", "2", "bob"));
    Assert.assertNotNull(status);
    // request parameter collection duplicate items
    Assert.assertEquals("ERR11009", status.getCode());
}
Also used : Status(com.networknt.status.Status) IntegerProperty(io.swagger.models.properties.IntegerProperty) Test(org.junit.Test)

Example 58 with Status

use of com.networknt.status.Status in project light-rest-4j by networknt.

the class ArrayParameterValidatorTest method validate_withEmptyValue_shouldFail_whenRequired.

@Test
public void validate_withEmptyValue_shouldFail_whenRequired() {
    Status status = classUnderTest.validate("", 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)

Example 59 with Status

use of com.networknt.status.Status in project light-rest-4j by networknt.

the class ArrayParameterValidatorTest method validate_withInvalidCollectionParameter_shouldFail.

@Test
public void validate_withInvalidCollectionParameter_shouldFail() {
    Status status = classUnderTest.validate(asList("1", "2.1", "3"), intArrayParam(true, "multi"));
    Assert.assertNotNull(status);
    // validator schema
    Assert.assertEquals("ERR11004", status.getCode());
}
Also used : Status(com.networknt.status.Status) Test(org.junit.Test)

Example 60 with Status

use of com.networknt.status.Status in project light-rest-4j by networknt.

the class IntegerParameterValidatorTest method validate_withEmptyValue_shouldFail_whenRequired.

@Test
public void validate_withEmptyValue_shouldFail_whenRequired() {
    Status status = classUnderTest.validate("", intParam(true));
    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