Search in sources :

Example 11 with UsersPage

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

the class UsersEntityTest method shouldListUsersWithFields.

@Test
public void shouldListUsersWithFields() throws Exception {
    UserFilter filter = new UserFilter().withFields("some,random,fields", true);
    Request<UsersPage> request = api.users().list(filter);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_USERS_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("fields", "some,random,fields"));
    assertThat(recordedRequest, hasQueryParameter("include_fields", "true"));
    assertThat(response, is(notNullValue()));
    assertThat(response.getItems(), hasSize(2));
}
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