Search in sources :

Example 1 with RepositoryServiceImpl

use of org.camunda.bpm.engine.impl.RepositoryServiceImpl in project camunda-bpm-platform by camunda.

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/camunda/bpm/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/camunda/bpm/engine/test/bpmn/deployment/BpmnDeploymentTest.testGetBpmnXmlFileThroughService.bpmn20.xml");
    String contentFromFile = readInputStreamToString(fileInputStream);
    assertEquals(contentFromFile, contentFromDeployment);
}
Also used : InputStream(java.io.InputStream) ReadOnlyProcessDefinition(org.camunda.bpm.engine.impl.pvm.ReadOnlyProcessDefinition) ReadOnlyProcessDefinition(org.camunda.bpm.engine.impl.pvm.ReadOnlyProcessDefinition) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) RepositoryServiceImpl(org.camunda.bpm.engine.impl.RepositoryServiceImpl) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 2 with RepositoryServiceImpl

use of org.camunda.bpm.engine.impl.RepositoryServiceImpl in project camunda-bpm-platform by camunda.

the class RepositoryServiceTest method testProcessDefinitionIntrospection.

public void testProcessDefinitionIntrospection() {
    String deploymentId = repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/repository/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.camunda.bpm.engine.impl.pvm.ReadOnlyProcessDefinition) RepositoryServiceImpl(org.camunda.bpm.engine.impl.RepositoryServiceImpl) PvmActivity(org.camunda.bpm.engine.impl.pvm.PvmActivity) PvmTransition(org.camunda.bpm.engine.impl.pvm.PvmTransition)

Example 3 with RepositoryServiceImpl

use of org.camunda.bpm.engine.impl.RepositoryServiceImpl in project camunda-bpm-platform by camunda.

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.camunda.bpm.engine.impl.pvm.ReadOnlyProcessDefinition) RepositoryServiceImpl(org.camunda.bpm.engine.impl.RepositoryServiceImpl) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 4 with RepositoryServiceImpl

use of org.camunda.bpm.engine.impl.RepositoryServiceImpl in project camunda-bpm-platform by camunda.

the class ProcessDefinitionAuthorizationTest method testGetDeployedProcessDefinition.

public void testGetDeployedProcessDefinition() {
    // given
    String processDefinitionId = selectProcessDefinitionByKey(ONE_TASK_PROCESS_KEY).getId();
    createGrantAuthorization(PROCESS_DEFINITION, ONE_TASK_PROCESS_KEY, userId, READ);
    // when
    ReadOnlyProcessDefinition definition = ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(processDefinitionId);
    // then
    assertNotNull(definition);
}
Also used : ReadOnlyProcessDefinition(org.camunda.bpm.engine.impl.pvm.ReadOnlyProcessDefinition) RepositoryServiceImpl(org.camunda.bpm.engine.impl.RepositoryServiceImpl)

Aggregations

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