@Test public void testExecuteWithDataForAllStreams() { final long id = 1L; final long messagecount = 5L; final long pageviewcount = 55L; final long streamcontributorcount = 555L; final long streamviewcount = 5555L; final long streamviewercount = 55555L; final long uniquevisitorcount = 555555L; final long responseTime = 5555555L; final long april7th2011 = 1302196002000L; Date date = new Date(april7th2011); DailyUsageSummary result = sut.execute(new UsageMetricDailyStreamInfoRequest(date, null)); Assert.assertEquals(id, result.getId()); Assert.assertEquals(messagecount, result.getMessageCount()); Assert.assertEquals(pageviewcount, result.getPageViewCount()); Assert.assertEquals(streamcontributorcount, result.getStreamContributorCount()); Assert.assertEquals(streamviewcount, result.getStreamViewCount()); Assert.assertEquals(streamviewercount, result.getStreamViewerCount()); Assert.assertEquals(uniquevisitorcount, result.getUniqueVisitorCount()); Assert.assertEquals(responseTime, result.getAvgActivityResponseTime()); }
@Override public DailyUsageSummary execute(final UsageMetricDailyStreamInfoRequest inRequest) { List<DailyUsageSummary> results; Query q; if (inRequest.getStreamRecipientStreamScopeId() == null) { q = getEntityManager().createQuery( "FROM DailyUsageSummary WHERE usageDate = :usageDate AND streamViewStreamScopeId IS NULL"); q.setParameter("usageDate", inRequest.getMetricsDate()); } else { q = getEntityManager().createQuery( "FROM DailyUsageSummary WHERE usageDate = :usageDate " + "AND streamViewStreamScopeId = :streamViewStreamScopeId"); q.setParameter("usageDate", inRequest.getMetricsDate()); q.setParameter("streamViewStreamScopeId", inRequest.getStreamRecipientStreamScopeId()); } results = q.getResultList(); if (results.size() > 0) { return results.get(0); } return null; }
GetDailyUsageSummaryByDateDbMapper extends
        BaseArgDomainMapper<UsageMetricDailyStreamInfoRequest, DailyUsageSummary> { @Override public DailyUsageSummary execute(final UsageMetricDailyStreamInfoRequest inRequest) { List<DailyUsageSummary> results; Query q; if (inRequest.getStreamRecipientStreamScopeId() == null) { q = getEntityManager().createQuery( "FROM DailyUsageSummary WHERE usageDate = :usageDate AND streamViewStreamScopeId IS NULL"); q.setParameter("usageDate", inRequest.getMetricsDate()); } else { q = getEntityManager().createQuery( "FROM DailyUsageSummary WHERE usageDate = :usageDate " + "AND streamViewStreamScopeId = :streamViewStreamScopeId"); q.setParameter("usageDate", inRequest.getMetricsDate()); q.setParameter("streamViewStreamScopeId", inRequest.getStreamRecipientStreamScopeId()); } results = q.getResultList(); if (results.size() > 0) { return results.get(0); } return null; } }
GetDailyUsageSummaryByDateDbMapper extends
        BaseArgDomainMapper<UsageMetricDailyStreamInfoRequest, DailyUsageSummary> { @Override public DailyUsageSummary execute(final UsageMetricDailyStreamInfoRequest inRequest) { List<DailyUsageSummary> results; Query q; if (inRequest.getStreamRecipientStreamScopeId() == null) { q = getEntityManager().createQuery( "FROM DailyUsageSummary WHERE usageDate = :usageDate AND streamViewStreamScopeId IS NULL"); q.setParameter("usageDate", inRequest.getMetricsDate()); } else { q = getEntityManager().createQuery( "FROM DailyUsageSummary WHERE usageDate = :usageDate " + "AND streamViewStreamScopeId = :streamViewStreamScopeId"); q.setParameter("usageDate", inRequest.getMetricsDate()); q.setParameter("streamViewStreamScopeId", inRequest.getStreamRecipientStreamScopeId()); } results = q.getResultList(); if (results.size() > 0) { return results.get(0); } return null; }  }
GetDailyUsageSummaryByDateDbMapper extends
        BaseArgDomainMapper<UsageMetricDailyStreamInfoRequest, DailyUsageSummary> { @Override public DailyUsageSummary execute(final UsageMetricDailyStreamInfoRequest inRequest) { List<DailyUsageSummary> results; Query q; if (inRequest.getStreamRecipientStreamScopeId() == null) { q = getEntityManager().createQuery( "FROM DailyUsageSummary WHERE usageDate = :usageDate AND streamViewStreamScopeId IS NULL"); q.setParameter("usageDate", inRequest.getMetricsDate()); } else { q = getEntityManager().createQuery( "FROM DailyUsageSummary WHERE usageDate = :usageDate " + "AND streamViewStreamScopeId = :streamViewStreamScopeId"); q.setParameter("usageDate", inRequest.getMetricsDate()); q.setParameter("streamViewStreamScopeId", inRequest.getStreamRecipientStreamScopeId()); } results = q.getResultList(); if (results.size() > 0) { return results.get(0); } return null; }  @Override DailyUsageSummary execute(final UsageMetricDailyStreamInfoRequest inRequest); }
GetDailyUsageSummaryByDateDbMapper extends
        BaseArgDomainMapper<UsageMetricDailyStreamInfoRequest, DailyUsageSummary> { @Override public DailyUsageSummary execute(final UsageMetricDailyStreamInfoRequest inRequest) { List<DailyUsageSummary> results; Query q; if (inRequest.getStreamRecipientStreamScopeId() == null) { q = getEntityManager().createQuery( "FROM DailyUsageSummary WHERE usageDate = :usageDate AND streamViewStreamScopeId IS NULL"); q.setParameter("usageDate", inRequest.getMetricsDate()); } else { q = getEntityManager().createQuery( "FROM DailyUsageSummary WHERE usageDate = :usageDate " + "AND streamViewStreamScopeId = :streamViewStreamScopeId"); q.setParameter("usageDate", inRequest.getMetricsDate()); q.setParameter("streamViewStreamScopeId", inRequest.getStreamRecipientStreamScopeId()); } results = q.getResultList(); if (results.size() > 0) { return results.get(0); } return null; }  @Override DailyUsageSummary execute(final UsageMetricDailyStreamInfoRequest inRequest);  }