Search in sources :

Example 16 with MatchProfile

use of org.folio.MatchProfile 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 17 with MatchProfile

use of org.folio.MatchProfile in project mod-inventory by folio-org.

the class MatchInstanceEventHandlerUnitTest method shouldReturnFalseOnIsEligibleForNotInstanceMatchProfile.

@Test
public void shouldReturnFalseOnIsEligibleForNotInstanceMatchProfile() {
    EventHandler eventHandler = new MatchInstanceEventHandler(mappingMetadataCache);
    DataImportEventPayload eventPayload = new DataImportEventPayload().withCurrentNode(new ProfileSnapshotWrapper().withContentType(MATCH_PROFILE).withContent(JsonObject.mapFrom(new MatchProfile().withExistingRecordType(MARC_BIBLIOGRAPHIC))));
    assertFalse(eventHandler.isEligible(eventPayload));
}
Also used : MatchProfile(org.folio.MatchProfile) MatchInstanceEventHandler(org.folio.inventory.dataimport.handlers.matching.MatchInstanceEventHandler) EventHandler(org.folio.processing.events.services.handler.EventHandler) MatchInstanceEventHandler(org.folio.inventory.dataimport.handlers.matching.MatchInstanceEventHandler) DataImportEventPayload(org.folio.DataImportEventPayload) ProfileSnapshotWrapper(org.folio.rest.jaxrs.model.ProfileSnapshotWrapper) Test(org.junit.Test)

Example 18 with MatchProfile

use of org.folio.MatchProfile in project mod-inventory by folio-org.

the class MatchItemEventHandlerUnitTest method shouldReturnFalseOnIsEligibleForNotItemMatchProfile.

@Test
public void shouldReturnFalseOnIsEligibleForNotItemMatchProfile() {
    EventHandler eventHandler = new MatchItemEventHandler(mappingMetadataCache);
    DataImportEventPayload eventPayload = new DataImportEventPayload().withCurrentNode(new ProfileSnapshotWrapper().withContentType(MATCH_PROFILE).withContent(JsonObject.mapFrom(new MatchProfile().withExistingRecordType(MARC_BIBLIOGRAPHIC))));
    assertFalse(eventHandler.isEligible(eventPayload));
}
Also used : MatchProfile(org.folio.MatchProfile) MatchItemEventHandler(org.folio.inventory.dataimport.handlers.matching.MatchItemEventHandler) EventHandler(org.folio.processing.events.services.handler.EventHandler) MatchItemEventHandler(org.folio.inventory.dataimport.handlers.matching.MatchItemEventHandler) DataImportEventPayload(org.folio.DataImportEventPayload) ProfileSnapshotWrapper(org.folio.rest.jaxrs.model.ProfileSnapshotWrapper) Test(org.junit.Test)

Example 19 with MatchProfile

use of org.folio.MatchProfile in project mod-inventory by folio-org.

the class MatchItemEventHandlerUnitTest method shouldReturnTrueOnIsEligibleForItemMatchProfile.

@Test
public void shouldReturnTrueOnIsEligibleForItemMatchProfile() {
    EventHandler eventHandler = new MatchItemEventHandler(mappingMetadataCache);
    DataImportEventPayload eventPayload = new DataImportEventPayload().withCurrentNode(new ProfileSnapshotWrapper().withContentType(MATCH_PROFILE).withContent(JsonObject.mapFrom(new MatchProfile().withExistingRecordType(ITEM))));
    assertTrue(eventHandler.isEligible(eventPayload));
}
Also used : MatchProfile(org.folio.MatchProfile) MatchItemEventHandler(org.folio.inventory.dataimport.handlers.matching.MatchItemEventHandler) EventHandler(org.folio.processing.events.services.handler.EventHandler) MatchItemEventHandler(org.folio.inventory.dataimport.handlers.matching.MatchItemEventHandler) DataImportEventPayload(org.folio.DataImportEventPayload) ProfileSnapshotWrapper(org.folio.rest.jaxrs.model.ProfileSnapshotWrapper) Test(org.junit.Test)

Example 20 with MatchProfile

use of org.folio.MatchProfile in project mod-inventory by folio-org.

the class MatchAuthorityEventHandlerUnitTest method shouldReturnTrueOnIsEligibleForAuthorityMatchProfile.

@Test
public void shouldReturnTrueOnIsEligibleForAuthorityMatchProfile() {
    EventHandler eventHandler = new MatchAuthorityEventHandler(mappingMetadataCache);
    DataImportEventPayload eventPayload = new DataImportEventPayload().withCurrentNode(new ProfileSnapshotWrapper().withContentType(MATCH_PROFILE).withContent(JsonObject.mapFrom(new MatchProfile().withExistingRecordType(AUTHORITY))));
    assertTrue(eventHandler.isEligible(eventPayload));
}
Also used : MatchProfile(org.folio.MatchProfile) MatchAuthorityEventHandler(org.folio.inventory.dataimport.handlers.matching.MatchAuthorityEventHandler) EventHandler(org.folio.processing.events.services.handler.EventHandler) MatchAuthorityEventHandler(org.folio.inventory.dataimport.handlers.matching.MatchAuthorityEventHandler) DataImportEventPayload(org.folio.DataImportEventPayload) ProfileSnapshotWrapper(org.folio.rest.jaxrs.model.ProfileSnapshotWrapper) Test(org.junit.Test)

Aggregations

MatchProfile (org.folio.MatchProfile)28 ProfileSnapshotWrapper (org.folio.rest.jaxrs.model.ProfileSnapshotWrapper)28 Test (org.junit.Test)27 DataImportEventPayload (org.folio.DataImportEventPayload)26 HashMap (java.util.HashMap)19 EventHandler (org.folio.processing.events.services.handler.EventHandler)17 JsonObject (io.vertx.core.json.JsonObject)15 Async (io.vertx.ext.unit.Async)15 Json (io.vertx.core.json.Json)14 TestContext (io.vertx.ext.unit.TestContext)14 VertxUnitRunner (io.vertx.ext.unit.junit.VertxUnitRunner)14 ArrayList (java.util.ArrayList)14 Collections.singletonList (java.util.Collections.singletonList)14 List (java.util.List)14 UUID (java.util.UUID)14 MatchDetail (org.folio.MatchDetail)14 EXACTLY_MATCHES (org.folio.MatchDetail.MatchCriterion.EXACTLY_MATCHES)14 Field (org.folio.rest.jaxrs.model.Field)14 MatchExpression (org.folio.rest.jaxrs.model.MatchExpression)14 VALUE_FROM_RECORD (org.folio.rest.jaxrs.model.MatchExpression.DataValueType.VALUE_FROM_RECORD)14