use of com.auth0.client.mgmt.filter.PageFilter in project auth0-java by auth0.
the class OrganizationEntityTest method shouldListOrgsWithCheckpointPagination.
@Test
public void shouldListOrgsWithCheckpointPagination() throws Exception {
PageFilter filter = new PageFilter().withTake(10).withFrom("from-id");
Request<OrganizationsPage> request = api.organizations().list(filter);
assertThat(request, is(notNullValue()));
server.jsonResponse(ORGANIZATIONS_CHECKPOINT_PAGED_LIST, 200);
OrganizationsPage response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/organizations"));
assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
assertThat(recordedRequest, hasQueryParameter("take", "10"));
assertThat(recordedRequest, hasQueryParameter("from", "from-id"));
assertThat(response, is(notNullValue()));
assertThat(response.getItems(), hasSize(2));
}
use of com.auth0.client.mgmt.filter.PageFilter in project auth0-java by auth0.
the class OrganizationEntityTest method shouldListOrgsWithTotals.
@Test
public void shouldListOrgsWithTotals() throws Exception {
PageFilter filter = new PageFilter().withTotals(true);
Request<OrganizationsPage> request = api.organizations().list(filter);
assertThat(request, is(notNullValue()));
server.jsonResponse(MockServer.ORGANIZATIONS_PAGED_LIST, 200);
OrganizationsPage response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/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));
}
use of com.auth0.client.mgmt.filter.PageFilter in project auth0-java by auth0.
the class RolesEntityTest method shouldListUsersWithCheckpointPaging.
@Test
public void shouldListUsersWithCheckpointPaging() throws Exception {
PageFilter filter = new PageFilter().withTake(2).withFrom("from-id");
Request<UsersPage> request = api.roles().listUsers("1", filter);
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_ROLE_USERS_CHECKPOINT_PAGED_LIST, 200);
UsersPage response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/roles/1/users"));
assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
assertThat(recordedRequest, hasQueryParameter("take", "2"));
assertThat(recordedRequest, hasQueryParameter("from", "from-id"));
assertThat(response, is(notNullValue()));
assertThat(response.getItems(), hasSize(2));
assertThat(response.getNext(), is("MjAyMS0wMy0yOSAxNjo1MDo09s44NDYxODcrMDAsb3JnX2Y0VXZUbG1iSWd2005zTGw"));
assertThat(response.getStart(), is(nullValue()));
assertThat(response.getLength(), is(nullValue()));
assertThat(response.getTotal(), is(nullValue()));
assertThat(response.getLimit(), is(nullValue()));
}
use of com.auth0.client.mgmt.filter.PageFilter in project auth0-java by auth0.
the class RolesEntityTest method shouldListPermissionsWithTotal.
@Test
public void shouldListPermissionsWithTotal() throws Exception {
PageFilter filter = new PageFilter().withTotals(true);
Request<PermissionsPage> request = api.roles().listPermissions("1", filter);
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_ROLE_PERMISSIONS_PAGED_LIST, 200);
PermissionsPage response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/roles/1/permissions"));
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));
}
use of com.auth0.client.mgmt.filter.PageFilter in project auth0-java by auth0.
the class RolesEntityTest method shouldListUsersWithTotals.
@Test
public void shouldListUsersWithTotals() throws Exception {
PageFilter filter = new PageFilter().withTotals(true);
Request<UsersPage> request = api.roles().listUsers("1", filter);
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_ROLE_USERS_PAGED_LIST, 200);
UsersPage response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/roles/1/users"));
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