@Test public void undefinedIsSentToServerMapped() throws Exception { NakadiClient client = spy(NakadiClient.newBuilder() .baseURI("http: .build()); EventResource resource = client.resources().events(); UndefinedPayload up1 = new UndefinedPayload("01", "A", "B"); UndefinedPayload up2 = new UndefinedPayload("02", "C", "D"); UndefinedEventMapped<UndefinedPayload> event1 = new UndefinedEventMapped<UndefinedPayload>().data(up1); UndefinedEventMapped<UndefinedPayload> event2 = new UndefinedEventMapped<UndefinedPayload>().data(up2); List<UndefinedEventMapped<UndefinedPayload>> list = ImmutableList.of(event1, event2); try { before(); server.enqueue(new MockResponse().setResponseCode(200)); resource.send("ue-1-1479125860", list); RecordedRequest request = server.takeRequest(); assertEquals("POST /event-types/ue-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); Type U_TYPE = new TypeToken<List<Map<String, String>>>() { }.getType(); Type M_TYPE = new TypeToken<Map<String, String>>() { }.getType(); List<Map<String, String>> sent = json.fromJson(request.getBody().readUtf8(), U_TYPE); assertEquals(2, sent.size()); Map<String, String> first = sent.get(0); Map<String, String> second = sent.get(1); Map<String, String> mFirst = json.fromJson(json.toJson(up1), M_TYPE); Map<String, String> mSecond = json.fromJson(json.toJson(up2), M_TYPE); assertEquals(mFirst, first); assertEquals(mSecond, second); } 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);  }