use of com.amazonaws.services.cloudformation.model.ListStackResourcesRequest in project cloudbreak by hortonworks.
the class AwsLoadBalancerMetadataCollectorTest method testCollectInternalLoadBalancer.
@Test
public void testCollectInternalLoadBalancer() {
int numPorts = 1;
AuthenticatedContext ac = authenticatedContext();
LoadBalancer loadBalancer = createLoadBalancer();
List<StackResourceSummary> summaries = createSummaries(numPorts, true);
ListStackResourcesResult result = new ListStackResourcesResult();
result.setStackResourceSummaries(summaries);
Map<String, Object> expectedParameters = Map.of(AwsLoadBalancerMetadataView.LOADBALANCER_ARN, LOAD_BALANCER_ARN, AwsLoadBalancerMetadataView.LISTENER_ARN_PREFIX + 0, LISTENER_ARN + "0Internal", AwsLoadBalancerMetadataView.TARGET_GROUP_ARN_PREFIX + 0, TARGET_GROUP_ARN + "0Internal");
when(awsClient.createCloudFormationClient(any(), any())).thenReturn(cfRetryClient);
when(cloudFormationStackUtil.getCfStackName(ac)).thenReturn("stackName");
when(awsStackRequestHelper.createListStackResourcesRequest(eq("stackName"))).thenReturn(new ListStackResourcesRequest());
when(cfRetryClient.listStackResources(any())).thenReturn(result);
Map<String, Object> parameters = underTest.getParameters(ac, loadBalancer, AwsLoadBalancerScheme.INTERNAL);
assertEquals(expectedParameters, parameters);
}
use of com.amazonaws.services.cloudformation.model.ListStackResourcesRequest in project spring-cloud-aws by awspring.
the class StackConfigurationBeanDefinitionParserTest method resourceIdResolverResolveToPhysicalResourceId_stackConfigurationWithoutStaticNameAndLogicalResourceIdOfExistingResourceProvided_returnsPhysicalResourceId.
// @checkstyle:off
@Test
void resourceIdResolverResolveToPhysicalResourceId_stackConfigurationWithoutStaticNameAndLogicalResourceIdOfExistingResourceProvided_returnsPhysicalResourceId() throws Exception {
// @checkstyle:on
// Arrange
HttpServer server = MetaDataServer.setupHttpServer();
HttpContext httpContext = server.createContext("/latest/meta-data/instance-id", new MetaDataServer.HttpResponseWriterHandler("foo"));
GenericXmlApplicationContext applicationContext = new GenericXmlApplicationContext();
AmazonCloudFormation amazonCloudFormation = Mockito.mock(AmazonCloudFormation.class);
when(amazonCloudFormation.describeStackResources(new DescribeStackResourcesRequest().withPhysicalResourceId("foo"))).thenReturn(new DescribeStackResourcesResult().withStackResources(new StackResource().withStackName("test")));
when(amazonCloudFormation.listStackResources(new ListStackResourcesRequest().withStackName("test"))).thenReturn(new ListStackResourcesResult().withStackResourceSummaries(new StackResourceSummary().withLogicalResourceId("EmptyBucket").withPhysicalResourceId("integrationteststack-emptybucket-foo")));
applicationContext.load(new ClassPathResource(getClass().getSimpleName() + "-autoDetectStackName.xml", getClass()));
applicationContext.getBeanFactory().registerSingleton(getBeanName(AmazonCloudFormation.class.getName()), amazonCloudFormation);
applicationContext.refresh();
ResourceIdResolver resourceIdResolver = applicationContext.getBean(ResourceIdResolver.class);
// Act
String physicalResourceId = resourceIdResolver.resolveToPhysicalResourceId("EmptyBucket");
// Assert
assertThat(physicalResourceId).startsWith("integrationteststack-emptybucket-");
server.removeContext(httpContext);
}
use of com.amazonaws.services.cloudformation.model.ListStackResourcesRequest in project spring-cloud-aws by awspring.
the class StackResourceRegistryFactoryBeanTest method createInstance_stackWithNextTag_returnsStackResourceRegistryBuildWithTwoPages.
@Test
void createInstance_stackWithNextTag_returnsStackResourceRegistryBuildWithTwoPages() throws Exception {
// Arrange
AmazonCloudFormation cloudFormationClient = mock(AmazonCloudFormation.class);
StackResourceRegistryFactoryBean stackResourceRegistryFactoryBean = new StackResourceRegistryFactoryBean(cloudFormationClient, new StaticStackNameProvider(STACK_NAME));
when(cloudFormationClient.listStackResources(new ListStackResourcesRequest().withStackName(STACK_NAME))).thenReturn(new ListStackResourcesResult().withNextToken("2").withStackResourceSummaries(new StackResourceSummary().withLogicalResourceId("log1")));
when(cloudFormationClient.listStackResources(new ListStackResourcesRequest().withStackName(STACK_NAME).withNextToken("2"))).thenReturn(new ListStackResourcesResult().withStackResourceSummaries(new StackResourceSummary().withLogicalResourceId("log2")));
// Act
ListableStackResourceFactory stackResourceFactory = stackResourceRegistryFactoryBean.createInstance();
// Assert
verify(cloudFormationClient, times(2)).listStackResources(isA(ListStackResourcesRequest.class));
assertThat(stackResourceFactory.getAllResources().size()).isEqualTo(2);
}
Aggregations