Search in sources :

Example 1 with AuthorityUpdateDelegate

use of org.folio.inventory.dataimport.handlers.actions.AuthorityUpdateDelegate in project mod-inventory by folio-org.

the class UpdateAuthorityQuickMarcEventHandlerTest method setUp.

@Before
public void setUp() throws IOException {
    existingAuthority = new JsonObject(TestUtil.readFileFromPath(AUTHORITY_PATH)).mapTo(Authority.class);
    authorityUpdateDelegate = Mockito.spy(new AuthorityUpdateDelegate(storage));
    updateAuthorityQuickMarcEventHandler = new UpdateAuthorityQuickMarcEventHandler(authorityUpdateDelegate, context);
    when(storage.getAuthorityRecordCollection(any())).thenReturn(authorityRecordCollection);
    doAnswer(invocationOnMock -> {
        Consumer<Success<Authority>> successHandler = invocationOnMock.getArgument(1);
        successHandler.accept(new Success<>(existingAuthority));
        return null;
    }).when(authorityRecordCollection).findById(anyString(), any(), any());
    doAnswer(invocationOnMock -> {
        Authority authority = invocationOnMock.getArgument(0);
        Consumer<Success<Authority>> successHandler = invocationOnMock.getArgument(1);
        successHandler.accept(new Success<>(authority));
        return null;
    }).when(authorityRecordCollection).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 : Authority(org.folio.Authority) JsonObject(io.vertx.core.json.JsonObject) UpdateAuthorityQuickMarcEventHandler(org.folio.inventory.dataimport.handlers.quickmarc.UpdateAuthorityQuickMarcEventHandler) AuthorityUpdateDelegate(org.folio.inventory.dataimport.handlers.actions.AuthorityUpdateDelegate) Success(org.folio.inventory.common.domain.Success) Before(org.junit.Before)

Aggregations

JsonObject (io.vertx.core.json.JsonObject)1 Authority (org.folio.Authority)1 Success (org.folio.inventory.common.domain.Success)1 AuthorityUpdateDelegate (org.folio.inventory.dataimport.handlers.actions.AuthorityUpdateDelegate)1 UpdateAuthorityQuickMarcEventHandler (org.folio.inventory.dataimport.handlers.quickmarc.UpdateAuthorityQuickMarcEventHandler)1 Before (org.junit.Before)1