Search in sources :

Example 56 with Disk

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

the class BackendVmDisksResourceTest method testAddDiskWithStepId.

@Test
public void testAddDiskWithStepId() throws Exception {
    Disk model = getModel();
    setUriInfo(setUpBasicUriExpectations());
    setUriInfo(setUpGetMatrixConstraintsExpectations(BackendResource.STEP_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());
}
Also used : Response(javax.ws.rs.core.Response) Disk(org.ovirt.engine.api.model.Disk) Test(org.junit.Test)

Example 57 with Disk

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

the class BackendVmDisksResourceTest method testAddLunDiskMissingType.

@Test
public void testAddLunDiskMissingType() {
    Disk model = createIscsiLunDisk();
    model.getLunStorage().setType(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, "HostStorage", "testAddLunDiskMissingType", "type");
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) Disk(org.ovirt.engine.api.model.Disk) Test(org.junit.Test)

Example 58 with Disk

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

the class BackendVmDisksResourceTest method testAddIncompleteParameters.

@Test
public void testAddIncompleteParameters() throws Exception {
    Disk model = new Disk();
    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", "testAddIncompleteParameters", "provisionedSize|size", "format");
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) Disk(org.ovirt.engine.api.model.Disk) Test(org.junit.Test)

Example 59 with Disk

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

the class BackendStorageDomainDiskResourceTest method testGet.

@Test
public void testGet() {
    setUriInfo(setUpBasicUriExpectations());
    setUpEntityQueryExpectations(QueryType.GetDiskAndSnapshotsByDiskId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { DISK_ID }, getEntity(1));
    Disk disk = resource.get();
    verifyModelSpecific(disk, 1);
    verifyLinks(disk);
}
Also used : Disk(org.ovirt.engine.api.model.Disk) Test(org.junit.Test)

Example 60 with Disk

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

the class BackendStorageDomainDisksResourceTest method getModel.

static Disk getModel() {
    Disk model = new Disk();
    model.setProvisionedSize(1024 * 1024L);
    model.setFormat(DiskFormat.COW);
    model.setSparse(true);
    model.setShareable(false);
    model.setPropagateErrors(true);
    model.setStorageDomains(new StorageDomains());
    model.getStorageDomains().getStorageDomains().add(new StorageDomain());
    model.getStorageDomains().getStorageDomains().get(0).setId(GUIDS[2].toString());
    return model;
}
Also used : StorageDomain(org.ovirt.engine.api.model.StorageDomain) StorageDomains(org.ovirt.engine.api.model.StorageDomains) Disk(org.ovirt.engine.api.model.Disk)

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