Package org.activiti.engine.repository

Examples of org.activiti.engine.repository.ProcessDefinition


  * GET repository/process-definitions/{processDefinitionResource}
  */
  @Deployment(resources={"org/activiti/rest/service/api/repository/oneTaskProcess.bpmn20.xml"})
  public void testGetProcessDefinition() throws Exception {

    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
   
    HttpGet httpGet = new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(
        RestUrls.URL_PROCESS_DEFINITION, processDefinition.getId()));
    CloseableHttpResponse response = executeRequest(httpGet, HttpStatus.SC_OK);
    JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
    closeResponse(response);
    assertEquals(processDefinition.getId(), responseNode.get("id").textValue());
    assertEquals(processDefinition.getKey(), responseNode.get("key").textValue());
    assertEquals(processDefinition.getCategory(), responseNode.get("category").textValue());
    assertEquals(processDefinition.getVersion(), responseNode.get("version").intValue());
    assertEquals(processDefinition.getDescription(), responseNode.get("description").textValue());
    assertEquals(processDefinition.getName(), responseNode.get("name").textValue());
    assertFalse(responseNode.get("graphicalNotationDefined").booleanValue());
   
    // Check URL's
    assertEquals(httpGet.getURI().toString(), responseNode.get("url").asText());
    assertEquals(processDefinition.getDeploymentId(), responseNode.get("deploymentId").textValue());
    assertTrue(responseNode.get("deploymentUrl").textValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_DEPLOYMENT, processDefinition.getDeploymentId())));
    assertTrue(URLDecoder.decode(responseNode.get("resource").textValue(), "UTF-8").endsWith(RestUrls.createRelativeResourceUrl(
            RestUrls.URL_DEPLOYMENT_RESOURCE, processDefinition.getDeploymentId(), processDefinition.getResourceName())));
    assertTrue(responseNode.get("diagramResource").isNull());
  }
View Full Code Here


   * GET repository/process-definitions/{processDefinitionResource}
   */
  @Deployment
  public void testGetProcessDefinitionWithGraphicalNotation() throws Exception {
 
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    
    HttpGet httpGet = new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(
        RestUrls.URL_PROCESS_DEFINITION, processDefinition.getId()));
    CloseableHttpResponse response = executeRequest(httpGet, HttpStatus.SC_OK);
    JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
    closeResponse(response);
    assertEquals(processDefinition.getId(), responseNode.get("id").textValue());
    assertEquals(processDefinition.getKey(), responseNode.get("key").textValue());
    assertEquals(processDefinition.getCategory(), responseNode.get("category").textValue());
    assertEquals(processDefinition.getVersion(), responseNode.get("version").intValue());
    assertEquals(processDefinition.getDescription(), responseNode.get("description").textValue());
    assertEquals(processDefinition.getName(), responseNode.get("name").textValue());
    assertTrue(responseNode.get("graphicalNotationDefined").booleanValue());
    
    // Check URL's
    assertEquals(httpGet.getURI().toString(), responseNode.get("url").asText());
    assertEquals(processDefinition.getDeploymentId(), responseNode.get("deploymentId").textValue());
    assertTrue(responseNode.get("deploymentUrl").textValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_DEPLOYMENT, processDefinition.getDeploymentId())));
    assertTrue(URLDecoder.decode(responseNode.get("resource").textValue(), "UTF-8").endsWith(RestUrls.createRelativeResourceUrl(
        RestUrls.URL_DEPLOYMENT_RESOURCE, processDefinition.getDeploymentId(), processDefinition.getResourceName())));
    assertTrue(URLDecoder.decode(responseNode.get("diagramResource").textValue(), "UTF-8").endsWith(RestUrls.createRelativeResourceUrl(
        RestUrls.URL_DEPLOYMENT_RESOURCE, processDefinition.getDeploymentId(), processDefinition.getDiagramResourceName())));
  }
View Full Code Here

      .addClasspathResource("org/activiti/engine/test/regression/ProcessValidationExecutedAfterDeployTest.bpmn20.xml")
      .deploy();
    enableValidation();
    clearDeploymentCache();
   
    ProcessDefinition definition = getLatestProcessDefinitionVersionByKey("testProcess1");
    if (definition == null) {
      fail("Error occurred in fetching process model.");
    }
    try {
      repositoryService.getProcessModel(definition.getId());
      assertTrue(true);
    } catch (ActivitiException e) {
      fail("Error occurred in fetching process model.");
    }
   
View Full Code Here

      .addClasspathResource("org/activiti/engine/test/regression/ProcessValidationExecutedAfterDeployTest.bpmn20.xml")
      .deploy();
    enableValidation();
    clearDeploymentCache();
   
    ProcessDefinition definition = getLatestProcessDefinitionVersionByKey("testProcess1");
    if (definition == null) {
      fail("Error occurred in fetching process model.");
    }
    try {
      formService.getStartFormData(definition.getId());
      assertTrue(true);
    } catch (ActivitiException e) {
      fail("Error occurred in fetching start form data:");
    }
   
View Full Code Here

    * Test suspending a process definition.
    * POST repository/process-definitions/{processDefinitionId}
    */
   @Deployment(resources={"org/activiti/rest/service/api/repository/oneTaskProcess.bpmn20.xml"})
   public void testSuspendProcessDefinition() throws Exception {
     ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
     assertFalse(processDefinition.isSuspended());
     
     ObjectNode requestNode = objectMapper.createObjectNode();
     requestNode.put("action", "suspend");
     
     HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(
         RestUrls.URL_PROCESS_DEFINITION, processDefinition.getId()));
     httpPut.setEntity(new StringEntity(requestNode.toString()));
     CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_OK);
     
     // Check "OK" status
     JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
     closeResponse(response);
     assertTrue(responseNode.get("suspended").booleanValue());
     
     // Check if process-definitoin is suspended
     processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
     assertTrue(processDefinition.isSuspended());
   }
View Full Code Here

   * Test suspending a process definition on a certain date.
   * POST repository/process-definitions/{processDefinitionId}
   */
   @Deployment(resources={"org/activiti/rest/service/api/repository/oneTaskProcess.bpmn20.xml"})
   public void testSuspendProcessDefinitionDelayed() throws Exception {
     ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
     assertFalse(processDefinition.isSuspended());
    
     ObjectNode requestNode = objectMapper.createObjectNode();
    
     Calendar cal = Calendar.getInstance();
     cal.add(Calendar.HOUR, 2);
    
     // Format the date using ISO date format
     DateTimeFormatter formatter = ISODateTimeFormat.dateTime();
     String dateString = formatter.print(cal.getTimeInMillis());
    
     requestNode.put("action", "suspend");
     requestNode.put("date", dateString);
    
     HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(
         RestUrls.URL_PROCESS_DEFINITION, processDefinition.getId()));
     httpPut.setEntity(new StringEntity(requestNode.toString()));
     CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_OK);
    
     // Check "OK" status
     JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
     closeResponse(response);
     assertTrue(responseNode.get("suspended").booleanValue());
    
     // Check if process-definition is not yet suspended
     processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
     assertFalse(processDefinition.isSuspended());
    
     // Force suspension by altering time
     cal.add(Calendar.HOUR, 1);
     processEngineConfiguration.getClock().setCurrentTime(cal.getTime());
     waitForJobExecutorToProcessAllJobs(5000, 100);
    
     // Check if process-definition is suspended
     processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
     assertTrue(processDefinition.isSuspended());
   }
View Full Code Here

   * Test suspending already suspended process definition.
   * POST repository/process-definitions/{processDefinitionId}
   */
   @Deployment(resources={"org/activiti/rest/service/api/repository/oneTaskProcess.bpmn20.xml"})
   public void testSuspendAlreadySuspendedProcessDefinition() throws Exception {
     ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
     repositoryService.suspendProcessDefinitionById(processDefinition.getId());
    
     processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
     assertTrue(processDefinition.isSuspended());
    
     ObjectNode requestNode = objectMapper.createObjectNode();
     requestNode.put("action", "suspend");
    
     HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(
         RestUrls.URL_PROCESS_DEFINITION, processDefinition.getId()));
     httpPut.setEntity(new StringEntity(requestNode.toString()));
     CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_CONFLICT);
     closeResponse(response);
   }
View Full Code Here

   * Test activating a suspended process definition.
   * POST repository/process-definitions/{processDefinitionId}
   */
   @Deployment(resources={"org/activiti/rest/service/api/repository/oneTaskProcess.bpmn20.xml"})
   public void testActivateProcessDefinition() throws Exception {
     ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
     repositoryService.suspendProcessDefinitionById(processDefinition.getId());
    
     processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
     assertTrue(processDefinition.isSuspended());
    
     ObjectNode requestNode = objectMapper.createObjectNode();
     requestNode.put("action", "activate");
    
     HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(
         RestUrls.URL_PROCESS_DEFINITION, processDefinition.getId()));
     httpPut.setEntity(new StringEntity(requestNode.toString()));
     CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_OK);
    
     // Check "OK" status
     JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
     closeResponse(response);
     assertFalse(responseNode.get("suspended").booleanValue());
    
     // Check if process-definitoin is suspended
     processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
     assertFalse(processDefinition.isSuspended());
   }
View Full Code Here

  * Test activating a suspended process definition delayed.
  * POST repository/process-definitions/{processDefinitionId}
  */
  @Deployment(resources={"org/activiti/rest/service/api/repository/oneTaskProcess.bpmn20.xml"})
  public void testActivateProcessDefinitionDelayed() throws Exception {
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    repositoryService.suspendProcessDefinitionById(processDefinition.getId());
   
    processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    assertTrue(processDefinition.isSuspended());
   
    ObjectNode requestNode = objectMapper.createObjectNode();
   
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.HOUR, 2);
   
    // Format the date using ISO date format
    DateTimeFormatter formatter = ISODateTimeFormat.dateTime();
    String dateString = formatter.print(cal.getTimeInMillis());
   
    requestNode.put("action", "activate");
    requestNode.put("date", dateString);
   
    HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(
        RestUrls.URL_PROCESS_DEFINITION, processDefinition.getId()));
    httpPut.setEntity(new StringEntity(requestNode.toString()));
    CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_OK);
   
    // Check "OK" status
    JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
    closeResponse(response);
    assertFalse(responseNode.get("suspended").booleanValue());
   
    // Check if process-definition is not yet active
    processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    assertTrue(processDefinition.isSuspended());
   
    // Force activation by altering time
    cal.add(Calendar.HOUR, 1);
    processEngineConfiguration.getClock().setCurrentTime(cal.getTime());
    waitForJobExecutorToProcessAllJobs(5000, 100);
   
    // Check if process-definition is activated
    processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    assertFalse(processDefinition.isSuspended());
  }
View Full Code Here

  * Test activating already active process definition.
  * POST repository/process-definitions/{processDefinitionId}
  */
  @Deployment(resources={"org/activiti/rest/service/api/repository/oneTaskProcess.bpmn20.xml"})
  public void testActivateAlreadyActiveProcessDefinition() throws Exception {
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    assertFalse(processDefinition.isSuspended());
   
    ObjectNode requestNode = objectMapper.createObjectNode();
    requestNode.put("action", "activate");
   
    HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(
        RestUrls.URL_PROCESS_DEFINITION, processDefinition.getId()));
    httpPut.setEntity(new StringEntity(requestNode.toString()));
    CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_CONFLICT);
    closeResponse(response);
  }
View Full Code Here

TOP

Related Classes of org.activiti.engine.repository.ProcessDefinition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.