use of org.folio.rest.jaxrs.model.MatchExpression in project mod-source-record-storage by folio-org.
the class MarcAuthorityMatchEventHandlerTest method shouldMatchBy999ffsField.
@Test
public void shouldMatchBy999ffsField(TestContext context) {
Async async = context.async();
HashMap<String, String> payloadContext = new HashMap<>();
payloadContext.put(EntityType.MARC_AUTHORITY.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_AUTHORITY).withIncomingRecordType(EntityType.MARC_AUTHORITY).withMatchDetails(singletonList(new MatchDetail().withMatchCriterion(EXACTLY_MATCHES).withExistingRecordType(EntityType.MARC_AUTHORITY).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")))).withIncomingRecordType(EntityType.MARC_AUTHORITY).withIncomingMatchExpression(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"))))))));
recordDao.saveRecord(existingRecord, TENANT_ID).onComplete(context.asyncAssertSuccess()).onSuccess(existingSavedRecord -> handler.handle(dataImportEventPayload).whenComplete((updatedEventPayload, throwable) -> {
context.assertNull(throwable);
context.assertEquals(1, updatedEventPayload.getEventsChain().size());
context.assertEquals(updatedEventPayload.getEventType(), DI_SRS_MARC_AUTHORITY_RECORD_MATCHED.value());
context.assertEquals(new JsonObject(updatedEventPayload.getContext().get(MATCHED_MARC_KEY)).mapTo(Record.class), existingSavedRecord);
async.complete();
}));
}
use of org.folio.rest.jaxrs.model.MatchExpression in project mod-source-record-storage by folio-org.
the class MarcAuthorityMatchEventHandlerTest method shouldMatchBy001Field.
@Test
public void shouldMatchBy001Field(TestContext context) {
Async async = context.async();
HashMap<String, String> payloadContext = new HashMap<>();
payloadContext.put(EntityType.MARC_AUTHORITY.value(), Json.encode(existingRecord));
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_AUTHORITY).withIncomingRecordType(EntityType.MARC_AUTHORITY).withMatchDetails(singletonList(new MatchDetail().withMatchCriterion(EXACTLY_MATCHES).withExistingMatchExpression(new MatchExpression().withDataValueType(VALUE_FROM_RECORD).withFields(Lists.newArrayList(new Field().withLabel("field").withValue("001"), new Field().withLabel("indicator1").withValue(""), new Field().withLabel("indicator2").withValue(""), new Field().withLabel("recordSubfield").withValue("")))).withExistingRecordType(EntityType.MARC_AUTHORITY).withIncomingRecordType(EntityType.MARC_AUTHORITY).withIncomingMatchExpression(new MatchExpression().withDataValueType(VALUE_FROM_RECORD).withFields(Lists.newArrayList(new Field().withLabel("field").withValue("001"), new Field().withLabel("indicator1").withValue(""), new Field().withLabel("indicator2").withValue(""), new Field().withLabel("recordSubfield").withValue(""))))))));
recordDao.saveRecord(existingRecord, TENANT_ID).onComplete(context.asyncAssertSuccess()).onSuccess(existingSavedRecord -> handler.handle(dataImportEventPayload).whenComplete((updatedEventPayload, throwable) -> {
context.assertNull(throwable);
context.assertEquals(1, updatedEventPayload.getEventsChain().size());
context.assertEquals(updatedEventPayload.getEventType(), DI_SRS_MARC_AUTHORITY_RECORD_MATCHED.value());
context.assertEquals(new JsonObject(updatedEventPayload.getContext().get(MATCHED_MARC_KEY)).mapTo(Record.class), existingSavedRecord);
async.complete();
}));
}
use of org.folio.rest.jaxrs.model.MatchExpression in project mod-source-record-storage by folio-org.
the class MarcAuthorityMatchEventHandlerTest method shouldNotMatchBy999ffsField.
@Test
public void shouldNotMatchBy999ffsField(TestContext context) {
Async async = context.async();
HashMap<String, String> payloadContext = new HashMap<>();
payloadContext.put(EntityType.MARC_AUTHORITY.value(), Json.encode(existingRecord));
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_AUTHORITY).withIncomingRecordType(EntityType.MARC_AUTHORITY).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_AUTHORITY).withIncomingRecordType(EntityType.MARC_AUTHORITY).withIncomingMatchExpression(new MatchExpression().withDataValueType(VALUE_FROM_RECORD).withFields(Lists.newArrayList(new Field().withLabel("field").withValue("035"), new Field().withLabel("indicator1").withValue(""), new Field().withLabel("indicator2").withValue(""), new Field().withLabel("recordSubfield").withValue("a"))))))));
recordDao.saveRecord(existingRecord, TENANT_ID).onComplete(context.asyncAssertSuccess()).onSuccess(existingSavedRecord -> handler.handle(dataImportEventPayload).whenComplete((updatedEventPayload, throwable) -> {
context.assertNull(throwable);
context.assertEquals(1, updatedEventPayload.getEventsChain().size());
context.assertEquals(updatedEventPayload.getEventType(), DI_SRS_MARC_AUTHORITY_RECORD_NOT_MATCHED.value());
context.assertNull(updatedEventPayload.getContext().get(MATCHED_MARC_KEY));
async.complete();
}));
}
use of org.folio.rest.jaxrs.model.MatchExpression in project mod-source-record-storage by folio-org.
the class MarcBibliographicMatchEventHandlerTest method shouldNotMatchByMatchedIdFieldIfNotMatch.
@Test
public void shouldNotMatchByMatchedIdFieldIfNotMatch(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("r")))).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("d"))))))));
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.rest.jaxrs.model.MatchExpression 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();
}));
}
Aggregations