Search in sources :

Example 1 with ResponseImpl

use of core.framework.impl.web.response.ResponseImpl in project core-ng-project by neowu.

the class WebServiceControllerBuilderTest method get.

@Test
void get() throws Exception {
    when(request.pathParam("id", Integer.class)).thenReturn(1);
    WebServiceControllerBuilder<TestWebService> builder = new WebServiceControllerBuilder<>(TestWebService.class, serviceImpl, TestWebService.class.getDeclaredMethod("get", Integer.class));
    Controller controller = builder.build();
    String sourceCode = builder.builder.sourceCode();
    assertEquals(ClasspathResources.text("webservice-test/test-webservice-controller-get.java"), sourceCode);
    Response response = controller.execute(request);
    assertEquals(HTTPStatus.OK, response.status());
    @SuppressWarnings("unchecked") Optional<TestWebService.TestResponse> bean = (Optional<TestWebService.TestResponse>) ((BeanBody) ((ResponseImpl) response).body).bean;
    assertEquals(2, (int) bean.get().intField);
}
Also used : Response(core.framework.web.Response) Optional(java.util.Optional) Controller(core.framework.web.Controller) ResponseImpl(core.framework.impl.web.response.ResponseImpl) Test(org.junit.jupiter.api.Test)

Aggregations

ResponseImpl (core.framework.impl.web.response.ResponseImpl)1 Controller (core.framework.web.Controller)1 Response (core.framework.web.Response)1 Optional (java.util.Optional)1 Test (org.junit.jupiter.api.Test)1