InterProTsvParser { public static ImmutableMap<String, OntologyTerm> parse(TsvStreamer tsvStreamer) { return tsvStreamer.get() .filter(line -> line.length > 2) .filter(line -> line[ACCESSION_COLUMN_INDEX].startsWith("IPR")) .collect(toImmutableMap( line -> line[ACCESSION_COLUMN_INDEX], line -> OntologyTerm.create( line[ACCESSION_COLUMN_INDEX], line[NAME_COLUMN_INDEX] + " (" + line[TYPE_COLUMN_INDEX].toLowerCase() + ")"))); } protected  InterProTsvParser(); static ImmutableMap<String, OntologyTerm> parse(TsvStreamer tsvStreamer);  }
@Test void parseLine() { when(tsvStreamerMock.get()) .thenReturn(Stream.<String[]>of(new String[] {KRINGLE, IPR000001, DOMAIN})); Map<String, OntologyTerm> map = InterProTsvParser.parse(tsvStreamerMock); assertThat(map.get(IPR000001)) .isEqualTo(OntologyTerm.create(IPR000001, KRINGLE + " (" + DOMAIN.toLowerCase() + ")")); }
@Test void ignoreLineWithoutValidAccessionPrefix() { when(tsvStreamerMock.get()) .thenReturn(Stream.<String[]>of(new String[] {"foo:0000001", "bar"})); Map<String, OntologyTerm> map = InterProTsvParser.parse(tsvStreamerMock); assertThat(map).isEmpty(); }
@Test void incompleteLinesAreIgnored() { when(tsvStreamerMock.get()) .thenReturn(Stream.<String[]>of(new String[] {IPR000001, "", "", "", "", ""})); Map<String, OntologyTerm> map = InterProTsvParser.parse(tsvStreamerMock); assertThat(map).isEmpty(); }
@Test void emptyLinesAreIgnored() { when(tsvStreamerMock.get()) .thenReturn(Stream.of(new String[] {}, new String[] {"", "", "", "", "", ""})); Map<String, OntologyTerm> map = InterProTsvParser.parse(tsvStreamerMock); assertThat(map).isEmpty(); }