Search in sources :

Example 1 with UserGroupCallback

use of org.kie.internal.task.api.UserGroupCallback in project jbpm by kiegroup.

the class HumanTaskResolver method getRuntimeManager.

private RuntimeManager getRuntimeManager(String process, int i) {
    Properties properties = new Properties();
    properties.setProperty("krisv", "");
    properties.setProperty("sales-rep", "sales");
    properties.setProperty("john", "PM");
    KnowledgeBuilder knowledgeBuilder = createKBuilder(process, ResourceType.BPMN2);
    KieBase kieBase = knowledgeBuilder.newKieBase();
    UserGroupCallback userGroupCallback = new JBossUserGroupCallbackImpl(properties);
    // load up the knowledge base
    TimerServiceRegistry.getInstance();
    RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().userGroupCallback(userGroupCallback).persistence(true).entityManagerFactory(emf).knowledgeBase(kieBase).get();
    return RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment, "id-" + i);
}
Also used : KnowledgeBuilder(org.kie.internal.builder.KnowledgeBuilder) RuntimeEnvironment(org.kie.api.runtime.manager.RuntimeEnvironment) KieBase(org.kie.api.KieBase) JBossUserGroupCallbackImpl(org.jbpm.services.task.identity.JBossUserGroupCallbackImpl) Properties(java.util.Properties) UserGroupCallback(org.kie.internal.task.api.UserGroupCallback)

Example 2 with UserGroupCallback

use of org.kie.internal.task.api.UserGroupCallback in project jbpm by kiegroup.

the class JaxbTaskSerializationTest method setTaskPropertyCommandTest.

@Test
public void setTaskPropertyCommandTest() throws Exception {
    SetTaskPropertyCommand cmd;
    int taskId = 1;
    String userId = "user";
    FaultDataImpl faultData = new FaultDataImpl();
    faultData.setAccessType(AccessType.Inline);
    faultData.setContent("skinned shins".getBytes());
    faultData.setFaultName("Whoops!");
    faultData.setType("skates");
    List<I18NText> textList = new ArrayList<I18NText>();
    I18NText text = new I18NTextImpl("nl-NL", "Stroopwafel!");
    textList.add(text);
    Object[][] testData = { { FAULT_PROPERTY, faultData }, { OUTPUT_PROPERTY, new Object() }, { PRIORITY_PROPERTY, 23 }, { TASK_NAMES_PROPERTY, textList }, { EXPIRATION_DATE_PROPERTY, new Date() }, { DESCRIPTION_PROPERTY, new ArrayList<I18NText>() }, { SKIPPABLE_PROPERTY, false }, { SUB_TASK_STRATEGY_PROPERTY, SubTasksStrategy.EndParentOnAllSubTasksEnd } };
    TaskContext mockContext = mock(TaskContext.class);
    TaskInstanceService mockTaskService = mock(TaskInstanceService.class);
    UserGroupCallback mockUserGroupCallback = mock(UserGroupCallback.class);
    when(mockContext.getTaskInstanceService()).thenReturn(mockTaskService);
    when(mockContext.getUserGroupCallback()).thenReturn(mockUserGroupCallback);
    when(mockUserGroupCallback.existsUser(anyString())).thenReturn(false);
    for (Object[] data : testData) {
        int property = (Integer) data[0];
        cmd = new SetTaskPropertyCommand(taskId, userId, property, data[1]);
        try {
            cmd.execute(mockContext);
        } catch (IllegalArgumentException e) {
            // expected for fault and output
            assertTrue(e.getMessage().startsWith("User user was not found in callback "));
        }
    }
}
Also used : I18NText(org.kie.api.task.model.I18NText) TaskContext(org.jbpm.services.task.commands.TaskContext) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) UserGroupCallback(org.kie.internal.task.api.UserGroupCallback) Date(java.util.Date) FaultDataImpl(org.jbpm.services.task.impl.model.FaultDataImpl) TaskInstanceService(org.kie.internal.task.api.TaskInstanceService) SetTaskPropertyCommand(org.jbpm.services.task.commands.SetTaskPropertyCommand) I18NTextImpl(org.jbpm.services.task.impl.model.I18NTextImpl) Test(org.junit.Test)

Aggregations

UserGroupCallback (org.kie.internal.task.api.UserGroupCallback)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Properties (java.util.Properties)1 SetTaskPropertyCommand (org.jbpm.services.task.commands.SetTaskPropertyCommand)1 TaskContext (org.jbpm.services.task.commands.TaskContext)1 JBossUserGroupCallbackImpl (org.jbpm.services.task.identity.JBossUserGroupCallbackImpl)1 FaultDataImpl (org.jbpm.services.task.impl.model.FaultDataImpl)1 I18NTextImpl (org.jbpm.services.task.impl.model.I18NTextImpl)1 Test (org.junit.Test)1 KieBase (org.kie.api.KieBase)1 RuntimeEnvironment (org.kie.api.runtime.manager.RuntimeEnvironment)1 I18NText (org.kie.api.task.model.I18NText)1 KnowledgeBuilder (org.kie.internal.builder.KnowledgeBuilder)1 TaskInstanceService (org.kie.internal.task.api.TaskInstanceService)1 Matchers.anyString (org.mockito.Matchers.anyString)1