Search in sources :

Example 66 with IdentityLink

use of org.camunda.bpm.engine.task.IdentityLink in project camunda-bpm-platform by camunda.

the class ProcessDefinitionCandidateTest method shouldPropagateTenantIdToCandidateStarterUser.

@Test
public void shouldPropagateTenantIdToCandidateStarterUser() {
    // when
    DeploymentBuilder builder = repositoryService.createDeployment().addClasspathResource(CANDIDATE_STARTER_USER).tenantId(TENANT_ONE);
    testRule.deploy(builder);
    // then
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    List<IdentityLink> links = repositoryService.getIdentityLinksForProcessDefinition(processDefinition.getId());
    assertEquals(1, links.size());
    IdentityLink link = links.get(0);
    assertNotNull(link.getTenantId());
    assertEquals(TENANT_ONE, link.getTenantId());
}
Also used : ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) IdentityLink(org.camunda.bpm.engine.task.IdentityLink) DeploymentBuilder(org.camunda.bpm.engine.repository.DeploymentBuilder) Test(org.junit.Test)

Example 67 with IdentityLink

use of org.camunda.bpm.engine.task.IdentityLink in project camunda-bpm-platform by camunda.

the class ProcessDefinitionCandidateTest method shouldPropagateTenantIdToCandidateStarterGroup.

@Test
public void shouldPropagateTenantIdToCandidateStarterGroup() {
    // when
    DeploymentBuilder builder = repositoryService.createDeployment().addClasspathResource(CANDIDATE_STARTER_GROUP).tenantId(TENANT_ONE);
    testRule.deploy(builder);
    // then
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    List<IdentityLink> links = repositoryService.getIdentityLinksForProcessDefinition(processDefinition.getId());
    assertEquals(1, links.size());
    IdentityLink link = links.get(0);
    assertNotNull(link.getTenantId());
    assertEquals(TENANT_ONE, link.getTenantId());
}
Also used : ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) IdentityLink(org.camunda.bpm.engine.task.IdentityLink) DeploymentBuilder(org.camunda.bpm.engine.repository.DeploymentBuilder) Test(org.junit.Test)

Example 68 with IdentityLink

use of org.camunda.bpm.engine.task.IdentityLink in project camunda-bpm-platform by camunda.

the class MultiTenancyHistoricIdentityLinkLogQueryTest method identityLinksForProcessDefinitionWithTenantId.

@SuppressWarnings("deprecation")
@Test
public void identityLinksForProcessDefinitionWithTenantId() throws Exception {
    String resourceName = "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml";
    testRule.deployForTenant(TENANT_1, resourceName);
    testRule.deployForTenant(TENANT_2, resourceName);
    ProcessDefinition processDefinition1 = repositoryService.createProcessDefinitionQuery().processDefinitionKey(PROCESS_DEFINITION_KEY).list().get(0);
    assertNotNull(processDefinition1);
    // Add candidate group with process definition 1
    repositoryService.addCandidateStarterGroup(processDefinition1.getId(), GROUP_1);
    // Add candidate user for process definition 2
    repositoryService.addCandidateStarterUser(processDefinition1.getId(), USER_1);
    ProcessDefinition processDefinition2 = repositoryService.createProcessDefinitionQuery().processDefinitionKey(PROCESS_DEFINITION_KEY).list().get(1);
    assertNotNull(processDefinition2);
    // Add candidate group with process definition 2
    repositoryService.addCandidateStarterGroup(processDefinition2.getId(), GROUP_1);
    // Add candidate user for process definition 2
    repositoryService.addCandidateStarterUser(processDefinition2.getId(), USER_1);
    // Identity link test
    List<IdentityLink> identityLinks = repositoryService.getIdentityLinksForProcessDefinition(processDefinition1.getId());
    assertEquals(identityLinks.size(), 2);
    assertEquals(identityLinks.get(0).getTenantId(), TENANT_1);
    assertEquals(identityLinks.get(1).getTenantId(), TENANT_1);
    identityLinks = repositoryService.getIdentityLinksForProcessDefinition(processDefinition2.getId());
    assertEquals(identityLinks.size(), 2);
    assertEquals(identityLinks.get(0).getTenantId(), TENANT_2);
    assertEquals(identityLinks.get(1).getTenantId(), TENANT_2);
}
Also used : ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) IdentityLink(org.camunda.bpm.engine.task.IdentityLink) Test(org.junit.Test)

Example 69 with IdentityLink

use of org.camunda.bpm.engine.task.IdentityLink in project camunda-bpm-platform by camunda.

the class InvoiceTestCase method testHappyPathV2.

@Deployment(resources = { "invoice.v2.bpmn", "invoiceBusinessDecisions.dmn" })
public void testHappyPathV2() {
    InputStream invoiceInputStream = InvoiceProcessApplication.class.getClassLoader().getResourceAsStream("invoice.pdf");
    VariableMap variables = Variables.createVariables().putValue("creditor", "Great Pizza for Everyone Inc.").putValue("amount", 300.0d).putValue("invoiceCategory", "Travel Expenses").putValue("invoiceNumber", "GPFE-23232323").putValue("invoiceDocument", fileValue("invoice.pdf").file(invoiceInputStream).mimeType("application/pdf").create());
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("invoice", variables);
    Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
    assertEquals("approveInvoice", task.getTaskDefinitionKey());
    List<IdentityLink> links = taskService.getIdentityLinksForTask(task.getId());
    Set<String> approverGroups = new HashSet<String>();
    for (IdentityLink link : links) {
        approverGroups.add(link.getGroupId());
    }
    assertEquals(2, approverGroups.size());
    assertTrue(approverGroups.contains("accounting"));
    assertTrue(approverGroups.contains("sales"));
    variables.clear();
    variables.put("approved", Boolean.TRUE);
    taskService.complete(task.getId(), variables);
    task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
    assertEquals("prepareBankTransfer", task.getTaskDefinitionKey());
    taskService.complete(task.getId());
    Job archiveInvoiceJob = managementService.createJobQuery().singleResult();
    assertNotNull(archiveInvoiceJob);
    managementService.executeJob(archiveInvoiceJob.getId());
    assertProcessEnded(pi.getId());
}
Also used : Task(org.camunda.bpm.engine.task.Task) VariableMap(org.camunda.bpm.engine.variable.VariableMap) InputStream(java.io.InputStream) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Job(org.camunda.bpm.engine.runtime.Job) IdentityLink(org.camunda.bpm.engine.task.IdentityLink) HashSet(java.util.HashSet) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 70 with IdentityLink

use of org.camunda.bpm.engine.task.IdentityLink in project camunda-bpm-platform by camunda.

the class InvoiceTestCase method testHappyPathV1.

@Deployment(resources = { "invoice.v1.bpmn", "invoiceBusinessDecisions.dmn" })
public void testHappyPathV1() {
    InputStream invoiceInputStream = InvoiceProcessApplication.class.getClassLoader().getResourceAsStream("invoice.pdf");
    VariableMap variables = Variables.createVariables().putValue("creditor", "Great Pizza for Everyone Inc.").putValue("amount", 300.0d).putValue("invoiceCategory", "Travel Expenses").putValue("invoiceNumber", "GPFE-23232323").putValue("invoiceDocument", fileValue("invoice.pdf").file(invoiceInputStream).mimeType("application/pdf").create());
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("invoice", variables);
    Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
    assertEquals("approveInvoice", task.getTaskDefinitionKey());
    List<IdentityLink> links = taskService.getIdentityLinksForTask(task.getId());
    Set<String> approverGroups = new HashSet<String>();
    for (IdentityLink link : links) {
        approverGroups.add(link.getGroupId());
    }
    assertEquals(2, approverGroups.size());
    assertTrue(approverGroups.contains("accounting"));
    assertTrue(approverGroups.contains("sales"));
    variables.clear();
    variables.put("approved", Boolean.TRUE);
    taskService.complete(task.getId(), variables);
    task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
    assertEquals("prepareBankTransfer", task.getTaskDefinitionKey());
    taskService.complete(task.getId());
    Job archiveInvoiceJob = managementService.createJobQuery().singleResult();
    assertNotNull(archiveInvoiceJob);
    managementService.executeJob(archiveInvoiceJob.getId());
    assertProcessEnded(pi.getId());
}
Also used : Task(org.camunda.bpm.engine.task.Task) VariableMap(org.camunda.bpm.engine.variable.VariableMap) InputStream(java.io.InputStream) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Job(org.camunda.bpm.engine.runtime.Job) IdentityLink(org.camunda.bpm.engine.task.IdentityLink) HashSet(java.util.HashSet) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

IdentityLink (org.camunda.bpm.engine.task.IdentityLink)81 Task (org.camunda.bpm.engine.task.Task)13 Deployment (org.camunda.bpm.engine.test.Deployment)13 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)12 Test (org.junit.Test)12 ArrayList (java.util.ArrayList)7 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)5 InputStream (java.io.InputStream)4 HashSet (java.util.HashSet)4 Expression (org.camunda.bpm.engine.delegate.Expression)4 HistoricIdentityLinkLog (org.camunda.bpm.engine.history.HistoricIdentityLinkLog)4 DeploymentBuilder (org.camunda.bpm.engine.repository.DeploymentBuilder)4 VariableMap (org.camunda.bpm.engine.variable.VariableMap)4 TaskService (org.camunda.bpm.engine.TaskService)3 HistoricIdentityLinkLogQuery (org.camunda.bpm.engine.history.HistoricIdentityLinkLogQuery)3 List (java.util.List)2 HalResource (org.camunda.bpm.engine.rest.hal.HalResource)2 Job (org.camunda.bpm.engine.runtime.Job)2 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)2 Matchers.anyString (org.mockito.Matchers.anyString)2