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