CoansysOutputWriter implements OutputWriter<String, PicOut> { @Override public void writeMatchedCitations(JavaPairRDD<String, PicOut> srcDocIdPicOuts, String path) { Preconditions.checkNotNull(srcDocIdPicOuts); Preconditions.checkNotNull(path); srcDocIdPicOuts .mapToPair(srcDocIdPicOut -> new Tuple2<Text, BytesWritable>(new Text(srcDocIdPicOut._1()), new BytesWritable(srcDocIdPicOut._2().toByteArray()))) .saveAsNewAPIHadoopFile(path, Text.class, BytesWritable.class, SequenceFileOutputFormat.class); }  @Override void writeMatchedCitations(JavaPairRDD<String, PicOut> srcDocIdPicOuts, String path);  }
@Test(expectedExceptions=NullPointerException.class) public void writeMatchedCitations_NULL_path() { coansysOutputWriter.writeMatchedCitations(srcDocIdPicOutRdd, null); }
@Test(expectedExceptions=NullPointerException.class) public void writeMatchedCitations_NULL_srcDocIdPicOuts() { coansysOutputWriter.writeMatchedCitations(null, "/path"); }
@Test public void writeMatchedCitations() throws Exception { String path = "/path"; doReturn(srcDocIdPicOutWritableRdd).when(srcDocIdPicOutRdd).mapToPair(Mockito.any()); coansysOutputWriter.writeMatchedCitations(srcDocIdPicOutRdd, path); verify(srcDocIdPicOutWritableRdd).saveAsNewAPIHadoopFile(path, Text.class, BytesWritable.class, SequenceFileOutputFormat.class); verify(srcDocIdPicOutRdd).mapToPair(convertToWritableFunction.capture()); assertConvertToWritableFunction(convertToWritableFunction.getValue()); }