@@ -0,0 +1,2457 @@
+package org.batfish.datamodel.routing_policy.statement;%0A%0Aimport static org.hamcrest.Matchers.equalTo;%0Aimport static org.junit.Assert.assertThat;%0A%0Aimport com.google.common.collect.ImmutableSortedSet;%0Aimport com.google.common.collect.Lists;%0Aimport java.util.Arrays;%0Aimport java.util.List;%0Aimport java.util.SortedSet;%0Aimport java.util.stream.Collectors;%0Aimport org.batfish.datamodel.BgpRoute;%0Aimport org.batfish.datamodel.Configuration;%0Aimport org.batfish.datamodel.routing_policy.Environment;%0Aimport org.batfish.datamodel.routing_policy.expr.AsExpr;%0Aimport org.batfish.datamodel.routing_policy.expr.ExplicitAs;%0Aimport org.batfish.datamodel.routing_policy.expr.LiteralAsList;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.junit.runners.JUnit4;%0A%0A@RunWith(JUnit4.class)%0Apublic class PrependAsPathTest %7B%0A%0A  private static Environment newTestEnvironment(BgpRoute.Builder outputRoute) %7B%0A    Configuration c = new Configuration(%22host%22);%0A    return new Environment(c, %22vrf%22, null, null, outputRoute, null);%0A  %7D%0A%0A  private static List%3CSortedSet%3CInteger%3E%3E mkAsPath(Integer... explicitAs) %7B%0A    return Arrays.stream(explicitAs).map(ImmutableSortedSet::of).collect(Collectors.toList());%0A  %7D%0A%0A  @Test%0A  public void testPrepend() %7B%0A    List%3CAsExpr%3E prepend = Lists.newArrayList(new ExplicitAs(1), new ExplicitAs(2));%0A    PrependAsPath operation = new PrependAsPath(new LiteralAsList(prepend));%0A    BgpRoute.Builder builder = new BgpRoute.Builder();%0A    builder.setAsPath(mkAsPath(3, 4));%0A    Environment env = newTestEnvironment(builder);%0A%0A    operation.execute(env);%0A    assertThat(builder.getAsPath(), equalTo(mkAsPath(1, 2, 3, 4)));%0A  %7D%0A%0A  @Test%0A  public void testPrependWithIntermediateAttributes() %7B%0A    List%3CAsExpr%3E prepend = Lists.newArrayList(new ExplicitAs(1), new ExplicitAs(2));%0A    PrependAsPath operation = new PrependAsPath(new LiteralAsList(prepend));%0A    BgpRoute.Builder outputRoute = new BgpRoute.Builder();%0A    outputRoute.setAsPath(mkAsPath(3, 4));%0A%0A    BgpRoute.Builder intermediateAttributes = new BgpRoute.Builder();%0A    intermediateAttributes.setAsPath(mkAsPath(5, 6));%0A    Environment env = newTestEnvironment(outputRoute);%0A    env.setIntermediateBgpAttributes(intermediateAttributes);%0A    env.setWriteToIntermediateBgpAttributes(true);%0A%0A    operation.execute(env);%0A    assertThat(outputRoute.getAsPath(), equalTo(mkAsPath(1, 2, 3, 4)));%0A    assertThat(intermediateAttributes.getAsPath(), equalTo(mkAsPath(1, 2, 5, 6)));%0A  %7D%0A%7D%0A

Test PrependAsPath