use of org.ovirt.engine.api.model.Action in project ovirt-engine by oVirt.
the class BackendVmResourceTest method testPreviewSnapshot.
@Test
public void testPreviewSnapshot() throws Exception {
setUriInfo(setUpActionExpectations(ActionType.TryBackToAllSnapshotsOfVm, TryBackToAllSnapshotsOfVmParameters.class, new String[] { "VmId", "DstSnapshotId" }, new Object[] { GUIDS[0], GUIDS[1] }));
Action action = new Action();
Snapshot snapshot = new Snapshot();
snapshot.setId(GUIDS[1].toString());
action.setSnapshot(snapshot);
Response response = resource.previewSnapshot(action);
verifyActionResponse(response);
Action actionResponse = (Action) response.getEntity();
assertTrue(actionResponse.isSetStatus());
assertEquals(CreationStatus.COMPLETE.value(), actionResponse.getStatus());
}
use of org.ovirt.engine.api.model.Action 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());
}
use of org.ovirt.engine.api.model.Action in project ovirt-engine by oVirt.
the class BackendVmResourceTest method doTestSuspendAsync.
private void doTestSuspendAsync(AsyncTaskStatusEnum asyncStatus, CreationStatus actionStatus) throws Exception {
setUriInfo(setUpActionExpectations(ActionType.HibernateVm, VmOperationParameterBase.class, new String[] { "VmId" }, new Object[] { GUIDS[0] }, asList(GUIDS[1]), asList(new AsyncTaskStatus(asyncStatus))));
Response response = resource.suspend(new Action());
verifyActionResponse(response, "vms/" + GUIDS[0], true, null);
Action action = (Action) response.getEntity();
assertTrue(action.isSetStatus());
assertEquals(actionStatus.value(), action.getStatus());
}
use of org.ovirt.engine.api.model.Action in project ovirt-engine by oVirt.
the class BackendVmResourceTest method testMaintenance.
@Test
public void testMaintenance() throws Exception {
setUpGetEntityExpectations(1);
setUriInfo(setUpActionExpectations(ActionType.SetHaMaintenance, SetHaMaintenanceParameters.class, new String[] { "IsEnabled" }, new Object[] { true }));
Action action = new Action();
action.setMaintenanceEnabled(true);
verifyActionResponse(resource.maintenance(action));
}
use of org.ovirt.engine.api.model.Action in project ovirt-engine by oVirt.
the class BackendVmResourceTest method testMigrateWithClusterId.
@Test
public void testMigrateWithClusterId() throws Exception {
setUriInfo(setUpActionExpectations(ActionType.MigrateVm, MigrateVmParameters.class, new String[] { "VmId", "ForceMigrationForNonMigratableVm", "TargetClusterId" }, new Object[] { GUIDS[0], Boolean.FALSE, GUIDS[1] }));
Action action = new Action();
org.ovirt.engine.api.model.Cluster cluster = new org.ovirt.engine.api.model.Cluster();
cluster.setId(GUIDS[1].toString());
action.setCluster(cluster);
verifyActionResponse(resource.migrate(action));
}
Aggregations