AnalyticsClientImpl implements AnalyticsClient { @Override public String sendAnalytics(AnalyticsEventsMessage analyticsEventsMessage) throws Exception { String jsonAnalyticsEventsMessage = _jsonObjectMapper.map( analyticsEventsMessage); if (_log.isDebugEnabled()) { _log.debug( String.format( "Sending analytics message %s to destination %s jsonAnalyticsEventsMessage, _SYSTEM_PROPERTY_VALUE_ANALYTICS_GATEWAY_PROTOCOL, _SYSTEM_PROPERTY_VALUE_ANALYTICS_GATEWAY_HOST, _SYSTEM_PROPERTY_VALUE_ANALYTICS_GATEWAY_PORT, _SYSTEM_PROPERTY_VALUE_ANALYTICS_GATEWAY_PATH)); } _jsonWebServiceClient.setHostName( _SYSTEM_PROPERTY_VALUE_ANALYTICS_GATEWAY_HOST); _jsonWebServiceClient.setHostPort( GetterUtil.getInteger( _SYSTEM_PROPERTY_VALUE_ANALYTICS_GATEWAY_PORT)); _jsonWebServiceClient.setProtocol( _SYSTEM_PROPERTY_VALUE_ANALYTICS_GATEWAY_PROTOCOL); return _jsonWebServiceClient.doPostAsJSON( _SYSTEM_PROPERTY_VALUE_ANALYTICS_GATEWAY_PATH, jsonAnalyticsEventsMessage); }  @Override String sendAnalytics(AnalyticsEventsMessage analyticsEventsMessage);  }
@Test public void testSendAnalytics() throws Exception { AnalyticsEventsMessage.Builder analyticsEventsMessageBuilder = AnalyticsEventsMessage.builder("ApplicationKey", "UserId"); analyticsEventsMessageBuilder.contextProperty("languageId", "en_US"); analyticsEventsMessageBuilder.contextProperty( "url", "http: AnalyticsEventsMessage.Event.Builder eventBuilder = AnalyticsEventsMessage.Event.builder("ApplicationId", "View"); eventBuilder.property("elementId", "banner1"); analyticsEventsMessageBuilder.event(eventBuilder.build()); analyticsEventsMessageBuilder.protocolVersion("1.0"); String response = _analyticsClientImpl.sendAnalytics( analyticsEventsMessageBuilder.build()); Assert.assertNull(response); }