Browse Source

Merge pull request #9363 from thingsboard/hotfix/3.6

Hotfix/3.6
pull/9381/head
Andrew Shvayka 3 years ago
committed by GitHub
parent
commit
43ccbdb787
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      application/src/test/java/org/thingsboard/server/service/notification/AbstractNotificationApiTest.java
  2. 5
      application/src/test/java/org/thingsboard/server/service/notification/NotificationApiTest.java
  3. 4
      application/src/test/java/org/thingsboard/server/service/notification/NotificationRuleApiTest.java

4
application/src/test/java/org/thingsboard/server/service/notification/AbstractNotificationApiTest.java

@ -61,6 +61,7 @@ import org.thingsboard.server.dao.notification.NotificationRequestService;
import org.thingsboard.server.dao.notification.NotificationRuleService;
import org.thingsboard.server.dao.notification.NotificationTargetService;
import org.thingsboard.server.dao.notification.NotificationTemplateService;
import org.thingsboard.server.dao.sqlts.insert.sql.SqlPartitioningRepository;
import java.net.URISyntaxException;
import java.util.Arrays;
@ -90,6 +91,8 @@ public abstract class AbstractNotificationApiTest extends AbstractControllerTest
protected NotificationTargetService notificationTargetService;
@Autowired
protected NotificationRequestService notificationRequestService;
@Autowired
protected SqlPartitioningRepository partitioningRepository;
public static final String DEFAULT_NOTIFICATION_SUBJECT = "Just a test";
public static final NotificationType DEFAULT_NOTIFICATION_TYPE = NotificationType.GENERAL;
@ -100,6 +103,7 @@ public abstract class AbstractNotificationApiTest extends AbstractControllerTest
notificationRuleService.deleteNotificationRulesByTenantId(TenantId.SYS_TENANT_ID);
notificationTemplateService.deleteNotificationTemplatesByTenantId(TenantId.SYS_TENANT_ID);
notificationTargetService.deleteNotificationTargetsByTenantId(TenantId.SYS_TENANT_ID);
partitioningRepository.dropPartitionsBefore("notification", Long.MAX_VALUE, 1);
}
protected NotificationTarget createNotificationTarget(UserId... usersIds) {

5
application/src/test/java/org/thingsboard/server/service/notification/NotificationApiTest.java

@ -286,18 +286,19 @@ public class NotificationApiTest extends AbstractNotificationApiTest {
@Test
public void whenTenantIsDeleted_thenDeleteNotificationRequests() throws Exception {
createDifferentTenant();
TenantId tenantId = differentTenantId;
NotificationTarget target = createNotificationTarget(savedDifferentTenantUser.getId());
int notificationsCount = 20;
for (int i = 0; i < notificationsCount; i++) {
NotificationRequest request = submitNotificationRequest(target.getId(), "Test " + i, NotificationDeliveryMethod.WEB);
awaitNotificationRequest(request.getId());
}
List<NotificationRequest> requests = notificationRequestService.findNotificationRequestsByTenantIdAndOriginatorType(differentTenantId, EntityType.USER, new PageLink(100)).getData();
List<NotificationRequest> requests = notificationRequestService.findNotificationRequestsByTenantIdAndOriginatorType(tenantId, EntityType.USER, new PageLink(100)).getData();
assertThat(requests).size().isEqualTo(notificationsCount);
deleteDifferentTenant();
assertThat(notificationRequestService.findNotificationRequestsByTenantIdAndOriginatorType(differentTenantId, EntityType.USER, new PageLink(1)).getTotalElements())
assertThat(notificationRequestService.findNotificationRequestsByTenantIdAndOriginatorType(tenantId, EntityType.USER, new PageLink(1)).getTotalElements())
.isZero();
}

4
application/src/test/java/org/thingsboard/server/service/notification/NotificationRuleApiTest.java

@ -456,9 +456,7 @@ public class NotificationRuleApiTest extends AbstractNotificationApiTest {
loginSysAdmin();
notifications = await().atMost(30, TimeUnit.SECONDS)
.until(() -> getMyNotifications(true, 10).stream()
.filter(notification -> notification.getType() == NotificationType.RATE_LIMITS)
.collect(Collectors.toList()), list -> list.size() == 1);
.until(() -> getMyNotifications(true, 10), list -> list.size() == 1);
assertThat(notifications).allSatisfy(notification -> {
assertThat(notification.getSubject()).isEqualTo("Rate limits exceeded for tenant " + TEST_TENANT_NAME);
});

Loading…
Cancel
Save