@Test public void testExecuteAll() { Date yesterday = new GetDateFromDaysAgoStrategy().execute(1); getEntityManager().persist(new UsageMetric(1L, true, true, 1L, yesterday)); getEntityManager().persist(new UsageMetric(3L, true, false, null, yesterday)); getEntityManager().persist(new UsageMetric(3L, true, true, 2L, yesterday)); getEntityManager().persist(new UsageMetric(4L, true, true, 4L, yesterday)); getEntityManager().persist(new UsageMetric(5L, true, true, 5L, yesterday)); List<Long> ids = sut.execute(yesterday); Assert.assertEquals(4, ids.size()); Assert.assertTrue(ids.contains(1L)); Assert.assertTrue(ids.contains(2L)); Assert.assertTrue(ids.contains(4L)); Assert.assertTrue(ids.contains(5L)); }
@SuppressWarnings("unchecked") @Override public List<Long> execute(final Date inMetricsDate) { Date startOfDay = DateDayExtractor.getStartOfDay(inMetricsDate); Date endOfDay = DateDayExtractor.getEndOfDay(inMetricsDate); return getEntityManager().createQuery( "SELECT DISTINCT(streamViewStreamScopeId) FROM UsageMetric " + "WHERE streamViewStreamScopeId != NULL AND created >= :start AND created <= :end") .setParameter("start", startOfDay).setParameter("end", endOfDay).getResultList(); }
GetMetricStreamScopeIdsDbMapper extends BaseArgDomainMapper<Date, List<Long>> { @SuppressWarnings("unchecked") @Override public List<Long> execute(final Date inMetricsDate) { Date startOfDay = DateDayExtractor.getStartOfDay(inMetricsDate); Date endOfDay = DateDayExtractor.getEndOfDay(inMetricsDate); return getEntityManager().createQuery( "SELECT DISTINCT(streamViewStreamScopeId) FROM UsageMetric " + "WHERE streamViewStreamScopeId != NULL AND created >= :start AND created <= :end") .setParameter("start", startOfDay).setParameter("end", endOfDay).getResultList(); } }
GetMetricStreamScopeIdsDbMapper extends BaseArgDomainMapper<Date, List<Long>> { @SuppressWarnings("unchecked") @Override public List<Long> execute(final Date inMetricsDate) { Date startOfDay = DateDayExtractor.getStartOfDay(inMetricsDate); Date endOfDay = DateDayExtractor.getEndOfDay(inMetricsDate); return getEntityManager().createQuery( "SELECT DISTINCT(streamViewStreamScopeId) FROM UsageMetric " + "WHERE streamViewStreamScopeId != NULL AND created >= :start AND created <= :end") .setParameter("start", startOfDay).setParameter("end", endOfDay).getResultList(); }  }
GetMetricStreamScopeIdsDbMapper extends BaseArgDomainMapper<Date, List<Long>> { @SuppressWarnings("unchecked") @Override public List<Long> execute(final Date inMetricsDate) { Date startOfDay = DateDayExtractor.getStartOfDay(inMetricsDate); Date endOfDay = DateDayExtractor.getEndOfDay(inMetricsDate); return getEntityManager().createQuery( "SELECT DISTINCT(streamViewStreamScopeId) FROM UsageMetric " + "WHERE streamViewStreamScopeId != NULL AND created >= :start AND created <= :end") .setParameter("start", startOfDay).setParameter("end", endOfDay).getResultList(); }  @SuppressWarnings("unchecked") @Override List<Long> execute(final Date inMetricsDate); }
GetMetricStreamScopeIdsDbMapper extends BaseArgDomainMapper<Date, List<Long>> { @SuppressWarnings("unchecked") @Override public List<Long> execute(final Date inMetricsDate) { Date startOfDay = DateDayExtractor.getStartOfDay(inMetricsDate); Date endOfDay = DateDayExtractor.getEndOfDay(inMetricsDate); return getEntityManager().createQuery( "SELECT DISTINCT(streamViewStreamScopeId) FROM UsageMetric " + "WHERE streamViewStreamScopeId != NULL AND created >= :start AND created <= :end") .setParameter("start", startOfDay).setParameter("end", endOfDay).getResultList(); }  @SuppressWarnings("unchecked") @Override List<Long> execute(final Date inMetricsDate);  }