### Question:
RuleImpl implements Rule { @Override public String toString() { return Serializer.getSerialization(serializer -> serializer.writeRule(this)); } RuleImpl(final Conjunction<PositiveLiteral> head, final Conjunction<Literal> body); @Override int hashCode(); @Override boolean equals(final Object obj); @Override String toString(); @Override Conjunction<PositiveLiteral> getHead(); @Override Conjunction<Literal> getBody(); @Override T accept(StatementVisitor<T> statementVisitor); @Override Stream<Term> getTerms();  }### Answer:
@Test public void ruleToStringTest() { final Variable x = Expressions.makeUniversalVariable("X"); final Variable y = Expressions.makeExistentialVariable("Y"); final Variable z = Expressions.makeUniversalVariable("Z"); final Variable y2 = Expressions.makeUniversalVariable("Y"); final Constant d = Expressions.makeAbstractConstant("d"); final Constant c = Expressions.makeAbstractConstant("c"); final LanguageStringConstantImpl s = new LanguageStringConstantImpl("Test", "en"); final PositiveLiteral atom1 = Expressions.makePositiveLiteral("p", x, c); final PositiveLiteral atom2 = Expressions.makePositiveLiteral("p", x, z); final PositiveLiteral headAtom1 = Expressions.makePositiveLiteral("q", x, y); final PositiveLiteral positiveLiteral1 = Expressions.makePositiveLiteral("p", x, c); final PositiveLiteral positiveLiteral2 = Expressions.makePositiveLiteral("p", y2, x); final PositiveLiteral positiveLiteral3 = Expressions.makePositiveLiteral("q", x, d); final NegativeLiteral NegativeLiteral = Expressions.makeNegativeLiteral("r", x, d); final PositiveLiteral PositiveLiteral4 = Expressions.makePositiveLiteral("s", c, s); final List<Literal> LiteralList = Arrays.asList(positiveLiteral1, positiveLiteral2, positiveLiteral3, NegativeLiteral, PositiveLiteral4); final Conjunction<Literal> bodyLiterals = Expressions.makeConjunction(atom1, atom2); final Conjunction<PositiveLiteral> headPositiveLiterals = Expressions.makePositiveConjunction(headAtom1); final Conjunction<Literal> bodyConjunction = new ConjunctionImpl<>(LiteralList); final Rule rule1 = new RuleImpl(headPositiveLiterals, bodyLiterals); final Rule rule2 = new RuleImpl(headPositiveLiterals, bodyConjunction); assertEquals("q(?X, !Y) :- p(?X, c), p(?X, ?Z) .", rule1.toString()); assertEquals("q(?X, !Y) :- p(?X, c), p(?Y, ?X), q(?X, d), ~r(?X, d), s(c, \"Test\"@en) .", rule2.toString()); }