Search in sources :

Example 1 with DailyStats

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

the class StatsEntityTest method shouldReturnEmptyDailyStats.

@Test
public void shouldReturnEmptyDailyStats() throws Exception {
    Request<List<DailyStats>> request = api.stats().getDailyStats(new Date(), new Date());
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_EMPTY_LIST, 200);
    List<DailyStats> response = request.execute();
    assertThat(response, is(notNullValue()));
    assertThat(response, is(emptyCollectionOf(DailyStats.class)));
}
Also used : DailyStats(com.auth0.json.mgmt.DailyStats) List(java.util.List) Date(java.util.Date) Test(org.junit.Test)

Example 2 with DailyStats

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

the class StatsEntityTest method shouldGetDailyStats.

@SuppressWarnings("deprecation")
@Test
public void shouldGetDailyStats() throws Exception {
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.YEAR, 2016);
    calendar.set(Calendar.MONTH, Calendar.OCTOBER);
    calendar.set(Calendar.DATE, 11);
    Date dateFrom = calendar.getTime();
    calendar.set(Calendar.DATE, 12);
    Date dateTo = calendar.getTime();
    Request<List<DailyStats>> request = api.stats().getDailyStats(dateFrom, dateTo);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_DAILY_STATS_LIST, 200);
    List<DailyStats> response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/stats/daily"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    assertThat(recordedRequest, hasQueryParameter("from", "20161011"));
    assertThat(recordedRequest, hasQueryParameter("to", "20161012"));
    assertThat(response, is(notNullValue()));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) Calendar(java.util.Calendar) DailyStats(com.auth0.json.mgmt.DailyStats) List(java.util.List) Date(java.util.Date) Test(org.junit.Test)

Aggregations

DailyStats (com.auth0.json.mgmt.DailyStats)2 Date (java.util.Date)2 List (java.util.List)2 Test (org.junit.Test)2 Calendar (java.util.Calendar)1 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)1