@Test public void testToAsPathAccessList() { long permitted = 11111; long denied = 22222; IpAsPathAccessList asPathAccessList = new IpAsPathAccessList("name"); asPathAccessList.addLine(new IpAsPathAccessListLine(LineAction.DENY, denied)); asPathAccessList.addLine(new IpAsPathAccessListLine(LineAction.PERMIT, permitted)); AsPathAccessList viList = toAsPathAccessList(asPathAccessList); viList = SerializationUtils.clone(viList); List<AsPathAccessListLine> expectedViLines = ImmutableList.of( new AsPathAccessListLine(LineAction.DENY, String.format("(^| )%s($| )", denied)), new AsPathAccessListLine(LineAction.PERMIT, String.format("(^| )%s($| )", permitted))); assertThat(viList, equalTo(new AsPathAccessList("name", expectedViLines))); long other = 33333; assertTrue(viList.permits(AsPath.ofSingletonAsSets(permitted))); assertTrue(viList.permits(AsPath.ofSingletonAsSets(permitted, other))); assertTrue(viList.permits(AsPath.ofSingletonAsSets(other, permitted))); assertTrue(viList.permits(AsPath.ofSingletonAsSets(other, permitted, other))); assertFalse(viList.permits(AsPath.ofSingletonAsSets(denied))); assertFalse(viList.permits(AsPath.ofSingletonAsSets(denied, permitted))); assertFalse(viList.permits(AsPath.ofSingletonAsSets(permitted, denied))); assertFalse(viList.permits(AsPath.ofSingletonAsSets(permitted, denied, permitted))); assertFalse(viList.permits(AsPath.ofSingletonAsSets(other))); }
@VisibleForTesting static @Nonnull AsPathAccessList toAsPathAccessList(IpAsPathAccessList asPathAccessList) { String name = asPathAccessList.getName(); List<AsPathAccessListLine> lines = asPathAccessList.getLines().stream() .map( line -> new AsPathAccessListLine( line.getAction(), String.format("(^| )%s($| )", line.getAsNum()))) .collect(ImmutableList.toImmutableList()); return new AsPathAccessList(name, lines); }
CumulusConversions { @VisibleForTesting static @Nonnull AsPathAccessList toAsPathAccessList(IpAsPathAccessList asPathAccessList) { String name = asPathAccessList.getName(); List<AsPathAccessListLine> lines = asPathAccessList.getLines().stream() .map( line -> new AsPathAccessListLine( line.getAction(), String.format("(^| )%s($| )", line.getAsNum()))) .collect(ImmutableList.toImmutableList()); return new AsPathAccessList(name, lines); } }
CumulusConversions { @VisibleForTesting static @Nonnull AsPathAccessList toAsPathAccessList(IpAsPathAccessList asPathAccessList) { String name = asPathAccessList.getName(); List<AsPathAccessListLine> lines = asPathAccessList.getLines().stream() .map( line -> new AsPathAccessListLine( line.getAction(), String.format("(^| )%s($| )", line.getAsNum()))) .collect(ImmutableList.toImmutableList()); return new AsPathAccessList(name, lines); }  }
CumulusConversions { @VisibleForTesting static @Nonnull AsPathAccessList toAsPathAccessList(IpAsPathAccessList asPathAccessList) { String name = asPathAccessList.getName(); List<AsPathAccessListLine> lines = asPathAccessList.getLines().stream() .map( line -> new AsPathAccessListLine( line.getAction(), String.format("(^| )%s($| )", line.getAsNum()))) .collect(ImmutableList.toImmutableList()); return new AsPathAccessList(name, lines); }  static @Nonnull String computeBgpCommonExportPolicyName(String vrfName); @VisibleForTesting static @Nonnull String computeBgpPeerExportPolicyName(
      String vrfName, String peerInterface); static @Nonnull String computeBgpPeerImportPolicyName(String vrf, String peer); static String computeBgpGenerationPolicyName(boolean ipv4, String vrfName, String prefix); static String computeMatchSuppressedSummaryOnlyPolicyName(String vrfName); static String computeOspfExportPolicyName(String vrfName); }
CumulusConversions { @VisibleForTesting static @Nonnull AsPathAccessList toAsPathAccessList(IpAsPathAccessList asPathAccessList) { String name = asPathAccessList.getName(); List<AsPathAccessListLine> lines = asPathAccessList.getLines().stream() .map( line -> new AsPathAccessListLine( line.getAction(), String.format("(^| )%s($| )", line.getAsNum()))) .collect(ImmutableList.toImmutableList()); return new AsPathAccessList(name, lines); }  static @Nonnull String computeBgpCommonExportPolicyName(String vrfName); @VisibleForTesting static @Nonnull String computeBgpPeerExportPolicyName(
      String vrfName, String peerInterface); static @Nonnull String computeBgpPeerImportPolicyName(String vrf, String peer); static String computeBgpGenerationPolicyName(boolean ipv4, String vrfName, String prefix); static String computeMatchSuppressedSummaryOnlyPolicyName(String vrfName); static String computeOspfExportPolicyName(String vrfName); static final int DEFAULT_STATIC_ROUTE_ADMINISTRATIVE_DISTANCE; static final int DEFAULT_STATIC_ROUTE_METRIC; static final Ip CLAG_LINK_LOCAL_IP; static final long DEFAULT_MAX_MED; static final double SPEED_CONVERSION_FACTOR; static final double DEFAULT_LOOPBACK_BANDWIDTH; static final double DEFAULT_PORT_BANDWIDTH; }