### Question:
DefaultInstanceGroupProvider { public Template createDefaultTemplate(CloudPlatform cloudPlatform, String accountId) { Template template = new Template(); template.setName(missingResourceNameGenerator.generateName(APIResourceType.TEMPLATE)); template.setStatus(ResourceStatus.DEFAULT); template.setRootVolumeSize(defaultRootVolumeSizeProvider.getForPlatform(cloudPlatform.name())); template.setVolumeCount(0); template.setVolumeSize(0); template.setInstanceType(defaultInstanceTypeProvider.getForPlatform(cloudPlatform.name())); template.setAccountId(accountId); if (cloudPlatform == CloudPlatform.AWS && entitlementService.freeIpaDlEbsEncryptionEnabled(INTERNAL_ACTOR_CRN, accountId)) { template.setAttributes(new Json(Map.<String, Object>ofEntries( entry(AwsInstanceTemplate.EBS_ENCRYPTION_ENABLED, Boolean.TRUE), entry(AwsInstanceTemplate.FAST_EBS_ENCRYPTION_ENABLED, entitlementService.fastEbsEncryptionEnabled(INTERNAL_ACTOR_CRN, accountId)), entry(InstanceTemplate.VOLUME_ENCRYPTION_KEY_TYPE, EncryptionType.DEFAULT.name())))); } return template; }  Template createDefaultTemplate(CloudPlatform cloudPlatform, String accountId); Json createAttributes(CloudPlatform cloudPlatform, String stackName, String instanceGroupName);  }### Answer:
@Test void createDefaultTemplateTestNoVolumeEncryptionWhenAzure() { Template result = underTest.createDefaultTemplate(CloudPlatform.AZURE, ACCOUNT_ID); assertThat(result).isNotNull(); assertThat(result.getAttributes()).isNull(); }
@Test void createDefaultTemplateTestNoVolumeEncryptionWhenAwsAndNotEntitled() { when(entitlementService.freeIpaDlEbsEncryptionEnabled(INTERNAL_ACTOR_CRN, ACCOUNT_ID)).thenReturn(false); Template result = underTest.createDefaultTemplate(CloudPlatform.AWS, ACCOUNT_ID); assertThat(result).isNotNull(); assertThat(result.getAttributes()).isNull(); }
@Test void createDefaultTemplateTestVolumeEncryptionAddedWhenAwsAndEntitled() { when(entitlementService.freeIpaDlEbsEncryptionEnabled(INTERNAL_ACTOR_CRN, ACCOUNT_ID)).thenReturn(true); Template result = underTest.createDefaultTemplate(CloudPlatform.AWS, ACCOUNT_ID); assertThat(result).isNotNull(); Json attributes = result.getAttributes(); assertThat(attributes).isNotNull(); assertThat(attributes.<Object>getValue(AwsInstanceTemplate.EBS_ENCRYPTION_ENABLED)).isEqualTo(Boolean.TRUE); assertThat(attributes.<Object>getValue(AwsInstanceTemplate.FAST_EBS_ENCRYPTION_ENABLED)).isEqualTo(Boolean.FALSE); assertThat(attributes.<Object>getValue(InstanceTemplate.VOLUME_ENCRYPTION_KEY_TYPE)).isEqualTo(EncryptionType.DEFAULT.name()); }
@Test void createDefaultTemplateTestVolumeEncryptionAddedWhenAwsAndEntitledAndFastEncryption() { when(entitlementService.freeIpaDlEbsEncryptionEnabled(INTERNAL_ACTOR_CRN, ACCOUNT_ID)).thenReturn(true); when(entitlementService.fastEbsEncryptionEnabled(INTERNAL_ACTOR_CRN, ACCOUNT_ID)).thenReturn(true); Template result = underTest.createDefaultTemplate(CloudPlatform.AWS, ACCOUNT_ID); assertThat(result).isNotNull(); Json attributes = result.getAttributes(); assertThat(attributes).isNotNull(); assertThat(attributes.<Object>getValue(AwsInstanceTemplate.EBS_ENCRYPTION_ENABLED)).isEqualTo(Boolean.TRUE); assertThat(attributes.<Object>getValue(AwsInstanceTemplate.FAST_EBS_ENCRYPTION_ENABLED)).isEqualTo(Boolean.TRUE); assertThat(attributes.<Object>getValue(InstanceTemplate.VOLUME_ENCRYPTION_KEY_TYPE)).isEqualTo(EncryptionType.DEFAULT.name()); }