Search in sources :

Example 11 with RemoteDependencyData

use of com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData in project ApplicationInsights-Java by microsoft.

the class AiSmokeTest method getTelemetry.

protected static Telemetry getTelemetry(int rddCount, Predicate<RemoteDependencyData> condition) throws Exception {
    if (rddCount > 3) {
        throw new IllegalArgumentException("this method currently only supports rddCount up to 3");
    }
    Telemetry telemetry = new Telemetry();
    List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
    telemetry.rdEnvelope = rdList.get(0);
    telemetry.rd = (RequestData) ((Data<?>) telemetry.rdEnvelope.getData()).getBaseData();
    assertEquals(0, mockedIngestion.getCountForType("EventData"));
    if (rddCount == 0) {
        return telemetry;
    }
    String operationId = telemetry.rdEnvelope.getTags().get("ai.operation.id");
    List<Envelope> rddList = mockedIngestion.waitForItemsInOperation("RemoteDependencyData", rddCount, operationId, envelope -> {
        RemoteDependencyData rdd = (RemoteDependencyData) ((Data<?>) envelope.getData()).getBaseData();
        return condition.test(rdd);
    });
    telemetry.rddEnvelope1 = rddList.get(0);
    telemetry.rdd1 = (RemoteDependencyData) ((Data<?>) telemetry.rddEnvelope1.getData()).getBaseData();
    if (rddCount == 1) {
        return telemetry;
    }
    telemetry.rddEnvelope2 = rddList.get(1);
    telemetry.rdd2 = (RemoteDependencyData) ((Data<?>) telemetry.rddEnvelope2.getData()).getBaseData();
    if (rddCount == 2) {
        return telemetry;
    }
    telemetry.rddEnvelope3 = rddList.get(2);
    telemetry.rdd3 = (RemoteDependencyData) ((Data<?>) telemetry.rddEnvelope3.getData()).getBaseData();
    return telemetry;
}
Also used : RemoteDependencyData(com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData) Data(com.microsoft.applicationinsights.smoketest.schemav2.Data) RequestData(com.microsoft.applicationinsights.smoketest.schemav2.RequestData) RemoteDependencyData(com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData) Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope)

Example 12 with RemoteDependencyData

use of com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData in project ApplicationInsights-Java by microsoft.

the class CustomInstrumentationTest method customInstrumentationTwo.

@Test
@TargetUri("/customInstrumentationTwo")
public void customInstrumentationTwo() throws Exception {
    List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
    List<Envelope> rddList = mockedIngestion.waitForItemsInRequest("RemoteDependencyData", 1);
    Envelope rdEnvelope = rdList.get(0);
    Envelope rddEnvelope = rddList.get(0);
    RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
    RemoteDependencyData rdd = (RemoteDependencyData) ((Data<?>) rddEnvelope.getData()).getBaseData();
    assertTrue(rd.getSuccess());
    assertEquals(rdd.getName(), "com/microsoft/applicationinsights/smoketestapp/TargetObject.two");
    assertEquals(rdd.getType(), "OTHER");
    assertEquals(rdd.getSuccess(), true);
    assertParentChild(rd, rdEnvelope, rddEnvelope, "GET /CustomInstrumentation/*");
}
Also used : RequestData(com.microsoft.applicationinsights.smoketest.schemav2.RequestData) RemoteDependencyData(com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData) Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope) AiSmokeTest(com.microsoft.applicationinsights.smoketest.AiSmokeTest) Test(org.junit.Test) TargetUri(com.microsoft.applicationinsights.smoketest.TargetUri)

Example 13 with RemoteDependencyData

use of com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData in project ApplicationInsights-Java by microsoft.

the class CustomInstrumentationTest method customInstrumentationFour.

@Test
@TargetUri("/customInstrumentationFour")
public void customInstrumentationFour() throws Exception {
    List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
    List<Envelope> rddList = mockedIngestion.waitForItemsInRequest("RemoteDependencyData", 1);
    Envelope rdEnvelope = rdList.get(0);
    Envelope rddEnvelope = rddList.get(0);
    RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
    RemoteDependencyData rdd = (RemoteDependencyData) ((Data<?>) rddEnvelope.getData()).getBaseData();
    assertTrue(rd.getSuccess());
    assertEquals(rdd.getName(), "com/microsoft/applicationinsights/smoketestapp/TargetObject$NestedObject.four");
    assertEquals(rdd.getType(), "OTHER");
    assertEquals(rdd.getSuccess(), true);
    assertParentChild(rd, rdEnvelope, rddEnvelope, "GET /CustomInstrumentation/*");
}
Also used : RequestData(com.microsoft.applicationinsights.smoketest.schemav2.RequestData) RemoteDependencyData(com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData) Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope) AiSmokeTest(com.microsoft.applicationinsights.smoketest.AiSmokeTest) Test(org.junit.Test) TargetUri(com.microsoft.applicationinsights.smoketest.TargetUri)

Example 14 with RemoteDependencyData

use of com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData in project ApplicationInsights-Java by microsoft.

the class CustomInstrumentationTest method customInstrumentationEight.

@Test
@TargetUri("/customInstrumentationEight")
public void customInstrumentationEight() throws Exception {
    List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
    List<Envelope> rddList = mockedIngestion.waitForItemsInRequest("RemoteDependencyData", 2);
    Envelope rdEnvelope = rdList.get(0);
    Envelope rddEnvelope1 = rddList.get(0);
    Envelope rddEnvelope2 = rddList.get(1);
    RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
    RemoteDependencyData rdd1 = (RemoteDependencyData) ((Data<?>) rddEnvelope1.getData()).getBaseData();
    RemoteDependencyData rdd2 = (RemoteDependencyData) ((Data<?>) rddEnvelope2.getData()).getBaseData();
    assertTrue(rd.getSuccess());
    assertEquals(rdd1.getName(), "com/microsoft/applicationinsights/smoketestapp/TargetObject.eight");
    assertEquals(rdd1.getType(), "OTHER");
    assertEquals(rdd1.getSuccess(), true);
    assertParentChild(rd, rdEnvelope, rddEnvelope1, "GET /CustomInstrumentation/*");
    assertEquals(rdd2.getName(), "com/microsoft/applicationinsights/smoketestapp/TargetObject.eight");
    assertEquals(rdd2.getType(), "OTHER");
    assertEquals(rdd2.getSuccess(), true);
    assertParentChild(rd, rdEnvelope, rddEnvelope2, "GET /CustomInstrumentation/*");
}
Also used : RequestData(com.microsoft.applicationinsights.smoketest.schemav2.RequestData) RemoteDependencyData(com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData) Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope) AiSmokeTest(com.microsoft.applicationinsights.smoketest.AiSmokeTest) Test(org.junit.Test) TargetUri(com.microsoft.applicationinsights.smoketest.TargetUri)

Example 15 with RemoteDependencyData

use of com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData in project ApplicationInsights-Java by microsoft.

the class CustomInstrumentationTest method customInstrumentationThree.

@Test
@TargetUri("/customInstrumentationThree")
public void customInstrumentationThree() throws Exception {
    List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
    List<Envelope> rddList = mockedIngestion.waitForItemsInRequest("RemoteDependencyData", 1);
    List<Envelope> edList = mockedIngestion.waitForItemsInRequest("ExceptionData", 1);
    Envelope rdEnvelope = rdList.get(0);
    Envelope rddEnvelope = rddList.get(0);
    Envelope edEnvelope = edList.get(0);
    RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
    RemoteDependencyData rdd = (RemoteDependencyData) ((Data<?>) rddEnvelope.getData()).getBaseData();
    ExceptionData ed = (ExceptionData) ((Data<?>) edEnvelope.getData()).getBaseData();
    assertTrue(rd.getSuccess());
    assertEquals(rdd.getName(), "com/microsoft/applicationinsights/smoketestapp/TargetObject.three");
    assertEquals(rdd.getType(), "OTHER");
    assertEquals(rdd.getSuccess(), false);
    List<ExceptionDetails> exceptions = ed.getExceptions();
    assertEquals(exceptions.size(), 1);
    assertEquals(exceptions.get(0).getMessage(), "Three");
    assertParentChild(rd, rdEnvelope, rddEnvelope, "GET /CustomInstrumentation/*");
    assertParentChild(rd, rdEnvelope, edEnvelope, "GET /CustomInstrumentation/*");
}
Also used : RequestData(com.microsoft.applicationinsights.smoketest.schemav2.RequestData) RemoteDependencyData(com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData) ExceptionData(com.microsoft.applicationinsights.smoketest.schemav2.ExceptionData) ExceptionDetails(com.microsoft.applicationinsights.smoketest.schemav2.ExceptionDetails) Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope) AiSmokeTest(com.microsoft.applicationinsights.smoketest.AiSmokeTest) Test(org.junit.Test) TargetUri(com.microsoft.applicationinsights.smoketest.TargetUri)

Aggregations

Envelope (com.microsoft.applicationinsights.smoketest.schemav2.Envelope)27 RemoteDependencyData (com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData)26 Test (org.junit.Test)26 RequestData (com.microsoft.applicationinsights.smoketest.schemav2.RequestData)25 AiSmokeTest (com.microsoft.applicationinsights.smoketest.AiSmokeTest)10 TargetUri (com.microsoft.applicationinsights.smoketest.TargetUri)10 Data (com.microsoft.applicationinsights.smoketest.schemav2.Data)2 ExceptionData (com.microsoft.applicationinsights.smoketest.schemav2.ExceptionData)2 EventData (com.microsoft.applicationinsights.smoketest.schemav2.EventData)1 ExceptionDetails (com.microsoft.applicationinsights.smoketest.schemav2.ExceptionDetails)1