private String deployProcessString(String processString) {
   RepositoryService repositoryService = activitiRule.getRepositoryService();
   String resourceName = "xmlString." + BpmnDeployer.BPMN_RESOURCE_SUFFIXES;
   return repositoryService
       .createDeployment()
       .addString(resourceName, processString)
       .deploy()
       .getId();
 }
  @Test
  public void testDeployIdenticalProcessDefinitions() {
    List<String> deploymentIds = new ArrayList<String>();
    deploymentIds.add(
        deployProcessString(
            ("<definitions "
                + NAMESPACE
                + " "
                + TARGET_NAMESPACE
                + ">"
                + "  <process id='IDR' name='Insurance Damage Report' />"
                + "</definitions>")));
    deploymentIds.add(
        deployProcessString(
            ("<definitions "
                + NAMESPACE
                + " "
                + TARGET_NAMESPACE
                + ">"
                + "  <process id='IDR' name='Insurance Damage Report' />"
                + "</definitions>")));

    RepositoryService repositoryService = activitiRule.getRepositoryService();
    List<ProcessDefinition> processDefinitions =
        repositoryService
            .createProcessDefinitionQuery()
            .orderByProcessDefinitionKey()
            .asc()
            .orderByProcessDefinitionVersion()
            .desc()
            .list();

    assertNotNull(processDefinitions);
    assertEquals(2, processDefinitions.size());

    ProcessDefinition processDefinition = processDefinitions.get(0);
    assertEquals("IDR", processDefinition.getKey());
    assertEquals("Insurance Damage Report", processDefinition.getName());
    assertTrue(processDefinition.getId().startsWith("IDR:2"));
    assertEquals(2, processDefinition.getVersion());

    processDefinition = processDefinitions.get(1);
    assertEquals("IDR", processDefinition.getKey());
    assertEquals("Insurance Damage Report", processDefinition.getName());
    assertTrue(processDefinition.getId().startsWith("IDR:1"));
    assertEquals(1, processDefinition.getVersion());

    deleteDeployments(deploymentIds);
  }
  @Test
  public void startProcess() throws Exception {
    RepositoryService repositoryService = activitiRule.getRepositoryService();
    TaskService taskService = activitiRule.getTaskService();
    repositoryService
        .createDeployment()
        .addInputStream("process1.bpmn20.xml", new FileInputStream(filename))
        .deploy();
    RuntimeService runtimeService = activitiRule.getRuntimeService();
    Map<String, Object> variableMap = new HashMap<String, Object>();
    variableMap.put("name", "Activiti");
    ProcessInstance processInstance =
        runtimeService.startProcessInstanceByKey("MyProcess", variableMap);
    assertNotNull(processInstance.getId());
    System.out.println(
        "id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());

    assertNotNull(taskService.createTaskQuery().taskAssignee("fg").singleResult());
  }
 private void deleteDeployments(Collection<String> deploymentIds) {
   RepositoryService repositoryService = activitiRule.getRepositoryService();
   for (String deploymentId : deploymentIds) {
     repositoryService.deleteDeployment(deploymentId);
   }
 }