use of com.auth0.net.Request 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.net.Request 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.net.Request 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.net.Request in project auth0-java by auth0.
the class JobsEntityTest method shouldGetJobErrorDetails.
@Test
public void shouldGetJobErrorDetails() throws Exception {
Request<List<JobErrorDetails>> request = api.jobs().getErrorDetails("1");
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_JOB_ERROR_DETAILS, 200);
List<JobErrorDetails> response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/jobs/1/errors"));
assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
assertThat(response, is(notNullValue()));
assertThat(response, hasSize(1));
assertThat(response.get(0).getErrors(), hasSize(1));
}
use of com.auth0.net.Request in project auth0-java by auth0.
the class LogEventsEntityTest method shouldListLogEventsWithSort.
@Test
public void shouldListLogEventsWithSort() throws Exception {
LogEventFilter filter = new LogEventFilter().withSort("date:1");
Request<LogEventsPage> request = api.logEvents().list(filter);
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_LOG_EVENTS_LIST, 200);
LogEventsPage response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/logs"));
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));
}
Aggregations