use of org.ovirt.engine.api.model.Disk in project ovirt-engine by oVirt.
the class BackendVmDisksResourceTest method testAddDiskWithJobId.
@Test
public void testAddDiskWithJobId() throws Exception {
Disk model = getModel();
setUriInfo(setUpBasicUriExpectations());
setUriInfo(setUpGetMatrixConstraintsExpectations(BackendResource.JOB_ID_CONSTRAINT, true, GUIDS[1].toString(), collection.getUriInfo()));
setUpGetDiskExpectations();
setCommonExpectations(model);
Response response = collection.add(getModel());
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 BackendVmDisksResourceTest method testAddDiskWithinStorageDomain.
@Test
public void testAddDiskWithinStorageDomain() throws Exception {
setUriInfo(setUpBasicUriExpectations());
setUpHttpHeaderExpectations("Expect", "201-created");
setUpGetDiskExpectations();
setUpEntityQueryExpectations(QueryType.GetStorageDomainById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[3] }, getStorageDomain(GUIDS[3]));
setUpCreationExpectations(ActionType.AddDisk, AddDiskParameters.class, new String[] { "VmId", "StorageDomainId" }, new Object[] { VM_ID, GUIDS[3] }, 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.setStorageDomains(new StorageDomains());
StorageDomain storageDomain = new StorageDomain();
storageDomain.setId(GUIDS[3].toString());
model.getStorageDomains().getStorageDomains().add(storageDomain);
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.api.model.Disk in project ovirt-engine by oVirt.
the class BackendVmDisksResourceTest method testAddIncompleteParameters2.
@Test
public void testAddIncompleteParameters2() throws Exception {
Disk model = getModel();
model.setProvisionedSize(null);
setUriInfo(setUpBasicUriExpectations());
try {
collection.add(model);
fail("expected WebApplicationException on incomplete parameters");
} catch (WebApplicationException wae) {
// Because of extra frame offset used current method name in test, while in real world used "add" method name
verifyIncompleteException(wae, "Disk", "testAddIncompleteParameters2", "provisionedSize|size");
}
}
use of org.ovirt.engine.api.model.Disk in project ovirt-engine by oVirt.
the class BackendVmDisksResourceTest method doTestAddAsync.
private void doTestAddAsync(AsyncTaskStatusEnum asyncStatus, CreationStatus creationStatus) throws Exception {
setUriInfo(setUpBasicUriExpectations());
setUpEntityQueryExpectations(QueryType.GetStorageDomainById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[2] }, getStorageDomain(GUIDS[2]));
setUpCreationExpectations(ActionType.AddDisk, AddDiskParameters.class, new String[] { "VmId" }, new Object[] { VM_ID }, true, true, GUIDS[0], asList(GUIDS[3]), asList(new AsyncTaskStatus(asyncStatus)), QueryType.GetDiskByDiskId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { DISK_ID }, asList(getEntity(0)));
Disk model = getModel();
model.setProvisionedSize(1024 * 1024L);
Response response = collection.add(model);
assertEquals(202, response.getStatus());
assertTrue(response.getEntity() instanceof Disk);
verifyModel((Disk) response.getEntity(), 0);
Disk created = (Disk) response.getEntity();
assertNotNull(created.getCreationStatus());
assertEquals(creationStatus.value(), created.getCreationStatus());
}
use of org.ovirt.engine.api.model.Disk in project ovirt-engine by oVirt.
the class BackendVmDisksResourceTest method testAttachDiskSnapshot.
@Test
public void testAttachDiskSnapshot() throws Exception {
setUriInfo(setUpBasicUriExpectations());
Guid snapshotId = Guid.newGuid();
Disk model = getModel();
model.setSnapshot(new Snapshot());
model.getSnapshot().setId(snapshotId.toString());
// means this is an existing disk --> attach
model.setId(DISK_ID.toString());
setUpCreationExpectations(ActionType.AttachDiskToVm, AttachDetachVmDiskParameters.class, new String[] { "VmId", "EntityInfo", "SnapshotId" }, new Object[] { VM_ID, new EntityInfo(VdcObjectType.Disk, DISK_ID), snapshotId }, true, true, null, null, null, QueryType.GetDiskByDiskId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { DISK_ID }, asList(getEntity(0)));
Response response = collection.add(model);
assertEquals(201, response.getStatus());
}
Aggregations