Search in sources :

Example 1 with NetworkProducer

use of org.apache.camel.component.openstack.neutron.producer.NetworkProducer in project camel by apache.

the class NetworkProducerTest method setUp.

@Before
public void setUp() {
    producer = new NetworkProducer(endpoint, client);
    when(networkService.create(any(Network.class))).thenReturn(testOSnetwork);
    when(networkService.get(anyString())).thenReturn(testOSnetwork);
    List<Network> getAllList = new ArrayList<>();
    getAllList.add(testOSnetwork);
    getAllList.add(testOSnetwork);
    doReturn(getAllList).when(networkService).list();
    dummyNetwork = createNetwork();
    when(testOSnetwork.getName()).thenReturn(dummyNetwork.getName());
    when(testOSnetwork.getTenantId()).thenReturn(dummyNetwork.getTenantId());
    when(testOSnetwork.getNetworkType()).thenReturn(dummyNetwork.getNetworkType());
    when(testOSnetwork.getId()).thenReturn(UUID.randomUUID().toString());
}
Also used : Network(org.openstack4j.model.network.Network) ArrayList(java.util.ArrayList) NetworkProducer(org.apache.camel.component.openstack.neutron.producer.NetworkProducer) Before(org.junit.Before)

Example 2 with NetworkProducer

use of org.apache.camel.component.openstack.neutron.producer.NetworkProducer in project wildfly-camel by wildfly-extras.

the class OpenstackIntegrationTest method createNeutronNetwork.

@Test
public void createNeutronNetwork() throws Exception {
    CamelContext camelContext = Mockito.mock(CamelContext.class);
    when(camelContext.getHeadersMapFactory()).thenReturn(new DefaultHeadersMapFactory());
    Message msg = new DefaultMessage(camelContext);
    Exchange exchange = Mockito.mock(Exchange.class);
    when(exchange.getIn()).thenReturn(msg);
    msg.setHeader(OpenstackConstants.OPERATION, OpenstackConstants.CREATE);
    msg.setHeader(OpenstackConstants.NAME, dummyNetwork.getName());
    msg.setHeader(NeutronConstants.NETWORK_TYPE, dummyNetwork.getNetworkType());
    msg.setHeader(NeutronConstants.TENANT_ID, dummyNetwork.getTenantId());
    NeutronEndpoint endpoint = Mockito.mock(NeutronEndpoint.class);
    Producer producer = new NetworkProducer(endpoint, client);
    producer.process(exchange);
    ArgumentCaptor<Network> captor = ArgumentCaptor.forClass(Network.class);
    verify(networkService).create(captor.capture());
    assertEqualsNetwork(dummyNetwork, captor.getValue());
    assertNotNull(msg.getBody(Network.class).getId());
}
Also used : DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) CamelContext(org.apache.camel.CamelContext) DefaultMessage(org.apache.camel.impl.DefaultMessage) Exchange(org.apache.camel.Exchange) Message(org.apache.camel.Message) DefaultMessage(org.apache.camel.impl.DefaultMessage) NeutronEndpoint(org.apache.camel.component.openstack.neutron.NeutronEndpoint) VolumeProducer(org.apache.camel.component.openstack.cinder.producer.VolumeProducer) ProjectProducer(org.apache.camel.component.openstack.keystone.producer.ProjectProducer) ContainerProducer(org.apache.camel.component.openstack.swift.producer.ContainerProducer) GlanceProducer(org.apache.camel.component.openstack.glance.GlanceProducer) KeypairProducer(org.apache.camel.component.openstack.nova.producer.KeypairProducer) Producer(org.apache.camel.Producer) NetworkProducer(org.apache.camel.component.openstack.neutron.producer.NetworkProducer) Network(org.openstack4j.model.network.Network) DefaultHeadersMapFactory(org.apache.camel.impl.DefaultHeadersMapFactory) NetworkProducer(org.apache.camel.component.openstack.neutron.producer.NetworkProducer) Test(org.junit.Test)

Aggregations

NetworkProducer (org.apache.camel.component.openstack.neutron.producer.NetworkProducer)2 Network (org.openstack4j.model.network.Network)2 ArrayList (java.util.ArrayList)1 CamelContext (org.apache.camel.CamelContext)1 Exchange (org.apache.camel.Exchange)1 Message (org.apache.camel.Message)1 Producer (org.apache.camel.Producer)1 VolumeProducer (org.apache.camel.component.openstack.cinder.producer.VolumeProducer)1 GlanceProducer (org.apache.camel.component.openstack.glance.GlanceProducer)1 ProjectProducer (org.apache.camel.component.openstack.keystone.producer.ProjectProducer)1 NeutronEndpoint (org.apache.camel.component.openstack.neutron.NeutronEndpoint)1 KeypairProducer (org.apache.camel.component.openstack.nova.producer.KeypairProducer)1 ContainerProducer (org.apache.camel.component.openstack.swift.producer.ContainerProducer)1 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)1 DefaultHeadersMapFactory (org.apache.camel.impl.DefaultHeadersMapFactory)1 DefaultMessage (org.apache.camel.impl.DefaultMessage)1 Before (org.junit.Before)1 Test (org.junit.Test)1