@Test public void createVocabulariesListWithSupplierCreatesCorrectVocabularyRepresentations() { final List<org.phenotips.vocabularies.rest.model.Category> categoryReps = Arrays.asList(this.categoryRep1, this.categoryRep2); final Set<Vocabulary> vocabularies = new HashSet<>(); vocabularies.add(this.vocabulary1); vocabularies.add(this.vocabulary2); vocabularies.add(this.vocabulary3); final List<org.phenotips.vocabularies.rest.model.Vocabulary> vocabularyReps = this.component.createVocabulariesRepresentation(vocabularies, this.autolinker, this::categoriesSupplier); Assert.assertEquals(3, vocabularyReps.size()); sortById(vocabularyReps); final Set<String> aliasSet1 = new HashSet<>(); aliasSet1.add(VOCAB_1_ID); aliasSet1.add(ALIAS_1); final org.phenotips.vocabularies.rest.model.Vocabulary vocabRep1 = vocabularyReps.get(0); Assert.assertEquals(VOCAB_1_ID, vocabRep1.getIdentifier()); Assert.assertEquals(VOCAB_1_ID, vocabRep1.getName()); Assert.assertEquals(2, vocabRep1.getAliases().size()); Assert.assertEquals(aliasSet1, new HashSet<>(vocabRep1.getAliases())); Assert.assertEquals(VOCAB_1_SOURCE, vocabRep1.getDefaultSourceLocation()); Assert.assertEquals(VOCAB_1_SIZE, vocabRep1.getSize()); Assert.assertEquals(VOCAB_1_VERSION, vocabRep1.getVersion()); Assert.assertEquals(categoryReps, vocabRep1.getCategories()); final Set<String> aliasSet2 = new HashSet<>(); aliasSet2.add(VOCAB_2_ID); final org.phenotips.vocabularies.rest.model.Vocabulary vocabRep2 = vocabularyReps.get(1); Assert.assertEquals(VOCAB_2_ID, vocabRep2.getIdentifier()); Assert.assertEquals(VOCAB_2_ID, vocabRep2.getName()); Assert.assertEquals(1, vocabRep2.getAliases().size()); Assert.assertEquals(aliasSet2, new HashSet<>(vocabRep2.getAliases())); Assert.assertNull(vocabRep2.getDefaultSourceLocation()); Assert.assertEquals(VOCAB_2_SIZE, vocabRep2.getSize()); Assert.assertEquals(VOCAB_2_VERSION, vocabRep2.getVersion()); Assert.assertEquals(categoryReps, vocabRep2.getCategories()); final Set<String> aliasSet3 = new HashSet<>(); aliasSet3.add(VOCAB_3_ID); final org.phenotips.vocabularies.rest.model.Vocabulary vocabRep3 = vocabularyReps.get(2); Assert.assertEquals(VOCAB_3_ID, vocabRep3.getIdentifier()); Assert.assertEquals(VOCAB_3_ID, vocabRep3.getName()); Assert.assertEquals(1, vocabRep3.getAliases().size()); Assert.assertEquals(aliasSet3, new HashSet<>(vocabRep3.getAliases())); Assert.assertEquals(VOCAB_3_SOURCE, vocabRep3.getDefaultSourceLocation()); Assert.assertEquals(VOCAB_3_SIZE, vocabRep3.getSize()); Assert.assertNull(vocabRep3.getVersion()); Assert.assertEquals(categoryReps, vocabRep1.getCategories()); }
@Override public List<org.phenotips.vocabularies.rest.model.Vocabulary> createVocabulariesRepresentation( final Collection<Vocabulary> vocabularies, final Autolinker linker, final Function<Vocabulary, List<org.phenotips.vocabularies.rest.model.Category>> categorySupplier) { return vocabularies.stream() .map(vocabulary -> createLinkedVocabularyRepresentation(vocabulary, linker, categorySupplier)) .collect(Collectors.toList()); }
DefaultDomainObjectFactory implements DomainObjectFactory { @Override public List<org.phenotips.vocabularies.rest.model.Vocabulary> createVocabulariesRepresentation( final Collection<Vocabulary> vocabularies, final Autolinker linker, final Function<Vocabulary, List<org.phenotips.vocabularies.rest.model.Category>> categorySupplier) { return vocabularies.stream() .map(vocabulary -> createLinkedVocabularyRepresentation(vocabulary, linker, categorySupplier)) .collect(Collectors.toList()); } }
DefaultDomainObjectFactory implements DomainObjectFactory { @Override public List<org.phenotips.vocabularies.rest.model.Vocabulary> createVocabulariesRepresentation( final Collection<Vocabulary> vocabularies, final Autolinker linker, final Function<Vocabulary, List<org.phenotips.vocabularies.rest.model.Category>> categorySupplier) { return vocabularies.stream() .map(vocabulary -> createLinkedVocabularyRepresentation(vocabulary, linker, categorySupplier)) .collect(Collectors.toList()); }  }
DefaultDomainObjectFactory implements DomainObjectFactory { @Override public List<org.phenotips.vocabularies.rest.model.Vocabulary> createVocabulariesRepresentation( final Collection<Vocabulary> vocabularies, final Autolinker linker, final Function<Vocabulary, List<org.phenotips.vocabularies.rest.model.Category>> categorySupplier) { return vocabularies.stream() .map(vocabulary -> createLinkedVocabularyRepresentation(vocabulary, linker, categorySupplier)) .collect(Collectors.toList()); }  @Override org.phenotips.vocabularies.rest.model.Vocabulary createVocabularyRepresentation(Vocabulary vocabulary); @Override List<org.phenotips.vocabularies.rest.model.Vocabulary> createVocabulariesRepresentation(
        final Collection<Vocabulary> vocabularies,
        final Autolinker linker,
        final Function<Vocabulary, List<org.phenotips.vocabularies.rest.model.Category>> categorySupplier); @Override org.phenotips.vocabularies.rest.model.Vocabulary createLinkedVocabularyRepresentation(
        final Vocabulary vocabulary,
        final Autolinker linker,
        final Function<Vocabulary, List<org.phenotips.vocabularies.rest.model.Category>> categorySupplier); @Override org.phenotips.vocabularies.rest.model.Category createCategoryRepresentation(final String categoryId); @Override List<Category> createCategoriesRepresentation(
        final Collection<String> categoryIds,
        final Autolinker linker,
        final Function<String, List<org.phenotips.vocabularies.rest.model.Vocabulary>> vocabularySupplier); @Override org.phenotips.vocabularies.rest.model.Category createLinkedCategoryRepresentation(
        final String categoryId,
        final Autolinker linker,
        final Function<String, List<org.phenotips.vocabularies.rest.model.Vocabulary>> vocabularySupplier); }
DefaultDomainObjectFactory implements DomainObjectFactory { @Override public List<org.phenotips.vocabularies.rest.model.Vocabulary> createVocabulariesRepresentation( final Collection<Vocabulary> vocabularies, final Autolinker linker, final Function<Vocabulary, List<org.phenotips.vocabularies.rest.model.Category>> categorySupplier) { return vocabularies.stream() .map(vocabulary -> createLinkedVocabularyRepresentation(vocabulary, linker, categorySupplier)) .collect(Collectors.toList()); }  @Override org.phenotips.vocabularies.rest.model.Vocabulary createVocabularyRepresentation(Vocabulary vocabulary); @Override List<org.phenotips.vocabularies.rest.model.Vocabulary> createVocabulariesRepresentation(
        final Collection<Vocabulary> vocabularies,
        final Autolinker linker,
        final Function<Vocabulary, List<org.phenotips.vocabularies.rest.model.Category>> categorySupplier); @Override org.phenotips.vocabularies.rest.model.Vocabulary createLinkedVocabularyRepresentation(
        final Vocabulary vocabulary,
        final Autolinker linker,
        final Function<Vocabulary, List<org.phenotips.vocabularies.rest.model.Category>> categorySupplier); @Override org.phenotips.vocabularies.rest.model.Category createCategoryRepresentation(final String categoryId); @Override List<Category> createCategoriesRepresentation(
        final Collection<String> categoryIds,
        final Autolinker linker,
        final Function<String, List<org.phenotips.vocabularies.rest.model.Vocabulary>> vocabularySupplier); @Override org.phenotips.vocabularies.rest.model.Category createLinkedCategoryRepresentation(
        final String categoryId,
        final Autolinker linker,
        final Function<String, List<org.phenotips.vocabularies.rest.model.Vocabulary>> vocabularySupplier);  }