Search in sources :

Example 1 with SetTaskPropertyCommand

use of org.jbpm.services.task.commands.SetTaskPropertyCommand 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

ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 SetTaskPropertyCommand (org.jbpm.services.task.commands.SetTaskPropertyCommand)1 TaskContext (org.jbpm.services.task.commands.TaskContext)1 FaultDataImpl (org.jbpm.services.task.impl.model.FaultDataImpl)1 I18NTextImpl (org.jbpm.services.task.impl.model.I18NTextImpl)1 Test (org.junit.Test)1 I18NText (org.kie.api.task.model.I18NText)1 TaskInstanceService (org.kie.internal.task.api.TaskInstanceService)1 UserGroupCallback (org.kie.internal.task.api.UserGroupCallback)1 Matchers.anyString (org.mockito.Matchers.anyString)1