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());
}
Aggregations