From 0a324bc39befbb453d2565de085394aca976aacd Mon Sep 17 00:00:00 2001 From: Michael Calmer Date: Mon, 9 Oct 2023 10:53:49 +0200 Subject: [PATCH] unit test for notification mail body --- .../test/NotificationFactoryTest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/java/code/src/com/redhat/rhn/domain/notification/test/NotificationFactoryTest.java b/java/code/src/com/redhat/rhn/domain/notification/test/NotificationFactoryTest.java index d5cd7256b0b9..dc03d322e559 100644 --- a/java/code/src/com/redhat/rhn/domain/notification/test/NotificationFactoryTest.java +++ b/java/code/src/com/redhat/rhn/domain/notification/test/NotificationFactoryTest.java @@ -24,6 +24,7 @@ import com.redhat.rhn.domain.notification.UserNotification; import com.redhat.rhn.domain.notification.UserNotificationFactory; import com.redhat.rhn.domain.notification.types.OnboardingFailed; +import com.redhat.rhn.domain.notification.types.StateApplyFailed; import com.redhat.rhn.domain.role.RoleFactory; import com.redhat.rhn.testing.BaseTestCaseWithUser; import com.redhat.rhn.testing.TestUtils; @@ -60,6 +61,23 @@ public final void testVisibilityForNoRoles() { assertEquals(1, UserNotificationFactory.listUnreadByUser(user).size()); assertEquals(1, UserNotificationFactory.listAllByUser(user).size()); mailer.verify(); + assertContains(mailer.getBody(), "minion1"); + } + + @Test + public final void testEmailContentStripHTML() { + mailer.setExpectedSendCount(1); + UserNotificationFactory.setMailer(mailer); + assertEquals(0, UserNotificationFactory.unreadUserNotificationsSize(user)); + NotificationMessage msg = UserNotificationFactory.createNotificationMessage( + new StateApplyFailed("minion1", 10000010000L, 42L)); + UserNotificationFactory.storeNotificationMessageFor(msg, Collections.emptySet(), empty()); + + assertEquals(1, UserNotificationFactory.unreadUserNotificationsSize(user)); + assertEquals(1, UserNotificationFactory.listUnreadByUser(user).size()); + assertEquals(1, UserNotificationFactory.listAllByUser(user).size()); + mailer.verify(); + assertContains(mailer.getBody(), "minion1"); } @Test