private CaseDefinitionQuery createMockCaseDefinitionQuery(
      List<CaseDefinition> mockedDefinitions) {
    CaseDefinitionQuery sampleDefinitionsQuery = mock(CaseDefinitionQuery.class);

    when(sampleDefinitionsQuery.list()).thenReturn(mockedDefinitions);
    when(sampleDefinitionsQuery.count()).thenReturn((long) mockedDefinitions.size());
    when(processEngine.getRepositoryService().createCaseDefinitionQuery())
        .thenReturn(sampleDefinitionsQuery);

    return sampleDefinitionsQuery;
  }
  @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);
  }