GroupFacetImpl extends FacetSupport implements GroupFacet { @Override public boolean isStale(@Nullable final Content content) { if (content == null) { return true; } final CacheInfo cacheInfo = content.getAttributes().get(CacheInfo.class); if(isNull(cacheInfo)) { log.warn("CacheInfo missing for {}, assuming stale content.", content); return true; } return cacheController.isStale(cacheInfo); } @Inject  GroupFacetImpl(final RepositoryManager repositoryManager,
                        final ConstraintViolationFactory constraintViolationFactory,
                        @Named(GroupType.NAME) final Type groupType); @Override @Guarded(by = STARTED) boolean member(final String repositoryName); @Override @Guarded(by = STARTED) boolean member(final Repository repository); @Override @Guarded(by = STARTED) List<Repository> members(); @Override List<Repository> leafMembers(); @Override List<Repository> allMembers(); @Override void invalidateGroupCaches(); @Override boolean isStale(@Nullable final Content content); @Override void maintainCacheInfo(final AttributesMap attributesMap); static final String CONFIG_KEY; }
@Test public void whenContentIsNullIsStale() { assertThat(underTest.isStale(null), is(true)); }
@Test public void whenCacheInfoIsNullThenIsStale() { when(content.getAttributes()).thenReturn(attributesMap); when(attributesMap.get(CacheInfo.class)).thenReturn(null); assertThat(underTest.isStale(content), is(true)); }
@Test public void whenCachePresentTheNotStale() { when(content.getAttributes()).thenReturn(attributesMap); when(attributesMap.get(CacheInfo.class)).thenReturn(cacheInfo); CacheController cacheController = mock(CacheController.class); underTest.cacheController = cacheController; when(cacheController.isStale(cacheInfo)).thenReturn(false); assertThat(underTest.isStale(content), is(false)); }