@Test public void testExecuteWithDataAlreadyExisting() { GenerateDailyUsageSummaryExecution sut = new GenerateDailyUsageSummaryExecution(1, daysAgoDateStrategy, getDailyUsageSummaryByDateMapper, getDailyMessageCountMapper, getDailyPageViewCountMapper, getDailyStreamContributorCountMapper, getDailyStreamViewCountMapper, getDailyStreamViewerCountMapper, getDailyUniqueVisitorCountMapper, getDailyMessageResponseTimeMapper, insertMapper, usageMetricDataCleanupMapper, dayOfWeekStrategy, streamScopeIdsMapper, getTotalActivityCountMapper, getTotalCommentCountMapper, getTotalStreamContributorMapper, clearEntityManagerMapper, summaryDataMapper, discoverPageListsCacheRefreshingMapper, numberOfDaysToCacheSummaryDataFor); final DailyUsageSummary existingSummary = context.mock(DailyUsageSummary.class); final Date date = new Date(2011, 1, 22); context.checking(new Expectations() { { oneOf(daysAgoDateStrategy).execute(with(1)); will(returnValue(date)); oneOf(getDailyUsageSummaryByDateMapper).execute( with(IsEqualInternally.equalInternally(new UsageMetricDailyStreamInfoRequest(DateDayExtractor .getStartOfDay(date), null)))); will(returnValue(existingSummary)); oneOf(dayOfWeekStrategy).isWeekday(with(DateDayExtractor.getStartOfDay(date))); will(returnValue(true)); oneOf(usageMetricDataCleanupMapper).execute(null); allowing(clearEntityManagerMapper).execute(null); oneOf(discoverPageListsCacheRefreshingMapper).execute(null); } }); sut.execute(actionContext); context.assertIsSatisfied(); }
@Override public Serializable execute(final TaskHandlerActionContext<ActionContext> inActionContext) throws ExecutionException { long start = System.currentTimeMillis(); for (int i = daysToGenerate; i >= 1; i--) { logger.info("Generating metric data for " + i + " days ago."); generateDailyUsageSummaryForDay(i); } logger.info("Deleting old daily usage metric data older than 2 days"); usageMetricDataCleanupMapper.execute(null); logger.info("Completed generating usage metrics in " + (System.currentTimeMillis() - start) + "ms"); logger.info("Updating the Discover Page cache."); discoverPageListsCacheRefreshingMapper.execute(null); logger.info("Completed generating Discover Page cache."); return Boolean.TRUE; }
GenerateDailyUsageSummaryExecution implements TaskHandlerExecutionStrategy<ActionContext> { @Override public Serializable execute(final TaskHandlerActionContext<ActionContext> inActionContext) throws ExecutionException { long start = System.currentTimeMillis(); for (int i = daysToGenerate; i >= 1; i--) { logger.info("Generating metric data for " + i + " days ago."); generateDailyUsageSummaryForDay(i); } logger.info("Deleting old daily usage metric data older than 2 days"); usageMetricDataCleanupMapper.execute(null); logger.info("Completed generating usage metrics in " + (System.currentTimeMillis() - start) + "ms"); logger.info("Updating the Discover Page cache."); discoverPageListsCacheRefreshingMapper.execute(null); logger.info("Completed generating Discover Page cache."); return Boolean.TRUE; } }
GenerateDailyUsageSummaryExecution implements TaskHandlerExecutionStrategy<ActionContext> { @Override public Serializable execute(final TaskHandlerActionContext<ActionContext> inActionContext) throws ExecutionException { long start = System.currentTimeMillis(); for (int i = daysToGenerate; i >= 1; i--) { logger.info("Generating metric data for " + i + " days ago."); generateDailyUsageSummaryForDay(i); } logger.info("Deleting old daily usage metric data older than 2 days"); usageMetricDataCleanupMapper.execute(null); logger.info("Completed generating usage metrics in " + (System.currentTimeMillis() - start) + "ms"); logger.info("Updating the Discover Page cache."); discoverPageListsCacheRefreshingMapper.execute(null); logger.info("Completed generating Discover Page cache."); return Boolean.TRUE; } GenerateDailyUsageSummaryExecution(
            final int inDaysToGenerate,
            final GetDateFromDaysAgoStrategy inDaysAgoDateStrategy,
            final DomainMapper<UsageMetricDailyStreamInfoRequest, DailyUsageSummary> inGetDailyUsageSummaryByDateMapper,
            final DomainMapper<UsageMetricDailyStreamInfoRequest, Long> inGetDailyMessageCountMapper,
            final DomainMapper<Date, Long> inGetDailyPageViewCountMapper,
            final DomainMapper<UsageMetricDailyStreamInfoRequest, Long> inGetDailyStreamContributorCountMapper,
            final DomainMapper<UsageMetricDailyStreamInfoRequest, Long> inGetDailyStreamViewCountMapper,
            final DomainMapper<UsageMetricDailyStreamInfoRequest, Long> inGetDailyStreamViewerCountMapper,
            final DomainMapper<Date, Long> inGetDailyUniqueVisitorCountMapper,
            final DomainMapper<Date, Long> inGetDailyMessageResponseTimeMapper,
            final DomainMapper<PersistenceRequest<DailyUsageSummary>, Boolean> inInsertMapper,
            final DomainMapper<Serializable, Serializable> inUsageMetricDataCleanupMapper,
            final DayOfWeekStrategy inDayOfWeekStrategy, final DomainMapper<Date, List<Long>> inStreamScopeIdsMapper,
            final DomainMapper<UsageMetricDailyStreamInfoRequest, Long> inGetTotalActivityCountMapper,
            final DomainMapper<UsageMetricDailyStreamInfoRequest, Long> inGetTotalCommentCountMapper,
            final DomainMapper<UsageMetricDailyStreamInfoRequest, Long> inGetTotalStreamContributorMapper,
            final DomainMapper<Serializable, Boolean> inClearEntityManagerMapper,
            final DomainMapper<UsageMetricStreamSummaryRequest, List<DailyUsageSummary>> inSummaryDataMapper,
            final DomainMapper<Serializable, StreamDiscoverListsDTO> inDiscoverPageListsCacheRefreshingMapper,
            final int inNumberOfDaysToCacheSummaryDataFor); }
GenerateDailyUsageSummaryExecution implements TaskHandlerExecutionStrategy<ActionContext> { @Override public Serializable execute(final TaskHandlerActionContext<ActionContext> inActionContext) throws ExecutionException { long start = System.currentTimeMillis(); for (int i = daysToGenerate; i >= 1; i--) { logger.info("Generating metric data for " + i + " days ago."); generateDailyUsageSummaryForDay(i); } logger.info("Deleting old daily usage metric data older than 2 days"); usageMetricDataCleanupMapper.execute(null); logger.info("Completed generating usage metrics in " + (System.currentTimeMillis() - start) + "ms"); logger.info("Updating the Discover Page cache."); discoverPageListsCacheRefreshingMapper.execute(null); logger.info("Completed generating Discover Page cache."); return Boolean.TRUE; } GenerateDailyUsageSummaryExecution(
            final int inDaysToGenerate,
            final GetDateFromDaysAgoStrategy inDaysAgoDateStrategy,
            final DomainMapper<UsageMetricDailyStreamInfoRequest, DailyUsageSummary> inGetDailyUsageSummaryByDateMapper,
            final DomainMapper<UsageMetricDailyStreamInfoRequest, Long> inGetDailyMessageCountMapper,
            final DomainMapper<Date, Long> inGetDailyPageViewCountMapper,
            final DomainMapper<UsageMetricDailyStreamInfoRequest, Long> inGetDailyStreamContributorCountMapper,
            final DomainMapper<UsageMetricDailyStreamInfoRequest, Long> inGetDailyStreamViewCountMapper,
            final DomainMapper<UsageMetricDailyStreamInfoRequest, Long> inGetDailyStreamViewerCountMapper,
            final DomainMapper<Date, Long> inGetDailyUniqueVisitorCountMapper,
            final DomainMapper<Date, Long> inGetDailyMessageResponseTimeMapper,
            final DomainMapper<PersistenceRequest<DailyUsageSummary>, Boolean> inInsertMapper,
            final DomainMapper<Serializable, Serializable> inUsageMetricDataCleanupMapper,
            final DayOfWeekStrategy inDayOfWeekStrategy, final DomainMapper<Date, List<Long>> inStreamScopeIdsMapper,
            final DomainMapper<UsageMetricDailyStreamInfoRequest, Long> inGetTotalActivityCountMapper,
            final DomainMapper<UsageMetricDailyStreamInfoRequest, Long> inGetTotalCommentCountMapper,
            final DomainMapper<UsageMetricDailyStreamInfoRequest, Long> inGetTotalStreamContributorMapper,
            final DomainMapper<Serializable, Boolean> inClearEntityManagerMapper,
            final DomainMapper<UsageMetricStreamSummaryRequest, List<DailyUsageSummary>> inSummaryDataMapper,
            final DomainMapper<Serializable, StreamDiscoverListsDTO> inDiscoverPageListsCacheRefreshingMapper,
            final int inNumberOfDaysToCacheSummaryDataFor); @Override Serializable execute(final TaskHandlerActionContext<ActionContext> inActionContext); }
GenerateDailyUsageSummaryExecution implements TaskHandlerExecutionStrategy<ActionContext> { @Override public Serializable execute(final TaskHandlerActionContext<ActionContext> inActionContext) throws ExecutionException { long start = System.currentTimeMillis(); for (int i = daysToGenerate; i >= 1; i--) { logger.info("Generating metric data for " + i + " days ago."); generateDailyUsageSummaryForDay(i); } logger.info("Deleting old daily usage metric data older than 2 days"); usageMetricDataCleanupMapper.execute(null); logger.info("Completed generating usage metrics in " + (System.currentTimeMillis() - start) + "ms"); logger.info("Updating the Discover Page cache."); discoverPageListsCacheRefreshingMapper.execute(null); logger.info("Completed generating Discover Page cache."); return Boolean.TRUE; } GenerateDailyUsageSummaryExecution(
            final int inDaysToGenerate,
            final GetDateFromDaysAgoStrategy inDaysAgoDateStrategy,
            final DomainMapper<UsageMetricDailyStreamInfoRequest, DailyUsageSummary> inGetDailyUsageSummaryByDateMapper,
            final DomainMapper<UsageMetricDailyStreamInfoRequest, Long> inGetDailyMessageCountMapper,
            final DomainMapper<Date, Long> inGetDailyPageViewCountMapper,
            final DomainMapper<UsageMetricDailyStreamInfoRequest, Long> inGetDailyStreamContributorCountMapper,
            final DomainMapper<UsageMetricDailyStreamInfoRequest, Long> inGetDailyStreamViewCountMapper,
            final DomainMapper<UsageMetricDailyStreamInfoRequest, Long> inGetDailyStreamViewerCountMapper,
            final DomainMapper<Date, Long> inGetDailyUniqueVisitorCountMapper,
            final DomainMapper<Date, Long> inGetDailyMessageResponseTimeMapper,
            final DomainMapper<PersistenceRequest<DailyUsageSummary>, Boolean> inInsertMapper,
            final DomainMapper<Serializable, Serializable> inUsageMetricDataCleanupMapper,
            final DayOfWeekStrategy inDayOfWeekStrategy, final DomainMapper<Date, List<Long>> inStreamScopeIdsMapper,
            final DomainMapper<UsageMetricDailyStreamInfoRequest, Long> inGetTotalActivityCountMapper,
            final DomainMapper<UsageMetricDailyStreamInfoRequest, Long> inGetTotalCommentCountMapper,
            final DomainMapper<UsageMetricDailyStreamInfoRequest, Long> inGetTotalStreamContributorMapper,
            final DomainMapper<Serializable, Boolean> inClearEntityManagerMapper,
            final DomainMapper<UsageMetricStreamSummaryRequest, List<DailyUsageSummary>> inSummaryDataMapper,
            final DomainMapper<Serializable, StreamDiscoverListsDTO> inDiscoverPageListsCacheRefreshingMapper,
            final int inNumberOfDaysToCacheSummaryDataFor); @Override Serializable execute(final TaskHandlerActionContext<ActionContext> inActionContext);  }