use of org.folio.MappingMetadataDto in project mod-inventory by folio-org.
the class UpdateHoldingEventHandlerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
MappingManager.clearReaderFactories();
updateHoldingEventHandler = new UpdateHoldingEventHandler(storage, mappingMetadataCache);
doAnswer(invocationOnMock -> {
HoldingsRecord holdingsRecord = invocationOnMock.getArgument(0);
Consumer<Success<HoldingsRecord>> successHandler = invocationOnMock.getArgument(1);
successHandler.accept(new Success<>(holdingsRecord));
return null;
}).when(holdingsRecordsCollection).update(any(), any(Consumer.class), any(Consumer.class));
when(mappingMetadataCache.get(anyString(), any(Context.class))).thenReturn(Future.succeededFuture(Optional.of(new MappingMetadataDto().withMappingRules(new JsonObject().encode()).withMappingParams(Json.encode(new MappingParameters())))));
}
use of org.folio.MappingMetadataDto in project mod-inventory by folio-org.
the class UpdateItemEventHandlerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
doAnswer(invocationOnMock -> {
Item item = invocationOnMock.getArgument(0);
return CompletableFuture.completedFuture(item);
}).when(mockedItemCollection).update(any(Item.class));
Item returnedItem = new Item(UUID.randomUUID().toString(), "2", UUID.randomUUID().toString(), "test", new Status(AVAILABLE), UUID.randomUUID().toString(), UUID.randomUUID().toString(), new JsonObject());
doAnswer(invocationOnMock -> {
Consumer<Success<Item>> successHandler = invocationOnMock.getArgument(1);
successHandler.accept(new Success<>(returnedItem));
return null;
}).when(mockedItemCollection).update(any(), any(), any());
when(fakeReaderFactory.createReader()).thenReturn(fakeReader);
when(fakeReader.read(any(MappingRule.class))).thenReturn(StringValue.of(IN_PROCESS.value()));
when(mockedStorage.getItemCollection(ArgumentMatchers.any(Context.class))).thenReturn(mockedItemCollection);
when(mockedStorage.getHoldingsRecordCollection(ArgumentMatchers.any(Context.class))).thenReturn(mockedHoldingsCollection);
String instanceId = String.valueOf(UUID.randomUUID());
String holdingId = UUID.randomUUID().toString();
String hrid = UUID.randomUUID().toString();
String permanentLocationId = UUID.randomUUID().toString();
doAnswer(invocationOnMock -> {
HoldingsRecord returnedHoldings = new HoldingsRecord().withId(holdingId).withHrid(hrid).withInstanceId(instanceId).withPermanentLocationId(permanentLocationId).withVersion(1);
Consumer<Success<HoldingsRecord>> successHandler = invocationOnMock.getArgument(1);
successHandler.accept(new Success<>(returnedHoldings));
return null;
}).when(mockedHoldingsCollection).findById(anyString(), any(Consumer.class), any(Consumer.class));
when(mappingMetadataCache.get(anyString(), any(Context.class))).thenReturn(Future.succeededFuture(Optional.of(new MappingMetadataDto().withMappingRules(new JsonObject().encode()).withMappingParams(Json.encode(new MappingParameters())))));
MappingManager.clearReaderFactories();
MappingManager.registerReaderFactory(fakeReaderFactory);
MappingManager.registerWriterFactory(new ItemWriterFactory());
updateItemHandler = new UpdateItemEventHandler(mockedStorage, mappingMetadataCache);
existingItemJson = new JsonObject().put("id", UUID.randomUUID().toString()).put("status", new JsonObject().put("name", AVAILABLE.value())).put("materialType", new JsonObject().put("id", UUID.randomUUID().toString())).put("permanentLoanType", new JsonObject().put("id", UUID.randomUUID().toString())).put("holdingsRecordId", UUID.randomUUID().toString());
}
use of org.folio.MappingMetadataDto in project mod-inventory by folio-org.
the class MatchItemEventHandlerUnitTest method setUp.
@Before
public void setUp() {
MatchValueReaderFactory.clearReaderFactory();
MatchValueLoaderFactory.clearLoaderFactory();
MockitoAnnotations.initMocks(this);
when(marcValueReader.isEligibleForEntityType(MARC_BIBLIOGRAPHIC)).thenReturn(true);
when(storage.getItemCollection(any(Context.class))).thenReturn(itemCollection);
when(marcValueReader.read(any(DataImportEventPayload.class), any(MatchDetail.class))).thenReturn(StringValue.of(ITEM_HRID));
MatchValueReaderFactory.register(marcValueReader);
MatchValueLoaderFactory.register(itemLoader);
when(mappingMetadataCache.get(anyString(), any(Context.class))).thenReturn(Future.succeededFuture(Optional.of(new MappingMetadataDto().withMappingRules(new JsonObject().encode()).withMappingParams(LOCATIONS_PARAMS))));
}
Aggregations