Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Improve test robustness

Rich Turner2525f334a4df
diff --git a/test/src/test/groovy/org/openremote/test/notification/NotificationTest.groovy b/test/src/test/groovy/org/openremote/test/notification/NotificationTest.groovy
index 76b64356d..d44d979c3 100644
--- a/test/src/test/groovy/org/openremote/test/notification/NotificationTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/notification/NotificationTest.groovy
@@ -589,9 +589,9 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
then: "the child asset with the email attribute should have been sent an email"
conditions.eventually {
- assert sentEmails.size() == 5
- assert sentEmails.get(4).getSubject() == "Test 2"
- assert sentEmails.get(4).getRecipients().get(0).getAddress() == "[email protected]"
+ assert sentEmails.size() >= 4
+ assert sentEmails.any { it.getSubject() == "Test 2"}
+ assert sentEmails.any { it.getRecipients().size() == 1 && it.getRecipients().get(0).address == "[email protected]"}
}
when: "an email is sent to a custom target"
@@ -601,13 +601,12 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
then: "the email should have been sent to all custom recipients"
conditions.eventually {
- assert sentEmails.size() == 6
- assert sentEmails.get(5).getSubject() == "Test Custom"
- assert sentEmails.get(5).getRecipients().size() == 4
- assert sentEmails.get(5).getRecipients().any{ it.type == javax.mail.Message.RecipientType.TO && it.address == "[email protected]"}
- assert sentEmails.get(5).getRecipients().any{ it.type == javax.mail.Message.RecipientType.TO && it.address == "[email protected]"}
- assert sentEmails.get(5).getRecipients().any{ it.type == javax.mail.Message.RecipientType.CC && it.address == "[email protected]"}
- assert sentEmails.get(5).getRecipients().any{ it.type == javax.mail.Message.RecipientType.BCC && it.address == "[email protected]"}
+ assert sentEmails.size() >= 5
+ assert sentEmails.any { it.getSubject() == "Test Custom" && it.getRecipients().size() == 4}
+ assert sentEmails.any { it.getSubject() == "Test Custom" && it.getRecipients().any{it.type == javax.mail.Message.RecipientType.TO && it.address == "[email protected]"}}
+ assert sentEmails.any { it.getSubject() == "Test Custom" && it.getRecipients().any{it.type == javax.mail.Message.RecipientType.TO && it.address == "[email protected]"}}
+ assert sentEmails.any { it.getSubject() == "Test Custom" && it.getRecipients().any{it.type == javax.mail.Message.RecipientType.CC && it.address == "[email protected]"}}
+ assert sentEmails.any { it.getSubject() == "Test Custom" && it.getRecipients().any{it.type == javax.mail.Message.RecipientType.BCC && it.address == "[email protected]"}}
}
cleanup: "the mock is removed"