Search in sources :

Example 6 with Duration

use of com.microsoft.applicationinsights.smoketest.telemetry.Duration in project ApplicationInsights-Java by microsoft.

the class JsonHelperTests method testMinuteDuration.

@Test
public void testMinuteDuration() {
    Duration expected = new Duration(0, 0, 25, 50, 0);
    String json = getJsonDurationInHolder(expected);
    System.out.println(json);
    DurationHolder actual = JsonHelper.GSON.fromJson(json, DurationHolder.class);
    assertThat(actual.getData()).isEqualTo(expected);
    json = getJsonDurationInHolder(new Duration(25 * 60000L + 50000L));
    System.out.println(json);
    actual = JsonHelper.GSON.fromJson(json, DurationHolder.class);
    assertThat(actual.getData()).isEqualTo(expected);
}
Also used : Duration(com.microsoft.applicationinsights.smoketest.telemetry.Duration) Test(org.junit.jupiter.api.Test)

Example 7 with Duration

use of com.microsoft.applicationinsights.smoketest.telemetry.Duration in project ApplicationInsights-Java by microsoft.

the class JsonHelperTests method testDaysAndMilliseconds.

@Test
public void testDaysAndMilliseconds() {
    Duration expected = new Duration(5, 0, 1, 0, 213);
    String json = getJsonDurationInHolder(expected);
    System.out.println(json);
    DurationHolder actual = JsonHelper.GSON.fromJson(json, DurationHolder.class);
    assertThat(actual.getData()).isEqualTo(expected);
    json = getJsonDurationInHolder(new Duration(60213L + 5 * 86400000L));
    System.out.println(json);
    actual = JsonHelper.GSON.fromJson(json, DurationHolder.class);
    assertThat(actual.getData()).isEqualTo(expected);
}
Also used : Duration(com.microsoft.applicationinsights.smoketest.telemetry.Duration) Test(org.junit.jupiter.api.Test)

Example 8 with Duration

use of com.microsoft.applicationinsights.smoketest.telemetry.Duration in project ApplicationInsights-Java by microsoft.

the class JsonHelperTests method testDayDuration.

@Test
public void testDayDuration() {
    Duration expected = new Duration(2, 0, 0, 0, 0);
    String json = getJsonDurationInHolder(expected);
    System.out.println(json);
    DurationHolder actual = JsonHelper.GSON.fromJson(json, DurationHolder.class);
    assertThat(actual.getData()).isEqualTo(expected);
    expected = new Duration(2L * 86400000L);
    json = getJsonDurationInHolder(expected);
    System.out.println(json);
    actual = JsonHelper.GSON.fromJson(json, DurationHolder.class);
    assertThat(actual.getData()).isEqualTo(expected);
}
Also used : Duration(com.microsoft.applicationinsights.smoketest.telemetry.Duration) Test(org.junit.jupiter.api.Test)

Example 9 with Duration

use of com.microsoft.applicationinsights.smoketest.telemetry.Duration in project ApplicationInsights-Java by microsoft.

the class JsonHelperTests method testMillisecondDuration.

@Test
public void testMillisecondDuration() {
    Duration expected = new Duration(1);
    String json = getJsonDurationInHolder(expected);
    System.out.println(json);
    DurationHolder actual = JsonHelper.GSON.fromJson(json, DurationHolder.class);
    assertThat(actual.getData()).isEqualTo(expected);
    expected = new Duration(0, 0, 0, 0, 1);
    json = getJsonDurationInHolder(expected);
    System.out.println(json);
    actual = JsonHelper.GSON.fromJson(json, DurationHolder.class);
    assertThat(actual.getData()).isEqualTo(expected);
}
Also used : Duration(com.microsoft.applicationinsights.smoketest.telemetry.Duration) Test(org.junit.jupiter.api.Test)

Example 10 with Duration

use of com.microsoft.applicationinsights.smoketest.telemetry.Duration 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");
}
Also used : RequestData(com.microsoft.applicationinsights.smoketest.schemav2.RequestData) RequestDataMatchers.hasDuration(com.microsoft.applicationinsights.smoketest.matchers.RequestDataMatchers.hasDuration) Duration(com.microsoft.applicationinsights.smoketest.telemetry.Duration) Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope) PageViewData(com.microsoft.applicationinsights.smoketest.schemav2.PageViewData) Test(org.junit.Test)

Aggregations

Duration (com.microsoft.applicationinsights.smoketest.telemetry.Duration)11 Test (org.junit.jupiter.api.Test)6 RequestDataMatchers.hasDuration (com.microsoft.applicationinsights.smoketest.matchers.RequestDataMatchers.hasDuration)5 Test (org.junit.Test)4 Envelope (com.microsoft.applicationinsights.smoketest.schemav2.Envelope)3 RequestData (com.microsoft.applicationinsights.smoketest.schemav2.RequestData)3 PageViewData (com.microsoft.applicationinsights.smoketest.schemav2.PageViewData)2 DataPoint (com.microsoft.applicationinsights.smoketest.schemav2.DataPoint)1 Domain (com.microsoft.applicationinsights.smoketest.schemav2.Domain)1