@Test public void testAnswererFlow() { TestBatfish batfish = new TestBatfish(); FileParseStatusAnswerer answerer = new FileParseStatusAnswerer(new FileParseStatusQuestion(), batfish); TableAnswerElement answer = answerer.answer(batfish.getSnapshot()); assertThat( answer.getRows(), equalTo( new Rows() .add( Row.of( COL_FILENAME, "f", COL_PARSE_STATUS, ParseStatus.PASSED, COL_NODES, ImmutableList.of(new Node("h"), new Node("h1"), new Node("h2")))))); }
@Override public TableAnswerElement answer(NetworkSnapshot snapshot) { ParseVendorConfigurationAnswerElement pvcae = _batfish.loadParseVendorConfigurationAnswerElement(snapshot); ConvertConfigurationAnswerElement ccae = _batfish.loadConvertConfigurationAnswerElementOrReparse(snapshot); Map<String, ParseStatus> statusMap = pvcae.getParseStatus(); Rows rows = new Rows(); Multimap<String, String> fileToConvertedHosts = ccae.getFileMap(); Multimap<String, String> fileToHost = TreeMultimap.create(); pvcae .getFileMap() .forEach( (hostname, filename) -> { fileToHost.put(filename, hostname); fileToHost.putAll(filename, fileToConvertedHosts.get(filename)); }); statusMap.forEach( (filename, status) -> rows.add(getRow(filename, status, fileToHost.get(filename)))); TableAnswerElement answerElement = new TableAnswerElement(TABLE_METADATA); answerElement.postProcessAnswer(_question, rows.getData()); return answerElement; }
FileParseStatusAnswerer extends Answerer { @Override public TableAnswerElement answer(NetworkSnapshot snapshot) { ParseVendorConfigurationAnswerElement pvcae = _batfish.loadParseVendorConfigurationAnswerElement(snapshot); ConvertConfigurationAnswerElement ccae = _batfish.loadConvertConfigurationAnswerElementOrReparse(snapshot); Map<String, ParseStatus> statusMap = pvcae.getParseStatus(); Rows rows = new Rows(); Multimap<String, String> fileToConvertedHosts = ccae.getFileMap(); Multimap<String, String> fileToHost = TreeMultimap.create(); pvcae .getFileMap() .forEach( (hostname, filename) -> { fileToHost.put(filename, hostname); fileToHost.putAll(filename, fileToConvertedHosts.get(filename)); }); statusMap.forEach( (filename, status) -> rows.add(getRow(filename, status, fileToHost.get(filename)))); TableAnswerElement answerElement = new TableAnswerElement(TABLE_METADATA); answerElement.postProcessAnswer(_question, rows.getData()); return answerElement; } }
FileParseStatusAnswerer extends Answerer { @Override public TableAnswerElement answer(NetworkSnapshot snapshot) { ParseVendorConfigurationAnswerElement pvcae = _batfish.loadParseVendorConfigurationAnswerElement(snapshot); ConvertConfigurationAnswerElement ccae = _batfish.loadConvertConfigurationAnswerElementOrReparse(snapshot); Map<String, ParseStatus> statusMap = pvcae.getParseStatus(); Rows rows = new Rows(); Multimap<String, String> fileToConvertedHosts = ccae.getFileMap(); Multimap<String, String> fileToHost = TreeMultimap.create(); pvcae .getFileMap() .forEach( (hostname, filename) -> { fileToHost.put(filename, hostname); fileToHost.putAll(filename, fileToConvertedHosts.get(filename)); }); statusMap.forEach( (filename, status) -> rows.add(getRow(filename, status, fileToHost.get(filename)))); TableAnswerElement answerElement = new TableAnswerElement(TABLE_METADATA); answerElement.postProcessAnswer(_question, rows.getData()); return answerElement; } FileParseStatusAnswerer(FileParseStatusQuestion question, IBatfish batfish); }
FileParseStatusAnswerer extends Answerer { @Override public TableAnswerElement answer(NetworkSnapshot snapshot) { ParseVendorConfigurationAnswerElement pvcae = _batfish.loadParseVendorConfigurationAnswerElement(snapshot); ConvertConfigurationAnswerElement ccae = _batfish.loadConvertConfigurationAnswerElementOrReparse(snapshot); Map<String, ParseStatus> statusMap = pvcae.getParseStatus(); Rows rows = new Rows(); Multimap<String, String> fileToConvertedHosts = ccae.getFileMap(); Multimap<String, String> fileToHost = TreeMultimap.create(); pvcae .getFileMap() .forEach( (hostname, filename) -> { fileToHost.put(filename, hostname); fileToHost.putAll(filename, fileToConvertedHosts.get(filename)); }); statusMap.forEach( (filename, status) -> rows.add(getRow(filename, status, fileToHost.get(filename)))); TableAnswerElement answerElement = new TableAnswerElement(TABLE_METADATA); answerElement.postProcessAnswer(_question, rows.getData()); return answerElement; } FileParseStatusAnswerer(FileParseStatusQuestion question, IBatfish batfish); @Override TableAnswerElement answer(NetworkSnapshot snapshot); }
FileParseStatusAnswerer extends Answerer { @Override public TableAnswerElement answer(NetworkSnapshot snapshot) { ParseVendorConfigurationAnswerElement pvcae = _batfish.loadParseVendorConfigurationAnswerElement(snapshot); ConvertConfigurationAnswerElement ccae = _batfish.loadConvertConfigurationAnswerElementOrReparse(snapshot); Map<String, ParseStatus> statusMap = pvcae.getParseStatus(); Rows rows = new Rows(); Multimap<String, String> fileToConvertedHosts = ccae.getFileMap(); Multimap<String, String> fileToHost = TreeMultimap.create(); pvcae .getFileMap() .forEach( (hostname, filename) -> { fileToHost.put(filename, hostname); fileToHost.putAll(filename, fileToConvertedHosts.get(filename)); }); statusMap.forEach( (filename, status) -> rows.add(getRow(filename, status, fileToHost.get(filename)))); TableAnswerElement answerElement = new TableAnswerElement(TABLE_METADATA); answerElement.postProcessAnswer(_question, rows.getData()); return answerElement; } FileParseStatusAnswerer(FileParseStatusQuestion question, IBatfish batfish); @Override TableAnswerElement answer(NetworkSnapshot snapshot);  }