use of com.sequenceiq.environment.environment.dto.UpdateAzureResourceEncryptionDto in project cloudbreak by hortonworks.
the class EnvironmentModificationServiceTest method testUpdateAzureResourceEncryptionParametersByEnvironmentCrn.
@Test
void testUpdateAzureResourceEncryptionParametersByEnvironmentCrn() {
UpdateAzureResourceEncryptionDto updateAzureResourceEncryptionDto = UpdateAzureResourceEncryptionDto.builder().withAzureResourceEncryptionParametersDto(AzureResourceEncryptionParametersDto.builder().withEncryptionKeyUrl("dummyKeyUrl").withEncryptionKeyResourceGroupName("dummyResourceGroupName").build()).build();
CreatedDiskEncryptionSet createdDiskEncryptionSet = new CreatedDiskEncryptionSet.Builder().withDiskEncryptionSetId("dummyId").build();
Environment env = new Environment();
env.setParameters(new AzureParameters());
when(environmentService.getValidatorService()).thenReturn(validatorService);
when(environmentService.findByResourceCrnAndAccountIdAndArchivedIsFalse(eq(ENVIRONMENT_NAME), eq(ACCOUNT_ID))).thenReturn(Optional.of(env));
when(validatorService.validateEncryptionKeyUrl(any(String.class), any(String.class))).thenReturn(ValidationResult.builder().build());
when(environmentDtoConverter.environmentToDto(env)).thenReturn(new EnvironmentDto());
when(environmentEncryptionService.createEncryptionResources(any(EnvironmentDto.class))).thenReturn(createdDiskEncryptionSet);
environmentModificationServiceUnderTest.updateAzureResourceEncryptionParametersByEnvironmentCrn(ACCOUNT_ID, ENVIRONMENT_NAME, updateAzureResourceEncryptionDto);
ArgumentCaptor<AzureParameters> azureParametersArgumentCaptor = ArgumentCaptor.forClass(AzureParameters.class);
verify(azureParametersRepository).save(azureParametersArgumentCaptor.capture());
assertEquals("dummyKeyUrl", azureParametersArgumentCaptor.getValue().getEncryptionKeyUrl());
assertEquals("dummyResourceGroupName", azureParametersArgumentCaptor.getValue().getEncryptionKeyResourceGroupName());
}
Aggregations