use of org.folio.rest.jaxrs.model.JobProfileInfo in project mod-source-record-manager by folio-org.
the class MetadataProviderJobExecutionAPITest method shouldReturnUsersInfoCollection.
@Test
public void shouldReturnUsersInfoCollection() {
int uniqueJobProfilesAmount = 5;
List<JobExecution> createdJobExecution = constructAndPostInitJobExecutionRqDto(uniqueJobProfilesAmount).getJobExecutions();
getBeanFromSpringContext(vertx, JobExecutionsCache.class).evictCache();
List<JobExecution> children = createdJobExecution.stream().filter(jobExec -> jobExec.getSubordinationType().equals(CHILD)).collect(Collectors.toList());
for (JobExecution jobExecution : children) {
jobExecution.setJobProfileInfo(new JobProfileInfo().withId(UUID.randomUUID().toString()).withName("Marc jobs profile"));
RestAssured.given().spec(spec).body(JsonObject.mapFrom(jobExecution).toString()).when().put(JOB_EXECUTION_PATH + jobExecution.getId()).then().statusCode(HttpStatus.SC_OK).body("id", is(jobExecution.getId()));
}
RestAssured.given().spec(spec).when().get(GET_UNIQUE_USERS_INFO).then().statusCode(HttpStatus.SC_OK).body("jobExecutionUsersInfo[0].userId", notNullValue()).body("jobExecutionUsersInfo[0].jobUserFirstName", is("DIKU")).body("jobExecutionUsersInfo[0].jobUserLastName", is("ADMINISTRATOR")).body("totalRecords", is(1));
}
use of org.folio.rest.jaxrs.model.JobProfileInfo in project mod-source-record-manager by folio-org.
the class MetadataProviderJobExecutionAPITest method shouldReturnLimitedRelatedProfilesCollectionOnGetWithLimit.
@Test
public void shouldReturnLimitedRelatedProfilesCollectionOnGetWithLimit() {
int uniqueJobProfilesAmount = 5;
int limitNumber = 3;
List<JobExecution> createdJobExecution = constructAndPostInitJobExecutionRqDto(uniqueJobProfilesAmount).getJobExecutions();
getBeanFromSpringContext(vertx, JobExecutionsCache.class).evictCache();
List<JobExecution> children = createdJobExecution.stream().filter(jobExec -> jobExec.getSubordinationType().equals(CHILD)).collect(Collectors.toList());
for (JobExecution jobExecution : children) {
jobExecution.setJobProfileInfo(new JobProfileInfo().withId(UUID.randomUUID().toString()).withName("Marc jobs profile"));
RestAssured.given().spec(spec).body(JsonObject.mapFrom(jobExecution).toString()).when().put(JOB_EXECUTION_PATH + jobExecution.getId()).then().statusCode(HttpStatus.SC_OK).body("id", is(jobExecution.getId()));
}
RestAssured.given().spec(spec).param("limit", limitNumber).when().get(GET_JOB_EXECUTION_JOB_PROFILES_PATH).then().statusCode(HttpStatus.SC_OK).body("jobProfilesInfo", hasSize(limitNumber)).body("totalRecords", is(uniqueJobProfilesAmount));
}
use of org.folio.rest.jaxrs.model.JobProfileInfo in project mod-source-record-manager by folio-org.
the class EventDrivenChunkProcessingServiceImplTest method shouldProcessErrorRawRecord.
@Test
public void shouldProcessErrorRawRecord(TestContext context) {
Async async = context.async();
RawRecordsDto rawRecordsDto = new RawRecordsDto().withRecordsMetadata(new RecordsMetadata().withLast(false).withCounter(1).withContentType(RecordsMetadata.ContentType.MARC_RAW)).withInitialRecords(Collections.singletonList(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, times(1)).updateJobExecutionStatus(anyString(), captor.capture(), isA(OkapiConnectionParams.class));
context.assertTrue(PARSING_IN_PROGRESS.equals(captor.getAllValues().get(0).getStatus()));
verify(1, postRequestedFor(urlEqualTo(SNAPSHOT_SERVICE_URL)));
async.complete();
});
}
use of org.folio.rest.jaxrs.model.JobProfileInfo in project mod-source-record-manager by folio-org.
the class EventDrivenChunkProcessingServiceImplTest method shouldMarkJobExecutionAsErrorWhenFailedPostRecordsToRecordsStorage.
@Test
public void shouldMarkJobExecutionAsErrorWhenFailedPostRecordsToRecordsStorage(TestContext context) {
Async async = context.async();
RawRecordsDto lastRawRecordsDto = new RawRecordsDto().withRecordsMetadata(new RecordsMetadata().withLast(true).withCounter(15).withTotal(15).withContentType(RecordsMetadata.ContentType.MARC_RAW)).withInitialRecords(rawRecordsDto.getInitialRecords());
WireMock.stubFor(WireMock.post(SNAPSHOT_SERVICE_URL).willReturn(WireMock.serverError()));
Future<Optional<JobExecution>> jobFuture = jobExecutionService.initializeJobExecutions(initJobExecutionsRqDto, params).compose(initJobExecutionsRsDto -> jobExecutionService.setJobProfileToJobExecution(initJobExecutionsRsDto.getParentJobExecutionId(), jobProfileInfo, params)).compose(jobExecution -> chunkProcessingService.processChunk(lastRawRecordsDto, jobExecution.getId(), params).otherwise(true).map(jobExecution)).compose(jobExecution -> jobExecutionService.getJobExecutionById(jobExecution.getId(), params.getTenantId()));
jobFuture.onComplete(ar -> {
context.assertTrue(ar.failed());
verify(1, postRequestedFor(urlEqualTo(SNAPSHOT_SERVICE_URL)));
async.complete();
});
}
use of org.folio.rest.jaxrs.model.JobProfileInfo in project mod-source-record-manager by folio-org.
the class EventDrivenChunkProcessingServiceImplTest method shouldProcessChunkOfRawRecords.
@Test
public void shouldProcessChunkOfRawRecords(TestContext context) {
Async async = context.async();
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> statusCaptor = ArgumentCaptor.forClass(StatusDto.class);
ArgumentCaptor<String> jobExecutionIdCaptor = ArgumentCaptor.forClass(String.class);
Mockito.verify(jobExecutionService).updateJobExecutionStatus(jobExecutionIdCaptor.capture(), statusCaptor.capture(), isA(OkapiConnectionParams.class));
Mockito.verify(jobExecutionProgressService).initializeJobExecutionProgress(anyString(), eq(rawRecordsDto.getRecordsMetadata().getTotal()), eq(TENANT_ID));
context.assertTrue(PARSING_IN_PROGRESS.equals(statusCaptor.getValue().getStatus()));
mappingMetadataService.getMappingMetadataDto(jobExecutionIdCaptor.getValue(), params).onComplete(mappingMetadataDtoAsyncResult -> {
context.assertTrue(mappingMetadataDtoAsyncResult.succeeded());
context.assertTrue(mappingMetadataDtoAsyncResult.result().getJobExecutionId().equals(jobExecutionIdCaptor.getValue()));
});
async.complete();
});
}
Aggregations