/** * 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); }
/** * Make sure a pure issue key search is given when issues are found. Also, make sure there are no * "updated date" critera added to the query. * * @throws Exception indicates some unexpected failure. */ @Test public void testGetRecentCommentsIssues() throws Exception { final JqlQueryBuilder builder = JqlQueryBuilder.newBuilder(); builder.where().updatedBetween(createDate(1996, Calendar.SEPTEMBER, 11), null); final SearchRequest request = new SearchRequest(builder.buildQuery()); final List<Long> issueIds = CollectionBuilder.newBuilder(1L, 2L, 4L, 5L).asList(); _testGetRecentComments(issueIds, request, null, false, createIssueQuery(issueIds)); }
@Override public SearchRequest getSearchUrlSuffix(TimePeriod value, SearchRequest searchRequest) { TimePeriod timePeriod = value; Date startDate = timePeriod.getStart(); Date endDate = new Date(timePeriod.getEnd().getTime()); // copy the old searchrequest's query JqlQueryBuilder builder = JqlQueryBuilder.newBuilder(searchRequest.getQuery()); builder.where().defaultAnd().addDateRangeCondition(documentConstant, startDate, endDate); return new SearchRequest(builder.buildQuery(), searchRequest.getOwnerUserName(), null, null); }
/** * 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 testGetRecentCommentsIssuesUpdatedToAbsoluteDate() throws Exception { final Date beforeDate = createDate(1994, Calendar.JANUARY, 26); final JqlQueryBuilder builder = JqlQueryBuilder.newBuilder(); builder.where().updated().ltEq(beforeDate); 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); }
/** * 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 testGetRecentCommentsIssuesUpdatedFromAbsoluteDate() throws Exception { final Date afterDate = createDate(2006, Calendar.JANUARY, 26); builder = JqlQueryBuilder.newBuilder(); builder.where().updatedAfter(afterDate); final SearchRequest request = new SearchRequest(builder.buildQuery()); final List<Long> issueIds = CollectionBuilder.newBuilder(5674L).asList(); final BooleanQuery query = createIssueQuery(issueIds); final org.apache.lucene.search.Query dateQuery = createAfterQuery(afterDate); query.add(dateQuery, BooleanClause.Occur.MUST); _testGetRecentComments(issueIds, request, null, true, query); }
/** * 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); }
/** * Make sure the correct search is performed when theh search request does contain "update date", * but that criteria cannot be converted into a filter, that is, when all the "updated date" * clauses are not anded together. * * @throws Exception indicates some unexpected failure. */ @Test public void testGetRecentCommentsIssuesBad() throws Exception { final String beforeDuration = "-3d"; final Date afterDate = createDate(1981, Calendar.JANUARY, 12); final User user = new MockUser("me"); final JqlQueryBuilder builder = JqlQueryBuilder.newBuilder(); builder .where() .updatedAfter(afterDate) .and() .sub() .priority("minor") .or() .updated() .ltEq(beforeDuration) .endsub(); final SearchRequest request = new SearchRequest(builder.buildQuery()); final List<Long> issueIds = CollectionBuilder.newBuilder(6L, 3L, 13484L, 11111134L).asList(); final BooleanQuery query = createIssueQuery(issueIds); _testGetRecentComments(issueIds, request, user, true, query); }