use of com.microsoft.applicationinsights.smoketest.schemav2.Domain in project ApplicationInsights-Java by microsoft.
the class CoreAndFilterTests method testHttpRequest.
@Test
@TargetUri("/trackHttpRequest")
public void testHttpRequest() throws Exception {
mockedIngestion.waitForItems("RequestData", 5);
int totalItems = mockedIngestion.getItemCount();
int expectedItems = 5;
assertEquals(String.format("There were %d extra telemetry items received.", totalItems - expectedItems), expectedItems, totalItems);
// TODO get HttpRequest data envelope and verify value
List<Domain> requests = mockedIngestion.getTelemetryDataByType("RequestData");
// true
assertThat(requests, hasItem(allOf(hasName("HttpRequestDataTest"), hasResponseCode("200"), hasDuration(new Duration(4711)), hasSuccess(true))));
assertThat(requests, hasItem(allOf(hasName("PingTest"), hasResponseCode("200"), hasDuration(new Duration(1)), hasSuccess(true), hasUrl("http://tempuri.org/ping"))));
// false
assertThat(requests, hasItem(allOf(hasName("FailedHttpRequest"), hasResponseCode("404"), hasDuration(new Duration(6666)), hasSuccess(false))));
assertThat(requests, hasItem(allOf(hasName("FailedHttpRequest2"), hasResponseCode("505"), hasDuration(new Duration(8888)), hasSuccess(false), hasUrl("https://www.bingasdasdasdasda.com/"))));
}
use of com.microsoft.applicationinsights.smoketest.schemav2.Domain in project ApplicationInsights-Java by microsoft.
the class MockedAppInsightsIngestionServer method getTelemetryDataByType.
private <T extends Domain> List<T> getTelemetryDataByType(String type, boolean inRequestOnly) {
Objects.requireNonNull(type, "type");
List<Envelope> items = getItemsEnvelopeDataType(type);
List<T> dataItems = new ArrayList<>();
for (Envelope e : items) {
if (!inRequestOnly || e.getTags().containsKey("ai.operation.id")) {
Data<T> dt = (Data<T>) e.getData();
dataItems.add(dt.getBaseData());
}
}
return dataItems;
}
use of com.microsoft.applicationinsights.smoketest.schemav2.Domain in project ApplicationInsights-Java by microsoft.
the class MockedAppInsightsIngestionServer method getMessageDataInRequest.
public <T extends Domain> List<T> getMessageDataInRequest() {
List<Envelope> items = getItemsEnvelopeDataType("MessageData");
List<T> dataItems = new ArrayList<>();
for (Envelope e : items) {
String message = ((MessageData) ((Data<?>) e.getData()).getBaseData()).getMessage();
if (e.getTags().containsKey("ai.operation.id") && !ignoreMessageData(message)) {
Data<T> dt = (Data<T>) e.getData();
dataItems.add(dt.getBaseData());
}
}
return dataItems;
}
use of com.microsoft.applicationinsights.smoketest.schemav2.Domain in project camel by apache.
the class DomainProducer method doCreate.
private void doCreate(Exchange exchange) {
final Domain in = messageToDomain(exchange.getIn());
final Domain out = osV3Client.identity().domains().create(in);
exchange.getIn().setBody(out);
}
use of com.microsoft.applicationinsights.smoketest.schemav2.Domain in project camel by apache.
the class DomainProducer method messageToDomain.
private Domain messageToDomain(Message message) {
Domain domain = message.getBody(Domain.class);
if (domain == null) {
Map headers = message.getHeaders();
DomainBuilder builder = Builders.domain();
ObjectHelper.notEmpty(message.getHeader(OpenstackConstants.NAME, String.class), "Name");
builder.name(message.getHeader(OpenstackConstants.NAME, String.class));
if (headers.containsKey(KeystoneConstants.DESCRIPTION)) {
builder.description(message.getHeader(KeystoneConstants.DESCRIPTION, String.class));
}
domain = builder.build();
}
return domain;
}
Aggregations