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();
}
Aggregations