Search in sources :

Example 26 with TelemetryClient

use of com.microsoft.applicationinsights.agent.internal.telemetry.TelemetryClient in project ApplicationInsights-Java by microsoft.

the class QuickPulseDataFetcherTests method endpointIsFormattedCorrectlyWhenUsingConfig.

@Test
void endpointIsFormattedCorrectlyWhenUsingConfig() throws URISyntaxException {
    TelemetryClient telemetryClient = TelemetryClient.createForTest();
    telemetryClient.setConnectionString("InstrumentationKey=testing-123");
    QuickPulseDataFetcher quickPulseDataFetcher = new QuickPulseDataFetcher(null, telemetryClient, null, null, null);
    String quickPulseEndpoint = quickPulseDataFetcher.getQuickPulseEndpoint();
    String endpointUrl = quickPulseDataFetcher.getEndpointUrl(quickPulseEndpoint);
    URI uri = new URI(endpointUrl);
    assertThat(uri).isNotNull();
    assertThat(endpointUrl).isEqualTo("https://rt.services.visualstudio.com/QuickPulseService.svc/post?ikey=testing-123");
}
Also used : TelemetryClient(com.microsoft.applicationinsights.agent.internal.telemetry.TelemetryClient) URI(java.net.URI) Test(org.junit.jupiter.api.Test)

Example 27 with TelemetryClient

use of com.microsoft.applicationinsights.agent.internal.telemetry.TelemetryClient in project ApplicationInsights-Java by microsoft.

the class LazyConfigurationAccessorTest method disableLazySetWithLazySetOptInOnConnectionStringNullAndInstrumentationKeyNull.

@Test
// TRUE"
void disableLazySetWithLazySetOptInOnConnectionStringNullAndInstrumentationKeyNull() {
    assertThat(LazyConfigurationAccessor.shouldSetConnectionString(true, "true")).isTrue();
    // given
    TelemetryClient telemetryClient = mock(TelemetryClient.class);
    AppIdSupplier appIdSupplier = mock(AppIdSupplier.class);
    LazyConfigurationAccessor lazyConfigurationAccessor = new LazyConfigurationAccessor(telemetryClient, appIdSupplier);
    // when
    lazyConfigurationAccessor.setConnectionString(null, null);
    // then
    verify(telemetryClient, never()).setConnectionString(anyString());
}
Also used : TelemetryClient(com.microsoft.applicationinsights.agent.internal.telemetry.TelemetryClient) Test(org.junit.jupiter.api.Test)

Example 28 with TelemetryClient

use of com.microsoft.applicationinsights.agent.internal.telemetry.TelemetryClient in project ApplicationInsights-Java by microsoft.

the class LazyConfigurationAccessorTest method enableLazySetWithLazySetOptInOffConnectionStringNullInstrumentationKeyNotNull.

@Test
// is TRUE")
void enableLazySetWithLazySetOptInOffConnectionStringNullInstrumentationKeyNotNull() {
    assertThat(LazyConfigurationAccessor.shouldSetConnectionString(false, "true")).isTrue();
    // given
    TelemetryClient telemetryClient = mock(TelemetryClient.class);
    AppIdSupplier appIdSupplier = mock(AppIdSupplier.class);
    LazyConfigurationAccessor lazyConfigurationAccessor = new LazyConfigurationAccessor(telemetryClient, appIdSupplier);
    // when
    lazyConfigurationAccessor.setConnectionString(null, INSTRUMENTATION_KEY);
    // then
    verify(telemetryClient).setConnectionString("InstrumentationKey=" + INSTRUMENTATION_KEY);
}
Also used : TelemetryClient(com.microsoft.applicationinsights.agent.internal.telemetry.TelemetryClient) Test(org.junit.jupiter.api.Test)

Aggregations

TelemetryClient (com.microsoft.applicationinsights.agent.internal.telemetry.TelemetryClient)28 Test (org.junit.jupiter.api.Test)21 TelemetryItem (com.microsoft.applicationinsights.agent.internal.exporter.models.TelemetryItem)7 Configuration (com.microsoft.applicationinsights.agent.internal.configuration.Configuration)6 URI (java.net.URI)5 FinalCounters (com.microsoft.applicationinsights.agent.internal.quickpulse.QuickPulseDataCollector.FinalCounters)4 RpConfiguration (com.microsoft.applicationinsights.agent.internal.configuration.RpConfiguration)3 Date (java.util.Date)3 HttpHeaders (com.azure.core.http.HttpHeaders)2 HttpPipeline (com.azure.core.http.HttpPipeline)2 HttpPipelineBuilder (com.azure.core.http.HttpPipelineBuilder)2 MockHttpResponse (com.microsoft.applicationinsights.agent.internal.MockHttpResponse)2 ProcessorConfig (com.microsoft.applicationinsights.agent.internal.configuration.Configuration.ProcessorConfig)2 AiLegacyHeaderSpanProcessor (com.microsoft.applicationinsights.agent.internal.legacyheaders.AiLegacyHeaderSpanProcessor)2 URISyntaxException (java.net.URISyntaxException)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 Mono (reactor.core.publisher.Mono)2 HttpRequest (com.azure.core.http.HttpRequest)1