@Test public void testJsonPost() throws Exception { DirectProvider ep = new DirectProvider(); Topology topology = ep.newTopology(); final String url = "http://httpbin.org/post"; JsonObject body = new JsonObject(); body.addProperty("foo", getProp1()); body.addProperty("bar", getProp2()); TStream<JsonObject> stream = topology.collection(Arrays.asList(body)); TStream<JsonObject> rc = HttpStreams.postJson( stream, HttpClients::noAuthentication, t -> url, t -> t); TStream<Boolean> resStream = rc.map(j -> { assertTrue(j.has("request")); assertTrue(j.has("response")); JsonObject req = j.getAsJsonObject("request"); JsonObject res = j.getAsJsonObject("response"); assertTrue(res.has("status")); assertTrue(res.has("entity")); assertEquals(req, res.getAsJsonObject("entity").getAsJsonObject("json")); return true; }); rc.print(); Tester tester = topology.getTester(); Condition<List<Boolean>> endCondition = tester.streamContents(resStream, true); tester.complete(ep, new JsonObject(), endCondition, 10, TimeUnit.SECONDS); assertTrue(endCondition.getResult().toString(), endCondition.valid()); }