use of org.ovirt.engine.api.model.Vm in project ovirt-engine by oVirt.
the class BackendVmResourceTest method testUpdateVmPolicySingleHostName.
@Test
public void testUpdateVmPolicySingleHostName() throws Exception {
setUpUdpateVm();
setUpGetHostByNameExpectations(1);
setUriInfo(setUpActionExpectations(ActionType.UpdateVm, VmManagementParametersBase.class, new String[] {}, new Object[] {}, true, true));
Vm model = getModel(0);
model.setPlacementPolicy(new VmPlacementPolicy());
model.getPlacementPolicy().setHosts(new Hosts());
model.getPlacementPolicy().getHosts().getHosts().add(new Host());
model.getPlacementPolicy().getHosts().getHosts().get(0).setName(NAMES[1]);
verifyModel(resource.update(model), 0);
}
use of org.ovirt.engine.api.model.Vm in project ovirt-engine by oVirt.
the class BackendVmResourceTest method testGet.
@Test
public void testGet() throws Exception {
setUriInfo(setUpBasicUriExpectations());
setUpGetEntityExpectations(1);
setUpGetPayloadExpectations(0, 1);
setUpGetBallooningExpectations();
setUpGetGraphicsExpectations(1);
setUpGetCertuficateExpectations();
Vm response = resource.get();
verifyModel(response, 0);
verifyCertificate(response);
}
use of org.ovirt.engine.api.model.Vm in project ovirt-engine by oVirt.
the class BackendVmResourceTest method testUpdateVmPolicyHostsNames.
@Test
public void testUpdateVmPolicyHostsNames() throws Exception {
setUpUdpateVm();
for (int i = 0; i < NAMES.length; i++) {
setUpGetHostByNameExpectations(i);
}
setUriInfo(setUpActionExpectations(ActionType.UpdateVm, VmManagementParametersBase.class, new String[] {}, new Object[] {}, true, true));
Vm model = getModel(0);
model.setPlacementPolicy(new VmPlacementPolicy());
Hosts hosts = new Hosts();
for (int i = 0; i < NAMES.length; i++) {
Host newHost = new Host();
newHost.setName(NAMES[i]);
hosts.getHosts().add(newHost);
}
model.getPlacementPolicy().setHosts(hosts);
verifyModel(resource.update(model), 0);
}
use of org.ovirt.engine.api.model.Vm in project ovirt-engine by oVirt.
the class BackendVmResourceTest method testStartWithVm.
@Test
public void testStartWithVm() throws Exception {
setUpWindowsGetEntityExpectations(1, false);
setUriInfo(setUpActionExpectations(ActionType.RunVmOnce, RunVmOnceParams.class, new String[] { "VmId" }, new Object[] { GUIDS[0] }));
Action action = new Action();
action.setVm(new Vm());
Response response = resource.start(action);
verifyActionResponse(response);
verifyActionModel(((Action) response.getEntity()).getVm(), 0);
}
use of org.ovirt.engine.api.model.Vm in project ovirt-engine by oVirt.
the class BackendVmResourceTest method testCloneVm.
@Test
public void testCloneVm() throws Exception {
org.ovirt.engine.core.common.businessentities.VM mockedVm = mock(org.ovirt.engine.core.common.businessentities.VM.class);
VmStatic vmStatic = mock(VmStatic.class);
when(mockedVm.getStaticData()).thenReturn(vmStatic);
setUpGetEntityExpectations(QueryType.GetVmByVmId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, mockedVm);
setUriInfo(setUpActionExpectations(ActionType.CloneVm, CloneVmParameters.class, new String[] { "VmStaticData", "NewName" }, new Object[] { vmStatic, "someNewName" }));
Action action = new Action();
Vm vm = new Vm();
vm.setName("someNewName");
action.setVm(vm);
Response response = resource.doClone(action);
verifyActionResponse(response);
Action actionResponse = (Action) response.getEntity();
assertTrue(actionResponse.isSetStatus());
}
Aggregations