Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rmiccoli committed Jul 27, 2024
1 parent fdeacf1 commit 25ef340
Showing 1 changed file with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ public void tearDown() throws InterruptedException {
notificationDelivery.clearDeliveredNotifications();
}

public String formatSubject(String key) {
return String.format("[%s IAM] %s", organisationName, properties.getSubject().get(key));
}

@Test
public void testSendWithEmptyQueue() {

Expand Down Expand Up @@ -145,7 +149,7 @@ public void testApproveFlowNotifications() throws Exception {

IamEmailNotification message = notificationDelivery.getDeliveredNotifications().get(0);

assertThat(message.getSubject(), equalTo(properties.getSubject().get("confirmation")));
assertThat(message.getSubject(), equalTo(formatSubject("confirmation")));

notificationDelivery.clearDeliveredNotifications();

Expand All @@ -161,7 +165,7 @@ public void testApproveFlowNotifications() throws Exception {

message = notificationDelivery.getDeliveredNotifications().get(0);

assertThat(message.getSubject(), equalTo(properties.getSubject().get("adminHandleRequest")));
assertThat(message.getSubject(), equalTo(formatSubject("adminHandleRequest")));

assertThat(message.getReceivers(), hasSize(1));
assertThat(message.getReceivers().get(0).getEmailAddress(),
Expand All @@ -180,7 +184,7 @@ public void testApproveFlowNotifications() throws Exception {

message = notificationDelivery.getDeliveredNotifications().get(0);

assertThat(message.getSubject(), equalTo(properties.getSubject().get("activated")));
assertThat(message.getSubject(), equalTo(formatSubject("activated")));
assertThat(message.getBody(), containsString(request.getUsername()));

}
Expand Down Expand Up @@ -212,7 +216,7 @@ public void testRejectFlowNoMotivationNotifications() throws Exception {

IamEmailNotification message = notificationDelivery.getDeliveredNotifications().get(0);

assertThat(message.getSubject(), equalTo(properties.getSubject().get("confirmation")));
assertThat(message.getSubject(), equalTo(formatSubject("confirmation")));

notificationDelivery.clearDeliveredNotifications();

Expand All @@ -228,7 +232,7 @@ public void testRejectFlowNoMotivationNotifications() throws Exception {

message = notificationDelivery.getDeliveredNotifications().get(0);

assertThat(message.getSubject(), equalTo(properties.getSubject().get("adminHandleRequest")));
assertThat(message.getSubject(), equalTo(formatSubject("adminHandleRequest")));

assertThat(message.getReceivers(), hasSize(1));
assertThat(message.getReceivers().get(0).getEmailAddress(),
Expand All @@ -247,7 +251,7 @@ public void testRejectFlowNoMotivationNotifications() throws Exception {

message = notificationDelivery.getDeliveredNotifications().get(0);

assertThat(message.getSubject(), equalTo(properties.getSubject().get("rejected")));
assertThat(message.getSubject(), equalTo(formatSubject("rejected")));
assertThat(message.getBody(),
not(containsString("The administrator has provided the following motivation")));

Expand Down Expand Up @@ -280,7 +284,7 @@ public void testRejectFlowMotivationNotifications() throws Exception {

IamEmailNotification message = notificationDelivery.getDeliveredNotifications().get(0);

assertThat(message.getSubject(), equalTo(properties.getSubject().get("confirmation")));
assertThat(message.getSubject(), equalTo(formatSubject("confirmation")));

notificationDelivery.clearDeliveredNotifications();

Expand All @@ -296,7 +300,7 @@ public void testRejectFlowMotivationNotifications() throws Exception {

message = notificationDelivery.getDeliveredNotifications().get(0);

assertThat(message.getSubject(), equalTo(properties.getSubject().get("adminHandleRequest")));
assertThat(message.getSubject(), equalTo(formatSubject("adminHandleRequest")));

assertThat(message.getReceivers(), hasSize(1));
assertThat(message.getReceivers().get(0).getEmailAddress(),
Expand All @@ -317,11 +321,10 @@ public void testRejectFlowMotivationNotifications() throws Exception {

message = notificationDelivery.getDeliveredNotifications().get(0);

assertThat(message.getSubject(), equalTo(properties.getSubject().get("rejected")));
assertThat(message.getSubject(), equalTo(formatSubject("rejected")));
assertThat(message.getBody(),
containsString("The administrator has provided the following motivation"));
assertThat(message.getBody(),
containsString("We hate you"));
assertThat(message.getBody(), containsString("We hate you"));

}

Expand Down

0 comments on commit 25ef340

Please sign in to comment.