@Test public void testMatches() { NetworkFactory nf = new NetworkFactory(); Configuration c = nf.configurationBuilder() .setHostname("n1") .setConfigurationFormat(ConfigurationFormat.CISCO_IOS) .build(); nf.vrfBuilder().setName(Configuration.DEFAULT_VRF_NAME).setOwner(c).build(); MatchProtocol mp = new MatchProtocol(RoutingProtocol.CONNECTED, RoutingProtocol.ISIS_L1); Environment.Builder eb = Environment.builder(c); StaticRoute staticR = StaticRoute.builder() .setNetwork(Prefix.parse("1.1.1.0/24")) .setAdmin(1) .setNextHopIp(Ip.parse("2.2.2.2")) .build(); ConnectedRoute connected = ConnectedRoute.builder() .setNetwork(Prefix.parse("1.1.1.0/24")) .setAdmin(1) .setNextHopIp(Ip.parse("2.2.2.2")) .setNextHopInterface("null0") .build(); IsisRoute.Builder ib = IsisRoute.builder() .setNetwork(Prefix.parse("1.1.1.0/24")) .setArea("fakeArea") .setSystemId("invalidSystemId"); IsisRoute isisL1 = ib.setLevel(IsisLevel.LEVEL_1).setProtocol(RoutingProtocol.ISIS_L1).build(); IsisRoute isisL2 = ib.setLevel(IsisLevel.LEVEL_2).setProtocol(RoutingProtocol.ISIS_L2).build(); assertThat( "Matches CONNECTED", not(mp.evaluate(eb.setOriginalRoute(connected).build()).getBooleanValue())); assertThat( "Matches ISIS_L1", not(mp.evaluate(eb.setOriginalRoute(isisL1).build()).getBooleanValue())); assertThat( "Does not match STATIC", not(mp.evaluate(eb.setOriginalRoute(staticR).build()).getBooleanValue())); assertThat( "Does not match ISIS_L2", not(mp.evaluate(eb.setOriginalRoute(isisL2).build()).getBooleanValue())); }
@Override public Result evaluate(Environment environment) { return new Result(_protocols.contains(environment.getOriginalRoute().getProtocol())); }
MatchProtocol extends BooleanExpr { @Override public Result evaluate(Environment environment) { return new Result(_protocols.contains(environment.getOriginalRoute().getProtocol())); } }
MatchProtocol extends BooleanExpr { @Override public Result evaluate(Environment environment) { return new Result(_protocols.contains(environment.getOriginalRoute().getProtocol())); } MatchProtocol(RoutingProtocol... protocols);  MatchProtocol(Collection<RoutingProtocol> protocols); }
MatchProtocol extends BooleanExpr { @Override public Result evaluate(Environment environment) { return new Result(_protocols.contains(environment.getOriginalRoute().getProtocol())); } MatchProtocol(RoutingProtocol... protocols);  MatchProtocol(Collection<RoutingProtocol> protocols); @Override T accept(BooleanExprVisitor<T, U> visitor, U arg); @Override Result evaluate(Environment environment); @Nonnull @JsonProperty(PROP_PROTOCOLS) Set<RoutingProtocol> getProtocols(); @Override boolean equals(@Nullable Object o); @Override int hashCode(); @Override String toString(); }
MatchProtocol extends BooleanExpr { @Override public Result evaluate(Environment environment) { return new Result(_protocols.contains(environment.getOriginalRoute().getProtocol())); } MatchProtocol(RoutingProtocol... protocols);  MatchProtocol(Collection<RoutingProtocol> protocols); @Override T accept(BooleanExprVisitor<T, U> visitor, U arg); @Override Result evaluate(Environment environment); @Nonnull @JsonProperty(PROP_PROTOCOLS) Set<RoutingProtocol> getProtocols(); @Override boolean equals(@Nullable Object o); @Override int hashCode(); @Override String toString();  }