InMemoryUnitsDAO implements UnitsDAO { @Override public void toTSV(Writer writer) { PrintWriter pw = new PrintWriter(writer); for (Unit unit : this.getUnits()) { URI documentURI = unit.getDocumentURI(); int begin = unit.getBegin(); int end = unit.getEnd(); for (Map.Entry<String, String> annotatorIdAndClass : unit .getClassesByAnnotatorId().entrySet()) { String annotatorId = annotatorIdAndClass.getKey(); String annotatorClass = annotatorIdAndClass.getValue(); pw.format("%s\t%d\t%d\t%s\t%s%n", documentURI, begin, end, annotatorId, annotatorClass); } } }  @Override void addUnitItem(URI documentURI, int begin, int end,
                            String annotatorId, String annotatorClass); @Override Iterable<Unit> getUnits(); @Override void toTSV(Writer writer); @Override void addUnitsFromTSV(Reader reader);  }
@Test public void testToTSV() { List<String> tsvLines = Lists.newArrayList(daoToString().split( "[\\r\\n]+")); assertEquals(6, tsvLines.size()); assertTrue(tsvLines.contains("1\t11\t15\t1\tone")); }