@Override public List<DecisionRequirementsDefinition> getDeployedDecisionRequirementsDefinitions() { return deployment.getDeployedDecisionRequirementsDefinitions(); } }
@Override public List<DecisionRequirementsDefinition> getDeployedDecisionRequirementsDefinitions() { return deployment.getDeployedDecisionRequirementsDefinitions(); } }
List<DecisionRequirementsDefinition> deployedDecisionRequirementsDefinitions = deployment.getDeployedDecisionRequirementsDefinitions(); if (deployedDecisionRequirementsDefinitions != null) { dto.deployedDecisionRequirementsDefinitions = new HashMap<String, DecisionRequirementsDefinitionDto>();
List<DecisionRequirementsDefinition> deployedDecisionRequirementsDefinitions = deployment.getDeployedDecisionRequirementsDefinitions(); if (deployedDecisionRequirementsDefinitions != null) { dto.deployedDecisionRequirementsDefinitions = new HashMap<String, DecisionRequirementsDefinitionDto>();
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<DecisionRequirementsDefinition> getDeployedDecisionRequirementsDefinitions() { return deployment.getDeployedDecisionRequirementsDefinitions(); } }
@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 testCreateDeploymentWithNonExecutableProcess() throws Exception { // given DeploymentWithDefinitions mockDeployment = MockProvider.createMockDeploymentWithDefinitions(); when(mockDeployment.getDeployedDecisionDefinitions()).thenReturn(null); 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", createMockDeploymentResourceBpmnDataNonExecutableProcess()) .multiPart("deployment-name", MockProvider.EXAMPLE_DEPLOYMENT_ID) .multiPart("enable-duplicate-filtering", "true") .expect() .statusCode(Status.OK.getStatusCode()) .when() .post(CREATE_DEPLOYMENT_URL); // then verifyCreatedEmptyDeployment(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); }
@Test public void testDeployAndGetDRDDefinition() throws Exception { // when decision requirement graph is deployed DeploymentWithDefinitions deployment = testRule.deploy(DRD_SCORE_RESOURCE); // then deployment contains definitions List<DecisionDefinition> deployedDecisionDefinitions = deployment.getDeployedDecisionDefinitions(); assertEquals(2, deployedDecisionDefinitions.size()); List<DecisionRequirementsDefinition> deployedDecisionRequirementsDefinitions = deployment.getDeployedDecisionRequirementsDefinitions(); assertEquals(1, deployedDecisionRequirementsDefinitions.size()); assertNull(deployment.getDeployedProcessDefinitions()); assertNull(deployment.getDeployedCaseDefinitions()); // and persisted definitions are equal to deployed definitions DecisionRequirementsDefinition persistedDecisionRequirementsDefinition = repositoryService.createDecisionRequirementsDefinitionQuery() .decisionRequirementsDefinitionResourceName(DRD_SCORE_RESOURCE).singleResult(); assertEquals(persistedDecisionRequirementsDefinition.getId(), deployedDecisionRequirementsDefinitions.get(0).getId()); List<DecisionDefinition> persistedDecisionDefinitions = repositoryService.createDecisionDefinitionQuery().decisionDefinitionResourceName(DRD_SCORE_RESOURCE).list(); assertEquals(deployedDecisionDefinitions.size(), persistedDecisionDefinitions.size()); }
public void testDeployAndGetCaseDefinition() throws Exception { // given case model final CmmnModelInstance modelInstance = createCmmnModelInstance(); // when case model is deployed DeploymentWithDefinitions deployment = repositoryService.createDeployment() .addModelInstance("foo.cmmn", modelInstance).deployWithResult(); deploymentIds.add(deployment.getId()); // then deployment contains deployed case definition List<CaseDefinition> deployedCaseDefinitions = deployment.getDeployedCaseDefinitions(); assertEquals(1, deployedCaseDefinitions.size()); assertNull(deployment.getDeployedProcessDefinitions()); assertNull(deployment.getDeployedDecisionDefinitions()); assertNull(deployment.getDeployedDecisionRequirementsDefinitions()); // and persisted case definition is equal to deployed case definition CaseDefinition persistedCaseDefinition = repositoryService.createCaseDefinitionQuery().caseDefinitionResourceName("foo.cmmn").singleResult(); assertEquals(persistedCaseDefinition.getId(), deployedCaseDefinitions.get(0).getId()); }
public void testDeployAndGetProcessDefinition() throws Exception { // given process model final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess("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 deployed process definitions List<ProcessDefinition> deployedProcessDefinitions = deployment.getDeployedProcessDefinitions(); assertEquals(1, deployedProcessDefinitions.size()); assertNull(deployment.getDeployedCaseDefinitions()); assertNull(deployment.getDeployedDecisionDefinitions()); assertNull(deployment.getDeployedDecisionRequirementsDefinitions()); // and persisted process definition is equal to deployed process definition ProcessDefinition persistedProcDef = repositoryService.createProcessDefinitionQuery() .processDefinitionResourceName("foo.bpmn") .singleResult(); assertEquals(persistedProcDef.getId(), deployedProcessDefinitions.get(0).getId()); }
@Test public void testDeployAndGetDecisionDefinition() throws Exception { // given decision model DmnModelInstance dmnModelInstance = createDmnModelInstance(); // when decision model is deployed DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().addModelInstance("foo.dmn", dmnModelInstance); DeploymentWithDefinitions deployment = testRule.deploy(deploymentBuilder); // then deployment contains definition List<DecisionDefinition> deployedDecisionDefinitions = deployment.getDeployedDecisionDefinitions(); assertEquals(1, deployedDecisionDefinitions.size()); assertNull(deployment.getDeployedDecisionRequirementsDefinitions()); assertNull(deployment.getDeployedProcessDefinitions()); assertNull(deployment.getDeployedCaseDefinitions()); // and persisted definition are equal to deployed definition DecisionDefinition persistedDecisionDef = repositoryService.createDecisionDefinitionQuery() .decisionDefinitionResourceName("foo.dmn").singleResult(); assertEquals(persistedDecisionDef.getId(), deployedDecisionDefinitions.get(0).getId()); }
@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 testDeployAndGetDRDDefinition() throws Exception { // when decision requirement graph is deployed DeploymentWithDefinitions deployment = testRule.deploy(DRD_SCORE_RESOURCE); // then deployment contains definitions List<DecisionDefinition> deployedDecisionDefinitions = deployment.getDeployedDecisionDefinitions(); assertEquals(2, deployedDecisionDefinitions.size()); List<DecisionRequirementsDefinition> deployedDecisionRequirementsDefinitions = deployment.getDeployedDecisionRequirementsDefinitions(); assertEquals(1, deployedDecisionRequirementsDefinitions.size()); assertNull(deployment.getDeployedProcessDefinitions()); assertNull(deployment.getDeployedCaseDefinitions()); // and persisted definitions are equal to deployed definitions DecisionRequirementsDefinition persistedDecisionRequirementsDefinition = repositoryService.createDecisionRequirementsDefinitionQuery() .decisionRequirementsDefinitionResourceName(DRD_SCORE_RESOURCE).singleResult(); assertEquals(persistedDecisionRequirementsDefinition.getId(), deployedDecisionRequirementsDefinitions.get(0).getId()); List<DecisionDefinition> persistedDecisionDefinitions = repositoryService.createDecisionDefinitionQuery().decisionDefinitionResourceName(DRD_SCORE_RESOURCE).list(); assertEquals(deployedDecisionDefinitions.size(), persistedDecisionDefinitions.size()); }
public void testDeployAndGetCaseDefinition() throws Exception { // given case model final CmmnModelInstance modelInstance = createCmmnModelInstance(); // when case model is deployed DeploymentWithDefinitions deployment = repositoryService.createDeployment() .addModelInstance("foo.cmmn", modelInstance).deployWithResult(); deploymentIds.add(deployment.getId()); // then deployment contains deployed case definition List<CaseDefinition> deployedCaseDefinitions = deployment.getDeployedCaseDefinitions(); assertEquals(1, deployedCaseDefinitions.size()); assertNull(deployment.getDeployedProcessDefinitions()); assertNull(deployment.getDeployedDecisionDefinitions()); assertNull(deployment.getDeployedDecisionRequirementsDefinitions()); // and persisted case definition is equal to deployed case definition CaseDefinition persistedCaseDefinition = repositoryService.createCaseDefinitionQuery().caseDefinitionResourceName("foo.cmmn").singleResult(); assertEquals(persistedCaseDefinition.getId(), deployedCaseDefinitions.get(0).getId()); }
@Test public void testDeployAndGetDecisionDefinition() throws Exception { // given decision model DmnModelInstance dmnModelInstance = createDmnModelInstance(); // when decision model is deployed DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().addModelInstance("foo.dmn", dmnModelInstance); DeploymentWithDefinitions deployment = testRule.deploy(deploymentBuilder); // then deployment contains definition List<DecisionDefinition> deployedDecisionDefinitions = deployment.getDeployedDecisionDefinitions(); assertEquals(1, deployedDecisionDefinitions.size()); assertNull(deployment.getDeployedDecisionRequirementsDefinitions()); assertNull(deployment.getDeployedProcessDefinitions()); assertNull(deployment.getDeployedCaseDefinitions()); // and persisted definition are equal to deployed definition DecisionDefinition persistedDecisionDef = repositoryService.createDecisionDefinitionQuery() .decisionDefinitionResourceName("foo.dmn").singleResult(); assertEquals(persistedDecisionDef.getId(), deployedDecisionDefinitions.get(0).getId()); }
public void testDeployAndGetProcessDefinition() throws Exception { // given process model final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess("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 deployed process definitions List<ProcessDefinition> deployedProcessDefinitions = deployment.getDeployedProcessDefinitions(); assertEquals(1, deployedProcessDefinitions.size()); assertNull(deployment.getDeployedCaseDefinitions()); assertNull(deployment.getDeployedDecisionDefinitions()); assertNull(deployment.getDeployedDecisionRequirementsDefinitions()); // and persisted process definition is equal to deployed process definition ProcessDefinition persistedProcDef = repositoryService.createProcessDefinitionQuery() .processDefinitionResourceName("foo.bpmn") .singleResult(); assertEquals(persistedProcDef.getId(), deployedProcessDefinitions.get(0).getId()); }
@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()); }