use of org.apache.tapestry5.http.internal.services.RestSupportImpl in project tapestry-5 by apache.
the class RestSupportImplTest method get_request_body_as_null_result.
@Test
public void get_request_body_as_null_result() {
HttpRequestBodyConverter converter = new TestHttpRequestBodyConverter(null);
RestSupport restSupport = new RestSupportImpl(null, converter);
Optional<String> result = restSupport.getRequestBodyAs(String.class);
assertFalse(result.isPresent());
}
use of org.apache.tapestry5.http.internal.services.RestSupportImpl in project tapestry-5 by apache.
the class RestSupportImplTest method get_request_body_as_result_provided.
@Test
public void get_request_body_as_result_provided() {
final String TEXT_CONTENT = "asdfadfasdfs";
HttpRequestBodyConverter converter = new TestHttpRequestBodyConverter(TEXT_CONTENT);
RestSupport restSupport = new RestSupportImpl(null, converter);
Optional<String> result = restSupport.getRequestBodyAs(String.class);
assertTrue(result.isPresent());
assertEquals(result.get(), TEXT_CONTENT);
}
use of org.apache.tapestry5.http.internal.services.RestSupportImpl in project tapestry-5 by apache.
the class RestSupportImplTest method test.
private void test(String method, byte[] body, Consumer<RestSupport> testCode) throws IOException {
HttpServletRequest request = createRequest(method, body);
RestSupport restSupport = new RestSupportImpl(request, null);
testCode.accept(restSupport);
EasyMock.verify(request);
}
Aggregations