private static long toCommunityLong(Sc_literalContext ctx) { String text = ctx.COMMUNITY_LITERAL().getText(); return CommonUtil.communityStringToLong(text); }
@Test public void testCommunityStringToLong() { assertThat(communityStringToLong("0:0"), equalTo(0L)); assertThat(communityStringToLong("65535:65535"), equalTo(4294967295L)); }
@Override public void exitRoa_community(Roa_communityContext ctx) { long community = CommonUtil.communityStringToLong(ctx.COMMUNITY_LITERAL().getText()); _configuration.getAllStandardCommunities().add(community); _currentAggregateRoute.getCommunities().add(community); }
@Test(expected = ArrayIndexOutOfBoundsException.class) public void testCommunityStringToLongInvalidInput() { communityStringToLong("111"); }
@Test(expected = NumberFormatException.class) public void testCommunityStringToLongNoInput() { communityStringToLong(""); }
@Test public void testMatchedCommunities() { RegexCommunitySet l = new RegexCommunitySet("1:1"); Set<Long> communityCandidates = ImmutableSet.of(communityStringToLong("1:1"), 2L); assertThat( l, matchedCommunities( null, communityCandidates, ImmutableSet.of(communityStringToLong("1:1")))); } }
@Test public void testMatchCommunities() { Set<Long> matchingCommunitySetCandidate1 = ImmutableSet.of(communityStringToLong("1:1"), 2L); Set<Long> matchingCommunitySetCandidate2 = ImmutableSet.of(communityStringToLong("11:11")); Set<Long> nonMatchingCommunitySetCandidate = ImmutableSet.of(2L); RegexCommunitySet r = new RegexCommunitySet("1:1"); assertThat(r, matchCommunities(null, matchingCommunitySetCandidate1)); assertThat(r, matchCommunities(null, matchingCommunitySetCandidate2)); assertThat(r, not(matchCommunities(null, nonMatchingCommunitySetCandidate))); }
@Test public void testMatchCommunities() { Set<Long> matchingCommunitySetCandidate1 = ImmutableSet.of(communityStringToLong("1:1"), communityStringToLong("2:2")); Set<Long> matchingCommunitySetCandidate2 = ImmutableSet.of(communityStringToLong("1:1")); Set<Long> nonMatchingCommunitySetCandidate = ImmutableSet.of(communityStringToLong("2:2")); CommunityHalvesExpr expr = new CommunityHalvesExpr(new LiteralCommunityHalf(1), new LiteralCommunityHalf(1)); assertThat(expr, matchCommunities(null, matchingCommunitySetCandidate1)); assertThat(expr, matchCommunities(null, matchingCommunitySetCandidate2)); assertThat(expr, not(matchCommunities(null, nonMatchingCommunitySetCandidate))); }
@Test(expected = IllegalArgumentException.class) @Ignore("https://github.com/batfish/batfish/issues/2103") public void testCommunityStringHighTooBig() { communityStringToLong("65537:1"); }
@Test(expected = IllegalArgumentException.class) @Ignore("https://github.com/batfish/batfish/issues/2103") public void testCommunityStringLowTooBig() { communityStringToLong("1:65537"); }
@Test public void testMatchAnyCommunity() { RegexCommunitySet l = new RegexCommunitySet("1:1"); Set<Long> communityCandidates = ImmutableSet.of(communityStringToLong("1:1"), 2L); assertThat(l, matchAnyCommunity(null, communityCandidates)); }
@Test public void testMatchCommunity() { RegexCommunitySet l = new RegexCommunitySet("1:1"); assertThat(l, matchCommunity(null, communityStringToLong("1:1"))); assertThat(l, not(matchCommunity(null, 2L))); }
@Test public void testMatchedCommunities() { CommunityHalvesExpr expr = new CommunityHalvesExpr(new LiteralCommunityHalf(1), new LiteralCommunityHalf(1)); Set<Long> communityCandidates = ImmutableSet.of(communityStringToLong("1:1"), 2L); assertThat( expr, matchedCommunities( null, communityCandidates, ImmutableSet.of(communityStringToLong("1:1")))); } }
@Test public void testMatchCommunity() { CommunityHalvesExpr expr = new CommunityHalvesExpr(new LiteralCommunityHalf(1), new LiteralCommunityHalf(1)); assertThat(expr, matchCommunity(null, communityStringToLong("1:1"))); assertThat(expr, not(matchCommunity(null, 2L))); }
@Test public void testMatchAnyCommunity() { CommunityHalvesExpr expr = new CommunityHalvesExpr(new LiteralCommunityHalf(1), new LiteralCommunityHalf(1)); Set<Long> communityCandidates = ImmutableSet.of(communityStringToLong("1:1"), 2L); assertThat(expr, matchAnyCommunity(null, communityCandidates)); }
_currentCommunityList.getLines().add(new CommunityListLine(text)); if (text.matches("[0-9]+:[0-9]+")) { long communityVal = CommonUtil.communityStringToLong(text); _configuration.getAllStandardCommunities().add(communityVal);