### Question:
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);  }### Answer:
@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)); }
@Test public void testTitleIsNull() { notification.setTitle(null); replayAll(); titleFormatter.format(notification); verifyAll(); assertNull(notification.getTitle()); }