use of org.folio.rest.jaxrs.model.ExternalIdsHolder in project mod-source-record-manager by folio-org.
the class ChangeManagerParsedRecordsAPITest method shouldReturnParsedRecordDtoIfSourceRecordExists.
@Test
public void shouldReturnParsedRecordDtoIfSourceRecordExists(TestContext testContext) {
Async async = testContext.async();
String externalId = UUID.randomUUID().toString();
SourceRecord sourceRecord = new SourceRecord().withRecordId(UUID.randomUUID().toString()).withParsedRecord(new ParsedRecord().withId(UUID.randomUUID().toString()).withContent("{\"leader\":\"01240cas a2200397 4500\",\"fields\":[]}")).withRecordType(SourceRecord.RecordType.MARC_BIB).withExternalIdsHolder(new ExternalIdsHolder().withInstanceId(externalId));
WireMock.stubFor(get(new UrlPathPattern(new RegexPattern(SOURCE_RECORDS_URL + ".*"), true)).willReturn(ok().withBody(JsonObject.mapFrom(sourceRecord).encode())));
RestAssured.given().spec(spec).queryParam(EXTERNAL_ID_QUERY_PARAM, externalId).when().get(PARSED_RECORDS_URL).then().statusCode(HttpStatus.SC_OK).body("id", is(sourceRecord.getRecordId())).body("parsedRecord.id", is(sourceRecord.getParsedRecord().getId())).body("recordType", is(sourceRecord.getRecordType().value())).body("externalIdsHolder.instanceId", is(externalId));
async.complete();
}
use of org.folio.rest.jaxrs.model.ExternalIdsHolder in project mod-source-record-manager by folio-org.
the class HrIdFieldServiceTest method shouldNotAdd035FieldIf001FieldNotExists.
@Test
public void shouldNotAdd035FieldIf001FieldNotExists() {
// given
String parsedContent = "{\"leader\":\"00115nam 22000731a 4500\",\"fields\":[{\"003\":\"in001\"},{\"507\":{\"subfields\":[{\"a\":\"data\"}],\"ind1\":\" \",\"ind2\":\" \"}},{\"500\":{\"subfields\":[{\"a\":\"data\"}],\"ind1\":\" \",\"ind2\":\" \"}}]}";
String expectedParsedContent = "{\"leader\":\"00115nam 22000731a 4500\",\"fields\":[{\"003\":\"in001\"},{\"507\":{\"subfields\":[{\"a\":\"data\"}],\"ind1\":\" \",\"ind2\":\" \"}},{\"500\":{\"subfields\":[{\"a\":\"data\"}],\"ind1\":\" \",\"ind2\":\" \"}}]}";
ParsedRecord parsedRecord = new ParsedRecord();
parsedRecord.setContent(parsedContent);
Record record = new Record().withId(UUID.randomUUID().toString()).withParsedRecord(parsedRecord).withGeneration(0).withState(Record.State.ACTUAL).withExternalIdsHolder(new ExternalIdsHolder().withInstanceId("001").withInstanceHrid("in001"));
// when
HrIdFieldService hrIdFieldService = new HrIdFieldServiceImpl();
hrIdFieldService.move001valueTo035Field(Lists.newArrayList(record));
// then
Assert.assertEquals(expectedParsedContent, record.getParsedRecord().getContent());
}
use of org.folio.rest.jaxrs.model.ExternalIdsHolder in project mod-source-record-manager by folio-org.
the class HrIdFieldServiceTest method shouldNotAdd035FieldIf035FieldExists.
@Test
public void shouldNotAdd035FieldIf035FieldExists() {
// given
String parsedContent = "{\"leader\":\"00115nam 22000731a 4500\",\"fields\":[{\"001\":\"in001\"},{\"003\":\"in001\"},{\"035\":{\"subfields\":[{\"a\":\"(test)data\"}],\"ind1\":\" \",\"ind2\":\" \"}},{\"507\":{\"subfields\":[{\"a\":\"data\"}],\"ind1\":\" \",\"ind2\":\" \"}},{\"500\":{\"subfields\":[{\"a\":\"data\"}],\"ind1\":\" \",\"ind2\":\" \"}}]}";
String expectedParsedContent = "{\"leader\":\"00115nam 22000731a 4500\",\"fields\":[{\"001\":\"in001\"},{\"003\":\"in001\"},{\"035\":{\"subfields\":[{\"a\":\"(test)data\"}],\"ind1\":\" \",\"ind2\":\" \"}},{\"507\":{\"subfields\":[{\"a\":\"data\"}],\"ind1\":\" \",\"ind2\":\" \"}},{\"500\":{\"subfields\":[{\"a\":\"data\"}],\"ind1\":\" \",\"ind2\":\" \"}}]}";
ParsedRecord parsedRecord = new ParsedRecord();
parsedRecord.setContent(parsedContent);
Record record = new Record().withId(UUID.randomUUID().toString()).withParsedRecord(parsedRecord).withGeneration(0).withState(Record.State.ACTUAL).withExternalIdsHolder(new ExternalIdsHolder().withInstanceId("001").withInstanceHrid("in001"));
// when
HrIdFieldService hrIdFieldService = new HrIdFieldServiceImpl();
hrIdFieldService.move001valueTo035Field(Lists.newArrayList(record));
// then
Assert.assertEquals(expectedParsedContent, record.getParsedRecord().getContent());
}
use of org.folio.rest.jaxrs.model.ExternalIdsHolder in project mod-source-record-manager by folio-org.
the class HrIdFieldServiceTest method shouldAdd035FieldIf001FieldExists.
@Test
public void shouldAdd035FieldIf001FieldExists() {
// given
String parsedContent = "{\"leader\":\"00115nam 22000731a 4500\",\"fields\":[{\"001\":\"in001\"},{\"507\":{\"subfields\":[{\"a\":\"data\"}],\"ind1\":\" \",\"ind2\":\" \"}},{\"500\":{\"subfields\":[{\"a\":\"data\"}],\"ind1\":\" \",\"ind2\":\" \"}}]}";
String expectedParsedContent = "{\"leader\":\"00108nam 22000731a 4500\",\"fields\":[{\"001\":\"in001\"},{\"035\":{\"subfields\":[{\"a\":\"in001\"}],\"ind1\":\" \",\"ind2\":\" \"}},{\"507\":{\"subfields\":[{\"a\":\"data\"}],\"ind1\":\" \",\"ind2\":\" \"}},{\"500\":{\"subfields\":[{\"a\":\"data\"}],\"ind1\":\" \",\"ind2\":\" \"}}]}";
ParsedRecord parsedRecord = new ParsedRecord();
parsedRecord.setContent(parsedContent);
Record record = new Record().withId(UUID.randomUUID().toString()).withParsedRecord(parsedRecord).withGeneration(0).withState(Record.State.ACTUAL).withExternalIdsHolder(new ExternalIdsHolder().withInstanceId("001").withInstanceHrid("in001"));
// when
HrIdFieldService hrIdFieldService = new HrIdFieldServiceImpl();
hrIdFieldService.move001valueTo035Field(Lists.newArrayList(record));
// then
Assert.assertEquals(expectedParsedContent, record.getParsedRecord().getContent());
}
use of org.folio.rest.jaxrs.model.ExternalIdsHolder in project mod-inventory by folio-org.
the class CreateHoldingEventHandlerTest method shouldNotProcessEventIfInstanceIdIsNotExistsInInstanceInContextAndMarcBibliographicNotExists.
@Test(expected = ExecutionException.class)
public void shouldNotProcessEventIfInstanceIdIsNotExistsInInstanceInContextAndMarcBibliographicNotExists() throws InterruptedException, ExecutionException, TimeoutException {
Reader fakeReader = Mockito.mock(Reader.class);
String permanentLocationId = UUID.randomUUID().toString();
when(fakeReader.read(any(MappingRule.class))).thenReturn(StringValue.of(permanentLocationId));
when(fakeReaderFactory.createReader()).thenReturn(fakeReader);
when(storage.getHoldingsRecordCollection(any())).thenReturn(holdingsRecordsCollection);
MappingManager.registerReaderFactory(fakeReaderFactory);
MappingManager.registerWriterFactory(new HoldingWriterFactory());
String instanceId = String.valueOf(UUID.randomUUID());
Record record = new Record().withExternalIdsHolder(new ExternalIdsHolder().withInstanceId(instanceId));
HashMap<String, String> context = new HashMap<>();
context.put("INSTANCE", new JsonObject().encode());
context.put("InvalidField", JsonObject.mapFrom(record).encode());
DataImportEventPayload dataImportEventPayload = new DataImportEventPayload().withEventType(DI_INVENTORY_HOLDING_CREATED.value()).withJobExecutionId(UUID.randomUUID().toString()).withContext(context).withProfileSnapshot(profileSnapshotWrapper).withCurrentNode(profileSnapshotWrapper.getChildSnapshotWrappers().get(0));
CompletableFuture<DataImportEventPayload> future = createHoldingEventHandler.handle(dataImportEventPayload);
future.get(5, TimeUnit.MILLISECONDS);
}
Aggregations