@Test public void testEvaluateDirectionOut_noBgpSessionProps() { Environment env = Environment.builder(C).setDirection(Direction.OUT).build(); _thrown.expectMessage("Expected BGP session properties"); INSTANCE.evaluate(env); }
@Override public long evaluate(Environment environment) { Direction direction = environment.getDirection(); if (direction == Direction.IN) { AsPath asPath; if (environment.getUseOutputAttributes() && environment.getOutputRoute() instanceof BgpRoute.Builder<?, ?>) { BgpRoute.Builder<?, ?> bgpRouteBuilder = (BgpRoute.Builder<?, ?>) environment.getOutputRoute(); asPath = bgpRouteBuilder.getAsPath(); } else if (environment.getReadFromIntermediateBgpAttributes()) { asPath = environment.getIntermediateBgpAttributes().getAsPath(); } else { assert environment.getOriginalRoute() instanceof BgpRoute; BgpRoute<?, ?> bgpRoute = (BgpRoute<?, ?>) environment.getOriginalRoute(); asPath = bgpRoute.getAsPath(); } List<AsSet> asSets = asPath.getAsSets(); assert !asSets.isEmpty(); SortedSet<Long> firstAsSetAsns = asSets.get(0).getAsns(); assert firstAsSetAsns.size() == 1; return firstAsSetAsns.first(); } assert direction == Direction.OUT; BgpSessionProperties sessionProps = environment.getBgpSessionProperties(); checkState(sessionProps != null, "Expected BGP session properties"); return sessionProps.getHeadAs(); }
AutoAs extends AsExpr { @Override public long evaluate(Environment environment) { Direction direction = environment.getDirection(); if (direction == Direction.IN) { AsPath asPath; if (environment.getUseOutputAttributes() && environment.getOutputRoute() instanceof BgpRoute.Builder<?, ?>) { BgpRoute.Builder<?, ?> bgpRouteBuilder = (BgpRoute.Builder<?, ?>) environment.getOutputRoute(); asPath = bgpRouteBuilder.getAsPath(); } else if (environment.getReadFromIntermediateBgpAttributes()) { asPath = environment.getIntermediateBgpAttributes().getAsPath(); } else { assert environment.getOriginalRoute() instanceof BgpRoute; BgpRoute<?, ?> bgpRoute = (BgpRoute<?, ?>) environment.getOriginalRoute(); asPath = bgpRoute.getAsPath(); } List<AsSet> asSets = asPath.getAsSets(); assert !asSets.isEmpty(); SortedSet<Long> firstAsSetAsns = asSets.get(0).getAsns(); assert firstAsSetAsns.size() == 1; return firstAsSetAsns.first(); } assert direction == Direction.OUT; BgpSessionProperties sessionProps = environment.getBgpSessionProperties(); checkState(sessionProps != null, "Expected BGP session properties"); return sessionProps.getHeadAs(); } }
AutoAs extends AsExpr { @Override public long evaluate(Environment environment) { Direction direction = environment.getDirection(); if (direction == Direction.IN) { AsPath asPath; if (environment.getUseOutputAttributes() && environment.getOutputRoute() instanceof BgpRoute.Builder<?, ?>) { BgpRoute.Builder<?, ?> bgpRouteBuilder = (BgpRoute.Builder<?, ?>) environment.getOutputRoute(); asPath = bgpRouteBuilder.getAsPath(); } else if (environment.getReadFromIntermediateBgpAttributes()) { asPath = environment.getIntermediateBgpAttributes().getAsPath(); } else { assert environment.getOriginalRoute() instanceof BgpRoute; BgpRoute<?, ?> bgpRoute = (BgpRoute<?, ?>) environment.getOriginalRoute(); asPath = bgpRoute.getAsPath(); } List<AsSet> asSets = asPath.getAsSets(); assert !asSets.isEmpty(); SortedSet<Long> firstAsSetAsns = asSets.get(0).getAsns(); assert firstAsSetAsns.size() == 1; return firstAsSetAsns.first(); } assert direction == Direction.OUT; BgpSessionProperties sessionProps = environment.getBgpSessionProperties(); checkState(sessionProps != null, "Expected BGP session properties"); return sessionProps.getHeadAs(); } private  AutoAs(); }
AutoAs extends AsExpr { @Override public long evaluate(Environment environment) { Direction direction = environment.getDirection(); if (direction == Direction.IN) { AsPath asPath; if (environment.getUseOutputAttributes() && environment.getOutputRoute() instanceof BgpRoute.Builder<?, ?>) { BgpRoute.Builder<?, ?> bgpRouteBuilder = (BgpRoute.Builder<?, ?>) environment.getOutputRoute(); asPath = bgpRouteBuilder.getAsPath(); } else if (environment.getReadFromIntermediateBgpAttributes()) { asPath = environment.getIntermediateBgpAttributes().getAsPath(); } else { assert environment.getOriginalRoute() instanceof BgpRoute; BgpRoute<?, ?> bgpRoute = (BgpRoute<?, ?>) environment.getOriginalRoute(); asPath = bgpRoute.getAsPath(); } List<AsSet> asSets = asPath.getAsSets(); assert !asSets.isEmpty(); SortedSet<Long> firstAsSetAsns = asSets.get(0).getAsns(); assert firstAsSetAsns.size() == 1; return firstAsSetAsns.first(); } assert direction == Direction.OUT; BgpSessionProperties sessionProps = environment.getBgpSessionProperties(); checkState(sessionProps != null, "Expected BGP session properties"); return sessionProps.getHeadAs(); } private  AutoAs(); static @Nonnull AutoAs instance(); @Override boolean equals(Object obj); @Override long evaluate(Environment environment); @Override int hashCode(); }
AutoAs extends AsExpr { @Override public long evaluate(Environment environment) { Direction direction = environment.getDirection(); if (direction == Direction.IN) { AsPath asPath; if (environment.getUseOutputAttributes() && environment.getOutputRoute() instanceof BgpRoute.Builder<?, ?>) { BgpRoute.Builder<?, ?> bgpRouteBuilder = (BgpRoute.Builder<?, ?>) environment.getOutputRoute(); asPath = bgpRouteBuilder.getAsPath(); } else if (environment.getReadFromIntermediateBgpAttributes()) { asPath = environment.getIntermediateBgpAttributes().getAsPath(); } else { assert environment.getOriginalRoute() instanceof BgpRoute; BgpRoute<?, ?> bgpRoute = (BgpRoute<?, ?>) environment.getOriginalRoute(); asPath = bgpRoute.getAsPath(); } List<AsSet> asSets = asPath.getAsSets(); assert !asSets.isEmpty(); SortedSet<Long> firstAsSetAsns = asSets.get(0).getAsns(); assert firstAsSetAsns.size() == 1; return firstAsSetAsns.first(); } assert direction == Direction.OUT; BgpSessionProperties sessionProps = environment.getBgpSessionProperties(); checkState(sessionProps != null, "Expected BGP session properties"); return sessionProps.getHeadAs(); } private  AutoAs(); static @Nonnull AutoAs instance(); @Override boolean equals(Object obj); @Override long evaluate(Environment environment); @Override int hashCode();  }