Search in sources :

Example 16 with JobExecution

use of org.folio.rest.jaxrs.model.JobExecution in project mod-source-record-manager by folio-org.

the class ChangeManagerAPITest method fillInRecordOrderIfAtLeastOneRecordHasNoOrder.

private void fillInRecordOrderIfAtLeastOneRecordHasNoOrder(String rawRecord) throws InterruptedException {
    RawRecordsDto rawRecordsDto = new RawRecordsDto().withId(UUID.randomUUID().toString()).withRecordsMetadata(new RecordsMetadata().withLast(true).withCounter(7).withContentType(RecordsMetadata.ContentType.MARC_RAW)).withInitialRecords(asList(new InitialRecord().withRecord(CORRECT_RAW_RECORD_1), new InitialRecord().withRecord(CORRECT_RAW_RECORD_2).withOrder(5), new InitialRecord().withRecord(rawRecord).withOrder(6)));
    InitJobExecutionsRsDto response = constructAndPostInitJobExecutionRqDto(1);
    List<JobExecution> createdJobExecutions = response.getJobExecutions();
    assertThat(createdJobExecutions.size(), is(1));
    JobExecution jobExec = createdJobExecutions.get(0);
    RestAssured.given().spec(spec).body(new JobProfileInfo().withName("MARC records").withId(DEFAULT_JOB_PROFILE_ID).withDataType(DataType.MARC)).when().put(JOB_EXECUTION_PATH + jobExec.getId() + JOB_PROFILE_PATH).then().statusCode(HttpStatus.SC_OK);
    RestAssured.given().spec(spec).body(rawRecordsDto).when().post(JOB_EXECUTION_PATH + jobExec.getId() + RECORDS_PATH).then().statusCode(HttpStatus.SC_NO_CONTENT);
    String topicToObserve = formatToKafkaTopicName(DI_RAW_RECORDS_CHUNK_PARSED.value());
    List<String> observedValues = kafkaCluster.observeValues(ObserveKeyValues.on(topicToObserve, 1).observeFor(30, TimeUnit.SECONDS).build());
    Event obtainedEvent = Json.decodeValue(observedValues.get(0), Event.class);
    assertEquals(DI_RAW_RECORDS_CHUNK_PARSED.value(), obtainedEvent.getEventType());
    RecordCollection processedRecords = Json.decodeValue(obtainedEvent.getEventPayload(), RecordCollection.class);
    assertEquals(3, processedRecords.getRecords().size());
    assertEquals(4, processedRecords.getRecords().get(0).getOrder().intValue());
    assertEquals(5, processedRecords.getRecords().get(1).getOrder().intValue());
    assertEquals(6, processedRecords.getRecords().get(2).getOrder().intValue());
}
Also used : JobExecution(org.folio.rest.jaxrs.model.JobExecution) InitialRecord(org.folio.rest.jaxrs.model.InitialRecord) JobProfileInfo(org.folio.rest.jaxrs.model.JobProfileInfo) RawRecordsDto(org.folio.rest.jaxrs.model.RawRecordsDto) RecordCollection(org.folio.rest.jaxrs.model.RecordCollection) RecordsMetadata(org.folio.rest.jaxrs.model.RecordsMetadata) Event(org.folio.rest.jaxrs.model.Event) InitJobExecutionsRsDto(org.folio.rest.jaxrs.model.InitJobExecutionsRsDto) Matchers.containsString(org.hamcrest.Matchers.containsString)

Example 17 with JobExecution

use of org.folio.rest.jaxrs.model.JobExecution in project mod-source-record-manager by folio-org.

the class ChangeManagerAPITest method shouldNotReturnAnyChildrenOfAnyParentOnGetChildrenByIdForDeletedLogs.

@Test
public void shouldNotReturnAnyChildrenOfAnyParentOnGetChildrenByIdForDeletedLogs() {
    InitJobExecutionsRsDto response = constructAndPostInitJobExecutionRqDto(25);
    List<JobExecution> createdJobExecutions = response.getJobExecutions();
    assertThat(createdJobExecutions.size(), is(26));
    JobExecution multipleParent = createdJobExecutions.stream().filter(jobExec -> jobExec.getSubordinationType().equals(JobExecution.SubordinationType.PARENT_MULTIPLE)).findFirst().get();
    DeleteJobExecutionsResp deleteJobExecutionsResp = returnDeletedJobExecutionResponse(new String[] { multipleParent.getId() });
    assertThat(deleteJobExecutionsResp.getJobExecutionDetails().get(0).getJobExecutionId(), is(multipleParent.getId()));
    assertThat(deleteJobExecutionsResp.getJobExecutionDetails().get(0).getIsDeleted(), is(true));
    RestAssured.given().spec(spec).when().get(JOB_EXECUTION_PATH + multipleParent.getId() + CHILDREN_PATH).then().statusCode(HttpStatus.SC_NOT_FOUND);
}
Also used : JobExecution(org.folio.rest.jaxrs.model.JobExecution) DeleteJobExecutionsResp(org.folio.rest.jaxrs.model.DeleteJobExecutionsResp) InitJobExecutionsRsDto(org.folio.rest.jaxrs.model.InitJobExecutionsRsDto) AbstractRestTest(org.folio.rest.impl.AbstractRestTest) Test(org.junit.Test)

Example 18 with JobExecution

use of org.folio.rest.jaxrs.model.JobExecution in project mod-source-record-manager by folio-org.

the class ChangeManagerAPITest method shouldMarkJobExecutionAsErrorOnSetJobProfileInfoWhenCreationProfileWrapperFailed.

@Test
public void shouldMarkJobExecutionAsErrorOnSetJobProfileInfoWhenCreationProfileWrapperFailed() {
    InitJobExecutionsRsDto response = constructAndPostInitJobExecutionRqDto(1);
    List<JobExecution> createdJobExecutions = response.getJobExecutions();
    assertThat(createdJobExecutions.size(), is(1));
    JobExecution jobExec = createdJobExecutions.get(0);
    WireMock.stubFor(post(new UrlPathPattern(new RegexPattern(PROFILE_SNAPSHOT_URL + "/.*"), true)).willReturn(serverError()));
    JobProfileInfo jobProfile = new JobProfileInfo().withId(DEFAULT_JOB_PROFILE_ID).withName("marc");
    RestAssured.given().spec(spec).body(JsonObject.mapFrom(jobProfile).toString()).when().put(JOB_EXECUTION_PATH + jobExec.getId() + JOB_PROFILE_PATH).then().statusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
    RestAssured.given().spec(spec).when().get(JOB_EXECUTION_PATH + jobExec.getId()).then().statusCode(HttpStatus.SC_OK).body("status", is(JobExecution.Status.ERROR.value())).body("errorStatus", is(JobExecution.ErrorStatus.PROFILE_SNAPSHOT_CREATING_ERROR.value()));
}
Also used : JobExecution(org.folio.rest.jaxrs.model.JobExecution) JobProfileInfo(org.folio.rest.jaxrs.model.JobProfileInfo) UrlPathPattern(com.github.tomakehurst.wiremock.matching.UrlPathPattern) RegexPattern(com.github.tomakehurst.wiremock.matching.RegexPattern) InitJobExecutionsRsDto(org.folio.rest.jaxrs.model.InitJobExecutionsRsDto) AbstractRestTest(org.folio.rest.impl.AbstractRestTest) Test(org.junit.Test)

Example 19 with JobExecution

use of org.folio.rest.jaxrs.model.JobExecution in project mod-source-record-manager by folio-org.

the class ChangeManagerAPITest method shouldSetJobProfileInfoForJobExecution.

@Test
public void shouldSetJobProfileInfoForJobExecution() {
    InitJobExecutionsRsDto response = constructAndPostInitJobExecutionRqDto(1);
    List<JobExecution> createdJobExecutions = response.getJobExecutions();
    assertThat(createdJobExecutions.size(), is(1));
    JobExecution jobExec = createdJobExecutions.get(0);
    JobProfileInfo jobProfile = new JobProfileInfo().withId(DEFAULT_JOB_PROFILE_ID).withName("Default job profile");
    RestAssured.given().spec(spec).body(JsonObject.mapFrom(jobProfile).toString()).when().put(JOB_EXECUTION_PATH + jobExec.getId() + JOB_PROFILE_PATH).then().statusCode(HttpStatus.SC_OK).body("jobProfileInfo.id", is(jobProfile.getId())).body("jobProfileInfo.name", is(jobProfile.getName())).body("jobProfileSnapshotWrapper", notNullValue());
    RestAssured.given().spec(spec).when().get(JOB_EXECUTION_PATH + jobExec.getId()).then().statusCode(HttpStatus.SC_OK).body("jobProfileInfo.id", is(jobProfile.getId())).body("jobProfileInfo.name", is(jobProfile.getName())).body("jobProfileSnapshotWrapper", notNullValue());
}
Also used : JobExecution(org.folio.rest.jaxrs.model.JobExecution) JobProfileInfo(org.folio.rest.jaxrs.model.JobProfileInfo) InitJobExecutionsRsDto(org.folio.rest.jaxrs.model.InitJobExecutionsRsDto) AbstractRestTest(org.folio.rest.impl.AbstractRestTest) Test(org.junit.Test)

Example 20 with JobExecution

use of org.folio.rest.jaxrs.model.JobExecution in project mod-source-record-manager by folio-org.

the class ChangeManagerAPITest method shouldReturnEmptyCollectionOnGetChildrenByIdInCaseOfSingleParent.

@Test
public void shouldReturnEmptyCollectionOnGetChildrenByIdInCaseOfSingleParent() {
    InitJobExecutionsRsDto response = constructAndPostInitJobExecutionRqDto(1);
    List<JobExecution> createdJobExecutions = response.getJobExecutions();
    assertThat(createdJobExecutions.size(), is(1));
    JobExecution jobExec = createdJobExecutions.get(0);
    RestAssured.given().spec(spec).when().get(JOB_EXECUTION_PATH + jobExec.getId() + CHILDREN_PATH).then().statusCode(HttpStatus.SC_OK).body("jobExecutions", empty()).body("totalRecords", is(0));
}
Also used : JobExecution(org.folio.rest.jaxrs.model.JobExecution) InitJobExecutionsRsDto(org.folio.rest.jaxrs.model.InitJobExecutionsRsDto) AbstractRestTest(org.folio.rest.impl.AbstractRestTest) Test(org.junit.Test)

Aggregations

JobExecution (org.folio.rest.jaxrs.model.JobExecution)128 Test (org.junit.Test)111 AbstractRestTest (org.folio.rest.impl.AbstractRestTest)99 InitJobExecutionsRsDto (org.folio.rest.jaxrs.model.InitJobExecutionsRsDto)73 Async (io.vertx.ext.unit.Async)68 Future (io.vertx.core.Future)55 JobProfileInfo (org.folio.rest.jaxrs.model.JobProfileInfo)55 List (java.util.List)54 Date (java.util.Date)53 UUID (java.util.UUID)52 Before (org.junit.Before)48 PostgresClientFactory (org.folio.dao.util.PostgresClientFactory)47 RunWith (org.junit.runner.RunWith)47 InjectMocks (org.mockito.InjectMocks)47 TestContext (io.vertx.ext.unit.TestContext)46 VertxUnitRunner (io.vertx.ext.unit.junit.VertxUnitRunner)46 MockitoAnnotations (org.mockito.MockitoAnnotations)46 Spy (org.mockito.Spy)46 JournalRecordDaoImpl (org.folio.dao.JournalRecordDaoImpl)41 JournalRecord (org.folio.rest.jaxrs.model.JournalRecord)38