public ProcessDefinition build() { ProcessDefinition mockDefinition = mock(ProcessDefinition.class); when(mockDefinition.getId()).thenReturn(id); when(mockDefinition.getCategory()).thenReturn(category); when(mockDefinition.getName()).thenReturn(name); when(mockDefinition.getKey()).thenReturn(key); when(mockDefinition.getDescription()).thenReturn(description); when(mockDefinition.getVersion()).thenReturn(version); when(mockDefinition.getResourceName()).thenReturn(resource); when(mockDefinition.getDeploymentId()).thenReturn(deploymentId); when(mockDefinition.getDiagramResourceName()).thenReturn(diagram); when(mockDefinition.isSuspended()).thenReturn(suspended); when(mockDefinition.hasStartFormKey()).thenReturn(startFormKey); when(mockDefinition.getTenantId()).thenReturn(tenantId); when(mockDefinition.getVersionTag()).thenReturn(versionTag); when(mockDefinition.isStartableInTasklist()).thenReturn(isStartableInTasklist); return mockDefinition; } }
@Test public void testResourceName() { ProcessEngine processEngine = ProgrammaticBeanLookup.lookup(ProcessEngine.class); Assert.assertNotNull(processEngine); RepositoryService repositoryService = processEngine.getRepositoryService(); ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery(); ProcessDefinition definition = query.processDefinitionKey("process-0").singleResult(); Assert.assertEquals("process0.bpmn", definition.getResourceName()); definition = query.processDefinitionKey("process-1").singleResult(); Assert.assertEquals("processes/process1.bpmn", definition.getResourceName()); definition = query.processDefinitionKey("process-2").singleResult(); Assert.assertEquals("process2.bpmn", definition.getResourceName()); definition = query.processDefinitionKey("process-3").singleResult(); Assert.assertEquals("subDirectory/process3.bpmn", definition.getResourceName()); definition = query.processDefinitionKey("process-4").singleResult(); Assert.assertEquals("process4.bpmn", definition.getResourceName()); definition = query.processDefinitionKey("process-5").singleResult(); Assert.assertEquals("subDirectory/process5.bpmn", definition.getResourceName()); }
public static HalProcessDefinition fromProcessDefinition(ProcessDefinition processDefinition, ProcessEngine processEngine) { HalProcessDefinition halProcDef = new HalProcessDefinition(); halProcDef.id = processDefinition.getId(); halProcDef.key = processDefinition.getKey(); halProcDef.category = processDefinition.getCategory(); halProcDef.description = processDefinition.getDescription(); halProcDef.name = processDefinition.getName(); halProcDef.version = processDefinition.getVersion(); halProcDef.resource = processDefinition.getResourceName(); halProcDef.deploymentId = processDefinition.getDeploymentId(); halProcDef.diagram = processDefinition.getDiagramResourceName(); halProcDef.suspended = processDefinition.isSuspended(); halProcDef.contextPath = ApplicationContextPathUtil.getApplicationPathForDeployment(processEngine, processDefinition.getDeploymentId()); halProcDef.linker.createLink(REL_SELF, processDefinition.getId()); halProcDef.linker.createLink(REL_DEPLOYMENT, processDefinition.getDeploymentId()); halProcDef.linker.createLink(REL_DEPLOYMENT_RESOURCE, processDefinition.getDeploymentId(), processDefinition.getResourceName()); return halProcDef; }
public static HalProcessDefinition fromProcessDefinition(ProcessDefinition processDefinition, ProcessEngine processEngine) { HalProcessDefinition halProcDef = new HalProcessDefinition(); halProcDef.id = processDefinition.getId(); halProcDef.key = processDefinition.getKey(); halProcDef.category = processDefinition.getCategory(); halProcDef.description = processDefinition.getDescription(); halProcDef.name = processDefinition.getName(); halProcDef.version = processDefinition.getVersion(); halProcDef.resource = processDefinition.getResourceName(); halProcDef.deploymentId = processDefinition.getDeploymentId(); halProcDef.diagram = processDefinition.getDiagramResourceName(); halProcDef.suspended = processDefinition.isSuspended(); halProcDef.contextPath = ApplicationContextPathUtil.getApplicationPathForDeployment(processEngine, processDefinition.getDeploymentId()); halProcDef.linker.createLink(REL_SELF, processDefinition.getId()); halProcDef.linker.createLink(REL_DEPLOYMENT, processDefinition.getDeploymentId()); halProcDef.linker.createLink(REL_DEPLOYMENT_RESOURCE, processDefinition.getDeploymentId(), processDefinition.getResourceName()); return halProcDef; }
@Override public int compare(ProcessDefinition o1, ProcessDefinition o2) { return o1.getResourceName().compareTo(o2.getResourceName()); } });
public static ProcessDefinitionDto fromProcessDefinition(ProcessDefinition definition) { ProcessDefinitionDto dto = new ProcessDefinitionDto(); dto.id = definition.getId(); dto.key = definition.getKey(); dto.category = definition.getCategory(); dto.description = definition.getDescription(); dto.name = definition.getName(); dto.version = definition.getVersion(); dto.resource = definition.getResourceName(); dto.deploymentId = definition.getDeploymentId(); dto.diagram = definition.getDiagramResourceName(); dto.suspended = definition.isSuspended(); dto.tenantId = definition.getTenantId(); dto.versionTag = definition.getVersionTag(); dto.historyTimeToLive = definition.getHistoryTimeToLive(); dto.isStartableInTasklist = definition.isStartableInTasklist(); return dto; }
public static ProcessDefinitionDto fromProcessDefinition(ProcessDefinition definition) { ProcessDefinitionDto dto = new ProcessDefinitionDto(); dto.id = definition.getId(); dto.key = definition.getKey(); dto.category = definition.getCategory(); dto.description = definition.getDescription(); dto.name = definition.getName(); dto.version = definition.getVersion(); dto.resource = definition.getResourceName(); dto.deploymentId = definition.getDeploymentId(); dto.diagram = definition.getDiagramResourceName(); dto.suspended = definition.isSuspended(); dto.tenantId = definition.getTenantId(); dto.versionTag = definition.getVersionTag(); dto.historyTimeToLive = definition.getHistoryTimeToLive(); dto.isStartableInTasklist = definition.isStartableInTasklist(); return dto; }
/** * Retrieves a process definitions BPMN XML. * * @param processDefinition * @return * @throws IOException * Thrown if the BPMN resource is not found. */ protected static String getBpmnXml(ProcessDefinition processDefinition) throws IOException { InputStream inputStream = CoverageReportUtil.class.getClassLoader().getResourceAsStream( processDefinition.getResourceName()); if (inputStream == null) { inputStream = new FileInputStream(processDefinition.getResourceName()); } return IOUtils.toString(inputStream); }
@Deployment(resources={ "org/camunda/bpm/engine/test/bpmn/deployment/BpmnDeploymentTest.testProcessDiagramResource.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/deployment/BpmnDeploymentTest.testProcessDiagramResource.jpg" }) public void testProcessDiagramResource() { ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult(); assertEquals("org/camunda/bpm/engine/test/bpmn/deployment/BpmnDeploymentTest.testProcessDiagramResource.bpmn20.xml", processDefinition.getResourceName()); assertTrue(processDefinition.hasStartFormKey()); String diagramResourceName = processDefinition.getDiagramResourceName(); assertEquals("org/camunda/bpm/engine/test/bpmn/deployment/BpmnDeploymentTest.testProcessDiagramResource.jpg", diagramResourceName); InputStream diagramStream = repositoryService.getResourceAsStream(deploymentId, "org/camunda/bpm/engine/test/bpmn/deployment/BpmnDeploymentTest.testProcessDiagramResource.jpg"); byte[] diagramBytes = IoUtil.readInputStream(diagramStream, "diagram stream"); assertEquals(33343, diagramBytes.length); }
@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); }
public static HalProcessDefinition fromProcessDefinition(ProcessDefinition processDefinition, ProcessEngine processEngine) { HalProcessDefinition halProcDef = new HalProcessDefinition(); halProcDef.id = processDefinition.getId(); halProcDef.key = processDefinition.getKey(); halProcDef.category = processDefinition.getCategory(); halProcDef.description = processDefinition.getDescription(); halProcDef.name = processDefinition.getName(); halProcDef.version = processDefinition.getVersion(); halProcDef.resource = processDefinition.getResourceName(); halProcDef.deploymentId = processDefinition.getDeploymentId(); halProcDef.diagram = processDefinition.getDiagramResourceName(); halProcDef.suspended = processDefinition.isSuspended(); halProcDef.contextPath = ApplicationContextPathUtil.getApplicationPathForDeployment(processEngine, processDefinition.getDeploymentId()); halProcDef.linker.createLink(REL_SELF, processDefinition.getId()); halProcDef.linker.createLink(REL_DEPLOYMENT, processDefinition.getDeploymentId()); halProcDef.linker.createLink(REL_DEPLOYMENT_RESOURCE, processDefinition.getDeploymentId(), processDefinition.getResourceName()); return halProcDef; }
public static ProcessDefinitionDto fromProcessDefinition(ProcessDefinition definition) { ProcessDefinitionDto dto = new ProcessDefinitionDto(); dto.id = definition.getId(); dto.key = definition.getKey(); dto.category = definition.getCategory(); dto.description = definition.getDescription(); dto.name = definition.getName(); dto.version = definition.getVersion(); dto.resource = definition.getResourceName(); dto.deploymentId = definition.getDeploymentId(); dto.diagram = definition.getDiagramResourceName(); dto.suspended = definition.isSuspended(); dto.tenantId = definition.getTenantId(); dto.versionTag = definition.getVersionTag(); dto.historyTimeToLive = definition.getHistoryTimeToLive(); dto.isStartableInTasklist = definition.isStartableInTasklist(); return dto; }
@Deployment(resources={ "org/camunda/bpm/engine/test/bpmn/deployment/BpmnDeploymentTest.testProcessDiagramResource.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/deployment/BpmnDeploymentTest.testProcessDiagramResource.jpg" }) public void testProcessDiagramResource() { ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult(); assertEquals("org/camunda/bpm/engine/test/bpmn/deployment/BpmnDeploymentTest.testProcessDiagramResource.bpmn20.xml", processDefinition.getResourceName()); assertTrue(processDefinition.hasStartFormKey()); String diagramResourceName = processDefinition.getDiagramResourceName(); assertEquals("org/camunda/bpm/engine/test/bpmn/deployment/BpmnDeploymentTest.testProcessDiagramResource.jpg", diagramResourceName); InputStream diagramStream = repositoryService.getResourceAsStream(deploymentId, "org/camunda/bpm/engine/test/bpmn/deployment/BpmnDeploymentTest.testProcessDiagramResource.jpg"); byte[] diagramBytes = IoUtil.readInputStream(diagramStream, "diagram stream"); assertEquals(33343, diagramBytes.length); }
@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); }