Search in sources :

Example 21 with Status

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

the class IntegerParameterValidatorTest method validate_withNullValue_shouldFail_whenRequired.

@Test
public void validate_withNullValue_shouldFail_whenRequired() {
    Status status = classUnderTest.validate(null, intParam(true));
    Assert.assertNotNull(status);
    // request parameter missing
    Assert.assertEquals("ERR11001", status.getCode());
}
Also used : Status(com.networknt.status.Status) Test(org.junit.Test)

Example 22 with Status

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

the class IntegerParameterValidatorTest method validate_withValueLessThanMin_shouldFail_ifMinSpecified.

@Test
public void validate_withValueLessThanMin_shouldFail_ifMinSpecified() {
    Status status = classUnderTest.validate("0", intParam(new BigDecimal(1.0), null));
    Assert.assertNotNull(status);
    // request parameter number below min
    Assert.assertEquals("ERR11011", status.getCode());
}
Also used : Status(com.networknt.status.Status) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 23 with Status

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

the class IntegerParameterValidatorTest method validate_withNonNumericValue_shouldFail.

@Test
public void validate_withNonNumericValue_shouldFail() {
    Status status = classUnderTest.validate("123a", intParam(true));
    Assert.assertNotNull(status);
    // request parameter invalid format
    Assert.assertEquals("ERR11010", status.getCode());
}
Also used : Status(com.networknt.status.Status) Test(org.junit.Test)

Example 24 with Status

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

the class IntegerParameterValidatorTest method validate_withNonIntegerValue_shouldFail.

@Test
public void validate_withNonIntegerValue_shouldFail() {
    Status status = classUnderTest.validate("123.1", intParam(true));
    Assert.assertNotNull(status);
    // request parameter invalid format
    Assert.assertEquals("ERR11010", status.getCode());
}
Also used : Status(com.networknt.status.Status) Test(org.junit.Test)

Example 25 with Status

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

the class NumberParameterValidatorTest method validate_withNullValue_shouldFail_whenRequired.

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