Search in sources :

Example 21 with IdQueryParameters

use of org.ovirt.engine.core.common.queries.IdQueryParameters in project ovirt-engine by oVirt.

the class GetVmConfigurationBySnapshotQueryTest method testQuery.

@Test
public void testQuery() throws Exception {
    GetVmConfigurationBySnapshotQuery<IdQueryParameters> query = setupQueryBySnapshotId(existingSnapshotId);
    VM vm = new VM();
    doReturn(vm).when(snapshotVmConfigurationHelper).getVmFromConfiguration(any(), any(), any());
    query.execute();
    QueryReturnValue returnValue = query.getQueryReturnValue();
    assertNotNull("Return value from query cannot be null", returnValue);
    VM returnedVm = returnValue.getReturnValue();
    assertEquals(vm, returnedVm);
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) VM(org.ovirt.engine.core.common.businessentities.VM) Test(org.junit.Test)

Example 22 with IdQueryParameters

use of org.ovirt.engine.core.common.queries.IdQueryParameters in project ovirt-engine by oVirt.

the class GetVmGuestAgentInterfacesByVmIdQueryTest method testExecuteQuery.

@Test
public void testExecuteQuery() {
    IdQueryParameters params = getQueryParameters();
    Guid vmId = Guid.newGuid();
    when(params.getId()).thenReturn(vmId);
    getQuery().executeQueryCommand();
    verify(vmGuestAgentInterfaceDao).getAllForVm(vmId, getUser().getId(), getQueryParameters().isFiltered());
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Guid(org.ovirt.engine.core.compat.Guid) Test(org.junit.Test)

Example 23 with IdQueryParameters

use of org.ovirt.engine.core.common.queries.IdQueryParameters in project ovirt-engine by oVirt.

the class GetVmTemplatesByImageGuidQueryTest 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, VmTemplate> expected = Collections.singletonMap(true, new VmTemplate());
    when(vmTemplateDaoMock.getAllForImage(imageGuid)).thenReturn(expected);
    // Mock away the handler
    doNothing().when(getQuery()).updateDisksFromDb(any());
    // Run the query
    GetVmTemplatesByImageGuidQuery<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) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) Guid(org.ovirt.engine.core.compat.Guid) Test(org.junit.Test)

Example 24 with IdQueryParameters

use of org.ovirt.engine.core.common.queries.IdQueryParameters 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 25 with IdQueryParameters

use of org.ovirt.engine.core.common.queries.IdQueryParameters in project ovirt-engine by oVirt.

the class GetVdsByVdsIdQueryTest method testExecuteQueryCommnad.

@Test
public void testExecuteQueryCommnad() {
    // Set up the expected data
    Guid vdsID = Guid.newGuid();
    VDS expected = new VDS();
    expected.setId(vdsID);
    // Mock the query's parameters
    when(getQueryParameters().getId()).thenReturn(vdsID);
    // Mock the Daos
    when(vdsDaoMock.get(vdsID)).thenReturn(expected);
    GetVdsByVdsIdQuery<IdQueryParameters> query = getQuery();
    query.executeQueryCommand();
    VDS actual = query.getQueryReturnValue().getReturnValue();
    assertEquals("wrong VDS", expected, actual);
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) VDS(org.ovirt.engine.core.common.businessentities.VDS) Guid(org.ovirt.engine.core.compat.Guid) Test(org.junit.Test)

Aggregations

IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)268 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)89 Guid (org.ovirt.engine.core.compat.Guid)80 ArrayList (java.util.ArrayList)68 StorageDomainsAndStoragePoolIdQueryParameters (org.ovirt.engine.core.common.queries.StorageDomainsAndStoragePoolIdQueryParameters)62 QueryType (org.ovirt.engine.core.common.queries.QueryType)59 List (java.util.List)47 Frontend (org.ovirt.engine.ui.frontend.Frontend)45 VM (org.ovirt.engine.core.common.businessentities.VM)42 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)36 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)35 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)26 Collection (java.util.Collection)25 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)25 SearchableListModel (org.ovirt.engine.ui.uicommonweb.models.SearchableListModel)25 Test (org.junit.Test)24 VDS (org.ovirt.engine.core.common.businessentities.VDS)24 HashMap (java.util.HashMap)22 ActionType (org.ovirt.engine.core.common.action.ActionType)21 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)19