### Question:
IntegrationHandlerProvider { public Optional<IntegrationHandler> getIntegrationHandler() { return integrationHandler; } IntegrationHandlerProvider(); @Inject  IntegrationHandlerProvider(@Any final Instance<IntegrationHandler> integrationHandlerInstance); Optional<IntegrationHandler> getIntegrationHandler();  }### Answer:
@Test public void testIntegrationHandlerProviderWhenIntegrationIsPresent() { IntegrationHandler integrationHandler = mock(IntegrationHandler.class); integrationHandlers.add(integrationHandler); when(integrationHandlerInstance.iterator()).thenReturn(integrationHandlers.iterator()); integrationHandlerProvider = new IntegrationHandlerProvider(integrationHandlerInstance); assertTrue(integrationHandlerProvider.getIntegrationHandler().isPresent()); assertEquals(integrationHandler, integrationHandlerProvider.getIntegrationHandler().get()); }
@Test public void testIntegrationHandlerProviderWhenIntegrationIsNotPresent() { when(integrationHandlerInstance.iterator()).thenReturn(integrationHandlers.iterator()); integrationHandlerProvider = new IntegrationHandlerProvider(integrationHandlerInstance); assertFalse(integrationHandlerProvider.getIntegrationHandler().isPresent()); }