Search in sources :

Example 6 with HistoricIdentityLinkLog

use of org.camunda.bpm.engine.history.HistoricIdentityLinkLog in project camunda-bpm-platform by camunda.

the class HistoricIdentityLinkLogQueryTest method testQueryAddAndRemoveIdentityLinksForProcessDefinition.

@SuppressWarnings("deprecation")
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testQueryAddAndRemoveIdentityLinksForProcessDefinition() throws Exception {
    ProcessDefinition latestProcessDef = repositoryService.createProcessDefinitionQuery().processDefinitionKey(PROCESS_DEFINITION_KEY).singleResult();
    assertNotNull(latestProcessDef);
    List<IdentityLink> links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
    assertEquals(0, links.size());
    // Add candiate group with process definition
    repositoryService.addCandidateStarterGroup(latestProcessDef.getId(), GROUP_1);
    List<HistoricIdentityLinkLog> historicIdentityLinks = historyService.createHistoricIdentityLinkLogQuery().list();
    assertEquals(historicIdentityLinks.size(), 1);
    // Query test
    HistoricIdentityLinkLogQuery query = historyService.createHistoricIdentityLinkLogQuery();
    assertEquals(query.processDefinitionId(latestProcessDef.getId()).count(), 1);
    assertEquals(query.operationType(IDENTITY_LINK_ADD).count(), 1);
    assertEquals(query.groupId(GROUP_1).count(), 1);
    // Add candidate user for process definition
    repositoryService.addCandidateStarterUser(latestProcessDef.getId(), USER_1);
    // Query test
    query = historyService.createHistoricIdentityLinkLogQuery();
    assertEquals(query.processDefinitionId(latestProcessDef.getId()).count(), 2);
    assertEquals(query.processDefinitionKey(latestProcessDef.getKey()).count(), 2);
    assertEquals(query.operationType(IDENTITY_LINK_ADD).count(), 2);
    assertEquals(query.userId(USER_1).count(), 1);
    // Delete candiate group with process definition
    repositoryService.deleteCandidateStarterGroup(latestProcessDef.getId(), GROUP_1);
    // Query test
    query = historyService.createHistoricIdentityLinkLogQuery();
    assertEquals(query.processDefinitionId(latestProcessDef.getId()).count(), 3);
    assertEquals(query.processDefinitionKey(latestProcessDef.getKey()).count(), 3);
    assertEquals(query.groupId(GROUP_1).count(), 2);
    assertEquals(query.operationType(IDENTITY_LINK_DELETE).count(), 1);
    // Delete candidate user for process definition
    repositoryService.deleteCandidateStarterUser(latestProcessDef.getId(), USER_1);
    // Query test
    query = historyService.createHistoricIdentityLinkLogQuery();
    assertEquals(query.processDefinitionId(latestProcessDef.getId()).count(), 4);
    assertEquals(query.processDefinitionKey(latestProcessDef.getKey()).count(), 4);
    assertEquals(query.userId(USER_1).count(), 2);
    query = historyService.createHistoricIdentityLinkLogQuery();
    assertEquals(query.operationType(IDENTITY_LINK_DELETE).count(), 2);
}
Also used : HistoricIdentityLinkLog(org.camunda.bpm.engine.history.HistoricIdentityLinkLog) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) IdentityLink(org.camunda.bpm.engine.task.IdentityLink) HistoricIdentityLinkLogQuery(org.camunda.bpm.engine.history.HistoricIdentityLinkLogQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 7 with HistoricIdentityLinkLog

use of org.camunda.bpm.engine.history.HistoricIdentityLinkLog in project camunda-bpm-platform by camunda.

the class HistoricIdentityLinkLogQueryTest method testQueryAddTaskCandidateforAddIdentityLink.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testQueryAddTaskCandidateforAddIdentityLink() {
    List<HistoricIdentityLinkLog> historicIdentityLinks = historyService.createHistoricIdentityLinkLogQuery().list();
    assertEquals(historicIdentityLinks.size(), 0);
    // given
    ProcessInstance processInstance = startProcessInstance(PROCESS_DEFINITION_KEY);
    String taskId = taskService.createTaskQuery().singleResult().getId();
    // if
    identityService.setAuthenticatedUserId(A_ASSIGNER_ID);
    taskService.addCandidateUser(taskId, A_USER_ID);
    // Query test
    HistoricIdentityLinkLog historicIdentityLink = historyService.createHistoricIdentityLinkLogQuery().singleResult();
    assertEquals(historicIdentityLink.getUserId(), A_USER_ID);
    assertEquals(historicIdentityLink.getTaskId(), taskId);
    assertEquals(historicIdentityLink.getType(), IdentityLinkType.CANDIDATE);
    assertEquals(historicIdentityLink.getAssignerId(), A_ASSIGNER_ID);
    assertEquals(historicIdentityLink.getGroupId(), null);
    assertEquals(historicIdentityLink.getOperationType(), IDENTITY_LINK_ADD);
    assertEquals(historicIdentityLink.getProcessDefinitionId(), processInstance.getProcessDefinitionId());
    assertEquals(historicIdentityLink.getProcessDefinitionKey(), PROCESS_DEFINITION_KEY);
}
Also used : HistoricIdentityLinkLog(org.camunda.bpm.engine.history.HistoricIdentityLinkLog) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 8 with HistoricIdentityLinkLog

use of org.camunda.bpm.engine.history.HistoricIdentityLinkLog in project camunda-bpm-platform by camunda.

the class HistoricIdentityLinkLogQueryTest method testValidIndividualQueryTaskCandidateForAddAndDeleteIdentityLink.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testValidIndividualQueryTaskCandidateForAddAndDeleteIdentityLink() {
    List<HistoricIdentityLinkLog> historicIdentityLinks = historyService.createHistoricIdentityLinkLogQuery().list();
    assertEquals(historicIdentityLinks.size(), 0);
    // given
    ProcessInstance processInstance = startProcessInstance(PROCESS_DEFINITION_KEY);
    String taskId = taskService.createTaskQuery().singleResult().getId();
    // if
    identityService.setAuthenticatedUserId(A_ASSIGNER_ID);
    taskService.addCandidateUser(taskId, A_USER_ID);
    taskService.deleteCandidateUser(taskId, A_USER_ID);
    // Valid Individual Query test
    HistoricIdentityLinkLogQuery query = historyService.createHistoricIdentityLinkLogQuery();
    assertEquals(query.taskId(taskId).count(), 2);
    query = historyService.createHistoricIdentityLinkLogQuery();
    assertEquals(query.type(IdentityLinkType.CANDIDATE).count(), 2);
    query = historyService.createHistoricIdentityLinkLogQuery();
    assertEquals(query.userId(A_USER_ID).count(), 2);
    query = historyService.createHistoricIdentityLinkLogQuery();
    assertEquals(query.assignerId(A_ASSIGNER_ID).count(), 2);
    query = historyService.createHistoricIdentityLinkLogQuery();
    assertEquals(query.operationType(IDENTITY_LINK_DELETE).count(), 1);
    query = historyService.createHistoricIdentityLinkLogQuery();
    assertEquals(query.operationType(IDENTITY_LINK_ADD).count(), 1);
    query = historyService.createHistoricIdentityLinkLogQuery();
    assertEquals(query.processDefinitionId(processInstance.getProcessDefinitionId()).count(), 2);
    query = historyService.createHistoricIdentityLinkLogQuery();
    assertEquals(query.processDefinitionKey(PROCESS_DEFINITION_KEY).count(), 2);
}
Also used : HistoricIdentityLinkLog(org.camunda.bpm.engine.history.HistoricIdentityLinkLog) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricIdentityLinkLogQuery(org.camunda.bpm.engine.history.HistoricIdentityLinkLogQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 9 with HistoricIdentityLinkLog

use of org.camunda.bpm.engine.history.HistoricIdentityLinkLog in project camunda-bpm-platform by camunda.

the class HistoricIdentityLinkLogQueryTest method testShouldAddTaskOwnerForAddandDeleteIdentityLinkByTimeStamp.

/**
 * Should add 3 history records of identity link addition at 01-01-2016
 * 00:00.00 Should add 3 history records of identity link deletion at
 * 01-01-2016 12:00.00
 *
 * Should add 3 history records of identity link addition at 01-01-2016
 * 12:30.00 Should add 3 history records of identity link deletion at
 * 01-01-2016 21:00.00
 *
 * Test case: Query the number of added records at different time interval.
 */
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testShouldAddTaskOwnerForAddandDeleteIdentityLinkByTimeStamp() {
    List<HistoricIdentityLinkLog> historicIdentityLinks = historyService.createHistoricIdentityLinkLogQuery().list();
    assertEquals(historicIdentityLinks.size(), 0);
    // given
    startProcessInstance(PROCESS_DEFINITION_KEY);
    String taskId = taskService.createTaskQuery().singleResult().getId();
    // if
    ClockUtil.setCurrentTime(newYearMorning(0));
    identityService.setAuthenticatedUserId(A_ASSIGNER_ID);
    // Adds aUserId1, deletes aUserID1, adds aUserId2, deletes aUserId2, Adds aUserId3 - 5
    addUserIdentityLinks(taskId);
    ClockUtil.setCurrentTime(newYearNoon(0));
    // Deletes aUserId3
    deleteUserIdentityLinks(taskId);
    ClockUtil.setCurrentTime(newYearNoon(30));
    addUserIdentityLinks(taskId);
    ClockUtil.setCurrentTime(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.setCurrentTime(new Date());
}
Also used : HistoricIdentityLinkLog(org.camunda.bpm.engine.history.HistoricIdentityLinkLog) HistoricIdentityLinkLogQuery(org.camunda.bpm.engine.history.HistoricIdentityLinkLogQuery) Date(java.util.Date) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 10 with HistoricIdentityLinkLog

use of org.camunda.bpm.engine.history.HistoricIdentityLinkLog in project camunda-bpm-platform by camunda.

the class HistoricIdentityLinkLogTestByXml method testPropagateTenantIdToCandidateStarterUser.

public void testPropagateTenantIdToCandidateStarterUser() {
    // when
    org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource(CANDIDATE_STARTER_USER).tenantId(TENANT_ONE).deploy();
    // then
    List<HistoricIdentityLinkLog> historicLinks = historyService.createHistoricIdentityLinkLogQuery().list();
    assertEquals(historicLinks.size(), 1);
    HistoricIdentityLinkLog historicLink = historicLinks.get(0);
    assertNotNull(historicLink.getTenantId());
    assertEquals(TENANT_ONE, historicLink.getTenantId());
    repositoryService.deleteDeployment(deployment.getId(), true);
}
Also used : HistoricIdentityLinkLog(org.camunda.bpm.engine.history.HistoricIdentityLinkLog)

Aggregations

HistoricIdentityLinkLog (org.camunda.bpm.engine.history.HistoricIdentityLinkLog)33 HistoricIdentityLinkLogQuery (org.camunda.bpm.engine.history.HistoricIdentityLinkLogQuery)23 Deployment (org.camunda.bpm.engine.test.Deployment)23 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)5 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)5 IdentityLink (org.camunda.bpm.engine.task.IdentityLink)4 Task (org.camunda.bpm.engine.task.Task)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 LockedExternalTask (org.camunda.bpm.engine.externaltask.LockedExternalTask)1 HistoricIdentityLinkLogDto (org.camunda.bpm.engine.rest.dto.history.HistoricIdentityLinkLogDto)1 HistoricIdentityLinkLogQueryDto (org.camunda.bpm.engine.rest.dto.history.HistoricIdentityLinkLogQueryDto)1