@Test public void testTaskDataWithVPSandMAPWithDeadline() throws Exception { taskService.setEscalatedDeadlineHandler(buildDeadlineHandler(env)); // JPA Entity EntityManager em = domainEmf.createEntityManager(); em.getTransaction().begin(); MyEntity myEntity = new MyEntity("This is a JPA Entity"); em.persist(myEntity); em.getTransaction().commit(); // Serializable Object MyObject myObject = new MyObject("This is a Serializable Object"); Map<String, Object> content = new HashMap<String, Object>(); content.put("myJPAEntity", myEntity); content.put("mySerializableObject", myObject); TestWorkItemManager manager = new TestWorkItemManager(); ksession.setWorkItemManager(manager); WorkItemImpl workItem = new WorkItemImpl(); workItem.setName("Human Task"); workItem.setParameter("TaskName", "TaskName"); workItem.setParameter("Comment", "Comment"); workItem.setParameter("Priority", "10"); workItem.setParameter("ActorId", "Darth Vader"); workItem.setParameter("Content", content); workItem.setParameter( "NotStartedNotify", "[tousers:john|subject:${doc['myJPAEntity'].test}|body:${doc['mySerializableObject'].value}]@[2s]"); getHandler().executeWorkItem(workItem, manager); BlockingTaskSummaryResponseHandler taskSummaryResponseHandler = new BlockingTaskSummaryResponseHandler(); getClient() .getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK", taskSummaryResponseHandler); List<TaskSummary> tasks = taskSummaryResponseHandler.getResults(); assertEquals(1, tasks.size()); TaskSummary taskSummary = tasks.get(0); assertEquals("TaskName", taskSummary.getName()); assertEquals(10, taskSummary.getPriority()); assertEquals("Comment", taskSummary.getDescription()); assertEquals(Status.Reserved, taskSummary.getStatus()); assertEquals("Darth Vader", taskSummary.getActualOwner().getId()); BlockingGetTaskResponseHandler getTaskResponseHandler = new BlockingGetTaskResponseHandler(); getClient().getTask(taskSummary.getId(), getTaskResponseHandler); Task task = getTaskResponseHandler.getTask(); assertEquals(AccessType.Inline, task.getTaskData().getDocumentAccessType()); assertEquals(task.getTaskData().getProcessSessionId(), ksession.getId()); long contentId = task.getTaskData().getDocumentContentId(); assertTrue(contentId != -1); BlockingGetContentResponseHandler getContentResponseHandler = new BlockingGetContentResponseHandler(); getClient().getContent(contentId, getContentResponseHandler); Object data = ContentMarshallerHelper.unmarshall( getContentResponseHandler.getContent().getContent(), ksession.getEnvironment()); Map<String, Object> dataMap = (Map<String, Object>) data; assertEquals(myEntity.getTest(), ((MyEntity) dataMap.get("myJPAEntity")).getTest()); assertEquals(myObject.getValue(), ((MyObject) dataMap.get("mySerializableObject")).getValue()); Thread.sleep(5000); assertEquals(2, wiser.getMessages().size()); assertEquals("*****@*****.**", wiser.getMessages().get(0).getEnvelopeReceiver()); assertEquals("*****@*****.**", wiser.getMessages().get(1).getEnvelopeReceiver()); assertEquals(myEntity.getTest(), wiser.getMessages().get(0).getMimeMessage().getSubject()); assertEquals(myObject.getValue(), wiser.getMessages().get(0).getMimeMessage().getContent()); BlockingTaskOperationResponseHandler startResponseHandler = new BlockingTaskOperationResponseHandler(); getClient().start(task.getId(), "Darth Vader", startResponseHandler); Map<String, Object> results = new HashMap<String, Object>(); em.getTransaction().begin(); MyEntity myEntity2 = new MyEntity("This is a JPA Entity 2"); em.persist(myEntity2); em.getTransaction().commit(); results.put("myEntity2", myEntity2); MyObject myObject2 = new MyObject("This is a Serializable Object 2"); results.put("myObject2", myObject2); ContentData result = ContentMarshallerHelper.marshal(results, ksession.getEnvironment()); BlockingTaskOperationResponseHandler completeResponseHandler = new BlockingTaskOperationResponseHandler(); getClient().complete(task.getId(), "Darth Vader", result, completeResponseHandler); assertTrue(manager.waitTillCompleted(MANAGER_COMPLETION_WAIT_TIME)); Map<String, Object> managerResults = manager.getResults(); assertNotNull(managerResults); assertEquals("Darth Vader", managerResults.get("ActorId")); assertEquals( myEntity2.getTest(), ((MyEntity) ((Map) managerResults.get("Result")).get("myEntity2")).getTest()); assertEquals(myEntity2.getTest(), ((MyEntity) managerResults.get("myEntity2")).getTest()); assertEquals( myObject2.getValue(), ((MyObject) ((Map) managerResults.get("Result")).get("myObject2")).getValue()); assertEquals(myObject2.getValue(), ((MyObject) managerResults.get("myObject2")).getValue()); }
@Test public void testTaskDataWithVPSSerializableObjectWithMarshal() throws Exception { // Serializable Object MyObject myObject = new MyObject("This is a Serializable Object"); TestWorkItemManager manager = new TestWorkItemManager(); ksession.setWorkItemManager(manager); WorkItemImpl workItem = new WorkItemImpl(); workItem.setName("Human Task"); workItem.setParameter("TaskName", "TaskName"); workItem.setParameter("Comment", "Comment"); workItem.setParameter("Priority", "10"); workItem.setParameter("ActorId", "Darth Vader"); workItem.setParameter("Content", myObject); getHandler().executeWorkItem(workItem, manager); BlockingTaskSummaryResponseHandler taskSummaryResponseHandler = new BlockingTaskSummaryResponseHandler(); getClient() .getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK", taskSummaryResponseHandler); List<TaskSummary> tasks = taskSummaryResponseHandler.getResults(); assertEquals(1, tasks.size()); TaskSummary taskSummary = tasks.get(0); assertEquals("TaskName", taskSummary.getName()); assertEquals(10, taskSummary.getPriority()); assertEquals("Comment", taskSummary.getDescription()); assertEquals(Status.Reserved, taskSummary.getStatus()); assertEquals("Darth Vader", taskSummary.getActualOwner().getId()); BlockingGetTaskResponseHandler getTaskResponseHandler = new BlockingGetTaskResponseHandler(); getClient().getTask(taskSummary.getId(), getTaskResponseHandler); Task task = getTaskResponseHandler.getTask(); assertEquals(AccessType.Inline, task.getTaskData().getDocumentAccessType()); assertEquals(task.getTaskData().getProcessSessionId(), ksession.getId()); long contentId = task.getTaskData().getDocumentContentId(); assertTrue(contentId != -1); BlockingGetContentResponseHandler getContentResponseHandler = new BlockingGetContentResponseHandler(); getClient().getContent(contentId, getContentResponseHandler); Object data = ContentMarshallerHelper.unmarshall( getContentResponseHandler.getContent().getContent(), ksession.getEnvironment()); assertEquals(myObject.getValue(), ((MyObject) data).getValue()); BlockingTaskOperationResponseHandler startResponseHandler = new BlockingTaskOperationResponseHandler(); getClient().start(task.getId(), "Darth Vader", startResponseHandler); MyObject myObject2 = new MyObject("This is a Serializable Object 2"); ContentData result = ContentMarshallerHelper.marshal(myObject2, ksession.getEnvironment()); BlockingTaskOperationResponseHandler completeResponseHandler = new BlockingTaskOperationResponseHandler(); getClient().complete(task.getId(), "Darth Vader", result, completeResponseHandler); assertTrue(manager.waitTillCompleted(MANAGER_COMPLETION_WAIT_TIME)); Map<String, Object> results = manager.getResults(); assertNotNull(results); assertEquals("Darth Vader", results.get("ActorId")); assertEquals(myObject2.getValue(), ((MyObject) results.get("Result")).getValue()); }