Search in sources :

Example 11 with LogEventsPage

use of com.auth0.json.mgmt.logevents.LogEventsPage in project auth0-java by auth0.

the class UsersEntityTest method shouldGetUserLogEventsWithTotals.

@Test
public void shouldGetUserLogEventsWithTotals() throws Exception {
    LogEventFilter filter = new LogEventFilter().withTotals(true);
    Request<LogEventsPage> request = api.users().getLogEvents("1", filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_LOG_EVENTS_PAGED_LIST, 200);
    LogEventsPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/users/1/logs"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    assertThat(recordedRequest, hasQueryParameter("include_totals", "true"));
    assertThat(response, is(notNullValue()));
    assertThat(response.getItems(), hasSize(2));
    assertThat(response.getStart(), is(0));
    assertThat(response.getLength(), is(14));
    assertThat(response.getTotal(), is(14));
    assertThat(response.getLimit(), is(50));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) LogEventsPage(com.auth0.json.mgmt.logevents.LogEventsPage) LogEventFilter(com.auth0.client.mgmt.filter.LogEventFilter) Test(org.junit.Test)

Example 12 with LogEventsPage

use of com.auth0.json.mgmt.logevents.LogEventsPage in project auth0-java by auth0.

the class LogEventsEntityTest method shouldReturnEmptyLogEvents.

@Test
public void shouldReturnEmptyLogEvents() throws Exception {
    Request<LogEventsPage> request = api.logEvents().list(null);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_EMPTY_LIST, 200);
    LogEventsPage response = request.execute();
    assertThat(response, is(notNullValue()));
    assertThat(response.getItems(), is(emptyCollectionOf(LogEvent.class)));
}
Also used : LogEventsPage(com.auth0.json.mgmt.logevents.LogEventsPage) Test(org.junit.Test)

Example 13 with LogEventsPage

use of com.auth0.json.mgmt.logevents.LogEventsPage in project auth0-java by auth0.

the class LogEventsEntityTest method shouldListLogEventsWithTotals.

@Test
public void shouldListLogEventsWithTotals() throws Exception {
    LogEventFilter filter = new LogEventFilter().withTotals(true);
    Request<LogEventsPage> request = api.logEvents().list(filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_LOG_EVENTS_PAGED_LIST, 200);
    LogEventsPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/logs"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    assertThat(recordedRequest, hasQueryParameter("include_totals", "true"));
    assertThat(response, is(notNullValue()));
    assertThat(response.getItems(), hasSize(2));
    assertThat(response.getStart(), is(0));
    assertThat(response.getLength(), is(14));
    assertThat(response.getTotal(), is(14));
    assertThat(response.getLimit(), is(50));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) LogEventsPage(com.auth0.json.mgmt.logevents.LogEventsPage) LogEventFilter(com.auth0.client.mgmt.filter.LogEventFilter) Test(org.junit.Test)

Example 14 with LogEventsPage

use of com.auth0.json.mgmt.logevents.LogEventsPage in project auth0-java by auth0.

the class UsersEntityTest method shouldReturnEmptyUserLogEvents.

@Test
public void shouldReturnEmptyUserLogEvents() throws Exception {
    Request<LogEventsPage> request = api.users().getLogEvents("1", null);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_EMPTY_LIST, 200);
    LogEventsPage response = request.execute();
    assertThat(response, is(notNullValue()));
    assertThat(response.getItems(), is(emptyCollectionOf(LogEvent.class)));
}
Also used : LogEventsPage(com.auth0.json.mgmt.logevents.LogEventsPage) Test(org.junit.Test)

Aggregations

LogEventsPage (com.auth0.json.mgmt.logevents.LogEventsPage)14 Test (org.junit.Test)14 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)12 LogEventFilter (com.auth0.client.mgmt.filter.LogEventFilter)10