@Test public void testFilterFiles() { DefinedStructuresQuestion fileFilter = new DefinedStructuresQuestion("file1", null, ".*", ".*"); TestBatfish tb = new TestBatfish(); TableAnswerElement answer = new DefinedStructuresAnswerer(fileFilter, tb).answer(tb.getSnapshot()); assertThat( answer, hasRows( containsInAnyOrder( allOf( hasColumn(COL_STRUCTURE_NAME, "name1", Schema.STRING), hasColumn( COL_SOURCE_LINES, new FileLines("file1", ImmutableSortedSet.of(1)), Schema.FILE_LINES), hasColumn(COL_STRUCT_TYPE, "type1", Schema.STRING)), allOf( hasColumn(COL_STRUCTURE_NAME, "name2", Schema.STRING), hasColumn( COL_SOURCE_LINES, new FileLines("file1", ImmutableSortedSet.of(2)), Schema.FILE_LINES), hasColumn(COL_STRUCT_TYPE, "type1", Schema.STRING))))); }
@Override public TableAnswerElement answer(NetworkSnapshot snapshot) { DefinedStructuresQuestion question = (DefinedStructuresQuestion) _question; Multiset<Row> structures = rawAnswer(snapshot, question); TableAnswerElement answer = new TableAnswerElement(createMetadata(question)); answer.postProcessAnswer(question, structures); return answer; }
DefinedStructuresAnswerer extends Answerer { @Override public TableAnswerElement answer(NetworkSnapshot snapshot) { DefinedStructuresQuestion question = (DefinedStructuresQuestion) _question; Multiset<Row> structures = rawAnswer(snapshot, question); TableAnswerElement answer = new TableAnswerElement(createMetadata(question)); answer.postProcessAnswer(question, structures); return answer; } }
DefinedStructuresAnswerer extends Answerer { @Override public TableAnswerElement answer(NetworkSnapshot snapshot) { DefinedStructuresQuestion question = (DefinedStructuresQuestion) _question; Multiset<Row> structures = rawAnswer(snapshot, question); TableAnswerElement answer = new TableAnswerElement(createMetadata(question)); answer.postProcessAnswer(question, structures); return answer; } DefinedStructuresAnswerer(Question question, IBatfish batfish); }
DefinedStructuresAnswerer extends Answerer { @Override public TableAnswerElement answer(NetworkSnapshot snapshot) { DefinedStructuresQuestion question = (DefinedStructuresQuestion) _question; Multiset<Row> structures = rawAnswer(snapshot, question); TableAnswerElement answer = new TableAnswerElement(createMetadata(question)); answer.postProcessAnswer(question, structures); return answer; } DefinedStructuresAnswerer(Question question, IBatfish batfish); @Override TableAnswerElement answer(NetworkSnapshot snapshot); static TableMetadata createMetadata(Question question); }
DefinedStructuresAnswerer extends Answerer { @Override public TableAnswerElement answer(NetworkSnapshot snapshot) { DefinedStructuresQuestion question = (DefinedStructuresQuestion) _question; Multiset<Row> structures = rawAnswer(snapshot, question); TableAnswerElement answer = new TableAnswerElement(createMetadata(question)); answer.postProcessAnswer(question, structures); return answer; } DefinedStructuresAnswerer(Question question, IBatfish batfish); @Override TableAnswerElement answer(NetworkSnapshot snapshot); static TableMetadata createMetadata(Question question); static final String COL_SOURCE_LINES; static final String COL_STRUCTURE_NAME; static final String COL_STRUCT_TYPE; }