### Question:
UsageUpdateHandler implements ResourceUpdateHandler { void processInternal(final ChangeEvent event) { LOG.debug("Processing event: {}", event); final ListResult<Integration> integrationsResult = dataManager.fetchAll(Integration.class); final List<Integration> integrations = integrationsResult.getItems(); updateUsageFor(Connection.class, integrations, Integration::getConnectionIds, Functions.compose(Optional::get, Connection::getId), UsageUpdateHandler::withUpdatedUsage); updateUsageFor(Extension.class, integrations, Integration::getExtensionIds, Extension::getExtensionId, UsageUpdateHandler::withUpdatedUsage); } UsageUpdateHandler(final DataManager dataManager); @Override boolean canHandle(final ChangeEvent event); @Override void process(final ChangeEvent event);  }### Answer:
@Test public void unusedConnectionsShouldHaveUseOfZero() { final Integration emptyIntegration = new Integration.Builder().build(); when(dataManager.fetchAll(Integration.class)).thenReturn(ListResult.of(emptyIntegration, emptyIntegration)); handler.processInternal(NOT_USED); verify(dataManager).fetchAll(Integration.class); verify(dataManager).fetchAll(Connection.class); verify(dataManager).fetchAll(Extension.class); verifyNoMoreInteractions(dataManager); }
@Test public void withNoIntegrationsConnectionUsageShouldBeZero() { when(dataManager.fetchAll(Integration.class)).thenReturn(ListResult.of(emptyList())); handler.processInternal(NOT_USED); verify(dataManager).fetchAll(Integration.class); verify(dataManager).fetchAll(Connection.class); verify(dataManager).fetchAll(Extension.class); verifyNoMoreInteractions(dataManager); }