/** * Make sure the correct search is performed when theh search request does contain "update date" * critera and we have determined that they be included in the comment search. * * @throws Exception indicates some unexpected failure. */ @Test public void testGetRecentCommentsIssuesUpdatedFromToDate() throws Exception { final String beforeDuration = "-3d"; final Date beforeDate = dateSupport.convertToDate(beforeDuration); final Date afterDate = createDate(1981, Calendar.JANUARY, 12); final User user = new MockUser("me"); final JqlQueryBuilder builder = JqlQueryBuilder.newBuilder(); builder .where() .updated() .ltEq(beforeDuration) .and() .updatedAfter(afterDate) .and() .priority("major"); final SearchRequest request = new SearchRequest(builder.buildQuery()); final List<Long> issueIds = CollectionBuilder.newBuilder(6L, 3L, 13484L, 11111134L).asList(); final BooleanQuery query = createIssueQuery(issueIds); final BooleanQuery dateQuery = new BooleanQuery(); dateQuery.add(createBeforeQuery(beforeDate), BooleanClause.Occur.MUST); dateQuery.add(createAfterQuery(afterDate), BooleanClause.Occur.MUST); query.add(dateQuery, BooleanClause.Occur.MUST); _testGetRecentComments(issueIds, request, user, true, query); }
private TermRangeQuery createBeforeQuery(final Date beforeDate) { return new TermRangeQuery( DocumentConstants.COMMENT_UPDATED, null, dateSupport.getIndexedValue(beforeDate), true, true); }
private TermRangeQuery createAfterQuery(final Date afterDate) { return new TermRangeQuery( DocumentConstants.COMMENT_UPDATED, dateSupport.getIndexedValue(afterDate), null, true, true); }
/** * Make sure the correct search is performed when theh search request does contain "update date" * critera and we have determined that they be included in the comment search. * * @throws Exception indicates some unexpected failure. */ @Test public void testGetRecentCommentsIssuesUpdatedToRelativeDate() throws Exception { final String beforeDuration = "-3d"; final Date beforeDate = dateSupport.convertToDate(beforeDuration); final JqlQueryBuilder builder = JqlQueryBuilder.newBuilder(); builder.where().updated().ltEq(beforeDuration); final SearchRequest request = new SearchRequest(builder.buildQuery()); final List<Long> issueIds = CollectionBuilder.newBuilder(5674L).asList(); final BooleanQuery query = createIssueQuery(issueIds); final TermRangeQuery dateQuery = createBeforeQuery(beforeDate); query.add(dateQuery, BooleanClause.Occur.MUST); _testGetRecentComments(issueIds, request, null, true, query); }