Search in sources :

Example 1 with PageFilter

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

the class OrganizationEntityTest method shouldGetOrgRolesWithPaging.

@Test
public void shouldGetOrgRolesWithPaging() throws Exception {
    Request<RolesPage> request = api.organizations().getRoles("org_abc", "user_123", new PageFilter().withPage(0, 20));
    assertThat(request, is(notNullValue()));
    server.jsonResponse(ORGANIZATION_MEMBER_ROLES_LIST, 200);
    RolesPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/organizations/org_abc/members/user_123/roles"));
    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(1));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) PageFilter(com.auth0.client.mgmt.filter.PageFilter) RolesPage(com.auth0.json.mgmt.RolesPage) Test(org.junit.Test)

Example 2 with PageFilter

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

the class OrganizationEntityTest method shouldGetOrgRolesWithIncludeTotals.

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

Example 3 with PageFilter

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

the class ActionsEntityTest method shouldGetActionVersionsWithFilter.

@Test
public void shouldGetActionVersionsWithFilter() throws Exception {
    PageFilter filter = new PageFilter().withPage(1, 10);
    Request<VersionsPage> request = api.actions().getVersions("action-id", filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MockServer.ACTION_VERSIONS_LIST, 200);
    VersionsPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/actions/actions/action-id/versions"));
    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)

Example 4 with PageFilter

use of com.auth0.client.mgmt.filter.PageFilter 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 5 with PageFilter

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

the class RolesEntityTest method shouldListUsersWithPage.

@Test
public void shouldListUsersWithPage() throws Exception {
    PageFilter filter = new PageFilter().withPage(23, 5);
    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("page", "23"));
    assertThat(recordedRequest, hasQueryParameter("per_page", "5"));
    assertThat(response, is(notNullValue()));
    assertThat(response.getItems(), hasSize(2));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) PageFilter(com.auth0.client.mgmt.filter.PageFilter) UsersPage(com.auth0.json.mgmt.users.UsersPage) 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