@Test public void extractIdMapping() throws Exception { doReturn(filteredDocumentsMetadataRdd).when(documentsMetadataRdd).filter(any()); doReturn(documentsMetadataWithExternalIdKeyRdd).when(filteredDocumentsMetadataRdd).keyBy(any()); doReturn(groupedByKeyDocumentsMetadataRdd).when(documentsMetadataWithExternalIdKeyRdd).groupByKey(); doReturn(documentsMetadataWithUniqueExternalIdKeyRdd).when(groupedByKeyDocumentsMetadataRdd).mapValues(any()); doReturn(idMappingRdd).when(documentsMetadataWithUniqueExternalIdKeyRdd).mapValues(any()); JavaPairRDD<String, String> retIdMappingRdd = idMappingExtractor.extractIdMapping(documentsMetadataRdd, "someIdType", pickOneDocumentMetadataFunction); assertTrue(retIdMappingRdd == idMappingRdd); verify(documentsMetadataRdd).filter(filterDocumentsMetadataFunctionArg.capture()); assertFilterFunction(filterDocumentsMetadataFunctionArg.getValue()); verify(filteredDocumentsMetadataRdd).keyBy(attachExternalIdKeyFunctionArg.capture()); assertAttachExternalIdKeyFunction(attachExternalIdKeyFunctionArg.getValue()); verify(documentsMetadataWithExternalIdKeyRdd).groupByKey(); verify(groupedByKeyDocumentsMetadataRdd).mapValues(same(pickOneDocumentMetadataFunction)); verify(documentsMetadataWithUniqueExternalIdKeyRdd).mapValues(extractIdFunctionArg.capture()); assertExtractIdFunction(extractIdFunctionArg.getValue()); }
public JavaPairRDD<String, String> extractIdMapping(JavaRDD<DocumentMetadata> documents, String idType, Function<Iterable<DocumentMetadata>, DocumentMetadata> pickSingle) { JavaPairRDD<String, String> externalIdToId = documents .filter(document -> document.getExternalIdentifiers() != null && document.getExternalIdentifiers().containsKey(idType)) .keyBy(document -> document.getExternalIdentifiers().get(idType).toString()) .groupByKey() .mapValues(pickSingle) .mapValues(document -> document.getId().toString()); return externalIdToId; }
IdentifierMappingExtractor implements Serializable { public JavaPairRDD<String, String> extractIdMapping(JavaRDD<DocumentMetadata> documents, String idType, Function<Iterable<DocumentMetadata>, DocumentMetadata> pickSingle) { JavaPairRDD<String, String> externalIdToId = documents .filter(document -> document.getExternalIdentifiers() != null && document.getExternalIdentifiers().containsKey(idType)) .keyBy(document -> document.getExternalIdentifiers().get(idType).toString()) .groupByKey() .mapValues(pickSingle) .mapValues(document -> document.getId().toString()); return externalIdToId; } }
IdentifierMappingExtractor implements Serializable { public JavaPairRDD<String, String> extractIdMapping(JavaRDD<DocumentMetadata> documents, String idType, Function<Iterable<DocumentMetadata>, DocumentMetadata> pickSingle) { JavaPairRDD<String, String> externalIdToId = documents .filter(document -> document.getExternalIdentifiers() != null && document.getExternalIdentifiers().containsKey(idType)) .keyBy(document -> document.getExternalIdentifiers().get(idType).toString()) .groupByKey() .mapValues(pickSingle) .mapValues(document -> document.getId().toString()); return externalIdToId; }  }
IdentifierMappingExtractor implements Serializable { public JavaPairRDD<String, String> extractIdMapping(JavaRDD<DocumentMetadata> documents, String idType, Function<Iterable<DocumentMetadata>, DocumentMetadata> pickSingle) { JavaPairRDD<String, String> externalIdToId = documents .filter(document -> document.getExternalIdentifiers() != null && document.getExternalIdentifiers().containsKey(idType)) .keyBy(document -> document.getExternalIdentifiers().get(idType).toString()) .groupByKey() .mapValues(pickSingle) .mapValues(document -> document.getId().toString()); return externalIdToId; }  JavaPairRDD<String, String> extractIdMapping(JavaRDD<DocumentMetadata> documents, String idType, Function<Iterable<DocumentMetadata>, DocumentMetadata> pickSingle); }
IdentifierMappingExtractor implements Serializable { public JavaPairRDD<String, String> extractIdMapping(JavaRDD<DocumentMetadata> documents, String idType, Function<Iterable<DocumentMetadata>, DocumentMetadata> pickSingle) { JavaPairRDD<String, String> externalIdToId = documents .filter(document -> document.getExternalIdentifiers() != null && document.getExternalIdentifiers().containsKey(idType)) .keyBy(document -> document.getExternalIdentifiers().get(idType).toString()) .groupByKey() .mapValues(pickSingle) .mapValues(document -> document.getId().toString()); return externalIdToId; }  JavaPairRDD<String, String> extractIdMapping(JavaRDD<DocumentMetadata> documents, String idType, Function<Iterable<DocumentMetadata>, DocumentMetadata> pickSingle);  }