use of com.auth0.client.mgmt.filter.PageFilter in project auth0-java by auth0.
the class UsersEntityTest method shouldGetUserOrganizationsWithPaging.
@Test
public void shouldGetUserOrganizationsWithPaging() throws Exception {
Request<OrganizationsPage> request = api.users().getOrganizations("1", new PageFilter().withPage(0, 20));
assertThat(request, is(notNullValue()));
server.jsonResponse(ORGANIZATIONS_LIST, 200);
OrganizationsPage response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/users/1/organizations"));
assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
assertThat(recordedRequest, hasQueryParameter("page", "0"));
assertThat(recordedRequest, hasQueryParameter("per_page", "20"));
assertThat(response, is(notNullValue()));
}
use of com.auth0.client.mgmt.filter.PageFilter in project auth0-java by auth0.
the class UsersEntityTest method shouldGetUserOrganizationsWithTotals.
@Test
public void shouldGetUserOrganizationsWithTotals() throws Exception {
Request<OrganizationsPage> request = api.users().getOrganizations("1", new PageFilter().withTotals(true));
assertThat(request, is(notNullValue()));
server.jsonResponse(ORGANIZATIONS_PAGED_LIST, 200);
OrganizationsPage response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/users/1/organizations"));
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.getTotal(), is(2));
assertThat(response.getLimit(), is(20));
}
use of com.auth0.client.mgmt.filter.PageFilter in project auth0-java by auth0.
the class UsersEntityTest method shouldListRolesWithPage.
@Test
public void shouldListRolesWithPage() throws Exception {
PageFilter filter = new PageFilter().withPage(23, 5);
Request<RolesPage> request = api.users().listRoles("1", filter);
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_USER_ROLES_PAGED_LIST, 200);
RolesPage response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/users/1/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));
}
Aggregations