DefaultOutputWriter implements OutputWriter<MatchableEntity, IdWithSimilarity> { @Override public void writeMatchedCitations(JavaPairRDD<MatchableEntity, IdWithSimilarity> matchedCitations, String path) { matchedCitations .mapToPair(x -> new Tuple2<TextWithBytesWritable, Text>( new TextWithBytesWritable(x._1.id(), x._1.data().toByteArray()), new Text(x._2.getSimilarity() + ":" + x._2.getId()))) .saveAsNewAPIHadoopFile(path, TextWithBytesWritable.class, Text.class, SequenceFileOutputFormat.class); }  @Override void writeMatchedCitations(JavaPairRDD<MatchableEntity, IdWithSimilarity> matchedCitations, String path);  }
@Test public void writeMatchedCitations() throws Exception { doReturn(mappedMatchedCitations).when(matchedCitations).mapToPair(any()); outputWriter.writeMatchedCitations(matchedCitations, "/output/path"); verify(matchedCitations).mapToPair(mapToWritableFunction.capture()); assertMapToWritableFunction(mapToWritableFunction.getValue()); verify(mappedMatchedCitations).saveAsNewAPIHadoopFile("/output/path", TextWithBytesWritable.class, Text.class, SequenceFileOutputFormat.class); }