Search in sources :

Example 1 with DescribeRulesRequest

use of software.amazon.awssdk.services.elasticloadbalancingv2.model.DescribeRulesRequest in project aws-cloudwatch-exporter by asserts.

the class TargetGroupLBMapProviderTest method mapListener.

@Test
public void mapListener() {
    Resource lbResource = Resource.builder().arn("lb-arn").build();
    Resource tgResource = Resource.builder().arn("tg-arn").build();
    Listener listener = Listener.builder().listenerArn("listener-arn").build();
    DescribeRulesRequest request = DescribeRulesRequest.builder().listenerArn("listener-arn").build();
    DescribeRulesResponse response = DescribeRulesResponse.builder().rules(Rule.builder().actions(Action.builder().targetGroupArn("tg-arn").build()).build()).build();
    expect(lbClient.describeRules(request)).andReturn(response);
    metricCollector.recordLatency(eq(SCRAPE_LATENCY_METRIC), anyObject(SortedMap.class), anyLong());
    expect(resourceMapper.map("tg-arn")).andReturn(Optional.of(tgResource));
    TargetGroupLBMapProvider testClass = new TargetGroupLBMapProvider(scrapeConfigProvider, awsClientProvider, resourceMapper, new RateLimiter(metricCollector));
    replayAll();
    assertTrue(testClass.getTgToLB().isEmpty());
    testClass.mapListener(lbClient, new TreeMap<>(), lbResource, listener);
    assertEquals(ImmutableMap.of(tgResource, lbResource), testClass.getTgToLB());
    verifyAll();
}
Also used : DescribeRulesRequest(software.amazon.awssdk.services.elasticloadbalancingv2.model.DescribeRulesRequest) Listener(software.amazon.awssdk.services.elasticloadbalancingv2.model.Listener) ImmutableSortedMap(com.google.common.collect.ImmutableSortedMap) SortedMap(java.util.SortedMap) Resource(ai.asserts.aws.resource.Resource) DescribeRulesResponse(software.amazon.awssdk.services.elasticloadbalancingv2.model.DescribeRulesResponse) RateLimiter(ai.asserts.aws.RateLimiter) Test(org.junit.jupiter.api.Test)

Aggregations

RateLimiter (ai.asserts.aws.RateLimiter)1 Resource (ai.asserts.aws.resource.Resource)1 ImmutableSortedMap (com.google.common.collect.ImmutableSortedMap)1 SortedMap (java.util.SortedMap)1 Test (org.junit.jupiter.api.Test)1 DescribeRulesRequest (software.amazon.awssdk.services.elasticloadbalancingv2.model.DescribeRulesRequest)1 DescribeRulesResponse (software.amazon.awssdk.services.elasticloadbalancingv2.model.DescribeRulesResponse)1 Listener (software.amazon.awssdk.services.elasticloadbalancingv2.model.Listener)1