@Test public void testFindMyNetworkAclNoMatchingVpc() { Map<String, NetworkAcl> networkAcls = ImmutableMap.of( "aclId", new NetworkAcl("aclId", "novpc", ImmutableList.of(), ImmutableList.of(), true)); assertThat(findSubnetNetworkAcl(networkAcls, "vpc", "subnet"), equalTo(ImmutableList.of())); }
static List<NetworkAcl> findSubnetNetworkAcl( Map<String, NetworkAcl> networkAcls, String vpcId, String subnetId) { List<NetworkAcl> subnetAcls = networkAcls.values().stream() .filter(acl -> acl.getVpcId().equals(vpcId)) .filter( acl -> acl.getAssociations().stream() .map(NetworkAclAssociation::getSubnetId) .anyMatch(subnetId::equals)) .collect(ImmutableList.toImmutableList()); if (!subnetAcls.isEmpty()) { return subnetAcls; } return networkAcls.values().stream() .filter(acl -> acl.getVpcId().equals(vpcId) && acl.isDefault()) .collect(ImmutableList.toImmutableList()); }
Subnet implements AwsVpcEntity, Serializable { static List<NetworkAcl> findSubnetNetworkAcl( Map<String, NetworkAcl> networkAcls, String vpcId, String subnetId) { List<NetworkAcl> subnetAcls = networkAcls.values().stream() .filter(acl -> acl.getVpcId().equals(vpcId)) .filter( acl -> acl.getAssociations().stream() .map(NetworkAclAssociation::getSubnetId) .anyMatch(subnetId::equals)) .collect(ImmutableList.toImmutableList()); if (!subnetAcls.isEmpty()) { return subnetAcls; } return networkAcls.values().stream() .filter(acl -> acl.getVpcId().equals(vpcId) && acl.isDefault()) .collect(ImmutableList.toImmutableList()); } }
Subnet implements AwsVpcEntity, Serializable { static List<NetworkAcl> findSubnetNetworkAcl( Map<String, NetworkAcl> networkAcls, String vpcId, String subnetId) { List<NetworkAcl> subnetAcls = networkAcls.values().stream() .filter(acl -> acl.getVpcId().equals(vpcId)) .filter( acl -> acl.getAssociations().stream() .map(NetworkAclAssociation::getSubnetId) .anyMatch(subnetId::equals)) .collect(ImmutableList.toImmutableList()); if (!subnetAcls.isEmpty()) { return subnetAcls; } return networkAcls.values().stream() .filter(acl -> acl.getVpcId().equals(vpcId) && acl.isDefault()) .collect(ImmutableList.toImmutableList()); } Subnet(
      Prefix cidrBlock,
      String ownerId,
      String subnetArn,
      String subnetId,
      String vpcId,
      String availabilityZone,
      Map<String, String> tags); }
Subnet implements AwsVpcEntity, Serializable { static List<NetworkAcl> findSubnetNetworkAcl( Map<String, NetworkAcl> networkAcls, String vpcId, String subnetId) { List<NetworkAcl> subnetAcls = networkAcls.values().stream() .filter(acl -> acl.getVpcId().equals(vpcId)) .filter( acl -> acl.getAssociations().stream() .map(NetworkAclAssociation::getSubnetId) .anyMatch(subnetId::equals)) .collect(ImmutableList.toImmutableList()); if (!subnetAcls.isEmpty()) { return subnetAcls; } return networkAcls.values().stream() .filter(acl -> acl.getVpcId().equals(vpcId) && acl.isDefault()) .collect(ImmutableList.toImmutableList()); } Subnet(
      Prefix cidrBlock,
      String ownerId,
      String subnetArn,
      String subnetId,
      String vpcId,
      String availabilityZone,
      Map<String, String> tags); @Nonnull Prefix getCidrBlock(); @Nonnull String getOwnerId(); @Nonnull String getSubnetArn(); @Override String getId(); @Nonnull String getVpcId(); @Nonnull String getAvailabilityZone(); Optional<NetworkAcl> getNetworkAcl(Region region); @Override boolean equals(Object o); @Override int hashCode(); static String nodeName(String subnetId); static String instancesInterfaceName(String subnetId); }
Subnet implements AwsVpcEntity, Serializable { static List<NetworkAcl> findSubnetNetworkAcl( Map<String, NetworkAcl> networkAcls, String vpcId, String subnetId) { List<NetworkAcl> subnetAcls = networkAcls.values().stream() .filter(acl -> acl.getVpcId().equals(vpcId)) .filter( acl -> acl.getAssociations().stream() .map(NetworkAclAssociation::getSubnetId) .anyMatch(subnetId::equals)) .collect(ImmutableList.toImmutableList()); if (!subnetAcls.isEmpty()) { return subnetAcls; } return networkAcls.values().stream() .filter(acl -> acl.getVpcId().equals(vpcId) && acl.isDefault()) .collect(ImmutableList.toImmutableList()); } Subnet(
      Prefix cidrBlock,
      String ownerId,
      String subnetArn,
      String subnetId,
      String vpcId,
      String availabilityZone,
      Map<String, String> tags); @Nonnull Prefix getCidrBlock(); @Nonnull String getOwnerId(); @Nonnull String getSubnetArn(); @Override String getId(); @Nonnull String getVpcId(); @Nonnull String getAvailabilityZone(); Optional<NetworkAcl> getNetworkAcl(Region region); @Override boolean equals(Object o); @Override int hashCode(); static String nodeName(String subnetId); static String instancesInterfaceName(String subnetId);  }