use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.GcpTargetGroupResponse in project cloudbreak by hortonworks.
the class LoadBalancerToLoadBalancerResponseConverterTest method testConvertGcp.
@Test
public void testConvertGcp() {
LoadBalancer source = getSource();
// GIVEN
getSource().setProviderConfig(createGcpLoadBalancerConfig());
given(targetGroupService.findByLoadBalancerId(any())).willReturn(creatGcpTargetGroups());
// WHEN
LoadBalancerResponse response = underTest.convert(source);
// THEN
assertAllFieldsNotNull(response, List.of("awsResourceId", "azureResourceId"));
assertEquals(GCP_LB_NAME, response.getGcpResourceId().getName());
assertEquals(1, response.getTargets().size());
TargetGroupResponse targetGroupResponse = response.getTargets().get(0);
assertEquals(PORT, targetGroupResponse.getPort());
assertEquals(Set.of(INSTANCE_ID), targetGroupResponse.getTargetInstances());
GcpTargetGroupResponse gcpTargetGroupResponse = targetGroupResponse.getGcpResourceId();
assertNotNull(gcpTargetGroupResponse);
assertEquals(GCP_INSTANCE_GROUP_NAME, gcpTargetGroupResponse.getGcpInstanceGroupName());
assertEquals(GCP_BACKEND_SERVICE_NAME, gcpTargetGroupResponse.getGcpBackendServiceName());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.GcpTargetGroupResponse in project cloudbreak by hortonworks.
the class LoadBalancerToLoadBalancerResponseConverter method convertGcpTargetGroup.
private GcpTargetGroupResponse convertGcpTargetGroup(GcpTargetGroupConfigDb gcpConfig, Integer port) {
if (gcpConfig != null) {
GcpLoadBalancerNamesDb gcpLoadBalancerNamesDb = gcpConfig.getPortMapping().get(port);
GcpTargetGroupResponse gcpTargetGroupResponse = new GcpTargetGroupResponse();
gcpTargetGroupResponse.setGcpInstanceGroupName(gcpLoadBalancerNamesDb.getInstanceGroupName());
gcpTargetGroupResponse.setGcpBackendServiceName(gcpLoadBalancerNamesDb.getBackendServiceName());
return gcpTargetGroupResponse;
}
return null;
}
Aggregations