@Test
public void testJSONSerialization() throws Exception {

	AnalyticsEventsMessage.Builder messageBuilder =
		AnalyticsEventsMessage.builder("DataSourceId", "UserId");
	messageBuilder.contextProperty("k1", "v1");
	messageBuilder.contextProperty("k2", "v2");
	AnalyticsEventsMessage.Event.Builder eventBuilder =
		AnalyticsEventsMessage.Event.builder("ApplicationId", "View");
	eventBuilder.property("k1", "v1");
	eventBuilder.property("k2", "v2");
	AnalyticsEventsMessage.Event event = eventBuilder.build();
	messageBuilder.event(event);
	messageBuilder.protocolVersion("1.0");
	String expectedJSON = read("analytics_events_message.json");
	expectedJSON = StringUtil.replace(
		expectedJSON, "2017-11-20T19:52:56.723Z",
		ISO8601Utils.format(event.getEventDate(), true));
	String actualJSON = _jsonObjectMapper.map(messageBuilder.build());
	JSONAssert.assertEquals(expectedJSON, actualJSON, false);
}