@Test public void testFindDevicesByTenantIdAndIdsAsync() throws ExecutionException, InterruptedException { UUID tenantId1 = Uuids.timeBased(); UUID customerId1 = Uuids.timeBased(); UUID tenantId2 = Uuids.timeBased(); UUID customerId2 = Uuids.timeBased(); List<UUID> deviceIds = new ArrayList<>(); for(int i = 0; i < 5; i++) { UUID deviceId1 = Uuids.timeBased(); UUID deviceId2 = Uuids.timeBased(); deviceDao.save(new TenantId(tenantId1), getDevice(tenantId1, customerId1, deviceId1)); deviceDao.save(new TenantId(tenantId2), getDevice(tenantId2, customerId2, deviceId2)); deviceIds.add(deviceId1); deviceIds.add(deviceId2); } ListenableFuture<List<Device>> devicesFuture = deviceDao.findDevicesByTenantIdAndIdsAsync(tenantId1, deviceIds); List<Device> devices = devicesFuture.get(); assertEquals(5, devices.size()); }
@Override public ListenableFuture<List<Device>> findDevicesByTenantIdAndIdsAsync(UUID tenantId, List<UUID> deviceIds) { return service.submit(() -> DaoUtil.convertDataList(deviceRepository.findDevicesByTenantIdAndIdIn(tenantId, deviceIds))); }
JpaDeviceDao extends JpaAbstractSearchTextDao<DeviceEntity, Device> implements DeviceDao { @Override public ListenableFuture<List<Device>> findDevicesByTenantIdAndIdsAsync(UUID tenantId, List<UUID> deviceIds) { return service.submit(() -> DaoUtil.convertDataList(deviceRepository.findDevicesByTenantIdAndIdIn(tenantId, deviceIds))); } }
JpaDeviceDao extends JpaAbstractSearchTextDao<DeviceEntity, Device> implements DeviceDao { @Override public ListenableFuture<List<Device>> findDevicesByTenantIdAndIdsAsync(UUID tenantId, List<UUID> deviceIds) { return service.submit(() -> DaoUtil.convertDataList(deviceRepository.findDevicesByTenantIdAndIdIn(tenantId, deviceIds))); }  }
JpaDeviceDao extends JpaAbstractSearchTextDao<DeviceEntity, Device> implements DeviceDao { @Override public ListenableFuture<List<Device>> findDevicesByTenantIdAndIdsAsync(UUID tenantId, List<UUID> deviceIds) { return service.submit(() -> DaoUtil.convertDataList(deviceRepository.findDevicesByTenantIdAndIdIn(tenantId, deviceIds))); }  @Override DeviceInfo findDeviceInfoById(TenantId tenantId, UUID deviceId); @Override PageData<Device> findDevicesByTenantId(UUID tenantId, PageLink pageLink); @Override PageData<DeviceInfo> findDeviceInfosByTenantId(UUID tenantId, PageLink pageLink); @Override ListenableFuture<List<Device>> findDevicesByTenantIdAndIdsAsync(UUID tenantId, List<UUID> deviceIds); @Override PageData<Device> findDevicesByTenantIdAndCustomerId(UUID tenantId, UUID customerId, PageLink pageLink); @Override PageData<Device> findDevicesByTenantIdAndProfileId(UUID tenantId, UUID profileId, PageLink pageLink); @Override PageData<DeviceInfo> findDeviceInfosByTenantIdAndCustomerId(UUID tenantId, UUID customerId, PageLink pageLink); @Override ListenableFuture<List<Device>> findDevicesByTenantIdCustomerIdAndIdsAsync(UUID tenantId, UUID customerId, List<UUID> deviceIds); @Override Optional<Device> findDeviceByTenantIdAndName(UUID tenantId, String name); @Override PageData<Device> findDevicesByTenantIdAndType(UUID tenantId, String type, PageLink pageLink); @Override PageData<DeviceInfo> findDeviceInfosByTenantIdAndType(UUID tenantId, String type, PageLink pageLink); @Override PageData<DeviceInfo> findDeviceInfosByTenantIdAndDeviceProfileId(UUID tenantId, UUID deviceProfileId, PageLink pageLink); @Override PageData<Device> findDevicesByTenantIdAndCustomerIdAndType(UUID tenantId, UUID customerId, String type, PageLink pageLink); @Override PageData<DeviceInfo> findDeviceInfosByTenantIdAndCustomerIdAndType(UUID tenantId, UUID customerId, String type, PageLink pageLink); @Override PageData<DeviceInfo> findDeviceInfosByTenantIdAndCustomerIdAndDeviceProfileId(UUID tenantId, UUID customerId, UUID deviceProfileId, PageLink pageLink); @Override ListenableFuture<List<EntitySubtype>> findTenantDeviceTypesAsync(UUID tenantId); @Override Device findDeviceByTenantIdAndId(TenantId tenantId, UUID id); @Override ListenableFuture<Device> findDeviceByTenantIdAndIdAsync(TenantId tenantId, UUID id); @Override Long countDevicesByDeviceProfileId(TenantId tenantId, UUID deviceProfileId); }
JpaDeviceDao extends JpaAbstractSearchTextDao<DeviceEntity, Device> implements DeviceDao { @Override public ListenableFuture<List<Device>> findDevicesByTenantIdAndIdsAsync(UUID tenantId, List<UUID> deviceIds) { return service.submit(() -> DaoUtil.convertDataList(deviceRepository.findDevicesByTenantIdAndIdIn(tenantId, deviceIds))); }  @Override DeviceInfo findDeviceInfoById(TenantId tenantId, UUID deviceId); @Override PageData<Device> findDevicesByTenantId(UUID tenantId, PageLink pageLink); @Override PageData<DeviceInfo> findDeviceInfosByTenantId(UUID tenantId, PageLink pageLink); @Override ListenableFuture<List<Device>> findDevicesByTenantIdAndIdsAsync(UUID tenantId, List<UUID> deviceIds); @Override PageData<Device> findDevicesByTenantIdAndCustomerId(UUID tenantId, UUID customerId, PageLink pageLink); @Override PageData<Device> findDevicesByTenantIdAndProfileId(UUID tenantId, UUID profileId, PageLink pageLink); @Override PageData<DeviceInfo> findDeviceInfosByTenantIdAndCustomerId(UUID tenantId, UUID customerId, PageLink pageLink); @Override ListenableFuture<List<Device>> findDevicesByTenantIdCustomerIdAndIdsAsync(UUID tenantId, UUID customerId, List<UUID> deviceIds); @Override Optional<Device> findDeviceByTenantIdAndName(UUID tenantId, String name); @Override PageData<Device> findDevicesByTenantIdAndType(UUID tenantId, String type, PageLink pageLink); @Override PageData<DeviceInfo> findDeviceInfosByTenantIdAndType(UUID tenantId, String type, PageLink pageLink); @Override PageData<DeviceInfo> findDeviceInfosByTenantIdAndDeviceProfileId(UUID tenantId, UUID deviceProfileId, PageLink pageLink); @Override PageData<Device> findDevicesByTenantIdAndCustomerIdAndType(UUID tenantId, UUID customerId, String type, PageLink pageLink); @Override PageData<DeviceInfo> findDeviceInfosByTenantIdAndCustomerIdAndType(UUID tenantId, UUID customerId, String type, PageLink pageLink); @Override PageData<DeviceInfo> findDeviceInfosByTenantIdAndCustomerIdAndDeviceProfileId(UUID tenantId, UUID customerId, UUID deviceProfileId, PageLink pageLink); @Override ListenableFuture<List<EntitySubtype>> findTenantDeviceTypesAsync(UUID tenantId); @Override Device findDeviceByTenantIdAndId(TenantId tenantId, UUID id); @Override ListenableFuture<Device> findDeviceByTenantIdAndIdAsync(TenantId tenantId, UUID id); @Override Long countDevicesByDeviceProfileId(TenantId tenantId, UUID deviceProfileId);  }