com.amazonaws.services.autoscaling.model.DescribeLaunchConfigurationsResult Java Examples

The following examples show how to use com.amazonaws.services.autoscaling.model.DescribeLaunchConfigurationsResult. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ASGInventoryUtilTest.java    From pacbot with Apache License 2.0 5 votes vote down vote up
/**
 * Fetch launch configurations test.
 *
 * @throws Exception the exception
 */
@SuppressWarnings("static-access")
@Test
public void fetchLaunchConfigurationsTest() throws Exception {
    
    mockStatic(AmazonAutoScalingClientBuilder.class);
    AmazonAutoScaling asgClient = PowerMockito.mock(AmazonAutoScaling.class);
    AmazonAutoScalingClientBuilder amazonAutoScalingClientBuilder = PowerMockito.mock(AmazonAutoScalingClientBuilder.class);
    AWSStaticCredentialsProvider awsStaticCredentialsProvider = PowerMockito.mock(AWSStaticCredentialsProvider.class);
    PowerMockito.whenNew(AWSStaticCredentialsProvider.class).withAnyArguments().thenReturn(awsStaticCredentialsProvider);
    when(amazonAutoScalingClientBuilder.standard()).thenReturn(amazonAutoScalingClientBuilder);
    when(amazonAutoScalingClientBuilder.withCredentials(anyObject())).thenReturn(amazonAutoScalingClientBuilder);
    when(amazonAutoScalingClientBuilder.withRegion(anyString())).thenReturn(amazonAutoScalingClientBuilder);
    when(amazonAutoScalingClientBuilder.build()).thenReturn(asgClient);
    
    DescribeAutoScalingGroupsResult autoScalingGroupsResult = new DescribeAutoScalingGroupsResult();
    List<AutoScalingGroup> asgList = new ArrayList<>();
    AutoScalingGroup autoScalingGroup = new AutoScalingGroup();
    autoScalingGroup.setLaunchConfigurationName("launchConfigurationName");
    asgList.add(autoScalingGroup);
    autoScalingGroupsResult.setAutoScalingGroups(asgList);
    when(asgClient.describeAutoScalingGroups(anyObject())).thenReturn(autoScalingGroupsResult);
    
    DescribeLaunchConfigurationsResult launchConfigurationsResult = new DescribeLaunchConfigurationsResult();
    List<LaunchConfiguration> launchConfigurations = new ArrayList<>();
    launchConfigurations.add(new LaunchConfiguration());
    
    launchConfigurationsResult.setLaunchConfigurations(launchConfigurations);
    when(asgClient.describeLaunchConfigurations(anyObject())).thenReturn(launchConfigurationsResult);
    assertThat(asgInventoryUtil.fetchLaunchConfigurations(new BasicSessionCredentials("awsAccessKey", "awsSecretKey", "sessionToken"), 
            "skipRegions", "account","accountName").size(), is(1));
    
}
 
Example #2
Source File: AwsInstanceCloudConnector.java    From titus-control-plane with Apache License 2.0 5 votes vote down vote up
@Override
public Observable<List<InstanceLaunchConfiguration>> getInstanceLaunchConfiguration(List<String> launchConfigurationIds) {
    if (launchConfigurationIds.isEmpty()) {
        return Observable.just(Collections.emptyList());
    }
    DescribeLaunchConfigurationsRequest request = new DescribeLaunchConfigurationsRequest().withLaunchConfigurationNames(launchConfigurationIds);
    Observable<DescribeLaunchConfigurationsResult> observable = toObservable(request, autoScalingClient::describeLaunchConfigurationsAsync);
    return observable.map(
            response -> toInstanceLaunchConfigurations(response.getLaunchConfigurations())
    ).timeout(configuration.getAwsRequestTimeoutMs(), TimeUnit.MILLISECONDS);
}
 
Example #3
Source File: LaunchConfigurationHandlerTest.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@Test
public void getLaunchConfigurations() {
    when(autoScalingClient.describeLaunchConfigurations(any(DescribeLaunchConfigurationsRequest.class)))
            .thenReturn(new DescribeLaunchConfigurationsResult());

    Collection<AutoScalingGroup> autoScalingGroups = Lists.newArrayList(new AutoScalingGroup().withLaunchConfigurationName("a"),
            new AutoScalingGroup().withLaunchConfigurationName("b"));
    underTest.getLaunchConfigurations(autoScalingClient, autoScalingGroups);
    ArgumentCaptor<DescribeLaunchConfigurationsRequest> captor = ArgumentCaptor.forClass(DescribeLaunchConfigurationsRequest.class);
    verify(autoScalingClient, times(1)).describeLaunchConfigurations(captor.capture());
    assertEquals(autoScalingGroups.size(), captor.getValue().getLaunchConfigurationNames().size());
}