use of org.camunda.bpm.engine.task.IdentityLink 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.task.IdentityLink in project camunda-bpm-platform by camunda.
the class HistoricIdentityLinkLogTestByXml method testShouldAddProcessCandidateStarterUserforAddIdentityLinkUsingXml.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/OneTaskProcessWithCandidateStarterUsers.bpmn20.xml" })
public void testShouldAddProcessCandidateStarterUserforAddIdentityLinkUsingXml() {
// Pre test - Historical identity link is added as part of deployment
List<HistoricIdentityLinkLog> historicIdentityLinks = historyService.createHistoricIdentityLinkLogQuery().list();
assertEquals(historicIdentityLinks.size(), 1);
// given
ProcessDefinition latestProcessDef = repositoryService.createProcessDefinitionQuery().processDefinitionKey(PROCESS_DEFINITION_KEY_CANDIDATE_STARTER_USER).singleResult();
assertNotNull(latestProcessDef);
List<IdentityLink> links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
assertEquals(1, links.size());
historicIdentityLinks = historyService.createHistoricIdentityLinkLogQuery().list();
assertEquals(historicIdentityLinks.size(), 1);
// query Test
HistoricIdentityLinkLogQuery query = historyService.createHistoricIdentityLinkLogQuery();
assertEquals(query.userId(XML_USER).count(), 1);
}
use of org.camunda.bpm.engine.task.IdentityLink in project camunda-bpm-platform by camunda.
the class MockProvider method createMockUserOwnerIdentityLink.
public static IdentityLink createMockUserOwnerIdentityLink() {
IdentityLink identityLink = mock(IdentityLink.class);
when(identityLink.getTaskId()).thenReturn(EXAMPLE_TASK_ID);
when(identityLink.getType()).thenReturn(IdentityLinkType.OWNER);
when(identityLink.getUserId()).thenReturn(EXAMPLE_TASK_OWNER);
return identityLink;
}
use of org.camunda.bpm.engine.task.IdentityLink in project camunda-bpm-platform by camunda.
the class MockProvider method createMockCandidateGroupIdentityLink.
public static IdentityLink createMockCandidateGroupIdentityLink() {
IdentityLink identityLink = mock(IdentityLink.class);
when(identityLink.getTaskId()).thenReturn(EXAMPLE_TASK_ID);
when(identityLink.getType()).thenReturn(IdentityLinkType.CANDIDATE);
when(identityLink.getGroupId()).thenReturn(EXAMPLE_GROUP_ID);
return identityLink;
}
use of org.camunda.bpm.engine.task.IdentityLink in project camunda-bpm-platform by camunda.
the class MockProvider method createMockUserAssigneeIdentityLink.
public static IdentityLink createMockUserAssigneeIdentityLink() {
IdentityLink identityLink = mock(IdentityLink.class);
when(identityLink.getTaskId()).thenReturn(EXAMPLE_TASK_ID);
when(identityLink.getType()).thenReturn(IdentityLinkType.ASSIGNEE);
when(identityLink.getUserId()).thenReturn(EXAMPLE_TASK_ASSIGNEE_NAME);
return identityLink;
}
Aggregations