Search in sources :

Example 11 with PageFilter

use of com.auth0.client.mgmt.filter.PageFilter in project auth0-java by auth0.

the class OrganizationEntityTest method shouldListOrgMembersWithPage.

@Test
public void shouldListOrgMembersWithPage() throws Exception {
    PageFilter filter = new PageFilter().withPage(0, 20);
    Request<MembersPage> request = api.organizations().getMembers("org_abc", filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MockServer.ORGANIZATION_MEMBERS_LIST, 200);
    MembersPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/organizations/org_abc/members"));
    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()));
    assertThat(response.getItems(), hasSize(3));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) PageFilter(com.auth0.client.mgmt.filter.PageFilter) Test(org.junit.Test)

Example 12 with PageFilter

use of com.auth0.client.mgmt.filter.PageFilter in project auth0-java by auth0.

the class OrganizationEntityTest method shouldListOrgMembersWithCheckpointPageResponse.

@Test
public void shouldListOrgMembersWithCheckpointPageResponse() throws Exception {
    PageFilter filter = new PageFilter().withTake(3).withFrom("from-pointer");
    Request<MembersPage> request = api.organizations().getMembers("org_abc", filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(ORGANIZATION_MEMBERS_CHECKPOINT_PAGED_LIST, 200);
    MembersPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/organizations/org_abc/members"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    assertThat(recordedRequest, hasQueryParameter("take", "3"));
    assertThat(recordedRequest, hasQueryParameter("from", "from-pointer"));
    assertThat(response, is(notNullValue()));
    assertThat(response.getItems(), hasSize(3));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) PageFilter(com.auth0.client.mgmt.filter.PageFilter) Test(org.junit.Test)

Example 13 with PageFilter

use of com.auth0.client.mgmt.filter.PageFilter in project auth0-java by auth0.

the class OrganizationEntityTest method shouldGetOrganizationConnectionsWithPage.

@Test
public void shouldGetOrganizationConnectionsWithPage() throws Exception {
    PageFilter filter = new PageFilter().withPage(2, 30);
    Request<EnabledConnectionsPage> request = api.organizations().getConnections("org_abc", filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MockServer.ORGANIZATION_CONNECTIONS_LIST, 200);
    EnabledConnectionsPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/organizations/org_abc/enabled_connections"));
    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 14 with PageFilter

use of com.auth0.client.mgmt.filter.PageFilter in project auth0-java by auth0.

the class OrganizationEntityTest method shouldListOrgMembersWithTotals.

@Test
public void shouldListOrgMembersWithTotals() throws Exception {
    PageFilter filter = new PageFilter().withTotals(true);
    Request<MembersPage> request = api.organizations().getMembers("org_abc", filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MockServer.ORGANIZATION_MEMBERS_PAGED_LIST, 200);
    MembersPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/organizations/org_abc/members"));
    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(3));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) PageFilter(com.auth0.client.mgmt.filter.PageFilter) Test(org.junit.Test)

Example 15 with PageFilter

use of com.auth0.client.mgmt.filter.PageFilter in project auth0-java by auth0.

the class ActionsEntityTest method shouldGetTriggerBindingsWithFilter.

@Test
public void shouldGetTriggerBindingsWithFilter() throws Exception {
    PageFilter filter = new PageFilter().withPage(1, 10);
    Request<BindingsPage> request = api.actions().getTriggerBindings("trigger-id", filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MockServer.ACTION_TRIGGER_BINDINGS, 200);
    BindingsPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/actions/triggers/trigger-id/bindings"));
    assertThat(recordedRequest, hasQueryParameter("page", "1"));
    assertThat(recordedRequest, hasQueryParameter("per_page", "10"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
    assertThat(response, is(notNullValue()));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) PageFilter(com.auth0.client.mgmt.filter.PageFilter) Test(org.junit.Test)

Aggregations

PageFilter (com.auth0.client.mgmt.filter.PageFilter)23 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)23 Test (org.junit.Test)23 PermissionsPage (com.auth0.json.mgmt.PermissionsPage)4 RolesPage (com.auth0.json.mgmt.RolesPage)4 UsersPage (com.auth0.json.mgmt.users.UsersPage)3 OrganizationsPage (com.auth0.json.mgmt.organizations.OrganizationsPage)2