Search in sources :

Example 21 with AwsNetwork

use of com.sequenceiq.environment.network.dao.domain.AwsNetwork in project cloudbreak by hortonworks.

the class NetworkCreationHandlerTest method testWithEndpointGatewayAndProvidedSubnets.

@Test
public void testWithEndpointGatewayAndProvidedSubnets() {
    EnvironmentDto environmentDto = createEnvironmentDto();
    Event<EnvironmentDto> environmentDtoEvent = Event.wrap(environmentDto);
    AwsNetwork network = createNetwork();
    Environment environment = createEnvironment(network);
    Optional<Environment> environmentOptional = Optional.of(environment);
    Map<String, CloudSubnet> subnets = createDefaultPrivateSubnets();
    Map<String, CloudSubnet> endpointGatewaySubnets = createDefaultPublicSubnets();
    when(environmentService.findEnvironmentById(any())).thenReturn(environmentOptional);
    when(cloudNetworkService.retrieveSubnetMetadata(any(EnvironmentDto.class), any())).thenReturn(subnets);
    when(networkMetadataValidationService.getEndpointGatewaySubnetMetadata(any(), any())).thenReturn(endpointGatewaySubnets);
    when(environmentResourceService.createAndSetNetwork(any(), any(), any(), any(), any())).thenReturn(network);
    ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.accept(environmentDtoEvent));
    assertEquals(2, environmentDto.getNetwork().getEndpointGatewaySubnetMetas().size());
    assertEquals(Set.of(PUBLIC_ID_1, PUBLIC_ID_2), environmentDto.getNetwork().getEndpointGatewaySubnetIds());
}
Also used : EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) AwsNetwork(com.sequenceiq.environment.network.dao.domain.AwsNetwork) Environment(com.sequenceiq.environment.environment.domain.Environment) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) NetworkTest(com.sequenceiq.environment.environment.service.network.NetworkTest) Test(org.junit.jupiter.api.Test)

Example 22 with AwsNetwork

use of com.sequenceiq.environment.network.dao.domain.AwsNetwork in project cloudbreak by hortonworks.

the class AwsEnvironmentNetworkConverter method setCreatedCloudNetwork.

@Override
public BaseNetwork setCreatedCloudNetwork(BaseNetwork baseNetwork, CreatedCloudNetwork createdCloudNetwork) {
    AwsNetwork awsNetwork = (AwsNetwork) baseNetwork;
    awsNetwork.setName(createdCloudNetwork.getStackName());
    awsNetwork.setVpcId(createdCloudNetwork.getNetworkId());
    awsNetwork.setSubnetMetas(createdCloudNetwork.getSubnets().stream().collect(Collectors.toMap(CreatedSubnet::getSubnetId, subnet -> new CloudSubnet(subnet.getSubnetId(), subnet.getSubnetId(), subnet.getAvailabilityZone(), subnet.getCidr(), !subnet.isPublicSubnet(), subnet.isMapPublicIpOnLaunch(), subnet.isIgwAvailable(), subnet.getType()))));
    return awsNetwork;
}
Also used : AwsNetwork(com.sequenceiq.environment.network.dao.domain.AwsNetwork) CreatedSubnet(com.sequenceiq.cloudbreak.cloud.model.network.CreatedSubnet) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)

Aggregations

AwsNetwork (com.sequenceiq.environment.network.dao.domain.AwsNetwork)22 Test (org.junit.jupiter.api.Test)15 Environment (com.sequenceiq.environment.environment.domain.Environment)12 NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)9 BaseNetwork (com.sequenceiq.environment.network.dao.domain.BaseNetwork)8 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)5 Network (com.sequenceiq.cloudbreak.cloud.model.Network)4 CreatedCloudNetwork (com.sequenceiq.cloudbreak.cloud.model.network.CreatedCloudNetwork)4 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 Credential (com.sequenceiq.environment.credential.domain.Credential)3 EnvironmentEditDto (com.sequenceiq.environment.environment.dto.EnvironmentEditDto)3 NetworkTest (com.sequenceiq.environment.environment.service.network.NetworkTest)3 CreatedSubnet (com.sequenceiq.cloudbreak.cloud.model.network.CreatedSubnet)2 Region (com.sequenceiq.environment.environment.domain.Region)2 GcpNetwork (com.sequenceiq.environment.network.dao.domain.GcpNetwork)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 CloudPlatformVariant (com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)1 Subnet (com.sequenceiq.cloudbreak.cloud.model.Subnet)1 NetworkCreationRequest (com.sequenceiq.cloudbreak.cloud.model.network.NetworkCreationRequest)1