@Test public void businessIsSentToServerMapped() throws Exception { NakadiClient client = spy(NakadiClient.newBuilder() .baseURI("http: .build()); EventResource resource = client.resources().events(); BusinessPayload bp = new BusinessPayload("22", "A", "B"); BusinessEventMapped<BusinessPayload> event = new BusinessEventMapped<BusinessPayload>() .metadata(EventMetadata.newPreparedEventMetadata()) .data(bp); try { before(); server.enqueue(new MockResponse().setResponseCode(200)); resource.send("be-1-1479125860", event); RecordedRequest request = server.takeRequest(); assertEquals("POST /event-types/be-1-1479125860/events HTTP/1.1", request.getRequestLine()); assertEquals("application/json; charset=utf8", request.getHeaders().get("Content-Type")); assertEquals(NakadiClient.USER_AGENT, request.getHeaders().get("User-Agent")); TestCase.assertTrue(request.getHeaders().get("X-Flow-Id") != null); String body = request.getBody().readUtf8(); Type U_TYPE = new TypeToken<List<Map<String, Object>>>() { }.getType(); List<Map<String, Object>> sent = json.fromJson(body, U_TYPE); assertEquals(1, sent.size()); Map<String, Object> businessAsMap = sent.get(0); assertEquals(4, businessAsMap.size()); assertEquals("22", businessAsMap.get("id")); assertEquals("A", businessAsMap.get("a")); assertEquals("B", businessAsMap.get("b")); assertEquals(3, ((Map)businessAsMap.get("metadata")).size()); assertTrue(((Map)businessAsMap.get("metadata")).containsKey("eid")); assertTrue(((Map)businessAsMap.get("metadata")).containsKey("occurred_at")); assertTrue(((Map)businessAsMap.get("metadata")).containsKey("flow_id")); assertTrue(((Map)businessAsMap.get("metadata")).get("flow_id").toString().startsWith("njc")); } finally { after(); } }
@Override public final <T> Response send(String eventTypeName, Collection<T> events) { return send(eventTypeName,events, SENTINEL_HEADERS); }
EventResourceReal implements EventResource { @Override public final <T> Response send(String eventTypeName, Collection<T> events) { return send(eventTypeName,events, SENTINEL_HEADERS); } }
EventResourceReal implements EventResource { @Override public final <T> Response send(String eventTypeName, Collection<T> events) { return send(eventTypeName,events, SENTINEL_HEADERS); } EventResourceReal(NakadiClient client); @VisibleForTesting  EventResourceReal(NakadiClient client, JsonSupport jsonSupport); }
EventResourceReal implements EventResource { @Override public final <T> Response send(String eventTypeName, Collection<T> events) { return send(eventTypeName,events, SENTINEL_HEADERS); } EventResourceReal(NakadiClient client); @VisibleForTesting  EventResourceReal(NakadiClient client, JsonSupport jsonSupport); @Deprecated @Override EventResource scope(String scope); @Override EventResource retryPolicy(RetryPolicy retryPolicy); @Override EventResource flowId(final String flowId); @Override final Response send(String eventTypeName, Collection<T> events); @Override Response send(String eventTypeName, Collection<T> events,
      Map<String, Object> headers); @Override Response send(String eventTypeName, T event); @Override Response send(String eventTypeName, T event, Map<String, Object> headers); @Override BatchItemResponseCollection sendBatch(String eventTypeName, List<T> events); @Override BatchItemResponseCollection sendBatch(String eventTypeName, List<T> events,
      Map<String, Object> headers); }
EventResourceReal implements EventResource { @Override public final <T> Response send(String eventTypeName, Collection<T> events) { return send(eventTypeName,events, SENTINEL_HEADERS); } EventResourceReal(NakadiClient client); @VisibleForTesting  EventResourceReal(NakadiClient client, JsonSupport jsonSupport); @Deprecated @Override EventResource scope(String scope); @Override EventResource retryPolicy(RetryPolicy retryPolicy); @Override EventResource flowId(final String flowId); @Override final Response send(String eventTypeName, Collection<T> events); @Override Response send(String eventTypeName, Collection<T> events,
      Map<String, Object> headers); @Override Response send(String eventTypeName, T event); @Override Response send(String eventTypeName, T event, Map<String, Object> headers); @Override BatchItemResponseCollection sendBatch(String eventTypeName, List<T> events); @Override BatchItemResponseCollection sendBatch(String eventTypeName, List<T> events,
      Map<String, Object> headers);  }