use of com.auth0.client.mgmt.filter.RolesFilter in project auth0-java by auth0.
the class RolesEntityTest method shouldListRolesWithPage.
@Test
public void shouldListRolesWithPage() throws Exception {
RolesFilter filter = new RolesFilter().withPage(23, 5);
Request<RolesPage> request = api.roles().list(filter);
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_ROLES_LIST, 200);
RolesPage response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/roles"));
assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
assertThat(recordedRequest, hasQueryParameter("page", "23"));
assertThat(recordedRequest, hasQueryParameter("per_page", "5"));
assertThat(response, is(notNullValue()));
assertThat(response.getItems(), hasSize(2));
}
use of com.auth0.client.mgmt.filter.RolesFilter in project auth0-java by auth0.
the class RolesEntityTest method shouldListRolesWithTotals.
@Test
public void shouldListRolesWithTotals() throws Exception {
RolesFilter filter = new RolesFilter().withTotals(true);
Request<RolesPage> request = api.roles().list(filter);
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_ROLES_PAGED_LIST, 200);
RolesPage response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/roles"));
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));
}
Aggregations