Search in sources :

Example 1 with JobErrorDetails

use of com.auth0.json.mgmt.jobs.JobErrorDetails in project auth0-java by auth0.

the class JobsEntityTest method shouldGetJobErrorDetails_noErrors.

@Test
public void shouldGetJobErrorDetails_noErrors() throws Exception {
    Request<List<JobErrorDetails>> request = api.jobs().getErrorDetails("1");
    assertThat(request, is(notNullValue()));
    server.noContentResponse();
    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, is(empty()));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) JobErrorDetails(com.auth0.json.mgmt.jobs.JobErrorDetails) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 2 with JobErrorDetails

use of com.auth0.json.mgmt.jobs.JobErrorDetails 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));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) JobErrorDetails(com.auth0.json.mgmt.jobs.JobErrorDetails) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 3 with JobErrorDetails

use of com.auth0.json.mgmt.jobs.JobErrorDetails in project auth0-java by auth0.

the class JobErrorDetailsTest method shouldSerialize.

@Test
public void shouldSerialize() throws JsonProcessingException {
    User user = new User();
    user.setEmail("john.doe@gmail.com");
    JobError error = new JobError("code", "message", "path");
    JobErrorDetails errorDetails = new JobErrorDetails(user, Collections.singletonList(error));
    String serialized = toJSON(errorDetails);
    assertThat(serialized, is(equalTo(json)));
}
Also used : User(com.auth0.json.mgmt.users.User) JsonTest(com.auth0.json.JsonTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 JobErrorDetails (com.auth0.json.mgmt.jobs.JobErrorDetails)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)2 JsonTest (com.auth0.json.JsonTest)1 User (com.auth0.json.mgmt.users.User)1