use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.
the class UserTaskAdminServiceImplTest method prepare.
@Before
public void prepare() {
configureServices();
logger.debug("Preparing kjar");
KieServices ks = KieServices.Factory.get();
// version 1 of kjar
ReleaseId releaseId = ks.newReleaseId(ADMIN_GROUP_ID, ADMIN_ARTIFACT_ID, ADMIN_VERSION_V1);
List<String> processes = new ArrayList<String>();
processes.add("repo/processes/general/humanTask.bpmn");
InternalKieModule kJar1 = createKieJar(ks, releaseId, processes);
File pom = new File("target/admin", "pom.xml");
pom.getParentFile().mkdir();
try {
FileOutputStream fs = new FileOutputStream(pom);
fs.write(getPom(releaseId).getBytes());
fs.close();
} catch (Exception e) {
}
KieMavenRepository repository = getKieMavenRepository();
repository.installArtifact(releaseId, kJar1, pom);
userTaskAdminService = new UserTaskAdminServiceImpl();
((UserTaskAdminServiceImpl) userTaskAdminService).setUserTaskService(userTaskService);
((UserTaskAdminServiceImpl) userTaskAdminService).setRuntimeDataService(runtimeDataService);
((UserTaskAdminServiceImpl) userTaskAdminService).setIdentityProvider(identityProvider);
((UserTaskAdminServiceImpl) userTaskAdminService).setCommandService(new TransactionalCommandService(emf));
// now let's deploy to runtime both kjars
deploymentUnit = new KModuleDeploymentUnit(ADMIN_GROUP_ID, ADMIN_ARTIFACT_ID, ADMIN_VERSION_V1);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
// set user to administrator so it will be allowed to do operations
identityProvider.setName("Administrator");
identityProvider.setRoles(Collections.singletonList(""));
}
use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.
the class BPMN2DataServicesTest method testHumanTaskProcessBeforeAndAfterUndeploy.
@Test
public void testHumanTaskProcessBeforeAndAfterUndeploy() throws IOException {
assertNotNull(deploymentService);
DeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
String processId = "org.jbpm.writedocument";
ProcessDefinition procDef = bpmn2Service.getProcessDefinition(deploymentUnit.getIdentifier(), processId);
assertNotNull(procDef);
assertEquals(procDef.getId(), "org.jbpm.writedocument");
assertEquals(procDef.getName(), "humanTaskSample");
assertEquals(procDef.getKnowledgeType(), "PROCESS");
assertEquals(procDef.getPackageName(), "defaultPackage");
assertEquals(procDef.getType(), "RuleFlow");
assertEquals(procDef.getVersion(), "3");
// now let's undeploy the unit
deploymentService.undeploy(deploymentUnit);
try {
bpmn2Service.getProcessDefinition(deploymentUnit.getIdentifier(), processId);
fail("DeploymentNotFoundException was not thrown");
} catch (DeploymentNotFoundException e) {
// expected
}
}
use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.
the class BPMN2DataServicesTest method testGetProcessDefinitionUndeployedDeploymentUnit.
@Test(expected = DeploymentNotFoundException.class)
public void testGetProcessDefinitionUndeployedDeploymentUnit() throws IOException {
assertNotNull(deploymentService);
DeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
deploymentService.undeploy(deploymentUnit);
bpmn2Service.getProcessDefinition(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
}
use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.
the class ClassloaderKModuleDeploymentServiceTest method testDeploymentOfProcesses.
@Test
public void testDeploymentOfProcesses() throws Exception {
assertNotNull(deploymentService);
KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION, "defaultKieBase", "defaultKieSession");
deploymentUnit.setStrategy(RuntimeStrategy.PER_REQUEST);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
DeployedUnit deployed = deploymentService.getDeployedUnit(deploymentUnit.getIdentifier());
assertNotNull(deployed);
assertNotNull(deployed.getDeploymentUnit());
assertNotNull(deployed.getRuntimeManager());
assertEquals("org.jbpm.test:jbpm-module:1.0:defaultKieBase:defaultKieSession", deployed.getDeploymentUnit().getIdentifier());
assertNotNull(runtimeDataService);
Collection<ProcessDefinition> processes = runtimeDataService.getProcesses(new QueryContext());
assertNotNull(processes);
assertEquals(1, processes.size());
RuntimeManager manager = deploymentService.getRuntimeManager(deploymentUnit.getIdentifier());
assertNotNull(manager);
RuntimeEngine engine = manager.getRuntimeEngine(EmptyContext.get());
assertNotNull(engine);
Class<?> clazz = Class.forName("org.jbpm.test.Person", true, ((InternalRuntimeManager) manager).getEnvironment().getClassLoader());
Object instance = clazz.newInstance();
Map<String, Object> params = new HashMap<String, Object>();
params.put("person", instance);
ProcessInstance processInstance = engine.getKieSession().startProcess("testkjar.src.main.resources.process", params);
assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
List<TaskSummary> tasks = engine.getTaskService().getTasksOwned("salaboy", "en-UK");
assertEquals(1, tasks.size());
long taskId = tasks.get(0).getId();
Map<String, Object> content = ((InternalTaskService) engine.getTaskService()).getTaskContent(taskId);
assertTrue(content.containsKey("personIn"));
Object person = content.get("personIn");
assertEquals(clazz.getName(), person.getClass().getName());
engine.getTaskService().start(taskId, "salaboy");
Map<String, Object> data = new HashMap<String, Object>();
data.put("personOut", instance);
engine.getTaskService().complete(taskId, "salaboy", data);
processInstance = engine.getKieSession().getProcessInstance(processInstance.getId());
assertNull(processInstance);
}
use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.
the class DeactivateDeploymentServiceWithSyncTest method testDeactivateDeploymentBySync.
@Test
public void testDeactivateDeploymentBySync() throws Exception {
Collection<DeployedUnit> deployed = deploymentService.getDeployedUnits();
assertNotNull(deployed);
assertEquals(0, deployed.size());
KModuleDeploymentUnit unit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(unit);
deploymentService.deactivate(unit.getIdentifier());
((KModuleDeploymentService) deploymentService).shutdown();
sync.clear();
AtomicBoolean deploymentActive = new AtomicBoolean(true);
CoundDownDeploymentListener countDownListener = new CoundDownDeploymentListener(1) {
@Override
public void onDeploy(DeploymentEvent event) {
// This used to use a specific listener for setting the active state
deploymentActive.set(event.getDeployedUnit().isActive());
super.onDeploy(event);
}
};
countDownListener.setDeploy(true);
((ListenerSupport) deploymentService).addListener(countDownListener);
invoker.start();
countDownListener.waitTillCompleted();
assertFalse("Deployment should be deactivated", deploymentActive.get());
deployed = deploymentService.getDeployedUnits();
assertNotNull(deployed);
assertEquals(1, deployed.size());
}
Aggregations