use of org.ovirt.engine.api.model.StorageDomain in project ovirt-engine by oVirt.
the class BackendStorageDomainsResourceTest method testAddStorageDomainWithExistingConnectionId.
@Test
public void testAddStorageDomainWithExistingConnectionId() throws Exception {
Host host = new Host();
host.setId(GUIDS[0].toString());
setUriInfo(setUpBasicUriExpectations());
setUpGetEntityExpectations(QueryType.GetStorageServerConnectionById, StorageServerConnectionQueryParametersBase.class, new String[] { "ServerConnectionId" }, new Object[] { GUIDS[POSIX_IDX].toString() }, setUpPosixStorageServerConnection(POSIX_IDX));
setUpGetEntityExpectations(QueryType.GetStorageServerConnectionById, StorageServerConnectionQueryParametersBase.class, new String[] { "ServerConnectionId" }, new Object[] { GUIDS[POSIX_IDX].toString() }, setUpPosixStorageServerConnection(POSIX_IDX));
setUpGetEntityExpectations(QueryType.GetExistingStorageDomainList, GetExistingStorageDomainListParameters.class, new String[] { "Id", "StorageType", "StorageDomainType", "Path" }, new Object[] { GUIDS[0], STORAGE_TYPES_MAPPED[POSIX_IDX], TYPES_MAPPED[0], ADDRESSES[POSIX_IDX] + ":" + PATHS[POSIX_IDX] }, new ArrayList<>());
setUpCreationExpectations(ActionType.AddPosixFsStorageDomain, StorageDomainManagementParameter.class, new String[] { "VdsId" }, new Object[] { GUIDS[0] }, true, true, GUIDS[POSIX_IDX], QueryType.GetStorageDomainById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[POSIX_IDX] }, getEntity(POSIX_IDX));
StorageDomain model = new StorageDomain();
model.setName(getSafeEntry(POSIX_IDX, NAMES));
model.setDescription(getSafeEntry(POSIX_IDX, DESCRIPTIONS));
model.setType(getSafeEntry(POSIX_IDX, TYPES));
model.setStorage(new HostStorage());
model.setHost(new Host());
model.getHost().setId(GUIDS[0].toString());
model.getStorage().setId(GUIDS[POSIX_IDX].toString());
Response response = collection.add(model);
assertEquals(201, response.getStatus());
assertTrue(response.getEntity() instanceof StorageDomain);
verifyModel((StorageDomain) response.getEntity(), POSIX_IDX);
}
use of org.ovirt.engine.api.model.StorageDomain in project ovirt-engine by oVirt.
the class BackendStorageDomainsResourceTest method testAddIncompleteDomainParameters.
@Test
public void testAddIncompleteDomainParameters() throws Exception {
StorageDomain model = getModel(0);
model.setName(NAMES[0]);
model.setHost(new Host());
model.getHost().setId(GUIDS[0].toString());
model.setStorage(new HostStorage());
model.getStorage().setAddress(ADDRESSES[0]);
model.getStorage().setPath(PATHS[0]);
setUriInfo(setUpBasicUriExpectations());
try {
collection.add(model);
fail("expected WebApplicationException on incomplete parameters");
} catch (WebApplicationException wae) {
verifyIncompleteException(wae, "StorageDomain", "add", "storage.type");
}
}
use of org.ovirt.engine.api.model.StorageDomain in project ovirt-engine by oVirt.
the class BackendStorageDomainsResourceTest method testAddStorageDomainWithNoStorageObject.
@Test
public void testAddStorageDomainWithNoStorageObject() throws Exception {
Host host = new Host();
host.setId(GUIDS[0].toString());
setUriInfo(setUpBasicUriExpectations());
StorageDomain model = new StorageDomain();
model.setName(getSafeEntry(POSIX_IDX, NAMES));
model.setDescription(getSafeEntry(POSIX_IDX, DESCRIPTIONS));
model.setType(getSafeEntry(POSIX_IDX, TYPES));
model.setHost(new Host());
model.getHost().setId(GUIDS[0].toString());
try {
collection.add(model);
fail("expected WebApplicationException on incomplete parameters");
} catch (WebApplicationException wae) {
verifyIncompleteException(wae, "StorageDomain", "add", "storage");
}
}
use of org.ovirt.engine.api.model.StorageDomain in project ovirt-engine by oVirt.
the class BackendStorageDomainsResourceTest method testAddLocalStorageDomain.
@Test
public void testAddLocalStorageDomain() throws Exception {
setUriInfo(setUpActionExpectations(ActionType.AddStorageServerConnection, StorageServerConnectionParametersBase.class, new String[] { "StorageServerConnection.Connection", "StorageServerConnection.StorageType", "VdsId" }, new Object[] { PATHS[LOCAL_IDX], STORAGE_TYPES_MAPPED[LOCAL_IDX], GUIDS[0] }, true, true, GUIDS[LOCAL_IDX].toString()));
setUpGetEntityExpectations(QueryType.GetStorageServerConnectionById, StorageServerConnectionQueryParametersBase.class, new String[] { "ServerConnectionId" }, new Object[] { GUIDS[LOCAL_IDX].toString() }, setUpLocalStorageServerConnection(LOCAL_IDX));
setUpCreationExpectations(ActionType.AddLocalStorageDomain, StorageDomainManagementParameter.class, new String[] { "VdsId" }, new Object[] { GUIDS[0] }, true, true, GUIDS[LOCAL_IDX], QueryType.GetStorageDomainById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[LOCAL_IDX] }, getEntity(LOCAL_IDX));
StorageDomain model = getModel(LOCAL_IDX);
model.getStorage().setAddress(null);
model.setHost(new Host());
model.getHost().setId(GUIDS[0].toString());
Response response = collection.add(model);
assertEquals(201, response.getStatus());
assertTrue(response.getEntity() instanceof StorageDomain);
verifyModel((StorageDomain) response.getEntity(), LOCAL_IDX);
}
use of org.ovirt.engine.api.model.StorageDomain in project ovirt-engine by oVirt.
the class BackendStorageDomainsResourceTest method doTestBadAddStorageDomain.
private void doTestBadAddStorageDomain(boolean valid, boolean success, String detail) throws Exception {
setUriInfo(setUpActionExpectations(ActionType.AddStorageServerConnection, StorageServerConnectionParametersBase.class, new String[] { "StorageServerConnection.Connection", "StorageServerConnection.StorageType", "VdsId" }, new Object[] { ADDRESSES[0] + ":" + PATHS[0], STORAGE_TYPES_MAPPED[0], GUIDS[0] }, true, true, GUIDS[0].toString()));
setUpActionExpectations(ActionType.RemoveStorageServerConnection, StorageServerConnectionParametersBase.class, new String[] {}, new Object[] {}, true, true, null);
setUpGetEntityExpectations(QueryType.GetExistingStorageDomainList, GetExistingStorageDomainListParameters.class, new String[] { "Id", "StorageType", "StorageDomainType", "Path" }, new Object[] { GUIDS[0], STORAGE_TYPES_MAPPED[0], TYPES_MAPPED[0], ADDRESSES[0] + ":" + PATHS[0] }, new ArrayList<>());
setUpActionExpectations(ActionType.AddNFSStorageDomain, StorageDomainManagementParameter.class, new String[] {}, new Object[] {}, valid, success);
StorageDomain model = getModel(0);
model.setHost(new Host());
model.getHost().setId(GUIDS[0].toString());
try {
collection.add(model);
fail("expected WebApplicationException");
} catch (WebApplicationException wae) {
verifyFault(wae, detail);
}
}
Aggregations