@Test public void testExecute() { final long groupId = 1L; final long p1id = 1837L; final long p2id = 8847L; final long p3id = 8777L; final String p1Key = CacheKeys.PRIVATE_GROUP_IDS_VIEWABLE_BY_PERSON_AS_COORDINATOR + p1id; final String p2Key = CacheKeys.PRIVATE_GROUP_IDS_VIEWABLE_BY_PERSON_AS_COORDINATOR + p2id; final String p3Key = CacheKeys.PRIVATE_GROUP_IDS_VIEWABLE_BY_PERSON_AS_COORDINATOR + p3id; final Query query = context.mock(Query.class); final List<Long> ids = new ArrayList<Long>(); ids.add(p1id); ids.add(p2id); ids.add(p3id); context.checking(new Expectations() { { oneOf(em).createQuery( "SELECT p.id FROM Person p, DomainGroup g " + "WHERE g.id = :groupId " + "AND p MEMBER OF g.coordinators"); will(returnValue(query)); oneOf(query).setParameter("groupId", groupId); oneOf(query).getResultList(); will(returnValue(ids)); oneOf(cache).delete(p1Key); oneOf(cache).delete(p2Key); oneOf(cache).delete(p3Key); } }); sut.execute(groupId); context.assertIsSatisfied(); }
@SuppressWarnings("unchecked") public Void execute(final Long inDomainGroupId) { String queryTemplate = "SELECT p.id FROM Person p, DomainGroup g " + "WHERE g.id = :groupId AND p MEMBER OF g.coordinators"; Query query = getEntityManager().createQuery(queryTemplate); query.setParameter("groupId", inDomainGroupId); List<Long> peopleIds = query.getResultList(); for (Long id : peopleIds) { log.info("Clearing the cached security-scoped activity search string for user with person id: " + id); getCache().delete(CacheKeys.PRIVATE_GROUP_IDS_VIEWABLE_BY_PERSON_AS_COORDINATOR + id); } return null; }
ClearPrivateGroupIdsViewableByCoordinatorCacheOnGroupUpdate extends CachedDomainMapper implements
        DomainMapper<Long, Void> { @SuppressWarnings("unchecked") public Void execute(final Long inDomainGroupId) { String queryTemplate = "SELECT p.id FROM Person p, DomainGroup g " + "WHERE g.id = :groupId AND p MEMBER OF g.coordinators"; Query query = getEntityManager().createQuery(queryTemplate); query.setParameter("groupId", inDomainGroupId); List<Long> peopleIds = query.getResultList(); for (Long id : peopleIds) { log.info("Clearing the cached security-scoped activity search string for user with person id: " + id); getCache().delete(CacheKeys.PRIVATE_GROUP_IDS_VIEWABLE_BY_PERSON_AS_COORDINATOR + id); } return null; } }
ClearPrivateGroupIdsViewableByCoordinatorCacheOnGroupUpdate extends CachedDomainMapper implements
        DomainMapper<Long, Void> { @SuppressWarnings("unchecked") public Void execute(final Long inDomainGroupId) { String queryTemplate = "SELECT p.id FROM Person p, DomainGroup g " + "WHERE g.id = :groupId AND p MEMBER OF g.coordinators"; Query query = getEntityManager().createQuery(queryTemplate); query.setParameter("groupId", inDomainGroupId); List<Long> peopleIds = query.getResultList(); for (Long id : peopleIds) { log.info("Clearing the cached security-scoped activity search string for user with person id: " + id); getCache().delete(CacheKeys.PRIVATE_GROUP_IDS_VIEWABLE_BY_PERSON_AS_COORDINATOR + id); } return null; }  }
ClearPrivateGroupIdsViewableByCoordinatorCacheOnGroupUpdate extends CachedDomainMapper implements
        DomainMapper<Long, Void> { @SuppressWarnings("unchecked") public Void execute(final Long inDomainGroupId) { String queryTemplate = "SELECT p.id FROM Person p, DomainGroup g " + "WHERE g.id = :groupId AND p MEMBER OF g.coordinators"; Query query = getEntityManager().createQuery(queryTemplate); query.setParameter("groupId", inDomainGroupId); List<Long> peopleIds = query.getResultList(); for (Long id : peopleIds) { log.info("Clearing the cached security-scoped activity search string for user with person id: " + id); getCache().delete(CacheKeys.PRIVATE_GROUP_IDS_VIEWABLE_BY_PERSON_AS_COORDINATOR + id); } return null; }  @SuppressWarnings("unchecked") Void execute(final Long inDomainGroupId); }
ClearPrivateGroupIdsViewableByCoordinatorCacheOnGroupUpdate extends CachedDomainMapper implements
        DomainMapper<Long, Void> { @SuppressWarnings("unchecked") public Void execute(final Long inDomainGroupId) { String queryTemplate = "SELECT p.id FROM Person p, DomainGroup g " + "WHERE g.id = :groupId AND p MEMBER OF g.coordinators"; Query query = getEntityManager().createQuery(queryTemplate); query.setParameter("groupId", inDomainGroupId); List<Long> peopleIds = query.getResultList(); for (Long id : peopleIds) { log.info("Clearing the cached security-scoped activity search string for user with person id: " + id); getCache().delete(CacheKeys.PRIVATE_GROUP_IDS_VIEWABLE_BY_PERSON_AS_COORDINATOR + id); } return null; }  @SuppressWarnings("unchecked") Void execute(final Long inDomainGroupId);  }