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));
}
}
}
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));
}
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));
}
}
}
Aggregations