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));
}
Aggregations