Search in sources :

Example 46 with Disk

use of org.ovirt.engine.api.model.Disk in project ovirt-engine by oVirt.

the class BackendVmDiskResourceTest method testStatisticalQuery.

@Test
public void testStatisticalQuery() throws Exception {
    DiskImage entity = setUpStatisticalExpectations();
    @SuppressWarnings("unchecked") BackendStatisticsResource<Disk, DiskImage> statisticsResource = (BackendStatisticsResource<Disk, DiskImage>) resource.getStatisticsResource();
    assertNotNull(statisticsResource);
    verifyQuery(statisticsResource.getQuery(), entity);
}
Also used : DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Disk(org.ovirt.engine.api.model.Disk) Test(org.junit.Test)

Example 47 with Disk

use of org.ovirt.engine.api.model.Disk in project ovirt-engine by oVirt.

the class BackendVmDiskResourceTest method getUpdate.

protected Disk getUpdate() {
    Disk update = new Disk();
    update.setWipeAfterDelete(false);
    update.setReadOnly(true);
    return update;
}
Also used : Disk(org.ovirt.engine.api.model.Disk)

Example 48 with Disk

use of org.ovirt.engine.api.model.Disk in project ovirt-engine by oVirt.

the class BackendVmDiskResourceTest method testGet.

@Test
public void testGet() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpEntityQueryExpectations(1);
    Disk disk = resource.get();
    verifyModelSpecific(disk, 1);
    verifyLinks(disk);
}
Also used : Disk(org.ovirt.engine.api.model.Disk) Test(org.junit.Test)

Example 49 with Disk

use of org.ovirt.engine.api.model.Disk in project ovirt-engine by oVirt.

the class BackendVmDiskResourceTest method testUpdateReadOnly.

@Test
public void testUpdateReadOnly() throws Exception {
    setUpGetEntityExpectations(2);
    setUpDiskVmElementExpectations();
    setUriInfo(setUpActionExpectations(ActionType.UpdateVmDisk, VmDiskOperationParameterBase.class, new String[] { "VmId", "DiskVmElement.ReadOnly" }, new Object[] { VM_ID, Boolean.TRUE }, true, true));
    Disk disk = resource.update(getUpdate());
    assertNotNull(disk);
}
Also used : Disk(org.ovirt.engine.api.model.Disk) VmDiskOperationParameterBase(org.ovirt.engine.core.common.action.VmDiskOperationParameterBase) Test(org.junit.Test)

Example 50 with Disk

use of org.ovirt.engine.api.model.Disk 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());
}
Also used : Response(javax.ws.rs.core.Response) AsyncTaskStatus(org.ovirt.engine.core.common.businessentities.AsyncTaskStatus) Disk(org.ovirt.engine.api.model.Disk) Test(org.junit.Test)

Aggregations

Disk (org.ovirt.engine.api.model.Disk)68 Test (org.junit.Test)33 Response (javax.ws.rs.core.Response)13 Guid (org.ovirt.engine.core.compat.Guid)13 WebApplicationException (javax.ws.rs.WebApplicationException)10 DiskAttachment (org.ovirt.engine.api.model.DiskAttachment)10 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)10 StorageDomain (org.ovirt.engine.api.model.StorageDomain)9 AsyncTaskStatus (org.ovirt.engine.core.common.businessentities.AsyncTaskStatus)7 Vm (org.ovirt.engine.api.model.Vm)6 StorageDomains (org.ovirt.engine.api.model.StorageDomains)4 V3Disk (org.ovirt.engine.api.v3.types.V3Disk)4 DiskAttachments (org.ovirt.engine.api.model.DiskAttachments)3 V3Disks (org.ovirt.engine.api.v3.types.V3Disks)3 UriInfo (javax.ws.rs.core.UriInfo)2 HostStorage (org.ovirt.engine.api.model.HostStorage)2 V3CdRoms (org.ovirt.engine.api.v3.types.V3CdRoms)2 V3CustomProperties (org.ovirt.engine.api.v3.types.V3CustomProperties)2 V3Floppies (org.ovirt.engine.api.v3.types.V3Floppies)2 V3KatelloErrata (org.ovirt.engine.api.v3.types.V3KatelloErrata)2