@Test public void testMergeIpAccessListLines() { List<ExprAclLine> lines = ImmutableList.of( new ExprAclLine( LineAction.PERMIT, new MatchHeaderSpace( HeaderSpace.builder().setSrcIps(Ip.parse("1.1.1.1").toIpSpace()).build()), "match1", TraceElement.of("trace of match1"))); MatchHeaderSpace conj = new MatchHeaderSpace( HeaderSpace.builder().setDstIps(Ip.parse("2.2.2.2").toIpSpace()).build()); List<AclLine> aclLines = mergeIpAccessListLines(lines, conj); assertThat(aclLines, hasSize(1)); assertThat(aclLines.get(0).getTraceElement(), equalTo(TraceElement.of("trace of match1"))); }
@VisibleForTesting static List<AclLine> mergeIpAccessListLines( List<ExprAclLine> lines, @Nullable AclLineMatchExpr conjunctMatchExpr) { if (conjunctMatchExpr == null) { return ImmutableList.copyOf(lines); } return lines.stream() .map( l -> new ExprAclLine( l.getAction(), new AndMatchExpr(ImmutableList.of(l.getMatchCondition(), conjunctMatchExpr)), l.getName(), l.getTraceElement())) .collect(ImmutableList.toImmutableList()); }
JuniperConfiguration extends VendorConfiguration { @VisibleForTesting static List<AclLine> mergeIpAccessListLines( List<ExprAclLine> lines, @Nullable AclLineMatchExpr conjunctMatchExpr) { if (conjunctMatchExpr == null) { return ImmutableList.copyOf(lines); } return lines.stream() .map( l -> new ExprAclLine( l.getAction(), new AndMatchExpr(ImmutableList.of(l.getMatchCondition(), conjunctMatchExpr)), l.getName(), l.getTraceElement())) .collect(ImmutableList.toImmutableList()); } }
JuniperConfiguration extends VendorConfiguration { @VisibleForTesting static List<AclLine> mergeIpAccessListLines( List<ExprAclLine> lines, @Nullable AclLineMatchExpr conjunctMatchExpr) { if (conjunctMatchExpr == null) { return ImmutableList.copyOf(lines); } return lines.stream() .map( l -> new ExprAclLine( l.getAction(), new AndMatchExpr(ImmutableList.of(l.getMatchCondition(), conjunctMatchExpr)), l.getName(), l.getTraceElement())) .collect(ImmutableList.toImmutableList()); } JuniperConfiguration(); }
JuniperConfiguration extends VendorConfiguration { @VisibleForTesting static List<AclLine> mergeIpAccessListLines( List<ExprAclLine> lines, @Nullable AclLineMatchExpr conjunctMatchExpr) { if (conjunctMatchExpr == null) { return ImmutableList.copyOf(lines); } return lines.stream() .map( l -> new ExprAclLine( l.getAction(), new AndMatchExpr(ImmutableList.of(l.getMatchCondition(), conjunctMatchExpr)), l.getName(), l.getTraceElement())) .collect(ImmutableList.toImmutableList()); } JuniperConfiguration(); static @Nonnull String computeFirewallFilterTermName(
      @Nonnull String filterName, @Nonnull String termName); static @Nonnull String computeSecurityPolicyTermName(
      @Nonnull String policyName, @Nonnull String termName); @VisibleForTesting static TraceElement matchingFirewallFilter(String filename, String filterName); @VisibleForTesting static TraceElement matchingFirewallFilterTerm(
      String filename, String filterName, String termName); @VisibleForTesting static TraceElement matchingSecurityPolicyTerm(
      String filename, String policyName, String termName); static String computePeerExportPolicyName(Prefix remoteAddress); static String computeOspfExportPolicyName(String vrfName); Map<String, NodeDevice> getNodeDevices(); @Override void setVendor(ConfigurationFormat format); static String computeContributorRouteFilterListName(Prefix prefix); static String computeAggregatedRouteGenerationPolicyName(Prefix prefix); static String computeGeneratedRouteGenerationPolicyName(Prefix prefix); static String computeIsisExportPolicyName(String routingInstanceName); @Override List<Configuration> toVendorIndependentConfigurations(); static String computeLogicalSystemDefaultHostname(
      String masterHostname, String logicalSystemName); @Nonnull Map<String, LogicalSystem> getLogicalSystems(); LogicalSystem getMasterLogicalSystem(); @Override String getHostname(); @Override void setHostname(String hostname); }
JuniperConfiguration extends VendorConfiguration { @VisibleForTesting static List<AclLine> mergeIpAccessListLines( List<ExprAclLine> lines, @Nullable AclLineMatchExpr conjunctMatchExpr) { if (conjunctMatchExpr == null) { return ImmutableList.copyOf(lines); } return lines.stream() .map( l -> new ExprAclLine( l.getAction(), new AndMatchExpr(ImmutableList.of(l.getMatchCondition(), conjunctMatchExpr)), l.getName(), l.getTraceElement())) .collect(ImmutableList.toImmutableList()); } JuniperConfiguration(); static @Nonnull String computeFirewallFilterTermName(
      @Nonnull String filterName, @Nonnull String termName); static @Nonnull String computeSecurityPolicyTermName(
      @Nonnull String policyName, @Nonnull String termName); @VisibleForTesting static TraceElement matchingFirewallFilter(String filename, String filterName); @VisibleForTesting static TraceElement matchingFirewallFilterTerm(
      String filename, String filterName, String termName); @VisibleForTesting static TraceElement matchingSecurityPolicyTerm(
      String filename, String policyName, String termName); static String computePeerExportPolicyName(Prefix remoteAddress); static String computeOspfExportPolicyName(String vrfName); Map<String, NodeDevice> getNodeDevices(); @Override void setVendor(ConfigurationFormat format); static String computeContributorRouteFilterListName(Prefix prefix); static String computeAggregatedRouteGenerationPolicyName(Prefix prefix); static String computeGeneratedRouteGenerationPolicyName(Prefix prefix); static String computeIsisExportPolicyName(String routingInstanceName); @Override List<Configuration> toVendorIndependentConfigurations(); static String computeLogicalSystemDefaultHostname(
      String masterHostname, String logicalSystemName); @Nonnull Map<String, LogicalSystem> getLogicalSystems(); LogicalSystem getMasterLogicalSystem(); @Override String getHostname(); @Override void setHostname(String hostname); static final String ACL_NAME_COMBINED_INCOMING; static final String ACL_NAME_GLOBAL_POLICY; static final String ACL_NAME_SCREEN; static final String ACL_NAME_SCREEN_INTERFACE; static final String ACL_NAME_SCREEN_ZONE; static final String ACL_NAME_SECURITY_POLICY; @VisibleForTesting static final int DEFAULT_ISIS_COST; }