FrozenHttpAdapter { public Single<RpcReply<T>> sendPostRequest( String destination, T request) { return delegate.sendPostRequest(destination, request, freezeType); } FrozenHttpAdapter(HttpAdapter delegate, Class<T> freezeType); void shutdown(); Single<RpcReply<T>> sendGetRequest(String destination); Single<RpcReply<T>> sendGetRequest(String destination, Map<String, String> headers); Single<RpcReply<T>> sendGetRequest(
            String destination,
            Duration timeout); Single<RpcReply<T>> sendGetRequest(
                String destination,
                Map<String, String> headers,
                Duration timeout); Single<RpcReply<T>> sendPostRequest(
                String destination,
                T request); Single<RpcReply<T>> sendPostRequest(
                String destination,
                Map<String, String> headers,
                T request); Single<RpcReply<T>> sendPostRequest(
                String destination,
                T request,
                Duration timeout); Single<RpcReply<T>> sendPostRequest(
                String destination,
                T request,
                Map<String, String> headers,
                Duration timeout); Single<RpcReply<T>> sendPutRequest(
                String destination,
                T request); Single<RpcReply<T>> sendPutRequest(
                String destination,
                Map<String, String> headers,
                T request); Single<RpcReply<T>> sendPutRequest(
                String destination,
                T request,
                Duration timeout); Single<RpcReply<T>> sendPutRequest(
                String destination,
                Map<String, String> headers,
                T request,
                Duration timeout); Single<RpcReply<T>> sendDeleteRequest(
                String destination,
                T request); Single<RpcReply<T>> sendDeleteRequest(
                String destination,
                Map<String, String> headers,
                T request); Single<RpcReply<T>> sendDeleteRequest(
                String destination,
                T request,
                Duration timeout); Single<RpcReply<T>> sendDeleteRequest(
                String destination,
                T request,
                Map<String, String> headers,
                Duration timeout); Single<RpcReply<T>> sendRequest(
                String destination,
                T request,
                HttpRequestMethod requestMethod); Single<RpcReply<T>> sendRequest(
                String destination,
                T request,
                Map<String, String> headers,
                HttpRequestMethod requestMethod); Single<RpcReply<T>> sendRequest(
                String destination,
                T request,
                HttpRequestMethod requestMethod,
                Duration timeout); Single<RpcReply<T>> sendRequest(
                String destination,
                T request,
                Map<String, String> headers,
                HttpRequestMethod requestMethod,
                Duration timeout);  }
@Test void invalidDestinationFormatReturnError() { TestObserver observer = sut.sendPostRequest("\\ßö ", "1.0").test(); observer.assertError(t -> t instanceof IllegalArgumentException && ((IllegalArgumentException) t).getMessage().contains("Invalid URL format")); }
@Test void notExistingDestinationReturnError() throws Exception { TestObserver<RpcReply<String>> observer = sut .sendPostRequest("http: .test(); observer.await(5, SECONDS); observer.assertError(Exception.class); }
@Test void postRequestCanBeSpecified() throws Exception { String[] requestMethodHolder = new String[1]; Pair<com.sun.net.httpserver.HttpServer, Integer> serverPortPair = httpServer("/postTest", "myPostResponse", httpExchange -> requestMethodHolder[0] = httpExchange.getRequestMethod()); TestObserver<RpcReply<String>> observer = sut .sendPostRequest("http: .test(); await().atMost(40, SECONDS).until(observer::valueCount, is(1)); RpcReply<String> reply = observer.values().get(0); assertNotNull(reply); assertThat(reply.metaData.details.statusCode, is(200)); assertThat(reply.result, is("myPostResponse")); assertThat(requestMethodHolder[0], is("POST")); }