CoansysOutputConverter implements OutputConverter<String, PicOut>, Serializable { @Override public JavaPairRDD<String, PicOut> convertMatchedCitations(JavaPairRDD<MatchableEntity, IdWithSimilarity> matchedCitations) { Preconditions.checkNotNull(matchedCitations); JavaPairRDD<String, Reference> matchedReferences = matchedCitations.mapToPair(entityWithId -> matchableEntityWithSimilarityConverter.convertToReference(entityWithId)); JavaPairRDD<String, PicOut> docIdWithPicOut = matchedReferences.groupByKey().mapToPair(srcDocIdReferences -> referenceToPicOutConverter.convertToPicOut(srcDocIdReferences)); return docIdWithPicOut; }  @Override JavaPairRDD<String, PicOut> convertMatchedCitations(JavaPairRDD<MatchableEntity, IdWithSimilarity> matchedCitations); void setMatchableEntityWithSimilarityConverter(MatchableEntityWithSimilarityConverter matchableEntityWithSimilarityConverter); void setReferenceToPicOutConverter(ReferenceToPicOutConverter referenceToPicOutConverter);  }
@Test(expectedExceptions=NullPointerException.class) public void convertMatchedCitations_NULL() { coansysOutputConverter.convertMatchedCitations(null); }
@Test public void convertMatchedCitations() throws Exception { doReturn(matchedReferences).when(matchedCitations).mapToPair(Mockito.any()); doReturn(docIdReferences).when(matchedReferences).groupByKey(); doReturn(docIdWithPicOut).when(docIdReferences).mapToPair(Mockito.any()); JavaPairRDD<String, PicOut> retDocIdWithPicOut = coansysOutputConverter.convertMatchedCitations(matchedCitations); assertTrue(docIdWithPicOut == retDocIdWithPicOut); verify(matchedCitations).mapToPair(convertToReferenceFunction.capture()); assertConvertToReferenceFunction(convertToReferenceFunction.getValue()); verify(docIdReferences).mapToPair(convertToPicOutFunction.capture()); assertConvertToPicOutFunction(convertToPicOutFunction.getValue()); }