@Test public void testSnapshotToImage() { Calendar calendar = Calendar.getInstance(); calendar.set(2015, 4, 13); Date date = calendar.getTime(); Snapshot snapshot1 = Snapshot.builder() .isBootable(true) .isCpuHotPlug(true) .isCpuHotUnPlug(false) .isDiscVirtioHotPlug(true) .isDiscVirtioHotUnPlug(true) .id("qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh") .name("placeholder-snapshot-04/13/2015") .description("Created from \"placeholder\" in Data Center \"sbx-computeservice\"") .size(2048f) .location(US_LAS) .isNicHotPlug(true) .isNicHotUnPlug(true) .osType(OsType.LINUX) .isRamHotPlug(true) .isRamHotUnPlug(false) .creationTime(date) .lastModificationTime(new Date()) .state(ProvisioningState.AVAILABLE) .build(); Image actual1 = fnImage.apply(snapshot1); Image expected1 = new ImageBuilder() .ids(snapshot1.id()) .name(snapshot1.name()) .location(location) .status(Image.Status.AVAILABLE) .operatingSystem(OperatingSystem.builder() .description(snapshot1.description()) .family(OsFamily.LINUX) .is64Bit(true) .build()) .userMetadata(ImmutableMap.of("provisionableType", "snapshot")) .build(); assertEquals(actual1, expected1); Snapshot snapshot2 = Snapshot.builder() .isBootable(true) .isCpuHotPlug(true) .isCpuHotUnPlug(false) .isDiscVirtioHotPlug(true) .isDiscVirtioHotUnPlug(true) .id("d80bf9c0-ce6e-4283-9ea4-2906635f6137") .name("jclouds-ubuntu14.10-template") .description("Created from \"jclouds-ubuntu14.10 Storage\" in Data Center \"jclouds-computeservice\"") .size(10240f) .location(US_LAS) .isNicHotPlug(true) .isNicHotUnPlug(true) .osType(OsType.LINUX) .isRamHotPlug(true) .isRamHotUnPlug(false) .creationTime(date) .lastModificationTime(new Date()) .state(ProvisioningState.INPROCESS) .build(); Image actual2 = fnImage.apply(snapshot2); Image expected2 = new ImageBuilder() .ids(snapshot2.id()) .name(snapshot2.name()) .location(location) .status(Image.Status.PENDING) .operatingSystem(OperatingSystem.builder() .description("ubuntu") .family(OsFamily.UBUNTU) .is64Bit(true) .version("00.00") .build()) .userMetadata(ImmutableMap.of("provisionableType", "snapshot")) .build(); assertEquals(actual2, expected2); assertEquals(actual2.getOperatingSystem(), expected2.getOperatingSystem()); }
@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; }