use of org.jbpm.services.api.model.DeploymentUnit in project jbpm by kiegroup.
the class DeploymentSynchronizer method onDeploy.
@Override
public void onDeploy(DeploymentEvent event) {
if (event == null || event.getDeployedUnit() == null) {
return;
}
DeploymentUnit unit = event.getDeployedUnit().getDeploymentUnit();
if (!entries.containsKey(unit.getIdentifier()) && event.getDeployedUnit().isActive()) {
try {
deploymentStore.enableDeploymentUnit(unit);
// when successfully stored add it to local store
entries.put(unit.getIdentifier(), unit);
logger.info("Deployment unit {} stored successfully", unit.getIdentifier());
} catch (Exception e) {
if (isCausedByConstraintViolation(e)) {
logger.info("Deployment {} already stored in deployment store", unit);
} else {
logger.error("Unable to store deployment {} in deployment store due to {}", unit, e.getMessage());
}
}
}
}
use of org.jbpm.services.api.model.DeploymentUnit in project jbpm by kiegroup.
the class DeploymentStoreTest method testEnableAndGetAndDisableActiveDeployments.
@Test
public void testEnableAndGetAndDisableActiveDeployments() {
Collection<DeploymentUnit> enabled = store.getEnabledDeploymentUnits();
assertNotNull(enabled);
assertEquals(0, enabled.size());
KModuleDeploymentUnit unit = new KModuleDeploymentUnit("org.jbpm", "test", "1.0");
store.enableDeploymentUnit(unit);
enabled = store.getEnabledDeploymentUnits();
assertNotNull(enabled);
assertEquals(1, enabled.size());
store.disableDeploymentUnit(unit);
enabled = store.getEnabledDeploymentUnits();
assertNotNull(enabled);
assertEquals(0, enabled.size());
}
use of org.jbpm.services.api.model.DeploymentUnit in project jbpm by kiegroup.
the class DeploymentStoreTest method testEnableAndGetByDateActiveDeployments.
@Test
public void testEnableAndGetByDateActiveDeployments() {
Collection<DeploymentUnit> enabled = store.getEnabledDeploymentUnits();
assertNotNull(enabled);
assertEquals(0, enabled.size());
Date date = new Date();
KModuleDeploymentUnit unit = new KModuleDeploymentUnit("org.jbpm", "test", "1.0");
store.enableDeploymentUnit(unit);
unit = new KModuleDeploymentUnit("org.jbpm", "prod", "1.0");
store.enableDeploymentUnit(unit);
Collection<DeploymentUnit> unitsEnabled = new HashSet<DeploymentUnit>();
Collection<DeploymentUnit> unitsDisabled = new HashSet<DeploymentUnit>();
Collection<DeploymentUnit> unitsActivated = new HashSet<DeploymentUnit>();
Collection<DeploymentUnit> unitsDeactivated = new HashSet<DeploymentUnit>();
store.getDeploymentUnitsByDate(date, unitsEnabled, unitsDisabled, unitsActivated, unitsDeactivated);
assertNotNull(unitsEnabled);
assertEquals(2, unitsEnabled.size());
assertNotNull(unitsDisabled);
assertEquals(0, unitsDisabled.size());
date = new Date();
store.disableDeploymentUnit(unit);
// verify
unitsEnabled.clear();
unitsDisabled.clear();
unitsActivated.clear();
unitsDeactivated.clear();
store.getDeploymentUnitsByDate(date, unitsEnabled, unitsDisabled, unitsActivated, unitsDeactivated);
assertNotNull(unitsEnabled);
assertEquals(0, unitsEnabled.size());
assertNotNull(unitsDisabled);
assertEquals(1, unitsDisabled.size());
}
use of org.jbpm.services.api.model.DeploymentUnit in project jbpm by kiegroup.
the class ClientEjbTimerServiceTest method cleanup.
@After
public void cleanup() {
if (processInstanceId != null) {
// let's abort process instance to leave the system in clear state
processService.abortProcessInstance(processInstanceId);
}
cleanupSingletonSessionId();
if (units != null && !units.isEmpty()) {
for (DeploymentUnit unit : units) {
deploymentService.undeploy(unit);
}
units.clear();
}
close();
}
use of org.jbpm.services.api.model.DeploymentUnit in project jbpm by kiegroup.
the class SupportProcessBaseTest method testSupportProcess.
@Test
public void testSupportProcess() {
DeploymentUnit deploymentUnitSupport = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnitSupport);
units.add(deploymentUnitSupport);
Map<String, Object> params = new HashMap<String, Object>();
params.put("customer", "polymita");
RuntimeManager managerSupport = deploymentService.getRuntimeManager(deploymentUnitSupport.getIdentifier());
assertNotNull(managerSupport);
int currentNumberOfEvents = DebugTaskLifeCycleEventListener.getEventCounter();
assertEquals(0, currentNumberOfEvents);
RuntimeEngine engine = managerSupport.getRuntimeEngine(EmptyContext.get());
assertNotNull(engine);
ProcessInstance pI = engine.getKieSession().startProcess("support.process", params);
assertNotNull(pI);
TaskService taskService = engine.getTaskService();
currentNumberOfEvents = DebugTaskLifeCycleEventListener.getEventCounter();
assertEquals(2, currentNumberOfEvents);
// Configure Release
List<TaskSummary> tasksAssignedToSalaboy = taskService.getTasksAssignedAsPotentialOwner("salaboy", "en-UK");
assertEquals(1, tasksAssignedToSalaboy.size());
assertEquals("Create Support", tasksAssignedToSalaboy.get(0).getName());
TaskSummary createSupportTask = tasksAssignedToSalaboy.get(0);
taskService.start(createSupportTask.getId(), "salaboy");
currentNumberOfEvents = DebugTaskLifeCycleEventListener.getEventCounter();
assertEquals(4, currentNumberOfEvents);
Map<String, Object> taskContent = ((InternalTaskService) taskService).getTaskContent(createSupportTask.getId());
assertEquals("polymita", taskContent.get("input_customer"));
Map<String, String> taskOutputMappings = bpmn2Service.getTaskOutputMappings(deploymentUnitSupport.getIdentifier(), "support.process", createSupportTask.getName());
assertEquals(1, taskOutputMappings.size());
assertEquals("output_customer", taskOutputMappings.keySet().iterator().next());
Map<String, Object> output = new HashMap<String, Object>();
output.put("output_customer", "polymita/redhat");
taskService.complete(createSupportTask.getId(), "salaboy", output);
currentNumberOfEvents = DebugTaskLifeCycleEventListener.getEventCounter();
assertEquals(8, currentNumberOfEvents);
tasksAssignedToSalaboy = taskService.getTasksAssignedAsPotentialOwner("salaboy", "en-UK");
assertEquals(1, tasksAssignedToSalaboy.size());
assertEquals("Resolve Support", tasksAssignedToSalaboy.get(0).getName());
TaskSummary resolveSupportTask = tasksAssignedToSalaboy.get(0);
taskService.start(resolveSupportTask.getId(), "salaboy");
currentNumberOfEvents = DebugTaskLifeCycleEventListener.getEventCounter();
assertEquals(10, currentNumberOfEvents);
taskService.complete(resolveSupportTask.getId(), "salaboy", null);
currentNumberOfEvents = DebugTaskLifeCycleEventListener.getEventCounter();
assertEquals(14, currentNumberOfEvents);
tasksAssignedToSalaboy = taskService.getTasksAssignedAsPotentialOwner("salaboy", "en-UK");
assertEquals(1, tasksAssignedToSalaboy.size());
assertEquals("Notify Customer", tasksAssignedToSalaboy.get(0).getName());
TaskSummary notifySupportTask = tasksAssignedToSalaboy.get(0);
taskService.start(notifySupportTask.getId(), "salaboy");
currentNumberOfEvents = DebugTaskLifeCycleEventListener.getEventCounter();
assertEquals(16, currentNumberOfEvents);
output = new HashMap<String, Object>();
output.put("output_solution", "solved today");
taskService.complete(notifySupportTask.getId(), "salaboy", output);
currentNumberOfEvents = DebugTaskLifeCycleEventListener.getEventCounter();
assertEquals(18, currentNumberOfEvents);
}
Aggregations