Search in sources :

Example 61 with Status

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

the class IntegerParameterValidatorTest method validate_withValueGreaterThanMax_shouldFail_ifMaxSpecified.

@Test
public void validate_withValueGreaterThanMax_shouldFail_ifMaxSpecified() {
    Status status = classUnderTest.validate("2", intParam(null, new BigDecimal(1.0)));
    Assert.assertNotNull(status);
    // request parameter number above max
    Assert.assertEquals("ERR11012", status.getCode());
}
Also used : Status(com.networknt.status.Status) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 62 with Status

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

the class NumberParameterValidatorTest method validate_withNonNumericValue_shouldFail.

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

Example 63 with Status

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

the class NumberParameterValidatorTest method validate_withValueLessThanMin_shouldFail_ifMinSpecified.

@Test
public void validate_withValueLessThanMin_shouldFail_ifMinSpecified() {
    Status status = classUnderTest.validate("0.9", floatParam(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 64 with Status

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

the class NumberParameterValidatorTest method validate_withEmptyValue_shouldFail_whenRequired.

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

Example 65 with Status

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

the class ParameterValidatorsTest method validate_withInvalidIntegerParam_shouldFail.

@Test
public void validate_withInvalidIntegerParam_shouldFail() {
    Status status = parameterValidators.validate("1.0", intParam());
    Assert.assertNotNull(status);
    // request parameter invalid format
    Assert.assertEquals("ERR11010", 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