use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.AwsTargetGroupResponse in project cloudbreak by hortonworks.
the class LoadBalancerToLoadBalancerResponseConverter method convertAwsTargetGroup.
private AwsTargetGroupResponse convertAwsTargetGroup(AwsTargetGroupConfigDb awsConfig, Integer port) {
if (awsConfig != null) {
Optional<AwsTargetGroupArnsDb> arns = awsConfig.getPortArnMapping().entrySet().stream().filter(entry -> entry.getKey().equals(port)).map(Map.Entry::getValue).findFirst();
if (arns.isPresent()) {
AwsTargetGroupResponse awsSettings = new AwsTargetGroupResponse();
awsSettings.setListenerArn(arns.get().getListenerArn());
awsSettings.setTargetGroupArn(arns.get().getTargetGroupArn());
return awsSettings;
}
}
return null;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.AwsTargetGroupResponse in project cloudbreak by hortonworks.
the class LoadBalancerToLoadBalancerResponseConverterTest method testConvertAws.
@Test
public void testConvertAws() {
LoadBalancer source = getSource();
// GIVEN
getSource().setProviderConfig(createAwsLoadBalancerConfig());
given(targetGroupService.findByLoadBalancerId(any())).willReturn(createAwsTargetGroups());
// WHEN
LoadBalancerResponse response = underTest.convert(source);
// THEN
assertAllFieldsNotNull(response, List.of("azureResourceId", "gcpResourceId"));
assertEquals(LB_ARN, response.getAwsResourceId().getArn());
assertEquals(1, response.getTargets().size());
TargetGroupResponse targetGroupResponse = response.getTargets().get(0);
assertEquals(PORT, targetGroupResponse.getPort());
assertEquals(Set.of(INSTANCE_ID), targetGroupResponse.getTargetInstances());
AwsTargetGroupResponse awsTargetGroupResponse = targetGroupResponse.getAwsResourceIds();
assertNotNull(awsTargetGroupResponse);
assertEquals(LISTENER_ARN, awsTargetGroupResponse.getListenerArn());
assertEquals(TG_ARN, awsTargetGroupResponse.getTargetGroupArn());
}
Aggregations