@Test public void testImageDescriptionParsing() { org.jclouds.profitbricks.domain.Image image1 = org.jclouds.profitbricks.domain.Image.builder() .id("f4742db0-9160-11e4-9d74-52540066fee9") .name("Fedora-19-server-2015-01-01") .size(2048f) .type(org.jclouds.profitbricks.domain.Image.Type.HDD) .location(US_LAS) .osType(OsType.LINUX) .build(); Image actual1 = fnImage.apply(image1); Image expected1 = new ImageBuilder() .ids(image1.id()) .name(image1.name()) .location(location) .status(Image.Status.AVAILABLE) .operatingSystem(OperatingSystem.builder() .description("FEDORA") .family(OsFamily.FEDORA) .version("7") .is64Bit(true) .build()) .userMetadata(ImmutableMap.of("provisionableType", "image")) .build(); assertEquals(actual1, expected1); org.jclouds.profitbricks.domain.Image image2 = org.jclouds.profitbricks.domain.Image.builder() .id("457bf707-d5d1-11e3-8b4f-52540066fee9") .name("clearos-community-6.5.0-x86_64.iso") .size(2048f) .type(org.jclouds.profitbricks.domain.Image.Type.CDROM) .location(US_LAS) .osType(OsType.LINUX) .build(); Image actual2 = fnImage.apply(image2); Image expected2 = new ImageBuilder() .ids(image2.id()) .name(image2.name()) .location(location) .status(Image.Status.AVAILABLE) .operatingSystem(OperatingSystem.builder() .description("UNRECOGNIZED") .family(OsFamily.UNRECOGNIZED) .version("6.5.0") .is64Bit(true) .build()) .userMetadata(ImmutableMap.of("provisionableType", "image")) .build(); assertEquals(actual2, expected2); org.jclouds.profitbricks.domain.Image image3 = org.jclouds.profitbricks.domain.Image.builder() .id("e54af701-53b8-11e3-8f17-52540066fee9") .name("windows-2008-r2-server-setup.iso") .size(2048f) .type(org.jclouds.profitbricks.domain.Image.Type.CDROM) .location(US_LAS) .osType(OsType.WINDOWS) .build(); Image actual3 = fnImage.apply(image3); Image expected3 = new ImageBuilder() .ids(image3.id()) .name(image3.name()) .location(location) .status(Image.Status.AVAILABLE) .operatingSystem(OperatingSystem.builder() .description("WINDOWS") .family(OsFamily.WINDOWS) .version("2008") .is64Bit(false) .build()) .userMetadata(ImmutableMap.of("provisionableType", "image")) .build(); assertEquals(actual3, expected3); }
@Override public Image apply(Provisionable input) { checkNotNull(input, "Cannot convert null input"); if (input instanceof org.jclouds.profitbricks.domain.Image) return fnImageToImage.apply((org.jclouds.profitbricks.domain.Image) input); else if (input instanceof Snapshot) return fnSnapshotToImage.apply((Snapshot) input); else throw new UnsupportedOperationException("No implementation found for provisionable of concrete type '" + input.getClass().getCanonicalName() + "'"); }
ProvisionableToImage implements Function<Provisionable, Image> { @Override public Image apply(Provisionable input) { checkNotNull(input, "Cannot convert null input"); if (input instanceof org.jclouds.profitbricks.domain.Image) return fnImageToImage.apply((org.jclouds.profitbricks.domain.Image) input); else if (input instanceof Snapshot) return fnSnapshotToImage.apply((Snapshot) input); else throw new UnsupportedOperationException("No implementation found for provisionable of concrete type '" + input.getClass().getCanonicalName() + "'"); } }
ProvisionableToImage implements Function<Provisionable, Image> { @Override public Image apply(Provisionable input) { checkNotNull(input, "Cannot convert null input"); if (input instanceof org.jclouds.profitbricks.domain.Image) return fnImageToImage.apply((org.jclouds.profitbricks.domain.Image) input); else if (input instanceof Snapshot) return fnSnapshotToImage.apply((Snapshot) input); else throw new UnsupportedOperationException("No implementation found for provisionable of concrete type '" + input.getClass().getCanonicalName() + "'"); } @Inject  ProvisionableToImage(@Memoized Supplier<Set<? extends Location>> locations); }
ProvisionableToImage implements Function<Provisionable, Image> { @Override public Image apply(Provisionable input) { checkNotNull(input, "Cannot convert null input"); if (input instanceof org.jclouds.profitbricks.domain.Image) return fnImageToImage.apply((org.jclouds.profitbricks.domain.Image) input); else if (input instanceof Snapshot) return fnSnapshotToImage.apply((Snapshot) input); else throw new UnsupportedOperationException("No implementation found for provisionable of concrete type '" + input.getClass().getCanonicalName() + "'"); } @Inject  ProvisionableToImage(@Memoized Supplier<Set<? extends Location>> locations); @Override Image apply(Provisionable input); }
ProvisionableToImage implements Function<Provisionable, Image> { @Override public Image apply(Provisionable input) { checkNotNull(input, "Cannot convert null input"); if (input instanceof org.jclouds.profitbricks.domain.Image) return fnImageToImage.apply((org.jclouds.profitbricks.domain.Image) input); else if (input instanceof Snapshot) return fnSnapshotToImage.apply((Snapshot) input); else throw new UnsupportedOperationException("No implementation found for provisionable of concrete type '" + input.getClass().getCanonicalName() + "'"); } @Inject  ProvisionableToImage(@Memoized Supplier<Set<? extends Location>> locations); @Override Image apply(Provisionable input); static final String KEY_PROVISIONABLE_TYPE; }