Search in sources :

Example 1 with DiskMapper

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

Aggregations

Response (javax.ws.rs.core.Response)1 Test (org.junit.Test)1 Disk (org.ovirt.engine.api.model.Disk)1 DiskMapper (org.ovirt.engine.api.restapi.types.DiskMapper)1 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)1