use of com.amazonaws.services.elasticloadbalancingv2.model.LoadBalancerNotFoundException in project cloudbreak by hortonworks.
the class AwsNativeMetadataCollectorTest method collectLoadBalancerMetadataWhenWhenNotExpectedAmazonServiceExceptionOccurs.
@Test
void collectLoadBalancerMetadataWhenWhenNotExpectedAmazonServiceExceptionOccurs() {
List<LoadBalancerType> loadBalancerTypes = List.of();
CloudResource cloudResource = getCloudResource("secondCrn", "secondInstanceName", null, ELASTIC_LOAD_BALANCER);
List<CloudResource> cloudResources = List.of(cloudResource);
when(awsClient.createElasticLoadBalancingClient(any(), any())).thenReturn(loadBalancingClient);
LoadBalancerNotFoundException loadBalancerNotFoundException = new LoadBalancerNotFoundException("One or more elastic lb not found");
when(loadBalancingClient.describeLoadBalancers(any())).thenThrow(loadBalancerNotFoundException);
CloudConnectorException cloudConnectorException = assertThrows(CloudConnectorException.class, () -> underTest.collectLoadBalancer(authenticatedContext, loadBalancerTypes, cloudResources));
assertThat(cloudConnectorException).hasMessage("Metadata collection of load balancers failed");
assertThat(cloudConnectorException).hasCauseReference(loadBalancerNotFoundException);
verify(loadBalancingClient, times(1)).describeLoadBalancers(any());
}
use of com.amazonaws.services.elasticloadbalancingv2.model.LoadBalancerNotFoundException in project cloudbreak by hortonworks.
the class AwsNativeMetadataCollectorTest method collectLoadBalancerMetadataWhenOneOfSpecifiedArnsDoNotExist.
@Test
void collectLoadBalancerMetadataWhenOneOfSpecifiedArnsDoNotExist() {
List<LoadBalancerType> loadBalancerTypes = List.of();
CloudResource cloudResource = getCloudResource("aCrn", "lbname", null, ELASTIC_LOAD_BALANCER);
CloudResource secondCloudResource = getCloudResource("secondCrn", "lbnamesecond", null, ELASTIC_LOAD_BALANCER);
List<CloudResource> cloudResources = List.of(cloudResource, secondCloudResource);
when(awsClient.createElasticLoadBalancingClient(any(), any())).thenReturn(loadBalancingClient);
LoadBalancerNotFoundException loadBalancerNotFoundException = new LoadBalancerNotFoundException("One or more elastic lb not found");
loadBalancerNotFoundException.setErrorCode(LOAD_BALANCER_NOT_FOUND_ERROR_CODE);
LoadBalancer loadBalancer = new LoadBalancer();
loadBalancer.setScheme(LoadBalancerSchemeEnum.Internal);
when(loadBalancingClient.describeLoadBalancers(any())).thenReturn(new DescribeLoadBalancersResult().withLoadBalancers(loadBalancer)).thenThrow(loadBalancerNotFoundException);
List<CloudLoadBalancerMetadata> cloudLoadBalancerMetadata = underTest.collectLoadBalancer(authenticatedContext, loadBalancerTypes, cloudResources);
verify(loadBalancingClient, times(2)).describeLoadBalancers(any());
assertFalse(cloudLoadBalancerMetadata.isEmpty());
}
use of com.amazonaws.services.elasticloadbalancingv2.model.LoadBalancerNotFoundException in project cloudbreak by hortonworks.
the class AwsNativeMetadataCollectorTest method collectLoadBalancerMetadataWhenTheSpecifiedArnsDoNotExist.
@Test
void collectLoadBalancerMetadataWhenTheSpecifiedArnsDoNotExist() {
List<LoadBalancerType> loadBalancerTypes = List.of();
CloudResource cloudResource = getCloudResource("secondCrn", "secondInstanceName", null, ELASTIC_LOAD_BALANCER);
List<CloudResource> cloudResources = List.of(cloudResource);
when(awsClient.createElasticLoadBalancingClient(any(), any())).thenReturn(loadBalancingClient);
LoadBalancerNotFoundException loadBalancerNotFoundException = new LoadBalancerNotFoundException("One or more elastic lb not found");
loadBalancerNotFoundException.setErrorCode(LOAD_BALANCER_NOT_FOUND_ERROR_CODE);
when(loadBalancingClient.describeLoadBalancers(any())).thenThrow(loadBalancerNotFoundException);
List<CloudLoadBalancerMetadata> cloudLoadBalancerMetadata = underTest.collectLoadBalancer(authenticatedContext, loadBalancerTypes, cloudResources);
verify(loadBalancingClient, times(1)).describeLoadBalancers(any());
Assertions.assertTrue(cloudLoadBalancerMetadata.isEmpty());
}
Aggregations