use of org.ovirt.engine.core.common.businessentities.VM in project ovirt-engine by oVirt.
the class GetVmsByDiskGuidQueryTest method testExecuteQueryCommand.
@Test
public void testExecuteQueryCommand() {
// Set up the query parameters
Guid imageGuid = Guid.newGuid();
when(params.getId()).thenReturn(imageGuid);
// Set up the Daos
Map<Boolean, List<VM>> expected = Collections.singletonMap(true, Collections.singletonList(new VM()));
when(vmDaoMock.getForDisk(imageGuid, true)).thenReturn(expected);
// Run the query
GetVmsByDiskGuidQuery<IdQueryParameters> query = getQuery();
query.executeQueryCommand();
// Assert the result
assertEquals("Wrong result returned", expected, getQuery().getQueryReturnValue().getReturnValue());
}
use of org.ovirt.engine.core.common.businessentities.VM in project ovirt-engine by oVirt.
the class GetVmsByStorageDomainQueryTest method testExecuteQueryCommandNoDisks.
@Test
public void testExecuteQueryCommandNoDisks() {
List<VM> vmsOfDomain = new ArrayList<>();
VM vm1 = mock(VM.class);
VM vm2 = mock(VM.class);
vmsOfDomain.add(vm1);
vmsOfDomain.add(vm2);
when(vmDao.getAllForStorageDomain(domainId)).thenReturn(vmsOfDomain);
QueryReturnValue returnValue = new QueryReturnValue();
returnValue.setSucceeded(true);
List<DiskImage> diskImages = new ArrayList<>();
returnValue.setReturnValue(diskImages);
doReturn(returnValue).when(query).getAllDisksByStorageDomain(domainId);
query.executeQueryCommand();
List<VM> vms = query.getQueryReturnValue().getReturnValue();
assertEquals(2, vms.size());
}
use of org.ovirt.engine.core.common.businessentities.VM in project ovirt-engine by oVirt.
the class GetUnregisteredVmsQueryTest method setUpQueryEntities.
private void setUpQueryEntities() throws OvfReaderException {
// Set up the expected result
VM vmReturnForOvf = new VM();
vmReturnForOvf.setId(newVmGuid);
vmReturnForOvf.setName("Name");
String ovfData = new String("OVF data for the first VM");
OvfEntityData ovfEntityData = new OvfEntityData(vmReturnForOvf.getId(), vmReturnForOvf.getName(), VmEntityType.VM, null, null, storageDomainId, ovfData, null);
ovfEntityData.setStatus(vmStatus);
List<OvfEntityData> expectedResultQuery1 = new ArrayList<>();
expectedResultQuery1.add(ovfEntityData);
List<OvfEntityData> expectedResult = new ArrayList<>();
expectedResult.add(ovfEntityData);
VM vmReturnForOvf2 = new VM();
vmReturnForOvf2.setId(newVmGuid2);
vmReturnForOvf2.setName("Name2");
String ovfData2 = new String("OVF data for the second VM");
OvfEntityData ovfEntityData2 = new OvfEntityData(vmReturnForOvf2.getId(), vmReturnForOvf2.getName(), VmEntityType.VM, null, null, storageDomainId, ovfData2, null);
ovfEntityData2.setStatus(vmStatus2);
expectedResult.add(ovfEntityData2);
List<OvfEntityData> expectedResultQuery2 = new ArrayList<>();
expectedResultQuery2.add(ovfEntityData);
// Mock the Daos
when(unregisteredOVFDataDaoMock.getAllForStorageDomainByEntityType(storageDomainId, entityType)).thenReturn(expectedResult);
when(unregisteredOVFDataDaoMock.getByEntityIdAndStorageDomain(newVmGuid2, storageDomainId)).thenReturn(expectedResultQuery2);
when(unregisteredOVFDataDaoMock.getByEntityIdAndStorageDomain(newVmGuid, storageDomainId)).thenReturn(expectedResultQuery1);
// Mock OVF
when(ovfHelperMock.readVmFromOvf(ovfData)).thenReturn(new FullEntityOvfData(vmReturnForOvf));
when(ovfHelperMock.readVmFromOvf(ovfData2)).thenReturn(new FullEntityOvfData(vmReturnForOvf2));
}
use of org.ovirt.engine.core.common.businessentities.VM in project ovirt-engine by oVirt.
the class GetUserVmsByUserIdAndGroupsQueryTest method mockVMFromDao.
/**
* Mocks the Daos to return a VM
* @param requestedUser The user on the parameter object to return the VM for
* @return The VM the mocked Dao will return
*/
private VM mockVMFromDao(Guid requestedUser) {
VM expectedVM = new VM();
when(vmDaoMock.getAllForUserWithGroupsAndUserRoles(requestedUser)).thenReturn(Collections.singletonList(expectedVM));
return expectedVM;
}
use of org.ovirt.engine.core.common.businessentities.VM in project ovirt-engine by oVirt.
the class ImportValidatorTest method createParameters.
protected ImportVmParameters createParameters() {
final VM v = createVM();
v.setName("testVm");
return new ImportVmParameters(v, Guid.newGuid(), Guid.newGuid(), Guid.newGuid(), Guid.newGuid());
}
Aggregations