use of com.auth0.json.mgmt.organizations.OrganizationsPage in project auth0-java by auth0.
the class OrganizationEntityTest method shouldListOrgsWithPage.
@Test
public void shouldListOrgsWithPage() throws Exception {
PageFilter filter = new PageFilter().withPage(2, 30);
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("page", "2"));
assertThat(recordedRequest, hasQueryParameter("per_page", "30"));
assertThat(response, is(notNullValue()));
assertThat(response.getItems(), hasSize(2));
}
use of com.auth0.json.mgmt.organizations.OrganizationsPage in project auth0-java by auth0.
the class UsersEntityTest method shouldGetUserOrganizationsWithoutFilter.
@Test
public void shouldGetUserOrganizationsWithoutFilter() throws Exception {
Request<OrganizationsPage> request = api.users().getOrganizations("1", null);
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(response, is(notNullValue()));
}
use of com.auth0.json.mgmt.organizations.OrganizationsPage 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.json.mgmt.organizations.OrganizationsPage 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.json.mgmt.organizations.OrganizationsPage 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()));
}
Aggregations