Source:
<code>public void testStartCaseWithSLASubprocess() { Map<String, OrganizationalEntity> roleAssignments = new HashMap<>(); roleAssignments.put("owner", new UserImpl("john")); roleAssignments.put("admin", new UserImpl("mary")); Map<String, Object> data = new HashMap<>(); data.put("s", "Case with SLA"); CaseFileInstance caseFile = caseService.newCaseFileInstance(deploymentUnit.getIdentifier(), USER_TASK_SLA_CASE_P_ID, data, roleAssignments); String caseId = caseService.startCase(deploymentUnit.getIdentifier(), USER_TASK_SLA_CASE_P_ID, caseFile); assertNotNull(caseId); assertEquals(HR_CASE_ID, caseId); try { CaseInstance cInstance = caseService.getCaseInstance(caseId); assertNotNull(cInstance); assertEquals(deploymentUnit.getIdentifier(), cInstance.getDeploymentId()); assertEquals(ProcessInstance.SLA_PENDING, cInstance.getSlaCompliance().intValue()); Collection<ProcessInstanceDesc> caseProcessInstances = caseRuntimeDataService.getProcessInstancesForCase(caseId, new QueryContext()); assertNotNull(caseProcessInstances); assertEquals(1, caseProcessInstances.size()); CountDownListenerFactory.getExisting("slaCompliance").waitTillCompleted(); cInstance = caseService.getCaseInstance(caseId); assertNotNull(cInstance); assertEquals(deploymentUnit.getIdentifier(), cInstance.getDeploymentId()); assertEquals(ProcessInstance.SLA_VIOLATED, cInstance.getSlaCompliance().intValue()); caseProcessInstances = caseRuntimeDataService.getProcessInstancesForCase(caseId, new QueryContext()); assertNotNull(caseProcessInstances); <START> assertEquals(2, caseProcessInstances.size()); <END> caseService.cancelCase(caseId); CaseInstance instance = caseService.getCaseInstance(caseId); Assertions.assertThat(instance.getStatus()).isEqualTo(CaseStatus.CANCELLED.getId()); caseId = null; } catch (Exception e) { logger.error("Unexpected error {}", e.getMessage(), e); fail("Unexpected exception " + e.getMessage()); } finally { if (caseId != null) { caseService.cancelCase(caseId); } } }</code><technical_language>I check is a process instance processId wanted start</technical_language>

Target:
public void testStartCaseWithSLASubprocess() { Map<String, OrganizationalEntity> roleAssignments = new HashMap<>(); roleAssignments.put("owner", new UserImpl("john")); roleAssignments.put("admin", new UserImpl("mary")); Map<String, Object> data = new HashMap<>(); data.put("s", "Case with SLA"); CaseFileInstance caseFile = caseService.newCaseFileInstance(deploymentUnit.getIdentifier(), USER_TASK_SLA_CASE_P_ID, data, roleAssignments); String caseId = caseService.startCase(deploymentUnit.getIdentifier(), USER_TASK_SLA_CASE_P_ID, caseFile); assertNotNull(caseId); assertEquals(HR_CASE_ID, caseId); try { CaseInstance cInstance = caseService.getCaseInstance(caseId); assertNotNull(cInstance); assertEquals(deploymentUnit.getIdentifier(), cInstance.getDeploymentId()); assertEquals(ProcessInstance.SLA_PENDING, cInstance.getSlaCompliance().intValue()); Collection<ProcessInstanceDesc> caseProcessInstances = caseRuntimeDataService.getProcessInstancesForCase(caseId, new QueryContext()); assertNotNull(caseProcessInstances); assertEquals(1, caseProcessInstances.size()); CountDownListenerFactory.getExisting("slaCompliance").waitTillCompleted(); cInstance = caseService.getCaseInstance(caseId); assertNotNull(cInstance); assertEquals(deploymentUnit.getIdentifier(), cInstance.getDeploymentId()); assertEquals(ProcessInstance.SLA_VIOLATED, cInstance.getSlaCompliance().intValue()); caseProcessInstances = caseRuntimeDataService.getProcessInstancesForCase(caseId, new QueryContext()); assertNotNull(caseProcessInstances); assertEquals(2, caseProcessInstances.size()); for (ProcessInstanceDesc pi : caseProcessInstances) { assertThat(pi.getCorrelationKey()).startsWith(HR_CASE_ID); } caseService.cancelCase(caseId); CaseInstance instance = caseService.getCaseInstance(caseId); Assertions.assertThat(instance.getStatus()).isEqualTo(CaseStatus.CANCELLED.getId()); caseId = null; } catch (Exception e) { logger.error("Unexpected error {}", e.getMessage(), e); fail("Unexpected exception " + e.getMessage()); } finally { if (caseId != null) { caseService.cancelCase(caseId); } } }