@Test public void testRegionsShouldReturnTheEnabledRegionsWhenAzureResponseContainsUnsupportedRegions() { Collection<Region> azureRegions = getAzureRegionsWithUnsupportedRegion(); Collection<Region> supportedAzureRegions = getAzureRegions(); CloudRegions actual = underTest.regions(null, azureRegions); assertRegionNames(actual, supportedAzureRegions); Assert.assertEquals("North Europe", actual.getDefaultRegion()); }
public CloudRegions regions(Region region, Collection<com.microsoft.azure.management.resources.fluentcore.arm.Region> azureRegions) { Map<Region, List<AvailabilityZone>> cloudRegions = new HashMap<>(); Map<Region, String> displayNames = new HashMap<>(); Map<Region, Coordinate> coordinates = new HashMap<>(); String defaultRegion = armZoneParameterDefault; azureRegions = filterByEnabledRegions(azureRegions); for (com.microsoft.azure.management.resources.fluentcore.arm.Region azureRegion : azureRegions) { cloudRegions.put(region(azureRegion.label()), new ArrayList<>()); displayNames.put(region(azureRegion.label()), azureRegion.label()); Coordinate coordinate = enabledRegions.get(region(azureRegion.label())); if (coordinate == null || coordinate.getLongitude() == null || coordinate.getLatitude() == null) { LOGGER.warn("Unregistered region with location coordinates on azure side: {} using default California", azureRegion.label()); coordinates.put(region(azureRegion.label()), Coordinate.defaultCoordinate()); } else { coordinates.put(region(azureRegion.label()), coordinate); } } if (region != null && !Strings.isNullOrEmpty(region.value())) { defaultRegion = region.value(); } return new CloudRegions(cloudRegions, displayNames, coordinates, defaultRegion, true); }
AzureRegionProvider { public CloudRegions regions(Region region, Collection<com.microsoft.azure.management.resources.fluentcore.arm.Region> azureRegions) { Map<Region, List<AvailabilityZone>> cloudRegions = new HashMap<>(); Map<Region, String> displayNames = new HashMap<>(); Map<Region, Coordinate> coordinates = new HashMap<>(); String defaultRegion = armZoneParameterDefault; azureRegions = filterByEnabledRegions(azureRegions); for (com.microsoft.azure.management.resources.fluentcore.arm.Region azureRegion : azureRegions) { cloudRegions.put(region(azureRegion.label()), new ArrayList<>()); displayNames.put(region(azureRegion.label()), azureRegion.label()); Coordinate coordinate = enabledRegions.get(region(azureRegion.label())); if (coordinate == null || coordinate.getLongitude() == null || coordinate.getLatitude() == null) { LOGGER.warn("Unregistered region with location coordinates on azure side: {} using default California", azureRegion.label()); coordinates.put(region(azureRegion.label()), Coordinate.defaultCoordinate()); } else { coordinates.put(region(azureRegion.label()), coordinate); } } if (region != null && !Strings.isNullOrEmpty(region.value())) { defaultRegion = region.value(); } return new CloudRegions(cloudRegions, displayNames, coordinates, defaultRegion, true); } }
AzureRegionProvider { public CloudRegions regions(Region region, Collection<com.microsoft.azure.management.resources.fluentcore.arm.Region> azureRegions) { Map<Region, List<AvailabilityZone>> cloudRegions = new HashMap<>(); Map<Region, String> displayNames = new HashMap<>(); Map<Region, Coordinate> coordinates = new HashMap<>(); String defaultRegion = armZoneParameterDefault; azureRegions = filterByEnabledRegions(azureRegions); for (com.microsoft.azure.management.resources.fluentcore.arm.Region azureRegion : azureRegions) { cloudRegions.put(region(azureRegion.label()), new ArrayList<>()); displayNames.put(region(azureRegion.label()), azureRegion.label()); Coordinate coordinate = enabledRegions.get(region(azureRegion.label())); if (coordinate == null || coordinate.getLongitude() == null || coordinate.getLatitude() == null) { LOGGER.warn("Unregistered region with location coordinates on azure side: {} using default California", azureRegion.label()); coordinates.put(region(azureRegion.label()), Coordinate.defaultCoordinate()); } else { coordinates.put(region(azureRegion.label()), coordinate); } } if (region != null && !Strings.isNullOrEmpty(region.value())) { defaultRegion = region.value(); } return new CloudRegions(cloudRegions, displayNames, coordinates, defaultRegion, true); }  }
AzureRegionProvider { public CloudRegions regions(Region region, Collection<com.microsoft.azure.management.resources.fluentcore.arm.Region> azureRegions) { Map<Region, List<AvailabilityZone>> cloudRegions = new HashMap<>(); Map<Region, String> displayNames = new HashMap<>(); Map<Region, Coordinate> coordinates = new HashMap<>(); String defaultRegion = armZoneParameterDefault; azureRegions = filterByEnabledRegions(azureRegions); for (com.microsoft.azure.management.resources.fluentcore.arm.Region azureRegion : azureRegions) { cloudRegions.put(region(azureRegion.label()), new ArrayList<>()); displayNames.put(region(azureRegion.label()), azureRegion.label()); Coordinate coordinate = enabledRegions.get(region(azureRegion.label())); if (coordinate == null || coordinate.getLongitude() == null || coordinate.getLatitude() == null) { LOGGER.warn("Unregistered region with location coordinates on azure side: {} using default California", azureRegion.label()); coordinates.put(region(azureRegion.label()), Coordinate.defaultCoordinate()); } else { coordinates.put(region(azureRegion.label()), coordinate); } } if (region != null && !Strings.isNullOrEmpty(region.value())) { defaultRegion = region.value(); } return new CloudRegions(cloudRegions, displayNames, coordinates, defaultRegion, true); }  @PostConstruct void init(); CloudRegions regions(Region region, Collection<com.microsoft.azure.management.resources.fluentcore.arm.Region> azureRegions); }
AzureRegionProvider { public CloudRegions regions(Region region, Collection<com.microsoft.azure.management.resources.fluentcore.arm.Region> azureRegions) { Map<Region, List<AvailabilityZone>> cloudRegions = new HashMap<>(); Map<Region, String> displayNames = new HashMap<>(); Map<Region, Coordinate> coordinates = new HashMap<>(); String defaultRegion = armZoneParameterDefault; azureRegions = filterByEnabledRegions(azureRegions); for (com.microsoft.azure.management.resources.fluentcore.arm.Region azureRegion : azureRegions) { cloudRegions.put(region(azureRegion.label()), new ArrayList<>()); displayNames.put(region(azureRegion.label()), azureRegion.label()); Coordinate coordinate = enabledRegions.get(region(azureRegion.label())); if (coordinate == null || coordinate.getLongitude() == null || coordinate.getLatitude() == null) { LOGGER.warn("Unregistered region with location coordinates on azure side: {} using default California", azureRegion.label()); coordinates.put(region(azureRegion.label()), Coordinate.defaultCoordinate()); } else { coordinates.put(region(azureRegion.label()), coordinate); } } if (region != null && !Strings.isNullOrEmpty(region.value())) { defaultRegion = region.value(); } return new CloudRegions(cloudRegions, displayNames, coordinates, defaultRegion, true); }  @PostConstruct void init(); CloudRegions regions(Region region, Collection<com.microsoft.azure.management.resources.fluentcore.arm.Region> azureRegions);  }