@Test public void test() { final Long activityId = 6789L; Activity a = (Activity) getEntityManager().createQuery("FROM Activity WHERE id = :activityId").setParameter( "activityId", activityId).getSingleResult(); assertTrue(a.getShowInStream()); context.checking(new Expectations() { { oneOf(cache).removeFromList(CacheKeys.EVERYONE_ACTIVITY_IDS, activityId); oneOf(cache).delete(CacheKeys.ACTIVITY_BY_ID + activityId); oneOf(cache).delete(CacheKeys.ACTIVITY_SECURITY_BY_ID + activityId); } }); sut.execute(activityId); getEntityManager().flush(); getEntityManager().clear(); a = (Activity) getEntityManager().createQuery("FROM Activity WHERE id = :activityId").setParameter( "activityId", activityId).getSingleResult(); assertFalse(a.getShowInStream()); context.assertIsSatisfied(); }
@Override public Void execute(final Long inRequest) { getEntityManager().createQuery("UPDATE Activity a SET a.showInStream = :showInStream WHERE id = :activityId") .setParameter("showInStream", false).setParameter("activityId", inRequest).executeUpdate(); getCache().removeFromList(CacheKeys.EVERYONE_ACTIVITY_IDS, inRequest); log.info("Removing activity with id #" + inRequest + " from cache."); getCache().delete(CacheKeys.ACTIVITY_BY_ID + inRequest); log.info("Removing activity security dto with activity id #" + inRequest + " from cache."); getCache().delete(CacheKeys.ACTIVITY_SECURITY_BY_ID + inRequest); return null; }
HideResourceActivityMapper extends BaseArgCachedDomainMapper<Long, Void> { @Override public Void execute(final Long inRequest) { getEntityManager().createQuery("UPDATE Activity a SET a.showInStream = :showInStream WHERE id = :activityId") .setParameter("showInStream", false).setParameter("activityId", inRequest).executeUpdate(); getCache().removeFromList(CacheKeys.EVERYONE_ACTIVITY_IDS, inRequest); log.info("Removing activity with id #" + inRequest + " from cache."); getCache().delete(CacheKeys.ACTIVITY_BY_ID + inRequest); log.info("Removing activity security dto with activity id #" + inRequest + " from cache."); getCache().delete(CacheKeys.ACTIVITY_SECURITY_BY_ID + inRequest); return null; } }
HideResourceActivityMapper extends BaseArgCachedDomainMapper<Long, Void> { @Override public Void execute(final Long inRequest) { getEntityManager().createQuery("UPDATE Activity a SET a.showInStream = :showInStream WHERE id = :activityId") .setParameter("showInStream", false).setParameter("activityId", inRequest).executeUpdate(); getCache().removeFromList(CacheKeys.EVERYONE_ACTIVITY_IDS, inRequest); log.info("Removing activity with id #" + inRequest + " from cache."); getCache().delete(CacheKeys.ACTIVITY_BY_ID + inRequest); log.info("Removing activity security dto with activity id #" + inRequest + " from cache."); getCache().delete(CacheKeys.ACTIVITY_SECURITY_BY_ID + inRequest); return null; }  }
HideResourceActivityMapper extends BaseArgCachedDomainMapper<Long, Void> { @Override public Void execute(final Long inRequest) { getEntityManager().createQuery("UPDATE Activity a SET a.showInStream = :showInStream WHERE id = :activityId") .setParameter("showInStream", false).setParameter("activityId", inRequest).executeUpdate(); getCache().removeFromList(CacheKeys.EVERYONE_ACTIVITY_IDS, inRequest); log.info("Removing activity with id #" + inRequest + " from cache."); getCache().delete(CacheKeys.ACTIVITY_BY_ID + inRequest); log.info("Removing activity security dto with activity id #" + inRequest + " from cache."); getCache().delete(CacheKeys.ACTIVITY_SECURITY_BY_ID + inRequest); return null; }  @Override Void execute(final Long inRequest); }
HideResourceActivityMapper extends BaseArgCachedDomainMapper<Long, Void> { @Override public Void execute(final Long inRequest) { getEntityManager().createQuery("UPDATE Activity a SET a.showInStream = :showInStream WHERE id = :activityId") .setParameter("showInStream", false).setParameter("activityId", inRequest).executeUpdate(); getCache().removeFromList(CacheKeys.EVERYONE_ACTIVITY_IDS, inRequest); log.info("Removing activity with id #" + inRequest + " from cache."); getCache().delete(CacheKeys.ACTIVITY_BY_ID + inRequest); log.info("Removing activity security dto with activity id #" + inRequest + " from cache."); getCache().delete(CacheKeys.ACTIVITY_SECURITY_BY_ID + inRequest); return null; }  @Override Void execute(final Long inRequest);  }