use of org.folio.inventory.dataimport.handlers.quickmarc.UpdateHoldingsQuickMarcEventHandler in project mod-inventory by folio-org.
the class UpdateHoldingsQuickMarcEventHandlerTest method setUp.
@Before
public void setUp() throws IOException {
existingHoldingsRecord = new JsonObject(TestUtil.readFileFromPath(INSTANCE_PATH)).mapTo(HoldingsRecord.class);
holdingsUpdateDelegate = Mockito.spy(new HoldingsUpdateDelegate(storage));
updateHoldingsQuickMarcEventHandler = new UpdateHoldingsQuickMarcEventHandler(holdingsUpdateDelegate, context);
when(storage.getHoldingsRecordCollection(any())).thenReturn(holdingsRecordCollection);
doAnswer(invocationOnMock -> {
Consumer<Success<HoldingsRecord>> successHandler = invocationOnMock.getArgument(1);
successHandler.accept(new Success<>(existingHoldingsRecord));
return null;
}).when(holdingsRecordCollection).findById(anyString(), any(), any());
doAnswer(invocationOnMock -> {
HoldingsRecord holdingsRecord = invocationOnMock.getArgument(0);
Consumer<Success<HoldingsRecord>> successHandler = invocationOnMock.getArgument(1);
successHandler.accept(new Success<>(holdingsRecord));
return null;
}).when(holdingsRecordCollection).update(any(), any(), any());
when(context.getTenantId()).thenReturn("dummy");
when(context.getToken()).thenReturn("token");
when(context.getOkapiLocation()).thenReturn("http://localhost");
mappingRules = new JsonObject(TestUtil.readFileFromPath(MAPPING_RULES_PATH));
record = new JsonObject(TestUtil.readFileFromPath(RECORD_PATH));
}
Aggregations