private static void initDeployedResourceLists(DeploymentWithDefinitions deployment, DeploymentWithDefinitionsDto dto) { List<ProcessDefinition> deployedProcessDefinitions = deployment.getDeployedProcessDefinitions(); if (deployedProcessDefinitions != null) { dto.deployedProcessDefinitions = new HashMap<String, ProcessDefinitionDto>(); List<CaseDefinition> deployedCaseDefinitions = deployment.getDeployedCaseDefinitions(); if (deployedCaseDefinitions != null) { dto.deployedCaseDefinitions = new HashMap<String, CaseDefinitionDto>(); List<DecisionDefinition> deployedDecisionDefinitions = deployment.getDeployedDecisionDefinitions(); if (deployedDecisionDefinitions != null) { dto.deployedDecisionDefinitions = new HashMap<String, DecisionDefinitionDto>(); List<DecisionRequirementsDefinition> deployedDecisionRequirementsDefinitions = deployment.getDeployedDecisionRequirementsDefinitions(); if (deployedDecisionRequirementsDefinitions != null) { dto.deployedDecisionRequirementsDefinitions = new HashMap<String, DecisionRequirementsDefinitionDto>();
public static DeploymentWithDefinitionsDto fromDeployment(DeploymentWithDefinitions deployment) { DeploymentWithDefinitionsDto dto = new DeploymentWithDefinitionsDto(); dto.id = deployment.getId(); dto.name = deployment.getName(); dto.source = deployment.getSource(); dto.deploymentTime = deployment.getDeploymentTime(); dto.tenantId = deployment.getTenantId(); initDeployedResourceLists(deployment, dto); return dto; }
public static DeploymentWithDefinitions createMockDeploymentWithDefinitions(String tenantId) { DeploymentWithDefinitions mockDeployment = mock(DeploymentWithDefinitions.class); when(mockDeployment.getId()).thenReturn(EXAMPLE_DEPLOYMENT_ID); when(mockDeployment.getName()).thenReturn(EXAMPLE_DEPLOYMENT_NAME); when(mockDeployment.getDeploymentTime()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_DEPLOYMENT_TIME)); when(mockDeployment.getSource()).thenReturn(EXAMPLE_DEPLOYMENT_SOURCE); when(mockDeployment.getTenantId()).thenReturn(tenantId); List<ProcessDefinition> mockDefinitions = createMockDefinitions(); when(mockDeployment.getDeployedProcessDefinitions()).thenReturn(mockDefinitions); List<CaseDefinition> mockCaseDefinitions = createMockCaseDefinitions(); when(mockDeployment.getDeployedCaseDefinitions()).thenReturn(mockCaseDefinitions); List<DecisionDefinition> mockDecisionDefinitions = createMockDecisionDefinitions(); when(mockDeployment.getDeployedDecisionDefinitions()).thenReturn(mockDecisionDefinitions); List<DecisionRequirementsDefinition> mockDecisionRequirementsDefinitions = createMockDecisionRequirementsDefinitions(); when(mockDeployment.getDeployedDecisionRequirementsDefinitions()).thenReturn(mockDecisionRequirementsDefinitions); return mockDeployment; }
@Override public List<ProcessDefinition> getDeployedProcessDefinitions() { return deployment.getDeployedProcessDefinitions(); }
public String getId() { return deployment.getId(); }
@Test public void testCreateCompleteDmnDeployment() throws Exception { // given DeploymentWithDefinitions mockDeployment = MockProvider.createMockDeploymentWithDefinitions(); when(mockDeployment.getDeployedCaseDefinitions()).thenReturn(null); when(mockDeployment.getDeployedProcessDefinitions()).thenReturn(null); when(mockDeployment.getDeployedDecisionRequirementsDefinitions()).thenReturn(null); when(mockDeploymentBuilder.deployWithResult()).thenReturn(mockDeployment); // when resourceNames.addAll(Arrays.asList("data", "more-data")); Response response = given() .multiPart("data", "unspecified", createMockDeploymentResourceByteData()) .multiPart("more-data", "unspecified", createMockDeploymentResourceBpmnData()) .multiPart("deployment-name", MockProvider.EXAMPLE_DEPLOYMENT_ID) .multiPart("enable-duplicate-filtering", "true") .expect() .statusCode(Status.OK.getStatusCode()) .when() .post(CREATE_DEPLOYMENT_URL); // then verifyCreatedDmnDeployment(mockDeployment, response); verify(mockDeploymentBuilder).name(MockProvider.EXAMPLE_DEPLOYMENT_ID); verify(mockDeploymentBuilder).enableDuplicateFiltering(false); }
@Test public void testCreateCompleteCmmnDeployment() throws Exception { // given DeploymentWithDefinitions mockDeployment = MockProvider.createMockDeploymentWithDefinitions(); when(mockDeployment.getDeployedDecisionDefinitions()).thenReturn(null); when(mockDeployment.getDeployedProcessDefinitions()).thenReturn(null); when(mockDeployment.getDeployedDecisionRequirementsDefinitions()).thenReturn(null); when(mockDeploymentBuilder.deployWithResult()).thenReturn(mockDeployment); // when resourceNames.addAll(Arrays.asList("data", "more-data")); Response response = given() .multiPart("data", "unspecified", createMockDeploymentResourceByteData()) .multiPart("more-data", "unspecified", createMockDeploymentResourceBpmnData()) .multiPart("deployment-name", MockProvider.EXAMPLE_DEPLOYMENT_ID) .multiPart("enable-duplicate-filtering", "true") .expect() .statusCode(Status.OK.getStatusCode()) .when() .post(CREATE_DEPLOYMENT_URL); // then verifyCreatedCmmnDeployment(mockDeployment, response); verify(mockDeploymentBuilder).name(MockProvider.EXAMPLE_DEPLOYMENT_ID); verify(mockDeploymentBuilder).enableDuplicateFiltering(false); }
@Test public void testCreateCompleteBpmnDeployment() throws Exception { // given DeploymentWithDefinitions mockDeployment = MockProvider.createMockDeploymentWithDefinitions(); when(mockDeployment.getDeployedDecisionDefinitions()).thenReturn(null); when(mockDeployment.getDeployedCaseDefinitions()).thenReturn(null); when(mockDeployment.getDeployedDecisionRequirementsDefinitions()).thenReturn(null); when(mockDeploymentBuilder.deployWithResult()).thenReturn(mockDeployment); // when resourceNames.addAll(Arrays.asList("data", "more-data")); Response response = given() .multiPart("data", "unspecified", createMockDeploymentResourceByteData()) .multiPart("more-data", "unspecified", createMockDeploymentResourceBpmnData()) .multiPart("deployment-name", MockProvider.EXAMPLE_DEPLOYMENT_ID) .multiPart("enable-duplicate-filtering", "true") .expect() .statusCode(Status.OK.getStatusCode()) .when() .post(CREATE_DEPLOYMENT_URL); // then verifyCreatedBpmnDeployment(mockDeployment, response); verify(mockDeploymentBuilder).name(MockProvider.EXAMPLE_DEPLOYMENT_ID); verify(mockDeploymentBuilder).enableDuplicateFiltering(false); }
@Override public List<DecisionDefinition> getDeployedDecisionDefinitions() { return deployment.getDeployedDecisionDefinitions(); }
public void testDeployEmptyCaseDefinition() throws Exception { // given empty case model final CmmnModelInstance modelInstance = Cmmn.createEmptyModel(); org.camunda.bpm.model.cmmn.instance.Definitions definitions = modelInstance.newInstance(org.camunda.bpm.model.cmmn.instance.Definitions.class); definitions.setTargetNamespace("http://camunda.org/examples"); modelInstance.setDefinitions(definitions); // when case model is deployed DeploymentWithDefinitions deployment = repositoryService.createDeployment() .addModelInstance("foo.cmmn", modelInstance).deployWithResult(); deploymentIds.add(deployment.getId()); // then no case definition is deployed assertNull(deployment.getDeployedCaseDefinitions()); // and there exist not persisted case definition assertNull(repositoryService.createCaseDefinitionQuery().caseDefinitionResourceName("foo.cmmn").singleResult()); }
@Test public void testDeployEmptyDecisionDefinition() throws Exception { // given empty decision model DmnModelInstance modelInstance = Dmn.createEmptyModel(); Definitions definitions = modelInstance.newInstance(Definitions.class); definitions.setId(DmnModelConstants.DMN_ELEMENT_DEFINITIONS); definitions.setName(DmnModelConstants.DMN_ELEMENT_DEFINITIONS); definitions.setNamespace(DmnModelConstants.CAMUNDA_NS); modelInstance.setDefinitions(definitions); // when decision model is deployed DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().addModelInstance("foo.dmn", modelInstance); DeploymentWithDefinitions deployment = testRule.deploy(deploymentBuilder); // then deployment contains no definitions assertNull(deployment.getDeployedDecisionDefinitions()); assertNull(deployment.getDeployedDecisionRequirementsDefinitions()); // and there are no persisted definitions assertNull(repositoryService.createDecisionDefinitionQuery() .decisionDefinitionResourceName("foo.dmn").singleResult()); }
@Test public void testCreateCompleteDrdDeployment() throws Exception { // given DeploymentWithDefinitions mockDeployment = MockProvider.createMockDeploymentWithDefinitions(); when(mockDeployment.getDeployedCaseDefinitions()).thenReturn(null); when(mockDeployment.getDeployedProcessDefinitions()).thenReturn(null); when(mockDeploymentBuilder.deployWithResult()).thenReturn(mockDeployment); // when resourceNames.addAll(Arrays.asList("data", "more-data")); Response response = given() .multiPart("data", "unspecified", createMockDeploymentResourceByteData()) .multiPart("more-data", "unspecified", createMockDeploymentResourceBpmnData()) .multiPart("deployment-name", MockProvider.EXAMPLE_DEPLOYMENT_ID) .multiPart("enable-duplicate-filtering", "true") .expect() .statusCode(Status.OK.getStatusCode()) .when() .post(CREATE_DEPLOYMENT_URL); // then verifyCreatedDrdDeployment(mockDeployment, response); verify(mockDeploymentBuilder).name(MockProvider.EXAMPLE_DEPLOYMENT_ID); verify(mockDeploymentBuilder).enableDuplicateFiltering(false); }
public void testDeployNonExecutableProcess() throws Exception { // given non executable process definition final BpmnModelInstance modelInstance = Bpmn.createProcess("foo").startEvent().userTask().endEvent().done(); // when process model is deployed DeploymentWithDefinitions deployment = repositoryService.createDeployment() .addModelInstance("foo.bpmn", modelInstance).deployWithResult(); deploymentIds.add(deployment.getId()); // then deployment contains no deployed process definition assertNull(deployment.getDeployedProcessDefinitions()); // and there exist no persisted process definitions assertNull(repositoryService.createProcessDefinitionQuery() .processDefinitionResourceName("foo.bpmn") .singleResult()); }
@Override public List<DecisionRequirementsDefinition> getDeployedDecisionRequirementsDefinitions() { return deployment.getDeployedDecisionRequirementsDefinitions(); } }
@Override public List<CaseDefinition> getDeployedCaseDefinitions() { return deployment.getDeployedCaseDefinitions(); }
public String getName() { return deployment.getName(); }
public Date getDeploymentTime() { return deployment.getDeploymentTime(); }
public String getSource() { return deployment.getSource(); }
public String getTenantId() { return deployment.getTenantId(); }
@Override public List<ProcessDefinition> getDeployedProcessDefinitions() { return deployment.getDeployedProcessDefinitions(); }