use of org.folio.rest.jaxrs.model.JobExecution in project mod-source-record-manager by folio-org.
the class ChangeManagerAPITest method shouldSetTotalZeroToJobExecutionOnUpdateStatusToError.
@Test
public void shouldSetTotalZeroToJobExecutionOnUpdateStatusToError() {
InitJobExecutionsRsDto response = constructAndPostInitJobExecutionRqDto(1);
List<JobExecution> createdJobExecutions = response.getJobExecutions();
assertThat(createdJobExecutions.size(), is(1));
JobExecution jobExecution = createdJobExecutions.get(0);
assertThat(jobExecution.getSubordinationType(), is(JobExecution.SubordinationType.PARENT_SINGLE));
Assert.assertNotNull(jobExecution.getRunBy().getFirstName());
Assert.assertNotNull(jobExecution.getRunBy().getLastName());
StatusDto status = new StatusDto().withStatus(ERROR).withErrorStatus(StatusDto.ErrorStatus.FILE_PROCESSING_ERROR);
RestAssured.given().spec(spec).body(JsonObject.mapFrom(status).toString()).when().put(JOB_EXECUTION_PATH + jobExecution.getId() + STATUS_PATH).then().statusCode(HttpStatus.SC_OK).body("status", is(status.getStatus().name())).body("uiStatus", is(Status.valueOf(status.getStatus().name()).getUiStatus())).body("errorStatus", is(status.getErrorStatus().toString())).body("completedDate", notNullValue(Date.class));
RestAssured.given().spec(spec).when().get(JOB_EXECUTION_PATH + jobExecution.getId()).then().statusCode(HttpStatus.SC_OK).body("status", is(status.getStatus().name())).body("uiStatus", is(Status.valueOf(status.getStatus().name()).getUiStatus())).body("errorStatus", is(status.getErrorStatus().toString())).body("completedDate", notNullValue(Date.class)).body("progress.total", is(0));
}
use of org.folio.rest.jaxrs.model.JobExecution in project mod-source-record-manager by folio-org.
the class ChangeManagerAPITest method shouldSetCompletedDateToJobExecutionOnUpdateStatusToError.
@Test
public void shouldSetCompletedDateToJobExecutionOnUpdateStatusToError() {
InitJobExecutionsRsDto response = constructAndPostInitJobExecutionRqDto(1);
List<JobExecution> createdJobExecutions = response.getJobExecutions();
assertThat(createdJobExecutions.size(), is(1));
JobExecution jobExecution = createdJobExecutions.get(0);
assertThat(jobExecution.getSubordinationType(), is(JobExecution.SubordinationType.PARENT_SINGLE));
Assert.assertNotNull(jobExecution.getRunBy().getFirstName());
Assert.assertNotNull(jobExecution.getRunBy().getLastName());
StatusDto status = new StatusDto().withStatus(ERROR).withErrorStatus(StatusDto.ErrorStatus.FILE_PROCESSING_ERROR);
RestAssured.given().spec(spec).body(JsonObject.mapFrom(status).toString()).when().put(JOB_EXECUTION_PATH + jobExecution.getId() + STATUS_PATH).then().statusCode(HttpStatus.SC_OK).body("status", is(status.getStatus().name())).body("uiStatus", is(Status.valueOf(status.getStatus().name()).getUiStatus())).body("errorStatus", is(status.getErrorStatus().toString())).body("completedDate", notNullValue(Date.class));
RestAssured.given().spec(spec).when().get(JOB_EXECUTION_PATH + jobExecution.getId()).then().statusCode(HttpStatus.SC_OK).body("status", is(status.getStatus().name())).body("uiStatus", is(Status.valueOf(status.getStatus().name()).getUiStatus())).body("errorStatus", is(status.getErrorStatus().toString())).body("completedDate", notNullValue(Date.class));
}
use of org.folio.rest.jaxrs.model.JobExecution in project mod-source-record-manager by folio-org.
the class ChangeManagerAPITest method shouldProcessChunksAndRequestForMappingParameters1Time.
@Test
public void shouldProcessChunksAndRequestForMappingParameters1Time(TestContext testContext) {
// given
InitJobExecutionsRsDto response = constructAndPostInitJobExecutionRqDto(1);
List<JobExecution> createdJobExecutions = response.getJobExecutions();
assertThat(createdJobExecutions.size(), is(1));
JobExecution jobExec = createdJobExecutions.get(0);
WireMock.stubFor(post(RECORDS_SERVICE_URL).willReturn(created().withTransformers(RequestToResponseTransformer.NAME)));
Async async = testContext.async();
RestAssured.given().spec(spec).body(new JobProfileInfo().withName("MARC records").withId(DEFAULT_JOB_PROFILE_ID).withDataType(JobProfileInfo.DataType.MARC)).when().put(JOB_EXECUTION_PATH + jobExec.getId() + JOB_PROFILE_PATH).then().statusCode(HttpStatus.SC_OK);
async.complete();
// when
async = testContext.async();
RestAssured.given().spec(spec).body(rawRecordsDto).when().post(JOB_EXECUTION_PATH + jobExec.getId() + RECORDS_PATH).then().statusCode(HttpStatus.SC_NO_CONTENT);
async.complete();
async = testContext.async();
RestAssured.given().spec(spec).body(rawRecordsDto).when().post(JOB_EXECUTION_PATH + jobExec.getId() + RECORDS_PATH).then().statusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
async.complete();
// then
async = testContext.async();
RestAssured.given().spec(spec).when().get(JOB_EXECUTION_PATH + jobExec.getId()).then().statusCode(HttpStatus.SC_OK).body("status", is(JobExecution.Status.PARSING_IN_PROGRESS.name())).body("runBy.firstName", is("DIKU")).body("progress.total", is(100)).body("startedDate", notNullValue(Date.class)).log().all();
verify(1, getRequestedFor(urlEqualTo(IDENTIFIER_TYPES_URL)));
verify(1, getRequestedFor(urlEqualTo(INSTANCE_TYPES_URL)));
verify(1, getRequestedFor(urlEqualTo(CLASSIFICATION_TYPES_URL)));
verify(1, getRequestedFor(urlEqualTo(INSTANCE_FORMATS_URL)));
verify(1, getRequestedFor(urlEqualTo(CONTRIBUTOR_TYPES_URL)));
verify(1, getRequestedFor(urlEqualTo(CONTRIBUTOR_NAME_TYPES_URL)));
verify(1, getRequestedFor(urlEqualTo(ELECTRONIC_ACCESS_URL)));
verify(1, getRequestedFor(urlEqualTo(INSTANCE_NOTE_TYPES_URL)));
verify(1, getRequestedFor(urlEqualTo(INSTANCE_ALTERNATIVE_TITLE_TYPES_URL)));
verify(1, getRequestedFor(urlEqualTo(MODE_OF_ISSUANCE_TYPES_URL)));
verify(1, getRequestedFor(urlEqualTo(INSTANCE_STATUSES_URL)));
verify(1, getRequestedFor(urlEqualTo(NATURE_OF_CONTENT_TERMS_URL)));
verify(1, getRequestedFor(urlEqualTo(INSTANCE_RELATIONSHIP_TYPES_URL)));
verify(1, getRequestedFor(urlEqualTo(HOLDINGS_TYPES_URL)));
verify(1, getRequestedFor(urlEqualTo(HOLDINGS_NOTE_TYPES_URL)));
verify(1, getRequestedFor(urlEqualTo(ILL_POLICIES_URL)));
verify(1, getRequestedFor(urlEqualTo(CALL_NUMBER_TYPES_URL)));
verify(1, getRequestedFor(urlEqualTo(STATISTICAL_CODES_URL)));
verify(1, getRequestedFor(urlEqualTo(STATISTICAL_CODE_TYPES_URL)));
verify(1, getRequestedFor(urlEqualTo(LOCATIONS_URL)));
verify(1, getRequestedFor(urlEqualTo(MATERIAL_TYPES_URL)));
verify(1, getRequestedFor(urlEqualTo(ITEM_DAMAGED_STATUSES_URL)));
verify(1, getRequestedFor(urlEqualTo(LOAN_TYPES_URL)));
verify(1, getRequestedFor(urlEqualTo(ITEM_NOTE_TYPES_URL)));
verify(1, getRequestedFor(urlEqualTo(AUTHORITY_NOTE_TYPES_URL)));
verify(1, getRequestedFor(urlEqualTo(FIELD_PROTECTION_SETTINGS_URL)));
verify(1, getRequestedFor(urlEqualTo(TENANT_CONFIGURATIONS_SETTINGS_URL)));
async.complete();
}
use of org.folio.rest.jaxrs.model.JobExecution in project mod-source-record-manager by folio-org.
the class ChangeManagerAPITest method testInitJobExecutionsWith2Files.
@Test
public void testInitJobExecutionsWith2Files() {
// given
int expectedParentJobExecutions = 1;
int expectedChildJobExecutions = 2;
int expectedJobExecutionsNumber = expectedParentJobExecutions + expectedChildJobExecutions;
// when
InitJobExecutionsRsDto response = constructAndPostInitJobExecutionRqDto(expectedChildJobExecutions);
// then
String actualParentJobExecutionId = response.getParentJobExecutionId();
List<JobExecution> actualJobExecutions = response.getJobExecutions();
Assert.assertNotNull(actualParentJobExecutionId);
assertEquals(expectedJobExecutionsNumber, actualJobExecutions.size());
int actualParentJobExecutions = 0;
int actualChildJobExecutions = 0;
for (JobExecution actualJobExecution : actualJobExecutions) {
if (JobExecution.SubordinationType.PARENT_MULTIPLE.equals(actualJobExecution.getSubordinationType())) {
assertParent(actualJobExecution);
actualParentJobExecutions++;
} else {
assertChild(actualJobExecution, actualParentJobExecutionId);
actualChildJobExecutions++;
}
}
assertEquals(expectedParentJobExecutions, actualParentJobExecutions);
assertEquals(expectedChildJobExecutions, actualChildJobExecutions);
}
use of org.folio.rest.jaxrs.model.JobExecution in project mod-source-record-manager by folio-org.
the class ChangeManagerAPITest method shouldNotUpdateMultipleParentStatusOnPut.
@Test
public void shouldNotUpdateMultipleParentStatusOnPut() {
InitJobExecutionsRsDto response = constructAndPostInitJobExecutionRqDto(2);
List<JobExecution> createdJobExecutions = response.getJobExecutions();
assertThat(createdJobExecutions.size(), is(3));
JobExecution multipleParent = createdJobExecutions.stream().filter(jobExec -> jobExec.getSubordinationType().equals(JobExecution.SubordinationType.PARENT_MULTIPLE)).findFirst().get();
multipleParent.setStatus(JobExecution.Status.PARSING_IN_PROGRESS);
RestAssured.given().spec(spec).body(JsonObject.mapFrom(multipleParent).toString()).when().put(JOB_EXECUTION_PATH + multipleParent.getId()).then().statusCode(HttpStatus.SC_BAD_REQUEST);
RestAssured.given().spec(spec).when().get(JOB_EXECUTION_PATH + multipleParent.getId()).then().statusCode(HttpStatus.SC_OK).body("status", is(JobExecution.Status.PARENT.name())).body("uiStatus", is(JobExecution.UiStatus.PARENT.name()));
}
Aggregations