use of com.auth0.client.mgmt.filter.UserFilter in project auth0-java by auth0.
the class UsersEntityTest method shouldGetUserWithFields.
@Test
public void shouldGetUserWithFields() throws Exception {
UserFilter filter = new UserFilter().withFields("some,random,fields", true);
Request<User> request = api.users().get("1", filter);
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_USER, 200);
User response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/users/1"));
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()));
}
use of com.auth0.client.mgmt.filter.UserFilter 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));
}
use of com.auth0.client.mgmt.filter.UserFilter 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.client.mgmt.filter.UserFilter 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.client.mgmt.filter.UserFilter 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));
}
Aggregations