Search in sources :

Example 6 with UsersPage

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

the class UsersEntityTest method shouldListUsers.

@Test
public void shouldListUsers() throws Exception {
    Request<UsersPage> request = api.users().list(null);
    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(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 7 with UsersPage

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

the class UsersEntityTest method shouldListUsersWithPage.

@Test
public void shouldListUsersWithPage() throws Exception {
    UserFilter filter = new UserFilter().withPage(23, 5);
    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("page", "23"));
    assertThat(recordedRequest, hasQueryParameter("per_page", "5"));
    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)

Example 8 with UsersPage

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

the class UsersEntityTest method shouldListUsersWithSort.

@Test
public void shouldListUsersWithSort() throws Exception {
    UserFilter filter = new UserFilter().withSort("date:1");
    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("sort", "date:1"));
    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)

Example 9 with UsersPage

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

the class UsersEntityTest method shouldListUsersWithQuery.

@Test
public void shouldListUsersWithQuery() throws Exception {
    UserFilter filter = new UserFilter().withQuery("email:\\*@gmail.com");
    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, not(hasQueryParameter("search_engine")));
    assertThat(recordedRequest, hasQueryParameter("q", "email:\\*@gmail.com"));
    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)

Example 10 with UsersPage

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

the class UsersEntityTest method shouldReturnEmptyUsers.

@Test
public void shouldReturnEmptyUsers() throws Exception {
    Request<UsersPage> request = api.users().list(null);
    assertThat(request, is(notNullValue()));
    server.jsonResponse(MGMT_EMPTY_LIST, 200);
    UsersPage response = request.execute();
    assertThat(response, is(notNullValue()));
    assertThat(response.getItems(), is(emptyCollectionOf(User.class)));
}
Also used : 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