RegionUtils { public static Region convertLocationId2Region(final String locationId) { String regionString = locationId.replaceAll("-", "_").toUpperCase(); Regions regionEnum = Regions.valueOf(regionString); Region region = Region.getRegion(regionEnum); return region; } private  RegionUtils(); static Region convertAvailabilityZone2Region(final String availabilityZone); static Region convertLocationId2Region(final String locationId); static String convertAvailabilityZone2LocationId(final String availabilityZone);  }
@Test public void testConvertLocationId2Region() throws Exception { String locationId = "eu-west-1"; Region result = RegionUtils.convertLocationId2Region(locationId); assertThat(result, is(Region.getRegion(Regions.EU_WEST_1))); }
@Test(expected = IllegalArgumentException.class) public void testConvertLocationId2RegionShouldFails() throws Exception { String locationId = "eu-west-1a"; Region result = RegionUtils.convertLocationId2Region(locationId); assertThat(result, is(Region.getRegion(Regions.EU_WEST_1))); }