@Test public void testHasAsPathLoop() { BgpRouteEntry bgpRouteEntry = generateBgpRouteEntry(); for (int i = 1; i <= 6; i++) { assertThat(bgpRouteEntry.hasAsPathLoop(i), is(true)); } assertThat(bgpRouteEntry.hasAsPathLoop(500), is(false)); }
boolean hasAsPathLoop(long localAsNumber) { for (PathSegment pathSegment : asPath.getPathSegments()) { for (Long asNumber : pathSegment.getSegmentAsNumbers()) { if (asNumber.equals(localAsNumber)) { return true; } } } return false; }
BgpRouteEntry extends RouteEntry { boolean hasAsPathLoop(long localAsNumber) { for (PathSegment pathSegment : asPath.getPathSegments()) { for (Long asNumber : pathSegment.getSegmentAsNumbers()) { if (asNumber.equals(localAsNumber)) { return true; } } } return false; } }
BgpRouteEntry extends RouteEntry { boolean hasAsPathLoop(long localAsNumber) { for (PathSegment pathSegment : asPath.getPathSegments()) { for (Long asNumber : pathSegment.getSegmentAsNumbers()) { if (asNumber.equals(localAsNumber)) { return true; } } } return false; } BgpRouteEntry(BgpSession bgpSession, IpPrefix prefix,
                         IpAddress nextHop, byte origin,
                         BgpRouteEntry.AsPath asPath, long localPref); }
BgpRouteEntry extends RouteEntry { boolean hasAsPathLoop(long localAsNumber) { for (PathSegment pathSegment : asPath.getPathSegments()) { for (Long asNumber : pathSegment.getSegmentAsNumbers()) { if (asNumber.equals(localAsNumber)) { return true; } } } return false; } BgpRouteEntry(BgpSession bgpSession, IpPrefix prefix,
                         IpAddress nextHop, byte origin,
                         BgpRouteEntry.AsPath asPath, long localPref); BgpSession getBgpSession(); byte getOrigin(); BgpRouteEntry.AsPath getAsPath(); long getLocalPref(); long getMultiExitDisc(); @Override boolean equals(Object other); @Override int hashCode(); @Override String toString(); }
BgpRouteEntry extends RouteEntry { boolean hasAsPathLoop(long localAsNumber) { for (PathSegment pathSegment : asPath.getPathSegments()) { for (Long asNumber : pathSegment.getSegmentAsNumbers()) { if (asNumber.equals(localAsNumber)) { return true; } } } return false; } BgpRouteEntry(BgpSession bgpSession, IpPrefix prefix,
                         IpAddress nextHop, byte origin,
                         BgpRouteEntry.AsPath asPath, long localPref); BgpSession getBgpSession(); byte getOrigin(); BgpRouteEntry.AsPath getAsPath(); long getLocalPref(); long getMultiExitDisc(); @Override boolean equals(Object other); @Override int hashCode(); @Override String toString();  }