use of org.batfish.z3.state.Originate in project batfish by batfish.
the class DefaultTransitionGeneratorTest method testVisitPostIn.
@Test
public void testVisitPostIn() {
SynthesizerInput input = MockSynthesizerInput.builder().setEnabledNodes(ImmutableSet.of(NODE1, NODE2)).setEnabledInterfaces(ImmutableMap.of(NODE1, ImmutableSet.of(INTERFACE1, INTERFACE2), NODE2, ImmutableSet.of(INTERFACE1, INTERFACE2))).build();
Set<RuleStatement> rules = ImmutableSet.copyOf(DefaultTransitionGenerator.generateTransitions(input, ImmutableSet.of(PostIn.State.INSTANCE)));
// CopyOriginate
assertThat(rules, hasItem(new BasicRuleStatement(new Originate(NODE1), new PostIn(NODE1))));
assertThat(rules, hasItem(new BasicRuleStatement(new Originate(NODE2), new PostIn(NODE2))));
// ProjectPostInInterface
assertThat(rules, hasItem(new BasicRuleStatement(new PostInInterface(NODE1, INTERFACE1), new PostIn(NODE1))));
assertThat(rules, hasItem(new BasicRuleStatement(new PostInInterface(NODE1, INTERFACE2), new PostIn(NODE1))));
assertThat(rules, hasItem(new BasicRuleStatement(new PostInInterface(NODE2, INTERFACE1), new PostIn(NODE2))));
assertThat(rules, hasItem(new BasicRuleStatement(new PostInInterface(NODE2, INTERFACE2), new PostIn(NODE2))));
}
use of org.batfish.z3.state.Originate in project batfish by batfish.
the class DefaultTransitionGenerator method visitPostIn.
@Override
public void visitPostIn(PostIn.State postIn) {
// CopyOriginate
_input.getEnabledNodes().stream().map(hostname -> new BasicRuleStatement(new Originate(hostname), new PostIn(hostname))).forEach(_rules::add);
// ProjectPostInInterface
_input.getEnabledInterfaces().entrySet().stream().flatMap(enabledInterfacesByHostnameEntry -> {
String hostname = enabledInterfacesByHostnameEntry.getKey();
return enabledInterfacesByHostnameEntry.getValue().stream().map(ifaceName -> new BasicRuleStatement(new PostInInterface(hostname, ifaceName), new PostIn(hostname)));
}).forEach(_rules::add);
}
use of org.batfish.z3.state.Originate in project batfish by batfish.
the class DefaultTransitionGeneratorTest method testVisitOriginate.
@Test
public void testVisitOriginate() {
SynthesizerInput input = MockSynthesizerInput.builder().setEnabledVrfs(ImmutableMap.of(NODE1, ImmutableSet.of(VRF1, VRF2), NODE2, ImmutableSet.of(VRF1, VRF2))).build();
Set<RuleStatement> rules = ImmutableSet.copyOf(DefaultTransitionGenerator.generateTransitions(input, ImmutableSet.of(Originate.State.INSTANCE)));
// ProjectOriginateVrf
assertThat(rules, hasItem(new BasicRuleStatement(new OriginateVrf(NODE1, VRF1), new Originate(NODE1))));
assertThat(rules, hasItem(new BasicRuleStatement(new OriginateVrf(NODE1, VRF2), new Originate(NODE1))));
assertThat(rules, hasItem(new BasicRuleStatement(new OriginateVrf(NODE2, VRF1), new Originate(NODE2))));
assertThat(rules, hasItem(new BasicRuleStatement(new OriginateVrf(NODE2, VRF2), new Originate(NODE2))));
}
Aggregations