@Test public void testTryAddVlanVniVlanPresent() { int vni = 10000; int vlan = 1; IntegerSpace vlans = IntegerSpace.of(vlan); ImmutableMap.Builder<Integer, Integer> vlanVnisBuilder = ImmutableMap.builder(); Map<Integer, ImmutableSet.Builder<NodeInterfacePair>> switchedVlanInterfaces = new HashMap<>(); Layer2Vni vniSettings = _vnb.setVni(vni).setVlan(vlan).build(); tryAddVlanVni(vniSettings, vlans, vlanVnisBuilder, switchedVlanInterfaces); assertThat(vlanVnisBuilder.build(), equalTo(ImmutableMap.of(vlan, vni))); assertThat(switchedVlanInterfaces, hasKey(vlan)); assertThat(switchedVlanInterfaces.get(vlan).build(), empty()); }
@VisibleForTesting static void tryAddVlanVni( Layer2Vni vniSettings, IntegerSpace vlans, ImmutableMap.Builder<Integer, Integer> vlanVnisBuilder, Map<Integer, ImmutableSet.Builder<NodeInterfacePair>> switchedVlanInterfaces) { if (vlans.contains(vniSettings.getVlan())) { int vlan = vniSettings.getVlan(); vlanVnisBuilder.put(vlan, vniSettings.getVni()); switchedVlanInterfaces.computeIfAbsent(vlan, v -> ImmutableSet.builder()); } }
SwitchedVlanPropertiesAnswerer extends Answerer { @VisibleForTesting static void tryAddVlanVni( Layer2Vni vniSettings, IntegerSpace vlans, ImmutableMap.Builder<Integer, Integer> vlanVnisBuilder, Map<Integer, ImmutableSet.Builder<NodeInterfacePair>> switchedVlanInterfaces) { if (vlans.contains(vniSettings.getVlan())) { int vlan = vniSettings.getVlan(); vlanVnisBuilder.put(vlan, vniSettings.getVni()); switchedVlanInterfaces.computeIfAbsent(vlan, v -> ImmutableSet.builder()); } } }
SwitchedVlanPropertiesAnswerer extends Answerer { @VisibleForTesting static void tryAddVlanVni( Layer2Vni vniSettings, IntegerSpace vlans, ImmutableMap.Builder<Integer, Integer> vlanVnisBuilder, Map<Integer, ImmutableSet.Builder<NodeInterfacePair>> switchedVlanInterfaces) { if (vlans.contains(vniSettings.getVlan())) { int vlan = vniSettings.getVlan(); vlanVnisBuilder.put(vlan, vniSettings.getVni()); switchedVlanInterfaces.computeIfAbsent(vlan, v -> ImmutableSet.builder()); } } SwitchedVlanPropertiesAnswerer(Question question, IBatfish batfish); }
SwitchedVlanPropertiesAnswerer extends Answerer { @VisibleForTesting static void tryAddVlanVni( Layer2Vni vniSettings, IntegerSpace vlans, ImmutableMap.Builder<Integer, Integer> vlanVnisBuilder, Map<Integer, ImmutableSet.Builder<NodeInterfacePair>> switchedVlanInterfaces) { if (vlans.contains(vniSettings.getVlan())) { int vlan = vniSettings.getVlan(); vlanVnisBuilder.put(vlan, vniSettings.getVni()); switchedVlanInterfaces.computeIfAbsent(vlan, v -> ImmutableSet.builder()); } } SwitchedVlanPropertiesAnswerer(Question question, IBatfish batfish); static List<ColumnMetadata> createColumnMetadata(); static String getColumnName(String property); static Multiset<Row> getProperties(
      SpecifierContext ctxt,
      Map<String, Configuration> configurations,
      Set<String> nodes,
      InterfaceSpecifier interfaceSpecifier,
      boolean excludeShutInterfaces,
      IntegerSpace vlans,
      Map<String, ColumnMetadata> columns); @Override TableAnswerElement answer(NetworkSnapshot snapshot); }
SwitchedVlanPropertiesAnswerer extends Answerer { @VisibleForTesting static void tryAddVlanVni( Layer2Vni vniSettings, IntegerSpace vlans, ImmutableMap.Builder<Integer, Integer> vlanVnisBuilder, Map<Integer, ImmutableSet.Builder<NodeInterfacePair>> switchedVlanInterfaces) { if (vlans.contains(vniSettings.getVlan())) { int vlan = vniSettings.getVlan(); vlanVnisBuilder.put(vlan, vniSettings.getVni()); switchedVlanInterfaces.computeIfAbsent(vlan, v -> ImmutableSet.builder()); } } SwitchedVlanPropertiesAnswerer(Question question, IBatfish batfish); static List<ColumnMetadata> createColumnMetadata(); static String getColumnName(String property); static Multiset<Row> getProperties(
      SpecifierContext ctxt,
      Map<String, Configuration> configurations,
      Set<String> nodes,
      InterfaceSpecifier interfaceSpecifier,
      boolean excludeShutInterfaces,
      IntegerSpace vlans,
      Map<String, ColumnMetadata> columns); @Override TableAnswerElement answer(NetworkSnapshot snapshot);  }