Search in sources :

Example 1 with SearchRequest

use of org.webpieces.webserver.json.app.SearchRequest in project webpieces by deanhiller.

the class TestJsonCustomFilter method testNoAttributeValueInJsonGoesToEmptyString.

@Test
public void testNoAttributeValueInJsonGoesToEmptyString() {
    // test out "something":null converts to "" in java....
    String json = "{ `meta`: { `numResults`: 4 }, `testValidation`:`notBlank` }".replace("`", "\"");
    HttpFullRequest req = Requests.createJsonRequest(KnownHttpMethod.POST, "/json/simple", json);
    XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    response.assertContentType("application/json");
    SearchRequest request = mockSvc.getCachedRequest();
    Assert.assertEquals("", request.getQuery());
    Assert.assertEquals("", request.getMeta().getExtraField());
}
Also used : HttpFullResponse(org.webpieces.httpclient11.api.HttpFullResponse) SearchRequest(org.webpieces.webserver.json.app.SearchRequest) HttpFullRequest(org.webpieces.httpclient11.api.HttpFullRequest) ResponseWrapper(org.webpieces.webserver.test.ResponseWrapper) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest) PrivateWebserverForTest(org.webpieces.webserver.PrivateWebserverForTest) Test(org.junit.Test)

Example 2 with SearchRequest

use of org.webpieces.webserver.json.app.SearchRequest in project webpieces by deanhiller.

the class TestJsonCustomFilter method testNullValueInJsonGoesToEmptyString.

@Test
public void testNullValueInJsonGoesToEmptyString() {
    // test out "something":null converts to "" in java....
    String json = "{ `query`: null, `meta`: { `numResults`: 4 }, `testValidation`:`notBlank` }".replace("`", "\"");
    HttpFullRequest req = Requests.createJsonRequest(KnownHttpMethod.POST, "/json/simple", json);
    XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    response.assertContentType("application/json");
    SearchRequest request = mockSvc.getCachedRequest();
    Assert.assertEquals("", request.getQuery());
    Assert.assertEquals("", request.getMeta().getExtraField());
}
Also used : HttpFullResponse(org.webpieces.httpclient11.api.HttpFullResponse) SearchRequest(org.webpieces.webserver.json.app.SearchRequest) HttpFullRequest(org.webpieces.httpclient11.api.HttpFullRequest) ResponseWrapper(org.webpieces.webserver.test.ResponseWrapper) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest) PrivateWebserverForTest(org.webpieces.webserver.PrivateWebserverForTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 HttpFullRequest (org.webpieces.httpclient11.api.HttpFullRequest)2 HttpFullResponse (org.webpieces.httpclient11.api.HttpFullResponse)2 PrivateWebserverForTest (org.webpieces.webserver.PrivateWebserverForTest)2 SearchRequest (org.webpieces.webserver.json.app.SearchRequest)2 AbstractWebpiecesTest (org.webpieces.webserver.test.AbstractWebpiecesTest)2 ResponseWrapper (org.webpieces.webserver.test.ResponseWrapper)2