@Test public void testAwsEncryptionConvert() { String encyptionKey = "aKey"; Template template = new Template(); Map<String, String> attributes = Maps.newHashMap(); attributes.put(InstanceTemplate.VOLUME_ENCRYPTION_KEY_ID, encyptionKey); attributes.put(InstanceTemplate.VOLUME_ENCRYPTION_KEY_TYPE, "CUSTOM"); attributes.put("cloudPlatform", "AWS"); template.setAttributes(new Json(attributes)); template.setVolumeTemplates(Sets.newHashSet()); template.setCloudPlatform("AWS"); InstanceTemplateV4Response response = underTest.convert(template); assertEquals(response.getAws().getEncryption().getType(), EncryptionType.CUSTOM); assertEquals(response.getAws().getEncryption().getKey(), encyptionKey); }
@Override public InstanceTemplateV4Response convert(Template source) { InstanceTemplateV4Response response = new InstanceTemplateV4Response(); response.setId(source.getId()); response.setRootVolume(rootVolume(source)); response.setAttachedVolumes(source.getVolumeTemplates().stream() .map(volume -> getConversionService().convert(volume, VolumeV4Response.class)) .collect(Collectors.toSet())); response.setInstanceType(source.getInstanceType()); Json attributes = source.getAttributes(); if (attributes != null) { Map<String, Object> parameters = attributes.getMap(); ofNullable(source.getSecretAttributes()).ifPresent(attr -> parameters.putAll(new Json(attr).getMap())); providerParameterCalculator.parse(parameters, response); } response.setCloudPlatform(CloudPlatform.valueOf(source.cloudPlatform())); return response; }
TemplateToInstanceTemplateV4ResponseConverter extends AbstractConversionServiceAwareConverter<Template, InstanceTemplateV4Response> { @Override public InstanceTemplateV4Response convert(Template source) { InstanceTemplateV4Response response = new InstanceTemplateV4Response(); response.setId(source.getId()); response.setRootVolume(rootVolume(source)); response.setAttachedVolumes(source.getVolumeTemplates().stream() .map(volume -> getConversionService().convert(volume, VolumeV4Response.class)) .collect(Collectors.toSet())); response.setInstanceType(source.getInstanceType()); Json attributes = source.getAttributes(); if (attributes != null) { Map<String, Object> parameters = attributes.getMap(); ofNullable(source.getSecretAttributes()).ifPresent(attr -> parameters.putAll(new Json(attr).getMap())); providerParameterCalculator.parse(parameters, response); } response.setCloudPlatform(CloudPlatform.valueOf(source.cloudPlatform())); return response; } }
TemplateToInstanceTemplateV4ResponseConverter extends AbstractConversionServiceAwareConverter<Template, InstanceTemplateV4Response> { @Override public InstanceTemplateV4Response convert(Template source) { InstanceTemplateV4Response response = new InstanceTemplateV4Response(); response.setId(source.getId()); response.setRootVolume(rootVolume(source)); response.setAttachedVolumes(source.getVolumeTemplates().stream() .map(volume -> getConversionService().convert(volume, VolumeV4Response.class)) .collect(Collectors.toSet())); response.setInstanceType(source.getInstanceType()); Json attributes = source.getAttributes(); if (attributes != null) { Map<String, Object> parameters = attributes.getMap(); ofNullable(source.getSecretAttributes()).ifPresent(attr -> parameters.putAll(new Json(attr).getMap())); providerParameterCalculator.parse(parameters, response); } response.setCloudPlatform(CloudPlatform.valueOf(source.cloudPlatform())); return response; }  }
TemplateToInstanceTemplateV4ResponseConverter extends AbstractConversionServiceAwareConverter<Template, InstanceTemplateV4Response> { @Override public InstanceTemplateV4Response convert(Template source) { InstanceTemplateV4Response response = new InstanceTemplateV4Response(); response.setId(source.getId()); response.setRootVolume(rootVolume(source)); response.setAttachedVolumes(source.getVolumeTemplates().stream() .map(volume -> getConversionService().convert(volume, VolumeV4Response.class)) .collect(Collectors.toSet())); response.setInstanceType(source.getInstanceType()); Json attributes = source.getAttributes(); if (attributes != null) { Map<String, Object> parameters = attributes.getMap(); ofNullable(source.getSecretAttributes()).ifPresent(attr -> parameters.putAll(new Json(attr).getMap())); providerParameterCalculator.parse(parameters, response); } response.setCloudPlatform(CloudPlatform.valueOf(source.cloudPlatform())); return response; }  @Override InstanceTemplateV4Response convert(Template source); }
TemplateToInstanceTemplateV4ResponseConverter extends AbstractConversionServiceAwareConverter<Template, InstanceTemplateV4Response> { @Override public InstanceTemplateV4Response convert(Template source) { InstanceTemplateV4Response response = new InstanceTemplateV4Response(); response.setId(source.getId()); response.setRootVolume(rootVolume(source)); response.setAttachedVolumes(source.getVolumeTemplates().stream() .map(volume -> getConversionService().convert(volume, VolumeV4Response.class)) .collect(Collectors.toSet())); response.setInstanceType(source.getInstanceType()); Json attributes = source.getAttributes(); if (attributes != null) { Map<String, Object> parameters = attributes.getMap(); ofNullable(source.getSecretAttributes()).ifPresent(attr -> parameters.putAll(new Json(attr).getMap())); providerParameterCalculator.parse(parameters, response); } response.setCloudPlatform(CloudPlatform.valueOf(source.cloudPlatform())); return response; }  @Override InstanceTemplateV4Response convert(Template source);  }