Example #1
0
        public virtual void testShouldAddTaskOwnerForAddandDeleteIdentityLinkByTimeStamp()
        {
            IList <HistoricIdentityLinkLog> historicIdentityLinks = historyService.createHistoricIdentityLinkLogQuery().list();

            assertEquals(historicIdentityLinks.Count, 0);

            // given
            startProcessInstance(PROCESS_DEFINITION_KEY);
            string taskId = taskService.createTaskQuery().singleResult().Id;

            // if
            ClockUtil.CurrentTime = newYearMorning(0);
            identityService.AuthenticatedUserId = A_ASSIGNER_ID;
            // Adds aUserId1, deletes aUserID1, adds aUserId2, deletes aUserId2, Adds aUserId3 - 5
            addUserIdentityLinks(taskId);

            ClockUtil.CurrentTime = newYearNoon(0);
            //Deletes aUserId3
            deleteUserIdentityLinks(taskId);

            ClockUtil.CurrentTime = newYearNoon(30);
            addUserIdentityLinks(taskId);

            ClockUtil.CurrentTime = newYearEvening();
            deleteUserIdentityLinks(taskId);

            // Query records with time before 12:20
            HistoricIdentityLinkLogQuery query = historyService.createHistoricIdentityLinkLogQuery();

            assertEquals(query.dateBefore(newYearNoon(20)).count(), 6);
            assertEquals(query.operationType(IDENTITY_LINK_ADD).count(), 3);
            assertEquals(query.operationType(IDENTITY_LINK_DELETE).count(), 3);

            // Query records with time between 00:01 and 12:00
            query = historyService.createHistoricIdentityLinkLogQuery();
            assertEquals(query.dateBefore(newYearNoon(0)).count(), 6);
            assertEquals(query.dateAfter(newYearMorning(1)).count(), 1);
            assertEquals(query.operationType(IDENTITY_LINK_ADD).count(), 0);
            assertEquals(query.operationType(IDENTITY_LINK_DELETE).count(), 1);

            // Query records with time after 12:45
            query = historyService.createHistoricIdentityLinkLogQuery();
            assertEquals(query.dateAfter(newYearNoon(45)).count(), 1);
            assertEquals(query.operationType(IDENTITY_LINK_ADD).count(), 0);
            assertEquals(query.operationType(IDENTITY_LINK_DELETE).count(), 1);

            ClockUtil.CurrentTime = DateTime.Now;
        }