Search in sources :

Example 1 with OrganizationsPage

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));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) PageFilter(com.auth0.client.mgmt.filter.PageFilter) Test(org.junit.Test)

Example 2 with OrganizationsPage

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()));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) OrganizationsPage(com.auth0.json.mgmt.organizations.OrganizationsPage) Test(org.junit.Test)

Example 3 with OrganizationsPage

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));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) PageFilter(com.auth0.client.mgmt.filter.PageFilter) Test(org.junit.Test)

Example 4 with OrganizationsPage

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));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) PageFilter(com.auth0.client.mgmt.filter.PageFilter) Test(org.junit.Test)

Example 5 with OrganizationsPage

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()));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) OrganizationsPage(com.auth0.json.mgmt.organizations.OrganizationsPage) PageFilter(com.auth0.client.mgmt.filter.PageFilter) Test(org.junit.Test)

Aggregations

RecordedRequest (okhttp3.mockwebserver.RecordedRequest)6 Test (org.junit.Test)6 PageFilter (com.auth0.client.mgmt.filter.PageFilter)5 OrganizationsPage (com.auth0.json.mgmt.organizations.OrganizationsPage)3