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