use of net.morimekta.test.providence.thrift.service.Response in project providence by morimekta.
the class SocketClientHandlerTest method testSimpleRequest.
@Test
public void testSimpleRequest() throws IOException, TException, Failure {
AtomicBoolean called = new AtomicBoolean();
when(impl.test(new net.morimekta.test.thrift.thrift.service.Request("test"))).thenAnswer(i -> {
called.set(true);
return new net.morimekta.test.thrift.thrift.service.Response("response");
});
MyService.Iface client = new MyService.Client(new SocketClientHandler(serializer, address));
Response response = client.test(new Request("test"));
waitAtMost(Duration.ONE_HUNDRED_MILLISECONDS).untilTrue(called);
verify(impl).test(any(net.morimekta.test.thrift.thrift.service.Request.class));
assertThat(response, is(equalToMessage(new Response("response"))));
}
use of net.morimekta.test.providence.thrift.service.Response in project providence by morimekta.
the class NonblockingSocketClientHandlerTest method testSimpleRequest.
@Test
public void testSimpleRequest() throws IOException, TException, net.morimekta.test.providence.thrift.service.Failure {
when(impl.test(new net.morimekta.test.thrift.thrift.service.Request("test"))).thenReturn(new net.morimekta.test.thrift.thrift.service.Response("response"));
try (NonblockingSocketClientHandler handler = new NonblockingSocketClientHandler(serializer, address)) {
MyService.Iface client = new MyService.Client(handler);
Response response = client.test(Request.builder().setText("test").build());
verify(impl).test(any(net.morimekta.test.thrift.thrift.service.Request.class));
assertThat(response, is(equalToMessage(new Response("response"))));
}
}
use of net.morimekta.test.providence.thrift.service.Response in project providence by morimekta.
the class NonblockingSocketClientHandlerTest method testMultipleRequests.
@Test
public void testMultipleRequests() throws IOException, TException, net.morimekta.test.providence.thrift.service.Failure {
when(impl.test(new net.morimekta.test.thrift.thrift.service.Request("test"))).thenReturn(new net.morimekta.test.thrift.thrift.service.Response("response"));
when(impl.test(new net.morimekta.test.thrift.thrift.service.Request("test2"))).thenReturn(new net.morimekta.test.thrift.thrift.service.Response("response2"));
try (NonblockingSocketClientHandler handler = new NonblockingSocketClientHandler(serializer, address)) {
MyService.Iface client = new MyService.Client(handler);
Response response = client.test(Request.builder().setText("test").build());
Response response2 = client.test(Request.builder().setText("test2").build());
verify(impl).test(eq(new net.morimekta.test.thrift.thrift.service.Request("test")));
verify(impl).test(eq(new net.morimekta.test.thrift.thrift.service.Request("test2")));
verifyNoMoreInteractions(impl);
assertThat(response, is(equalToMessage(new Response("response"))));
assertThat(response2, is(equalToMessage(new Response("response2"))));
}
}
Aggregations