diff --git a/application/src/test/java/org/thingsboard/server/service/notification/NotificationRuleApiTest.java b/application/src/test/java/org/thingsboard/server/service/notification/NotificationRuleApiTest.java index 20800f1bb9..31507758de 100644 --- a/application/src/test/java/org/thingsboard/server/service/notification/NotificationRuleApiTest.java +++ b/application/src/test/java/org/thingsboard/server/service/notification/NotificationRuleApiTest.java @@ -791,10 +791,9 @@ public class NotificationRuleApiTest extends AbstractNotificationApiTest { public void testNotificationRuleProcessing_resourcesShortage() throws Exception { loginSysAdmin(); ResourcesShortageNotificationRuleTriggerConfig triggerConfig = ResourcesShortageNotificationRuleTriggerConfig.builder() - .resource(Resource.CPU.name()) .cpuThreshold(0.01f) - .ramThreshold(0.01f) - .storageThreshold(0.01f) + .ramThreshold(1f) + .storageThreshold(1f) .build(); createNotificationRule(triggerConfig, "Test", "Test", createNotificationTarget(tenantAdminUserId).getId()); loginTenantAdmin(); @@ -805,15 +804,16 @@ public class NotificationRuleApiTest extends AbstractNotificationApiTest { TimeUnit.SECONDS.sleep(5); - assertThat(getMyNotifications(false, 100)).size().isEqualTo(3); + assertThat(getMyNotifications(false, 100)).size().isOne(); } @Test public void testNotificationsDeduplication_resourcesShortage() throws Exception { loginSysAdmin(); ResourcesShortageNotificationRuleTriggerConfig triggerConfig = ResourcesShortageNotificationRuleTriggerConfig.builder() - .resource(Resource.CPU.name()) .cpuThreshold(0.1f) + .ramThreshold(1f) + .storageThreshold(1f) .build(); createNotificationRule(triggerConfig, "Test", "Test", createNotificationTarget(tenantAdminUserId).getId()); loginTenantAdmin(); diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/notification/rule/trigger/config/ResourcesShortageNotificationRuleTriggerConfig.java b/common/data/src/main/java/org/thingsboard/server/common/data/notification/rule/trigger/config/ResourcesShortageNotificationRuleTriggerConfig.java index d542292113..e8ea6c9be5 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/notification/rule/trigger/config/ResourcesShortageNotificationRuleTriggerConfig.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/notification/rule/trigger/config/ResourcesShortageNotificationRuleTriggerConfig.java @@ -32,7 +32,6 @@ public class ResourcesShortageNotificationRuleTriggerConfig implements Notificat @Serial private static final long serialVersionUID = 339395299693241424L; - private String resource; @Max(1) private float cpuThreshold; // in percents @Max(1) diff --git a/dao/src/main/java/org/thingsboard/server/dao/notification/DefaultNotifications.java b/dao/src/main/java/org/thingsboard/server/dao/notification/DefaultNotifications.java index 2f209d8546..960cbfcd73 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/notification/DefaultNotifications.java +++ b/dao/src/main/java/org/thingsboard/server/dao/notification/DefaultNotifications.java @@ -382,7 +382,7 @@ public class DefaultNotifications { .icon("warning") .rule(DefaultRule.builder() .name("Resources shortage") - .triggerConfig(ResourcesShortageNotificationRuleTriggerConfig.builder().resource(Resource.CPU.name()).cpuThreshold(0.8f).storageThreshold(0.8f).ramThreshold(0.8f).build()) + .triggerConfig(ResourcesShortageNotificationRuleTriggerConfig.builder().cpuThreshold(0.8f).storageThreshold(0.8f).ramThreshold(0.8f).build()) .description("Send notification to system admins when resources shortage is running low") .build()) .color(RED_COLOR)