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);
}
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());
}
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());
}
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());
}
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);
}
Aggregations