CaseServiceImpl implements CaseService { @Override public CaseFileInstance newCaseFileInstance(String deploymentId, String caseDefinition, Map<String, Object> data) { CaseDefinition def = caseRuntimeDataService.getCase(deploymentId, caseDefinition); if (def == null) { throw new CaseDefinitionNotFoundException("Case definition " + caseDefinition + " does not exist in deployment " + deploymentId); } CaseFileInstanceImpl caseFile = new CaseFileInstanceImpl(caseDefinition, data); caseFile.setupRoles(def.getCaseRoles()); caseFile.setAccessRestrictions(def.getDataAccessRestrictions()); return caseFile; } CaseServiceImpl(); void setProcessService(ProcessService processService); void setRuntimeDataService(RuntimeDataService runtimeDataService); void setDeploymentService(DeploymentService deploymentService); void setCaseRuntimeDataService(CaseRuntimeDataService caseRuntimeDataService); void setCaseIdGenerator(CaseIdGenerator caseIdGenerator); void setCommandService(TransactionalCommandService commandService); void setAuthorizationManager(AuthorizationManager authorizationManager); void setIdentityProvider(IdentityProvider identityProvider); @Override String startCase(String deploymentId, String caseDefinitionId); @Override String startCase(String deploymentId, String caseDefinitionId, CaseFileInstance caseFile); @Override CaseFileInstance getCaseFileInstance(String caseId); @Override CaseInstance getCaseInstance(String caseId); @Override CaseInstance getCaseInstance(String caseId, boolean withData, boolean withRoles, boolean withMilestones, boolean withStages); @Override void closeCase(String caseId, String comment); @Override void cancelCase(String caseId); @Override void destroyCase(String caseId); @Override void reopenCase(String caseId, String deploymentId, String caseDefinitionId); @Override void reopenCase(String caseId, String deploymentId, String caseDefinitionId, Map<String, Object> data); @Override void addDynamicTask(String caseId, TaskSpecification taskSpecification); @Override void addDynamicTask(Long processInstanceId, TaskSpecification taskSpecification); @Override void addDynamicTaskToStage(String caseId, String stage, TaskSpecification taskSpecification); @Override void addDynamicTaskToStage(Long processInstanceId, String stage, TaskSpecification taskSpecification); @Override Long addDynamicSubprocess(String caseId, String processId, Map<String, Object> parameters); @Override Long addDynamicSubprocess(Long processInstanceId, String processId, Map<String, Object> parameters); @Override Long addDynamicSubprocessToStage(String caseId, String stage, String processId, Map<String, Object> parameters); @Override Long addDynamicSubprocessToStage(Long processInstanceId, String stage, String processId, Map<String, Object> parameters); @Override void triggerAdHocFragment(String caseId, String fragmentName, Object data); @Override void triggerAdHocFragment(Long processInstanceId, String fragmentName, Object data); @Override void triggerAdHocFragment(String caseId, String stage, String fragmentName, Object data); @Override void triggerAdHocFragment(Long processInstanceId, String stage, String fragmentName, Object data); @Override void addDataToCaseFile(String caseId, String name, Object value, String... restrictedTo); @Override void addDataToCaseFile(String caseId, Map<String, Object> data, String... restrictedTo); @Override void removeDataFromCaseFile(String caseId, String name); @Override void removeDataFromCaseFile(String caseId, List<String> variableNames); @Override void assignToCaseRole(String caseId, String role, OrganizationalEntity entity); @Override void removeFromCaseRole(String caseId, String role, OrganizationalEntity entity); @Override Collection<CaseRoleInstance> getCaseRoleAssignments(String caseId); @Override Collection<CommentInstance> getCaseComments(String caseId, QueryContext queryContext); @Override Collection<CommentInstance> getCaseComments(String caseId, CommentSortBy sortBy, QueryContext queryContext); @Override String addCaseComment(String caseId, String author, String comment, String... restrictedTo); @Override void updateCaseComment(String caseId, String commentId, String author, String text, String... restrictedTo); @Override void removeCaseComment(String caseId, String commentId); @Override CaseFileInstance newCaseFileInstance(String deploymentId, String caseDefinition, Map<String, Object> data); @Override CaseFileInstance newCaseFileInstanceWithRestrictions(String deploymentId, String caseDefinition, Map<String, Object> data, Map<String, List<String>> accessRestrictions); @Override CaseFileInstance newCaseFileInstance(String deploymentId, String caseDefinition, Map<String, Object> data, Map<String, OrganizationalEntity> rolesAssignment); @Override CaseFileInstance newCaseFileInstanceWithRestrictions(String deploymentId, String caseDefinition, Map<String, Object> data, Map<String, OrganizationalEntity> rolesAssignment, Map<String, List<String>> accessRestrictions); @Override TaskSpecification newHumanTaskSpec(String taskName, String description, String actorIds, String groupIds, Map<String, Object> parameters); @Override TaskSpecification newTaskSpec(String nodeType, String nodeName, Map<String, Object> parameters); @Override User newUser(String userId); @Override Group newGroup(String groupId);  }
@Test public void testCreateCaseFileInstanceForNotExistingCase() { assertThatExceptionOfType(CaseDefinitionNotFoundException.class) .isThrownBy(() -> caseService.newCaseFileInstance(deploymentUnit.getIdentifier(), "nonexisting", Collections.emptyMap())); assertThatExceptionOfType(CaseDefinitionNotFoundException.class) .isThrownBy(() -> caseService.newCaseFileInstance(deploymentUnit.getIdentifier(), "nonexisting", Collections.emptyMap(), Collections.emptyMap())); }