Search in sources :

Example 86 with DeviceProfile

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

the class BaseDeviceProfileServiceTest method testFindDeviceProfileById.

@Test
public void testFindDeviceProfileById() {
    DeviceProfile deviceProfile = this.createDeviceProfile(tenantId, "Device Profile");
    DeviceProfile savedDeviceProfile = deviceProfileService.saveDeviceProfile(deviceProfile);
    DeviceProfile foundDeviceProfile = deviceProfileService.findDeviceProfileById(tenantId, savedDeviceProfile.getId());
    Assert.assertNotNull(foundDeviceProfile);
    Assert.assertEquals(savedDeviceProfile, foundDeviceProfile);
}
Also used : DeviceProfile(org.thingsboard.server.common.data.DeviceProfile) Test(org.junit.Test)

Example 87 with DeviceProfile

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

the class BaseDeviceProfileServiceTest method testSaveDeviceProfile.

@Test
public void testSaveDeviceProfile() {
    DeviceProfile deviceProfile = this.createDeviceProfile(tenantId, "Device Profile");
    DeviceProfile savedDeviceProfile = deviceProfileService.saveDeviceProfile(deviceProfile);
    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");
    deviceProfileService.saveDeviceProfile(savedDeviceProfile);
    DeviceProfile foundDeviceProfile = deviceProfileService.findDeviceProfileById(tenantId, savedDeviceProfile.getId());
    Assert.assertEquals(savedDeviceProfile.getName(), foundDeviceProfile.getName());
}
Also used : DeviceProfile(org.thingsboard.server.common.data.DeviceProfile) Test(org.junit.Test)

Example 88 with DeviceProfile

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

the class BaseDeviceProfileServiceTest method testSaveDeviceProfileWithEmptyName.

@Test(expected = DataValidationException.class)
public void testSaveDeviceProfileWithEmptyName() {
    DeviceProfile deviceProfile = new DeviceProfile();
    deviceProfile.setTenantId(tenantId);
    deviceProfileService.saveDeviceProfile(deviceProfile);
}
Also used : DeviceProfile(org.thingsboard.server.common.data.DeviceProfile) Test(org.junit.Test)

Example 89 with DeviceProfile

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

the class BaseDeviceProfileServiceTest method testSaveDeviceProfileWithFirmware.

@Test
public void testSaveDeviceProfileWithFirmware() {
    DeviceProfile deviceProfile = this.createDeviceProfile(tenantId, "Device Profile");
    DeviceProfile savedDeviceProfile = deviceProfileService.saveDeviceProfile(deviceProfile);
    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());
    OtaPackage firmware = new OtaPackage();
    firmware.setTenantId(tenantId);
    firmware.setDeviceProfileId(savedDeviceProfile.getId());
    firmware.setType(FIRMWARE);
    firmware.setTitle("my firmware");
    firmware.setVersion("v1.0");
    firmware.setFileName("test.txt");
    firmware.setContentType("text/plain");
    firmware.setChecksumAlgorithm(ChecksumAlgorithm.SHA256);
    firmware.setChecksum("4bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459a");
    firmware.setData(ByteBuffer.wrap(new byte[] { 1 }));
    firmware.setDataSize(1L);
    OtaPackage savedFirmware = otaPackageService.saveOtaPackage(firmware);
    deviceProfile.setFirmwareId(savedFirmware.getId());
    deviceProfileService.saveDeviceProfile(savedDeviceProfile);
    DeviceProfile foundDeviceProfile = deviceProfileService.findDeviceProfileById(tenantId, savedDeviceProfile.getId());
    Assert.assertEquals(savedDeviceProfile.getName(), foundDeviceProfile.getName());
}
Also used : DeviceProfile(org.thingsboard.server.common.data.DeviceProfile) OtaPackage(org.thingsboard.server.common.data.OtaPackage) Test(org.junit.Test)

Example 90 with DeviceProfile

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

the class BaseDeviceProfileServiceTest method testChangeDeviceProfileTransportTypeWithExistingDevices.

@Test(expected = DataValidationException.class)
public void testChangeDeviceProfileTransportTypeWithExistingDevices() {
    DeviceProfile deviceProfile = this.createDeviceProfile(tenantId, "Device Profile");
    DeviceProfile savedDeviceProfile = deviceProfileService.saveDeviceProfile(deviceProfile);
    Device device = new Device();
    device.setTenantId(tenantId);
    device.setName("Test device");
    device.setType("default");
    device.setDeviceProfileId(savedDeviceProfile.getId());
    deviceService.saveDevice(device);
    savedDeviceProfile.setTransportType(DeviceTransportType.MQTT);
    deviceProfileService.saveDeviceProfile(savedDeviceProfile);
}
Also used : DeviceProfile(org.thingsboard.server.common.data.DeviceProfile) Device(org.thingsboard.server.common.data.Device) Test(org.junit.Test)

Aggregations

DeviceProfile (org.thingsboard.server.common.data.DeviceProfile)110 Test (org.junit.Test)48 Device (org.thingsboard.server.common.data.Device)30 DeviceProfileData (org.thingsboard.server.common.data.device.profile.DeviceProfileData)26 List (java.util.List)20 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)19 TbMsg (org.thingsboard.server.common.msg.TbMsg)19 DeviceProfileAlarm (org.thingsboard.server.common.data.device.profile.DeviceProfileAlarm)18 TbMsgMetaData (org.thingsboard.server.common.msg.TbMsgMetaData)18 AlarmConditionFilterKey (org.thingsboard.server.common.data.device.profile.AlarmConditionFilterKey)17 AlarmRule (org.thingsboard.server.common.data.device.profile.AlarmRule)17 AlarmCondition (org.thingsboard.server.common.data.device.profile.AlarmCondition)16 AlarmConditionFilter (org.thingsboard.server.common.data.device.profile.AlarmConditionFilter)16 NumericFilterPredicate (org.thingsboard.server.common.data.query.NumericFilterPredicate)16 DynamicValue (org.thingsboard.server.common.data.query.DynamicValue)14 DeviceProfileId (org.thingsboard.server.common.data.id.DeviceProfileId)13 AttributeKvEntry (org.thingsboard.server.common.data.kv.AttributeKvEntry)13 AttributeKvCompositeKey (org.thingsboard.server.dao.model.sql.AttributeKvCompositeKey)13 AttributeKvEntity (org.thingsboard.server.dao.model.sql.AttributeKvEntity)13 UUID (java.util.UUID)12