@Test public void testExecute() { final Long user1 = 123L; final Long user2 = 456L; final List<Long> userIds = Arrays.asList(user1, user2); context.checking(new Expectations() { { oneOf(unreadMapper).execute(with(any(Date.class))); will(returnValue(userIds)); oneOf(deleteMapper).execute(with(any(Date.class))); will(returnValue(8)); oneOf(syncMapper).execute(user1); oneOf(syncMapper).execute(user2); } }); sut.execute(actionContext); context.assertIsSatisfied(); }
@Override public Serializable execute(final ActionContext inActionContext) { log.debug("Deleting in-app notifications older than {} days.", ageInDays); GregorianCalendar calendar = new GregorianCalendar(); calendar.add(GregorianCalendar.DATE, ageInDays * -1); Date oldDate = calendar.getTime(); List<Long> userIdsToSync = unreadMapper.execute(oldDate); int count = (Integer) deleteMapper.execute(oldDate); log.info("Deleted {} in-app notifications older than {} (over {} days old). Will sync {} users' counts.", new Object[] { count, oldDate, ageInDays, userIdsToSync.size() }); for (long userId : userIdsToSync) { syncMapper.execute(userId); } return true; }
DeleteOldInAppNotificationsExecution implements ExecutionStrategy<ActionContext> { @Override public Serializable execute(final ActionContext inActionContext) { log.debug("Deleting in-app notifications older than {} days.", ageInDays); GregorianCalendar calendar = new GregorianCalendar(); calendar.add(GregorianCalendar.DATE, ageInDays * -1); Date oldDate = calendar.getTime(); List<Long> userIdsToSync = unreadMapper.execute(oldDate); int count = (Integer) deleteMapper.execute(oldDate); log.info("Deleted {} in-app notifications older than {} (over {} days old). Will sync {} users' counts.", new Object[] { count, oldDate, ageInDays, userIdsToSync.size() }); for (long userId : userIdsToSync) { syncMapper.execute(userId); } return true; } }
DeleteOldInAppNotificationsExecution implements ExecutionStrategy<ActionContext> { @Override public Serializable execute(final ActionContext inActionContext) { log.debug("Deleting in-app notifications older than {} days.", ageInDays); GregorianCalendar calendar = new GregorianCalendar(); calendar.add(GregorianCalendar.DATE, ageInDays * -1); Date oldDate = calendar.getTime(); List<Long> userIdsToSync = unreadMapper.execute(oldDate); int count = (Integer) deleteMapper.execute(oldDate); log.info("Deleted {} in-app notifications older than {} (over {} days old). Will sync {} users' counts.", new Object[] { count, oldDate, ageInDays, userIdsToSync.size() }); for (long userId : userIdsToSync) { syncMapper.execute(userId); } return true; } DeleteOldInAppNotificationsExecution(final DeleteInAppNotificationsByDate inDeleteMapper,
            final DomainMapper<Date, List<Long>> inUnreadMapper,
            final DomainMapper<Long, UnreadInAppNotificationCountDTO> inSyncMapper, final int inAgeInDays); }
DeleteOldInAppNotificationsExecution implements ExecutionStrategy<ActionContext> { @Override public Serializable execute(final ActionContext inActionContext) { log.debug("Deleting in-app notifications older than {} days.", ageInDays); GregorianCalendar calendar = new GregorianCalendar(); calendar.add(GregorianCalendar.DATE, ageInDays * -1); Date oldDate = calendar.getTime(); List<Long> userIdsToSync = unreadMapper.execute(oldDate); int count = (Integer) deleteMapper.execute(oldDate); log.info("Deleted {} in-app notifications older than {} (over {} days old). Will sync {} users' counts.", new Object[] { count, oldDate, ageInDays, userIdsToSync.size() }); for (long userId : userIdsToSync) { syncMapper.execute(userId); } return true; } DeleteOldInAppNotificationsExecution(final DeleteInAppNotificationsByDate inDeleteMapper,
            final DomainMapper<Date, List<Long>> inUnreadMapper,
            final DomainMapper<Long, UnreadInAppNotificationCountDTO> inSyncMapper, final int inAgeInDays); @Override Serializable execute(final ActionContext inActionContext); }
DeleteOldInAppNotificationsExecution implements ExecutionStrategy<ActionContext> { @Override public Serializable execute(final ActionContext inActionContext) { log.debug("Deleting in-app notifications older than {} days.", ageInDays); GregorianCalendar calendar = new GregorianCalendar(); calendar.add(GregorianCalendar.DATE, ageInDays * -1); Date oldDate = calendar.getTime(); List<Long> userIdsToSync = unreadMapper.execute(oldDate); int count = (Integer) deleteMapper.execute(oldDate); log.info("Deleted {} in-app notifications older than {} (over {} days old). Will sync {} users' counts.", new Object[] { count, oldDate, ageInDays, userIdsToSync.size() }); for (long userId : userIdsToSync) { syncMapper.execute(userId); } return true; } DeleteOldInAppNotificationsExecution(final DeleteInAppNotificationsByDate inDeleteMapper,
            final DomainMapper<Date, List<Long>> inUnreadMapper,
            final DomainMapper<Long, UnreadInAppNotificationCountDTO> inSyncMapper, final int inAgeInDays); @Override Serializable execute(final ActionContext inActionContext);  }