Openstack { public @Nonnull List<? extends AvailabilityZone> getAvailabilityZones() { final List<? extends AvailabilityZone> zones = clientProvider.get().compute().zones().list(); zones.sort(AVAILABILITY_ZONES_COMPARATOR); return zones; } private  Openstack(@Nonnull String endPointUrl, boolean ignoreSsl, @Nonnull OpenstackCredential auth, @CheckForNull String region);  Openstack(@Nonnull final OSClient<?> client); static @Nonnull String getFlavorInfo(@Nonnull Flavor f); @Nonnull String getInfo(); @VisibleForTesting @Nonnull List<? extends Network> _listNetworks(); @Nonnull Map<String, Network> getNetworks(@Nonnull List<String> nameOrIds); @Nonnull Map<Network, Integer> getNetworksCapacity(@Nonnull Map<String, Network> declaredNetworks); @Nonnull Map<String, List<Image>> getImages(); @Nonnull Map<String, List<VolumeSnapshot>> getVolumeSnapshots(); @Nonnull Collection<? extends Flavor> getSortedFlavors(); @Nonnull List<String> getSortedIpPools(); @Nonnull List<? extends AvailabilityZone> getAvailabilityZones(); @Nonnull List<Server> getRunningNodes(); @Nonnull List<String> getFreeFipIds(); @Nonnull List<String> getSortedKeyPairNames(); @Nonnull List<String> getImageIdsFor(String nameOrId); @Nonnull List<String> getVolumeSnapshotIdsFor(String nameOrId); @CheckForNull String getVolumeSnapshotDescription(String volumeSnapshotId); void setVolumeNameAndDescription(String volumeId, String newVolumeName, String newVolumeDescription); static boolean isOccupied(@Nonnull Server server); @Nonnull Server getServerById(@Nonnull String id); @Nonnull List<Server> getServersByName(@Nonnull String name); @Nonnull Server bootAndWaitActive(@Nonnull ServerCreateBuilder request, @Nonnegative int timeout); @Restricted(NoExternalUse.class) // Test hook Server _bootAndWaitActive(@Nonnull ServerCreateBuilder request, @Nonnegative int timeout); @Nonnull Server updateInfo(@Nonnull Server server); void destroyServer(@Nonnull Server server); @Nonnull NetFloatingIP assignFloatingIp(@Nonnull Server server, @Nonnull String poolName); void destroyFip(String fip); static @CheckForNull String getAccessIpAddress(@Nonnull Server server); @SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT") @CheckForNull Throwable sanityCheck(); static final String FINGERPRINT_KEY; }
@Test public void getAvailabilityZonesReturnsAZsSortedByName() { final AvailabilityZone mockAZ1 = mock(AvailabilityZone.class); when(mockAZ1.getZoneName()).thenReturn("Foo"); final AvailabilityZone mockAZ2 = mock(AvailabilityZone.class); when(mockAZ2.getZoneName()).thenReturn("Bar"); final AvailabilityZone mockAZ3 = mock(AvailabilityZone.class); when(mockAZ3.getZoneName()).thenReturn("Flibble"); final ZoneService mockZS = mock(ZoneService.class); doReturn(Arrays.asList(mockAZ1, mockAZ2, mockAZ3)).when(mockZS).list(); final OSClient mockClient = mock(OSClient.class, RETURNS_DEEP_STUBS); when(mockClient.compute().zones()).thenReturn(mockZS); final ArrayList<AvailabilityZone> expected = new ArrayList<>(Arrays.asList(mockAZ2, mockAZ3, mockAZ1)); final Openstack instance = new Openstack(mockClient); final List<? extends AvailabilityZone> actual = instance.getAvailabilityZones(); assertThat(new ArrayList<>(actual), equalTo(expected)); }