Try to fix testNotificationRequestsPerRuleRateLimits
This commit is contained in:
parent
6e8ba8af13
commit
c6ff49caf5
@ -397,8 +397,8 @@ public class NotificationRuleApiTest extends AbstractNotificationApiTest {
|
|||||||
NotificationRule rule = new NotificationRule();
|
NotificationRule rule = new NotificationRule();
|
||||||
rule.setName("Device created");
|
rule.setName("Device created");
|
||||||
rule.setTriggerType(NotificationRuleTriggerType.ENTITY_ACTION);
|
rule.setTriggerType(NotificationRuleTriggerType.ENTITY_ACTION);
|
||||||
NotificationTemplate template = createNotificationTemplate(NotificationType.ENTITY_ACTION, "Device created", "Device created",
|
NotificationTemplate template = createNotificationTemplate(NotificationType.ENTITY_ACTION,
|
||||||
NotificationDeliveryMethod.WEB, NotificationDeliveryMethod.SMS);
|
"Device created", "Device created", NotificationDeliveryMethod.WEB);
|
||||||
rule.setTemplateId(template.getId());
|
rule.setTemplateId(template.getId());
|
||||||
EntityActionNotificationRuleTriggerConfig triggerConfig = new EntityActionNotificationRuleTriggerConfig();
|
EntityActionNotificationRuleTriggerConfig triggerConfig = new EntityActionNotificationRuleTriggerConfig();
|
||||||
triggerConfig.setEntityTypes(Set.of(EntityType.DEVICE));
|
triggerConfig.setEntityTypes(Set.of(EntityType.DEVICE));
|
||||||
@ -411,14 +411,16 @@ public class NotificationRuleApiTest extends AbstractNotificationApiTest {
|
|||||||
rule.setRecipientsConfig(recipientsConfig);
|
rule.setRecipientsConfig(recipientsConfig);
|
||||||
rule = saveNotificationRule(rule);
|
rule = saveNotificationRule(rule);
|
||||||
|
|
||||||
|
getWsClient().subscribeForUnreadNotificationsCount().waitForReply();
|
||||||
|
getWsClient().registerWaitForUpdate(notificationRequestsLimit);
|
||||||
for (int i = 0; i < notificationRequestsLimit; i++) {
|
for (int i = 0; i < notificationRequestsLimit; i++) {
|
||||||
String name = "device " + i;
|
String name = "device " + i;
|
||||||
createDevice(name, name);
|
createDevice(name, name);
|
||||||
|
TimeUnit.MILLISECONDS.sleep(200);
|
||||||
}
|
}
|
||||||
await().atMost(40, TimeUnit.SECONDS)
|
getWsClient().waitForUpdate(true);
|
||||||
.untilAsserted(() -> {
|
assertThat(getWsClient().getLastCountUpdate().getTotalUnreadCount()).isEqualTo(notificationRequestsLimit);
|
||||||
assertThat(getMyNotifications(false, 100)).size().isEqualTo(notificationRequestsLimit);
|
|
||||||
});
|
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
String name = "device " + (notificationRequestsLimit + i);
|
String name = "device " + (notificationRequestsLimit + i);
|
||||||
createDevice(name, name);
|
createDevice(name, name);
|
||||||
@ -428,7 +430,7 @@ public class NotificationRuleApiTest extends AbstractNotificationApiTest {
|
|||||||
assertThat(rateLimitExceeded).isTrue();
|
assertThat(rateLimitExceeded).isTrue();
|
||||||
|
|
||||||
TimeUnit.SECONDS.sleep(3);
|
TimeUnit.SECONDS.sleep(3);
|
||||||
assertThat(getMyNotifications(false, 100)).size().isEqualTo(notificationRequestsLimit);
|
assertThat(getWsClient().getLastCountUpdate().getTotalUnreadCount()).isEqualTo(notificationRequestsLimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
private <R> R checkNotificationAfter(Callable<R> action, BiConsumer<Notification, R> check) throws Exception {
|
private <R> R checkNotificationAfter(Callable<R> action, BiConsumer<Notification, R> check) throws Exception {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user