### Question:
CachedRolesProvider implements RolesProvider { @Override public RolesProviderHealth checkHealth() { return rolesProvider.checkHealth(); } CachedRolesProvider(RolesProvider rolesProvider);  CachedRolesProvider(RolesProvider rolesProvider, RolesCache rolesCache); @Override Set<String> getUserRoles(String username); @Override RolesProviderHealth checkHealth();  }### Answer:
@Test public void isHealthyIfDelegateRolesProviderIsHealthy() throws Exception { Map<String, Object> details = new LinkedHashMap<>(); details.put("mock", "Return healthy for a mock test"); Mockito.when(rolesProvider.checkHealth()).thenReturn(new RolesProviderHealth(true, details)); System.out.println(cachedRolesProvider.checkHealth().details()); Assert.assertTrue(cachedRolesProvider.checkHealth().isHealthy()); }
@Test public void isUnhealthyIfDelegateRolesProviderIsUnhealthy() throws Exception { Map<String, Object> details = new LinkedHashMap<>(); details.put("mock", "Return unhealthy for a mock test"); Mockito.when(rolesProvider.checkHealth()).thenReturn(new RolesProviderHealth(false, details)); System.out.println(cachedRolesProvider.checkHealth().details()); Assert.assertFalse(cachedRolesProvider.checkHealth().isHealthy()); }