Search in sources :

Example 11 with DataCenter

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

the class BackendEntityAssignedPermissionsResourceTest method testAddIncompletePermission.

@Test
public void testAddIncompletePermission() throws Exception {
    Permission model = new Permission();
    model.setDataCenter(new DataCenter());
    model.getDataCenter().setId(GUIDS[2].toString());
    model.setRole(new Role());
    model.getRole().setId(GUIDS[3].toString());
    setUriInfo(setUpBasicUriExpectations());
    try {
        collection.add(model);
    } catch (WebApplicationException wae) {
        verifyIncompleteException(wae, "Permission", "add", "user|group.id");
    }
}
Also used : Role(org.ovirt.engine.api.model.Role) DataCenter(org.ovirt.engine.api.model.DataCenter) WebApplicationException(javax.ws.rs.WebApplicationException) Permission(org.ovirt.engine.api.model.Permission) Test(org.junit.Test)

Example 12 with DataCenter

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

the class BackendClustersResourceTest method getModel.

static org.ovirt.engine.api.model.Cluster getModel(int index) {
    org.ovirt.engine.api.model.Cluster model = new org.ovirt.engine.api.model.Cluster();
    model.setName(NAMES[index]);
    model.setDescription(DESCRIPTIONS[index]);
    model.setDataCenter(new DataCenter());
    model.setCpu(new Cpu());
    model.getCpu().setType("Intel Xeon");
    return model;
}
Also used : DataCenter(org.ovirt.engine.api.model.DataCenter) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) Cpu(org.ovirt.engine.api.model.Cpu)

Example 13 with DataCenter

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

the class BackendDataCenterNetworksResourceTest method testAddNetwork.

@Test
public void testAddNetwork() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpCreationExpectations(ActionType.AddNetwork, AddNetworkStoragePoolParameters.class, new String[] { "StoragePoolId" }, new Object[] { DATA_CENTER_ID }, true, true, // GUIDS[0],
    null, QueryType.GetNetworksByDataCenterId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { DATA_CENTER_ID }, asList(getEntity(0)));
    Network model = getModel(0);
    model.setDataCenter(new DataCenter());
    model.getDataCenter().setId(DATA_CENTER_ID.toString());
    Response response = collection.add(model);
    assertEquals(201, response.getStatus());
    assertTrue(response.getEntity() instanceof Network);
    verifyModel((Network) response.getEntity(), 0);
}
Also used : Response(javax.ws.rs.core.Response) DataCenter(org.ovirt.engine.api.model.DataCenter) Network(org.ovirt.engine.api.model.Network) Test(org.junit.Test)

Example 14 with DataCenter

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

the class BackendDataCenterNetworksResourceTest method doTestBadAddNetwork.

private void doTestBadAddNetwork(boolean valid, boolean success, String detail) throws Exception {
    setUriInfo(setUpActionExpectations(ActionType.AddNetwork, AddNetworkStoragePoolParameters.class, new String[] { "StoragePoolId" }, new Object[] { DATA_CENTER_ID }, valid, success));
    Network model = getModel(0);
    model.setDataCenter(new DataCenter());
    model.getDataCenter().setId(DATA_CENTER_ID.toString());
    try {
        collection.add(model);
        fail("expected WebApplicationException");
    } catch (WebApplicationException wae) {
        verifyFault(wae, detail);
    }
}
Also used : DataCenter(org.ovirt.engine.api.model.DataCenter) WebApplicationException(javax.ws.rs.WebApplicationException) AddNetworkStoragePoolParameters(org.ovirt.engine.core.common.action.AddNetworkStoragePoolParameters) Network(org.ovirt.engine.api.model.Network)

Example 15 with DataCenter

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

the class BackendDataCenterResourceTest method testConflictedUpdate.

@Test
public void testConflictedUpdate() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpGetEntityExpectations(1);
    DataCenter model = getModel(1);
    model.setId(GUIDS[1].toString());
    try {
        resource.update(model);
        fail("expected WebApplicationException");
    } catch (WebApplicationException wae) {
        verifyImmutabilityConstraint(wae);
    }
}
Also used : DataCenter(org.ovirt.engine.api.model.DataCenter) WebApplicationException(javax.ws.rs.WebApplicationException) Test(org.junit.Test)

Aggregations

DataCenter (org.ovirt.engine.api.model.DataCenter)42 Test (org.junit.Test)10 WebApplicationException (javax.ws.rs.WebApplicationException)6 Network (org.ovirt.engine.api.model.Network)6 StorageDomain (org.ovirt.engine.api.model.StorageDomain)5 Response (javax.ws.rs.core.Response)4 Qos (org.ovirt.engine.api.model.Qos)4 Quota (org.ovirt.engine.api.model.Quota)4 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)4 Guid (org.ovirt.engine.core.compat.Guid)4 Cluster (org.ovirt.engine.api.model.Cluster)3 Permission (org.ovirt.engine.api.model.Permission)3 Role (org.ovirt.engine.api.model.Role)3 AddNetworkStoragePoolParameters (org.ovirt.engine.core.common.action.AddNetworkStoragePoolParameters)3 QosBase (org.ovirt.engine.core.common.businessentities.qos.QosBase)3 QosQueryParameterBase (org.ovirt.engine.core.common.queries.QosQueryParameterBase)3 Cpu (org.ovirt.engine.api.model.Cpu)2 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1