use of org.thingsboard.server.common.data.DeviceInfo in project thingsboard by thingsboard.
the class BaseDeviceServiceTest method testFindDeviceInfoByTenantIdAndDeviceProfileId.
@Test
public void testFindDeviceInfoByTenantIdAndDeviceProfileId() {
Customer customer = new Customer();
customer.setTitle("Customer X");
customer.setTenantId(tenantId);
Customer savedCustomer = customerService.saveCustomer(customer);
Device device = new Device();
device.setTenantId(tenantId);
device.setName("default");
device.setLabel("label");
device.setCustomerId(savedCustomer.getId());
Device savedDevice = deviceService.saveDevice(device);
PageLink pageLinkWithLabel = new PageLink(100, 0, "label");
List<DeviceInfo> deviceInfosWithLabel = deviceService.findDeviceInfosByTenantIdAndDeviceProfileId(tenantId, savedDevice.getDeviceProfileId(), pageLinkWithLabel).getData();
Assert.assertFalse(deviceInfosWithLabel.isEmpty());
Assert.assertTrue(deviceInfosWithLabel.stream().anyMatch(d -> d.getId().equals(savedDevice.getId()) && d.getTenantId().equals(tenantId) && d.getDeviceProfileId().equals(savedDevice.getDeviceProfileId()) && d.getLabel().equals(savedDevice.getLabel())));
PageLink pageLinkWithCustomer = new PageLink(100, 0, savedCustomer.getSearchText());
List<DeviceInfo> deviceInfosWithCustomer = deviceService.findDeviceInfosByTenantIdAndDeviceProfileId(tenantId, savedDevice.getDeviceProfileId(), pageLinkWithCustomer).getData();
Assert.assertFalse(deviceInfosWithCustomer.isEmpty());
Assert.assertTrue(deviceInfosWithCustomer.stream().anyMatch(d -> d.getId().equals(savedDevice.getId()) && d.getTenantId().equals(tenantId) && d.getDeviceProfileId().equals(savedDevice.getDeviceProfileId()) && d.getCustomerId().equals(savedCustomer.getId()) && d.getCustomerTitle().equals(savedCustomer.getTitle())));
}
Aggregations