Search in sources :

Example 16 with InitJobExecutionsRsDto

use of org.folio.rest.jaxrs.model.InitJobExecutionsRsDto 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 17 with InitJobExecutionsRsDto

use of org.folio.rest.jaxrs.model.InitJobExecutionsRsDto 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 18 with InitJobExecutionsRsDto

use of org.folio.rest.jaxrs.model.InitJobExecutionsRsDto 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)

Example 19 with InitJobExecutionsRsDto

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

the class ChangeManagerAPITest method shouldNotPostRecordsToRecordsStorageWhenJobProfileSnapshotContainsUpdateMarcActionProfile.

@Test
public void shouldNotPostRecordsToRecordsStorageWhenJobProfileSnapshotContainsUpdateMarcActionProfile(TestContext testContext) {
    InitJobExecutionsRsDto response = constructAndPostInitJobExecutionRqDto(1);
    List<JobExecution> createdJobExecutions = response.getJobExecutions();
    assertThat(createdJobExecutions.size(), is(1));
    JobExecution jobExec = createdJobExecutions.get(0);
    MatchProfile matchProfile = new MatchProfile().withName("match 999ff $s to 999ff $s");
    ActionProfile updateMarcAction = new ActionProfile().withName("update marc-bib").withAction(ActionProfile.Action.UPDATE).withFolioRecord(ActionProfile.FolioRecord.MARC_BIBLIOGRAPHIC);
    ProfileSnapshotWrapper profileSnapshotWithUpdateMarcAction = new ProfileSnapshotWrapper().withId(UUID.randomUUID().toString()).withProfileId(jobProfile.getId()).withContentType(JOB_PROFILE).withContent(jobProfile).withChildSnapshotWrappers(Collections.singletonList(new ProfileSnapshotWrapper().withContentType(MATCH_PROFILE).withContent(JsonObject.mapFrom(matchProfile).getMap()).withChildSnapshotWrappers(Collections.singletonList(new ProfileSnapshotWrapper().withContentType(ACTION_PROFILE).withContent(JsonObject.mapFrom(updateMarcAction).getMap())))));
    WireMock.stubFor(post(RECORDS_SERVICE_URL).willReturn(created().withTransformers(RequestToResponseTransformer.NAME)));
    WireMock.stubFor(post(new UrlPathPattern(new RegexPattern(PROFILE_SNAPSHOT_URL + "/.*"), true)).willReturn(WireMock.created().withBody(Json.encode(profileSnapshotWithUpdateMarcAction))));
    WireMock.stubFor(get(new UrlPathPattern(new RegexPattern(PROFILE_SNAPSHOT_URL + "/.*"), true)).willReturn(WireMock.ok().withBody(Json.encode(profileSnapshotWithUpdateMarcAction))));
    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();
    async = testContext.async();
    RestAssured.given().spec(spec).body(rawRecordsDto.withId(UUID.randomUUID().toString())).when().post(JOB_EXECUTION_PATH + jobExec.getId() + RECORDS_PATH).then().statusCode(HttpStatus.SC_NO_CONTENT);
    async.complete();
    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("startedDate", notNullValue(Date.class));
    async.complete();
    verify(0, getRequestedFor(urlEqualTo(RECORDS_SERVICE_URL)));
}
Also used : JobExecution(org.folio.rest.jaxrs.model.JobExecution) MatchProfile(org.folio.MatchProfile) JobProfileInfo(org.folio.rest.jaxrs.model.JobProfileInfo) UrlPathPattern(com.github.tomakehurst.wiremock.matching.UrlPathPattern) RegexPattern(com.github.tomakehurst.wiremock.matching.RegexPattern) Async(io.vertx.ext.unit.Async) InitJobExecutionsRsDto(org.folio.rest.jaxrs.model.InitJobExecutionsRsDto) Date(java.util.Date) ActionProfile(org.folio.rest.jaxrs.model.ActionProfile) ProfileSnapshotWrapper(org.folio.rest.jaxrs.model.ProfileSnapshotWrapper) AbstractRestTest(org.folio.rest.impl.AbstractRestTest) Test(org.junit.Test)

Example 20 with InitJobExecutionsRsDto

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

the class ChangeManagerAPITest method shouldProcessChunkOfRawRecordsIfAddingAdditionalFieldsFailed.

@Test
public void shouldProcessChunkOfRawRecordsIfAddingAdditionalFieldsFailed(TestContext testContext) {
    InitJobExecutionsRsDto response = constructAndPostInitJobExecutionRqDto(1);
    List<JobExecution> createdJobExecutions = response.getJobExecutions();
    assertThat(createdJobExecutions.size(), is(1));
    JobExecution jobExec = createdJobExecutions.get(0);
    WireMock.stubFor(WireMock.put(PARSED_RECORDS_COLLECTION_URL).willReturn(WireMock.serverError()));
    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();
    async = testContext.async();
    RestAssured.given().spec(spec).body(rawRecordsDto.withId(UUID.randomUUID().toString())).when().post(JOB_EXECUTION_PATH + jobExec.getId() + RECORDS_PATH).then().statusCode(HttpStatus.SC_NO_CONTENT);
    async.complete();
    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();
    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)

Aggregations

InitJobExecutionsRsDto (org.folio.rest.jaxrs.model.InitJobExecutionsRsDto)58 JobExecution (org.folio.rest.jaxrs.model.JobExecution)58 AbstractRestTest (org.folio.rest.impl.AbstractRestTest)53 Test (org.junit.Test)53 JobProfileInfo (org.folio.rest.jaxrs.model.JobProfileInfo)28 Async (io.vertx.ext.unit.Async)22 Date (java.util.Date)17 StatusDto (org.folio.rest.jaxrs.model.StatusDto)10 RegexPattern (com.github.tomakehurst.wiremock.matching.RegexPattern)7 UrlPathPattern (com.github.tomakehurst.wiremock.matching.UrlPathPattern)7 DeleteJobExecutionsResp (org.folio.rest.jaxrs.model.DeleteJobExecutionsResp)7 List (java.util.List)6 JournalRecord (org.folio.rest.jaxrs.model.JournalRecord)6 Matchers.containsString (org.hamcrest.Matchers.containsString)6 Before (org.junit.Before)6 Future (io.vertx.core.Future)5 TestContext (io.vertx.ext.unit.TestContext)5 VertxUnitRunner (io.vertx.ext.unit.junit.VertxUnitRunner)5 UUID (java.util.UUID)5 PostgresClientFactory (org.folio.dao.util.PostgresClientFactory)5