use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.
the class DeploymentEventsTest method testDeploymentEvents.
/**
* Test create, update and delete events of deployment entities.
*/
public void testDeploymentEvents() throws Exception {
Deployment deployment = null;
try {
listener.clearEventsReceived();
deployment = repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/api/runtime/oneTaskProcess.bpmn20.xml").deploy();
assertThat(deployment).isNotNull();
// Check create-event
assertThat(listener.getEventsReceived()).hasSize(2);
assertThat(listener.getEventsReceived().get(0)).isInstanceOf(ActivitiEntityEvent.class);
ActivitiEntityEvent event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
assertThat(event.getType()).isEqualTo(ActivitiEventType.ENTITY_CREATED);
assertThat(((Deployment) event.getEntity()).getId()).isEqualTo(deployment.getId());
assertThat(listener.getEventsReceived().get(1)).isInstanceOf(ActivitiEntityEvent.class);
event = (ActivitiEntityEvent) listener.getEventsReceived().get(1);
assertThat(event.getType()).isEqualTo(ActivitiEventType.ENTITY_INITIALIZED);
assertThat(((Deployment) event.getEntity()).getId()).isEqualTo(deployment.getId());
listener.clearEventsReceived();
// Check update event when category is updated
repositoryService.setDeploymentCategory(deployment.getId(), "test");
assertThat(listener.getEventsReceived()).hasSize(1);
assertThat(listener.getEventsReceived().get(0)).isInstanceOf(ActivitiEntityEvent.class);
event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
assertThat(event.getType()).isEqualTo(ActivitiEventType.ENTITY_UPDATED);
assertThat(((Deployment) event.getEntity()).getId()).isEqualTo(deployment.getId());
assertThat(((Deployment) event.getEntity()).getCategory()).isEqualTo("test");
listener.clearEventsReceived();
// Check delete event when category is updated
repositoryService.deleteDeployment(deployment.getId(), true);
assertThat(listener.getEventsReceived()).hasSize(1);
assertThat(listener.getEventsReceived().get(0)).isInstanceOf(ActivitiEntityEvent.class);
event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
assertThat(event.getType()).isEqualTo(ActivitiEventType.ENTITY_DELETED);
assertThat(((Deployment) event.getEntity()).getId()).isEqualTo(deployment.getId());
listener.clearEventsReceived();
} finally {
if (deployment != null && repositoryService.createDeploymentQuery().deploymentId(deployment.getId()).count() > 0) {
repositoryService.deleteDeployment(deployment.getId(), true);
}
}
}
use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.
the class CallActivityTest method testInstantiateSuspendedChildProcess.
public void testInstantiateSuspendedChildProcess() throws Exception {
BpmnModel childBpmnModel = loadBPMNModel(CHILD_PROCESS_RESOURCE);
Deployment childDeployment = processEngine.getRepositoryService().createDeployment().name("childProcessDeployment").addBpmnModel("childProcess.bpmn20.xml", childBpmnModel).deploy();
suspendProcessDefinitions(childDeployment);
assertThatExceptionOfType(ActivitiException.class).isThrownBy(() -> runtimeService.startProcessInstanceByKey("childProcess")).withMessageContaining("Cannot start process instance. Process definition Child Process");
}
use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.
the class CallActivityTest method testInstantiateSuspendedProcessByMessage.
public void testInstantiateSuspendedProcessByMessage() throws Exception {
BpmnModel messageTriggeredBpmnModel = loadBPMNModel(MESSAGE_TRIGGERED_PROCESS_RESOURCE);
Deployment messageTriggeredBpmnDeployment = processEngine.getRepositoryService().createDeployment().name("messageTriggeredProcessDeployment").addBpmnModel("messageTriggered.bpmn20.xml", messageTriggeredBpmnModel).deploy();
suspendProcessDefinitions(messageTriggeredBpmnDeployment);
assertThatExceptionOfType(ActivitiException.class).isThrownBy(() -> runtimeService.startProcessInstanceByMessage("TRIGGER_PROCESS_MESSAGE")).withMessageContaining("Cannot start process instance. Process definition Message Triggered Process");
}
use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.
the class ApplicationUpgradeIT method should_updateDeploymentVersion_when_onlyProjectManifestVersionIsSet.
@Test
public void should_updateDeploymentVersion_when_onlyProjectManifestVersionIsSet() {
ProjectManifest projectManifest = new ProjectManifest();
projectManifest.setVersion("2");
Deployment deployment1 = repositoryService.createDeployment().setProjectManifest(projectManifest).enableDuplicateFiltering().name("deploymentName").deploy();
deploymentIds.add(deployment1.getId());
assertThat(deployment1.getVersion()).isEqualTo(1);
assertThat(deployment1.getProjectReleaseVersion()).isEqualTo("2");
projectManifest.setVersion("17");
Deployment deployment2 = repositoryService.createDeployment().setProjectManifest(projectManifest).setEnforcedAppVersion(2).enableDuplicateFiltering().name("deploymentName").deploy();
deploymentIds.add(deployment2.getId());
assertThat(deployment2.getVersion()).isEqualTo(2);
assertThat(deployment2.getProjectReleaseVersion()).isEqualTo("17");
}
use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.
the class ApplicationUpgradeIT method should_noUpgradeTakePlace_when_enforcedAppVersionAndProjectManifestVersionAreNotSet.
@Test
public void should_noUpgradeTakePlace_when_enforcedAppVersionAndProjectManifestVersionAreNotSet() {
Deployment deployment1 = repositoryService.createDeployment().enableDuplicateFiltering().name("deploymentName").deploy();
deploymentIds.add(deployment1.getId());
assertThat(deployment1.getVersion()).isEqualTo(1);
Deployment deployment2 = repositoryService.createDeployment().enableDuplicateFiltering().name("deploymentName").deploy();
deploymentIds.add(deployment2.getId());
assertThat(deployment2.getVersion()).isEqualTo(1);
}
Aggregations