Search in sources :

Example 1 with Data

use of com.microsoft.applicationinsights.smoketest.schemav2.Data in project ddf by codice.

the class KMLTransformerImpl method setExtendedData.

private void setExtendedData(Placemark placemark, Metacard metacard) {
    final ExtendedData extendedData = new ExtendedData();
    final Set<AttributeDescriptor> attributeDescriptors = metacard.getMetacardType().getAttributeDescriptors();
    for (AttributeDescriptor attributeDescriptor : attributeDescriptors) {
        final String attributeName = attributeDescriptor.getName();
        final Attribute attribute = metacard.getAttribute(attributeName);
        if (attribute != null) {
            Serializable attributeValue = convertAttribute(attribute, attributeDescriptor);
            if (attributeValue == null) {
                LOGGER.debug("Attribute {} converted to null value.", attributeName);
            } else {
                final Data data = getData(attributeName, attributeValue.toString());
                extendedData.addToData(data);
            }
        }
    }
    placemark.setExtendedData(extendedData);
}
Also used : Serializable(java.io.Serializable) ExtendedData(de.micromata.opengis.kml.v_2_2_0.ExtendedData) Attribute(ddf.catalog.data.Attribute) AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) Data(de.micromata.opengis.kml.v_2_2_0.Data) ExtendedData(de.micromata.opengis.kml.v_2_2_0.ExtendedData)

Example 2 with Data

use of com.microsoft.applicationinsights.smoketest.schemav2.Data in project ddf by codice.

the class KMLTransformerImpl method getData.

private Data getData(String attributeAlias, String attributeValue) {
    final Data data = new Data(attributeValue);
    data.setName(attributeAlias);
    return data;
}
Also used : Data(de.micromata.opengis.kml.v_2_2_0.Data) ExtendedData(de.micromata.opengis.kml.v_2_2_0.ExtendedData)

Example 3 with Data

use of com.microsoft.applicationinsights.smoketest.schemav2.Data in project ddf by codice.

the class KMLTransformerImplTest method testPerformDefaultTransformationExtendedData.

@Test
public void testPerformDefaultTransformationExtendedData() throws CatalogTransformerException, DateTimeParseException {
    MetacardImpl metacard = createMockMetacard();
    metacard.setLocation(POINT_WKT);
    metacard.setCreatedDate(metacardDate);
    metacard.setEffectiveDate(metacardDate);
    metacard.setExpirationDate(metacardDate);
    metacard.setModifiedDate(metacardDate);
    metacard.setTags(METACARD_TAGS);
    final Set<AttributeDescriptor> attributeDescriptors = metacard.getMetacardType().getAttributeDescriptors();
    Placemark placemark = kmlTransformer.performDefaultTransformation(metacard);
    final List<Data> dataList = placemark.getExtendedData().getData();
    int dataCount = 0;
    for (AttributeDescriptor attributeDescriptor : attributeDescriptors) {
        final String attributeName = attributeDescriptor.getName();
        final Attribute attribute = metacard.getAttribute(attributeName);
        if (attribute != null) {
            dataCount++;
        }
    }
    assertThat(dataList.size(), is(dataCount));
    for (Data data : dataList) {
        switch(data.getName()) {
            case Core.ID:
                assertThat(data.getValue(), is(METACARD_ID));
                break;
            case Core.TITLE:
                assertThat(data.getValue(), is(METACARD_TITLE));
                break;
            case Core.LOCATION:
                assertThat(data.getValue(), is(POINT_WKT));
                break;
            case Metacard.CONTENT_TYPE:
                assertThat(data.getValue(), is(METACARD_TYPE));
                break;
            case Metacard.CONTENT_TYPE_VERSION:
                assertThat(data.getValue(), is(METACARD_VERSION));
                break;
            case Core.METADATA:
                assertThat(data.getValue(), is(METACARD_METADATA));
                break;
            case Core.METACARD_TAGS:
                assertThat(data.getValue(), is(METACARD_TAGS.asList().get(0) + "," + METACARD_TAGS.asList().get(1)));
                break;
            case Core.MODIFIED:
            case Metacard.EFFECTIVE:
            case Core.EXPIRATION:
            case Core.CREATED:
                assertThat(data.getValue(), is(METACARD_DATE_STRING));
                break;
            default:
                throw new IllegalArgumentException(String.format("Data %s was not expected", data.getName()));
        }
    }
}
Also used : Placemark(de.micromata.opengis.kml.v_2_2_0.Placemark) Attribute(ddf.catalog.data.Attribute) AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) Data(de.micromata.opengis.kml.v_2_2_0.Data) LineString(de.micromata.opengis.kml.v_2_2_0.LineString) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Point(de.micromata.opengis.kml.v_2_2_0.Point) Test(org.junit.Test)

Example 4 with Data

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

the class AiSmokeTest method waitForHealthCheckTelemetryIfNeeded.

private static void waitForHealthCheckTelemetryIfNeeded(String contextRootUrl) throws InterruptedException, ExecutionException {
    if (!requestCaptureEnabled) {
        return;
    }
    Stopwatch receivedTelemetryTimer = Stopwatch.createStarted();
    int requestTelemetryFromHealthCheckTimeout;
    if (currentImageName.startsWith("javase_")) {
        requestTelemetryFromHealthCheckTimeout = APPLICATION_READY_TIMEOUT_SECONDS;
    } else {
        requestTelemetryFromHealthCheckTimeout = TELEMETRY_RECEIVE_TIMEOUT_SECONDS;
    }
    try {
        mockedIngestion.waitForItem(new Predicate<Envelope>() {

            @Override
            public boolean test(Envelope input) {
                if (!"RequestData".equals(input.getData().getBaseType())) {
                    return false;
                }
                RequestData data = (RequestData) ((Data<?>) input.getData()).getBaseData();
                return contextRootUrl.equals(data.getUrl()) && "200".equals(data.getResponseCode());
            }
        }, requestTelemetryFromHealthCheckTimeout, TimeUnit.SECONDS);
        System.out.printf("Received request telemetry after %.3f seconds...%n", receivedTelemetryTimer.elapsed(TimeUnit.MILLISECONDS) / 1000.0);
        System.out.println("Clearing any RequestData from health check.");
    } catch (java.util.concurrent.TimeoutException e) {
        throw new TimeoutException("request telemetry from application health check", requestTelemetryFromHealthCheckTimeout, TimeUnit.SECONDS, e);
    }
}
Also used : RequestData(com.microsoft.applicationinsights.smoketest.schemav2.RequestData) Stopwatch(com.google.common.base.Stopwatch) 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) TimeoutException(com.microsoft.applicationinsights.smoketest.exceptions.TimeoutException)

Example 5 with Data

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

Aggregations

Test (org.junit.Test)65 Envelope (com.microsoft.applicationinsights.smoketest.schemav2.Envelope)53 RequestData (com.microsoft.applicationinsights.smoketest.schemav2.RequestData)45 Data (org.geotoolkit.wps.xml.v200.Data)42 RemoteDependencyData (com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData)26 UnconvertibleObjectException (org.apache.sis.util.UnconvertibleObjectException)20 IOException (java.io.IOException)16 DataInput (org.geotoolkit.wps.xml.v200.DataInput)15 Format (org.geotoolkit.wps.xml.v200.Format)12 AiSmokeTest (com.microsoft.applicationinsights.smoketest.AiSmokeTest)10 TargetUri (com.microsoft.applicationinsights.smoketest.TargetUri)10 MessageData (com.microsoft.applicationinsights.smoketest.schemav2.MessageData)10 ComplexData (org.geotoolkit.wps.xml.v200.ComplexData)10 ExceptionData (com.microsoft.applicationinsights.smoketest.schemav2.ExceptionData)9 ReferenceProxy (org.geotoolkit.wps.xml.ReferenceProxy)9 Data (com.microsoft.applicationinsights.smoketest.schemav2.Data)8 DataStoreException (org.apache.sis.storage.DataStoreException)8 LiteralValue (org.geotoolkit.wps.xml.v200.LiteralValue)7 EventData (com.microsoft.applicationinsights.smoketest.schemav2.EventData)6 MetricData (com.microsoft.applicationinsights.smoketest.schemav2.MetricData)6