use of org.folio.rest.jaxrs.model.StatusDto in project mod-source-record-manager by folio-org.
the class EventDrivenChunkProcessingServiceImplTest method shouldSendEventsWithSuccessfullyParsedRecords.
@Test
public void shouldSendEventsWithSuccessfullyParsedRecords(TestContext context) {
Async async = context.async();
RawRecordsDto rawRecordsDto = new RawRecordsDto().withRecordsMetadata(new RecordsMetadata().withLast(false).withCounter(1).withContentType(RecordsMetadata.ContentType.MARC_RAW)).withInitialRecords(Arrays.asList(new InitialRecord().withRecord(CORRECT_RAW_RECORD), new InitialRecord().withRecord(CORRECT_RAW_RECORD), new InitialRecord().withRecord(RAW_RECORD_RESULTING_IN_PARSING_ERROR)));
Future<Boolean> future = jobExecutionService.initializeJobExecutions(initJobExecutionsRqDto, params).compose(initJobExecutionsRsDto -> jobExecutionService.setJobProfileToJobExecution(initJobExecutionsRsDto.getParentJobExecutionId(), jobProfileInfo, params)).compose(jobExecution -> chunkProcessingService.processChunk(rawRecordsDto, jobExecution.getId(), params));
future.onComplete(ar -> {
context.assertTrue(ar.succeeded());
ArgumentCaptor<StatusDto> captor = ArgumentCaptor.forClass(StatusDto.class);
Mockito.verify(jobExecutionService).updateJobExecutionStatus(anyString(), captor.capture(), isA(OkapiConnectionParams.class));
context.assertTrue(PARSING_IN_PROGRESS.equals(captor.getValue().getStatus()));
verify(1, postRequestedFor(urlPathEqualTo(SNAPSHOT_SERVICE_URL)));
async.complete();
});
}
use of org.folio.rest.jaxrs.model.StatusDto in project mod-source-record-manager by folio-org.
the class EventDrivenChunkProcessingServiceImplTest method shouldReturnSucceededFutureWhenFailedPostSnapshotsToRecordsStorage.
@Test
public void shouldReturnSucceededFutureWhenFailedPostSnapshotsToRecordsStorage(TestContext context) {
Async async = context.async();
WireMock.stubFor(put(SNAPSHOT_SERVICE_URL).willReturn(WireMock.serverError()));
Future<Boolean> future = jobExecutionService.initializeJobExecutions(initJobExecutionsRqDto, params).compose(initJobExecutionsRsDto -> jobExecutionService.setJobProfileToJobExecution(initJobExecutionsRsDto.getParentJobExecutionId(), jobProfileInfo, params)).compose(jobExecution -> chunkProcessingService.processChunk(rawRecordsDto, jobExecution.getId(), params));
future.onComplete(ar -> {
context.assertTrue(ar.succeeded());
ArgumentCaptor<StatusDto> captor = ArgumentCaptor.forClass(StatusDto.class);
Mockito.verify(jobExecutionService, times(1)).updateJobExecutionStatus(anyString(), captor.capture(), isA(OkapiConnectionParams.class));
verify(1, postRequestedFor(urlEqualTo(SNAPSHOT_SERVICE_URL)));
async.complete();
});
}
use of org.folio.rest.jaxrs.model.StatusDto in project mod-source-record-manager by folio-org.
the class ChangeManagerAPITest method shouldReturnNotFoundOnStatusUpdate.
@Test
public void shouldReturnNotFoundOnStatusUpdate() {
StatusDto status = new StatusDto().withStatus(StatusDto.Status.NEW);
RestAssured.given().spec(spec).body(JsonObject.mapFrom(status).toString()).when().put(JOB_EXECUTION_PATH + UUID.randomUUID().toString() + STATUS_PATH).then().statusCode(HttpStatus.SC_NOT_FOUND);
}
use of org.folio.rest.jaxrs.model.StatusDto in project mod-source-record-manager by folio-org.
the class ChangeManagerAPITest method shouldNotUpdateStatusOfDeletedRecords.
@Test
public void shouldNotUpdateStatusOfDeletedRecords() {
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();
DeleteJobExecutionsResp deleteJobExecutionsResp = returnDeletedJobExecutionResponse(new String[] { child.getId() });
assertThat(deleteJobExecutionsResp.getJobExecutionDetails().get(0).getJobExecutionId(), is(child.getId()));
assertThat(deleteJobExecutionsResp.getJobExecutionDetails().get(0).getIsDeleted(), is(true));
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_NOT_FOUND);
}
use of org.folio.rest.jaxrs.model.StatusDto in project mod-source-record-manager by folio-org.
the class ChangeManagerAPITest method shouldNotUpdateStatusToParent.
@Test
public void shouldNotUpdateStatusToParent() {
InitJobExecutionsRsDto response = constructAndPostInitJobExecutionRqDto(1);
List<JobExecution> createdJobExecutions = response.getJobExecutions();
assertThat(createdJobExecutions.size(), is(1));
JobExecution jobExec = createdJobExecutions.get(0);
StatusDto status = new StatusDto().withStatus(StatusDto.Status.PARENT);
RestAssured.given().spec(spec).body(JsonObject.mapFrom(status).toString()).when().put(JOB_EXECUTION_PATH + jobExec.getId() + STATUS_PATH).then().statusCode(HttpStatus.SC_BAD_REQUEST);
RestAssured.given().spec(spec).when().get(JOB_EXECUTION_PATH + jobExec.getId()).then().statusCode(HttpStatus.SC_OK).body("status", is(jobExec.getStatus().name())).body("uiStatus", is(jobExec.getUiStatus().name()));
}
Aggregations