Search in sources :

Example 1 with ZoneService

use of org.openstack4j.api.compute.ext.ZoneService in project cloudbreak by hortonworks.

the class OpenStackClientTest method testGetZones.

@Test
public void testGetZones() {
    OSClient<?> osClient = mock(OSClient.class);
    ComputeService computeService = mock(ComputeService.class);
    ZoneService zoneService = mock(ZoneService.class);
    List availabilityZones = newArrayList(availabilityZone("zone1"));
    when(osClient.compute()).thenReturn(computeService);
    when(computeService.zones()).thenReturn(zoneService);
    when(zoneService.list()).thenReturn(availabilityZones);
    List<AvailabilityZone> actual = underTest.getZones(osClient, "region");
    Assert.assertEquals(1, actual.size());
    Assert.assertEquals("zone1", actual.get(0).value());
}
Also used : ZoneService(org.openstack4j.api.compute.ext.ZoneService) AvailabilityZone(com.sequenceiq.cloudbreak.cloud.model.AvailabilityZone) List(java.util.List) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ComputeService(org.openstack4j.api.compute.ComputeService) Test(org.junit.Test)

Example 2 with ZoneService

use of org.openstack4j.api.compute.ext.ZoneService in project cloudbreak by hortonworks.

the class OpenStackClientTest method testGetZonesWhenAvailabiltyZonesEmpt.

@Test
public void testGetZonesWhenAvailabiltyZonesEmpt() {
    OSClient<?> osClient = mock(OSClient.class);
    ComputeService computeService = mock(ComputeService.class);
    ZoneService zoneService = mock(ZoneService.class);
    when(osClient.compute()).thenReturn(computeService);
    when(computeService.zones()).thenReturn(zoneService);
    when(zoneService.list()).thenReturn(Collections.emptyList());
    List<AvailabilityZone> actual = underTest.getZones(osClient, "region");
    Assert.assertEquals(0, actual.size());
}
Also used : ZoneService(org.openstack4j.api.compute.ext.ZoneService) AvailabilityZone(com.sequenceiq.cloudbreak.cloud.model.AvailabilityZone) ComputeService(org.openstack4j.api.compute.ComputeService) Test(org.junit.Test)

Aggregations

AvailabilityZone (com.sequenceiq.cloudbreak.cloud.model.AvailabilityZone)2 Test (org.junit.Test)2 ComputeService (org.openstack4j.api.compute.ComputeService)2 ZoneService (org.openstack4j.api.compute.ext.ZoneService)2 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 List (java.util.List)1