KeenClient { public void addEvent(String eventCollection, Map<String, Object> event) { addEvent(eventCollection, event, null); } protected  KeenClient(Builder builder);   KeenClient(Builder builder, Environment env); static KeenClient client(); static void initialize(KeenClient client); static boolean isInitialized(); void addEvent(String eventCollection, Map<String, Object> event); void addEvent(String eventCollection, Map<String, Object> event,
                         Map<String, Object> keenProperties); void addEvent(KeenProject project, String eventCollection, Map<String, Object> event,
                         Map<String, Object> keenProperties, KeenCallback callback); void addEventAsync(String eventCollection, Map<String, Object> event); void addEventAsync(String eventCollection, Map<String, Object> event,
                              final Map<String, Object> keenProperties); void addEventAsync(final KeenProject project, final String eventCollection,
                              final Map<String, Object> event,
                              final Map<String, Object> keenProperties,
                              final KeenCallback callback); void queueEvent(String eventCollection, Map<String, Object> event); void queueEvent(String eventCollection, Map<String, Object> event,
                           Map<String, Object> keenProperties); void queueEvent(KeenProject project, String eventCollection, Map<String, Object> event,
                           Map<String, Object> keenProperties, final KeenCallback callback); void sendQueuedEvents(); void sendQueuedEvents(KeenProject project); synchronized void sendQueuedEvents(KeenProject project, KeenCallback callback); void sendQueuedEventsAsync(); void sendQueuedEventsAsync(final KeenProject project); void sendQueuedEventsAsync(final KeenProject project, final KeenCallback callback); KeenJsonHandler getJsonHandler(); KeenEventStore getEventStore(); Executor getPublishExecutor(); KeenProject getDefaultProject(); void setDefaultProject(KeenProject defaultProject); String getBaseUrl(); void setBaseUrl(String baseUrl); void setMaxAttempts(int maxAttempts); int getMaxAttempts(); GlobalPropertiesEvaluator getGlobalPropertiesEvaluator(); void setGlobalPropertiesEvaluator(GlobalPropertiesEvaluator globalPropertiesEvaluator); Map<String, Object> getGlobalProperties(); void setGlobalProperties(Map<String, Object> globalProperties); boolean isDebugMode(); void setDebugMode(boolean isDebugMode); boolean isActive(); void setProxy(String proxyHost, int proxyPort); void setProxy(Proxy proxy); Proxy getProxy();  }
@Test public void testAddEvent() throws Exception { setMockResponse(201, POST_EVENT_SUCCESS); client.addEvent(TEST_COLLECTION, TEST_EVENTS.get(0)); ArgumentCaptor<Request> capturedRequest = ArgumentCaptor.forClass(Request.class); verify(mockHttpHandler).execute(capturedRequest.capture()); assertThat(capturedRequest.getValue().url.toString(), startsWith("https: }
@Test public void testAddEventWithWhitespaceH() throws Exception{ setMockResponse(200, POST_EVENT_SUCCESS); client.addEvent(" H", TEST_EVENTS.get(0), null); ArgumentCaptor<Request> capturedRequest = ArgumentCaptor.forClass(Request.class); verify(mockHttpHandler).execute(capturedRequest.capture()); assertThat(capturedRequest.getValue().url.toString(), endsWith("%20H")); }
@Test public void testAddEventWithNameWhitespaceH() throws Exception{ setMockResponse(200, POST_EVENT_SUCCESS); client.addEvent("test test", TEST_EVENTS.get(0), null); ArgumentCaptor<Request> capturedRequest = ArgumentCaptor.forClass(Request.class); verify(mockHttpHandler).execute(capturedRequest.capture()); assertThat(capturedRequest.getValue().url.toString(), endsWith("test%20test")); }
@Test public void testAddEventWithPlus() throws Exception{ setMockResponse(200, POST_EVENT_SUCCESS); client.addEvent("Test+test", TEST_EVENTS.get(0), null); ArgumentCaptor<Request> capturedRequest = ArgumentCaptor.forClass(Request.class); verify(mockHttpHandler).execute(capturedRequest.capture()); assertThat(capturedRequest.getValue().url.toString(), endsWith("Test+test")); }
@Test(expected = ServerException.class) public void testAddEventServerFailure() throws Exception { setMockResponse(500, "Injected server error"); client.addEvent(TEST_COLLECTION, TEST_EVENTS.get(0)); }
@Test public void testAddEventWithCallback() throws Exception { setMockResponse(201, POST_EVENT_SUCCESS); final CountDownLatch latch = new CountDownLatch(1); client.addEvent(null, TEST_COLLECTION, TEST_EVENTS.get(0), null, new LatchKeenCallback(latch)); latch.await(2, TimeUnit.SECONDS); }