use of org.ovirt.engine.core.common.businessentities.AsyncTaskStatus in project ovirt-engine by oVirt.
the class BackendTemplateResourceTest method doTestExportAsync.
private void doTestExportAsync(AsyncTaskStatusEnum asyncStatus, CreationStatus actionStatus) throws Exception {
setUriInfo(setUpActionExpectations(ActionType.ExportVmTemplate, MoveOrCopyParameters.class, new String[] { "ContainerId", "StorageDomainId", "ForceOverride" }, new Object[] { GUIDS[0], GUIDS[2], false }, asList(GUIDS[1]), asList(new AsyncTaskStatus(asyncStatus))));
Action action = new Action();
StorageDomain storageDomain = new StorageDomain();
storageDomain.setId(GUIDS[2].toString());
action.setStorageDomain(storageDomain);
Response response = resource.export(action);
verifyActionResponse(response, "templates/" + GUIDS[0], true, null);
action = (Action) response.getEntity();
assertTrue(action.isSetStatus());
assertEquals(actionStatus.value(), action.getStatus());
}
use of org.ovirt.engine.core.common.businessentities.AsyncTaskStatus in project ovirt-engine by oVirt.
the class BackendTemplatesResourceTest method testAddNamedVm.
@Test
public void testAddNamedVm() throws Exception {
setUriInfo(setUpBasicUriExpectations());
setUpHttpHeaderExpectations("Expect", "201-created");
setUpGetEntityExpectations(QueryType.GetVmByVmNameForDataCenter, GetVmByVmNameForDataCenterParameters.class, new String[] { "Name" }, new Object[] { NAMES[1] }, setUpVm(GUIDS[1]));
setUpGetEntityExpectations(0);
setUpGetGraphicsExpectations(1);
setUpGetConsoleExpectations(0, 0, 1);
setUpGetVirtioScsiExpectations(0, 0);
setUpGetSoundcardExpectations(0, 0, 1);
setUpGetRngDeviceExpectations(0, 0);
setUpGetBallooningExpectations(0, 0);
setUpCreationExpectations(ActionType.AddVmTemplate, AddVmTemplateParameters.class, new String[] { "Name", "Description" }, new Object[] { NAMES[0], DESCRIPTIONS[0] }, true, true, GUIDS[0], asList(GUIDS[2]), asList(new AsyncTaskStatus(AsyncTaskStatusEnum.finished)), QueryType.GetVmTemplate, GetVmTemplateParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
Template model = getModel(0);
model.getVm().setId(null);
model.getVm().setName(NAMES[1]);
Response response = collection.add(model);
assertEquals(201, response.getStatus());
assertTrue(response.getEntity() instanceof Template);
verifyModel((Template) response.getEntity(), 0);
assertNull(((Template) response.getEntity()).getCreationStatus());
}
use of org.ovirt.engine.core.common.businessentities.AsyncTaskStatus in project ovirt-engine by oVirt.
the class BackendTemplatesResourceTest method testAddNamedVmFiltered.
@Test
public void testAddNamedVmFiltered() throws Exception {
setUpFilteredQueryExpectations();
setUriInfo(setUpBasicUriExpectations());
setUpHttpHeaderExpectations("Expect", "201-created");
setUpGetEntityExpectations(QueryType.GetVmByVmNameForDataCenter, GetVmByVmNameForDataCenterParameters.class, new String[] { "Name" }, new Object[] { NAMES[1] }, setUpVm(GUIDS[1]));
setUpGetEntityExpectations(0);
setUpGetGraphicsExpectations(1);
setUpGetConsoleExpectations(0, 0, 1);
setUpGetVirtioScsiExpectations(0, 0);
setUpGetSoundcardExpectations(0, 0, 1);
setUpGetRngDeviceExpectations(0, 0);
setUpGetBallooningExpectations(0, 0);
setUpCreationExpectations(ActionType.AddVmTemplate, AddVmTemplateParameters.class, new String[] { "Name", "Description" }, new Object[] { NAMES[0], DESCRIPTIONS[0] }, true, true, GUIDS[0], asList(GUIDS[2]), asList(new AsyncTaskStatus(AsyncTaskStatusEnum.finished)), QueryType.GetVmTemplate, GetVmTemplateParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
Template model = getModel(0);
model.getVm().setId(null);
model.getVm().setName(NAMES[1]);
Response response = collection.add(model);
assertEquals(201, response.getStatus());
assertTrue(response.getEntity() instanceof Template);
verifyModel((Template) response.getEntity(), 0);
assertNull(((Template) response.getEntity()).getCreationStatus());
}
use of org.ovirt.engine.core.common.businessentities.AsyncTaskStatus in project ovirt-engine by oVirt.
the class BackendTemplatesResourceTest method doTestAddWithClonePermissions.
private void doTestAddWithClonePermissions(Template model, boolean copy) throws Exception {
UriInfo uriInfo = setUpBasicUriExpectations();
uriInfo = addMatrixParameterExpectations(uriInfo, BackendTemplatesResource.CLONE_PERMISSIONS, Boolean.toString(copy));
setUriInfo(uriInfo);
setUpHttpHeaderExpectations("Expect", "201-created");
setUpGetEntityExpectations(QueryType.GetVmByVmId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[1] }, setUpVm(GUIDS[1]));
setUpGetEntityExpectations(0);
setUpGetGraphicsExpectations(1);
setUpGetConsoleExpectations(0, 0, 1);
setUpGetVirtioScsiExpectations(0, 0);
setUpGetSoundcardExpectations(0, 0, 1);
setUpGetRngDeviceExpectations(0, 0);
setUpGetBallooningExpectations(0, 0);
setUpCreationExpectations(ActionType.AddVmTemplate, AddVmTemplateParameters.class, new String[] { "Name", "Description", "CopyVmPermissions" }, new Object[] { NAMES[0], DESCRIPTIONS[0], copy }, true, true, GUIDS[0], asList(GUIDS[2]), asList(new AsyncTaskStatus(AsyncTaskStatusEnum.finished)), QueryType.GetVmTemplate, GetVmTemplateParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
Response response = collection.add(model);
assertEquals(201, response.getStatus());
assertTrue(response.getEntity() instanceof Template);
verifyModel((Template) response.getEntity(), 0);
assertNull(((Template) response.getEntity()).getCreationStatus());
}
use of org.ovirt.engine.core.common.businessentities.AsyncTaskStatus in project ovirt-engine by oVirt.
the class BackendTemplatesResourceTest method testAddUploadIcon.
@Test
public void testAddUploadIcon() throws Exception {
setUpGetGraphicsExpectations(1);
setUpGetConsoleExpectations(0, 0, 1);
setUpGetSoundcardExpectations(1);
setUpGetBallooningExpectations(0, 0);
setUpGetEntityExpectations(QueryType.GetVmByVmId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[1] }, setUpVm(GUIDS[1]));
setUpAddExpectations();
setUpCreationExpectations(ActionType.AddVmTemplate, AddVmTemplateParameters.class, new String[] { "Name", "Description", "VmLargeIcon" }, new Object[] { NAMES[0], DESCRIPTIONS[0], VmIcon.typeAndDataToDataUrl(IconTestHelpler.MEDIA_TYPE, IconTestHelpler.DATA_URL) }, true, true, GUIDS[0], asList(GUIDS[2]), asList(new AsyncTaskStatus(AsyncTaskStatusEnum.finished)), QueryType.GetVmTemplate, GetVmTemplateParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
final Template restModel = getRestModel(0);
restModel.setLargeIcon(IconTestHelpler.createIconWithData());
Response response = doAdd(restModel);
assertEquals(201, response.getStatus());
verifyModel((Template) response.getEntity(), 0);
assertNull(((Template) response.getEntity()).getCreationStatus());
}
Aggregations