### Question:
Serializer { public void writeTerm(Term term) throws IOException { try { term.accept(this.serializerTermVisitor); } catch (Serializer.RuntimeIoException e) { throw e.getIoException(); } } Serializer(final Writer writer, final Function<String, String> iriTransformer);  Serializer(final Writer writer);  Serializer(final Writer writer, PrefixDeclarationRegistry prefixDeclarationRegistry); void writeStatement(Statement statement); void writeFact(Fact fact); void writeRule(Rule rule); void writeDataSourceDeclaration(DataSourceDeclaration dataSourceDeclaration); void writeLiteral(Literal literal); void writePositiveLiteral(Predicate predicate, List<Term> arguments); void writeLiteralConjunction(final Conjunction<? extends Literal> literals); void writePredicate(Predicate predicate); void writeTerm(Term term); void writeAbstractConstant(AbstractConstant abstractConstant); void writeDatatypeConstant(DatatypeConstant datatypeConstant); void writeDatatypeConstantNoAbbreviations(DatatypeConstant datatypeConstant); void writeUniversalVariable(UniversalVariable universalVariable); void writeExistentialVariable(ExistentialVariable existentialVariable); void writeNamedNull(NamedNull namedNull); boolean writePrefixDeclarationRegistry(PrefixDeclarationRegistry prefixDeclarationRegistry); void writeLanguageStringConstant(LanguageStringConstant languageStringConstant); void writeCommand(Command command); static String getSerialization(SerializationWriter writeAction); static final String STATEMENT_END; static final Function<String, String> identityIriSerializer; }### Answer:
@Test public void serializeDatatypeConstant() throws IOException { serializer.writeTerm(datatypeConstantGeneral); assertEquals("\"abc\"^^<http: }
@Test public void serializeDatatypeConstantString() throws IOException { serializer.writeTerm(datatypeConstantString); assertEquals("\"abc\"", writer.toString()); }
@Test public void serializeDatatypeConstantInteger() throws IOException { serializer.writeTerm(datatypeConstantInteger); assertEquals("123", writer.toString()); }
@Test public void serializeExistentialVariable() throws IOException { serializer.writeTerm(existentialVariable); assertEquals("!X", writer.toString()); }
@Test public void serializeUniversalVariable() throws IOException { serializer.writeTerm(universalVariable); assertEquals("?X", writer.toString()); }
@Test public void serializeLanguageStringConstant() throws IOException { serializer.writeTerm(languageStringConstant); assertEquals("\"abc\"@de", writer.toString()); }
@Test public void serializeNamedNull() throws IOException { serializer.writeTerm(namedNull); assertEquals("_:n1", writer.toString()); }
@Test public void serializeAbstractConstantWithPrefixDeclarations() throws IOException { final MergingPrefixDeclarationRegistry prefixes = new MergingPrefixDeclarationRegistry(); prefixes.setPrefixIri("eg:", "http: Serializer prefSerializer = new Serializer(writer, prefixes); prefSerializer.writeTerm(abstractConstant); assertEquals("eg:test", writer.toString()); }
@Test public void serializeDatatypeConstantWithPrefixDeclarations() throws IOException { final MergingPrefixDeclarationRegistry prefixes = new MergingPrefixDeclarationRegistry(); prefixes.setPrefixIri("eg:", "http: Serializer prefSerializer = new Serializer(writer, prefixes); prefSerializer.writeTerm(datatypeConstantGeneral); assertEquals("\"abc\"^^eg:test", writer.toString()); }
@Test(expected = IOException.class) public void serializeAbstractConstant_fails() throws IOException { getThrowingSerializer().writeTerm(abstractConstant); }
@Test(expected = IOException.class) public void serializeDatatypeConstant_fails() throws IOException { getThrowingSerializer().writeTerm(datatypeConstantGeneral); }
@Test(expected = IOException.class) public void serializeExistentialVariable_fails() throws IOException { getThrowingSerializer().writeTerm(existentialVariable); }
@Test(expected = IOException.class) public void serializeUniversalVariable_fails() throws IOException { getThrowingSerializer().writeTerm(universalVariable); }
@Test(expected = IOException.class) public void serializeLanguageStringConstant_fails() throws IOException { getThrowingSerializer().writeTerm(languageStringConstant); }
@Test(expected = IOException.class) public void serializeNamedNull_fails() throws IOException { getThrowingSerializer().writeTerm(namedNull); }