use of com.sequenceiq.environment.network.dto.NetworkDto in project cloudbreak by hortonworks.
the class AzureEnvironmentNetworkValidatorTest method testValidateDuringFlowWhenTheAzureNetworkParamsContainsRequiredFields.
@Test
void testValidateDuringFlowWhenTheAzureNetworkParamsContainsRequiredFields() {
ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
AzureParams azureParams = getAzureParams("", "");
NetworkDto networkDto = NetworkDto.builder().withId(1L).withName("networkName").withResourceCrn("aResourceCRN").withAzure(azureParams).withSubnetMetas(Map.of()).build();
EnvironmentValidationDto environmentValidationDto = EnvironmentValidationDto.builder().withEnvironmentDto(EnvironmentDto.builder().build()).build();
underTest.validateDuringFlow(environmentValidationDto, networkDto, validationResultBuilder);
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 AzureEnvironmentNetworkValidatorTest method testValidateDuringRequestWhenNetworkIdWithSubnetsNotExistsOnAzure.
@Test
void testValidateDuringRequestWhenNetworkIdWithSubnetsNotExistsOnAzure() {
int numberOfSubnets = 2;
AzureParams azureParams = NetworkTestUtils.getAzureParams(true, true, true);
NetworkDto networkDto = NetworkTestUtils.getNetworkDto(azureParams, null, null, azureParams.getNetworkId(), null, numberOfSubnets);
EnvironmentDto environmentDto = new EnvironmentDto();
EnvironmentValidationDto environmentValidationDto = EnvironmentValidationDto.builder().withEnvironmentDto(environmentDto).build();
when(cloudNetworkService.retrieveSubnetMetadata(environmentDto, networkDto)).thenReturn(Map.of(networkDto.getSubnetIds().stream().findFirst().get(), new CloudSubnet()));
ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
underTest.validateDuringFlow(environmentValidationDto, networkDto, resultBuilder);
NetworkTestUtils.checkErrorsPresent(resultBuilder, List.of("If networkId (aNetworkId) and resourceGroupName (aResourceGroupId) are specified then" + " subnet ids must be specified and should exist on azure as well. Given subnetids: [\"key1\", \"key0\"], existing ones: [\"key1\"]"));
}
use of com.sequenceiq.environment.network.dto.NetworkDto in project cloudbreak by hortonworks.
the class AzureEnvironmentNetworkValidatorTest method testValidateDuringRequestWhenNoNetworkCidrAndNoAzureParams.
@Test
void testValidateDuringRequestWhenNoNetworkCidrAndNoAzureParams() {
NetworkDto networkDto = NetworkTestUtils.getNetworkDto(null, null, null, null, null, 1);
ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
underTest.validateDuringRequest(networkDto, resultBuilder);
NetworkTestUtils.checkErrorsPresent(resultBuilder, List.of("The 'AZURE' related network parameters should be specified!", "Either the AZURE network id or cidr needs to be defined!"));
}
use of com.sequenceiq.environment.network.dto.NetworkDto in project cloudbreak by hortonworks.
the class AzureExistingPrivateDnsZonesServiceTest method testGetServiceNamesWithExistingZonesWhenPostgresWithExistingPrivateDnsZone.
@Test
void testGetServiceNamesWithExistingZonesWhenPostgresWithExistingPrivateDnsZone() {
NetworkDto networkDto = getNetworkDto("postgresPrivateDnsZoneId");
Set<String> servicesWithPrivateDnsZones = underTest.getServiceNamesWithExistingZones(networkDto);
assertThat(servicesWithPrivateDnsZones).hasSize(1);
assertThat(servicesWithPrivateDnsZones).contains(AzurePrivateDnsZoneServiceEnum.POSTGRES.name());
}
Aggregations