@Deployment(resources = {"org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn"}) public void testQueryByCaseDefinitionName() { // given CaseDefinition caseDefinition = repositoryService.createCaseDefinitionQuery().singleResult(); String caseDefinitionName = caseDefinition.getName(); String caseDefinitionId = caseDefinition.getId(); String caseInstanceId = caseService.withCaseDefinitionByKey("oneTaskCase").create().getId(); String humanTaskId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId(); // then HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery(); query.caseDefinitionName(caseDefinitionName); assertEquals(1, query.count()); assertEquals(1, query.list().size()); assertNotNull(query.singleResult()); HistoricTaskInstance task = query.singleResult(); assertNotNull(task); assertEquals(caseDefinitionId, task.getCaseDefinitionId()); assertEquals(caseInstanceId, task.getCaseInstanceId()); assertEquals(humanTaskId, task.getCaseExecutionId()); }
@Deployment(resources = {"org/camunda/bpm/engine/test/repository/one.cmmn"}) public void testGetCaseDefinition() { CaseDefinitionQuery query = repositoryService.createCaseDefinitionQuery(); CaseDefinition caseDefinition = query.singleResult(); String caseDefinitionId = caseDefinition.getId(); CaseDefinition definition = repositoryService.getCaseDefinition(caseDefinitionId); assertNotNull(definition); assertEquals(caseDefinitionId, definition.getId()); }
@Deployment(resources = {"org/camunda/bpm/engine/test/repository/one.cmmn"}) public void testGetCaseModel() throws Exception { CaseDefinitionQuery query = repositoryService.createCaseDefinitionQuery(); CaseDefinition caseDefinition = query.singleResult(); String caseDefinitionId = caseDefinition.getId(); InputStream caseModel = repositoryService.getCaseModel(caseDefinitionId); assertNotNull(caseModel); byte[] readInputStream = IoUtil.readInputStream(caseModel, "caseModel"); String model = new String(readInputStream, "UTF-8"); assertTrue(model.contains("<case id=\"one\" name=\"One\">")); IoUtil.closeSilently(caseModel); }