@Test public void testGetUrlListAll() throws Exception { List<String> urls = dao.getUrlList(Optional.empty()); assertThat(urls).hasSize(2); }
@SuppressWarnings("unchecked") public List<String> getUrlList(Optional<DateRange> dateParam) { StringBuilder queryBuilder = new StringBuilder(); queryBuilder.append("SELECT DISTINCT url FROM Document"); if (dateParam.isPresent()) { queryBuilder.append(" where lastChanged between :fromDate and :toDate"); } Query query = getEntityManager().createQuery(queryBuilder.toString()); if (dateParam.isPresent()) { query.setParameter("fromDate", dateParam.get().getFromDate()); query.setParameter("toDate", dateParam.get().getToDate()); } return query.getResultList(); }
DocumentDAO extends AbstractDAO<Document> { @SuppressWarnings("unchecked") public List<String> getUrlList(Optional<DateRange> dateParam) { StringBuilder queryBuilder = new StringBuilder(); queryBuilder.append("SELECT DISTINCT url FROM Document"); if (dateParam.isPresent()) { queryBuilder.append(" where lastChanged between :fromDate and :toDate"); } Query query = getEntityManager().createQuery(queryBuilder.toString()); if (dateParam.isPresent()) { query.setParameter("fromDate", dateParam.get().getFromDate()); query.setParameter("toDate", dateParam.get().getToDate()); } return query.getResultList(); } }
DocumentDAO extends AbstractDAO<Document> { @SuppressWarnings("unchecked") public List<String> getUrlList(Optional<DateRange> dateParam) { StringBuilder queryBuilder = new StringBuilder(); queryBuilder.append("SELECT DISTINCT url FROM Document"); if (dateParam.isPresent()) { queryBuilder.append(" where lastChanged between :fromDate and :toDate"); } Query query = getEntityManager().createQuery(queryBuilder.toString()); if (dateParam.isPresent()) { query.setParameter("fromDate", dateParam.get().getFromDate()); query.setParameter("toDate", dateParam.get().getToDate()); } return query.getResultList(); } @SuppressWarnings("unused")  DocumentDAO(); @VisibleForTesting  DocumentDAO(EntityManager entityManager); }
DocumentDAO extends AbstractDAO<Document> { @SuppressWarnings("unchecked") public List<String> getUrlList(Optional<DateRange> dateParam) { StringBuilder queryBuilder = new StringBuilder(); queryBuilder.append("SELECT DISTINCT url FROM Document"); if (dateParam.isPresent()) { queryBuilder.append(" where lastChanged between :fromDate and :toDate"); } Query query = getEntityManager().createQuery(queryBuilder.toString()); if (dateParam.isPresent()) { query.setParameter("fromDate", dateParam.get().getFromDate()); query.setParameter("toDate", dateParam.get().getToDate()); } return query.getResultList(); } @SuppressWarnings("unused")  DocumentDAO(); @VisibleForTesting  DocumentDAO(EntityManager entityManager); Document reload(Document entity); @SuppressWarnings("unchecked") List<Document> getByUrl(@NotNull String url,
            Optional<LocaleCode> fromLocaleCode, Optional<LocaleCode> toLocaleCode,
            Optional<DateRange> dateParam); Document getByUrl(@NotNull String url, @NotNull Locale fromLocale,
            @NotNull Locale toLocale); @SuppressWarnings("unchecked") List<String> getUrlList(Optional<DateRange> dateParam); }
DocumentDAO extends AbstractDAO<Document> { @SuppressWarnings("unchecked") public List<String> getUrlList(Optional<DateRange> dateParam) { StringBuilder queryBuilder = new StringBuilder(); queryBuilder.append("SELECT DISTINCT url FROM Document"); if (dateParam.isPresent()) { queryBuilder.append(" where lastChanged between :fromDate and :toDate"); } Query query = getEntityManager().createQuery(queryBuilder.toString()); if (dateParam.isPresent()) { query.setParameter("fromDate", dateParam.get().getFromDate()); query.setParameter("toDate", dateParam.get().getToDate()); } return query.getResultList(); } @SuppressWarnings("unused")  DocumentDAO(); @VisibleForTesting  DocumentDAO(EntityManager entityManager); Document reload(Document entity); @SuppressWarnings("unchecked") List<Document> getByUrl(@NotNull String url,
            Optional<LocaleCode> fromLocaleCode, Optional<LocaleCode> toLocaleCode,
            Optional<DateRange> dateParam); Document getByUrl(@NotNull String url, @NotNull Locale fromLocale,
            @NotNull Locale toLocale); @SuppressWarnings("unchecked") List<String> getUrlList(Optional<DateRange> dateParam);  }