use of org.ovirt.engine.core.common.businessentities.AsyncTaskStatus in project ovirt-engine by oVirt.
the class BackendStorageDomainVmResourceTest method doTestImportAsync.
private void doTestImportAsync(AsyncTaskStatusEnum asyncStatus, CreationStatus actionStatus) throws Exception {
setUpGetEntityExpectations(1, StorageDomainType.ImportExport, GUIDS[2]);
setUpGetDataCenterByStorageDomainExpectations(GUIDS[3]);
setUriInfo(setUpActionExpectations(ActionType.ImportVm, ImportVmParameters.class, new String[] { "ContainerId", "StorageDomainId", "SourceDomainId", "DestDomainId", "StoragePoolId", "ClusterId" }, new Object[] { VM_ID, GUIDS[2], STORAGE_DOMAIN_ID, GUIDS[2], DATA_CENTER_ID, GUIDS[1] }, asList(GUIDS[1]), asList(new AsyncTaskStatus(asyncStatus))));
StorageDomain storageDomain = new StorageDomain();
storageDomain.setId(GUIDS[2].toString());
org.ovirt.engine.api.model.Cluster cluster = new org.ovirt.engine.api.model.Cluster();
cluster.setId(GUIDS[1].toString());
Action action = new Action();
action.setStorageDomain(storageDomain);
action.setCluster(cluster);
Response response = resource.doImport(action);
verifyActionResponse(response, URL_BASE, 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 BackendVmDisksResourceTest method testAddDiskIdentifyStorageDomainByName.
@Test
public void testAddDiskIdentifyStorageDomainByName() throws Exception {
setUriInfo(setUpBasicUriExpectations());
setUpHttpHeaderExpectations("Expect", "201-created");
setUpGetDiskExpectations();
int times = 2;
while (times-- > 0) {
setUpEntityQueryExpectations(QueryType.GetAllStorageDomains, QueryParametersBase.class, new String[] {}, new Object[] {}, getStorageDomains());
}
setUpEntityQueryExpectations(QueryType.GetStorageDomainById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[2] }, getStorageDomain(GUIDS[2]));
setUpCreationExpectations(ActionType.AddDisk, AddDiskParameters.class, new String[] { "VmId", "StorageDomainId" }, new Object[] { VM_ID, GUIDS[2] }, true, true, GUIDS[0], asList(GUIDS[3]), asList(new AsyncTaskStatus(AsyncTaskStatusEnum.finished)), QueryType.GetDiskByDiskId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { DISK_ID }, asList(getEntity(0)));
Disk model = getModel();
model.getStorageDomains().getStorageDomains().get(0).setId(null);
model.getStorageDomains().getStorageDomains().get(0).setName("Storage_Domain_1");
model.setProvisionedSize(1024 * 1024L);
Response response = collection.add(model);
assertEquals(201, response.getStatus());
assertTrue(response.getEntity() instanceof Disk);
verifyModel((Disk) response.getEntity(), 0);
assertNull(((Disk) response.getEntity()).getCreationStatus());
}
use of org.ovirt.engine.core.common.businessentities.AsyncTaskStatus in project ovirt-engine by oVirt.
the class BackendTemplatesResourceTest method testAddWithClusterName.
@Test
public void testAddWithClusterName() throws Exception {
setUriInfo(setUpBasicUriExpectations());
setUpHttpHeaderExpectations("Expect", "201-created");
setUpEntityQueryExpectations(QueryType.GetClusterById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[2] }, getClusterEntity());
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);
setUpGetEntityExpectations(QueryType.GetClusterByName, NameQueryParameters.class, new String[] { "Name" }, new Object[] { NAMES[2] }, setUpCluster(GUIDS[2]));
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.setCluster(new org.ovirt.engine.api.model.Cluster());
model.getCluster().setName(NAMES[2]);
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 testAddWithCluster.
@Test
public void testAddWithCluster() throws Exception {
setUriInfo(setUpBasicUriExpectations());
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" }, 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.setCluster(new org.ovirt.engine.api.model.Cluster());
model.getCluster().setId(GUIDS[2].toString());
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 doTestAddAsync.
private void doTestAddAsync(AsyncTaskStatusEnum asyncStatus, CreationStatus creationStatus) throws Exception {
setUriInfo(setUpBasicUriExpectations());
setUpGetGraphicsExpectations(1);
setUpGetConsoleExpectations(0, 1);
setUpGetVirtioScsiExpectations(0);
setUpGetSoundcardExpectations(0, 1);
setUpGetRngDeviceExpectations(0);
setUpGetBallooningExpectations(new Integer[] { 0 });
setUpGetEntityExpectations(QueryType.GetVmByVmId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[1] }, setUpVm(GUIDS[1]));
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(asyncStatus)), QueryType.GetVmTemplate, GetVmTemplateParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
Response response = collection.add(getModel(0));
assertEquals(202, response.getStatus());
assertTrue(response.getEntity() instanceof Template);
verifyModel((Template) response.getEntity(), 0);
Template created = (Template) response.getEntity();
assertNotNull(created.getCreationStatus());
assertEquals(creationStatus.value(), created.getCreationStatus());
}
Aggregations