use of com.sequenceiq.environment.network.dto.NetworkDto in project cloudbreak by hortonworks.
the class AzureEnvironmentNetworkValidatorTest method testValidateDuringFlowWhenEnvironmentIsBeingEditedThenPrivateEndpointValidationsSkipped.
@Test
void testValidateDuringFlowWhenEnvironmentIsBeingEditedThenPrivateEndpointValidationsSkipped() {
ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
AzureParams azureParams = getAzureParams("", "networkResourceGroupName");
NetworkDto networkDto = getNetworkDto(azureParams);
when(cloudNetworkService.retrieveSubnetMetadata(any(EnvironmentDto.class), any())).thenReturn(getCloudSubnets(false));
EnvironmentValidationDto environmentDto = environmentValidationDtoWithSingleRg(MY_SINGLE_RG, ResourceGroupUsagePattern.USE_SINGLE);
environmentDto.setValidationType(ValidationType.ENVIRONMENT_EDIT);
underTest.validateDuringFlow(environmentDto, networkDto, validationResultBuilder);
verify(azureNetworkLinkService, never()).validateExistingNetworkLink(any(), any(), any());
verify(azureCloudSubnetParametersService, never()).isPrivateEndpointNetworkPoliciesDisabled(any());
assertFalse(validationResultBuilder.build().hasError());
}
use of com.sequenceiq.environment.network.dto.NetworkDto in project cloudbreak by hortonworks.
the class AzureEnvironmentNetworkValidatorTest method testValidateDuringRequestWhenTheAzureNetworkParamsDoesNotContainNetworkId.
@Test
void testValidateDuringRequestWhenTheAzureNetworkParamsDoesNotContainNetworkId() {
AzureParams azureParams = NetworkTestUtils.getAzureParams(true, false, true);
NetworkDto networkDto = NetworkTestUtils.getNetworkDto(azureParams, null, null, azureParams.getNetworkId(), null, 1);
ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
underTest.validateDuringRequest(networkDto, validationResultBuilder);
NetworkTestUtils.checkErrorsPresent(validationResultBuilder, List.of("If resourceGroupName is specified, then networkId must be specified too.", "Either the AZURE network id or cidr needs to be defined!", "If subnetIds are specified, then networkId must be specified too."));
}
use of com.sequenceiq.environment.network.dto.NetworkDto in project cloudbreak by hortonworks.
the class EnvironmentModificationServiceTest method editByNameNetworkChange.
@Test
void editByNameNetworkChange() {
NetworkDto network = NetworkDto.builder().build();
EnvironmentEditDto environmentDto = EnvironmentEditDto.builder().withAccountId(ACCOUNT_ID).withNetwork(network).build();
Environment value = new Environment();
when(environmentService.findByNameAndAccountIdAndArchivedIsFalse(eq(ENVIRONMENT_NAME), eq(ACCOUNT_ID))).thenReturn(Optional.of(value));
when(networkService.findByEnvironment(any())).thenReturn(Optional.empty());
when(networkService.saveNetwork(any(), any(), anyString(), any(), any())).thenReturn(new AwsNetwork());
environmentModificationServiceUnderTest.editByName(ENVIRONMENT_NAME, environmentDto);
ArgumentCaptor<Environment> environmentArgumentCaptor = ArgumentCaptor.forClass(Environment.class);
verify(environmentService).save(environmentArgumentCaptor.capture());
}
use of com.sequenceiq.environment.network.dto.NetworkDto in project cloudbreak by hortonworks.
the class EnvironmentApiConverterTest method testAzureSingleRgEnabledAndEmptyAzureRequest.
@Test
void testAzureSingleRgEnabledAndEmptyAzureRequest() {
EnvironmentRequest request = createEnvironmentRequest(AZURE);
request.setAzure(null);
FreeIpaCreationDto freeIpaCreationDto = mock(FreeIpaCreationDto.class);
EnvironmentTelemetry environmentTelemetry = mock(EnvironmentTelemetry.class);
AccountTelemetry accountTelemetry = mock(AccountTelemetry.class);
Features features = mock(Features.class);
NetworkDto networkDto = mock(NetworkDto.class);
when(credentialService.getCloudPlatformByCredential(anyString(), anyString(), any())).thenReturn(AZURE.name());
when(freeIpaConverter.convert(request.getFreeIpa(), "id", CloudConstants.AWS)).thenReturn(freeIpaCreationDto);
when(accountTelemetry.getFeatures()).thenReturn(features);
when(accountTelemetryService.getOrDefault(any())).thenReturn(accountTelemetry);
when(telemetryApiConverter.convert(eq(request.getTelemetry()), any(), anyString())).thenReturn(environmentTelemetry);
when(tunnelConverter.convert(request.getTunnel())).thenReturn(request.getTunnel());
when(networkRequestToDtoConverter.convert(request.getNetwork())).thenReturn(networkDto);
EnvironmentCreationDto actual = testInitCreationDto(request);
assertEquals(ResourceGroupUsagePattern.USE_MULTIPLE, actual.getParameters().getAzureParametersDto().getAzureResourceGroupDto().getResourceGroupUsagePattern());
}
use of com.sequenceiq.environment.network.dto.NetworkDto in project cloudbreak by hortonworks.
the class NetworkDtoToResponseConverterTest method testConvertWithAwsParams.
@Test
void testConvertWithAwsParams() {
NetworkDto network = createNetworkDto().withAws(createAwsParams()).build();
ProvidedSubnetIds providedSubnetIds = new ProvidedSubnetIds(PREFERRED_SUBNET_ID, Set.of(PREFERRED_SUBNET_ID));
when(subnetIdProvider.subnets(network, TUNNEL, network.getCloudPlatform(), true)).thenReturn(providedSubnetIds);
EnvironmentNetworkResponse actual = underTest.convert(network, TUNNEL, true);
assertCommonFields(network, actual);
assertEquals(network.getAws().getVpcId(), actual.getAws().getVpcId());
assertNull(actual.getAzure());
assertNull(actual.getYarn());
assertNull(actual.getMock());
}
Aggregations