public String getId() { return deployment.getId(); }
public String getId() { return deployment.getId(); }
public DeploymentDto redeploy(UriInfo uriInfo, RedeploymentDto redeployment) { DeploymentWithDefinitions deployment = null; try { deployment = tryToRedeploy(redeployment); } catch (NotFoundException e) { throw createInvalidRequestException("redeploy", Status.NOT_FOUND, e); } catch (NotValidException e) { throw createInvalidRequestException("redeploy", Status.BAD_REQUEST, e); } DeploymentWithDefinitionsDto deploymentDto = DeploymentWithDefinitionsDto.fromDeployment(deployment); URI uri = uriInfo.getBaseUriBuilder() .path(relativeRootResourcePath) .path(DeploymentRestService.PATH) .path(deployment.getId()) .build(); // GET / deploymentDto.addReflexiveLink(uri, HttpMethod.GET, "self"); return deploymentDto; }
public DeploymentWithDefinitionsDto createDeployment(UriInfo uriInfo, MultipartFormData payload) { DeploymentBuilder deploymentBuilder = extractDeploymentInformation(payload); if(!deploymentBuilder.getResourceNames().isEmpty()) { DeploymentWithDefinitions deployment = deploymentBuilder.deployWithResult(); DeploymentWithDefinitionsDto deploymentDto = DeploymentWithDefinitionsDto.fromDeployment(deployment); URI uri = uriInfo.getBaseUriBuilder() .path(relativeRootResourcePath) .path(DeploymentRestService.PATH) .path(deployment.getId()) .build(); // GET deploymentDto.addReflexiveLink(uri, HttpMethod.GET, "self"); return deploymentDto; } else { throw new InvalidRequestException(Status.BAD_REQUEST, "No deployment resources contained in the form upload."); } }
public DeploymentWithDefinitionsDto createDeployment(UriInfo uriInfo, MultipartFormData payload) { DeploymentBuilder deploymentBuilder = extractDeploymentInformation(payload); if(!deploymentBuilder.getResourceNames().isEmpty()) { DeploymentWithDefinitions deployment = deploymentBuilder.deployWithResult(); DeploymentWithDefinitionsDto deploymentDto = DeploymentWithDefinitionsDto.fromDeployment(deployment); URI uri = uriInfo.getBaseUriBuilder() .path(relativeRootResourcePath) .path(DeploymentRestService.PATH) .path(deployment.getId()) .build(); // GET deploymentDto.addReflexiveLink(uri, HttpMethod.GET, "self"); return deploymentDto; } else { throw new InvalidRequestException(Status.BAD_REQUEST, "No deployment resources contained in the form upload."); } }
@Test public void testResourceBinary() { Date fixedDate = new Date(); ClockUtil.setCurrentTime(fixedDate); String bpmnDeploymentId = testRule.deploy("org/camunda/bpm/engine/test/repository/one.bpmn20.xml").getId(); String dmnDeploymentId = testRule.deploy("org/camunda/bpm/engine/test/repository/one.dmn").getId(); String cmmnDeplymentId = testRule.deploy("org/camunda/bpm/engine/test/repository/one.cmmn").getId(); checkResource(fixedDate, bpmnDeploymentId); checkResource(fixedDate, dmnDeploymentId); checkResource(fixedDate, cmmnDeplymentId); }
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 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; }
@Before public void init() { repositoryService = engineRule.getRepositoryService(); firstDeploymentId = testRule.deploy(DRD_DISH_RESOURCE, DRD_SCORE_RESOURCE).getId(); secondDeploymentId = testRule.deploy(DRD_DISH_RESOURCE).getId(); thirdDeploymentId = testRule.deploy(DRD_XYZ_RESOURCE).getId(); decisionRequirementsDefinitionId = repositoryService .createDecisionRequirementsDefinitionQuery() .decisionRequirementsDefinitionKey("score") .singleResult() .getId(); }
@Test public void testFormsBinaries() { Date fixedDate = new Date(); ClockUtil.setCurrentTime(fixedDate); String deploymentId = testRule.deploy("org/camunda/bpm/engine/test/api/form/DeployedFormsProcess.bpmn20.xml", "org/camunda/bpm/engine/test/api/form/start.form", "org/camunda/bpm/engine/test/api/form/task.form", "org/camunda/bpm/engine/test/api/authorization/renderedFormProcess.bpmn20.xml", "org/camunda/bpm/engine/test/api/authorization/oneTaskCase.cmmn").getId(); List<Resource> deploymentResources = repositoryService.getDeploymentResources(deploymentId); assertEquals(5, deploymentResources.size()); for (Resource resource : deploymentResources) { ResourceEntity entity = (ResourceEntity) resource; checkEntity(fixedDate, entity); } }
@Test @Deployment(resources = SINGLE_CONDITIONAL_START_EVENT_XML) public void testStartInstanceAfterDeleteLatestProcessVersion() { // given a deployed process // deploy second version of the process String deploymentId = testRule.deploy(SINGLE_CONDITIONAL_XML).getId(); org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult(); // delete it repositoryService.deleteDeployment(deployment.getId(), true); // when List<ProcessInstance> conditionInstances = runtimeService .createConditionEvaluation() .setVariable("foo", 1) .evaluateStartConditions(); // then assertEquals(1, conditionInstances.size()); assertNotNull(conditionInstances.get(0)); }
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 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()); }
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()); }
@Test public void shouldDeleteDeployment() { BpmnModelInstance instance = Bpmn.createExecutableProcess("process").startEvent().endEvent().done(); DeploymentWithDefinitions deployment = engineRule.getRepositoryService() .createDeployment() .addModelInstance("foo.bpmn", instance) .deployWithResult(); engineRule.getRepositoryService().deleteDeployment(deployment.getId(), true); long count = engineRule.getRepositoryService().createDeploymentQuery().count(); assertEquals(0, count); }
@Test public void testVersionWithoutConditionAfterDeleteLatestProcessVersionWithCondition() { // given a process testRule.deploy(MODEL_WITHOUT_CONDITION); // deploy second version of the process String deploymentId = testRule.deploy(SINGLE_CONDITIONAL_XML).getId(); org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult(); // delete it repositoryService.deleteDeployment(deployment.getId(), true); thrown.expect(ProcessEngineException.class); thrown.expectMessage("No subscriptions were found during evaluation of the conditional start events."); // when runtimeService .createConditionEvaluation() .setVariable("foo", 1) .evaluateStartConditions(); }
@Test public void testVersionWithoutConditionAfterDeleteLatestProcessVersionWithCondition() { // given a process testRule.deploy(MODEL_WITHOUT_MESSAGE); // deploy second version of the process String deploymentId = testRule.deploy(SINGLE_MESSAGE_START_EVENT_XML).getId(); org.camunda.bpm.engine.repository.Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult(); // delete it repositoryService.deleteDeployment(deployment.getId(), true); thrown.expect(ProcessEngineException.class); thrown.expectMessage("No subscriptions were found during evaluation of the conditional start events."); // when runtimeService .createConditionEvaluation() .setVariable("foo", 1) .evaluateStartConditions(); }
@Test public void testEventSubscriptionAfterDeleteLatestProcessVersion() { // given a deployed process testRule.deploy(SINGLE_MESSAGE_START_EVENT_XML); ProcessDefinition processDefinitionV1 = repositoryService.createProcessDefinitionQuery().singleResult(); assertNotNull(processDefinitionV1); // deploy second version of the process String deploymentId = testRule.deploy(SINGLE_MESSAGE_START_EVENT_XML).getId(); // when repositoryService.deleteDeployment(deploymentId, true); // then ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey(MESSAGE_EVENT_PROCESS).singleResult(); assertEquals(processDefinitionV1.getId(), processDefinition.getId()); EventSubscriptionEntity eventSubscription = (EventSubscriptionEntity) runtimeService.createEventSubscriptionQuery().singleResult(); assertNotNull(eventSubscription); assertEquals(processDefinitionV1.getId(), eventSubscription.getConfiguration()); }