|
|
|
@ -19,6 +19,7 @@ import com.fasterxml.jackson.databind.node.NullNode; |
|
|
|
import org.junit.After; |
|
|
|
import org.junit.Assert; |
|
|
|
import org.junit.Test; |
|
|
|
import org.junit.jupiter.api.Assertions; |
|
|
|
import org.thingsboard.server.common.data.DataConstants; |
|
|
|
import org.thingsboard.server.common.data.EntityInfo; |
|
|
|
import org.thingsboard.server.common.data.Tenant; |
|
|
|
@ -154,30 +155,36 @@ public abstract class BaseTenantProfileServiceTest extends AbstractServiceTest { |
|
|
|
Assert.assertEquals(savedTenantProfile2.getId(), defaultTenantProfile.getId()); |
|
|
|
} |
|
|
|
|
|
|
|
@Test(expected = DataValidationException.class) |
|
|
|
@Test |
|
|
|
public void testSaveTenantProfileWithEmptyName() { |
|
|
|
TenantProfile tenantProfile = new TenantProfile(); |
|
|
|
tenantProfileService.saveTenantProfile(TenantId.SYS_TENANT_ID, tenantProfile); |
|
|
|
Assertions.assertThrows(DataValidationException.class, () -> { |
|
|
|
tenantProfileService.saveTenantProfile(TenantId.SYS_TENANT_ID, tenantProfile); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
@Test(expected = DataValidationException.class) |
|
|
|
@Test |
|
|
|
public void testSaveTenantProfileWithSameName() { |
|
|
|
TenantProfile tenantProfile = this.createTenantProfile("Tenant Profile"); |
|
|
|
tenantProfileService.saveTenantProfile(TenantId.SYS_TENANT_ID, tenantProfile); |
|
|
|
TenantProfile tenantProfile2 = this.createTenantProfile("Tenant Profile"); |
|
|
|
tenantProfileService.saveTenantProfile(TenantId.SYS_TENANT_ID, tenantProfile2); |
|
|
|
Assertions.assertThrows(DataValidationException.class, () -> { |
|
|
|
tenantProfileService.saveTenantProfile(TenantId.SYS_TENANT_ID, tenantProfile2); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
@Test(expected = DataValidationException.class) |
|
|
|
@Test |
|
|
|
public void testSaveSameTenantProfileWithDifferentIsolatedTbRuleEngine() { |
|
|
|
TenantProfile tenantProfile = this.createTenantProfile("Tenant Profile"); |
|
|
|
TenantProfile savedTenantProfile = tenantProfileService.saveTenantProfile(TenantId.SYS_TENANT_ID, tenantProfile); |
|
|
|
savedTenantProfile.setIsolatedTbRuleEngine(true); |
|
|
|
addMainQueueConfig(savedTenantProfile); |
|
|
|
tenantProfileService.saveTenantProfile(TenantId.SYS_TENANT_ID, savedTenantProfile); |
|
|
|
Assertions.assertThrows(DataValidationException.class, () -> { |
|
|
|
tenantProfileService.saveTenantProfile(TenantId.SYS_TENANT_ID, savedTenantProfile); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
@Test(expected = DataValidationException.class) |
|
|
|
@Test |
|
|
|
public void testDeleteTenantProfileWithExistingTenant() { |
|
|
|
TenantProfile tenantProfile = this.createTenantProfile("Tenant Profile"); |
|
|
|
TenantProfile savedTenantProfile = tenantProfileService.saveTenantProfile(TenantId.SYS_TENANT_ID, tenantProfile); |
|
|
|
@ -186,7 +193,9 @@ public abstract class BaseTenantProfileServiceTest extends AbstractServiceTest { |
|
|
|
tenant.setTenantProfileId(savedTenantProfile.getId()); |
|
|
|
tenant = tenantService.saveTenant(tenant); |
|
|
|
try { |
|
|
|
tenantProfileService.deleteTenantProfile(TenantId.SYS_TENANT_ID, savedTenantProfile.getId()); |
|
|
|
Assertions.assertThrows(DataValidationException.class, () -> { |
|
|
|
tenantProfileService.deleteTenantProfile(TenantId.SYS_TENANT_ID, savedTenantProfile.getId()); |
|
|
|
}); |
|
|
|
} finally { |
|
|
|
tenantService.deleteTenant(tenant.getId()); |
|
|
|
} |
|
|
|
|