@Test public void testToStatement_FalseToNewPolicyEntry() { RouteMapConvertor convertor = new RouteMapConvertor(C, VC, ROUTEMAP, W); Statement statement = convertor.toStatement(ENTRY2); Conjunction match = new Conjunction(ImmutableList.of(new MatchTag(IntComparator.EQ, new LiteralLong(2)))); assertThat( statement, equalTo( new If( match, ImmutableList.of( new SetMetric(new LiteralLong(20)), new If( BooleanExprs.CALL_EXPR_CONTEXT, ImmutableList.of(Statements.ReturnFalse.toStaticStatement()), ImmutableList.of(Statements.ExitReject.toStaticStatement()))), ImmutableList.of( new If( new CallExpr(String.format("~%s~SEQ:%d~", "routeMap", 30)), ImmutableList.of(Statements.ReturnTrue.toStaticStatement()), ImmutableList.of(Statements.ReturnFalse.toStaticStatement())))))); }
@VisibleForTesting @Nonnull Statement toStatement(RouteMapEntry entry) { List<BooleanExpr> matchConjuncts = entry .getMatches() .map(m -> m.toBooleanExpr(_c, _vc, _w)) .collect(ImmutableList.toImmutableList()); List<Statement> trueStatements = Stream.concat( entry.getSets().flatMap(m -> m.toStatements(_c, _vc, _w)), Stream.of(convertCallStatement(entry), convertActionStatement(entry))) .filter(Objects::nonNull) .collect(ImmutableList.toImmutableList()); Integer noMatchNext = _nextSeqMap.get(entry.getNumber()); List<Statement> noMatchStatements = noMatchNext != null && _continueTargets.contains(noMatchNext) ? ImmutableList.of(call(computeRoutingPolicyName(_routeMap.getName(), noMatchNext))) : ImmutableList.of(); return new If(new Conjunction(matchConjuncts), trueStatements, noMatchStatements); }
RouteMapConvertor { @VisibleForTesting @Nonnull Statement toStatement(RouteMapEntry entry) { List<BooleanExpr> matchConjuncts = entry .getMatches() .map(m -> m.toBooleanExpr(_c, _vc, _w)) .collect(ImmutableList.toImmutableList()); List<Statement> trueStatements = Stream.concat( entry.getSets().flatMap(m -> m.toStatements(_c, _vc, _w)), Stream.of(convertCallStatement(entry), convertActionStatement(entry))) .filter(Objects::nonNull) .collect(ImmutableList.toImmutableList()); Integer noMatchNext = _nextSeqMap.get(entry.getNumber()); List<Statement> noMatchStatements = noMatchNext != null && _continueTargets.contains(noMatchNext) ? ImmutableList.of(call(computeRoutingPolicyName(_routeMap.getName(), noMatchNext))) : ImmutableList.of(); return new If(new Conjunction(matchConjuncts), trueStatements, noMatchStatements); } }
RouteMapConvertor { @VisibleForTesting @Nonnull Statement toStatement(RouteMapEntry entry) { List<BooleanExpr> matchConjuncts = entry .getMatches() .map(m -> m.toBooleanExpr(_c, _vc, _w)) .collect(ImmutableList.toImmutableList()); List<Statement> trueStatements = Stream.concat( entry.getSets().flatMap(m -> m.toStatements(_c, _vc, _w)), Stream.of(convertCallStatement(entry), convertActionStatement(entry))) .filter(Objects::nonNull) .collect(ImmutableList.toImmutableList()); Integer noMatchNext = _nextSeqMap.get(entry.getNumber()); List<Statement> noMatchStatements = noMatchNext != null && _continueTargets.contains(noMatchNext) ? ImmutableList.of(call(computeRoutingPolicyName(_routeMap.getName(), noMatchNext))) : ImmutableList.of(); return new If(new Conjunction(matchConjuncts), trueStatements, noMatchStatements); } RouteMapConvertor(Configuration c, CumulusNodeConfiguration vc, RouteMap routeMap, Warnings w); }
RouteMapConvertor { @VisibleForTesting @Nonnull Statement toStatement(RouteMapEntry entry) { List<BooleanExpr> matchConjuncts = entry .getMatches() .map(m -> m.toBooleanExpr(_c, _vc, _w)) .collect(ImmutableList.toImmutableList()); List<Statement> trueStatements = Stream.concat( entry.getSets().flatMap(m -> m.toStatements(_c, _vc, _w)), Stream.of(convertCallStatement(entry), convertActionStatement(entry))) .filter(Objects::nonNull) .collect(ImmutableList.toImmutableList()); Integer noMatchNext = _nextSeqMap.get(entry.getNumber()); List<Statement> noMatchStatements = noMatchNext != null && _continueTargets.contains(noMatchNext) ? ImmutableList.of(call(computeRoutingPolicyName(_routeMap.getName(), noMatchNext))) : ImmutableList.of(); return new If(new Conjunction(matchConjuncts), trueStatements, noMatchStatements); } RouteMapConvertor(Configuration c, CumulusNodeConfiguration vc, RouteMap routeMap, Warnings w);  }
RouteMapConvertor { @VisibleForTesting @Nonnull Statement toStatement(RouteMapEntry entry) { List<BooleanExpr> matchConjuncts = entry .getMatches() .map(m -> m.toBooleanExpr(_c, _vc, _w)) .collect(ImmutableList.toImmutableList()); List<Statement> trueStatements = Stream.concat( entry.getSets().flatMap(m -> m.toStatements(_c, _vc, _w)), Stream.of(convertCallStatement(entry), convertActionStatement(entry))) .filter(Objects::nonNull) .collect(ImmutableList.toImmutableList()); Integer noMatchNext = _nextSeqMap.get(entry.getNumber()); List<Statement> noMatchStatements = noMatchNext != null && _continueTargets.contains(noMatchNext) ? ImmutableList.of(call(computeRoutingPolicyName(_routeMap.getName(), noMatchNext))) : ImmutableList.of(); return new If(new Conjunction(matchConjuncts), trueStatements, noMatchStatements); } RouteMapConvertor(Configuration c, CumulusNodeConfiguration vc, RouteMap routeMap, Warnings w);   }