Skip to content

Commit

Permalink
unit test for notification mail body
Browse files Browse the repository at this point in the history
  • Loading branch information
mcalmer committed Oct 9, 2023
1 parent 14c8b24 commit 0a324bc
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0a324bc

Please sign in to comment.