WorkflowTaskUserNotificationHandler extends BaseUserNotificationHandler { @Override protected String getBody( UserNotificationEvent userNotificationEvent, ServiceContext serviceContext) throws Exception { JSONObject jsonObject = JSONFactoryUtil.createJSONObject( userNotificationEvent.getPayload()); long workflowTaskId = jsonObject.getLong("workflowTaskId"); if (workflowTaskId > 0) { WorkflowTask workflowTask = _fetchWorkflowTask( workflowTaskId, serviceContext); if (workflowTask == null) { _userNotificationEventLocalService.deleteUserNotificationEvent( userNotificationEvent.getUserNotificationEventId()); return StringPool.BLANK; } } return HtmlUtil.escape(jsonObject.getString("notificationMessage")); } WorkflowTaskUserNotificationHandler();   }
@Test public void testInvalidWorkflowTaskIdShouldReturnBlankBody() throws Exception { Assert.assertEquals( StringPool.BLANK, _workflowTaskUserNotificationHandler.getBody( mockUserNotificationEvent(null, _INVALID_WORKFLOW_TASK_ID), _serviceContext)); }
@Test public void testNullWorkflowTaskIdShouldReturnBody() throws Exception { Assert.assertEquals( _NOTIFICATION_MESSAGE, _workflowTaskUserNotificationHandler.getBody( mockUserNotificationEvent(null, 0), _serviceContext)); }
@Test public void testValidWorkflowTaskIdShouldReturnBody() throws Exception { Assert.assertEquals( _NOTIFICATION_MESSAGE, _workflowTaskUserNotificationHandler.getBody( mockUserNotificationEvent(null, _VALID_WORKFLOW_TASK_ID), _serviceContext)); }