### Question:
AWSEC2ReviseParsedImage implements ReviseParsedImage { @Override public void reviseParsedImage(org.jclouds.ec2.domain.Image from, ImageBuilder builder, OsFamily family, OperatingSystem.Builder osBuilder) { try { Matcher matcher = getMatcherAndFind(from.getImageLocation()); if (matcher.pattern() == AMZN_PATTERN) { osBuilder.family(OsFamily.AMZN_LINUX); osBuilder.version(matcher.group(2)); builder.version(matcher.group(2)); } else if (matcher.pattern() == AMAZON_PATTERN) { family = OsFamily.fromValue(matcher.group(1)); osBuilder.family(family); osBuilder.version(ComputeServiceUtils.parseVersionOrReturnEmptyString(family, matcher.group(2), osVersionMap)); } else { family = OsFamily.fromValue(matcher.group(1)); osBuilder.family(family); osBuilder.version(ComputeServiceUtils.parseVersionOrReturnEmptyString(family, matcher.group(2), osVersionMap)); builder.version(matcher.group(3).replace(".manifest.xml", "")); } } catch (IllegalArgumentException e) { logger.debug("<< didn't match os(%s)", from.getImageLocation()); } catch (NoSuchElementException e) { logger.trace("<< didn't match at all(%s)", from.getImageLocation()); } } @Inject  AWSEC2ReviseParsedImage(Map<OsFamily, Map<String, String>> osVersionMap); @Override void reviseParsedImage(org.jclouds.ec2.domain.Image from, ImageBuilder builder, OsFamily family,
            OperatingSystem.Builder osBuilder); static final Pattern AMZN_PATTERN; static final Pattern AMAZON_PATTERN; static final Pattern AMAZON_WINDOWS_PATTERN; static final Pattern CENTOS_MARKETPLACE_PATTERN; static final Pattern CANONICAL_PATTERN; static final Pattern RIGHTSCALE_PATTERN; static final Pattern RIGHTIMAGE_PATTERN; }### Answer:
@Test public void testNewWindowsName() throws Exception { ReviseParsedImage rpi = new AWSEC2ReviseParsedImage(osVersionMap); Image from = newImage("amazon", "Windows_Server-2008-R2_SP1-English-64Bit-Base-2012.03.13"); OperatingSystem.Builder osBuilder = OperatingSystem.builder().description("test"); ImageBuilder builder = new ImageBuilder().id("1").operatingSystem(osBuilder.build()).status( org.jclouds.compute.domain.Image.Status.AVAILABLE).description("test"); OsFamily family = OsFamily.WINDOWS; rpi.reviseParsedImage(from, builder, family, osBuilder); OperatingSystem os = osBuilder.build(); assertEquals(os.getFamily(), OsFamily.WINDOWS); assertEquals(os.getVersion(), "2008"); assertEquals(builder.build().getVersion(), "2012.03.13"); }
@Test public void testOldWindowsName() throws Exception { ReviseParsedImage rpi = new AWSEC2ReviseParsedImage(osVersionMap); Image from = newImage("amazon", "Windows-2008R2-SP1-English-Base-2012.01.12"); OperatingSystem.Builder osBuilder = OperatingSystem.builder().description("test"); ImageBuilder builder = new ImageBuilder().id("1").operatingSystem(osBuilder.build()).status( org.jclouds.compute.domain.Image.Status.AVAILABLE).description("test"); OsFamily family = OsFamily.WINDOWS; rpi.reviseParsedImage(from, builder, family, osBuilder); OperatingSystem os = osBuilder.build(); assertEquals(os.getFamily(), OsFamily.WINDOWS); assertEquals(os.getVersion(), "2008"); assertEquals(builder.build().getVersion(), "2012.01.12"); }