WorkflowTaskUserNotificationHandler extends BaseUserNotificationHandler { @Override protected String getLink( UserNotificationEvent userNotificationEvent, ServiceContext serviceContext) throws Exception { JSONObject jsonObject = JSONFactoryUtil.createJSONObject( userNotificationEvent.getPayload()); WorkflowHandler<?> workflowHandler = WorkflowHandlerRegistryUtil.getWorkflowHandler( jsonObject.getString("entryClassName")); long workflowTaskId = jsonObject.getLong("workflowTaskId"); if ((workflowHandler == null) || !_hasPermission(workflowTaskId, serviceContext)) { return StringPool.BLANK; } serviceContext.setAttribute( WorkflowConstants.CONTEXT_ENTRY_CLASS_PK, jsonObject.getString(WorkflowConstants.CONTEXT_ENTRY_CLASS_PK)); serviceContext.setAttribute( WorkflowConstants.CONTEXT_URL, jsonObject.getString(WorkflowConstants.CONTEXT_URL)); serviceContext.setAttribute("plid", jsonObject.getLong("plid")); serviceContext.setAttribute( "portletId", jsonObject.getString("portletId")); return workflowHandler.getURLEditWorkflowTask( workflowTaskId, serviceContext); } WorkflowTaskUserNotificationHandler();   }
@Test public void testInvalidWorkflowTaskIdShouldReturnBlankLink() throws Exception { Assert.assertEquals( StringPool.BLANK, _workflowTaskUserNotificationHandler.getLink( mockUserNotificationEvent( _VALID_ENTRY_CLASS_NAME, _INVALID_WORKFLOW_TASK_ID), _serviceContext)); }
@Test public void testNullWorkflowTaskIdShouldReturnBlankLink() throws Exception { Assert.assertEquals( StringPool.BLANK, _workflowTaskUserNotificationHandler.getLink( mockUserNotificationEvent(_VALID_ENTRY_CLASS_NAME, 0), _serviceContext)); }
@Test public void testValidWorkflowTaskIdShouldReturnLink() throws Exception { Assert.assertEquals( _VALID_LINK, _workflowTaskUserNotificationHandler.getLink( mockUserNotificationEvent( _VALID_ENTRY_CLASS_NAME, _VALID_WORKFLOW_TASK_ID), _serviceContext)); }