@Test public void testIndirection() { String aclName = "acl1"; String ipSpaceName = "ipSpace1"; FibLookup fl = new FibLookup(new LiteralVrfName("vrf")); FlowResult r = FlowEvaluator.evaluate( _flow, "Eth0", "otherVrf", singletonPolicy( new If( new PacketMatchExpr(permittedByAcl(aclName)), ImmutableList.of(new Return(fl)))), ImmutableMap.of( aclName, IpAccessList.builder() .setName(aclName) .setLines( ImmutableList.of( ExprAclLine.acceptingHeaderSpace( HeaderSpace.builder() .setDstIps(new IpSpaceReference(ipSpaceName)) .build()))) .build()), ImmutableMap.of(ipSpaceName, UniverseIpSpace.INSTANCE), ImmutableMap.of()); assertThat(r.getAction(), equalTo(fl)); assertThat(r.getFinalFlow(), equalTo(_flow)); }
private FlowResult evaluate(PacketPolicy policy) { Action action = policy.getStatements().stream() .map(_stmtEvaluator::visit) .filter(Objects::nonNull) .findFirst() .orElse(policy.getDefaultAction().getAction()); return new FlowResult(getTransformedFlow(), action); }
FlowEvaluator { private FlowResult evaluate(PacketPolicy policy) { Action action = policy.getStatements().stream() .map(_stmtEvaluator::visit) .filter(Objects::nonNull) .findFirst() .orElse(policy.getDefaultAction().getAction()); return new FlowResult(getTransformedFlow(), action); } }
FlowEvaluator { private FlowResult evaluate(PacketPolicy policy) { Action action = policy.getStatements().stream() .map(_stmtEvaluator::visit) .filter(Objects::nonNull) .findFirst() .orElse(policy.getDefaultAction().getAction()); return new FlowResult(getTransformedFlow(), action); } private  FlowEvaluator(
      Flow originalFlow,
      String srcInterface,
      String srcInterfaceVrf,
      Map<String, IpAccessList> availableAcls,
      Map<String, IpSpace> namedIpSpaces,
      Map<String, Fib> fibs); }
FlowEvaluator { private FlowResult evaluate(PacketPolicy policy) { Action action = policy.getStatements().stream() .map(_stmtEvaluator::visit) .filter(Objects::nonNull) .findFirst() .orElse(policy.getDefaultAction().getAction()); return new FlowResult(getTransformedFlow(), action); } private  FlowEvaluator(
      Flow originalFlow,
      String srcInterface,
      String srcInterfaceVrf,
      Map<String, IpAccessList> availableAcls,
      Map<String, IpSpace> namedIpSpaces,
      Map<String, Fib> fibs); static FlowResult evaluate(
      Flow f,
      String srcInterface,
      String srcInterfaceVrf,
      PacketPolicy policy,
      Map<String, IpAccessList> availableAcls,
      Map<String, IpSpace> namedIpSpaces,
      Map<String, Fib> fibs); }
FlowEvaluator { private FlowResult evaluate(PacketPolicy policy) { Action action = policy.getStatements().stream() .map(_stmtEvaluator::visit) .filter(Objects::nonNull) .findFirst() .orElse(policy.getDefaultAction().getAction()); return new FlowResult(getTransformedFlow(), action); } private  FlowEvaluator(
      Flow originalFlow,
      String srcInterface,
      String srcInterfaceVrf,
      Map<String, IpAccessList> availableAcls,
      Map<String, IpSpace> namedIpSpaces,
      Map<String, Fib> fibs); static FlowResult evaluate(
      Flow f,
      String srcInterface,
      String srcInterfaceVrf,
      PacketPolicy policy,
      Map<String, IpAccessList> availableAcls,
      Map<String, IpSpace> namedIpSpaces,
      Map<String, Fib> fibs);  }