Search in sources :

Example 76 with VM

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());
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) VM(org.ovirt.engine.core.common.businessentities.VM) List(java.util.List) Guid(org.ovirt.engine.core.compat.Guid) Test(org.junit.Test)

Example 77 with VM

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());
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Test(org.junit.Test)

Example 78 with VM

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));
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList) OvfEntityData(org.ovirt.engine.core.common.businessentities.OvfEntityData) FullEntityOvfData(org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData)

Example 79 with VM

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;
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM)

Example 80 with VM

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());
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) ImportVmParameters(org.ovirt.engine.core.common.action.ImportVmParameters)

Aggregations

VM (org.ovirt.engine.core.common.businessentities.VM)591 Test (org.junit.Test)178 Guid (org.ovirt.engine.core.compat.Guid)150 ArrayList (java.util.ArrayList)130 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)82 HashMap (java.util.HashMap)69 List (java.util.List)65 VDS (org.ovirt.engine.core.common.businessentities.VDS)63 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)56 Map (java.util.Map)53 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)53 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)41 QueryType (org.ovirt.engine.core.common.queries.QueryType)36 Snapshot (org.ovirt.engine.core.common.businessentities.Snapshot)34 Frontend (org.ovirt.engine.ui.frontend.Frontend)34 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)33 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)32 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)32 Collectors (java.util.stream.Collectors)31 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)31