@Test public void testPrependWithIntermediateAttributes() { List<AsExpr> prepend = Lists.newArrayList(new ExplicitAs(1), new ExplicitAs(2)); PrependAsPath operation = new PrependAsPath(new LiteralAsList(prepend)); Bgpv4Route.Builder outputRoute = new Bgpv4Route.Builder(); outputRoute.setAsPath(ofSingletonAsSets(3L, 4L)); Bgpv4Route.Builder intermediateAttributes = new Bgpv4Route.Builder(); intermediateAttributes.setAsPath(ofSingletonAsSets(5L, 6L)); Environment env = newTestEnvironment(outputRoute); env.setIntermediateBgpAttributes(intermediateAttributes); env.setWriteToIntermediateBgpAttributes(true); operation.execute(env); assertThat(outputRoute.getAsPath(), equalTo(ofSingletonAsSets(1L, 2L, 3L, 4L))); assertThat(intermediateAttributes.getAsPath(), equalTo(ofSingletonAsSets(1L, 2L, 5L, 6L))); }
@Override public Result execute(Environment environment) { List<Long> toPrepend = _expr.evaluate(environment); List<AsSet> newAsPaths = toPrepend.stream().map(AsSet::of).collect(Collectors.toList()); BgpRoute.Builder<?, ?> bgpRouteBuilder = (BgpRoute.Builder<?, ?>) environment.getOutputRoute(); bgpRouteBuilder.setAsPath( AsPath.of( ImmutableList.<AsSet>builder() .addAll(newAsPaths) .addAll(bgpRouteBuilder.getAsPath().getAsSets()) .build())); if (environment.getWriteToIntermediateBgpAttributes()) { BgpRoute.Builder<?, ?> ir = environment.getIntermediateBgpAttributes(); ir.setAsPath( AsPath.of( ImmutableList.<AsSet>builder() .addAll(newAsPaths) .addAll(ir.getAsPath().getAsSets()) .build())); } Result result = new Result(); return result; }
PrependAsPath extends Statement { @Override public Result execute(Environment environment) { List<Long> toPrepend = _expr.evaluate(environment); List<AsSet> newAsPaths = toPrepend.stream().map(AsSet::of).collect(Collectors.toList()); BgpRoute.Builder<?, ?> bgpRouteBuilder = (BgpRoute.Builder<?, ?>) environment.getOutputRoute(); bgpRouteBuilder.setAsPath( AsPath.of( ImmutableList.<AsSet>builder() .addAll(newAsPaths) .addAll(bgpRouteBuilder.getAsPath().getAsSets()) .build())); if (environment.getWriteToIntermediateBgpAttributes()) { BgpRoute.Builder<?, ?> ir = environment.getIntermediateBgpAttributes(); ir.setAsPath( AsPath.of( ImmutableList.<AsSet>builder() .addAll(newAsPaths) .addAll(ir.getAsPath().getAsSets()) .build())); } Result result = new Result(); return result; } }
PrependAsPath extends Statement { @Override public Result execute(Environment environment) { List<Long> toPrepend = _expr.evaluate(environment); List<AsSet> newAsPaths = toPrepend.stream().map(AsSet::of).collect(Collectors.toList()); BgpRoute.Builder<?, ?> bgpRouteBuilder = (BgpRoute.Builder<?, ?>) environment.getOutputRoute(); bgpRouteBuilder.setAsPath( AsPath.of( ImmutableList.<AsSet>builder() .addAll(newAsPaths) .addAll(bgpRouteBuilder.getAsPath().getAsSets()) .build())); if (environment.getWriteToIntermediateBgpAttributes()) { BgpRoute.Builder<?, ?> ir = environment.getIntermediateBgpAttributes(); ir.setAsPath( AsPath.of( ImmutableList.<AsSet>builder() .addAll(newAsPaths) .addAll(ir.getAsPath().getAsSets()) .build())); } Result result = new Result(); return result; } PrependAsPath(AsPathListExpr expr); }
PrependAsPath extends Statement { @Override public Result execute(Environment environment) { List<Long> toPrepend = _expr.evaluate(environment); List<AsSet> newAsPaths = toPrepend.stream().map(AsSet::of).collect(Collectors.toList()); BgpRoute.Builder<?, ?> bgpRouteBuilder = (BgpRoute.Builder<?, ?>) environment.getOutputRoute(); bgpRouteBuilder.setAsPath( AsPath.of( ImmutableList.<AsSet>builder() .addAll(newAsPaths) .addAll(bgpRouteBuilder.getAsPath().getAsSets()) .build())); if (environment.getWriteToIntermediateBgpAttributes()) { BgpRoute.Builder<?, ?> ir = environment.getIntermediateBgpAttributes(); ir.setAsPath( AsPath.of( ImmutableList.<AsSet>builder() .addAll(newAsPaths) .addAll(ir.getAsPath().getAsSets()) .build())); } Result result = new Result(); return result; } PrependAsPath(AsPathListExpr expr); @Override T accept(StatementVisitor<T, U> visitor, U arg); @Override boolean equals(Object obj); @Override Result execute(Environment environment); @JsonProperty(PROP_EXPR) @Nonnull AsPathListExpr getExpr(); @Override int hashCode(); void setExpr(AsPathListExpr expr); }
PrependAsPath extends Statement { @Override public Result execute(Environment environment) { List<Long> toPrepend = _expr.evaluate(environment); List<AsSet> newAsPaths = toPrepend.stream().map(AsSet::of).collect(Collectors.toList()); BgpRoute.Builder<?, ?> bgpRouteBuilder = (BgpRoute.Builder<?, ?>) environment.getOutputRoute(); bgpRouteBuilder.setAsPath( AsPath.of( ImmutableList.<AsSet>builder() .addAll(newAsPaths) .addAll(bgpRouteBuilder.getAsPath().getAsSets()) .build())); if (environment.getWriteToIntermediateBgpAttributes()) { BgpRoute.Builder<?, ?> ir = environment.getIntermediateBgpAttributes(); ir.setAsPath( AsPath.of( ImmutableList.<AsSet>builder() .addAll(newAsPaths) .addAll(ir.getAsPath().getAsSets()) .build())); } Result result = new Result(); return result; } PrependAsPath(AsPathListExpr expr); @Override T accept(StatementVisitor<T, U> visitor, U arg); @Override boolean equals(Object obj); @Override Result execute(Environment environment); @JsonProperty(PROP_EXPR) @Nonnull AsPathListExpr getExpr(); @Override int hashCode(); void setExpr(AsPathListExpr expr);  }