### Question:
KnowledgeBase implements Iterable<Statement> { public void writeKnowledgeBase(Writer writer) throws IOException { Serializer serializer = new Serializer(writer, prefixDeclarationRegistry); boolean makeSeperator = serializer.writePrefixDeclarationRegistry(prefixDeclarationRegistry); for (DataSourceDeclaration dataSourceDeclaration : this.getDataSourceDeclarations()) { if (makeSeperator) { writer.write('\n'); makeSeperator = false; } serializer.writeDataSourceDeclaration(dataSourceDeclaration); writer.write('\n'); } makeSeperator |= !this.getDataSourceDeclarations().isEmpty(); for (Fact fact : this.getFacts()) { if (makeSeperator) { writer.write('\n'); makeSeperator = false; } serializer.writeFact(fact); writer.write('\n'); } makeSeperator |= !this.getFacts().isEmpty(); for (Rule rule : this.getRules()) { if (makeSeperator) { writer.write('\n'); makeSeperator = false; } serializer.writeRule(rule); writer.write('\n'); } }  void addListener(final KnowledgeBaseListener listener); void deleteListener(final KnowledgeBaseListener listener); void addStatement(final Statement statement); void addStatements(final Collection<? extends Statement> statements); void addStatements(final Statement... statements); int removeStatement(final Statement statement); int removeStatements(final Collection<? extends Statement> statements); int removeStatements(final Statement... statements); List<Rule> getRules(); List<Fact> getFacts(); List<DataSourceDeclaration> getDataSourceDeclarations(); Collection<Statement> getStatements(); @Override Iterator<Statement> iterator(); void importRulesFile(File file, AdditionalInputParser parseFunction); void mergePrefixDeclarations(PrefixDeclarationRegistry prefixDeclarationRegistry); PrefixDeclarationRegistry getPrefixDeclarationRegistry(); String getBaseIri(); Iterator<Entry<String, String>> getPrefixes(); String getPrefixIri(String prefixName); String resolvePrefixedName(String prefixedName); String unresolveAbsoluteIri(String iri); void writeKnowledgeBase(Writer writer); @Deprecated void writeKnowledgeBase(String filePath);  }### Answer:
@Test public void writeKnowledgeBase_justFacts_succeeds() throws IOException { StringWriter writer = new StringWriter(); this.kb.writeKnowledgeBase(writer); assertEquals("P(c) .\nP(d) .\nQ(c) .\n", writer.toString()); }