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; } }
@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); }
@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); }
@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); }