@Test void convert() { when(environmentValidatorService.validateAwsEnvironmentRequest(any())).thenReturn(ValidationResult.empty()); EnvironmentRequest request = getEnvironmentRequest(); CreateAWSEnvironmentRequest result = underTest.convert(request); assertEquals(request.getAuthentication().getPublicKey(), result.getAuthentication().getPublicKey()); assertEquals(request.getAuthentication().getPublicKeyId(), result.getAuthentication().getPublicKeyId()); assertEquals(request.getCredentialName(), result.getCredentialName()); assertEquals(request.getDescription(), result.getDescription()); assertEquals(request.getName(), result.getEnvironmentName()); assertEquals(request.getTelemetry().getLogging().getStorageLocation(), result.getLogStorage().getStorageLocationBase()); assertEquals(request.getTelemetry().getLogging().getS3().getInstanceProfile(), result.getLogStorage().getInstanceProfile()); assertEquals(request.getNetwork().getNetworkCidr(), result.getNetworkCidr()); assertEquals(request.getLocation().getName(), result.getRegion()); assertEquals(request.getAws().getS3guard().getDynamoDbTableName(), result.getS3GuardTableName()); assertEquals(request.getSecurityAccess().getCidr(), result.getSecurityAccess().getCidr()); assertEquals(request.getSecurityAccess().getDefaultSecurityGroupId(), result.getSecurityAccess().getDefaultSecurityGroupId()); assertEquals(request.getSecurityAccess().getSecurityGroupIdForKnox(), result.getSecurityAccess().getSecurityGroupIdForKnox()); assertThat(result.getSubnetIds()).hasSameElementsAs(request.getNetwork().getSubnetIds()); assertEquals(request.getNetwork().getAws().getVpcId(), result.getVpcId()); }
public CreateAWSEnvironmentRequest convert(EnvironmentRequest source) { validateRequest(source); CreateAWSEnvironmentRequest environmentRequest = new CreateAWSEnvironmentRequest(); environmentRequest.setAuthentication(environmentAuthenticationRequestToAuthenticationRequest(source.getAuthentication())); environmentRequest.setCredentialName(source.getCredentialName()); environmentRequest.setDescription(source.getDescription()); environmentRequest.setEnvironmentName(source.getName()); environmentRequest.setLogStorage(environmentTelemetryToLogStorageRequest(source.getTelemetry())); environmentRequest.setNetworkCidr(getIfNotNull(source.getNetwork(), EnvironmentNetworkBase::getNetworkCidr)); environmentRequest.setRegion(source.getLocation().getName()); environmentRequest.setS3GuardTableName(getS3GuardTableName(source)); environmentRequest.setSecurityAccess(environmentSecurityAccessToSecurityAccessRequest(source.getSecurityAccess())); environmentRequest.setSubnetIds(getSubnetIds(source)); environmentRequest.setVpcId(getVpcId(source)); return environmentRequest; }
EnvironmentRequestToCreateAWSEnvironmentRequestConverter implements EnvironmentRequestToCliRequestConverter { public CreateAWSEnvironmentRequest convert(EnvironmentRequest source) { validateRequest(source); CreateAWSEnvironmentRequest environmentRequest = new CreateAWSEnvironmentRequest(); environmentRequest.setAuthentication(environmentAuthenticationRequestToAuthenticationRequest(source.getAuthentication())); environmentRequest.setCredentialName(source.getCredentialName()); environmentRequest.setDescription(source.getDescription()); environmentRequest.setEnvironmentName(source.getName()); environmentRequest.setLogStorage(environmentTelemetryToLogStorageRequest(source.getTelemetry())); environmentRequest.setNetworkCidr(getIfNotNull(source.getNetwork(), EnvironmentNetworkBase::getNetworkCidr)); environmentRequest.setRegion(source.getLocation().getName()); environmentRequest.setS3GuardTableName(getS3GuardTableName(source)); environmentRequest.setSecurityAccess(environmentSecurityAccessToSecurityAccessRequest(source.getSecurityAccess())); environmentRequest.setSubnetIds(getSubnetIds(source)); environmentRequest.setVpcId(getVpcId(source)); return environmentRequest; } }
EnvironmentRequestToCreateAWSEnvironmentRequestConverter implements EnvironmentRequestToCliRequestConverter { public CreateAWSEnvironmentRequest convert(EnvironmentRequest source) { validateRequest(source); CreateAWSEnvironmentRequest environmentRequest = new CreateAWSEnvironmentRequest(); environmentRequest.setAuthentication(environmentAuthenticationRequestToAuthenticationRequest(source.getAuthentication())); environmentRequest.setCredentialName(source.getCredentialName()); environmentRequest.setDescription(source.getDescription()); environmentRequest.setEnvironmentName(source.getName()); environmentRequest.setLogStorage(environmentTelemetryToLogStorageRequest(source.getTelemetry())); environmentRequest.setNetworkCidr(getIfNotNull(source.getNetwork(), EnvironmentNetworkBase::getNetworkCidr)); environmentRequest.setRegion(source.getLocation().getName()); environmentRequest.setS3GuardTableName(getS3GuardTableName(source)); environmentRequest.setSecurityAccess(environmentSecurityAccessToSecurityAccessRequest(source.getSecurityAccess())); environmentRequest.setSubnetIds(getSubnetIds(source)); environmentRequest.setVpcId(getVpcId(source)); return environmentRequest; } EnvironmentRequestToCreateAWSEnvironmentRequestConverter(EnvironmentValidatorService environmentValidatorService); }
EnvironmentRequestToCreateAWSEnvironmentRequestConverter implements EnvironmentRequestToCliRequestConverter { public CreateAWSEnvironmentRequest convert(EnvironmentRequest source) { validateRequest(source); CreateAWSEnvironmentRequest environmentRequest = new CreateAWSEnvironmentRequest(); environmentRequest.setAuthentication(environmentAuthenticationRequestToAuthenticationRequest(source.getAuthentication())); environmentRequest.setCredentialName(source.getCredentialName()); environmentRequest.setDescription(source.getDescription()); environmentRequest.setEnvironmentName(source.getName()); environmentRequest.setLogStorage(environmentTelemetryToLogStorageRequest(source.getTelemetry())); environmentRequest.setNetworkCidr(getIfNotNull(source.getNetwork(), EnvironmentNetworkBase::getNetworkCidr)); environmentRequest.setRegion(source.getLocation().getName()); environmentRequest.setS3GuardTableName(getS3GuardTableName(source)); environmentRequest.setSecurityAccess(environmentSecurityAccessToSecurityAccessRequest(source.getSecurityAccess())); environmentRequest.setSubnetIds(getSubnetIds(source)); environmentRequest.setVpcId(getVpcId(source)); return environmentRequest; } EnvironmentRequestToCreateAWSEnvironmentRequestConverter(EnvironmentValidatorService environmentValidatorService); @Override CloudPlatform supportedPlatform(); CreateAWSEnvironmentRequest convert(EnvironmentRequest source); }
EnvironmentRequestToCreateAWSEnvironmentRequestConverter implements EnvironmentRequestToCliRequestConverter { public CreateAWSEnvironmentRequest convert(EnvironmentRequest source) { validateRequest(source); CreateAWSEnvironmentRequest environmentRequest = new CreateAWSEnvironmentRequest(); environmentRequest.setAuthentication(environmentAuthenticationRequestToAuthenticationRequest(source.getAuthentication())); environmentRequest.setCredentialName(source.getCredentialName()); environmentRequest.setDescription(source.getDescription()); environmentRequest.setEnvironmentName(source.getName()); environmentRequest.setLogStorage(environmentTelemetryToLogStorageRequest(source.getTelemetry())); environmentRequest.setNetworkCidr(getIfNotNull(source.getNetwork(), EnvironmentNetworkBase::getNetworkCidr)); environmentRequest.setRegion(source.getLocation().getName()); environmentRequest.setS3GuardTableName(getS3GuardTableName(source)); environmentRequest.setSecurityAccess(environmentSecurityAccessToSecurityAccessRequest(source.getSecurityAccess())); environmentRequest.setSubnetIds(getSubnetIds(source)); environmentRequest.setVpcId(getVpcId(source)); return environmentRequest; } EnvironmentRequestToCreateAWSEnvironmentRequestConverter(EnvironmentValidatorService environmentValidatorService); @Override CloudPlatform supportedPlatform(); CreateAWSEnvironmentRequest convert(EnvironmentRequest source);  }