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());
}
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);
}
}
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);
}
}
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 "));
}
}
}
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;
}
Aggregations