use of com.auth0.client.mgmt.filter.UsersExportFilter in project auth0-java by auth0.
the class JobsEntityTest method shouldRequestUsersExportWithLimit.
@Test
public void shouldRequestUsersExportWithLimit() throws Exception {
UsersExportFilter filter = new UsersExportFilter();
filter.withLimit(82);
Request<Job> request = api.jobs().exportUsers("con_123456789", filter);
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_JOB_POST_USERS_EXPORTS, 200);
Job response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("POST", "/api/v2/jobs/users-exports"));
assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
Map<String, Object> body = bodyFromRequest(recordedRequest);
assertThat(body.size(), is(2));
assertThat(body, hasEntry("connection_id", "con_123456789"));
assertThat(body, hasEntry("limit", 82));
assertThat(response, is(notNullValue()));
}
use of com.auth0.client.mgmt.filter.UsersExportFilter in project auth0-java by auth0.
the class JobsEntityTest method shouldRequestUsersExportWithFormat.
@Test
public void shouldRequestUsersExportWithFormat() throws Exception {
UsersExportFilter filter = new UsersExportFilter();
filter.withFormat("csv");
Request<Job> request = api.jobs().exportUsers("con_123456789", filter);
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_JOB_POST_USERS_EXPORTS, 200);
Job response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("POST", "/api/v2/jobs/users-exports"));
assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
Map<String, Object> body = bodyFromRequest(recordedRequest);
assertThat(body.size(), is(2));
assertThat(body, hasEntry("connection_id", "con_123456789"));
assertThat(body, hasEntry("format", "csv"));
assertThat(response, is(notNullValue()));
}
use of com.auth0.client.mgmt.filter.UsersExportFilter in project auth0-java by auth0.
the class JobsEntityTest method shouldRequestUsersExportWithFields.
@Test
public void shouldRequestUsersExportWithFields() throws Exception {
UsersExportFilter filter = new UsersExportFilter();
ArrayList<UsersExportField> fields = new ArrayList<>();
fields.add(new UsersExportField("full_name"));
fields.add(new UsersExportField("user_metadata.company_name", "company"));
filter.withFields(fields);
Request<Job> request = api.jobs().exportUsers("con_123456789", filter);
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_JOB_POST_USERS_EXPORTS, 200);
Job response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("POST", "/api/v2/jobs/users-exports"));
assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
Map<String, Object> body = bodyFromRequest(recordedRequest);
assertThat(body.size(), is(2));
assertThat(body, hasEntry("connection_id", "con_123456789"));
assertThat(body, hasKey("fields"));
@SuppressWarnings("unchecked") List<Map<String, String>> bodyFields = (List<Map<String, String>>) body.get("fields");
assertThat(bodyFields.get(0).get("name"), is("full_name"));
assertThat(bodyFields.get(0).get("export_as"), is(nullValue()));
assertThat(bodyFields.get(1).get("name"), is("user_metadata.company_name"));
assertThat(bodyFields.get(1).get("export_as"), is("company"));
assertThat(response, is(notNullValue()));
}
use of com.auth0.client.mgmt.filter.UsersExportFilter in project auth0-java by auth0.
the class UsersExportFilterTest method shouldFilterByFields.
@Test
public void shouldFilterByFields() {
ArrayList<UsersExportField> fields = new ArrayList<>();
fields.add(new UsersExportField("first_name"));
fields.add(new UsersExportField("last_name"));
fields.add(new UsersExportField("metadata.custom_property", "custom"));
filter.withFields(fields);
UsersExportFilter instance = filter.withFields(fields);
assertThat(filter, is(instance));
assertThat(filter.getAsMap(), is(notNullValue()));
assertThat(filter.getAsMap(), Matchers.hasKey("fields"));
@SuppressWarnings("unchecked") List<UsersExportField> bodyFields = (List<UsersExportField>) filter.getAsMap().get("fields");
assertThat(bodyFields.get(0).getName(), is("first_name"));
assertThat(bodyFields.get(0).getExportAs(), is(nullValue()));
assertThat(bodyFields.get(1).getName(), is("last_name"));
assertThat(bodyFields.get(1).getExportAs(), is(nullValue()));
assertThat(bodyFields.get(2).getName(), is("metadata.custom_property"));
assertThat(bodyFields.get(2).getExportAs(), is("custom"));
}
Aggregations