use of org.apache.camel.component.openstack.swift.producer.ContainerProducer 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());
}
Aggregations