Search in sources :

Example 46 with TenantProfile

use of org.thingsboard.server.common.data.TenantProfile in project thingsboard by thingsboard.

the class BaseTenantProfileServiceTest method testSaveSameTenantProfileWithDifferentIsolatedTbRuleEngine.

@Test(expected = DataValidationException.class)
public void testSaveSameTenantProfileWithDifferentIsolatedTbRuleEngine() {
    TenantProfile tenantProfile = this.createTenantProfile("Tenant Profile");
    TenantProfile savedTenantProfile = tenantProfileService.saveTenantProfile(TenantId.SYS_TENANT_ID, tenantProfile);
    savedTenantProfile.setIsolatedTbRuleEngine(true);
    tenantProfileService.saveTenantProfile(TenantId.SYS_TENANT_ID, savedTenantProfile);
}
Also used : TenantProfile(org.thingsboard.server.common.data.TenantProfile) Test(org.junit.Test)

Example 47 with TenantProfile

use of org.thingsboard.server.common.data.TenantProfile in project thingsboard by thingsboard.

the class BaseTenantProfileServiceTest method testDeleteTenantProfileWithExistingTenant.

@Test(expected = DataValidationException.class)
public void testDeleteTenantProfileWithExistingTenant() {
    TenantProfile tenantProfile = this.createTenantProfile("Tenant Profile");
    TenantProfile savedTenantProfile = tenantProfileService.saveTenantProfile(TenantId.SYS_TENANT_ID, tenantProfile);
    Tenant tenant = new Tenant();
    tenant.setTitle("Test tenant");
    tenant.setTenantProfileId(savedTenantProfile.getId());
    tenant = tenantService.saveTenant(tenant);
    try {
        tenantProfileService.deleteTenantProfile(TenantId.SYS_TENANT_ID, savedTenantProfile.getId());
    } finally {
        tenantService.deleteTenant(tenant.getId());
    }
}
Also used : Tenant(org.thingsboard.server.common.data.Tenant) TenantProfile(org.thingsboard.server.common.data.TenantProfile) Test(org.junit.Test)

Example 48 with TenantProfile

use of org.thingsboard.server.common.data.TenantProfile in project thingsboard by thingsboard.

the class BaseTenantProfileServiceTest method testSaveTenantProfileWithSameName.

@Test(expected = DataValidationException.class)
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);
}
Also used : TenantProfile(org.thingsboard.server.common.data.TenantProfile) Test(org.junit.Test)

Example 49 with TenantProfile

use of org.thingsboard.server.common.data.TenantProfile in project thingsboard by thingsboard.

the class BaseDeviceServiceTest method testSaveDevicesWithInfiniteMaxDeviceLimit.

@Test
public void testSaveDevicesWithInfiniteMaxDeviceLimit() {
    TenantProfile defaultTenantProfile = tenantProfileService.findDefaultTenantProfile(tenantId);
    defaultTenantProfile.getProfileData().setConfiguration(DefaultTenantProfileConfiguration.builder().maxDevices(Long.MAX_VALUE).build());
    tenantProfileService.saveTenantProfile(tenantId, defaultTenantProfile);
    Device device = this.saveDevice(tenantId, "My device");
    deleteDevice(tenantId, device);
}
Also used : Device(org.thingsboard.server.common.data.Device) TenantProfile(org.thingsboard.server.common.data.TenantProfile) Test(org.junit.Test)

Example 50 with TenantProfile

use of org.thingsboard.server.common.data.TenantProfile in project thingsboard by thingsboard.

the class TenantProfileEntity method toData.

@Override
public TenantProfile toData() {
    TenantProfile tenantProfile = new TenantProfile(new TenantProfileId(this.getUuid()));
    tenantProfile.setCreatedTime(createdTime);
    tenantProfile.setName(name);
    tenantProfile.setDescription(description);
    tenantProfile.setDefault(isDefault);
    tenantProfile.setIsolatedTbCore(isolatedTbCore);
    tenantProfile.setIsolatedTbRuleEngine(isolatedTbRuleEngine);
    tenantProfile.setProfileData(JacksonUtil.convertValue(profileData, TenantProfileData.class));
    return tenantProfile;
}
Also used : TenantProfileId(org.thingsboard.server.common.data.id.TenantProfileId) TenantProfileData(org.thingsboard.server.common.data.tenant.profile.TenantProfileData) TenantProfile(org.thingsboard.server.common.data.TenantProfile)

Aggregations

TenantProfile (org.thingsboard.server.common.data.TenantProfile)56 Test (org.junit.Test)33 Tenant (org.thingsboard.server.common.data.Tenant)10 DefaultTenantProfileConfiguration (org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration)10 TenantId (org.thingsboard.server.common.data.id.TenantId)9 TenantProfileData (org.thingsboard.server.common.data.tenant.profile.TenantProfileData)9 ArrayList (java.util.ArrayList)8 EntityInfo (org.thingsboard.server.common.data.EntityInfo)7 List (java.util.List)6 TenantProfileId (org.thingsboard.server.common.data.id.TenantProfileId)6 ApiUsageState (org.thingsboard.server.common.data.ApiUsageState)5 EntityType (org.thingsboard.server.common.data.EntityType)5 Collections (java.util.Collections)4 Collectors (java.util.stream.Collectors)4 ThingsboardException (org.thingsboard.server.common.data.exception.ThingsboardException)4 BasicTsKvEntry (org.thingsboard.server.common.data.kv.BasicTsKvEntry)4 TsKvEntry (org.thingsboard.server.common.data.kv.TsKvEntry)4 PageLink (org.thingsboard.server.common.data.page.PageLink)4 DataValidationException (org.thingsboard.server.dao.exception.DataValidationException)4 Map (java.util.Map)3