### Question:
GazeteerServiceImpl implements GazeteerService { public void parseGazeteer(Gazeteer aGaz, InputStream aStream, List<GazeteerEntry> aTarget) throws IOException { int lineNumber = 0; LineIterator i = IOUtils.lineIterator(aStream, UTF_8); while (i.hasNext()) { lineNumber++; String line = i.nextLine().trim(); if (line.isEmpty() || line.startsWith("#")) { continue; } String[] fields = line.split("\t"); if (fields.length == 2) { String text = trimToNull(fields[0]); String label = trimToNull(fields[1]); if (label != null && text != null) { aTarget.add(new GazeteerEntry(text, label)); } } else { throw new IOException("Unable to parse line " + lineNumber + " of [" + aGaz.getName() + "] - no tab character found: [" + line + "]"); } } } @Autowired  GazeteerServiceImpl(RepositoryProperties aRepositoryProperties,
            EntityManager aEntityManager); @Override @Transactional List<Gazeteer> listGazeteers(Recommender aRecommender); @Override @Transactional void createOrUpdateGazeteer(Gazeteer aGazeteer); @Override @Transactional void importGazeteerFile(Gazeteer aGazeteer, InputStream aStream); @Override File getGazeteerFile(Gazeteer aGazeteer); @Override @Transactional void deleteGazeteers(Gazeteer aGazeteer); @Override List<GazeteerEntry> readGazeteerFile(Gazeteer aGaz); void parseGazeteer(Gazeteer aGaz, InputStream aStream, List<GazeteerEntry> aTarget); @Override @Transactional boolean existsGazeteer(Recommender aRecommender, String aName);  }### Answer:
@Test public void thatGazeteerCommentLineIsIgnored() throws Exception { Gazeteer gaz = new Gazeteer("gaz", rec1); String gazeteer = String.join("\n", "# This is a comment", "John\tPER"); List<GazeteerEntry> data = new ArrayList<>(); sut.parseGazeteer(gaz, toInputStream(gazeteer, UTF_8), data); assertThat(data).containsExactlyInAnyOrder( new GazeteerEntry("John", "PER")); }
@Test public void thatInvalidGazeteerGeneratesException() throws Exception { Gazeteer gaz = new Gazeteer("gaz", rec1); List<GazeteerEntry> data = new ArrayList<>(); String gazeteer1 = String.join("\n", "Bill\tPER", "John PER"); assertThatExceptionOfType(IOException.class) .describedAs("Line without tab generated exception") .isThrownBy(() -> sut.parseGazeteer(gaz, toInputStream(gazeteer1, UTF_8), data)) .withMessageContaining("Unable to parse line 2"); String gazeteer2 = "Bill\tPER\tDUMMY"; assertThatExceptionOfType(IOException.class) .describedAs("Line without too many fields") .isThrownBy(() -> sut.parseGazeteer(gaz, toInputStream(gazeteer2, UTF_8), data)) .withMessageContaining("Unable to parse line 1"); }