EmailModule { @Singleton @Provides EmailHealthCheck provideEmailHealthCheck() { return emailServiceFactory.createHealthCheck(); } EmailModule(EmailServiceFactory emailServiceFactory);   }
@Test void testProvideDatabaseHealthCheck() { var factory = mock(EmailServiceFactory.class); var healthCheck = mock(EmailHealthCheck.class); when(factory.createHealthCheck()).thenReturn(healthCheck); EmailModule module = new EmailModule(factory); Assert.assertEquals(healthCheck, module.provideEmailHealthCheck()); }