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());
}
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;
}
Aggregations