PermissionEntryCache { @NotNull PrincipalPermissionEntries getFullyLoadedEntries(@NotNull PermissionStore store, @NotNull String principalName) { PrincipalPermissionEntries ppe = entries.get(principalName); if (ppe == null || !ppe.isFullyLoaded()) { ppe = store.load(principalName); entries.put(principalName, ppe); } return ppe; }    }
@Test public void testGetFullyLoadedEntries() throws Exception { ppe.setFullyLoaded(true); when(store.load("a")).thenReturn(ppe); PrincipalPermissionEntries entries = cache.getFullyLoadedEntries(store, "a"); assertSame(ppe, entries); PrincipalPermissionEntries inspectedEntries = inspectEntries(cache, "a"); assertSame(ppe, inspectedEntries); when(store.load("a")).thenThrow(IllegalStateException.class); entries = cache.getFullyLoadedEntries(store, "a"); assertSame(ppe, entries); }