use of org.folio.rest.jaxrs.model.StatusDto in project mod-source-record-manager by folio-org.
the class EventDrivenChunkProcessingServiceImpl method processRawRecordsChunk.
@Override
protected Future<Boolean> processRawRecordsChunk(RawRecordsDto incomingChunk, JobExecutionSourceChunk sourceChunk, String jobExecutionId, OkapiConnectionParams params) {
LOGGER.debug("Starting to process raw records chunk with id: {} for jobExecutionId: {}. Chunk size: {}.", sourceChunk.getId(), jobExecutionId, sourceChunk.getChunkSize());
Promise<Boolean> promise = Promise.promise();
initializeJobExecutionProgressIfNecessary(jobExecutionId, incomingChunk, params.getTenantId()).compose(ar -> checkAndUpdateJobExecutionStatusIfNecessary(jobExecutionId, new StatusDto().withStatus(StatusDto.Status.PARSING_IN_PROGRESS), params)).compose(jobExec -> changeEngineService.parseRawRecordsChunkForJobExecution(incomingChunk, jobExec, sourceChunk.getId(), params)).onComplete(sendEventsAr -> updateJobExecutionIfAllSourceChunksMarkedAsError(jobExecutionId, params).onComplete(updateAr -> promise.handle(sendEventsAr.map(true))));
return promise.future();
}
use of org.folio.rest.jaxrs.model.StatusDto in project mod-source-record-manager by folio-org.
the class ChangeManagerAPITest method shouldReturn204OkEventIfRemoveJobExecutionWithCommittedStatus.
@Test
public void shouldReturn204OkEventIfRemoveJobExecutionWithCommittedStatus(TestContext testContext) {
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)));
WireMock.stubFor(WireMock.delete(new UrlPathPattern(new RegexPattern(SNAPSHOT_SERVICE_URL + "/.*"), true)).willReturn(WireMock.noContent()));
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();
async = testContext.async();
RestAssured.given().spec(spec).body(rawRecordsDto.withId(UUID.randomUUID().toString())).when().post(JOB_EXECUTION_PATH + jobExec.getId() + RECORDS_PATH).then().statusCode(HttpStatus.SC_NO_CONTENT);
async.complete();
StatusDto status = new StatusDto().withStatus(COMMITTED);
RestAssured.given().spec(spec).body(JsonObject.mapFrom(status).toString()).when().put(JOB_EXECUTION_PATH + jobExec.getId() + STATUS_PATH).then().statusCode(HttpStatus.SC_OK);
async = testContext.async();
RestAssured.given().spec(spec).when().delete(JOB_EXECUTION_PATH + jobExec.getId() + RECORDS_PATH).then().statusCode(HttpStatus.SC_NO_CONTENT);
async.complete();
async = testContext.async();
RestAssured.given().spec(spec).when().get(JOB_EXECUTION_PATH + jobExec.getId()).then().statusCode(HttpStatus.SC_OK).body("status", is(COMMITTED.value()));
async.complete();
}
use of org.folio.rest.jaxrs.model.StatusDto 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.StatusDto 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.StatusDto in project mod-source-record-manager by folio-org.
the class ChangeManagerAPITest method shouldUpdateStatusOfChild.
@Test
public void shouldUpdateStatusOfChild() {
InitJobExecutionsRsDto response = constructAndPostInitJobExecutionRqDto(3);
List<JobExecution> createdJobExecutions = response.getJobExecutions();
assertThat(createdJobExecutions.size(), is(4));
JobExecution child = createdJobExecutions.stream().filter(jobExec -> jobExec.getSubordinationType().equals(JobExecution.SubordinationType.CHILD)).findFirst().get();
StatusDto status = new StatusDto().withStatus(StatusDto.Status.PARSING_IN_PROGRESS);
RestAssured.given().spec(spec).body(JsonObject.mapFrom(status).toString()).when().put(JOB_EXECUTION_PATH + child.getId() + STATUS_PATH).then().statusCode(HttpStatus.SC_OK).body("status", is(status.getStatus().name())).body("uiStatus", is(Status.valueOf(status.getStatus().name()).getUiStatus()));
RestAssured.given().spec(spec).when().get(JOB_EXECUTION_PATH + child.getId()).then().statusCode(HttpStatus.SC_OK).body("status", is(status.getStatus().name())).body("uiStatus", is(Status.valueOf(status.getStatus().name()).getUiStatus()));
}
Aggregations