Search in sources :

Example 1 with UsersPage

use of com.auth0.json.mgmt.users.UsersPage 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)

Example 2 with UsersPage

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

Example 3 with UsersPage

use of com.auth0.json.mgmt.users.UsersPage in project auth0-java by auth0.

the class RolesEntityTest method shouldListUsersWithoutFilter.

@Test
public void shouldListUsersWithoutFilter() throws Exception {
    Request<UsersPage> request = api.roles().listUsers("1", null);
    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(response, is(notNullValue()));
    assertThat(response.getItems(), hasSize(2));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) UsersPage(com.auth0.json.mgmt.users.UsersPage) Test(org.junit.Test)

Example 4 with UsersPage

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

Example 5 with UsersPage

use of com.auth0.json.mgmt.users.UsersPage in project auth0-java by auth0.

the class UsersEntityTest method shouldListUsersWithTotals.

@Test
public void shouldListUsersWithTotals() throws Exception {
    UserFilter filter = new UserFilter().withTotals(true);
    Request<UsersPage> request = api.users().list(filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_USERS_PAGED_LIST, 200);
    UsersPage response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/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));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) UserFilter(com.auth0.client.mgmt.filter.UserFilter) UsersPage(com.auth0.json.mgmt.users.UsersPage) Test(org.junit.Test)

Aggregations

UsersPage (com.auth0.json.mgmt.users.UsersPage)11 Test (org.junit.Test)11 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)10 UserFilter (com.auth0.client.mgmt.filter.UserFilter)5 PageFilter (com.auth0.client.mgmt.filter.PageFilter)3