Search in sources :

Example 21 with JobExecution

use of org.folio.rest.jaxrs.model.JobExecution 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));
}
Also used : JobExecution(org.folio.rest.jaxrs.model.JobExecution) StatusDto(org.folio.rest.jaxrs.model.StatusDto) InitJobExecutionsRsDto(org.folio.rest.jaxrs.model.InitJobExecutionsRsDto) Date(java.util.Date) AbstractRestTest(org.folio.rest.impl.AbstractRestTest) Test(org.junit.Test)

Example 22 with JobExecution

use of org.folio.rest.jaxrs.model.JobExecution 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));
}
Also used : JobExecution(org.folio.rest.jaxrs.model.JobExecution) StatusDto(org.folio.rest.jaxrs.model.StatusDto) InitJobExecutionsRsDto(org.folio.rest.jaxrs.model.InitJobExecutionsRsDto) Date(java.util.Date) AbstractRestTest(org.folio.rest.impl.AbstractRestTest) Test(org.junit.Test)

Example 23 with JobExecution

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

the class ChangeManagerAPITest method shouldProcessChunksAndRequestForMappingParameters1Time.

@Test
public void shouldProcessChunksAndRequestForMappingParameters1Time(TestContext testContext) {
    // given
    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)));
    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();
    // when
    async = testContext.async();
    RestAssured.given().spec(spec).body(rawRecordsDto).when().post(JOB_EXECUTION_PATH + jobExec.getId() + RECORDS_PATH).then().statusCode(HttpStatus.SC_NO_CONTENT);
    async.complete();
    async = testContext.async();
    RestAssured.given().spec(spec).body(rawRecordsDto).when().post(JOB_EXECUTION_PATH + jobExec.getId() + RECORDS_PATH).then().statusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
    async.complete();
    // then
    async = testContext.async();
    RestAssured.given().spec(spec).when().get(JOB_EXECUTION_PATH + jobExec.getId()).then().statusCode(HttpStatus.SC_OK).body("status", is(JobExecution.Status.PARSING_IN_PROGRESS.name())).body("runBy.firstName", is("DIKU")).body("progress.total", is(100)).body("startedDate", notNullValue(Date.class)).log().all();
    verify(1, getRequestedFor(urlEqualTo(IDENTIFIER_TYPES_URL)));
    verify(1, getRequestedFor(urlEqualTo(INSTANCE_TYPES_URL)));
    verify(1, getRequestedFor(urlEqualTo(CLASSIFICATION_TYPES_URL)));
    verify(1, getRequestedFor(urlEqualTo(INSTANCE_FORMATS_URL)));
    verify(1, getRequestedFor(urlEqualTo(CONTRIBUTOR_TYPES_URL)));
    verify(1, getRequestedFor(urlEqualTo(CONTRIBUTOR_NAME_TYPES_URL)));
    verify(1, getRequestedFor(urlEqualTo(ELECTRONIC_ACCESS_URL)));
    verify(1, getRequestedFor(urlEqualTo(INSTANCE_NOTE_TYPES_URL)));
    verify(1, getRequestedFor(urlEqualTo(INSTANCE_ALTERNATIVE_TITLE_TYPES_URL)));
    verify(1, getRequestedFor(urlEqualTo(MODE_OF_ISSUANCE_TYPES_URL)));
    verify(1, getRequestedFor(urlEqualTo(INSTANCE_STATUSES_URL)));
    verify(1, getRequestedFor(urlEqualTo(NATURE_OF_CONTENT_TERMS_URL)));
    verify(1, getRequestedFor(urlEqualTo(INSTANCE_RELATIONSHIP_TYPES_URL)));
    verify(1, getRequestedFor(urlEqualTo(HOLDINGS_TYPES_URL)));
    verify(1, getRequestedFor(urlEqualTo(HOLDINGS_NOTE_TYPES_URL)));
    verify(1, getRequestedFor(urlEqualTo(ILL_POLICIES_URL)));
    verify(1, getRequestedFor(urlEqualTo(CALL_NUMBER_TYPES_URL)));
    verify(1, getRequestedFor(urlEqualTo(STATISTICAL_CODES_URL)));
    verify(1, getRequestedFor(urlEqualTo(STATISTICAL_CODE_TYPES_URL)));
    verify(1, getRequestedFor(urlEqualTo(LOCATIONS_URL)));
    verify(1, getRequestedFor(urlEqualTo(MATERIAL_TYPES_URL)));
    verify(1, getRequestedFor(urlEqualTo(ITEM_DAMAGED_STATUSES_URL)));
    verify(1, getRequestedFor(urlEqualTo(LOAN_TYPES_URL)));
    verify(1, getRequestedFor(urlEqualTo(ITEM_NOTE_TYPES_URL)));
    verify(1, getRequestedFor(urlEqualTo(AUTHORITY_NOTE_TYPES_URL)));
    verify(1, getRequestedFor(urlEqualTo(FIELD_PROTECTION_SETTINGS_URL)));
    verify(1, getRequestedFor(urlEqualTo(TENANT_CONFIGURATIONS_SETTINGS_URL)));
    async.complete();
}
Also used : JobExecution(org.folio.rest.jaxrs.model.JobExecution) JobProfileInfo(org.folio.rest.jaxrs.model.JobProfileInfo) Async(io.vertx.ext.unit.Async) InitJobExecutionsRsDto(org.folio.rest.jaxrs.model.InitJobExecutionsRsDto) Date(java.util.Date) AbstractRestTest(org.folio.rest.impl.AbstractRestTest) Test(org.junit.Test)

Example 24 with JobExecution

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

the class ChangeManagerAPITest method testInitJobExecutionsWith2Files.

@Test
public void testInitJobExecutionsWith2Files() {
    // given
    int expectedParentJobExecutions = 1;
    int expectedChildJobExecutions = 2;
    int expectedJobExecutionsNumber = expectedParentJobExecutions + expectedChildJobExecutions;
    // when
    InitJobExecutionsRsDto response = constructAndPostInitJobExecutionRqDto(expectedChildJobExecutions);
    // then
    String actualParentJobExecutionId = response.getParentJobExecutionId();
    List<JobExecution> actualJobExecutions = response.getJobExecutions();
    Assert.assertNotNull(actualParentJobExecutionId);
    assertEquals(expectedJobExecutionsNumber, actualJobExecutions.size());
    int actualParentJobExecutions = 0;
    int actualChildJobExecutions = 0;
    for (JobExecution actualJobExecution : actualJobExecutions) {
        if (JobExecution.SubordinationType.PARENT_MULTIPLE.equals(actualJobExecution.getSubordinationType())) {
            assertParent(actualJobExecution);
            actualParentJobExecutions++;
        } else {
            assertChild(actualJobExecution, actualParentJobExecutionId);
            actualChildJobExecutions++;
        }
    }
    assertEquals(expectedParentJobExecutions, actualParentJobExecutions);
    assertEquals(expectedChildJobExecutions, actualChildJobExecutions);
}
Also used : JobExecution(org.folio.rest.jaxrs.model.JobExecution) InitJobExecutionsRsDto(org.folio.rest.jaxrs.model.InitJobExecutionsRsDto) Matchers.containsString(org.hamcrest.Matchers.containsString) AbstractRestTest(org.folio.rest.impl.AbstractRestTest) Test(org.junit.Test)

Example 25 with JobExecution

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

the class ChangeManagerAPITest method shouldNotUpdateMultipleParentStatusOnPut.

@Test
public void shouldNotUpdateMultipleParentStatusOnPut() {
    InitJobExecutionsRsDto response = constructAndPostInitJobExecutionRqDto(2);
    List<JobExecution> createdJobExecutions = response.getJobExecutions();
    assertThat(createdJobExecutions.size(), is(3));
    JobExecution multipleParent = createdJobExecutions.stream().filter(jobExec -> jobExec.getSubordinationType().equals(JobExecution.SubordinationType.PARENT_MULTIPLE)).findFirst().get();
    multipleParent.setStatus(JobExecution.Status.PARSING_IN_PROGRESS);
    RestAssured.given().spec(spec).body(JsonObject.mapFrom(multipleParent).toString()).when().put(JOB_EXECUTION_PATH + multipleParent.getId()).then().statusCode(HttpStatus.SC_BAD_REQUEST);
    RestAssured.given().spec(spec).when().get(JOB_EXECUTION_PATH + multipleParent.getId()).then().statusCode(HttpStatus.SC_OK).body("status", is(JobExecution.Status.PARENT.name())).body("uiStatus", is(JobExecution.UiStatus.PARENT.name()));
}
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