@Test public void testConvertSize() { Size size = Size.create("2gb", true, 1.0f, 10f, 0.05f, 2048, 1, 20, ImmutableList.<String> of()); Hardware expected = new HardwareBuilder().id("2gb").providerId("2gb").name("2gb") .processor(new Processor(1.0, 1.0)).ram(2048) .volume(new VolumeBuilder().size(20f).type(Type.LOCAL).build()) .userMetadata(ImmutableMap.of("costPerHour", "0.05", "costPerMonth", "10")).build(); SizeToHardware function = new SizeToHardware(); assertEquals(function.apply(size), expected); }
@Override public Hardware apply(Size input) { HardwareBuilder builder = new HardwareBuilder(); builder.id(input.slug()); builder.providerId(input.slug()); builder.name(input.slug()); builder.ram(input.memory()); builder.processor(new Processor(input.vcpus(), input.vcpus())); builder.volume(new VolumeBuilder() .size(Float.valueOf(input.disk())) .type(Type.LOCAL) .build()); ImmutableMap.Builder<String, String> metadata = ImmutableMap.builder(); metadata.put("costPerHour", String.valueOf(input.priceHourly())); metadata.put("costPerMonth", String.valueOf(input.priceMonthly())); builder.userMetadata(metadata.build()); return builder.build(); }
SizeToHardware implements Function<Size, Hardware> { @Override public Hardware apply(Size input) { HardwareBuilder builder = new HardwareBuilder(); builder.id(input.slug()); builder.providerId(input.slug()); builder.name(input.slug()); builder.ram(input.memory()); builder.processor(new Processor(input.vcpus(), input.vcpus())); builder.volume(new VolumeBuilder() .size(Float.valueOf(input.disk())) .type(Type.LOCAL) .build()); ImmutableMap.Builder<String, String> metadata = ImmutableMap.builder(); metadata.put("costPerHour", String.valueOf(input.priceHourly())); metadata.put("costPerMonth", String.valueOf(input.priceMonthly())); builder.userMetadata(metadata.build()); return builder.build(); } }
SizeToHardware implements Function<Size, Hardware> { @Override public Hardware apply(Size input) { HardwareBuilder builder = new HardwareBuilder(); builder.id(input.slug()); builder.providerId(input.slug()); builder.name(input.slug()); builder.ram(input.memory()); builder.processor(new Processor(input.vcpus(), input.vcpus())); builder.volume(new VolumeBuilder() .size(Float.valueOf(input.disk())) .type(Type.LOCAL) .build()); ImmutableMap.Builder<String, String> metadata = ImmutableMap.builder(); metadata.put("costPerHour", String.valueOf(input.priceHourly())); metadata.put("costPerMonth", String.valueOf(input.priceMonthly())); builder.userMetadata(metadata.build()); return builder.build(); }  }
SizeToHardware implements Function<Size, Hardware> { @Override public Hardware apply(Size input) { HardwareBuilder builder = new HardwareBuilder(); builder.id(input.slug()); builder.providerId(input.slug()); builder.name(input.slug()); builder.ram(input.memory()); builder.processor(new Processor(input.vcpus(), input.vcpus())); builder.volume(new VolumeBuilder() .size(Float.valueOf(input.disk())) .type(Type.LOCAL) .build()); ImmutableMap.Builder<String, String> metadata = ImmutableMap.builder(); metadata.put("costPerHour", String.valueOf(input.priceHourly())); metadata.put("costPerMonth", String.valueOf(input.priceMonthly())); builder.userMetadata(metadata.build()); return builder.build(); }  @Override Hardware apply(Size input); }
SizeToHardware implements Function<Size, Hardware> { @Override public Hardware apply(Size input) { HardwareBuilder builder = new HardwareBuilder(); builder.id(input.slug()); builder.providerId(input.slug()); builder.name(input.slug()); builder.ram(input.memory()); builder.processor(new Processor(input.vcpus(), input.vcpus())); builder.volume(new VolumeBuilder() .size(Float.valueOf(input.disk())) .type(Type.LOCAL) .build()); ImmutableMap.Builder<String, String> metadata = ImmutableMap.builder(); metadata.put("costPerHour", String.valueOf(input.priceHourly())); metadata.put("costPerMonth", String.valueOf(input.priceMonthly())); builder.userMetadata(metadata.build()); return builder.build(); }  @Override Hardware apply(Size input);  }