Search in sources :

Example 6 with UserFilter

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

UserFilter (com.auth0.client.mgmt.filter.UserFilter)6 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)6 Test (org.junit.Test)6 UsersPage (com.auth0.json.mgmt.users.UsersPage)5 User (com.auth0.json.mgmt.users.User)1