Java Code Examples for com.amazonaws.services.ec2.model.RouteTable#setAssociations()

The following examples show how to use com.amazonaws.services.ec2.model.RouteTable#setAssociations() . 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: AwsSubnetIgwExplorerTest.java    From cloudbreak with Apache License 2.0 6 votes vote down vote up
@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 2
Source File: AwsSubnetIgwExplorerTest.java    From cloudbreak with Apache License 2.0 6 votes vote down vote up
@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 3
Source File: AwsSubnetIgwExplorerTest.java    From cloudbreak with Apache License 2.0 6 votes vote down vote up
@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 4
Source File: AwsSubnetIgwExplorerTest.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@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 5
Source File: AwsSubnetIgwExplorerTest.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@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);
}