Search in sources :

Example 1 with UpdateHoldingsQuickMarcEventHandler

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));
}
Also used : HoldingsRecord(org.folio.HoldingsRecord) UpdateHoldingsQuickMarcEventHandler(org.folio.inventory.dataimport.handlers.quickmarc.UpdateHoldingsQuickMarcEventHandler) JsonObject(io.vertx.core.json.JsonObject) HoldingsUpdateDelegate(org.folio.inventory.dataimport.handlers.actions.HoldingsUpdateDelegate) Success(org.folio.inventory.common.domain.Success) Before(org.junit.Before)

Aggregations

JsonObject (io.vertx.core.json.JsonObject)1 HoldingsRecord (org.folio.HoldingsRecord)1 Success (org.folio.inventory.common.domain.Success)1 HoldingsUpdateDelegate (org.folio.inventory.dataimport.handlers.actions.HoldingsUpdateDelegate)1 UpdateHoldingsQuickMarcEventHandler (org.folio.inventory.dataimport.handlers.quickmarc.UpdateHoldingsQuickMarcEventHandler)1 Before (org.junit.Before)1