checkNotNull(operatingSystem, "operatingSystem"); final SoftwareLicense defaultSoftwareLicense = SoftwareLicense.builder().softwareDescription(SoftwareDescription.builder().build()).build(); SoftwareLicense softwareLicense = fromNullable(operatingSystem.getSoftwareLicense()).or(defaultSoftwareLicense); Optional<String> optOSReferenceCode = fromNullable(softwareLicense.getSoftwareDescription().getReferenceCode()); Optional<String> optVersion = fromNullable(softwareLicense.getSoftwareDescription().getVersion());
checkNotNull(operatingSystem, "operatingSystem"); final SoftwareLicense defaultSoftwareLicense = SoftwareLicense.builder().softwareDescription(SoftwareDescription.builder().build()).build(); SoftwareLicense softwareLicense = fromNullable(operatingSystem.getSoftwareLicense()).or(defaultSoftwareLicense); Optional<String> optOSReferenceCode = fromNullable(softwareLicense.getSoftwareDescription().getReferenceCode()); Optional<String> optVersion = fromNullable(softwareLicense.getSoftwareDescription().getVersion());
checkNotNull(operatingSystem, "operatingSystem"); final SoftwareLicense defaultSoftwareLicense = SoftwareLicense.builder().softwareDescription(SoftwareDescription.builder().build()).build(); SoftwareLicense softwareLicense = fromNullable(operatingSystem.getSoftwareLicense()).or(defaultSoftwareLicense); Optional<String> optOSReferenceCode = fromNullable(softwareLicense.getSoftwareDescription().getReferenceCode()); Optional<String> optVersion = fromNullable(softwareLicense.getSoftwareDescription().getVersion());
@Override public Image apply(OperatingSystem operatingSystem) { checkNotNull(operatingSystem, "operatingSystem"); SoftwareLicense softwareLicense = checkNotNull(operatingSystem.getSoftwareLicense(), "softwareLicense"); String operatingSystemReferenceCode = softwareLicense.getSoftwareDescription().getReferenceCode();
.build(); SoftwareLicense softwareLicense = from.getOperatingSystem().getSoftwareLicense(); String referenceCode = softwareLicense.getSoftwareDescription().getReferenceCode();
@Test public void testOperatingSystemToImage() { OperatingSystem operatingSystem = OperatingSystem.builder() .id("UBUNTU_12_64") .softwareLicense(SoftwareLicense.builder() .softwareDescription(SoftwareDescription.builder() .version("12.04-64 Minimal for CCI") .referenceCode("UBUNTU_12_64") .longDescription("Ubuntu Linux 12.04 LTS Precise Pangolin - Minimal Install (64 bit)") .build()) .build()) .build(); Image image = new OperatingSystemToImage().apply(operatingSystem); assertEquals(image.getId(), operatingSystem.getId()); String referenceCode = operatingSystem.getSoftwareLicense().getSoftwareDescription().getReferenceCode(); assertEquals(image.getDescription(), referenceCode); assertTrue(image.getOperatingSystem().getFamily().toString().equalsIgnoreCase("UBUNTU")); assertEquals(image.getOperatingSystem().getVersion(), "12.04"); assertEquals(image.getOperatingSystem().is64Bit(), true); assertEquals(image.getStatus(), Image.Status.AVAILABLE); }