@Test public void testSpecifyProperties() { IBatfish batfish = new VxlanVniPropertiesAnswererTest.TestBatfish(); VxlanVniPropertiesAnswerer answerer = new VxlanVniPropertiesAnswerer(new VxlanVniPropertiesQuestion(null, VLAN), batfish); TableAnswerElement answer = answerer.answer(batfish.getSnapshot()); assertThat( answer.getRows(), equalTo( new Rows() .add( Row.builder() .put(COL_NODE, "hostname") .put(COL_VRF, DEFAULT_VRF_NAME) .put(COL_VNI, 10001) .put(VLAN, 1) .build()) .add( Row.builder() .put(COL_NODE, "hostname") .put(COL_VRF, DEFAULT_VRF_NAME) .put(COL_VNI, 10002) .put(VLAN, 2) .build()) .add( Row.builder() .put(COL_NODE, "minimal") .put(COL_VRF, DEFAULT_VRF_NAME) .put(COL_VNI, 10001) .put(VLAN, 1) .build()))); }
@Override public TableAnswerElement answer(NetworkSnapshot snapshot) { VxlanVniPropertiesQuestion question = (VxlanVniPropertiesQuestion) _question; Set<String> nodes = SpecifierFactories.getNodeSpecifierOrDefault( question.getNodes(), AllNodesNodeSpecifier.INSTANCE) .resolve(_batfish.specifierContext(snapshot)); DataPlane dp = _batfish.loadDataPlane(snapshot); TableMetadata tableMetadata = createTableMetadata(question); TableAnswerElement answer = new TableAnswerElement(tableMetadata); Multiset<Row> propertyRows = getProperties( VxlanVniPropertySpecifier.create(question.getProperties()), dp, nodes, tableMetadata.toColumnMap()); answer.postProcessAnswer(question, propertyRows); return answer; }
VxlanVniPropertiesAnswerer extends Answerer { @Override public TableAnswerElement answer(NetworkSnapshot snapshot) { VxlanVniPropertiesQuestion question = (VxlanVniPropertiesQuestion) _question; Set<String> nodes = SpecifierFactories.getNodeSpecifierOrDefault( question.getNodes(), AllNodesNodeSpecifier.INSTANCE) .resolve(_batfish.specifierContext(snapshot)); DataPlane dp = _batfish.loadDataPlane(snapshot); TableMetadata tableMetadata = createTableMetadata(question); TableAnswerElement answer = new TableAnswerElement(tableMetadata); Multiset<Row> propertyRows = getProperties( VxlanVniPropertySpecifier.create(question.getProperties()), dp, nodes, tableMetadata.toColumnMap()); answer.postProcessAnswer(question, propertyRows); return answer; } }
VxlanVniPropertiesAnswerer extends Answerer { @Override public TableAnswerElement answer(NetworkSnapshot snapshot) { VxlanVniPropertiesQuestion question = (VxlanVniPropertiesQuestion) _question; Set<String> nodes = SpecifierFactories.getNodeSpecifierOrDefault( question.getNodes(), AllNodesNodeSpecifier.INSTANCE) .resolve(_batfish.specifierContext(snapshot)); DataPlane dp = _batfish.loadDataPlane(snapshot); TableMetadata tableMetadata = createTableMetadata(question); TableAnswerElement answer = new TableAnswerElement(tableMetadata); Multiset<Row> propertyRows = getProperties( VxlanVniPropertySpecifier.create(question.getProperties()), dp, nodes, tableMetadata.toColumnMap()); answer.postProcessAnswer(question, propertyRows); return answer; } VxlanVniPropertiesAnswerer(VxlanVniPropertiesQuestion question, IBatfish batfish); }
VxlanVniPropertiesAnswerer extends Answerer { @Override public TableAnswerElement answer(NetworkSnapshot snapshot) { VxlanVniPropertiesQuestion question = (VxlanVniPropertiesQuestion) _question; Set<String> nodes = SpecifierFactories.getNodeSpecifierOrDefault( question.getNodes(), AllNodesNodeSpecifier.INSTANCE) .resolve(_batfish.specifierContext(snapshot)); DataPlane dp = _batfish.loadDataPlane(snapshot); TableMetadata tableMetadata = createTableMetadata(question); TableAnswerElement answer = new TableAnswerElement(tableMetadata); Multiset<Row> propertyRows = getProperties( VxlanVniPropertySpecifier.create(question.getProperties()), dp, nodes, tableMetadata.toColumnMap()); answer.postProcessAnswer(question, propertyRows); return answer; } VxlanVniPropertiesAnswerer(VxlanVniPropertiesQuestion question, IBatfish batfish); static List<ColumnMetadata> createColumnMetadata(
      VxlanVniPropertySpecifier propertySpecifier); @Override TableAnswerElement answer(NetworkSnapshot snapshot); static Multiset<Row> getProperties(
      VxlanVniPropertySpecifier propertySpecifier,
      DataPlane dp,
      Set<String> nodes,
      Map<String, ColumnMetadata> columns); }
VxlanVniPropertiesAnswerer extends Answerer { @Override public TableAnswerElement answer(NetworkSnapshot snapshot) { VxlanVniPropertiesQuestion question = (VxlanVniPropertiesQuestion) _question; Set<String> nodes = SpecifierFactories.getNodeSpecifierOrDefault( question.getNodes(), AllNodesNodeSpecifier.INSTANCE) .resolve(_batfish.specifierContext(snapshot)); DataPlane dp = _batfish.loadDataPlane(snapshot); TableMetadata tableMetadata = createTableMetadata(question); TableAnswerElement answer = new TableAnswerElement(tableMetadata); Multiset<Row> propertyRows = getProperties( VxlanVniPropertySpecifier.create(question.getProperties()), dp, nodes, tableMetadata.toColumnMap()); answer.postProcessAnswer(question, propertyRows); return answer; } VxlanVniPropertiesAnswerer(VxlanVniPropertiesQuestion question, IBatfish batfish); static List<ColumnMetadata> createColumnMetadata(
      VxlanVniPropertySpecifier propertySpecifier); @Override TableAnswerElement answer(NetworkSnapshot snapshot); static Multiset<Row> getProperties(
      VxlanVniPropertySpecifier propertySpecifier,
      DataPlane dp,
      Set<String> nodes,
      Map<String, ColumnMetadata> columns); static final String COL_NODE; static final String COL_VRF; static final String COL_VNI; }