use of org.mockserver.model.HttpObjectCallback in project mockserver by mock-server.
the class HttpObjectCallbackDTOTest method shouldBuildObject.
@Test
public void shouldBuildObject() {
// given
String clientId = UUIDService.getUUID();
HttpObjectCallback httpObjectCallback = new HttpObjectCallback().withClientId(clientId);
// when
HttpObjectCallback builtHttpObjectCallback = new HttpObjectCallbackDTO(httpObjectCallback).buildObject();
// then
assertThat(builtHttpObjectCallback.getClientId(), is(clientId));
}
use of org.mockserver.model.HttpObjectCallback in project mockserver by mock-server.
the class HttpForwardObjectCallbackActionHandlerTest method shouldReturnNotFound.
@Test
public void shouldReturnNotFound() throws ExecutionException, InterruptedException {
// given
HttpActionHandler mockActionHandler = mock(HttpActionHandler.class);
HttpState mockHttpStateHandler = mock(HttpState.class);
WebSocketClientRegistry mockWebSocketClientRegistry = mock(WebSocketClientRegistry.class);
HttpObjectCallback httpObjectCallback = new HttpObjectCallback().withClientId("some_clientId");
HttpRequest request = request().withBody("some_body");
ResponseWriter mockResponseWriter = mock(ResponseWriter.class);
when(mockHttpStateHandler.getWebSocketClientRegistry()).thenReturn(mockWebSocketClientRegistry);
when(mockHttpStateHandler.getMockServerLogger()).thenReturn(new MockServerLogger());
when(mockWebSocketClientRegistry.sendClientMessage(eq("some_clientId"), any(HttpRequest.class), isNull())).thenReturn(false);
// when
new HttpForwardObjectCallbackActionHandler(mockHttpStateHandler, null).handle(mockActionHandler, httpObjectCallback, request, mockResponseWriter, true, null);
// then
verify(mockWebSocketClientRegistry).registerForwardCallbackHandler(any(String.class), any(WebSocketRequestCallback.class));
verify(mockWebSocketClientRegistry).sendClientMessage(eq("some_clientId"), any(HttpRequest.class), isNull());
ArgumentCaptor<HttpForwardActionResult> httpForwardActionResultArgumentCaptor = ArgumentCaptor.forClass(HttpForwardActionResult.class);
verify(mockActionHandler).writeForwardActionResponse(httpForwardActionResultArgumentCaptor.capture(), same(mockResponseWriter), same(request), same(httpObjectCallback), eq(true));
assertThat(httpForwardActionResultArgumentCaptor.getValue().getHttpResponse().get(), is(notFoundResponse()));
}
use of org.mockserver.model.HttpObjectCallback in project mockserver by mock-server.
the class HttpResponseObjectCallbackActionHandlerTest method shouldReturnNotFound.
@Test
public void shouldReturnNotFound() {
// given
HttpActionHandler mockActionHandler = mock(HttpActionHandler.class);
HttpState mockHttpStateHandler = mock(HttpState.class);
WebSocketClientRegistry mockWebSocketClientRegistry = mock(WebSocketClientRegistry.class);
HttpObjectCallback httpObjectCallback = new HttpObjectCallback().withClientId("some_clientId");
HttpRequest request = request().withBody("some_body");
ResponseWriter mockResponseWriter = mock(ResponseWriter.class);
when(mockHttpStateHandler.getWebSocketClientRegistry()).thenReturn(mockWebSocketClientRegistry);
when(mockHttpStateHandler.getMockServerLogger()).thenReturn(new MockServerLogger());
when(mockWebSocketClientRegistry.sendClientMessage(eq("some_clientId"), any(HttpRequest.class), isNull())).thenReturn(false);
// when
new HttpResponseObjectCallbackActionHandler(mockHttpStateHandler).handle(mockActionHandler, httpObjectCallback, request, mockResponseWriter, true, null);
// then
verify(mockWebSocketClientRegistry).registerResponseCallbackHandler(any(String.class), any(WebSocketResponseCallback.class));
verify(mockWebSocketClientRegistry).sendClientMessage(eq("some_clientId"), any(HttpRequest.class), isNull());
verify(mockActionHandler).writeResponseActionResponse(notFoundResponse().removeHeader(WEB_SOCKET_CORRELATION_ID_HEADER_NAME), mockResponseWriter, request, httpObjectCallback, true);
}
use of org.mockserver.model.HttpObjectCallback in project mockserver by mock-server.
the class HttpObjectCallbackDTOTest method shouldReturnValuesSetInSetter.
@Test
public void shouldReturnValuesSetInSetter() {
// given
String clientId = UUIDService.getUUID();
HttpObjectCallback httpObjectCallback = new HttpObjectCallback();
// when
HttpObjectCallbackDTO httpObjectCallbackDTO = new HttpObjectCallbackDTO(httpObjectCallback);
httpObjectCallbackDTO.setClientId(clientId);
// then
assertThat(httpObjectCallbackDTO.getClientId(), is(clientId));
}
use of org.mockserver.model.HttpObjectCallback in project mockserver by mock-server.
the class HttpObjectCallbackDTOTest method shouldHandleNullFieldInput.
@Test
public void shouldHandleNullFieldInput() {
// when
HttpObjectCallbackDTO httpObjectCallbackDTO = new HttpObjectCallbackDTO(new HttpObjectCallback());
// then
assertThat(httpObjectCallbackDTO.getClientId(), is(nullValue()));
}
Aggregations