@Test public void replaceParentTypeLabelInTitle() { String relatedType = "CASE_FILE"; String expectedTitle = "Title with label placeholder: parent_label"; notification.setNote(null); notification.setTitle("Title with label placeholder: " + NotificationConstants.PARENT_TYPE_LABEL_PLACEHOLDER); notification.setRelatedObjectType(relatedType); expect(mockConfig.getLabelForObjectType(relatedType)).andReturn("parent_label"); replayAll(); Notification updatedNotification = notificationFormatter.replaceFormatPlaceholders(notification); verifyAll(); assertEquals(updatedNotification.getTitle(), expectedTitle); }
public Notification replaceFormatPlaceholders(Notification notification) { String objectTypeLabelPlaceholder = NotificationConstants.OBJECT_TYPE_LABEL_PLACEHOLDER; String parentTypeLabelPlaceholder = NotificationConstants.PARENT_TYPE_LABEL_PLACEHOLDER; String notificationTitle = notification.getTitle(); if (notificationTitle != null && notificationTitle.contains(objectTypeLabelPlaceholder)) { String updatedTitle = replaceObjectTypeLabel(notificationTitle, objectTypeLabelPlaceholder, notification.getParentType()); notification.setTitle(updatedTitle); notificationTitle = updatedTitle; } if (notificationTitle != null && notificationTitle.contains(parentTypeLabelPlaceholder)) { String updatedTitle = replaceObjectTypeLabel(notificationTitle, parentTypeLabelPlaceholder, notification.getRelatedObjectType()); notification.setTitle(updatedTitle); } String notificationNote = notification.getNote(); if (notificationNote != null && notificationNote.contains(objectTypeLabelPlaceholder)) { String updatedNote = replaceObjectTypeLabel(notificationNote, objectTypeLabelPlaceholder, notification.getParentType()); notification.setNote(updatedNote); notificationNote = updatedNote; } if (notificationNote != null && notificationNote.contains(parentTypeLabelPlaceholder)) { String updatedNote = replaceObjectTypeLabel(notificationNote, parentTypeLabelPlaceholder, notification.getRelatedObjectType()); notification.setNote(updatedNote); } return notification; }
NotificationFormatter { public Notification replaceFormatPlaceholders(Notification notification) { String objectTypeLabelPlaceholder = NotificationConstants.OBJECT_TYPE_LABEL_PLACEHOLDER; String parentTypeLabelPlaceholder = NotificationConstants.PARENT_TYPE_LABEL_PLACEHOLDER; String notificationTitle = notification.getTitle(); if (notificationTitle != null && notificationTitle.contains(objectTypeLabelPlaceholder)) { String updatedTitle = replaceObjectTypeLabel(notificationTitle, objectTypeLabelPlaceholder, notification.getParentType()); notification.setTitle(updatedTitle); notificationTitle = updatedTitle; } if (notificationTitle != null && notificationTitle.contains(parentTypeLabelPlaceholder)) { String updatedTitle = replaceObjectTypeLabel(notificationTitle, parentTypeLabelPlaceholder, notification.getRelatedObjectType()); notification.setTitle(updatedTitle); } String notificationNote = notification.getNote(); if (notificationNote != null && notificationNote.contains(objectTypeLabelPlaceholder)) { String updatedNote = replaceObjectTypeLabel(notificationNote, objectTypeLabelPlaceholder, notification.getParentType()); notification.setNote(updatedNote); notificationNote = updatedNote; } if (notificationNote != null && notificationNote.contains(parentTypeLabelPlaceholder)) { String updatedNote = replaceObjectTypeLabel(notificationNote, parentTypeLabelPlaceholder, notification.getRelatedObjectType()); notification.setNote(updatedNote); } return notification; } }
NotificationFormatter { public Notification replaceFormatPlaceholders(Notification notification) { String objectTypeLabelPlaceholder = NotificationConstants.OBJECT_TYPE_LABEL_PLACEHOLDER; String parentTypeLabelPlaceholder = NotificationConstants.PARENT_TYPE_LABEL_PLACEHOLDER; String notificationTitle = notification.getTitle(); if (notificationTitle != null && notificationTitle.contains(objectTypeLabelPlaceholder)) { String updatedTitle = replaceObjectTypeLabel(notificationTitle, objectTypeLabelPlaceholder, notification.getParentType()); notification.setTitle(updatedTitle); notificationTitle = updatedTitle; } if (notificationTitle != null && notificationTitle.contains(parentTypeLabelPlaceholder)) { String updatedTitle = replaceObjectTypeLabel(notificationTitle, parentTypeLabelPlaceholder, notification.getRelatedObjectType()); notification.setTitle(updatedTitle); } String notificationNote = notification.getNote(); if (notificationNote != null && notificationNote.contains(objectTypeLabelPlaceholder)) { String updatedNote = replaceObjectTypeLabel(notificationNote, objectTypeLabelPlaceholder, notification.getParentType()); notification.setNote(updatedNote); notificationNote = updatedNote; } if (notificationNote != null && notificationNote.contains(parentTypeLabelPlaceholder)) { String updatedNote = replaceObjectTypeLabel(notificationNote, parentTypeLabelPlaceholder, notification.getRelatedObjectType()); notification.setNote(updatedNote); } return notification; }  }
NotificationFormatter { public Notification replaceFormatPlaceholders(Notification notification) { String objectTypeLabelPlaceholder = NotificationConstants.OBJECT_TYPE_LABEL_PLACEHOLDER; String parentTypeLabelPlaceholder = NotificationConstants.PARENT_TYPE_LABEL_PLACEHOLDER; String notificationTitle = notification.getTitle(); if (notificationTitle != null && notificationTitle.contains(objectTypeLabelPlaceholder)) { String updatedTitle = replaceObjectTypeLabel(notificationTitle, objectTypeLabelPlaceholder, notification.getParentType()); notification.setTitle(updatedTitle); notificationTitle = updatedTitle; } if (notificationTitle != null && notificationTitle.contains(parentTypeLabelPlaceholder)) { String updatedTitle = replaceObjectTypeLabel(notificationTitle, parentTypeLabelPlaceholder, notification.getRelatedObjectType()); notification.setTitle(updatedTitle); } String notificationNote = notification.getNote(); if (notificationNote != null && notificationNote.contains(objectTypeLabelPlaceholder)) { String updatedNote = replaceObjectTypeLabel(notificationNote, objectTypeLabelPlaceholder, notification.getParentType()); notification.setNote(updatedNote); notificationNote = updatedNote; } if (notificationNote != null && notificationNote.contains(parentTypeLabelPlaceholder)) { String updatedNote = replaceObjectTypeLabel(notificationNote, parentTypeLabelPlaceholder, notification.getRelatedObjectType()); notification.setNote(updatedNote); } return notification; }  Notification replaceFormatPlaceholders(Notification notification); String replaceSubscriptionTitle(String title, String placeholder, String objectType); NotificationConfig getNotificationConfig(); void setNotificationConfig(NotificationConfig notificationConfig); }
NotificationFormatter { public Notification replaceFormatPlaceholders(Notification notification) { String objectTypeLabelPlaceholder = NotificationConstants.OBJECT_TYPE_LABEL_PLACEHOLDER; String parentTypeLabelPlaceholder = NotificationConstants.PARENT_TYPE_LABEL_PLACEHOLDER; String notificationTitle = notification.getTitle(); if (notificationTitle != null && notificationTitle.contains(objectTypeLabelPlaceholder)) { String updatedTitle = replaceObjectTypeLabel(notificationTitle, objectTypeLabelPlaceholder, notification.getParentType()); notification.setTitle(updatedTitle); notificationTitle = updatedTitle; } if (notificationTitle != null && notificationTitle.contains(parentTypeLabelPlaceholder)) { String updatedTitle = replaceObjectTypeLabel(notificationTitle, parentTypeLabelPlaceholder, notification.getRelatedObjectType()); notification.setTitle(updatedTitle); } String notificationNote = notification.getNote(); if (notificationNote != null && notificationNote.contains(objectTypeLabelPlaceholder)) { String updatedNote = replaceObjectTypeLabel(notificationNote, objectTypeLabelPlaceholder, notification.getParentType()); notification.setNote(updatedNote); notificationNote = updatedNote; } if (notificationNote != null && notificationNote.contains(parentTypeLabelPlaceholder)) { String updatedNote = replaceObjectTypeLabel(notificationNote, parentTypeLabelPlaceholder, notification.getRelatedObjectType()); notification.setNote(updatedNote); } return notification; }  Notification replaceFormatPlaceholders(Notification notification); String replaceSubscriptionTitle(String title, String placeholder, String objectType); NotificationConfig getNotificationConfig(); void setNotificationConfig(NotificationConfig notificationConfig);  }