Search in sources :

Example 11 with Image

use of org.openstack4j.model.image.Image in project wildfly-camel by wildfly-extras.

the class OpenstackIntegrationTest method reserveGlanceImage.

@Test
public void reserveGlanceImage() throws Exception {
    CamelContext camelContext = Mockito.mock(CamelContext.class);
    when(camelContext.getHeadersMapFactory()).thenReturn(new DefaultHeadersMapFactory());
    GlanceEndpoint endpoint = Mockito.mock(GlanceEndpoint.class);
    when(endpoint.getOperation()).thenReturn(GlanceConstants.RESERVE);
    Message msg = new DefaultMessage(camelContext);
    msg.setBody(dummyImage);
    Exchange exchange = Mockito.mock(Exchange.class);
    when(exchange.getIn()).thenReturn(msg);
    Producer producer = new GlanceProducer(endpoint, client);
    producer.process(exchange);
    ArgumentCaptor<Image> captor = ArgumentCaptor.forClass(Image.class);
    verify(imageService).reserve(captor.capture());
    assertEquals(dummyImage, captor.getValue());
    Image result = msg.getBody(Image.class);
    assertNotNull(result.getId());
    assertEqualsImages(dummyImage, result);
}
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) 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) DefaultHeadersMapFactory(org.apache.camel.impl.DefaultHeadersMapFactory) GlanceProducer(org.apache.camel.component.openstack.glance.GlanceProducer) Image(org.openstack4j.model.image.Image) GlanceImage(org.openstack4j.openstack.image.domain.GlanceImage) GlanceEndpoint(org.apache.camel.component.openstack.glance.GlanceEndpoint) Test(org.junit.Test)

Aggregations

Image (org.openstack4j.model.image.Image)11 Test (org.junit.Test)6 GlanceImage (org.openstack4j.openstack.image.domain.GlanceImage)6 Message (org.apache.camel.Message)5 Payload (org.openstack4j.model.common.Payload)5 File (java.io.File)2 Matchers.anyString (org.mockito.Matchers.anyString)2 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 CamelContext (org.apache.camel.CamelContext)1 Exchange (org.apache.camel.Exchange)1 Producer (org.apache.camel.Producer)1 VolumeProducer (org.apache.camel.component.openstack.cinder.producer.VolumeProducer)1 GlanceEndpoint (org.apache.camel.component.openstack.glance.GlanceEndpoint)1 GlanceProducer (org.apache.camel.component.openstack.glance.GlanceProducer)1 ProjectProducer (org.apache.camel.component.openstack.keystone.producer.ProjectProducer)1 NetworkProducer (org.apache.camel.component.openstack.neutron.producer.NetworkProducer)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