use of org.thingsboard.server.common.data.DeviceProfileInfo in project thingsboard by thingsboard.
the class BaseDeviceProfileServiceTest method testFindDeviceProfileInfos.
@Test
public void testFindDeviceProfileInfos() {
List<DeviceProfile> deviceProfiles = new ArrayList<>();
PageLink pageLink = new PageLink(17);
PageData<DeviceProfile> deviceProfilePageData = deviceProfileService.findDeviceProfiles(tenantId, 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(tenantId, "Device Profile" + i);
deviceProfiles.add(deviceProfileService.saveDeviceProfile(deviceProfile));
}
List<DeviceProfileInfo> loadedDeviceProfileInfos = new ArrayList<>();
pageLink = new PageLink(17);
PageData<DeviceProfileInfo> pageData;
do {
pageData = deviceProfileService.findDeviceProfileInfos(tenantId, pageLink, null);
loadedDeviceProfileInfos.addAll(pageData.getData());
if (pageData.hasNext()) {
pageLink = pageLink.nextPageLink();
}
} while (pageData.hasNext());
Collections.sort(deviceProfiles, idComparator);
Collections.sort(loadedDeviceProfileInfos, deviceProfileInfoIdComparator);
List<DeviceProfileInfo> deviceProfileInfos = deviceProfiles.stream().map(deviceProfile -> new DeviceProfileInfo(deviceProfile.getId(), deviceProfile.getName(), deviceProfile.getImage(), deviceProfile.getDefaultDashboardId(), deviceProfile.getType(), deviceProfile.getTransportType())).collect(Collectors.toList());
Assert.assertEquals(deviceProfileInfos, loadedDeviceProfileInfos);
for (DeviceProfile deviceProfile : deviceProfiles) {
if (!deviceProfile.isDefault()) {
deviceProfileService.deleteDeviceProfile(tenantId, deviceProfile.getId());
}
}
pageLink = new PageLink(17);
pageData = deviceProfileService.findDeviceProfileInfos(tenantId, pageLink, null);
Assert.assertFalse(pageData.hasNext());
Assert.assertEquals(1, pageData.getTotalElements());
}
use of org.thingsboard.server.common.data.DeviceProfileInfo in project thingsboard by thingsboard.
the class BaseDeviceProfileServiceTest method testFindDefaultDeviceProfileInfo.
@Test
public void testFindDefaultDeviceProfileInfo() {
DeviceProfileInfo foundDefaultDeviceProfileInfo = deviceProfileService.findDefaultDeviceProfileInfo(tenantId);
Assert.assertNotNull(foundDefaultDeviceProfileInfo);
Assert.assertNotNull(foundDefaultDeviceProfileInfo.getId());
Assert.assertNotNull(foundDefaultDeviceProfileInfo.getName());
Assert.assertNotNull(foundDefaultDeviceProfileInfo.getType());
}
Aggregations