GeneFactory { private Set<GeneIdentifier> createKnownGeneIds() { ImmutableSet.Builder<GeneIdentifier> geneIdentifierBuilder = ImmutableSet.builder(); int identifiers = 0; int noEntrezId = 0; for (String geneSymbol : jannovarData.getTmByGeneSymbol().keySet()) { Collection<TranscriptModel> transcriptModels = jannovarData.getTmByGeneSymbol().get(geneSymbol); GeneIdentifier geneIdentifier = transcriptModels.stream() .filter(Objects::nonNull) .filter(transcriptModel -> transcriptModel.getGeneID() != null) .filter(transcriptModel -> !transcriptModel.getGeneID().equals("null")) .map(toGeneIdentifier()) .distinct() .findFirst() .orElse(GeneIdentifier.builder().geneSymbol(geneSymbol).build()); if (geneIdentifier.getEntrezId().isEmpty()) { noEntrezId++; logger.debug("No geneId associated with gene symbol {} geneId set to {}", geneSymbol, geneIdentifier); } identifiers++; geneIdentifierBuilder.add(geneIdentifier); } int geneIds = identifiers - noEntrezId; logger.debug("Created {} gene identifiers ({} genes, {} without EntrezId)", identifiers, geneIds, noEntrezId); geneIdentifiers = geneIdentifierBuilder.build(); return geneIdentifiers; } GeneFactory(JannovarData jannovarData); List<Gene> createKnownGenes(); Set<GeneIdentifier> getGeneIdentifiers();  }
@Test public void testCreateKnownGeneIds() { Set<GeneIdentifier> expected = Sets.newHashSet(TestFactory.buildGeneIdentifiers()); Set<GeneIdentifier> knownGeneIds = instance.getGeneIdentifiers(); assertThat(knownGeneIds, equalTo(expected)); }