use of org.kie.api.task.UserGroupCallback in project jbpm by kiegroup.
the class GlobalTimerServiceBaseTest method testInterediateTimerWithHTAfterWithGlobalTestService.
@Test(timeout = 20000)
public void testInterediateTimerWithHTAfterWithGlobalTestService() throws Exception {
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 3);
// prepare listener to assert results
final List<Long> timerExpirations = new ArrayList<Long>();
ProcessEventListener listener = new DefaultProcessEventListener() {
@Override
public void afterNodeLeft(ProcessNodeLeftEvent event) {
if (event.getNodeInstance().getNodeName().equals("timer")) {
timerExpirations.add(event.getProcessInstance().getId());
}
}
};
Properties properties = new Properties();
properties.setProperty("mary", "HR");
properties.setProperty("john", "HR");
UserGroupCallback userGroupCallback = new JBossUserGroupCallbackImpl(properties);
environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().entityManagerFactory(emf).addAsset(ResourceFactory.newClassPathResource("org/jbpm/test/functional/timer/IntermediateCatchEventTimerCycleWithHT.bpmn2"), ResourceType.BPMN2).schedulerService(globalScheduler).registerableItemsFactory(new TestRegisterableItemsFactory(listener, countDownListener)).userGroupCallback(userGroupCallback).get();
manager = getManager(environment, true);
RuntimeEngine runtime = manager.getRuntimeEngine(ProcessInstanceIdContext.get());
KieSession ksession = runtime.getKieSession();
Map<String, Object> params = new HashMap<String, Object>();
params.put("x", "R3/PT1S");
ProcessInstance processInstance = ksession.startProcess("IntermediateCatchEvent", params);
assertTrue(processInstance.getState() == ProcessInstance.STATE_ACTIVE);
logger.debug("Disposed after start");
// dispose session to force session to be reloaded on timer expiration
manager.disposeRuntimeEngine(runtime);
countDownListener.waitTillCompleted();
countDownListener.reset(1);
runtime = manager.getRuntimeEngine(ProcessInstanceIdContext.get(processInstance.getId()));
ksession = runtime.getKieSession();
// get tasks
List<Status> statuses = new ArrayList<Status>();
statuses.add(Status.Reserved);
List<TaskSummary> tasks = runtime.getTaskService().getTasksAssignedAsPotentialOwnerByStatus("john", statuses, "en-UK");
assertNotNull(tasks);
assertEquals(3, tasks.size());
for (TaskSummary task : tasks) {
runtime.getTaskService().start(task.getId(), "john");
runtime.getTaskService().complete(task.getId(), "john", null);
}
processInstance = ksession.getProcessInstance(processInstance.getId());
assertNull(processInstance);
// let's wait to ensure no more timers are expired and triggered
countDownListener.waitTillCompleted(3000);
manager.disposeRuntimeEngine(runtime);
assertEquals(3, timerExpirations.size());
}
use of org.kie.api.task.UserGroupCallback in project jbpm by kiegroup.
the class JBPMHelper method getUserGroupCallback.
@Deprecated
@SuppressWarnings("unchecked")
public static UserGroupCallback getUserGroupCallback() {
Properties properties = getProperties();
String className = properties.getProperty("taskservice.usergroupcallback");
if (className != null) {
try {
Class<UserGroupCallback> clazz = (Class<UserGroupCallback>) Class.forName(className);
return clazz.newInstance();
} catch (Exception e) {
throw new IllegalArgumentException("Cannot create instance of UserGroupCallback " + className, e);
}
} else {
return new JBossUserGroupCallbackImpl("classpath:/usergroups.properties");
}
}
use of org.kie.api.task.UserGroupCallback in project jbpm by kiegroup.
the class LDAPUserGroupCallbackImplTest method testGroupsForUser.
@Test
public void testGroupsForUser() {
UserGroupCallback ldapUserGroupCallback = createLdapUserGroupCallback(Configuration.CUSTOM);
Assertions.assertThat(ldapUserGroupCallback).isNotNull();
List<String> userGroups = ldapUserGroupCallback.getGroupsForUser("john");
Assertions.assertThat(userGroups).hasSize(1);
}
use of org.kie.api.task.UserGroupCallback in project jbpm by kiegroup.
the class LDAPUserGroupCallbackImplTest method testGroupExists.
@Test
public void testGroupExists() {
UserGroupCallback ldapUserGroupCallback = createLdapUserGroupCallback(Configuration.CUSTOM);
Assertions.assertThat(ldapUserGroupCallback).isNotNull();
boolean groupExists = ldapUserGroupCallback.existsGroup("manager");
Assertions.assertThat(groupExists).isTrue();
}
use of org.kie.api.task.UserGroupCallback in project jbpm by kiegroup.
the class LDAPUserGroupCallbackImplTest method testUsersSubtreeScopeBaseDnContext.
@Test
public void testUsersSubtreeScopeBaseDnContext() {
UserGroupCallback ldapUserGroupCallback = createLdapUserGroupCallbackWithUserCtx(SearchScope.SUBTREE_SCOPE, "dc=jbpm,dc=org");
assertUsers(ldapUserGroupCallback, true, true, true, true);
}
Aggregations