Exemplo n.º 1
0
        public virtual void testQueryOverrideExpression()
        {
            string queryString          = "query";
            string expressionString     = "expression";
            string testStringExpression = "${'" + expressionString + "'}";

            DateTime queryDate          = (new DateTime(now())).minusYears(1).toDate();
            string   testDateExpression = "${now()}";

            TaskQueryImpl taskQuery = (TaskQueryImpl)taskQuery().taskAssigneeExpression(testStringExpression).taskAssignee(queryString).taskAssigneeLikeExpression(testStringExpression).taskAssigneeLike(queryString).taskOwnerExpression(expressionString).taskOwner(queryString).taskInvolvedUserExpression(expressionString).taskInvolvedUser(queryString).taskCreatedBeforeExpression(testDateExpression).taskCreatedBefore(queryDate).taskCreatedOnExpression(testDateExpression).taskCreatedOn(queryDate).taskCreatedAfterExpression(testDateExpression).taskCreatedAfter(queryDate).dueBeforeExpression(testDateExpression).dueBefore(queryDate).dueDateExpression(testDateExpression).dueDate(queryDate).dueAfterExpression(testDateExpression).dueAfter(queryDate).followUpBeforeExpression(testDateExpression).followUpBefore(queryDate).followUpDateExpression(testDateExpression).followUpDate(queryDate).followUpAfterExpression(testDateExpression).followUpAfter(queryDate);

            // execute query so expression will be evaluated
            taskQuery.count();

            assertEquals(queryString, taskQuery.Assignee);
            assertEquals(queryString, taskQuery.AssigneeLike);
            assertEquals(queryString, taskQuery.Owner);
            assertEquals(queryString, taskQuery.InvolvedUser);
            assertTrue(taskQuery.CreateTimeBefore.Equals(queryDate));
            assertTrue(taskQuery.CreateTime.Equals(queryDate));
            assertTrue(taskQuery.CreateTimeAfter.Equals(queryDate));
            assertTrue(taskQuery.DueBefore.Equals(queryDate));
            assertTrue(taskQuery.DueDate.Equals(queryDate));
            assertTrue(taskQuery.DueAfter.Equals(queryDate));
            assertTrue(taskQuery.FollowUpBefore.Equals(queryDate));
            assertTrue(taskQuery.FollowUpDate.Equals(queryDate));
            assertTrue(taskQuery.FollowUpAfter.Equals(queryDate));

            // candidates has to be tested separately cause they have to be set exclusively

            taskQuery = (TaskQueryImpl)taskQuery().taskCandidateGroupExpression(testStringExpression).taskCandidateGroup(queryString);

            // execute query so expression will be evaluated
            taskQuery.count();

            assertEquals(queryString, taskQuery.CandidateGroup);

            taskQuery = (TaskQueryImpl)taskQuery().taskCandidateUserExpression(testStringExpression).taskCandidateUser(queryString);

            // execute query so expression will be evaluated
            taskQuery.count();

            assertEquals(queryString, taskQuery.CandidateUser);

            CurrentUser = user;
            IList <string> queryList            = Arrays.asList("query");
            string         testGroupsExpression = "${currentUserGroups()}";

            taskQuery = (TaskQueryImpl)taskQuery().taskCandidateGroupInExpression(testGroupsExpression).taskCandidateGroupIn(queryList);

            // execute query so expression will be evaluated
            taskQuery.count();

            assertEquals(1, taskQuery.CandidateGroups.Count);
        }