use of org.batfish.datamodel.routing_policy.statement.BufferedStatement in project batfish by batfish.
the class RoutingPolicyTests method testRoutingPolicyDeepCircularReference.
/**
* Policy with actual circular reference deep in the policy
*/
@Test
public void testRoutingPolicyDeepCircularReference() {
String parentPolicyName = "parent";
CallStatement callStatement = new CallStatement(parentPolicyName);
BufferedStatement bs = new BufferedStatement(callStatement);
WithEnvironmentExpr we1 = new WithEnvironmentExpr();
we1.setPostStatements(ImmutableList.of(bs));
If if1 = new If();
if1.setGuard(we1);
WithEnvironmentExpr we2 = new WithEnvironmentExpr();
we2.setPostTrueStatements(ImmutableList.of(if1));
If if2 = new If();
if2.setGuard(we2);
If if3 = new If();
if3.setTrueStatements(ImmutableList.of(if2));
If if4 = new If();
if4.setFalseStatements(ImmutableList.of(if3));
WithEnvironmentExpr we3 = new WithEnvironmentExpr();
we3.setPreStatements(ImmutableList.of(if4));
WithEnvironmentExpr we4 = new WithEnvironmentExpr();
we4.setExpr(we3);
Conjunction conj = new Conjunction();
conj.setConjuncts(ImmutableList.of(we4));
ConjunctionChain conjunctionChain = new ConjunctionChain(ImmutableList.of(conj));
Disjunction disjunction = new Disjunction();
disjunction.setDisjuncts(ImmutableList.of(conjunctionChain));
DisjunctionChain disjunctionChain = new DisjunctionChain(ImmutableList.of(disjunction));
Not not = new Not(disjunctionChain);
If if5 = new If();
if5.setGuard(not);
_rpb.setName(parentPolicyName).setStatements(ImmutableList.of(if5)).build();
_c.computeRoutingPolicySources(_w);
/*
* A circular reference warning should be emitted containing the name of the circularly
* referenced policy.
*/
assertThat(_w.getRedFlagWarnings(), not(empty()));
assertThat(_w.getRedFlagWarnings().iterator().next().getText(), containsString(parentPolicyName));
}
use of org.batfish.datamodel.routing_policy.statement.BufferedStatement in project batfish by batfish.
the class RoutePolicySetStatement method applyTo.
@Override
public final void applyTo(List<Statement> statements, CiscoConfiguration cc, Configuration c, Warnings w) {
Statement setStatement = toSetStatement(cc, c, w);
Statement bufferedStatement = new BufferedStatement(setStatement);
If ifStatement = new If();
ifStatement.setGuard(BooleanExprs.CallExprContext.toStaticBooleanExpr());
ifStatement.setTrueStatements(Collections.singletonList(Statements.SetLocalDefaultActionAccept.toStaticStatement()));
ifStatement.setFalseStatements(Collections.singletonList(Statements.SetDefaultActionAccept.toStaticStatement()));
statements.add(bufferedStatement);
statements.add(ifStatement);
}
Aggregations