@Test public void convertCitations() throws Exception { doReturn(convertedCitations).when(inputCitations).flatMapToPair(any()); JavaPairRDD<String, MatchableEntity> retConvertedCitations = referenceMetadataInputConverter.convertCitations(inputCitations); assertTrue(retConvertedCitations == convertedCitations); verify(inputCitations).flatMapToPair(convertCitationFunction.capture()); assertConvertCitationFunction(convertCitationFunction.getValue()); assertConvertCitationFunction_TOO_LONG_RAW_TEXT(convertCitationFunction.getValue()); }
@Override public JavaPairRDD<String, MatchableEntity> convertCitations(JavaPairRDD<String, ReferenceMetadata> inputCitations) { JavaPairRDD<String, MatchableEntity> citationEntities = inputCitations .flatMapToPair(inputCitation -> { List<Tuple2<String, MatchableEntity>> list = Lists.newArrayList(); MatchableEntity entity = converter.convertToMatchableEntity(inputCitation._1, inputCitation._2); if (entity.rawText().get().length() > MAX_CITATION_LENGTH) { log.error("RawText of citation " + inputCitation._1 + " exceeds length limit (" + MAX_CITATION_LENGTH + ")."); return list; } list.add(new Tuple2<String, MatchableEntity>(inputCitation._1, entity)); return list; }); return citationEntities; }
ReferenceMetadataInputConverter implements InputCitationConverter<String, ReferenceMetadata>, Serializable { @Override public JavaPairRDD<String, MatchableEntity> convertCitations(JavaPairRDD<String, ReferenceMetadata> inputCitations) { JavaPairRDD<String, MatchableEntity> citationEntities = inputCitations .flatMapToPair(inputCitation -> { List<Tuple2<String, MatchableEntity>> list = Lists.newArrayList(); MatchableEntity entity = converter.convertToMatchableEntity(inputCitation._1, inputCitation._2); if (entity.rawText().get().length() > MAX_CITATION_LENGTH) { log.error("RawText of citation " + inputCitation._1 + " exceeds length limit (" + MAX_CITATION_LENGTH + ")."); return list; } list.add(new Tuple2<String, MatchableEntity>(inputCitation._1, entity)); return list; }); return citationEntities; } }
ReferenceMetadataInputConverter implements InputCitationConverter<String, ReferenceMetadata>, Serializable { @Override public JavaPairRDD<String, MatchableEntity> convertCitations(JavaPairRDD<String, ReferenceMetadata> inputCitations) { JavaPairRDD<String, MatchableEntity> citationEntities = inputCitations .flatMapToPair(inputCitation -> { List<Tuple2<String, MatchableEntity>> list = Lists.newArrayList(); MatchableEntity entity = converter.convertToMatchableEntity(inputCitation._1, inputCitation._2); if (entity.rawText().get().length() > MAX_CITATION_LENGTH) { log.error("RawText of citation " + inputCitation._1 + " exceeds length limit (" + MAX_CITATION_LENGTH + ")."); return list; } list.add(new Tuple2<String, MatchableEntity>(inputCitation._1, entity)); return list; }); return citationEntities; }  }
ReferenceMetadataInputConverter implements InputCitationConverter<String, ReferenceMetadata>, Serializable { @Override public JavaPairRDD<String, MatchableEntity> convertCitations(JavaPairRDD<String, ReferenceMetadata> inputCitations) { JavaPairRDD<String, MatchableEntity> citationEntities = inputCitations .flatMapToPair(inputCitation -> { List<Tuple2<String, MatchableEntity>> list = Lists.newArrayList(); MatchableEntity entity = converter.convertToMatchableEntity(inputCitation._1, inputCitation._2); if (entity.rawText().get().length() > MAX_CITATION_LENGTH) { log.error("RawText of citation " + inputCitation._1 + " exceeds length limit (" + MAX_CITATION_LENGTH + ")."); return list; } list.add(new Tuple2<String, MatchableEntity>(inputCitation._1, entity)); return list; }); return citationEntities; }  @Override JavaPairRDD<String, MatchableEntity> convertCitations(JavaPairRDD<String, ReferenceMetadata> inputCitations); void setConverter(ReferenceMetadataToMatchableConverter converter); }
ReferenceMetadataInputConverter implements InputCitationConverter<String, ReferenceMetadata>, Serializable { @Override public JavaPairRDD<String, MatchableEntity> convertCitations(JavaPairRDD<String, ReferenceMetadata> inputCitations) { JavaPairRDD<String, MatchableEntity> citationEntities = inputCitations .flatMapToPair(inputCitation -> { List<Tuple2<String, MatchableEntity>> list = Lists.newArrayList(); MatchableEntity entity = converter.convertToMatchableEntity(inputCitation._1, inputCitation._2); if (entity.rawText().get().length() > MAX_CITATION_LENGTH) { log.error("RawText of citation " + inputCitation._1 + " exceeds length limit (" + MAX_CITATION_LENGTH + ")."); return list; } list.add(new Tuple2<String, MatchableEntity>(inputCitation._1, entity)); return list; }); return citationEntities; }  @Override JavaPairRDD<String, MatchableEntity> convertCitations(JavaPairRDD<String, ReferenceMetadata> inputCitations); void setConverter(ReferenceMetadataToMatchableConverter converter);  }