Search in sources :

Example 1 with GcpTargetGroupResponse

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());
}
Also used : LoadBalancerResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.LoadBalancerResponse) GcpTargetGroupResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.GcpTargetGroupResponse) LoadBalancer(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer) AzureTargetGroupResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.AzureTargetGroupResponse) AwsTargetGroupResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.AwsTargetGroupResponse) GcpTargetGroupResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.GcpTargetGroupResponse) TargetGroupResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.TargetGroupResponse) AbstractEntityConverterTest(com.sequenceiq.cloudbreak.converter.AbstractEntityConverterTest) Test(org.junit.Test)

Example 2 with GcpTargetGroupResponse

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;
}
Also used : GcpLoadBalancerNamesDb(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.gcp.GcpLoadBalancerNamesDb) GcpTargetGroupResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.GcpTargetGroupResponse)

Aggregations

GcpTargetGroupResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.GcpTargetGroupResponse)2 AwsTargetGroupResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.AwsTargetGroupResponse)1 AzureTargetGroupResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.AzureTargetGroupResponse)1 LoadBalancerResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.LoadBalancerResponse)1 TargetGroupResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.loadbalancer.TargetGroupResponse)1 AbstractEntityConverterTest (com.sequenceiq.cloudbreak.converter.AbstractEntityConverterTest)1 LoadBalancer (com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer)1 GcpLoadBalancerNamesDb (com.sequenceiq.cloudbreak.domain.stack.loadbalancer.gcp.GcpLoadBalancerNamesDb)1 Test (org.junit.Test)1