@Test public void test() { getEntityManager().createQuery("DELETE FROM DailyUsageSummary").executeUpdate(); getEntityManager().flush(); List<DailyUsageSummary> results = sut.execute(new UsageMetricStreamSummaryRequest(3, null)); assertEquals(0, results.size()); }
@SuppressWarnings("unchecked") @Override public List<DailyUsageSummary> execute(final UsageMetricStreamSummaryRequest inRequest) { Query q; if (inRequest.getStreamRecipientStreamScopeId() == null) { q = getEntityManager().createQuery( "FROM DailyUsageSummary WHERE streamViewStreamScopeId IS NULL " + "AND usageDate >= :usageDate ORDER BY usageDate ASC"); } else { q = getEntityManager().createQuery( "FROM DailyUsageSummary WHERE streamViewStreamScopeId = :streamViewStreamScopeId " + "AND usageDate >= :usageDate ORDER BY usageDate ASC").setParameter( "streamViewStreamScopeId", inRequest.getStreamRecipientStreamScopeId()); } Calendar day = Calendar.getInstance(); day.add(Calendar.DATE, -inRequest.getNumberOfDays()); Date oldestReportDate = DateDayExtractor.getStartOfDay(new Date(day.getTimeInMillis())); q.setParameter("usageDate", oldestReportDate); return q.getResultList(); }
GetUsageMetricSummaryDbMapper extends
        BaseArgDomainMapper<UsageMetricStreamSummaryRequest, List<DailyUsageSummary>> { @SuppressWarnings("unchecked") @Override public List<DailyUsageSummary> execute(final UsageMetricStreamSummaryRequest inRequest) { Query q; if (inRequest.getStreamRecipientStreamScopeId() == null) { q = getEntityManager().createQuery( "FROM DailyUsageSummary WHERE streamViewStreamScopeId IS NULL " + "AND usageDate >= :usageDate ORDER BY usageDate ASC"); } else { q = getEntityManager().createQuery( "FROM DailyUsageSummary WHERE streamViewStreamScopeId = :streamViewStreamScopeId " + "AND usageDate >= :usageDate ORDER BY usageDate ASC").setParameter( "streamViewStreamScopeId", inRequest.getStreamRecipientStreamScopeId()); } Calendar day = Calendar.getInstance(); day.add(Calendar.DATE, -inRequest.getNumberOfDays()); Date oldestReportDate = DateDayExtractor.getStartOfDay(new Date(day.getTimeInMillis())); q.setParameter("usageDate", oldestReportDate); return q.getResultList(); } }
GetUsageMetricSummaryDbMapper extends
        BaseArgDomainMapper<UsageMetricStreamSummaryRequest, List<DailyUsageSummary>> { @SuppressWarnings("unchecked") @Override public List<DailyUsageSummary> execute(final UsageMetricStreamSummaryRequest inRequest) { Query q; if (inRequest.getStreamRecipientStreamScopeId() == null) { q = getEntityManager().createQuery( "FROM DailyUsageSummary WHERE streamViewStreamScopeId IS NULL " + "AND usageDate >= :usageDate ORDER BY usageDate ASC"); } else { q = getEntityManager().createQuery( "FROM DailyUsageSummary WHERE streamViewStreamScopeId = :streamViewStreamScopeId " + "AND usageDate >= :usageDate ORDER BY usageDate ASC").setParameter( "streamViewStreamScopeId", inRequest.getStreamRecipientStreamScopeId()); } Calendar day = Calendar.getInstance(); day.add(Calendar.DATE, -inRequest.getNumberOfDays()); Date oldestReportDate = DateDayExtractor.getStartOfDay(new Date(day.getTimeInMillis())); q.setParameter("usageDate", oldestReportDate); return q.getResultList(); }  }
GetUsageMetricSummaryDbMapper extends
        BaseArgDomainMapper<UsageMetricStreamSummaryRequest, List<DailyUsageSummary>> { @SuppressWarnings("unchecked") @Override public List<DailyUsageSummary> execute(final UsageMetricStreamSummaryRequest inRequest) { Query q; if (inRequest.getStreamRecipientStreamScopeId() == null) { q = getEntityManager().createQuery( "FROM DailyUsageSummary WHERE streamViewStreamScopeId IS NULL " + "AND usageDate >= :usageDate ORDER BY usageDate ASC"); } else { q = getEntityManager().createQuery( "FROM DailyUsageSummary WHERE streamViewStreamScopeId = :streamViewStreamScopeId " + "AND usageDate >= :usageDate ORDER BY usageDate ASC").setParameter( "streamViewStreamScopeId", inRequest.getStreamRecipientStreamScopeId()); } Calendar day = Calendar.getInstance(); day.add(Calendar.DATE, -inRequest.getNumberOfDays()); Date oldestReportDate = DateDayExtractor.getStartOfDay(new Date(day.getTimeInMillis())); q.setParameter("usageDate", oldestReportDate); return q.getResultList(); }  @SuppressWarnings("unchecked") @Override List<DailyUsageSummary> execute(final UsageMetricStreamSummaryRequest inRequest); }
GetUsageMetricSummaryDbMapper extends
        BaseArgDomainMapper<UsageMetricStreamSummaryRequest, List<DailyUsageSummary>> { @SuppressWarnings("unchecked") @Override public List<DailyUsageSummary> execute(final UsageMetricStreamSummaryRequest inRequest) { Query q; if (inRequest.getStreamRecipientStreamScopeId() == null) { q = getEntityManager().createQuery( "FROM DailyUsageSummary WHERE streamViewStreamScopeId IS NULL " + "AND usageDate >= :usageDate ORDER BY usageDate ASC"); } else { q = getEntityManager().createQuery( "FROM DailyUsageSummary WHERE streamViewStreamScopeId = :streamViewStreamScopeId " + "AND usageDate >= :usageDate ORDER BY usageDate ASC").setParameter( "streamViewStreamScopeId", inRequest.getStreamRecipientStreamScopeId()); } Calendar day = Calendar.getInstance(); day.add(Calendar.DATE, -inRequest.getNumberOfDays()); Date oldestReportDate = DateDayExtractor.getStartOfDay(new Date(day.getTimeInMillis())); q.setParameter("usageDate", oldestReportDate); return q.getResultList(); }  @SuppressWarnings("unchecked") @Override List<DailyUsageSummary> execute(final UsageMetricStreamSummaryRequest inRequest);  }