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));
}
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));
}
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));
}
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));
}
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)));
}
Aggregations