Search in sources :

Example 6 with Region

use of org.openstack4j.model.identity.v3.Region in project camel by apache.

the class RegionProducerTest method setUp.

@Before
public void setUp() {
    producer = new RegionProducer(endpoint, client);
    when(regionService.create(any(Region.class))).thenReturn(testOSregion);
    when(regionService.get(anyString())).thenReturn(testOSregion);
    List<Region> getAllList = new ArrayList<>();
    getAllList.add(testOSregion);
    getAllList.add(testOSregion);
    doReturn(getAllList).when(regionService).list();
    dummyRegion = createRegion();
    when(testOSregion.getDescription()).thenReturn(dummyRegion.getDescription());
}
Also used : ArrayList(java.util.ArrayList) Region(org.openstack4j.model.identity.v3.Region) RegionProducer(org.apache.camel.component.openstack.keystone.producer.RegionProducer) Before(org.junit.Before)

Example 7 with Region

use of org.openstack4j.model.identity.v3.Region in project camel by apache.

the class RegionProducerTest method updateTest.

@Test
public void updateTest() throws Exception {
    final String id = "myID";
    msg.setHeader(OpenstackConstants.OPERATION, OpenstackConstants.UPDATE);
    when(testOSregion.getId()).thenReturn(id);
    final String newDescription = "ndesc";
    when(testOSregion.getDescription()).thenReturn(newDescription);
    when(regionService.update(any(Region.class))).thenReturn(testOSregion);
    msg.setBody(testOSregion);
    producer.process(exchange);
    ArgumentCaptor<Region> captor = ArgumentCaptor.forClass(Region.class);
    verify(regionService).update(captor.capture());
    assertEqualsRegion(testOSregion, captor.getValue());
    assertNotNull(captor.getValue().getId());
    assertEquals(newDescription, msg.getBody(Region.class).getDescription());
}
Also used : Region(org.openstack4j.model.identity.v3.Region) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

Region (org.openstack4j.model.identity.v3.Region)7 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Message (org.apache.camel.Message)1 RegionProducer (org.apache.camel.component.openstack.keystone.producer.RegionProducer)1 Before (org.junit.Before)1 Test (org.junit.Test)1 Matchers.anyString (org.mockito.Matchers.anyString)1 RegionBuilder (org.openstack4j.model.identity.v3.builder.RegionBuilder)1