use of org.folio.rest.jaxrs.model.RecordsMetadata 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.RecordsMetadata in project mod-source-record-manager by folio-org.
the class RecordProcessedEventHandlingServiceImplTest method shouldMarkJobExecutionAsCommittedOnHandleEventWhenAllRecordsSuccessfullyProcessed.
@Test
public void shouldMarkJobExecutionAsCommittedOnHandleEventWhenAllRecordsSuccessfullyProcessed(TestContext context) {
// given
Async async = context.async();
RawRecordsDto rawRecordsDto = new RawRecordsDto().withInitialRecords(Collections.singletonList(new InitialRecord().withRecord(CORRECT_RAW_RECORD))).withRecordsMetadata(new RecordsMetadata().withLast(false).withCounter(1).withTotal(1).withContentType(RecordsMetadata.ContentType.MARC_RAW));
HashMap<String, String> payloadContext = new HashMap<>();
DataImportEventPayload dataImportEventPayload = new DataImportEventPayload().withEventType(DataImportEventTypes.DI_COMPLETED.value()).withContext(payloadContext);
Future<Boolean> future = jobExecutionService.initializeJobExecutions(initJobExecutionsRqDto, params).compose(initJobExecutionsRsDto -> jobExecutionService.setJobProfileToJobExecution(initJobExecutionsRsDto.getParentJobExecutionId(), jobProfileInfo, params)).compose(jobExecution -> {
dataImportEventPayload.setJobExecutionId(jobExecution.getId());
return chunkProcessingService.processChunk(rawRecordsDto, jobExecution.getId(), params);
});
// when
Future<Optional<JobExecution>> jobFuture = future.compose(ar -> recordProcessedEventHandlingService.handle(Json.encode(dataImportEventPayload), params)).compose(ar -> jobExecutionService.getJobExecutionById(dataImportEventPayload.getJobExecutionId(), TENANT_ID));
// then
jobFuture.onComplete(ar -> {
context.assertTrue(ar.succeeded());
context.assertTrue(ar.result().isPresent());
JobExecution jobExecution = ar.result().get();
context.assertEquals(COMMITTED, jobExecution.getStatus());
context.assertEquals(RUNNING_COMPLETE, jobExecution.getUiStatus());
context.assertEquals(rawRecordsDto.getRecordsMetadata().getTotal(), jobExecution.getProgress().getTotal());
context.assertNotNull(jobExecution.getStartedDate());
context.assertNotNull(jobExecution.getCompletedDate());
async.complete();
});
}
use of org.folio.rest.jaxrs.model.RecordsMetadata in project mod-source-record-manager by folio-org.
the class ChangeManagerAPITest method shouldNotParseChunkOfRawRecordsIfRecordListEmpty.
@Test
public void shouldNotParseChunkOfRawRecordsIfRecordListEmpty() {
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)));
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);
RestAssured.given().spec(spec).body(new RawRecordsDto().withRecordsMetadata(new RecordsMetadata().withContentType(RecordsMetadata.ContentType.MARC_RAW).withLast(false).withCounter(1)).withId(UUID.randomUUID().toString())).when().post(JOB_EXECUTION_PATH + jobExec.getId() + RECORDS_PATH).then().statusCode(HttpStatus.SC_NO_CONTENT);
}
Aggregations