use of com.microsoft.applicationinsights.smoketest.schemav2.PageViewData in project ApplicationInsights-Java by microsoft.
the class CoreAndFilterTests method testTrackPageViewJsp.
@Test
@TargetUri("/doPageView.jsp")
public void testTrackPageViewJsp() throws Exception {
List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
Envelope rdEnvelope = rdList.get(0);
String operationId = rdEnvelope.getTags().get("ai.operation.id");
List<Envelope> pvdList = mockedIngestion.waitForItemsInOperation("PageViewData", 1, operationId);
assertEquals(0, mockedIngestion.getCountForType("EventData"));
Envelope pvdEnvelope = pvdList.get(0);
RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
PageViewData pv = (PageViewData) ((Data<?>) pvdEnvelope.getData()).getBaseData();
assertEquals("doPageView", pv.getName());
assertEquals(new Duration(0), pv.getDuration());
assertParentChild(rd, rdEnvelope, pvdEnvelope, "GET /CoreAndFilter/doPageView.jsp");
}
use of com.microsoft.applicationinsights.smoketest.schemav2.PageViewData in project ApplicationInsights-Java by microsoft.
the class CoreAndFilterTests method testTrackPageView.
@Test
@TargetUri("/trackPageView")
public void testTrackPageView() throws Exception {
List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
Envelope rdEnvelope = rdList.get(0);
List<Envelope> pvdList = mockedIngestion.waitForItems("PageViewData", 3);
assertEquals(0, mockedIngestion.getCountForType("EventData"));
RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
Envelope pvdEnvelope1 = null;
Envelope pvdEnvelope2 = null;
Envelope pvdEnvelope3 = null;
for (Envelope pvdEnvelope : pvdList) {
PageViewData pv = (PageViewData) ((Data<?>) pvdEnvelope.getData()).getBaseData();
if (pv.getName().equals("test-page")) {
pvdEnvelope1 = pvdEnvelope;
} else if (pv.getName().equals("test-page-2")) {
pvdEnvelope2 = pvdEnvelope;
} else if (pv.getName().equals("test-page-3")) {
pvdEnvelope3 = pvdEnvelope;
} else {
throw new AssertionError("Unexpected page view: " + pv.getName());
}
}
PageViewData pv1 = (PageViewData) ((Data<?>) pvdEnvelope1.getData()).getBaseData();
PageViewData pv2 = (PageViewData) ((Data<?>) pvdEnvelope2.getData()).getBaseData();
PageViewData pv3 = (PageViewData) ((Data<?>) pvdEnvelope3.getData()).getBaseData();
assertNotNull(pv1);
assertEquals(new Duration(0), pv1.getDuration());
// checking that instrumentation key, cloud role name, cloud role instance, and sdk version are
// from the agent
assertEquals("00000000-0000-0000-0000-0FEEDDADBEEF", pvdEnvelope1.getIKey());
assertEquals("testrolename", pvdEnvelope1.getTags().get("ai.cloud.role"));
assertEquals("testroleinstance", pvdEnvelope1.getTags().get("ai.cloud.roleInstance"));
assertTrue(pvdEnvelope1.getTags().get("ai.internal.sdkVersion").startsWith("java:3."));
assertNotNull(pv2);
assertEquals(new Duration(123456), pv2.getDuration());
assertEquals("2010-10-10T00:00:00Z", pvdEnvelope2.getTime());
assertEquals("value", pv2.getProperties().get("key"));
assertEquals("a-value", pv2.getProperties().get("a-prop"));
assertEquals("another-value", pv2.getProperties().get("another-prop"));
// operation name is verified below in assertParentChild()
assertEquals("user-id-goes-here", pvdEnvelope2.getTags().get("ai.user.id"));
assertEquals("account-id-goes-here", pvdEnvelope2.getTags().get("ai.user.accountId"));
assertEquals("user-agent-goes-here", pvdEnvelope2.getTags().get("ai.user.userAgent"));
assertEquals("os-goes-here", pvdEnvelope2.getTags().get("ai.device.os"));
assertEquals("session-id-goes-here", pvdEnvelope2.getTags().get("ai.session.id"));
assertEquals("1.2.3.4", pvdEnvelope2.getTags().get("ai.location.ip"));
// checking that instrumentation key, cloud role name and cloud role instance are overridden
assertEquals("12341234-1234-1234-1234-123412341234", pvdEnvelope2.getIKey());
assertEquals("role-goes-here", pvdEnvelope2.getTags().get("ai.cloud.role"));
assertEquals("role-instance-goes-here", pvdEnvelope2.getTags().get("ai.cloud.roleInstance"));
// checking that sdk version is from the agent
assertTrue(pvdEnvelope2.getTags().get("ai.internal.sdkVersion").startsWith("java:3."));
assertNotNull(pv3);
assertEquals(new Duration(123456), pv3.getDuration());
assertEquals("2010-10-10T00:00:00Z", pvdEnvelope3.getTime());
assertEquals("value", pv3.getProperties().get("key"));
assertEquals("a-value", pv3.getProperties().get("a-prop"));
assertEquals("another-value", pv3.getProperties().get("another-prop"));
// operation name is verified below in assertParentChild()
assertEquals("user-id-goes-here", pvdEnvelope3.getTags().get("ai.user.id"));
assertEquals("account-id-goes-here", pvdEnvelope3.getTags().get("ai.user.accountId"));
assertEquals("user-agent-goes-here", pvdEnvelope3.getTags().get("ai.user.userAgent"));
assertEquals("os-goes-here", pvdEnvelope3.getTags().get("ai.device.os"));
assertEquals("session-id-goes-here", pvdEnvelope3.getTags().get("ai.session.id"));
assertEquals("1.2.3.4", pvdEnvelope3.getTags().get("ai.location.ip"));
// checking that instrumentation key, cloud role name and cloud role instance are from the agent
assertEquals("00000000-0000-0000-0000-0FEEDDADBEEF", pvdEnvelope3.getIKey());
assertEquals("testrolename", pvdEnvelope3.getTags().get("ai.cloud.role"));
assertEquals("testroleinstance", pvdEnvelope3.getTags().get("ai.cloud.roleInstance"));
// checking that sdk version is from the agent
assertTrue(pvdEnvelope3.getTags().get("ai.internal.sdkVersion").startsWith("java:3."));
assertParentChild(rd, rdEnvelope, pvdEnvelope1, "GET /CoreAndFilter/trackPageView");
assertEquals("operation-id-goes-here", pvdEnvelope2.getTags().get("ai.operation.id"));
assertEquals("operation-parent-id-goes-here", pvdEnvelope2.getTags().get("ai.operation.parentId"));
assertEquals("operation-name-goes-here", pvdEnvelope2.getTags().get("ai.operation.name"));
assertEquals("operation-id-goes-here", pvdEnvelope3.getTags().get("ai.operation.id"));
assertEquals("operation-parent-id-goes-here", pvdEnvelope3.getTags().get("ai.operation.parentId"));
assertEquals("operation-name-goes-here", pvdEnvelope3.getTags().get("ai.operation.name"));
}
Aggregations