Search in sources :

Example 1 with CreateUpdateContainerOptions

use of org.openstack4j.model.storage.object.options.CreateUpdateContainerOptions in project camel by apache.

the class ContainerProducerTest method createTestWithOptions.

@Test
public void createTestWithOptions() throws Exception {
    when(containerService.create(anyString(), any(CreateUpdateContainerOptions.class))).thenReturn(ActionResponse.actionSuccess());
    msg.setHeader(OpenstackConstants.OPERATION, OpenstackConstants.CREATE);
    msg.setHeader(SwiftConstants.CONTAINER_NAME, CONTAINER_NAME);
    final CreateUpdateContainerOptions options = CreateUpdateContainerOptions.create().accessAnybodyRead();
    msg.setBody(options);
    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());
    assertEquals(options, optionsCaptor.getValue());
    assertFalse(msg.isFault());
}
Also used : CreateUpdateContainerOptions(org.openstack4j.model.storage.object.options.CreateUpdateContainerOptions) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 2 with CreateUpdateContainerOptions

use of org.openstack4j.model.storage.object.options.CreateUpdateContainerOptions in project camel by apache.

the class ContainerProducer method doCreate.

private void doCreate(Exchange exchange) {
    final Message msg = exchange.getIn();
    final String name = msg.getHeader(OpenstackConstants.NAME, msg.getHeader(SwiftConstants.CONTAINER_NAME, String.class), String.class);
    ObjectHelper.notEmpty(name, "Container name");
    final CreateUpdateContainerOptions options = messageToCreateUpdateOptions(msg);
    final ActionResponse out = os.objectStorage().containers().create(name, options);
    checkFailure(out, msg, "Create container " + name);
}
Also used : CreateUpdateContainerOptions(org.openstack4j.model.storage.object.options.CreateUpdateContainerOptions) Message(org.apache.camel.Message) ActionResponse(org.openstack4j.model.common.ActionResponse)

Example 3 with CreateUpdateContainerOptions

use of org.openstack4j.model.storage.object.options.CreateUpdateContainerOptions in project camel by apache.

the class ContainerProducer method doUpdate.

private void doUpdate(Exchange exchange) {
    final Message msg = exchange.getIn();
    final String name = msg.getHeader(OpenstackConstants.NAME, msg.getHeader(SwiftConstants.CONTAINER_NAME, String.class), String.class);
    ObjectHelper.notEmpty(name, "Container name");
    final CreateUpdateContainerOptions options = messageToCreateUpdateOptions(msg);
    final ActionResponse out = os.objectStorage().containers().update(name, options);
    checkFailure(out, msg, "Update container " + name);
}
Also used : CreateUpdateContainerOptions(org.openstack4j.model.storage.object.options.CreateUpdateContainerOptions) Message(org.apache.camel.Message) ActionResponse(org.openstack4j.model.common.ActionResponse)

Aggregations

CreateUpdateContainerOptions (org.openstack4j.model.storage.object.options.CreateUpdateContainerOptions)3 Message (org.apache.camel.Message)2 ActionResponse (org.openstack4j.model.common.ActionResponse)2 Test (org.junit.Test)1 Matchers.anyString (org.mockito.Matchers.anyString)1