private DiskImage mockDiskImage(DiskInterface iface) { disk.setImageId(diskImageGuid); ArrayList<Guid> storageIdList = new ArrayList<>(); storageIdList.add(storageDomainId); disk.setStorageIds(storageIdList); disk.setStoragePoolId(storagePoolId); disk.setActive(true); disk.setId(Guid.newGuid()); when(diskDao.get(diskImageGuid)).thenReturn(disk); DiskVmElement dve = new DiskVmElement(disk.getId(), vmId); dve.setDiskInterface(iface); when(diskVmElementDao.get(new VmDeviceId(disk.getId(), vmId))).thenReturn(dve); return disk; }
private void setUpDaoMocks() { // Disk Image Dao List<Disk> returnArray = new ArrayList<>(); returnArray.add(pluggedDisk); returnArray.add(unpluggedDisk); returnArray.add(pluggedDiskSnapshot); returnArray.add(unpluggedDiskSnapshot); when(diskDaoMock.getAllForVm(vmID, getUser().getId(), getQueryParameters().isFiltered())) .thenReturn(returnArray); when(diskVmElementDao.get(any(VmDeviceId.class))) .thenReturn(new DiskVmElement(new VmDeviceId())); // Snapshots doReturn( new ArrayList<>( Collections.nCopies( NUM_DISKS_OF_EACH_KIND, createDiskSnapshot(pluggedDisk.getId())))) .when(diskImageDao) .getAllSnapshotsForLeaf(pluggedDisk.getImageId()); doReturn(Collections.nCopies(NUM_DISKS_OF_EACH_KIND, createDiskSnapshot(unpluggedDisk.getId()))) .when(diskImageDao) .getAllSnapshotsForLeaf(unpluggedDisk.getImageId()); doReturn( new ArrayList<>( Collections.nCopies( NUM_DISKS_OF_EACH_KIND, createDiskSnapshot(pluggedDiskSnapshot.getId())))) .when(diskImageDao) .getAllSnapshotsForLeaf(pluggedDiskSnapshot.getImageId()); doReturn( Collections.nCopies( NUM_DISKS_OF_EACH_KIND, createDiskSnapshot(unpluggedDiskSnapshot.getId()))) .when(diskImageDao) .getAllSnapshotsForLeaf(unpluggedDiskSnapshot.getImageId()); }