Search in sources :

Example 11 with TenantProfile

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

the class BaseTenantProfileControllerTest method testSetDefaultTenantProfile.

@Test
public void testSetDefaultTenantProfile() throws Exception {
    loginSysAdmin();
    TenantProfile tenantProfile = this.createTenantProfile("Tenant Profile 1");
    TenantProfile savedTenantProfile = doPost("/api/tenantProfile", tenantProfile, TenantProfile.class);
    TenantProfile defaultTenantProfile = doPost("/api/tenantProfile/" + savedTenantProfile.getId().getId().toString() + "/default", null, TenantProfile.class);
    Assert.assertNotNull(defaultTenantProfile);
    EntityInfo foundDefaultTenantProfile = doGet("/api/tenantProfileInfo/default", EntityInfo.class);
    Assert.assertNotNull(foundDefaultTenantProfile);
    Assert.assertEquals(savedTenantProfile.getName(), foundDefaultTenantProfile.getName());
    Assert.assertEquals(savedTenantProfile.getId(), foundDefaultTenantProfile.getId());
}
Also used : EntityInfo(org.thingsboard.server.common.data.EntityInfo) TenantProfile(org.thingsboard.server.common.data.TenantProfile) Test(org.junit.Test)

Example 12 with TenantProfile

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

the class BaseTenantProfileControllerTest method testFindTenantProfileById.

@Test
public void testFindTenantProfileById() throws Exception {
    loginSysAdmin();
    TenantProfile tenantProfile = this.createTenantProfile("Tenant Profile");
    TenantProfile savedTenantProfile = doPost("/api/tenantProfile", tenantProfile, TenantProfile.class);
    TenantProfile foundTenantProfile = doGet("/api/tenantProfile/" + savedTenantProfile.getId().getId().toString(), TenantProfile.class);
    Assert.assertNotNull(foundTenantProfile);
    Assert.assertEquals(savedTenantProfile, foundTenantProfile);
}
Also used : TenantProfile(org.thingsboard.server.common.data.TenantProfile) Test(org.junit.Test)

Example 13 with TenantProfile

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

the class BaseTenantProfileControllerTest method testDeleteTenantProfile.

@Test
public void testDeleteTenantProfile() throws Exception {
    loginSysAdmin();
    TenantProfile tenantProfile = this.createTenantProfile("Tenant Profile");
    TenantProfile savedTenantProfile = doPost("/api/tenantProfile", tenantProfile, TenantProfile.class);
    doDelete("/api/tenantProfile/" + savedTenantProfile.getId().getId().toString()).andExpect(status().isOk());
    doGet("/api/tenantProfile/" + savedTenantProfile.getId().getId().toString()).andExpect(status().isNotFound());
}
Also used : TenantProfile(org.thingsboard.server.common.data.TenantProfile) Test(org.junit.Test)

Example 14 with TenantProfile

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

the class BaseTenantProfileControllerTest method testFindTenantProfileInfoById.

@Test
public void testFindTenantProfileInfoById() throws Exception {
    loginSysAdmin();
    TenantProfile tenantProfile = this.createTenantProfile("Tenant Profile");
    TenantProfile savedTenantProfile = doPost("/api/tenantProfile", tenantProfile, TenantProfile.class);
    EntityInfo foundTenantProfileInfo = doGet("/api/tenantProfileInfo/" + savedTenantProfile.getId().getId().toString(), EntityInfo.class);
    Assert.assertNotNull(foundTenantProfileInfo);
    Assert.assertEquals(savedTenantProfile.getId(), foundTenantProfileInfo.getId());
    Assert.assertEquals(savedTenantProfile.getName(), foundTenantProfileInfo.getName());
}
Also used : EntityInfo(org.thingsboard.server.common.data.EntityInfo) TenantProfile(org.thingsboard.server.common.data.TenantProfile) Test(org.junit.Test)

Example 15 with TenantProfile

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

the class BaseTenantProfileControllerTest method testDeleteTenantProfileWithExistingTenant.

@Test
public void testDeleteTenantProfileWithExistingTenant() throws Exception {
    loginSysAdmin();
    TenantProfile tenantProfile = this.createTenantProfile("Tenant Profile");
    TenantProfile savedTenantProfile = doPost("/api/tenantProfile", tenantProfile, TenantProfile.class);
    Tenant tenant = new Tenant();
    tenant.setTitle("My tenant with tenant profile");
    tenant.setTenantProfileId(savedTenantProfile.getId());
    Tenant savedTenant = doPost("/api/tenant", tenant, Tenant.class);
    doDelete("/api/tenantProfile/" + savedTenantProfile.getId().getId().toString()).andExpect(status().isBadRequest()).andExpect(statusReason(containsString("The tenant profile referenced by the tenants cannot be deleted")));
    doDelete("/api/tenant/" + savedTenant.getId().getId().toString()).andExpect(status().isOk());
}
Also used : Tenant(org.thingsboard.server.common.data.Tenant) TenantProfile(org.thingsboard.server.common.data.TenantProfile) Test(org.junit.Test)

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