use of com.newrelic.agent.model.AnalyticsEvent in project newrelic-java-agent by newrelic.
the class TransactionEventTest method testJSON.
@Test
public void testJSON() throws Exception {
float duration = 0.001931f;
AnalyticsEvent event = baseBuilder(duration).build();
JSONArray jsonArray = (JSONArray) AgentHelper.serializeJSON(event);
assertEquals(1, jsonArray.size());
JSONObject jsonObject = (JSONObject) jsonArray.get(0);
assertEquals(9, jsonObject.size());
assertEquals(startTime, jsonObject.get("timestamp"));
assertEquals(metricName, jsonObject.get("name"));
assertEquals(duration, ((Number) jsonObject.get("duration")).floatValue(), Float.NaN);
assertEquals("Transaction", jsonObject.get("type"));
assertEquals(duration, ((Number) jsonObject.get("totalTime")).floatValue(), Float.NaN);
assertEquals(.25, ((Number) jsonObject.get("priority")).floatValue(), Float.NaN);
}
use of com.newrelic.agent.model.AnalyticsEvent in project newrelic-java-agent by newrelic.
the class TransactionEventTest method testJSONDTIntrinsics.
@Test
public void testJSONDTIntrinsics() throws Exception {
float duration = 0.001931f;
AnalyticsEvent event = baseBuilder(duration).setDistributedTraceIntrinsics(Collections.<String, Object>singletonMap("dt-intrinsic", "yup")).build();
JSONArray jsonArray = (JSONArray) AgentHelper.serializeJSON(event);
assertEquals(1, jsonArray.size());
JSONObject intrinsicsJson = (JSONObject) jsonArray.get(0);
assertEquals("yup", intrinsicsJson.get("dt-intrinsic"));
}
Aggregations