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);
}
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);
}
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);
}
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());
}
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);
}
Aggregations