use of org.folio.MatchDetail in project mod-source-record-storage by folio-org.
the class MarcBibliographicMatchEventHandlerTest method shouldNotMatchByMatchedIdField.
@Test
public void shouldNotMatchByMatchedIdField(TestContext context) {
Async async = context.async();
HashMap<String, String> payloadContext = new HashMap<>();
payloadContext.put(EntityType.MARC_BIBLIOGRAPHIC.value(), Json.encode(incomingRecord));
DataImportEventPayload dataImportEventPayload = new DataImportEventPayload().withContext(payloadContext).withTenant(TENANT_ID).withCurrentNode(new ProfileSnapshotWrapper().withId(UUID.randomUUID().toString()).withContentType(MATCH_PROFILE).withContent(new MatchProfile().withExistingRecordType(EntityType.MARC_BIBLIOGRAPHIC).withIncomingRecordType(EntityType.MARC_BIBLIOGRAPHIC).withMatchDetails(singletonList(new MatchDetail().withMatchCriterion(EXACTLY_MATCHES).withExistingMatchExpression(new MatchExpression().withDataValueType(VALUE_FROM_RECORD).withFields(Lists.newArrayList(new Field().withLabel("field").withValue("999"), new Field().withLabel("indicator1").withValue("f"), new Field().withLabel("indicator2").withValue("f"), new Field().withLabel("recordSubfield").withValue("s")))).withExistingRecordType(EntityType.MARC_BIBLIOGRAPHIC).withIncomingRecordType(EntityType.MARC_BIBLIOGRAPHIC).withIncomingMatchExpression(new MatchExpression().withDataValueType(VALUE_FROM_RECORD).withFields(Lists.newArrayList(new Field().withLabel("field").withValue("948"), new Field().withLabel("indicator1").withValue(""), new Field().withLabel("indicator2").withValue(""), new Field().withLabel("recordSubfield").withValue("b"))))))));
recordDao.saveRecord(existingRecord, TENANT_ID).onComplete(context.asyncAssertSuccess()).onSuccess(record -> handler.handle(dataImportEventPayload).whenComplete((updatedEventPayload, throwable) -> {
context.assertNull(throwable);
context.assertEquals(1, updatedEventPayload.getEventsChain().size());
context.assertEquals(updatedEventPayload.getEventType(), DI_SRS_MARC_BIB_RECORD_NOT_MATCHED.value());
async.complete();
}));
}
use of org.folio.MatchDetail in project mod-source-record-storage by folio-org.
the class MarcBibliographicMatchEventHandlerTest method shouldMatchByInstanceIdField.
@Test
public void shouldMatchByInstanceIdField(TestContext context) {
Async async = context.async();
HashMap<String, String> payloadContext = new HashMap<>();
payloadContext.put(EntityType.MARC_BIBLIOGRAPHIC.value(), Json.encode(incomingRecord));
DataImportEventPayload dataImportEventPayload = new DataImportEventPayload().withContext(payloadContext).withTenant(TENANT_ID).withCurrentNode(new ProfileSnapshotWrapper().withId(UUID.randomUUID().toString()).withContentType(MATCH_PROFILE).withContent(new MatchProfile().withExistingRecordType(EntityType.MARC_BIBLIOGRAPHIC).withIncomingRecordType(EntityType.MARC_BIBLIOGRAPHIC).withMatchDetails(singletonList(new MatchDetail().withMatchCriterion(EXACTLY_MATCHES).withExistingMatchExpression(new MatchExpression().withDataValueType(VALUE_FROM_RECORD).withFields(Lists.newArrayList(new Field().withLabel("field").withValue("999"), new Field().withLabel("indicator1").withValue("f"), new Field().withLabel("indicator2").withValue("f"), new Field().withLabel("recordSubfield").withValue("i")))).withExistingRecordType(EntityType.MARC_BIBLIOGRAPHIC).withIncomingRecordType(EntityType.MARC_BIBLIOGRAPHIC).withIncomingMatchExpression(new MatchExpression().withDataValueType(VALUE_FROM_RECORD).withFields(Lists.newArrayList(new Field().withLabel("field").withValue("948"), new Field().withLabel("indicator1").withValue(""), new Field().withLabel("indicator2").withValue(""), new Field().withLabel("recordSubfield").withValue("b"))))))));
recordDao.saveRecord(existingRecord, TENANT_ID).onComplete(context.asyncAssertSuccess()).onSuccess(record -> handler.handle(dataImportEventPayload).whenComplete((updatedEventPayload, throwable) -> {
context.assertNull(throwable);
context.assertEquals(1, updatedEventPayload.getEventsChain().size());
context.assertEquals(updatedEventPayload.getEventType(), DI_SRS_MARC_BIB_RECORD_MATCHED.value());
context.assertEquals(new JsonObject(updatedEventPayload.getContext().get(MATCHED_MARC_BIB_KEY)).mapTo(Record.class), record);
async.complete();
}));
}
Aggregations