Search in sources :

Example 16 with Network

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

the class BackendClusterNetworksResourceTest method testAddIncompleteParametersNoName.

@Test
public void testAddIncompleteParametersNoName() throws Exception {
    Network model = new Network();
    model.setDescription(DESCRIPTIONS[0]);
    setUriInfo(setUpBasicUriExpectations());
    try {
        collection.add(model);
        fail("expected WebApplicationException on incomplete parameters");
    } catch (WebApplicationException wae) {
        verifyIncompleteException(wae, "Network", "add", "id|name");
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) Network(org.ovirt.engine.api.model.Network) Test(org.junit.Test)

Example 17 with Network

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

the class BackendClusterNetworksResourceTest method testAddIdSuppliedButNoName.

@Test
public void testAddIdSuppliedButNoName() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    Network model = new Network();
    model.setId("11111111-1111-1111-1111-111111111111");
    setUpEntityQueryExpectations(1, null);
    setUpGetNetworksByDataCenterExpectations(1, null);
    setUpClusterExpectations(CLUSTER_ID);
    setUpActionExpectations(ActionType.AttachNetworkToCluster, AttachNetworkToClusterParameter.class, new String[] { "ClusterId" }, new Object[] { CLUSTER_ID }, true, true);
    collection.add(model);
}
Also used : Network(org.ovirt.engine.api.model.Network) Test(org.junit.Test)

Example 18 with Network

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

the class BackendClusterNetworksResourceTest method testAddNameSuppliedButNoId.

@Test
public void testAddNameSuppliedButNoId() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    Network model = new Network();
    model.setName("orcus");
    model.setDescription(DESCRIPTIONS[0]);
    setUpEntityQueryExpectations(1, null);
    setUpGetNetworksByDataCenterExpectations(1, null);
    setUpClusterExpectations(CLUSTER_ID);
    setUpActionExpectations(ActionType.AttachNetworkToCluster, AttachNetworkToClusterParameter.class, new String[] { "ClusterId" }, new Object[] { CLUSTER_ID }, true, true);
    collection.add(model);
}
Also used : Network(org.ovirt.engine.api.model.Network) Test(org.junit.Test)

Example 19 with Network

use of org.ovirt.engine.api.model.Network 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 20 with Network

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

the class BackendDataCenterNetworksResourceTest method testAddIncompleteParameters.

@Test
public void testAddIncompleteParameters() throws Exception {
    Network model = new Network();
    setUriInfo(setUpBasicUriExpectations());
    try {
        collection.add(model);
        fail("expected WebApplicationException on incomplete parameters");
    } catch (WebApplicationException wae) {
        verifyIncompleteException(wae, "Network", "add", "name");
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) Network(org.ovirt.engine.api.model.Network) Test(org.junit.Test)

Aggregations

Network (org.ovirt.engine.api.model.Network)45 Test (org.junit.Test)16 WebApplicationException (javax.ws.rs.WebApplicationException)9 Response (javax.ws.rs.core.Response)6 DataCenter (org.ovirt.engine.api.model.DataCenter)6 VnicProfile (org.ovirt.engine.api.model.VnicProfile)5 V3Network (org.ovirt.engine.api.v3.types.V3Network)4 Guid (org.ovirt.engine.core.compat.Guid)4 Networks (org.ovirt.engine.api.model.Networks)3 V3Networks (org.ovirt.engine.api.v3.types.V3Networks)3 V3PortMirroring (org.ovirt.engine.api.v3.types.V3PortMirroring)3 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)3 HostNic (org.ovirt.engine.api.model.HostNic)2 NetworkLabels (org.ovirt.engine.api.model.NetworkLabels)2 Nic (org.ovirt.engine.api.model.Nic)2 ClusterNetworksResource (org.ovirt.engine.api.resource.ClusterNetworksResource)2 NetworkResource (org.ovirt.engine.api.resource.NetworkResource)2 NetworksResource (org.ovirt.engine.api.resource.NetworksResource)2 SystemResource (org.ovirt.engine.api.resource.SystemResource)2 VnicProfileResource (org.ovirt.engine.api.resource.VnicProfileResource)2