Search in sources :

Example 1 with TelemetryInterceptor

use of com.auth0.net.TelemetryInterceptor in project auth0-java by auth0.

the class ManagementAPITest method shouldDisableTelemetryInterceptor.

@Test
public void shouldDisableTelemetryInterceptor() {
    ManagementAPI api = new ManagementAPI(DOMAIN, API_TOKEN);
    assertThat(api.getClient().interceptors(), hasItem(isA(TelemetryInterceptor.class)));
    api.doNotSendTelemetry();
    for (Interceptor i : api.getClient().interceptors()) {
        if (i instanceof TelemetryInterceptor) {
            TelemetryInterceptor telemetry = (TelemetryInterceptor) i;
            assertThat(telemetry.isEnabled(), is(false));
        }
    }
}
Also used : TelemetryInterceptor(com.auth0.net.TelemetryInterceptor) TelemetryInterceptor(com.auth0.net.TelemetryInterceptor) RateLimitInterceptor(com.auth0.net.RateLimitInterceptor) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor) Test(org.junit.Test)

Example 2 with TelemetryInterceptor

use of com.auth0.net.TelemetryInterceptor in project auth0-java by auth0.

the class ManagementAPITest method shouldUseCustomTelemetry.

@Test
public void shouldUseCustomTelemetry() {
    ManagementAPI api = new ManagementAPI(DOMAIN, API_TOKEN);
    assertThat(api.getClient().interceptors(), hasItem(isA(TelemetryInterceptor.class)));
    Telemetry currentTelemetry = null;
    for (Interceptor i : api.getClient().interceptors()) {
        if (i instanceof TelemetryInterceptor) {
            TelemetryInterceptor interceptor = (TelemetryInterceptor) i;
            currentTelemetry = interceptor.getTelemetry();
        }
    }
    assertThat(currentTelemetry, is(notNullValue()));
    Telemetry newTelemetry = Mockito.mock(Telemetry.class);
    api.setTelemetry(newTelemetry);
    Telemetry updatedTelemetry = null;
    for (Interceptor i : api.getClient().interceptors()) {
        if (i instanceof TelemetryInterceptor) {
            TelemetryInterceptor interceptor = (TelemetryInterceptor) i;
            updatedTelemetry = interceptor.getTelemetry();
        }
    }
    assertThat(updatedTelemetry, is(newTelemetry));
}
Also used : TelemetryInterceptor(com.auth0.net.TelemetryInterceptor) Telemetry(com.auth0.net.Telemetry) TelemetryInterceptor(com.auth0.net.TelemetryInterceptor) RateLimitInterceptor(com.auth0.net.RateLimitInterceptor) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor) Test(org.junit.Test)

Example 3 with TelemetryInterceptor

use of com.auth0.net.TelemetryInterceptor in project auth0-java by auth0.

the class ManagementAPITest method shouldAddAndEnableTelemetryInterceptor.

@Test
public void shouldAddAndEnableTelemetryInterceptor() {
    ManagementAPI api = new ManagementAPI(DOMAIN, API_TOKEN);
    assertThat(api.getClient().interceptors(), hasItem(isA(TelemetryInterceptor.class)));
    for (Interceptor i : api.getClient().interceptors()) {
        if (i instanceof TelemetryInterceptor) {
            TelemetryInterceptor telemetry = (TelemetryInterceptor) i;
            assertThat(telemetry.isEnabled(), is(true));
        }
    }
}
Also used : TelemetryInterceptor(com.auth0.net.TelemetryInterceptor) TelemetryInterceptor(com.auth0.net.TelemetryInterceptor) RateLimitInterceptor(com.auth0.net.RateLimitInterceptor) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor) Test(org.junit.Test)

Aggregations

RateLimitInterceptor (com.auth0.net.RateLimitInterceptor)3 TelemetryInterceptor (com.auth0.net.TelemetryInterceptor)3 HttpLoggingInterceptor (okhttp3.logging.HttpLoggingInterceptor)3 Test (org.junit.Test)3 Telemetry (com.auth0.net.Telemetry)1