use of org.apache.camel.impl.DefaultHeadersMapFactory in project wildfly-camel by wildfly-extras.
the class OpenstackIntegrationTest method createSwiftContainer.
@Test
public void createSwiftContainer() 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);
when(containerService.create(anyString(), nullable(CreateUpdateContainerOptions.class))).thenReturn(actionResponse);
when(actionResponse.isSuccess()).thenReturn(true);
SwiftEndpoint endpoint = Mockito.mock(SwiftEndpoint.class);
Producer producer = new ContainerProducer(endpoint, client);
msg.setHeader(OpenstackConstants.OPERATION, OpenstackConstants.CREATE);
msg.setHeader(SwiftConstants.CONTAINER_NAME, CONTAINER_NAME);
producer.process(exchange);
ArgumentCaptor<String> containerNameCaptor = ArgumentCaptor.forClass(String.class);
ArgumentCaptor<CreateUpdateContainerOptions> optionsCaptor = ArgumentCaptor.forClass(CreateUpdateContainerOptions.class);
verify(containerService).create(containerNameCaptor.capture(), optionsCaptor.capture());
assertEquals(CONTAINER_NAME, containerNameCaptor.getValue());
assertNull(optionsCaptor.getValue());
assertFalse(msg.isFault());
}
use of org.apache.camel.impl.DefaultHeadersMapFactory 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());
}
use of org.apache.camel.impl.DefaultHeadersMapFactory in project wildfly-camel by wildfly-extras.
the class OpenstackIntegrationTest method testNovaKeypair.
@Test
public void testNovaKeypair() throws Exception {
when(osTestKeypair.getName()).thenReturn(KEYPAIR_NAME);
when(osTestKeypair.getPublicKey()).thenReturn(dummyKeypair.getPublicKey());
when(osTestKeypair.getFingerprint()).thenReturn("fp");
when(osTestKeypair.getPrivateKey()).thenReturn("prk");
CamelContext camelContext = Mockito.mock(CamelContext.class);
when(camelContext.getHeadersMapFactory()).thenReturn(new DefaultHeadersMapFactory());
Message msg = new DefaultMessage(camelContext);
msg.setHeader(OpenstackConstants.OPERATION, OpenstackConstants.CREATE);
msg.setHeader(OpenstackConstants.NAME, KEYPAIR_NAME);
Exchange exchange = Mockito.mock(Exchange.class);
when(exchange.getIn()).thenReturn(msg);
NovaEndpoint endpoint = Mockito.mock(NovaEndpoint.class);
Producer producer = new KeypairProducer(endpoint, client);
producer.process(exchange);
ArgumentCaptor<String> nameCaptor = ArgumentCaptor.forClass(String.class);
ArgumentCaptor<String> keypairCaptor = ArgumentCaptor.forClass(String.class);
verify(keypairService).create(nameCaptor.capture(), keypairCaptor.capture());
assertEquals(KEYPAIR_NAME, nameCaptor.getValue());
assertNull(keypairCaptor.getValue());
Keypair result = msg.getBody(Keypair.class);
assertEquals("fp", result.getFingerprint());
assertEquals("prk", result.getPrivateKey());
assertEquals(dummyKeypair.getName(), result.getName());
assertEquals(dummyKeypair.getPublicKey(), result.getPublicKey());
}
use of org.apache.camel.impl.DefaultHeadersMapFactory in project wildfly-camel by wildfly-extras.
the class OpenstackIntegrationTest method createCinderVolume.
@Test
public void createCinderVolume() 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);
CinderEndpoint endpoint = Mockito.mock(CinderEndpoint.class);
when(endpoint.getOperation()).thenReturn(OpenstackConstants.CREATE);
msg.setBody(dummyVolume);
Producer producer = new VolumeProducer(endpoint, client);
producer.process(exchange);
assertEqualVolumes(dummyVolume, msg.getBody(Volume.class));
}
use of org.apache.camel.impl.DefaultHeadersMapFactory in project wildfly-camel by wildfly-extras.
the class OpenstackIntegrationTest method createKeystoneProject.
@Test
public void createKeystoneProject() 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, dummyProject.getName());
msg.setHeader(KeystoneConstants.DESCRIPTION, dummyProject.getDescription());
msg.setHeader(KeystoneConstants.DOMAIN_ID, dummyProject.getDomainId());
msg.setHeader(KeystoneConstants.PARENT_ID, dummyProject.getParentId());
KeystoneEndpoint endpoint = Mockito.mock(KeystoneEndpoint.class);
Producer producer = new ProjectProducer(endpoint, client);
producer.process(exchange);
ArgumentCaptor<Project> captor = ArgumentCaptor.forClass(Project.class);
verify(projectService).create(captor.capture());
assertEqualsProject(dummyProject, captor.getValue());
}
Aggregations