Search in sources :

Example 1 with ReadOnlyProcessDefinition

use of org.activiti.engine.impl.pvm.ReadOnlyProcessDefinition in project Activiti by Activiti.

the class ProcessDefinitionPersistenceTest method testProcessDefinitionIntrospection.

public void testProcessDefinitionIntrospection() {
    String deploymentId = repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/db/processOne.bpmn20.xml").deploy().getId();
    String procDefId = repositoryService.createProcessDefinitionQuery().singleResult().getId();
    ReadOnlyProcessDefinition processDefinition = ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(procDefId);
    assertEquals(procDefId, processDefinition.getId());
    assertEquals("Process One", processDefinition.getName());
    assertEquals("the first process", processDefinition.getProperty("documentation"));
    PvmActivity start = processDefinition.findActivity("start");
    assertNotNull(start);
    assertEquals("start", start.getId());
    assertEquals("S t a r t", start.getProperty("name"));
    assertEquals("the start event", start.getProperty("documentation"));
    assertEquals(Collections.EMPTY_LIST, start.getActivities());
    List<PvmTransition> outgoingTransitions = start.getOutgoingTransitions();
    assertEquals(1, outgoingTransitions.size());
    assertEquals("${a == b}", outgoingTransitions.get(0).getProperty(BpmnParse.PROPERTYNAME_CONDITION_TEXT));
    PvmActivity end = processDefinition.findActivity("end");
    assertNotNull(end);
    assertEquals("end", end.getId());
    PvmTransition transition = outgoingTransitions.get(0);
    assertEquals("flow1", transition.getId());
    assertEquals("Flow One", transition.getProperty("name"));
    assertEquals("The only transitions in the process", transition.getProperty("documentation"));
    assertSame(start, transition.getSource());
    assertSame(end, transition.getDestination());
    repositoryService.deleteDeployment(deploymentId);
}
Also used : ReadOnlyProcessDefinition(org.activiti.engine.impl.pvm.ReadOnlyProcessDefinition) RepositoryServiceImpl(org.activiti.engine.impl.RepositoryServiceImpl) PvmActivity(org.activiti.engine.impl.pvm.PvmActivity) PvmTransition(org.activiti.engine.impl.pvm.PvmTransition)

Example 2 with ReadOnlyProcessDefinition

use of org.activiti.engine.impl.pvm.ReadOnlyProcessDefinition in project Activiti by Activiti.

the class BpmnDeploymentTest method testProcessDefinitionDescription.

@Deployment
public void testProcessDefinitionDescription() {
    String id = repositoryService.createProcessDefinitionQuery().singleResult().getId();
    ReadOnlyProcessDefinition processDefinition = ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(id);
    assertEquals("This is really good process documentation!", processDefinition.getDescription());
}
Also used : ReadOnlyProcessDefinition(org.activiti.engine.impl.pvm.ReadOnlyProcessDefinition) RepositoryServiceImpl(org.activiti.engine.impl.RepositoryServiceImpl) Deployment(org.activiti.engine.test.Deployment)

Example 3 with ReadOnlyProcessDefinition

use of org.activiti.engine.impl.pvm.ReadOnlyProcessDefinition in project Activiti by Activiti.

the class BpmnDeploymentTest method testGetBpmnXmlFileThroughService.

@Deployment
public void testGetBpmnXmlFileThroughService() {
    String deploymentId = repositoryService.createDeploymentQuery().singleResult().getId();
    List<String> deploymentResources = repositoryService.getDeploymentResourceNames(deploymentId);
    // verify bpmn file name
    assertEquals(1, deploymentResources.size());
    String bpmnResourceName = "org/activiti/engine/test/bpmn/deployment/BpmnDeploymentTest.testGetBpmnXmlFileThroughService.bpmn20.xml";
    assertEquals(bpmnResourceName, deploymentResources.get(0));
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    assertEquals(bpmnResourceName, processDefinition.getResourceName());
    assertNull(processDefinition.getDiagramResourceName());
    assertFalse(processDefinition.hasStartFormKey());
    ReadOnlyProcessDefinition readOnlyProcessDefinition = ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(processDefinition.getId());
    assertNull(readOnlyProcessDefinition.getDiagramResourceName());
    // verify content
    InputStream deploymentInputStream = repositoryService.getResourceAsStream(deploymentId, bpmnResourceName);
    String contentFromDeployment = readInputStreamToString(deploymentInputStream);
    assertTrue(contentFromDeployment.length() > 0);
    assertTrue(contentFromDeployment.contains("process id=\"emptyProcess\""));
    InputStream fileInputStream = ReflectUtil.getResourceAsStream("org/activiti/engine/test/bpmn/deployment/BpmnDeploymentTest.testGetBpmnXmlFileThroughService.bpmn20.xml");
    String contentFromFile = readInputStreamToString(fileInputStream);
    assertEquals(contentFromFile, contentFromDeployment);
}
Also used : InputStream(java.io.InputStream) ReadOnlyProcessDefinition(org.activiti.engine.impl.pvm.ReadOnlyProcessDefinition) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) ReadOnlyProcessDefinition(org.activiti.engine.impl.pvm.ReadOnlyProcessDefinition) RepositoryServiceImpl(org.activiti.engine.impl.RepositoryServiceImpl) Deployment(org.activiti.engine.test.Deployment)

Aggregations

RepositoryServiceImpl (org.activiti.engine.impl.RepositoryServiceImpl)3 ReadOnlyProcessDefinition (org.activiti.engine.impl.pvm.ReadOnlyProcessDefinition)3 Deployment (org.activiti.engine.test.Deployment)2 InputStream (java.io.InputStream)1 PvmActivity (org.activiti.engine.impl.pvm.PvmActivity)1 PvmTransition (org.activiti.engine.impl.pvm.PvmTransition)1 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)1