private void createDeploymentMock() { Deployment mockDeployment = MockProvider.createMockDeployment(); DeploymentQuery deploymentQueryMock = mock(DeploymentQuery.class); when(deploymentQueryMock.deploymentId(anyString())).thenReturn(deploymentQueryMock); when(deploymentQueryMock.singleResult()).thenReturn(mockDeployment); when(mockRepoService.createDeploymentQuery()).thenReturn(deploymentQueryMock); }
public DeploymentDto getDeployment() { RepositoryService repositoryService = getProcessEngine().getRepositoryService(); Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult(); if (deployment == null) { throw new InvalidRequestException(Status.NOT_FOUND, "Deployment with id '" + deploymentId + "' does not exist"); } return DeploymentDto.fromDeployment(deployment); }
public DeploymentDto getDeployment() { RepositoryService repositoryService = getProcessEngine().getRepositoryService(); Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult(); if (deployment == null) { throw new InvalidRequestException(Status.NOT_FOUND, "Deployment with id '" + deploymentId + "' does not exist"); } return DeploymentDto.fromDeployment(deployment); }
@Test public void testAdditionalParameters() { Map<String, String> queryParameters = getCompleteQueryParameters(); given().queryParams(queryParameters) .expect().statusCode(Status.OK.getStatusCode()) .when().get(DEPLOYMENT_QUERY_URL); // assert query invocation verify(mockedQuery).deploymentName(queryParameters.get("name")); verify(mockedQuery).deploymentNameLike(queryParameters.get("nameLike")); verify(mockedQuery).deploymentId(queryParameters.get("id")); verify(mockedQuery).deploymentSource(queryParameters.get("source")); verify(mockedQuery).list(); }
@Test public void testDeleteNonExistingDeployment() { when(mockDeploymentQuery.deploymentId(NON_EXISTING_DEPLOYMENT_ID)).thenReturn(mockDeploymentQuery); when(mockDeploymentQuery.singleResult()).thenReturn(null); given() .pathParam("id", NON_EXISTING_DEPLOYMENT_ID) .expect() .statusCode(Status.NOT_FOUND.getStatusCode()) .body(containsString("Deployment with id '" + NON_EXISTING_DEPLOYMENT_ID + "' do not exist")) .when() .delete(DEPLOYMENT_URL); }
@Test public void testGetNonExistingSingleDeployment() { when(mockDeploymentQuery.deploymentId(NON_EXISTING_DEPLOYMENT_ID)).thenReturn(mockDeploymentQuery); when(mockDeploymentQuery.singleResult()).thenReturn(null); given().pathParam("id", NON_EXISTING_DEPLOYMENT_ID) .then().expect().statusCode(Status.NOT_FOUND.getStatusCode()) .body(containsString("Deployment with id '" + NON_EXISTING_DEPLOYMENT_ID + "' does not exist")) .when().get(DEPLOYMENT_URL); }
public void testQueryByInvalidDeploymentId() { DeploymentQuery query = repositoryService.createDeploymentQuery().deploymentId("invalid"); assertNull(query.singleResult()); assertEquals(0, query.list().size()); assertEquals(0, query.count()); try { repositoryService.createDeploymentQuery().deploymentId(null); fail(); } catch (ProcessEngineException e) {} }
@Override public void deleteDeployment(String deploymentId, UriInfo uriInfo) { RepositoryService repositoryService = getProcessEngine().getRepositoryService(); Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult(); if (deployment == null) { throw new InvalidRequestException(Status.NOT_FOUND, "Deployment with id '" + deploymentId + "' do not exist"); } boolean cascade = isQueryPropertyEnabled(uriInfo, CASCADE); boolean skipCustomListeners = isQueryPropertyEnabled(uriInfo, "skipCustomListeners"); boolean skipIoMappings = isQueryPropertyEnabled(uriInfo, "skipIoMappings"); repositoryService.deleteDeployment(deploymentId, cascade, skipCustomListeners, skipIoMappings); }
@Override public void deleteDeployment(String deploymentId, UriInfo uriInfo) { RepositoryService repositoryService = getProcessEngine().getRepositoryService(); Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult(); if (deployment == null) { throw new InvalidRequestException(Status.NOT_FOUND, "Deployment with id '" + deploymentId + "' do not exist"); } boolean cascade = isQueryPropertyEnabled(uriInfo, CASCADE); boolean skipCustomListeners = isQueryPropertyEnabled(uriInfo, "skipCustomListeners"); boolean skipIoMappings = isQueryPropertyEnabled(uriInfo, "skipIoMappings"); repositoryService.deleteDeployment(deploymentId, cascade, skipCustomListeners, skipIoMappings); }
public void testQueryByDeploymentId() { DeploymentQuery query = repositoryService.createDeploymentQuery().deploymentId(deploymentOneId); assertNotNull(query.singleResult()); assertEquals(1, query.list().size()); assertEquals(1, query.count()); }
@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)); }
protected void assertProcessDeployed(String processKey, String expectedDeploymentName) { ProcessDefinition processDefinition = repositoryService .createProcessDefinitionQuery() .latestVersion() .processDefinitionKey(processKey) .singleResult(); DeploymentQuery deploymentQuery = repositoryService .createDeploymentQuery() .deploymentId(processDefinition.getDeploymentId()); Assert.assertEquals(expectedDeploymentName, deploymentQuery.singleResult().getName()); }
protected void assertProcessDeployed(String processKey, String expectedDeploymentName) { ProcessDefinition processDefinition = repositoryService .createProcessDefinitionQuery() .latestVersion() .processDefinitionKey(processKey) .singleResult(); DeploymentQuery deploymentQuery = repositoryService .createDeploymentQuery() .deploymentId(processDefinition.getDeploymentId()); Assert.assertEquals(expectedDeploymentName, deploymentQuery.singleResult().getName()); }
protected void assertProcessDeployed(String processKey, String expectedDeploymentName) { ProcessDefinition processDefinition = repositoryService .createProcessDefinitionQuery() .latestVersion() .processDefinitionKey(processKey) .singleResult(); DeploymentQuery deploymentQuery = repositoryService .createDeploymentQuery() .deploymentId(processDefinition.getDeploymentId()); Assert.assertEquals(expectedDeploymentName, deploymentQuery.singleResult().getName()); }
protected void assertProcessDeployed(String processKey, String expectedDeploymentName) { ProcessDefinition processDefinition = repositoryService .createProcessDefinitionQuery() .latestVersion() .processDefinitionKey(processKey) .singleResult(); DeploymentQuery deploymentQuery = repositoryService .createDeploymentQuery() .deploymentId(processDefinition.getDeploymentId()); Assert.assertEquals(expectedDeploymentName, deploymentQuery.singleResult().getName()); }
protected void assertProcessDeployed(String processKey, String expectedDeploymentName) { ProcessDefinition processDefinition = repositoryService .createProcessDefinitionQuery() .latestVersion() .processDefinitionKey(processKey) .singleResult(); DeploymentQuery deploymentQuery = repositoryService .createDeploymentQuery() .deploymentId(processDefinition.getDeploymentId()); Assert.assertEquals(expectedDeploymentName, deploymentQuery.singleResult().getName()); }
@Test public void testDeployProcessArchive() { assertNotNull(processEngine); RepositoryService repositoryService = processEngine.getRepositoryService(); ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery() .processDefinitionKey("invoice-it"); assertEquals(1, processDefinitionQuery.count()); ProcessDefinition processDefinition = processDefinitionQuery.singleResult(); String deploymentId = repositoryService.createDeploymentQuery() .deploymentId(processDefinition.getDeploymentId()) .singleResult() .getId(); List<Resource> deploymentResources = repositoryService.getDeploymentResources(deploymentId); assertEquals(3, deploymentResources.size()); }
@Deployment(resources = {"org/camunda/bpm/engine/test/bpmn/event/message/MessageStartEventTest.testDeployStartAndIntermediateEventWithSameMessageDifferentProcesses2.bpmn"}) public void testDeployStartAndIntermediateEventWithSameMessageDifferentProcessesFirstIntermediateEvent() { ProcessInstance pi = null; try { runtimeService.startProcessInstanceByKey("Process_2"); pi = runtimeService.createProcessInstanceQuery().singleResult(); assertThat(pi.isEnded(), is(false)); String deploymentId = repositoryService .createDeployment() .addClasspathResource( "org/camunda/bpm/engine/test/bpmn/event/message/MessageStartEventTest.testDeployStartAndIntermediateEventWithSameMessageDifferentProcesses.bpmn") .name("deployment2").deploy().getId(); assertThat(repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult(), is(notNullValue())); } finally { // clean db: runtimeService.deleteProcessInstance(pi.getId(), "failure"); List<org.camunda.bpm.engine.repository.Deployment> deployments = repositoryService.createDeploymentQuery().list(); for (org.camunda.bpm.engine.repository.Deployment d : deployments) { repositoryService.deleteDeployment(d.getId(), true); } // Workaround for #CAM-4250: remove process definition of failed // deployment from deployment cache processEngineConfiguration.getDeploymentCache().getProcessDefinitionCache().clear(); } }
@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 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(); }