Java Code Examples for com.amazonaws.services.ec2.model.DescribeVolumesResult#setVolumes()

The following examples show how to use com.amazonaws.services.ec2.model.DescribeVolumesResult#setVolumes() . 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: PacmanEc2UtilsTest.java    From pacbot with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("static-access")
@Test
public void collectAllVolumesTest() throws Exception {
    
    Volume vol = new Volume();
    vol.setVolumeId("123");
    Collection<Volume> volumes = new ArrayList<>();
    volumes.add(vol);
   
    
    DescribeVolumesResult result = new DescribeVolumesResult();
    result.setVolumes(volumes);
    
    when(ec2ServiceClient.describeVolumes(anyObject())).thenReturn(result);
    assertThat(pacmanEc2Utils.collectAllVolumes(ec2ServiceClient,describeVolumesRequest),is(notNullValue()));
}
 
Example 2
Source File: InventoryUtilTest.java    From pacbot with Apache License 2.0 6 votes vote down vote up
/**
 * Fetch volumet info test.
 *
 * @throws Exception the exception
 */
@SuppressWarnings("static-access")
@Test
public void fetchVolumetInfoTest() throws Exception {
    
    mockStatic(AmazonEC2ClientBuilder.class);
    AmazonEC2 ec2Client = PowerMockito.mock(AmazonEC2.class);
    AmazonEC2ClientBuilder amazonEC2ClientBuilder = PowerMockito.mock(AmazonEC2ClientBuilder.class);
    AWSStaticCredentialsProvider awsStaticCredentialsProvider = PowerMockito.mock(AWSStaticCredentialsProvider.class);
    PowerMockito.whenNew(AWSStaticCredentialsProvider.class).withAnyArguments().thenReturn(awsStaticCredentialsProvider);
    when(amazonEC2ClientBuilder.standard()).thenReturn(amazonEC2ClientBuilder);
    when(amazonEC2ClientBuilder.withCredentials(anyObject())).thenReturn(amazonEC2ClientBuilder);
    when(amazonEC2ClientBuilder.withRegion(anyString())).thenReturn(amazonEC2ClientBuilder);
    when(amazonEC2ClientBuilder.build()).thenReturn(ec2Client);
    
    DescribeVolumesResult describeVolumesResult = new DescribeVolumesResult();
    List<Volume> volumeList = new ArrayList<>();
    volumeList.add(new Volume());
    describeVolumesResult.setVolumes(volumeList);
    when(ec2Client.describeVolumes()).thenReturn(describeVolumesResult);
    assertThat(inventoryUtil.fetchVolumetInfo(new BasicSessionCredentials("awsAccessKey", "awsSecretKey", "sessionToken"), 
            "skipRegions", "account","accountName").size(), is(1));
}