Java Code Examples for com.amazonaws.services.ec2.model.DescribeRouteTablesResult#setRouteTables()
The following examples show how to use
com.amazonaws.services.ec2.model.DescribeRouteTablesResult#setRouteTables() .
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: EC2InventoryUtilTest.java From pacbot with Apache License 2.0 | 6 votes |
/** * Fetch route tables test. * * @throws Exception the exception */ @SuppressWarnings("static-access") @Test public void fetchRouteTablesTest() 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); DescribeRouteTablesResult describeRouteTablesResult = new DescribeRouteTablesResult(); List<RouteTable> routeTableList = new ArrayList<>(); routeTableList.add(new RouteTable()); describeRouteTablesResult.setRouteTables(routeTableList); when(ec2Client.describeRouteTables()).thenReturn(describeRouteTablesResult); assertThat(ec2InventoryUtil.fetchRouteTables(new BasicSessionCredentials("awsAccessKey", "awsSecretKey", "sessionToken"), "skipRegions", "account","accountName").size(), is(1)); }
Example 2
Source File: AwsSubnetIgwExplorerTest.java From cloudbreak with Apache License 2.0 | 6 votes |
@Test public void testWithValidIgw() { DescribeRouteTablesResult describeRouteTablesResult = new DescribeRouteTablesResult(); RouteTable routeTable = new RouteTable(); Route route = new Route(); route.setGatewayId(GATEWAY_ID); route.setDestinationCidrBlock(OPEN_CIDR_BLOCK); routeTable.setRoutes(List.of(route)); RouteTableAssociation routeTableAssociation = new RouteTableAssociation(); routeTableAssociation.setSubnetId(SUBNET_ID); routeTable.setAssociations(List.of(routeTableAssociation)); describeRouteTablesResult.setRouteTables(List.of(routeTable)); boolean hasInternetGateway = awsSubnetIgwExplorer.hasInternetGatewayOfSubnet(describeRouteTablesResult, SUBNET_ID); assertTrue(hasInternetGateway); }
Example 3
Source File: AwsSubnetIgwExplorerTest.java From cloudbreak with Apache License 2.0 | 6 votes |
@Test public void testWithVirtualPrivateGateway() { DescribeRouteTablesResult describeRouteTablesResult = new DescribeRouteTablesResult(); RouteTable routeTable = new RouteTable(); Route route = new Route(); route.setGatewayId(VGW_GATEWAY_ID); route.setDestinationCidrBlock(OPEN_CIDR_BLOCK); routeTable.setRoutes(List.of(route)); RouteTableAssociation routeTableAssociation = new RouteTableAssociation(); routeTableAssociation.setSubnetId(SUBNET_ID); routeTable.setAssociations(List.of(routeTableAssociation)); describeRouteTablesResult.setRouteTables(List.of(routeTable)); boolean hasInternetGateway = awsSubnetIgwExplorer.hasInternetGatewayOfSubnet(describeRouteTablesResult, SUBNET_ID); assertFalse(hasInternetGateway); }
Example 4
Source File: AwsSubnetIgwExplorerTest.java From cloudbreak with Apache License 2.0 | 6 votes |
@Test public void testWithIgwButNoAssociation() { DescribeRouteTablesResult describeRouteTablesResult = new DescribeRouteTablesResult(); RouteTable routeTable = new RouteTable(); Route route = new Route(); route.setGatewayId(GATEWAY_ID); route.setDestinationCidrBlock(OPEN_CIDR_BLOCK); routeTable.setRoutes(List.of(route)); RouteTableAssociation routeTableAssociation = new RouteTableAssociation(); routeTableAssociation.setSubnetId(DIFFERENT_SUBNET_ID); routeTable.setAssociations(List.of(routeTableAssociation)); describeRouteTablesResult.setRouteTables(List.of(routeTable)); boolean hasInternetGateway = awsSubnetIgwExplorer.hasInternetGatewayOfSubnet(describeRouteTablesResult, SUBNET_ID); assertFalse(hasInternetGateway); }
Example 5
Source File: AwsSubnetIgwExplorerTest.java From cloudbreak with Apache License 2.0 | 5 votes |
@Test public void testWithAssociationButNoIgw() { DescribeRouteTablesResult describeRouteTablesResult = new DescribeRouteTablesResult(); RouteTable routeTable = new RouteTable(); Route route = new Route(); routeTable.setRoutes(List.of(route)); RouteTableAssociation routeTableAssociation = new RouteTableAssociation(); routeTableAssociation.setSubnetId(SUBNET_ID); routeTable.setAssociations(List.of(routeTableAssociation)); describeRouteTablesResult.setRouteTables(List.of(routeTable)); boolean hasInternetGateway = awsSubnetIgwExplorer.hasInternetGatewayOfSubnet(describeRouteTablesResult, SUBNET_ID); assertFalse(hasInternetGateway); }
Example 6
Source File: AwsSubnetIgwExplorerTest.java From cloudbreak with Apache License 2.0 | 5 votes |
@Test public void testWithNoAssociationAndNoIgw() { DescribeRouteTablesResult describeRouteTablesResult = new DescribeRouteTablesResult(); RouteTable routeTable = new RouteTable(); Route route = new Route(); routeTable.setRoutes(List.of(route)); RouteTableAssociation routeTableAssociation = new RouteTableAssociation(); routeTableAssociation.setSubnetId(DIFFERENT_SUBNET_ID); routeTable.setAssociations(List.of(routeTableAssociation)); describeRouteTablesResult.setRouteTables(List.of(routeTable)); boolean hasInternetGateway = awsSubnetIgwExplorer.hasInternetGatewayOfSubnet(describeRouteTablesResult, SUBNET_ID); assertFalse(hasInternetGateway); }
Example 7
Source File: AwsSubnetIgwExplorerTest.java From cloudbreak with Apache License 2.0 | 5 votes |
@Test public void testWithRouteButNoAssociations() { DescribeRouteTablesResult describeRouteTablesResult = new DescribeRouteTablesResult(); RouteTable routeTable = new RouteTable(); Route route = new Route(); routeTable.setRoutes(List.of(route)); describeRouteTablesResult.setRouteTables(List.of(routeTable)); boolean hasInternetGateway = awsSubnetIgwExplorer.hasInternetGatewayOfSubnet(describeRouteTablesResult, SUBNET_ID); assertFalse(hasInternetGateway); }