@Test public void testExecute() { NetworkFactory nf = new NetworkFactory(); Configuration c = nf.configurationBuilder() .setHostname("c1") .setConfigurationFormat(ConfigurationFormat.CISCO_IOS) .build(); nf.vrfBuilder().setName("vrf").setOwner(c).build(); AddCommunity ac = new AddCommunity(new LiteralCommunity(StandardCommunity.of(1L))); ac.execute(Environment.builder(c).setOutputRoute(ConnectedRoute.builder()).build()); Environment e = Environment.builder(c).setOutputRoute(Bgpv4Route.builder()).build(); ac.execute(e); assertThat( ((Bgpv4Route.Builder) e.getOutputRoute()).getCommunities(), contains(StandardCommunity.of(1L))); }
@Override public Result execute(Environment environment) { if (environment.getOutputRoute() instanceof BgpRoute.Builder<?, ?>) { BgpRoute.Builder<?, ?> bgpRoute = (BgpRoute.Builder<?, ?>) environment.getOutputRoute(); Set<Community> communities = _expr.asLiteralCommunities(environment); bgpRoute.addCommunities(communities); if (environment.getWriteToIntermediateBgpAttributes()) { environment.getIntermediateBgpAttributes().addCommunities(communities); } } return new Result(); }
AddCommunity extends Statement { @Override public Result execute(Environment environment) { if (environment.getOutputRoute() instanceof BgpRoute.Builder<?, ?>) { BgpRoute.Builder<?, ?> bgpRoute = (BgpRoute.Builder<?, ?>) environment.getOutputRoute(); Set<Community> communities = _expr.asLiteralCommunities(environment); bgpRoute.addCommunities(communities); if (environment.getWriteToIntermediateBgpAttributes()) { environment.getIntermediateBgpAttributes().addCommunities(communities); } } return new Result(); } }
AddCommunity extends Statement { @Override public Result execute(Environment environment) { if (environment.getOutputRoute() instanceof BgpRoute.Builder<?, ?>) { BgpRoute.Builder<?, ?> bgpRoute = (BgpRoute.Builder<?, ?>) environment.getOutputRoute(); Set<Community> communities = _expr.asLiteralCommunities(environment); bgpRoute.addCommunities(communities); if (environment.getWriteToIntermediateBgpAttributes()) { environment.getIntermediateBgpAttributes().addCommunities(communities); } } return new Result(); } AddCommunity(CommunitySetExpr expr); }
AddCommunity extends Statement { @Override public Result execute(Environment environment) { if (environment.getOutputRoute() instanceof BgpRoute.Builder<?, ?>) { BgpRoute.Builder<?, ?> bgpRoute = (BgpRoute.Builder<?, ?>) environment.getOutputRoute(); Set<Community> communities = _expr.asLiteralCommunities(environment); bgpRoute.addCommunities(communities); if (environment.getWriteToIntermediateBgpAttributes()) { environment.getIntermediateBgpAttributes().addCommunities(communities); } } return new Result(); } AddCommunity(CommunitySetExpr expr); @Override T accept(StatementVisitor<T, U> visitor, U arg); @Override boolean equals(@Nullable Object o); @Override int hashCode(); @Override Result execute(Environment environment); @JsonProperty(PROP_EXPR) CommunitySetExpr getExpr(); }
AddCommunity extends Statement { @Override public Result execute(Environment environment) { if (environment.getOutputRoute() instanceof BgpRoute.Builder<?, ?>) { BgpRoute.Builder<?, ?> bgpRoute = (BgpRoute.Builder<?, ?>) environment.getOutputRoute(); Set<Community> communities = _expr.asLiteralCommunities(environment); bgpRoute.addCommunities(communities); if (environment.getWriteToIntermediateBgpAttributes()) { environment.getIntermediateBgpAttributes().addCommunities(communities); } } return new Result(); } AddCommunity(CommunitySetExpr expr); @Override T accept(StatementVisitor<T, U> visitor, U arg); @Override boolean equals(@Nullable Object o); @Override int hashCode(); @Override Result execute(Environment environment); @JsonProperty(PROP_EXPR) CommunitySetExpr getExpr();  }