use of org.ovirt.engine.api.model.Disk in project ovirt-engine by oVirt.
the class BackendStorageDomainDisksResourceTest method testAdd.
@Test
public void testAdd() throws Exception {
setUriInfo(setUpBasicUriExpectations());
setUpHttpHeaderExpectations("Expect", "201-created");
setUpEntityQueryExpectations(QueryType.GetDiskByDiskId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
Disk model = getModel();
setUpCreationExpectations(ActionType.AddDisk, AddDiskParameters.class, new String[] { "StorageDomainId" }, new Object[] { GUIDS[3] }, true, true, GUIDS[0], asList(storagePoolId), asList(new AsyncTaskStatus(AsyncTaskStatusEnum.finished)), QueryType.GetDiskByDiskId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
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.api.model.Disk in project ovirt-engine by oVirt.
the class BackendStorageDomainDisksResourceTest method testAddUnregistered.
@Test
public void testAddUnregistered() throws Exception {
setUriInfo(addMatrixParameterExpectations(setUpBasicUriExpectations(), BackendStorageDomainDisksResource.UNREGISTERED));
setUpHttpHeaderExpectations("Expect", "201-created");
StoragePool storagePool = new StoragePool();
storagePool.setId(storagePoolId);
setUpEntityQueryExpectations(QueryType.GetStoragePoolsByStorageDomainId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[3] }, Collections.singletonList(storagePool));
setUpEntityQueryExpectations(QueryType.GetUnregisteredDisk, GetUnregisteredDiskQueryParameters.class, new String[] { "DiskId", "StorageDomainId", "StoragePoolId" }, new Object[] { GUIDS[0], GUIDS[3], storagePoolId }, getEntity(0));
Disk model = getModel();
org.ovirt.engine.core.common.businessentities.storage.Disk imageToRegister = new DiskMapper().map(model, getEntity(0));
// imageToRegister.setDiskAlias("alias");
setUpCreationExpectations(ActionType.RegisterDisk, RegisterDiskParameters.class, new String[] { "DiskImage" }, new Object[] { imageToRegister }, true, true, GUIDS[0], QueryType.GetDiskByDiskId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
model.setId(GUIDS[0].toString());
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.api.model.Disk in project ovirt-engine by oVirt.
the class BackendTemplateDiskResourceTest method testGet.
@Test
public void testGet() throws Exception {
setUriInfo(setUpBasicUriExpectations());
setUpEntityQueryExpectations(1);
Disk disk = resource.get();
verifyModelSpecific(disk, 1);
verifyLinks(disk);
}
use of org.ovirt.engine.api.model.Disk in project ovirt-engine by oVirt.
the class BackendTemplateDisksResourceTest method testList.
@Test
@Override
public void testList() throws Exception {
UriInfo uriInfo = setUpUriExpectations(null);
setUpEntityQueryExpectations(1, null);
collection.setUriInfo(uriInfo);
List<Disk> disks = getCollection();
for (Disk disk : disks) {
assertNotNull(disk.getStorageDomains());
List<StorageDomain> storageDomains = disk.getStorageDomains().getStorageDomains();
assertEquals(1, storageDomains.size());
assertEquals(storageDomains.get(0).getId(), GUIDS[0].toString());
}
verifyCollection(disks);
}
use of org.ovirt.engine.api.model.Disk in project ovirt-engine by oVirt.
the class DiskSnapshotMapper method map.
@Mapping(from = org.ovirt.engine.core.common.businessentities.storage.Disk.class, to = DiskSnapshot.class)
public static DiskSnapshot map(org.ovirt.engine.core.common.businessentities.storage.Disk entity, DiskSnapshot template) {
if (template == null) {
template = new DiskSnapshot();
}
DiskSnapshot model = (DiskSnapshot) DiskMapper.map(entity, template);
Disk disk = new Disk();
disk.setId(entity.getId().toString());
model.setDisk(disk);
DiskImage diskImage = (DiskImage) entity;
model.setId(diskImage.getImageId().toString());
model.setImageId(null);
return model;
}
Aggregations