use of org.camunda.bpm.engine.repository.Deployment in project camunda-bpm-platform by camunda.
the class RedeploymentTest method testRedeployFormDifferentDeploymentsAddsNewSource.
public void testRedeployFormDifferentDeploymentsAddsNewSource() {
// given
ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery();
BpmnModelInstance model1 = createProcessWithServiceTask(PROCESS_1_KEY);
// first deployment
Deployment deployment1 = repositoryService.createDeployment().name(DEPLOYMENT_NAME + "-1").addModelInstance(RESOURCE_1_NAME, model1).deploy();
assertEquals(1, repositoryService.getDeploymentResources(deployment1.getId()).size());
verifyQueryResults(query.processDefinitionKey(PROCESS_1_KEY), 1);
// second deployment
BpmnModelInstance model2 = createProcessWithReceiveTask(PROCESS_2_KEY);
Deployment deployment2 = repositoryService.createDeployment().name(DEPLOYMENT_NAME + "-2").addModelInstance(RESOURCE_2_NAME, model2).deploy();
assertEquals(1, repositoryService.getDeploymentResources(deployment2.getId()).size());
verifyQueryResults(query.processDefinitionKey(PROCESS_1_KEY), 1);
verifyQueryResults(query.processDefinitionKey(PROCESS_2_KEY), 1);
// when
BpmnModelInstance model3 = createProcessWithUserTask(PROCESS_3_KEY);
Deployment deployment3 = repositoryService.createDeployment().name(DEPLOYMENT_NAME + "-3").addDeploymentResources(deployment1.getId()).addDeploymentResources(deployment2.getId()).addModelInstance(RESOURCE_3_NAME, model3).deploy();
assertEquals(3, repositoryService.getDeploymentResources(deployment3.getId()).size());
verifyQueryResults(query.processDefinitionKey(PROCESS_1_KEY), 2);
verifyQueryResults(query.processDefinitionKey(PROCESS_2_KEY), 2);
verifyQueryResults(query.processDefinitionKey(PROCESS_3_KEY), 1);
deleteDeployments(deployment1, deployment2, deployment3);
}
use of org.camunda.bpm.engine.repository.Deployment in project camunda-bpm-platform by camunda.
the class RedeploymentTest method testRedeployDeploymentResource.
public void testRedeployDeploymentResource() {
// given
// first deployment
BpmnModelInstance model = createProcessWithServiceTask(PROCESS_KEY);
Deployment deployment1 = repositoryService.createDeployment().name(DEPLOYMENT_NAME).addModelInstance(RESOURCE_NAME, model).deploy();
Resource resource1 = getResourceByName(deployment1.getId(), RESOURCE_NAME);
// second deployment
model = createProcessWithUserTask(PROCESS_KEY);
Deployment deployment2 = repositoryService.createDeployment().name(DEPLOYMENT_NAME).addModelInstance(RESOURCE_NAME, model).deploy();
Resource resource2 = getResourceByName(deployment2.getId(), RESOURCE_NAME);
// when
Deployment deployment3 = repositoryService.createDeployment().name(DEPLOYMENT_NAME).addDeploymentResources(deployment1.getId()).deploy();
// then
Resource resource3 = getResourceByName(deployment3.getId(), RESOURCE_NAME);
assertNotNull(resource3);
// id
assertNotNull(resource3.getId());
assertFalse(resource1.getId().equals(resource3.getId()));
// deployment id
assertEquals(deployment3.getId(), resource3.getDeploymentId());
// name
assertEquals(resource1.getName(), resource3.getName());
// bytes
byte[] bytes1 = ((ResourceEntity) resource1).getBytes();
byte[] bytes2 = ((ResourceEntity) resource2).getBytes();
byte[] bytes3 = ((ResourceEntity) resource3).getBytes();
assertTrue(Arrays.equals(bytes1, bytes3));
assertFalse(Arrays.equals(bytes2, bytes3));
deleteDeployments(deployment1, deployment2, deployment3);
}
use of org.camunda.bpm.engine.repository.Deployment in project camunda-bpm-platform by camunda.
the class RedeploymentTest method testSameDeploymentResourceByName.
public void testSameDeploymentResourceByName() {
// given
ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery();
BpmnModelInstance model1 = createProcessWithServiceTask(PROCESS_1_KEY);
BpmnModelInstance model2 = createProcessWithUserTask(PROCESS_2_KEY);
// first deployment
Deployment deployment1 = repositoryService.createDeployment().name(DEPLOYMENT_NAME).addModelInstance(RESOURCE_1_NAME, model1).addModelInstance(RESOURCE_2_NAME, model2).deploy();
verifyQueryResults(query.processDefinitionKey(PROCESS_1_KEY), 1);
verifyQueryResults(query.processDefinitionKey(PROCESS_2_KEY), 1);
// second deployment
model1 = createProcessWithScriptTask(PROCESS_1_KEY);
model2 = createProcessWithReceiveTask(PROCESS_2_KEY);
Deployment deployment2 = repositoryService.createDeployment().name(DEPLOYMENT_NAME).addModelInstance(RESOURCE_1_NAME, model1).addModelInstance(RESOURCE_2_NAME, model2).deploy();
verifyQueryResults(query.processDefinitionKey(PROCESS_1_KEY), 2);
verifyQueryResults(query.processDefinitionKey(PROCESS_2_KEY), 2);
// when
Deployment deployment3 = repositoryService.createDeployment().name(DEPLOYMENT_NAME).addDeploymentResourceByName(deployment1.getId(), RESOURCE_1_NAME).addDeploymentResourcesByName(deployment1.getId(), Arrays.asList(RESOURCE_1_NAME)).deploy();
// then
verifyQueryResults(query.processDefinitionKey(PROCESS_1_KEY), 3);
verifyQueryResults(query.processDefinitionKey(PROCESS_2_KEY), 2);
deleteDeployments(deployment1, deployment2, deployment3);
}
use of org.camunda.bpm.engine.repository.Deployment in project camunda-bpm-platform by camunda.
the class RedeploymentTest method testRedeployOneAndMultipleDeploymentResourcesByName.
public void testRedeployOneAndMultipleDeploymentResourcesByName() {
// given
ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery();
BpmnModelInstance model1 = createProcessWithServiceTask(PROCESS_1_KEY);
BpmnModelInstance model2 = createProcessWithUserTask(PROCESS_2_KEY);
BpmnModelInstance model3 = createProcessWithScriptTask(PROCESS_3_KEY);
// first deployment
Deployment deployment1 = repositoryService.createDeployment().name(DEPLOYMENT_NAME).addModelInstance(RESOURCE_1_NAME, model1).addModelInstance(RESOURCE_2_NAME, model2).addModelInstance(RESOURCE_3_NAME, model3).deploy();
verifyQueryResults(query.processDefinitionKey(PROCESS_1_KEY), 1);
verifyQueryResults(query.processDefinitionKey(PROCESS_2_KEY), 1);
verifyQueryResults(query.processDefinitionKey(PROCESS_3_KEY), 1);
// second deployment
model1 = createProcessWithScriptTask(PROCESS_1_KEY);
model2 = createProcessWithReceiveTask(PROCESS_2_KEY);
model3 = createProcessWithUserTask(PROCESS_3_KEY);
Deployment deployment2 = repositoryService.createDeployment().name(DEPLOYMENT_NAME).addModelInstance(RESOURCE_1_NAME, model1).addModelInstance(RESOURCE_2_NAME, model2).addModelInstance(RESOURCE_3_NAME, model3).deploy();
verifyQueryResults(query.processDefinitionKey(PROCESS_1_KEY), 2);
verifyQueryResults(query.processDefinitionKey(PROCESS_2_KEY), 2);
verifyQueryResults(query.processDefinitionKey(PROCESS_3_KEY), 2);
// when
Deployment deployment3 = repositoryService.createDeployment().name(DEPLOYMENT_NAME).addDeploymentResourceByName(deployment1.getId(), RESOURCE_1_NAME).addDeploymentResourcesByName(deployment1.getId(), Arrays.asList(RESOURCE_2_NAME, RESOURCE_3_NAME)).deploy();
// then
verifyQueryResults(query.processDefinitionKey(PROCESS_1_KEY), 3);
verifyQueryResults(query.processDefinitionKey(PROCESS_2_KEY), 3);
verifyQueryResults(query.processDefinitionKey(PROCESS_3_KEY), 3);
deleteDeployments(deployment1, deployment2, deployment3);
}
use of org.camunda.bpm.engine.repository.Deployment in project camunda-bpm-platform by camunda.
the class DeleteProcessDefinitionTest method testDeleteProcessDefinitionAndRedeploy.
@Test
public void testDeleteProcessDefinitionAndRedeploy() {
// given a deployment with two process definitions in one xml model file
deployment = repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/repository/twoProcesses.bpmn20.xml").deploy();
ProcessDefinition processDefinitionOne = repositoryService.createProcessDefinitionQuery().processDefinitionKey("one").singleResult();
// one is deleted from the deployment
repositoryService.deleteProcessDefinition(processDefinitionOne.getId());
// when the process definition is redeployed
Deployment deployment2 = repositoryService.createDeployment().name(DEPLOYMENT_NAME).addDeploymentResources(deployment.getId()).deploy();
// then there should exist three process definitions
// two of the redeployment and the remaining one
assertEquals(3, repositoryService.createProcessDefinitionQuery().count());
// clean up
repositoryService.deleteDeployment(deployment2.getId(), true);
}
Aggregations