@Test public void testAnswererFlow() { TestBatfish batfish = new TestBatfish(); ParseWarningAnswerer answerer = new ParseWarningAnswerer(new ParseWarningQuestion(), batfish); TableAnswerElement answer = answerer.answer(batfish.getSnapshot()); assertThat( answer.getRows(), equalTo( new Rows() .add( Row.of( COL_FILENAME, "f", COL_LINE, 3, COL_TEXT, "text", COL_PARSER_CONTEXT, "ctx", COL_COMMENT, "comment")))); }
@Override public TableAnswerElement answer(NetworkSnapshot snapshot) { ParseWarningQuestion question = (ParseWarningQuestion) _question; TableMetadata metadata = createMetadata(question); Map<String, ColumnMetadata> columnMetadataMap = metadata.toColumnMap(); ParseVendorConfigurationAnswerElement pvcae = _batfish.loadParseVendorConfigurationAnswerElement(snapshot); Map<String, Warnings> fileWarnings = pvcae.getWarnings(); ImmutableList.Builder<Row> rows = ImmutableList.builder(); if (question.getAggregateDuplicates()) { aggregateDuplicateParseWarnings(fileWarnings) .forEach( (triplet, fileLines) -> rows.add(getAggregateRow(triplet, fileLines, columnMetadataMap))); } else { fileWarnings.forEach( (filename, warnings) -> { for (ParseWarning w : warnings.getParseWarnings()) { rows.add(getRow(filename, w, columnMetadataMap)); } }); } TableAnswerElement answerElement = new TableAnswerElement(createMetadata(question)); answerElement.postProcessAnswer(_question, rows.build()); return answerElement; }
ParseWarningAnswerer extends Answerer { @Override public TableAnswerElement answer(NetworkSnapshot snapshot) { ParseWarningQuestion question = (ParseWarningQuestion) _question; TableMetadata metadata = createMetadata(question); Map<String, ColumnMetadata> columnMetadataMap = metadata.toColumnMap(); ParseVendorConfigurationAnswerElement pvcae = _batfish.loadParseVendorConfigurationAnswerElement(snapshot); Map<String, Warnings> fileWarnings = pvcae.getWarnings(); ImmutableList.Builder<Row> rows = ImmutableList.builder(); if (question.getAggregateDuplicates()) { aggregateDuplicateParseWarnings(fileWarnings) .forEach( (triplet, fileLines) -> rows.add(getAggregateRow(triplet, fileLines, columnMetadataMap))); } else { fileWarnings.forEach( (filename, warnings) -> { for (ParseWarning w : warnings.getParseWarnings()) { rows.add(getRow(filename, w, columnMetadataMap)); } }); } TableAnswerElement answerElement = new TableAnswerElement(createMetadata(question)); answerElement.postProcessAnswer(_question, rows.build()); return answerElement; } }
ParseWarningAnswerer extends Answerer { @Override public TableAnswerElement answer(NetworkSnapshot snapshot) { ParseWarningQuestion question = (ParseWarningQuestion) _question; TableMetadata metadata = createMetadata(question); Map<String, ColumnMetadata> columnMetadataMap = metadata.toColumnMap(); ParseVendorConfigurationAnswerElement pvcae = _batfish.loadParseVendorConfigurationAnswerElement(snapshot); Map<String, Warnings> fileWarnings = pvcae.getWarnings(); ImmutableList.Builder<Row> rows = ImmutableList.builder(); if (question.getAggregateDuplicates()) { aggregateDuplicateParseWarnings(fileWarnings) .forEach( (triplet, fileLines) -> rows.add(getAggregateRow(triplet, fileLines, columnMetadataMap))); } else { fileWarnings.forEach( (filename, warnings) -> { for (ParseWarning w : warnings.getParseWarnings()) { rows.add(getRow(filename, w, columnMetadataMap)); } }); } TableAnswerElement answerElement = new TableAnswerElement(createMetadata(question)); answerElement.postProcessAnswer(_question, rows.build()); return answerElement; } ParseWarningAnswerer(ParseWarningQuestion question, IBatfish batfish); }
ParseWarningAnswerer extends Answerer { @Override public TableAnswerElement answer(NetworkSnapshot snapshot) { ParseWarningQuestion question = (ParseWarningQuestion) _question; TableMetadata metadata = createMetadata(question); Map<String, ColumnMetadata> columnMetadataMap = metadata.toColumnMap(); ParseVendorConfigurationAnswerElement pvcae = _batfish.loadParseVendorConfigurationAnswerElement(snapshot); Map<String, Warnings> fileWarnings = pvcae.getWarnings(); ImmutableList.Builder<Row> rows = ImmutableList.builder(); if (question.getAggregateDuplicates()) { aggregateDuplicateParseWarnings(fileWarnings) .forEach( (triplet, fileLines) -> rows.add(getAggregateRow(triplet, fileLines, columnMetadataMap))); } else { fileWarnings.forEach( (filename, warnings) -> { for (ParseWarning w : warnings.getParseWarnings()) { rows.add(getRow(filename, w, columnMetadataMap)); } }); } TableAnswerElement answerElement = new TableAnswerElement(createMetadata(question)); answerElement.postProcessAnswer(_question, rows.build()); return answerElement; } ParseWarningAnswerer(ParseWarningQuestion question, IBatfish batfish); @Override TableAnswerElement answer(NetworkSnapshot snapshot); }
ParseWarningAnswerer extends Answerer { @Override public TableAnswerElement answer(NetworkSnapshot snapshot) { ParseWarningQuestion question = (ParseWarningQuestion) _question; TableMetadata metadata = createMetadata(question); Map<String, ColumnMetadata> columnMetadataMap = metadata.toColumnMap(); ParseVendorConfigurationAnswerElement pvcae = _batfish.loadParseVendorConfigurationAnswerElement(snapshot); Map<String, Warnings> fileWarnings = pvcae.getWarnings(); ImmutableList.Builder<Row> rows = ImmutableList.builder(); if (question.getAggregateDuplicates()) { aggregateDuplicateParseWarnings(fileWarnings) .forEach( (triplet, fileLines) -> rows.add(getAggregateRow(triplet, fileLines, columnMetadataMap))); } else { fileWarnings.forEach( (filename, warnings) -> { for (ParseWarning w : warnings.getParseWarnings()) { rows.add(getRow(filename, w, columnMetadataMap)); } }); } TableAnswerElement answerElement = new TableAnswerElement(createMetadata(question)); answerElement.postProcessAnswer(_question, rows.build()); return answerElement; } ParseWarningAnswerer(ParseWarningQuestion question, IBatfish batfish); @Override TableAnswerElement answer(NetworkSnapshot snapshot);  }