@Test public void testFormat() { expect(mockNotificationUtils.getNotificationParentOrRelatedObjectNumber(RELATED_OBJECT_TYPE, RELATED_OBJECT_ID)) .andReturn(COMPLAINT_TITLE); replayAll(); String expectedTitle = titleFormatter.format(notification); verifyAll(); assertEquals(expectedTitle, TITLE.replace(NotificationConstants.NAME_LABEL, COMPLAINT_TITLE)); }
@Override public String format(Notification notification) { String parentObjectType = notification.getRelatedObjectType() != null ? notification.getRelatedObjectType() : notification.getParentType(); Long parentObjectId = notification.getRelatedObjectId() != null ? notification.getRelatedObjectId() : notification.getParentId(); String title = notification.getTitle(); if (title != null) { String objectTitle = getNotificationUtils().getNotificationParentOrRelatedObjectNumber(parentObjectType, parentObjectId); title = replacePlaceholder(objectTitle, title, NotificationConstants.NAME_LABEL); } return title; }
ObjectNameTitleFormatter implements CustomTitleFormatter { @Override public String format(Notification notification) { String parentObjectType = notification.getRelatedObjectType() != null ? notification.getRelatedObjectType() : notification.getParentType(); Long parentObjectId = notification.getRelatedObjectId() != null ? notification.getRelatedObjectId() : notification.getParentId(); String title = notification.getTitle(); if (title != null) { String objectTitle = getNotificationUtils().getNotificationParentOrRelatedObjectNumber(parentObjectType, parentObjectId); title = replacePlaceholder(objectTitle, title, NotificationConstants.NAME_LABEL); } return title; } }
ObjectNameTitleFormatter implements CustomTitleFormatter { @Override public String format(Notification notification) { String parentObjectType = notification.getRelatedObjectType() != null ? notification.getRelatedObjectType() : notification.getParentType(); Long parentObjectId = notification.getRelatedObjectId() != null ? notification.getRelatedObjectId() : notification.getParentId(); String title = notification.getTitle(); if (title != null) { String objectTitle = getNotificationUtils().getNotificationParentOrRelatedObjectNumber(parentObjectType, parentObjectId); title = replacePlaceholder(objectTitle, title, NotificationConstants.NAME_LABEL); } return title; }  }
ObjectNameTitleFormatter implements CustomTitleFormatter { @Override public String format(Notification notification) { String parentObjectType = notification.getRelatedObjectType() != null ? notification.getRelatedObjectType() : notification.getParentType(); Long parentObjectId = notification.getRelatedObjectId() != null ? notification.getRelatedObjectId() : notification.getParentId(); String title = notification.getTitle(); if (title != null) { String objectTitle = getNotificationUtils().getNotificationParentOrRelatedObjectNumber(parentObjectType, parentObjectId); title = replacePlaceholder(objectTitle, title, NotificationConstants.NAME_LABEL); } return title; }  @Override String format(Notification notification); NotificationUtils getNotificationUtils(); void setNotificationUtils(NotificationUtils notificationUtils); }
ObjectNameTitleFormatter implements CustomTitleFormatter { @Override public String format(Notification notification) { String parentObjectType = notification.getRelatedObjectType() != null ? notification.getRelatedObjectType() : notification.getParentType(); Long parentObjectId = notification.getRelatedObjectId() != null ? notification.getRelatedObjectId() : notification.getParentId(); String title = notification.getTitle(); if (title != null) { String objectTitle = getNotificationUtils().getNotificationParentOrRelatedObjectNumber(parentObjectType, parentObjectId); title = replacePlaceholder(objectTitle, title, NotificationConstants.NAME_LABEL); } return title; }  @Override String format(Notification notification); NotificationUtils getNotificationUtils(); void setNotificationUtils(NotificationUtils notificationUtils);  }