20 changed files with 1037 additions and 34 deletions
@ -0,0 +1,192 @@ |
|||
/** |
|||
* Copyright © 2016-2020 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.controller; |
|||
|
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.security.access.prepost.PreAuthorize; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.bind.annotation.ResponseStatus; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.thingsboard.server.common.data.DeviceProfile; |
|||
import org.thingsboard.server.common.data.EntityInfo; |
|||
import org.thingsboard.server.common.data.EntityType; |
|||
import org.thingsboard.server.common.data.audit.ActionType; |
|||
import org.thingsboard.server.common.data.exception.ThingsboardException; |
|||
import org.thingsboard.server.common.data.id.DeviceProfileId; |
|||
import org.thingsboard.server.common.data.page.PageData; |
|||
import org.thingsboard.server.common.data.page.PageLink; |
|||
import org.thingsboard.server.queue.util.TbCoreComponent; |
|||
import org.thingsboard.server.service.security.permission.Operation; |
|||
import org.thingsboard.server.service.security.permission.Resource; |
|||
|
|||
@RestController |
|||
@TbCoreComponent |
|||
@RequestMapping("/api") |
|||
@Slf4j |
|||
public class DeviceProfileController extends BaseController { |
|||
|
|||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") |
|||
@RequestMapping(value = "/deviceProfile/{deviceProfileId}", method = RequestMethod.GET) |
|||
@ResponseBody |
|||
public DeviceProfile getDeviceProfileById(@PathVariable("deviceProfileId") String strDeviceProfileId) throws ThingsboardException { |
|||
checkParameter("deviceProfileId", strDeviceProfileId); |
|||
try { |
|||
DeviceProfileId deviceProfileId = new DeviceProfileId(toUUID(strDeviceProfileId)); |
|||
return checkDeviceProfileId(deviceProfileId, Operation.READ); |
|||
} catch (Exception e) { |
|||
throw handleException(e); |
|||
} |
|||
} |
|||
|
|||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
|||
@RequestMapping(value = "/deviceProfileInfo/{deviceProfileId}", method = RequestMethod.GET) |
|||
@ResponseBody |
|||
public EntityInfo getDeviceProfileInfoById(@PathVariable("deviceProfileId") String strDeviceProfileId) throws ThingsboardException { |
|||
checkParameter("deviceProfileId", strDeviceProfileId); |
|||
try { |
|||
DeviceProfileId deviceProfileId = new DeviceProfileId(toUUID(strDeviceProfileId)); |
|||
return checkNotNull(deviceProfileService.findDeviceProfileInfoById(getTenantId(), deviceProfileId)); |
|||
} catch (Exception e) { |
|||
throw handleException(e); |
|||
} |
|||
} |
|||
|
|||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
|||
@RequestMapping(value = "/deviceProfileInfo/default", method = RequestMethod.GET) |
|||
@ResponseBody |
|||
public EntityInfo getDefaultDeviceProfileInfo() throws ThingsboardException { |
|||
try { |
|||
return checkNotNull(deviceProfileService.findDefaultDeviceProfileInfo(getTenantId())); |
|||
} catch (Exception e) { |
|||
throw handleException(e); |
|||
} |
|||
} |
|||
|
|||
@PreAuthorize("hasAuthority('TENANT_ADMIN')") |
|||
@RequestMapping(value = "/deviceProfile", method = RequestMethod.POST) |
|||
@ResponseBody |
|||
public DeviceProfile saveDeviceProfile(@RequestBody DeviceProfile deviceProfile) throws ThingsboardException { |
|||
try { |
|||
deviceProfile.setTenantId(getTenantId()); |
|||
|
|||
checkEntity(deviceProfile.getId(), deviceProfile, Resource.DEVICE_PROFILE); |
|||
|
|||
DeviceProfile savedDeviceProfile = checkNotNull(deviceProfileService.saveDeviceProfile(deviceProfile)); |
|||
|
|||
logEntityAction(savedDeviceProfile.getId(), savedDeviceProfile, |
|||
null, |
|||
savedDeviceProfile.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null); |
|||
|
|||
return savedDeviceProfile; |
|||
} catch (Exception e) { |
|||
logEntityAction(emptyId(EntityType.DEVICE_PROFILE), deviceProfile, |
|||
null, deviceProfile.getId() == null ? ActionType.ADDED : ActionType.UPDATED, e); |
|||
throw handleException(e); |
|||
} |
|||
} |
|||
|
|||
@PreAuthorize("hasAuthority('TENANT_ADMIN')") |
|||
@RequestMapping(value = "/deviceProfile/{deviceProfileId}", method = RequestMethod.DELETE) |
|||
@ResponseStatus(value = HttpStatus.OK) |
|||
public void deleteDeviceProfile(@PathVariable("deviceProfileId") String strDeviceProfileId) throws ThingsboardException { |
|||
checkParameter("deviceProfileId", strDeviceProfileId); |
|||
try { |
|||
DeviceProfileId deviceProfileId = new DeviceProfileId(toUUID(strDeviceProfileId)); |
|||
DeviceProfile deviceProfile = checkDeviceProfileId(deviceProfileId, Operation.DELETE); |
|||
deviceProfileService.deleteDeviceProfile(getTenantId(), deviceProfileId); |
|||
|
|||
logEntityAction(deviceProfileId, deviceProfile, |
|||
null, |
|||
ActionType.DELETED, null, strDeviceProfileId); |
|||
|
|||
} catch (Exception e) { |
|||
logEntityAction(emptyId(EntityType.DEVICE_PROFILE), |
|||
null, |
|||
null, |
|||
ActionType.DELETED, e, strDeviceProfileId); |
|||
throw handleException(e); |
|||
} |
|||
} |
|||
|
|||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") |
|||
@RequestMapping(value = "/deviceProfile/{deviceProfileId}/default", method = RequestMethod.POST) |
|||
@ResponseBody |
|||
public DeviceProfile setDefaultDeviceProfile(@PathVariable("deviceProfileId") String strDeviceProfileId) throws ThingsboardException { |
|||
checkParameter("deviceProfileId", strDeviceProfileId); |
|||
try { |
|||
DeviceProfileId deviceProfileId = new DeviceProfileId(toUUID(strDeviceProfileId)); |
|||
DeviceProfile deviceProfile = checkDeviceProfileId(deviceProfileId, Operation.WRITE); |
|||
DeviceProfile previousDefaultDeviceProfile = deviceProfileService.findDefaultDeviceProfile(getTenantId()); |
|||
if (deviceProfileService.setDefaultDeviceProfile(getTenantId(), deviceProfileId)) { |
|||
if (previousDefaultDeviceProfile != null) { |
|||
previousDefaultDeviceProfile = deviceProfileService.findDeviceProfileById(getTenantId(), previousDefaultDeviceProfile.getId()); |
|||
|
|||
logEntityAction(previousDefaultDeviceProfile.getId(), previousDefaultDeviceProfile, |
|||
null, ActionType.UPDATED, null); |
|||
} |
|||
deviceProfile = deviceProfileService.findDeviceProfileById(getTenantId(), deviceProfileId); |
|||
|
|||
logEntityAction(deviceProfile.getId(), deviceProfile, |
|||
null, ActionType.UPDATED, null); |
|||
} |
|||
return deviceProfile; |
|||
} catch (Exception e) { |
|||
logEntityAction(emptyId(EntityType.DEVICE_PROFILE), |
|||
null, |
|||
null, |
|||
ActionType.UPDATED, e, strDeviceProfileId); |
|||
throw handleException(e); |
|||
} |
|||
} |
|||
|
|||
@PreAuthorize("hasAuthority('TENANT_ADMIN')") |
|||
@RequestMapping(value = "/deviceProfiles", params = {"pageSize", "page"}, method = RequestMethod.GET) |
|||
@ResponseBody |
|||
public PageData<DeviceProfile> getDeviceProfiles(@RequestParam int pageSize, |
|||
@RequestParam int page, |
|||
@RequestParam(required = false) String textSearch, |
|||
@RequestParam(required = false) String sortProperty, |
|||
@RequestParam(required = false) String sortOrder) throws ThingsboardException { |
|||
try { |
|||
PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); |
|||
return checkNotNull(deviceProfileService.findDeviceProfiles(getTenantId(), pageLink)); |
|||
} catch (Exception e) { |
|||
throw handleException(e); |
|||
} |
|||
} |
|||
|
|||
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") |
|||
@RequestMapping(value = "/deviceProfileInfos", params = {"pageSize", "page"}, method = RequestMethod.GET) |
|||
@ResponseBody |
|||
public PageData<EntityInfo> getDeviceProfileInfos(@RequestParam int pageSize, |
|||
@RequestParam int page, |
|||
@RequestParam(required = false) String textSearch, |
|||
@RequestParam(required = false) String sortProperty, |
|||
@RequestParam(required = false) String sortOrder) throws ThingsboardException { |
|||
try { |
|||
PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); |
|||
return checkNotNull(deviceProfileService.findDeviceProfileInfos(getTenantId(), pageLink)); |
|||
} catch (Exception e) { |
|||
throw handleException(e); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,162 @@ |
|||
/** |
|||
* Copyright © 2016-2020 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.controller; |
|||
|
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.security.access.prepost.PreAuthorize; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
import org.springframework.web.bind.annotation.ResponseStatus; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.thingsboard.server.common.data.EntityInfo; |
|||
import org.thingsboard.server.common.data.TenantProfile; |
|||
import org.thingsboard.server.common.data.exception.ThingsboardException; |
|||
import org.thingsboard.server.common.data.id.TenantProfileId; |
|||
import org.thingsboard.server.common.data.page.PageData; |
|||
import org.thingsboard.server.common.data.page.PageLink; |
|||
import org.thingsboard.server.queue.util.TbCoreComponent; |
|||
import org.thingsboard.server.service.security.permission.Operation; |
|||
import org.thingsboard.server.service.security.permission.Resource; |
|||
|
|||
@RestController |
|||
@TbCoreComponent |
|||
@RequestMapping("/api") |
|||
@Slf4j |
|||
public class TenantProfileController extends BaseController { |
|||
|
|||
@PreAuthorize("hasAnyAuthority('SYS_ADMIN')") |
|||
@RequestMapping(value = "/tenantProfile/{tenantProfileId}", method = RequestMethod.GET) |
|||
@ResponseBody |
|||
public TenantProfile getTenantProfileById(@PathVariable("tenantProfileId") String strTenantProfileId) throws ThingsboardException { |
|||
checkParameter("tenantProfileId", strTenantProfileId); |
|||
try { |
|||
TenantProfileId tenantProfileId = new TenantProfileId(toUUID(strTenantProfileId)); |
|||
return checkTenantProfileId(tenantProfileId, Operation.READ); |
|||
} catch (Exception e) { |
|||
throw handleException(e); |
|||
} |
|||
} |
|||
|
|||
@PreAuthorize("hasAnyAuthority('SYS_ADMIN')") |
|||
@RequestMapping(value = "/tenantProfileInfo/{tenantProfileId}", method = RequestMethod.GET) |
|||
@ResponseBody |
|||
public EntityInfo getTenantProfileInfoById(@PathVariable("tenantProfileId") String strTenantProfileId) throws ThingsboardException { |
|||
checkParameter("tenantProfileId", strTenantProfileId); |
|||
try { |
|||
TenantProfileId tenantProfileId = new TenantProfileId(toUUID(strTenantProfileId)); |
|||
return checkNotNull(tenantProfileService.findTenantProfileInfoById(getTenantId(), tenantProfileId)); |
|||
} catch (Exception e) { |
|||
throw handleException(e); |
|||
} |
|||
} |
|||
|
|||
@PreAuthorize("hasAnyAuthority('SYS_ADMIN')") |
|||
@RequestMapping(value = "/tenantProfileInfo/default", method = RequestMethod.GET) |
|||
@ResponseBody |
|||
public EntityInfo getDefaultTenantProfileInfo() throws ThingsboardException { |
|||
try { |
|||
return checkNotNull(tenantProfileService.findDefaultTenantProfileInfo(getTenantId())); |
|||
} catch (Exception e) { |
|||
throw handleException(e); |
|||
} |
|||
} |
|||
|
|||
@PreAuthorize("hasAuthority('SYS_ADMIN')") |
|||
@RequestMapping(value = "/tenantProfile", method = RequestMethod.POST) |
|||
@ResponseBody |
|||
public TenantProfile saveTenantProfile(@RequestBody TenantProfile tenantProfile) throws ThingsboardException { |
|||
try { |
|||
boolean newTenantProfile = tenantProfile.getId() == null; |
|||
if (newTenantProfile) { |
|||
accessControlService |
|||
.checkPermission(getCurrentUser(), Resource.TENANT_PROFILE, Operation.CREATE); |
|||
} else { |
|||
checkEntityId(tenantProfile.getId(), Operation.WRITE); |
|||
} |
|||
|
|||
tenantProfile = checkNotNull(tenantProfileService.saveTenantProfile(getTenantId(), tenantProfile)); |
|||
return tenantProfile; |
|||
} catch (Exception e) { |
|||
throw handleException(e); |
|||
} |
|||
} |
|||
|
|||
@PreAuthorize("hasAuthority('SYS_ADMIN')") |
|||
@RequestMapping(value = "/tenantProfile/{tenantProfileId}", method = RequestMethod.DELETE) |
|||
@ResponseStatus(value = HttpStatus.OK) |
|||
public void deleteTenantProfile(@PathVariable("tenantProfileId") String strTenantProfileId) throws ThingsboardException { |
|||
checkParameter("tenantProfileId", strTenantProfileId); |
|||
try { |
|||
TenantProfileId tenantProfileId = new TenantProfileId(toUUID(strTenantProfileId)); |
|||
checkTenantProfileId(tenantProfileId, Operation.DELETE); |
|||
tenantProfileService.deleteTenantProfile(getTenantId(), tenantProfileId); |
|||
} catch (Exception e) { |
|||
throw handleException(e); |
|||
} |
|||
} |
|||
|
|||
@PreAuthorize("hasAnyAuthority('SYS_ADMIN')") |
|||
@RequestMapping(value = "/tenantProfile/{tenantProfileId}/default", method = RequestMethod.POST) |
|||
@ResponseBody |
|||
public TenantProfile setDefaultTenantProfile(@PathVariable("tenantProfileId") String strTenantProfileId) throws ThingsboardException { |
|||
checkParameter("tenantProfileId", strTenantProfileId); |
|||
try { |
|||
TenantProfileId tenantProfileId = new TenantProfileId(toUUID(strTenantProfileId)); |
|||
TenantProfile tenantProfile = checkTenantProfileId(tenantProfileId, Operation.WRITE); |
|||
tenantProfileService.setDefaultTenantProfile(getTenantId(), tenantProfileId); |
|||
return tenantProfile; |
|||
} catch (Exception e) { |
|||
throw handleException(e); |
|||
} |
|||
} |
|||
|
|||
@PreAuthorize("hasAuthority('SYS_ADMIN')") |
|||
@RequestMapping(value = "/tenantProfiles", params = {"pageSize", "page"}, method = RequestMethod.GET) |
|||
@ResponseBody |
|||
public PageData<TenantProfile> getTenantProfiles(@RequestParam int pageSize, |
|||
@RequestParam int page, |
|||
@RequestParam(required = false) String textSearch, |
|||
@RequestParam(required = false) String sortProperty, |
|||
@RequestParam(required = false) String sortOrder) throws ThingsboardException { |
|||
try { |
|||
PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); |
|||
return checkNotNull(tenantProfileService.findTenantProfiles(getTenantId(), pageLink)); |
|||
} catch (Exception e) { |
|||
throw handleException(e); |
|||
} |
|||
} |
|||
|
|||
@PreAuthorize("hasAuthority('SYS_ADMIN')") |
|||
@RequestMapping(value = "/tenantProfileInfos", params = {"pageSize", "page"}, method = RequestMethod.GET) |
|||
@ResponseBody |
|||
public PageData<EntityInfo> getTenantProfileInfos(@RequestParam int pageSize, |
|||
@RequestParam int page, |
|||
@RequestParam(required = false) String textSearch, |
|||
@RequestParam(required = false) String sortProperty, |
|||
@RequestParam(required = false) String sortOrder) throws ThingsboardException { |
|||
try { |
|||
PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); |
|||
return checkNotNull(tenantProfileService.findTenantProfileInfos(getTenantId(), pageLink)); |
|||
} catch (Exception e) { |
|||
throw handleException(e); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,266 @@ |
|||
/** |
|||
* Copyright © 2016-2020 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.controller; |
|||
|
|||
import com.datastax.oss.driver.api.core.uuid.Uuids; |
|||
import com.fasterxml.jackson.core.type.TypeReference; |
|||
import org.junit.After; |
|||
import org.junit.Assert; |
|||
import org.junit.Before; |
|||
import org.junit.Test; |
|||
import org.thingsboard.server.common.data.DeviceProfile; |
|||
import org.thingsboard.server.common.data.EntityInfo; |
|||
import org.thingsboard.server.common.data.Tenant; |
|||
import org.thingsboard.server.common.data.User; |
|||
import org.thingsboard.server.common.data.id.RuleChainId; |
|||
import org.thingsboard.server.common.data.page.PageData; |
|||
import org.thingsboard.server.common.data.page.PageLink; |
|||
import org.thingsboard.server.common.data.security.Authority; |
|||
import org.thingsboard.server.dao.util.mapping.JacksonUtil; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.Collections; |
|||
import java.util.List; |
|||
import java.util.stream.Collectors; |
|||
|
|||
import static org.hamcrest.Matchers.containsString; |
|||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; |
|||
|
|||
public abstract class BaseDeviceProfileControllerTest extends AbstractControllerTest { |
|||
|
|||
private IdComparator<DeviceProfile> idComparator = new IdComparator<>(); |
|||
private IdComparator<EntityInfo> deviceProfileInfoIdComparator = new IdComparator<>(); |
|||
|
|||
private Tenant savedTenant; |
|||
private User tenantAdmin; |
|||
|
|||
@Before |
|||
public void beforeTest() throws Exception { |
|||
loginSysAdmin(); |
|||
|
|||
Tenant tenant = new Tenant(); |
|||
tenant.setTitle("My tenant"); |
|||
savedTenant = doPost("/api/tenant", tenant, Tenant.class); |
|||
Assert.assertNotNull(savedTenant); |
|||
|
|||
tenantAdmin = new User(); |
|||
tenantAdmin.setAuthority(Authority.TENANT_ADMIN); |
|||
tenantAdmin.setTenantId(savedTenant.getId()); |
|||
tenantAdmin.setEmail("tenant2@thingsboard.org"); |
|||
tenantAdmin.setFirstName("Joe"); |
|||
tenantAdmin.setLastName("Downs"); |
|||
|
|||
tenantAdmin = createUserAndLogin(tenantAdmin, "testPassword1"); |
|||
} |
|||
|
|||
@After |
|||
public void afterTest() throws Exception { |
|||
loginSysAdmin(); |
|||
|
|||
doDelete("/api/tenant/" + savedTenant.getId().getId().toString()) |
|||
.andExpect(status().isOk()); |
|||
} |
|||
|
|||
@Test |
|||
public void testSaveDeviceProfile() throws Exception { |
|||
DeviceProfile deviceProfile = this.createDeviceProfile("Device Profile"); |
|||
DeviceProfile savedDeviceProfile = doPost("/api/deviceProfile", deviceProfile, DeviceProfile.class); |
|||
Assert.assertNotNull(savedDeviceProfile); |
|||
Assert.assertNotNull(savedDeviceProfile.getId()); |
|||
Assert.assertTrue(savedDeviceProfile.getCreatedTime() > 0); |
|||
Assert.assertEquals(deviceProfile.getName(), savedDeviceProfile.getName()); |
|||
Assert.assertEquals(deviceProfile.getDescription(), savedDeviceProfile.getDescription()); |
|||
Assert.assertEquals(deviceProfile.getProfileData(), savedDeviceProfile.getProfileData()); |
|||
Assert.assertEquals(deviceProfile.isDefault(), savedDeviceProfile.isDefault()); |
|||
Assert.assertEquals(deviceProfile.getDefaultRuleChainId(), savedDeviceProfile.getDefaultRuleChainId()); |
|||
savedDeviceProfile.setName("New device profile"); |
|||
doPost("/api/deviceProfile", savedDeviceProfile, DeviceProfile.class); |
|||
DeviceProfile foundDeviceProfile = doGet("/api/deviceProfile/"+savedDeviceProfile.getId().getId().toString(), DeviceProfile.class); |
|||
Assert.assertEquals(savedDeviceProfile.getName(), foundDeviceProfile.getName()); |
|||
} |
|||
|
|||
@Test |
|||
public void testFindDeviceProfileById() throws Exception { |
|||
DeviceProfile deviceProfile = this.createDeviceProfile("Device Profile"); |
|||
DeviceProfile savedDeviceProfile = doPost("/api/deviceProfile", deviceProfile, DeviceProfile.class); |
|||
DeviceProfile foundDeviceProfile = doGet("/api/deviceProfile/"+savedDeviceProfile.getId().getId().toString(), DeviceProfile.class); |
|||
Assert.assertNotNull(foundDeviceProfile); |
|||
Assert.assertEquals(savedDeviceProfile, foundDeviceProfile); |
|||
} |
|||
|
|||
@Test |
|||
public void testFindDeviceProfileInfoById() throws Exception { |
|||
DeviceProfile deviceProfile = this.createDeviceProfile("Device Profile"); |
|||
DeviceProfile savedDeviceProfile = doPost("/api/deviceProfile", deviceProfile, DeviceProfile.class); |
|||
EntityInfo foundDeviceProfileInfo = doGet("/api/deviceProfileInfo/"+savedDeviceProfile.getId().getId().toString(), EntityInfo.class); |
|||
Assert.assertNotNull(foundDeviceProfileInfo); |
|||
Assert.assertEquals(savedDeviceProfile.getId(), foundDeviceProfileInfo.getId()); |
|||
Assert.assertEquals(savedDeviceProfile.getName(), foundDeviceProfileInfo.getName()); |
|||
} |
|||
|
|||
@Test |
|||
public void testFindDefaultDeviceProfileInfo() throws Exception { |
|||
EntityInfo foundDefaultDeviceProfileInfo = doGet("/api/deviceProfileInfo/default", EntityInfo.class); |
|||
Assert.assertNotNull(foundDefaultDeviceProfileInfo); |
|||
Assert.assertNotNull(foundDefaultDeviceProfileInfo.getId()); |
|||
Assert.assertNotNull(foundDefaultDeviceProfileInfo.getName()); |
|||
Assert.assertEquals("Default", foundDefaultDeviceProfileInfo.getName()); |
|||
} |
|||
|
|||
@Test |
|||
public void testSetDefaultDeviceProfile() throws Exception { |
|||
DeviceProfile deviceProfile = this.createDeviceProfile("Device Profile 1"); |
|||
DeviceProfile savedDeviceProfile = doPost("/api/deviceProfile", deviceProfile, DeviceProfile.class); |
|||
DeviceProfile defaultDeviceProfile = doPost("/api/deviceProfile/"+savedDeviceProfile.getId().getId().toString()+"/default", null, DeviceProfile.class); |
|||
Assert.assertNotNull(defaultDeviceProfile); |
|||
EntityInfo foundDefaultDeviceProfile = doGet("/api/deviceProfileInfo/default", EntityInfo.class); |
|||
Assert.assertNotNull(foundDefaultDeviceProfile); |
|||
Assert.assertEquals(savedDeviceProfile.getName(), foundDefaultDeviceProfile.getName()); |
|||
Assert.assertEquals(savedDeviceProfile.getId(), foundDefaultDeviceProfile.getId()); |
|||
} |
|||
|
|||
@Test |
|||
public void testSaveDeviceProfileWithEmptyName() throws Exception { |
|||
DeviceProfile deviceProfile = new DeviceProfile(); |
|||
doPost("/api/deviceProfile", deviceProfile).andExpect(status().isBadRequest()) |
|||
.andExpect(statusReason(containsString("Device profile name should be specified"))); |
|||
} |
|||
|
|||
@Test |
|||
public void testSaveDeviceProfileWithSameName() throws Exception { |
|||
DeviceProfile deviceProfile = this.createDeviceProfile("Device Profile"); |
|||
doPost("/api/deviceProfile", deviceProfile).andExpect(status().isOk()); |
|||
DeviceProfile deviceProfile2 = this.createDeviceProfile("Device Profile"); |
|||
doPost("/api/deviceProfile", deviceProfile2).andExpect(status().isBadRequest()) |
|||
.andExpect(statusReason(containsString("Device profile with such name already exists"))); |
|||
} |
|||
|
|||
@Test |
|||
public void testDeleteDeviceProfile() throws Exception { |
|||
DeviceProfile deviceProfile = this.createDeviceProfile("Device Profile"); |
|||
DeviceProfile savedDeviceProfile = doPost("/api/deviceProfile", deviceProfile, DeviceProfile.class); |
|||
|
|||
doDelete("/api/deviceProfile/" + savedDeviceProfile.getId().getId().toString()) |
|||
.andExpect(status().isOk()); |
|||
|
|||
doGet("/api/deviceProfile/" + savedDeviceProfile.getId().getId().toString()) |
|||
.andExpect(status().isNotFound()); |
|||
} |
|||
|
|||
@Test |
|||
public void testFindDeviceProfiles() throws Exception { |
|||
List<DeviceProfile> deviceProfiles = new ArrayList<>(); |
|||
PageLink pageLink = new PageLink(17); |
|||
PageData<DeviceProfile> pageData = doGetTypedWithPageLink("/api/deviceProfiles?", |
|||
new TypeReference<PageData<DeviceProfile>>(){}, pageLink); |
|||
Assert.assertFalse(pageData.hasNext()); |
|||
Assert.assertEquals(1, pageData.getTotalElements()); |
|||
deviceProfiles.addAll(pageData.getData()); |
|||
|
|||
for (int i=0;i<28;i++) { |
|||
DeviceProfile deviceProfile = this.createDeviceProfile("Device Profile"+i); |
|||
deviceProfiles.add(doPost("/api/deviceProfile", deviceProfile, DeviceProfile.class)); |
|||
} |
|||
|
|||
List<DeviceProfile> loadedDeviceProfiles = new ArrayList<>(); |
|||
pageLink = new PageLink(17); |
|||
do { |
|||
pageData = doGetTypedWithPageLink("/api/deviceProfiles?", |
|||
new TypeReference<PageData<DeviceProfile>>(){}, pageLink); |
|||
loadedDeviceProfiles.addAll(pageData.getData()); |
|||
if (pageData.hasNext()) { |
|||
pageLink = pageLink.nextPageLink(); |
|||
} |
|||
} while (pageData.hasNext()); |
|||
|
|||
Collections.sort(deviceProfiles, idComparator); |
|||
Collections.sort(loadedDeviceProfiles, idComparator); |
|||
|
|||
Assert.assertEquals(deviceProfiles, loadedDeviceProfiles); |
|||
|
|||
for (DeviceProfile deviceProfile : loadedDeviceProfiles) { |
|||
if (!deviceProfile.isDefault()) { |
|||
doDelete("/api/deviceProfile/" + deviceProfile.getId().getId().toString()) |
|||
.andExpect(status().isOk()); |
|||
} |
|||
} |
|||
|
|||
pageLink = new PageLink(17); |
|||
pageData = doGetTypedWithPageLink("/api/deviceProfiles?", |
|||
new TypeReference<PageData<DeviceProfile>>(){}, pageLink); |
|||
Assert.assertFalse(pageData.hasNext()); |
|||
Assert.assertEquals(1, pageData.getTotalElements()); |
|||
} |
|||
|
|||
@Test |
|||
public void testFindDeviceProfileInfos() throws Exception { |
|||
List<DeviceProfile> deviceProfiles = new ArrayList<>(); |
|||
PageLink pageLink = new PageLink(17); |
|||
PageData<DeviceProfile> deviceProfilePageData = doGetTypedWithPageLink("/api/deviceProfiles?", |
|||
new TypeReference<PageData<DeviceProfile>>(){}, pageLink); |
|||
Assert.assertFalse(deviceProfilePageData.hasNext()); |
|||
Assert.assertEquals(1, deviceProfilePageData.getTotalElements()); |
|||
deviceProfiles.addAll(deviceProfilePageData.getData()); |
|||
|
|||
for (int i=0;i<28;i++) { |
|||
DeviceProfile deviceProfile = this.createDeviceProfile("Device Profile"+i); |
|||
deviceProfiles.add(doPost("/api/deviceProfile", deviceProfile, DeviceProfile.class)); |
|||
} |
|||
|
|||
List<EntityInfo> loadedDeviceProfileInfos = new ArrayList<>(); |
|||
pageLink = new PageLink(17); |
|||
PageData<EntityInfo> pageData; |
|||
do { |
|||
pageData = doGetTypedWithPageLink("/api/deviceProfileInfos?", |
|||
new TypeReference<PageData<EntityInfo>>(){}, pageLink); |
|||
loadedDeviceProfileInfos.addAll(pageData.getData()); |
|||
if (pageData.hasNext()) { |
|||
pageLink = pageLink.nextPageLink(); |
|||
} |
|||
} while (pageData.hasNext()); |
|||
|
|||
Collections.sort(deviceProfiles, idComparator); |
|||
Collections.sort(loadedDeviceProfileInfos, deviceProfileInfoIdComparator); |
|||
|
|||
List<EntityInfo> deviceProfileInfos = deviceProfiles.stream().map(deviceProfile -> new EntityInfo(deviceProfile.getId(), |
|||
deviceProfile.getName())).collect(Collectors.toList()); |
|||
|
|||
Assert.assertEquals(deviceProfileInfos, loadedDeviceProfileInfos); |
|||
|
|||
for (DeviceProfile deviceProfile : deviceProfiles) { |
|||
if (!deviceProfile.isDefault()) { |
|||
doDelete("/api/deviceProfile/" + deviceProfile.getId().getId().toString()) |
|||
.andExpect(status().isOk()); |
|||
} |
|||
} |
|||
|
|||
pageLink = new PageLink(17); |
|||
pageData = doGetTypedWithPageLink("/api/deviceProfileInfos?", |
|||
new TypeReference<PageData<EntityInfo>>(){}, pageLink); |
|||
Assert.assertFalse(pageData.hasNext()); |
|||
Assert.assertEquals(1, pageData.getTotalElements()); |
|||
} |
|||
|
|||
private DeviceProfile createDeviceProfile(String name) { |
|||
DeviceProfile deviceProfile = new DeviceProfile(); |
|||
deviceProfile.setName(name); |
|||
deviceProfile.setDescription(name + " Test"); |
|||
deviceProfile.setProfileData(JacksonUtil.OBJECT_MAPPER.createObjectNode()); |
|||
deviceProfile.setDefault(false); |
|||
deviceProfile.setDefaultRuleChainId(new RuleChainId(Uuids.timeBased())); |
|||
return deviceProfile; |
|||
} |
|||
} |
|||
@ -0,0 +1,255 @@ |
|||
/** |
|||
* Copyright © 2016-2020 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.controller; |
|||
|
|||
import com.fasterxml.jackson.core.type.TypeReference; |
|||
import org.junit.After; |
|||
import org.junit.Assert; |
|||
import org.junit.Test; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.thingsboard.server.common.data.Device; |
|||
import org.thingsboard.server.common.data.EntityInfo; |
|||
import org.thingsboard.server.common.data.Tenant; |
|||
import org.thingsboard.server.common.data.TenantProfile; |
|||
import org.thingsboard.server.common.data.id.TenantId; |
|||
import org.thingsboard.server.common.data.page.PageData; |
|||
import org.thingsboard.server.common.data.page.PageLink; |
|||
import org.thingsboard.server.dao.exception.DataValidationException; |
|||
import org.thingsboard.server.dao.tenant.TenantProfileService; |
|||
import org.thingsboard.server.dao.util.mapping.JacksonUtil; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.Collections; |
|||
import java.util.List; |
|||
import java.util.stream.Collectors; |
|||
|
|||
import static org.hamcrest.Matchers.containsString; |
|||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; |
|||
|
|||
public abstract class BaseTenantProfileControllerTest extends AbstractControllerTest { |
|||
|
|||
private IdComparator<TenantProfile> idComparator = new IdComparator<>(); |
|||
private IdComparator<EntityInfo> tenantProfileInfoIdComparator = new IdComparator<>(); |
|||
|
|||
@Autowired |
|||
private TenantProfileService tenantProfileService; |
|||
|
|||
@After |
|||
public void after() { |
|||
tenantProfileService.deleteTenantProfiles(TenantId.SYS_TENANT_ID); |
|||
} |
|||
|
|||
@Test |
|||
public void testSaveTenantProfile() throws Exception { |
|||
loginSysAdmin(); |
|||
TenantProfile tenantProfile = this.createTenantProfile("Tenant Profile"); |
|||
TenantProfile savedTenantProfile = doPost("/api/tenantProfile", tenantProfile, TenantProfile.class); |
|||
Assert.assertNotNull(savedTenantProfile); |
|||
Assert.assertNotNull(savedTenantProfile.getId()); |
|||
Assert.assertTrue(savedTenantProfile.getCreatedTime() > 0); |
|||
Assert.assertEquals(tenantProfile.getName(), savedTenantProfile.getName()); |
|||
Assert.assertEquals(tenantProfile.getDescription(), savedTenantProfile.getDescription()); |
|||
Assert.assertEquals(tenantProfile.getProfileData(), savedTenantProfile.getProfileData()); |
|||
Assert.assertEquals(tenantProfile.isDefault(), savedTenantProfile.isDefault()); |
|||
Assert.assertEquals(tenantProfile.isIsolatedTbCore(), savedTenantProfile.isIsolatedTbCore()); |
|||
Assert.assertEquals(tenantProfile.isIsolatedTbRuleEngine(), savedTenantProfile.isIsolatedTbRuleEngine()); |
|||
|
|||
savedTenantProfile.setName("New tenant profile"); |
|||
doPost("/api/tenantProfile", savedTenantProfile, TenantProfile.class); |
|||
TenantProfile foundTenantProfile = doGet("/api/tenantProfile/"+savedTenantProfile.getId().getId().toString(), TenantProfile.class); |
|||
Assert.assertEquals(foundTenantProfile.getName(), savedTenantProfile.getName()); |
|||
} |
|||
|
|||
@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); |
|||
} |
|||
|
|||
@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()); |
|||
} |
|||
|
|||
@Test |
|||
public void testFindDefaultTenantProfileInfo() throws Exception { |
|||
loginSysAdmin(); |
|||
EntityInfo foundDefaultTenantProfile = doGet("/api/tenantProfileInfo/default", EntityInfo.class); |
|||
Assert.assertNotNull(foundDefaultTenantProfile); |
|||
Assert.assertEquals("Default", foundDefaultTenantProfile.getName()); |
|||
} |
|||
|
|||
@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()); |
|||
} |
|||
|
|||
@Test |
|||
public void testSaveTenantProfileWithEmptyName() throws Exception { |
|||
loginSysAdmin(); |
|||
TenantProfile tenantProfile = new TenantProfile(); |
|||
doPost("/api/tenantProfile", tenantProfile).andExpect(status().isBadRequest()) |
|||
.andExpect(statusReason(containsString("Tenant profile name should be specified"))); |
|||
} |
|||
|
|||
@Test |
|||
public void testSaveTenantProfileWithSameName() throws Exception { |
|||
loginSysAdmin(); |
|||
TenantProfile tenantProfile = this.createTenantProfile("Tenant Profile"); |
|||
doPost("/api/tenantProfile", tenantProfile).andExpect(status().isOk()); |
|||
TenantProfile tenantProfile2 = this.createTenantProfile("Tenant Profile"); |
|||
doPost("/api/tenantProfile", tenantProfile2).andExpect(status().isBadRequest()) |
|||
.andExpect(statusReason(containsString("Tenant profile with such name already exists"))); |
|||
} |
|||
|
|||
@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()); |
|||
} |
|||
|
|||
@Test |
|||
public void testFindTenantProfiles() throws Exception { |
|||
loginSysAdmin(); |
|||
List<TenantProfile> tenantProfiles = new ArrayList<>(); |
|||
PageLink pageLink = new PageLink(17); |
|||
PageData<TenantProfile> pageData = doGetTypedWithPageLink("/api/tenantProfiles?", |
|||
new TypeReference<PageData<TenantProfile>>(){}, pageLink); |
|||
Assert.assertFalse(pageData.hasNext()); |
|||
Assert.assertEquals(1, pageData.getTotalElements()); |
|||
tenantProfiles.addAll(pageData.getData()); |
|||
|
|||
for (int i=0;i<28;i++) { |
|||
TenantProfile tenantProfile = this.createTenantProfile("Tenant Profile"+i); |
|||
tenantProfiles.add(doPost("/api/tenantProfile", tenantProfile, TenantProfile.class)); |
|||
} |
|||
|
|||
List<TenantProfile> loadedTenantProfiles = new ArrayList<>(); |
|||
pageLink = new PageLink(17); |
|||
do { |
|||
pageData = doGetTypedWithPageLink("/api/tenantProfiles?", |
|||
new TypeReference<PageData<TenantProfile>>(){}, pageLink); |
|||
loadedTenantProfiles.addAll(pageData.getData()); |
|||
if (pageData.hasNext()) { |
|||
pageLink = pageLink.nextPageLink(); |
|||
} |
|||
} while (pageData.hasNext()); |
|||
|
|||
Collections.sort(tenantProfiles, idComparator); |
|||
Collections.sort(loadedTenantProfiles, idComparator); |
|||
|
|||
Assert.assertEquals(tenantProfiles, loadedTenantProfiles); |
|||
|
|||
for (TenantProfile tenantProfile : loadedTenantProfiles) { |
|||
if (!tenantProfile.isDefault()) { |
|||
doDelete("/api/tenantProfile/" + tenantProfile.getId().getId().toString()) |
|||
.andExpect(status().isOk()); |
|||
} |
|||
} |
|||
|
|||
pageLink = new PageLink(17); |
|||
pageData = doGetTypedWithPageLink("/api/tenantProfiles?", |
|||
new TypeReference<PageData<TenantProfile>>(){}, pageLink); |
|||
Assert.assertFalse(pageData.hasNext()); |
|||
Assert.assertEquals(1, pageData.getTotalElements()); |
|||
} |
|||
|
|||
@Test |
|||
public void testFindTenantProfileInfos() throws Exception { |
|||
loginSysAdmin(); |
|||
List<TenantProfile> tenantProfiles = new ArrayList<>(); |
|||
PageLink pageLink = new PageLink(17); |
|||
PageData<TenantProfile> tenantProfilePageData = doGetTypedWithPageLink("/api/tenantProfiles?", |
|||
new TypeReference<PageData<TenantProfile>>(){}, pageLink); |
|||
Assert.assertFalse(tenantProfilePageData.hasNext()); |
|||
Assert.assertEquals(1, tenantProfilePageData.getTotalElements()); |
|||
tenantProfiles.addAll(tenantProfilePageData.getData()); |
|||
|
|||
for (int i=0;i<28;i++) { |
|||
TenantProfile tenantProfile = this.createTenantProfile("Tenant Profile"+i); |
|||
tenantProfiles.add(doPost("/api/tenantProfile", tenantProfile, TenantProfile.class)); |
|||
} |
|||
|
|||
List<EntityInfo> loadedTenantProfileInfos = new ArrayList<>(); |
|||
pageLink = new PageLink(17); |
|||
PageData<EntityInfo> pageData; |
|||
do { |
|||
pageData = doGetTypedWithPageLink("/api/tenantProfileInfos?", |
|||
new TypeReference<PageData<EntityInfo>>(){}, pageLink); |
|||
loadedTenantProfileInfos.addAll(pageData.getData()); |
|||
if (pageData.hasNext()) { |
|||
pageLink = pageLink.nextPageLink(); |
|||
} |
|||
} while (pageData.hasNext()); |
|||
|
|||
Collections.sort(tenantProfiles, idComparator); |
|||
Collections.sort(loadedTenantProfileInfos, tenantProfileInfoIdComparator); |
|||
|
|||
List<EntityInfo> tenantProfileInfos = tenantProfiles.stream().map(tenantProfile -> new EntityInfo(tenantProfile.getId(), |
|||
tenantProfile.getName())).collect(Collectors.toList()); |
|||
|
|||
Assert.assertEquals(tenantProfileInfos, loadedTenantProfileInfos); |
|||
|
|||
for (TenantProfile tenantProfile : tenantProfiles) { |
|||
if (!tenantProfile.isDefault()) { |
|||
doDelete("/api/tenantProfile/" + tenantProfile.getId().getId().toString()) |
|||
.andExpect(status().isOk()); |
|||
} |
|||
} |
|||
|
|||
pageLink = new PageLink(17); |
|||
pageData = doGetTypedWithPageLink("/api/tenantProfileInfos?", |
|||
new TypeReference<PageData<EntityInfo>>(){}, pageLink); |
|||
Assert.assertFalse(pageData.hasNext()); |
|||
Assert.assertEquals(1, pageData.getTotalElements()); |
|||
} |
|||
|
|||
private TenantProfile createTenantProfile(String name) { |
|||
TenantProfile tenantProfile = new TenantProfile(); |
|||
tenantProfile.setName(name); |
|||
tenantProfile.setDescription(name + " Test"); |
|||
tenantProfile.setProfileData(JacksonUtil.OBJECT_MAPPER.createObjectNode()); |
|||
tenantProfile.setDefault(false); |
|||
tenantProfile.setIsolatedTbCore(false); |
|||
tenantProfile.setIsolatedTbRuleEngine(false); |
|||
return tenantProfile; |
|||
} |
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
/** |
|||
* Copyright © 2016-2020 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.controller.sql; |
|||
|
|||
import org.thingsboard.server.controller.BaseDeviceProfileControllerTest; |
|||
import org.thingsboard.server.dao.service.DaoSqlTest; |
|||
|
|||
@DaoSqlTest |
|||
public class DeviceProfileControllerSqlTest extends BaseDeviceProfileControllerTest { |
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
/** |
|||
* Copyright © 2016-2020 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.controller.sql; |
|||
|
|||
import org.thingsboard.server.controller.BaseTenantProfileControllerTest; |
|||
import org.thingsboard.server.dao.service.DaoSqlTest; |
|||
|
|||
@DaoSqlTest |
|||
public class TenantProfileControllerSqlTest extends BaseTenantProfileControllerTest { |
|||
} |
|||
Loading…
Reference in new issue