Search in sources :

Example 1 with I18NTextImpl

use of org.jbpm.services.task.impl.model.I18NTextImpl in project jbpm by kiegroup.

the class AbstractTaskSerializationTest method jaxbI18NTextTest.

@Test
public void jaxbI18NTextTest() throws Exception {
    Assume.assumeFalse(getType().equals(TestType.YAML));
    I18NTextImpl textImpl = new I18NTextImpl();
    textImpl.setId(1605l);
    textImpl.setLanguage("es-ES");
    textImpl.setText("Quixote");
    JaxbI18NText jaxbText = new JaxbI18NText(textImpl);
    assertEquals("id", textImpl.getId(), jaxbText.getId());
    assertEquals("language", textImpl.getLanguage(), jaxbText.getLanguage());
    assertEquals("text", textImpl.getText(), jaxbText.getText());
    JaxbI18NText copyJaxbText = testRoundTrip(jaxbText);
    Assertions.assertThat(jaxbText).isEqualToComparingFieldByFieldRecursively(copyJaxbText);
    List<I18NText> intList = new ArrayList<I18NText>();
    intList.add(textImpl);
    List<JaxbI18NText> jaxbList = JaxbI18NText.convertListFromInterfaceToJaxbImpl(intList, I18NText.class, JaxbI18NText.class);
    jaxbText = jaxbList.get(0);
    assertEquals("id", textImpl.getId(), jaxbText.getId());
    assertEquals("language", textImpl.getLanguage(), jaxbText.getLanguage());
    assertEquals("text", textImpl.getText(), jaxbText.getText());
    intList = JaxbI18NText.convertListFromJaxbImplToInterface(jaxbList);
    I18NText text = intList.get(0);
    assertEquals("id", text.getId(), jaxbText.getId());
    assertEquals("language", text.getLanguage(), jaxbText.getLanguage());
    assertEquals("text", text.getText(), jaxbText.getText());
}
Also used : I18NText(org.kie.api.task.model.I18NText) JaxbI18NText(org.jbpm.services.task.impl.model.xml.JaxbI18NText) InternalI18NText(org.kie.internal.task.api.model.InternalI18NText) JaxbI18NText(org.jbpm.services.task.impl.model.xml.JaxbI18NText) I18NTextImpl(org.jbpm.services.task.impl.model.I18NTextImpl) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 2 with I18NTextImpl

use of org.jbpm.services.task.impl.model.I18NTextImpl in project jbpm by kiegroup.

the class TaskAuditBaseTest method testNameUpdate.

private void testNameUpdate(String oldName, String newName, boolean changeExpected) {
    Task task = new TaskFluent().setName(oldName).setAdminUser("Administrator").getTask();
    taskService.addTask(task, new HashMap<String, Object>());
    long taskId = task.getId();
    List<I18NText> taskNames = new ArrayList<I18NText>();
    taskNames.add(new I18NTextImpl("", newName));
    taskService.setTaskNames(taskId, taskNames);
    task = taskService.getTaskById(taskId);
    Assertions.assertThat(task.getName()).isEqualTo(newName);
    List<AuditTask> auditTasks = taskAuditService.getAllAuditTasks(new QueryFilter());
    Assertions.assertThat(auditTasks).hasSize(1);
    Assertions.assertThat(auditTasks.get(0).getName()).isEqualTo(newName);
    List<TaskEvent> taskEvents = taskAuditService.getAllTaskEvents(taskId, new QueryFilter());
    if (changeExpected) {
        Assertions.assertThat(taskEvents).hasSize(2);
        Assertions.assertThat(taskEvents.get(1).getMessage()).contains(String.valueOf(oldName), String.valueOf(newName));
    } else {
        Assertions.assertThat(taskEvents).hasSize(1);
    }
}
Also used : Task(org.kie.api.task.model.Task) AuditTask(org.kie.internal.task.api.AuditTask) I18NText(org.kie.api.task.model.I18NText) TaskFluent(org.jbpm.services.task.utils.TaskFluent) ArrayList(java.util.ArrayList) AuditTask(org.kie.internal.task.api.AuditTask) QueryFilter(org.kie.internal.query.QueryFilter) I18NTextImpl(org.jbpm.services.task.impl.model.I18NTextImpl) TaskEvent(org.kie.internal.task.api.model.TaskEvent)

Example 3 with I18NTextImpl

use of org.jbpm.services.task.impl.model.I18NTextImpl in project jbpm by kiegroup.

the class TaskAuditBaseTest method testDescriptionUpdate.

private void testDescriptionUpdate(String oldDescription, String newDescription, boolean changeExpected) {
    Task task = new TaskFluent().setDescription(oldDescription).setAdminUser("Administrator").getTask();
    taskService.addTask(task, new HashMap<String, Object>());
    long taskId = task.getId();
    List<I18NText> descriptions = new ArrayList<I18NText>();
    descriptions.add(new I18NTextImpl("", newDescription));
    taskService.setDescriptions(taskId, descriptions);
    task = taskService.getTaskById(taskId);
    Assertions.assertThat(task.getDescription()).isEqualTo(newDescription);
    List<AuditTask> auditTasks = taskAuditService.getAllAuditTasks(new QueryFilter());
    Assertions.assertThat(auditTasks).hasSize(1);
    Assertions.assertThat(auditTasks.get(0).getDescription()).isEqualTo(newDescription);
    List<TaskEvent> taskEvents = taskAuditService.getAllTaskEvents(taskId, new QueryFilter());
    if (changeExpected) {
        Assertions.assertThat(taskEvents).hasSize(2);
        Assertions.assertThat(taskEvents.get(1).getMessage()).contains(String.valueOf(oldDescription), String.valueOf(newDescription));
    } else {
        Assertions.assertThat(taskEvents).hasSize(1);
    }
}
Also used : Task(org.kie.api.task.model.Task) AuditTask(org.kie.internal.task.api.AuditTask) I18NText(org.kie.api.task.model.I18NText) TaskFluent(org.jbpm.services.task.utils.TaskFluent) ArrayList(java.util.ArrayList) AuditTask(org.kie.internal.task.api.AuditTask) QueryFilter(org.kie.internal.query.QueryFilter) I18NTextImpl(org.jbpm.services.task.impl.model.I18NTextImpl) TaskEvent(org.kie.internal.task.api.model.TaskEvent)

Example 4 with I18NTextImpl

use of org.jbpm.services.task.impl.model.I18NTextImpl 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)

Example 5 with I18NTextImpl

use of org.jbpm.services.task.impl.model.I18NTextImpl in project jbpm by kiegroup.

the class CollectionUtils method readI18NTextList.

public static List<I18NText> readI18NTextList(ObjectInput in) throws IOException, ClassNotFoundException {
    int size = in.readInt();
    List<I18NText> list = new ArrayList<I18NText>(size);
    for (int i = 0; i < size; i++) {
        I18NText item = new I18NTextImpl();
        item.readExternal(in);
        list.add(item);
    }
    return list;
}
Also used : I18NText(org.kie.api.task.model.I18NText) I18NTextImpl(org.jbpm.services.task.impl.model.I18NTextImpl) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)5 I18NTextImpl (org.jbpm.services.task.impl.model.I18NTextImpl)5 I18NText (org.kie.api.task.model.I18NText)5 TaskFluent (org.jbpm.services.task.utils.TaskFluent)2 Test (org.junit.Test)2 Task (org.kie.api.task.model.Task)2 QueryFilter (org.kie.internal.query.QueryFilter)2 AuditTask (org.kie.internal.task.api.AuditTask)2 TaskEvent (org.kie.internal.task.api.model.TaskEvent)2 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 JaxbI18NText (org.jbpm.services.task.impl.model.xml.JaxbI18NText)1 TaskInstanceService (org.kie.internal.task.api.TaskInstanceService)1 UserGroupCallback (org.kie.internal.task.api.UserGroupCallback)1 InternalI18NText (org.kie.internal.task.api.model.InternalI18NText)1 Matchers.anyString (org.mockito.Matchers.anyString)1