@Test public void testMultipleTransformations() { Ip matchDstIp = Ip.parse("1.1.1.1"); Ip matchSrcIp = Ip.parse("2.2.2.2"); Ip truePoolIp = Ip.parse("3.3.3.3"); Ip falsePoolIp = Ip.parse("4.4.4.4"); Transformation transformation = when(matchDst(matchDstIp)) .apply(NOOP_SOURCE_NAT) .setAndThen( when(matchSrc(matchSrcIp)).apply(assignSourceIp(truePoolIp, truePoolIp)).build()) .setOrElse( when(matchSrc(matchSrcIp)).apply(assignSourceIp(falsePoolIp, falsePoolIp)).build()) .build(); Transition transition = _toTransition.toTransition(transformation); BDD matchDstIpBdd = _pkt.getDstIp().value(matchDstIp.asLong()); BDD notMatchDstIpBdd = matchDstIpBdd.not(); BDD matchSrcIpBdd = _pkt.getSrcIp().value(matchSrcIp.asLong()); BDD notMatchSrcIpBdd = matchSrcIpBdd.not(); BDD truePoolIpBdd = _pkt.getSrcIp().value(truePoolIp.asLong()); BDD falsePoolIpBdd = _pkt.getSrcIp().value(falsePoolIp.asLong()); assertThat( transition.transitForward(matchDstIpBdd.and(matchSrcIpBdd)), equalTo(matchDstIpBdd.and(truePoolIpBdd))); assertThat( transition.transitForward(matchDstIpBdd.and(notMatchSrcIpBdd)), equalTo(matchDstIpBdd.and(notMatchSrcIpBdd))); assertThat( transition.transitForward(notMatchDstIpBdd.and(matchSrcIpBdd)), equalTo(notMatchDstIpBdd.and(falsePoolIpBdd))); assertThat( transition.transitForward(notMatchDstIpBdd.and(notMatchSrcIpBdd)), equalTo(notMatchDstIpBdd.and(notMatchSrcIpBdd))); }
public Transition toTransition(@Nullable Transformation transformation) { return transformation == null ? IDENTITY : _cache.computeIfAbsent(transformation, this::computeTransition); }
TransformationToTransition { public Transition toTransition(@Nullable Transformation transformation) { return transformation == null ? IDENTITY : _cache.computeIfAbsent(transformation, this::computeTransition); } }
TransformationToTransition { public Transition toTransition(@Nullable Transformation transformation) { return transformation == null ? IDENTITY : _cache.computeIfAbsent(transformation, this::computeTransition); } TransformationToTransition(BDDPacket bddPacket, IpAccessListToBdd ipAccessListToBdd); }
TransformationToTransition { public Transition toTransition(@Nullable Transformation transformation) { return transformation == null ? IDENTITY : _cache.computeIfAbsent(transformation, this::computeTransition); } TransformationToTransition(BDDPacket bddPacket, IpAccessListToBdd ipAccessListToBdd); Transition toTransition(@Nullable Transformation transformation); Transition toReturnFlowTransition(@Nullable Transformation transformation); }
TransformationToTransition { public Transition toTransition(@Nullable Transformation transformation) { return transformation == null ? IDENTITY : _cache.computeIfAbsent(transformation, this::computeTransition); } TransformationToTransition(BDDPacket bddPacket, IpAccessListToBdd ipAccessListToBdd); Transition toTransition(@Nullable Transformation transformation); Transition toReturnFlowTransition(@Nullable Transformation transformation);  }