Browse Source

Truncate notification table on test finish

pull/13285/head
ViacheslavKlimov 1 year ago
parent
commit
03845450ef
  1. 5
      application/src/test/java/org/thingsboard/server/controller/AbstractWebTest.java
  2. 4
      application/src/test/java/org/thingsboard/server/service/notification/AbstractNotificationApiTest.java

5
application/src/test/java/org/thingsboard/server/controller/AbstractWebTest.java

@ -48,6 +48,7 @@ import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.mock.http.MockHttpInputMessage;
import org.springframework.mock.http.MockHttpOutputMessage;
import org.springframework.mock.web.MockMultipartFile;
@ -281,6 +282,8 @@ public abstract class AbstractWebTest extends AbstractInMemoryStorageTest {
@Autowired
protected InMemoryStorage storage;
protected JdbcTemplate jdbcTemplate;
@MockBean
protected CfRocksDb cfRocksDb;
@ -392,6 +395,8 @@ public abstract class AbstractWebTest extends AbstractInMemoryStorageTest {
tenantProfileService.deleteTenantProfiles(TenantId.SYS_TENANT_ID);
jdbcTemplate.execute("TRUNCATE TABLE notification");
log.info("Executed web test teardown");
}

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

@ -21,7 +21,6 @@ import org.junit.After;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.data.util.Pair;
import org.springframework.jdbc.core.JdbcTemplate;
import org.thingsboard.rule.engine.api.MailService;
import org.thingsboard.rule.engine.api.notification.SlackService;
import org.thingsboard.server.common.data.User;
@ -89,8 +88,6 @@ public abstract class AbstractNotificationApiTest extends AbstractControllerTest
protected SqlPartitioningRepository partitioningRepository;
@Autowired
protected DefaultNotifications defaultNotifications;
@Autowired
private JdbcTemplate jdbcTemplate;
public static final String DEFAULT_NOTIFICATION_SUBJECT = "Just a test";
public static final NotificationType DEFAULT_NOTIFICATION_TYPE = NotificationType.GENERAL;
@ -101,7 +98,6 @@ public abstract class AbstractNotificationApiTest extends AbstractControllerTest
notificationRuleService.deleteNotificationRulesByTenantId(TenantId.SYS_TENANT_ID);
notificationTemplateService.deleteNotificationTemplatesByTenantId(TenantId.SYS_TENANT_ID);
notificationTargetService.deleteNotificationTargetsByTenantId(TenantId.SYS_TENANT_ID);
jdbcTemplate.execute("TRUNCATE TABLE notification");
partitioningRepository.cleanupPartitionsCache("notification", Long.MAX_VALUE, 0);
notificationSettingsService.deleteNotificationSettings(TenantId.SYS_TENANT_ID);
}

Loading…
Cancel
Save