use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request in project cloudbreak by hortonworks.
the class InstanceTemplateV4RequestToTemplateConverterTest method convertWithNullTemporaryStorage.
@Test
public void convertWithNullTemporaryStorage() {
InstanceTemplateV4Request source = getSampleGcpRequest();
source.setTemporaryStorage(null);
Template result = underTest.convert(source);
assertThat(result.getTemporaryStorage()).isEqualTo(TemporaryStorage.ATTACHED_VOLUMES);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request in project cloudbreak by hortonworks.
the class InstanceTemplateV4RequestToTemplateConverterTest method convertWithAwsEncryption.
@Test
public void convertWithAwsEncryption() {
InstanceTemplateV4Request source = getSampleAwsRequest();
Template result = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.convert(source));
assertAwsEncryptionConvertResult(source, result);
assertThat(new Json(result.getSecretAttributes()).getMap().get(InstanceTemplate.VOLUME_ENCRYPTION_KEY_ID)).isEqualTo("myKey");
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request in project cloudbreak by hortonworks.
the class InstanceTemplateV4RequestToTemplateConverterTest method getSampleGcpRequest.
private InstanceTemplateV4Request getSampleGcpRequest() {
InstanceTemplateV4Request source = new InstanceTemplateV4Request();
source.setCloudPlatform(CloudPlatform.GCP);
source.setRootVolume(getRootVolume(100));
source.setInstanceType("n1-standard-4");
GcpInstanceTemplateV4Parameters parameters = new GcpInstanceTemplateV4Parameters();
GcpEncryptionV4Parameters encryption = new GcpEncryptionV4Parameters();
encryption.setType(EncryptionType.CUSTOM);
encryption.setKeyEncryptionMethod(KeyEncryptionMethod.RAW);
encryption.setKey("myKey");
parameters.setEncryption(encryption);
source.setGcp(parameters);
ProviderParameterCalculator providerParameterCalculator = new ProviderParameterCalculator();
ReflectionTestUtils.setField(underTest, "providerParameterCalculator", providerParameterCalculator);
when(missingResourceNameGenerator.generateName(APIResourceType.TEMPLATE)).thenReturn("name");
return source;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request in project cloudbreak by hortonworks.
the class InstanceTemplateV4RequestToTemplateConverterTest method convertWithGcpEncryptionWithNullKey.
@Test
public void convertWithGcpEncryptionWithNullKey() {
InstanceTemplateV4Request source = getSampleGcpRequest();
source.getGcp().getEncryption().setKey(null);
Template result = underTest.convert(source);
assertGcpEncryptionConvertResult(source, result);
assertThat(new Json(result.getSecretAttributes()).getMap().get(InstanceTemplate.VOLUME_ENCRYPTION_KEY_ID)).isNull();
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request in project cloudbreak by hortonworks.
the class InstanceTemplateV4RequestToTemplateConverterTest method convert.
@Test
public void convert() {
InstanceTemplateV4Request source = new InstanceTemplateV4Request();
source.setCloudPlatform(CloudPlatform.GCP);
source.setRootVolume(getRootVolume(100));
source.setInstanceType("large");
Map<String, Object> parameters = new HashMap<>();
parameters.put("cpus", 1);
when(missingResourceNameGenerator.generateName(APIResourceType.TEMPLATE)).thenReturn("name");
when(providerParameterCalculator.get(source)).thenReturn(mappable);
when(mappable.asMap()).thenReturn(parameters);
Template result = underTest.convert(source);
assertThat(result.getStatus()).isEqualTo(ResourceStatus.USER_MANAGED);
assertThat(result.cloudPlatform()).isEqualTo(source.getCloudPlatform().name());
assertThat(result.getRootVolumeSize()).isEqualTo(source.getRootVolume().getSize());
assertThat(result.getInstanceType()).isEqualTo(source.getInstanceType());
assertThat(result.getAttributes()).isNotNull();
assertThat(result.getAttributes().getMap().get("cpus")).isEqualTo(1);
assertThat(result.getSecretAttributes()).isNotNull();
}
Aggregations