import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import eu.etaxonomy.cdm.common.CdmUtils;
import eu.etaxonomy.cdm.io.common.CdmApplicationAwareDefaultImport;
import eu.etaxonomy.cdm.io.descriptive.owl.in.StructureTreeOwlImportConfigurator;
+import eu.etaxonomy.cdm.model.common.IdentifiableSource;
import eu.etaxonomy.cdm.model.common.Language;
+import eu.etaxonomy.cdm.model.media.Media;
+import eu.etaxonomy.cdm.model.media.MediaRepresentationPart;
+import eu.etaxonomy.cdm.model.media.MediaUtils;
+import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
import eu.etaxonomy.cdm.model.term.DefinedTerm;
+import eu.etaxonomy.cdm.model.term.DefinedTermBase;
import eu.etaxonomy.cdm.model.term.FeatureNode;
import eu.etaxonomy.cdm.model.term.FeatureTree;
import eu.etaxonomy.cdm.model.term.Representation;
List<FeatureTree> trees = featureTreeService.listByTitle(FeatureTree.class, treeLabel, MatchMode.EXACT, null, null, null, null, null);
List<String> nodeProperties = new ArrayList<>();
nodeProperties.add("term");
+ nodeProperties.add("term.media");
FeatureTree tree = featureTreeService.loadWithNodes(trees.iterator().next().getUuid(), null, nodeProperties);
assertNotNull("featureTree should not be null", tree);
assertEquals("wrong symbol", "infloSymbol", inflorescence.getSymbol());
assertEquals("wrong symbol2", "infloSymbol2", inflorescence.getSymbol2());
- String englishDescription = inflorescence.getDescription(Language.ENGLISH());
- assertTrue("Description not found", CdmUtils.isNotBlank(englishDescription));
- assertEquals("Description wrong", inflorescenceDescription, englishDescription);
+ Set<Media> mediaSet = inflorescence.getMedia();
+ assertEquals("wrong number of media", 1, mediaSet.size());
+ Media media = mediaSet.iterator().next();
+ MediaRepresentationPart part = MediaUtils.getFirstMediaRepresentationPart(media);
+ assertNotNull("media part not found", part);
+ assertEquals("incorrect URI", URI.create("https://upload.wikimedia.org/wikipedia/commons/8/82/Aloe_hereroensis_Auob_C15.JPG"), part.getUri());
+ assertEquals("incorrect title", "Aloe hereroensis", media.getTitle(Language.DEFAULT()).getText());
+
+ Representation englishRepresentation = inflorescence.getRepresentation(Language.ENGLISH());
+ assertTrue("Description not found", CdmUtils.isNotBlank(englishRepresentation.getDescription()));
+ assertEquals("Description wrong", inflorescenceDescription, englishRepresentation.getDescription());
+ assertEquals("wrong plural", "inflorescences", englishRepresentation.getPlural());
+ assertEquals("wrong label abbrev", "inflo", englishRepresentation.getAbbreviatedLabel());
// german representation
assertEquals("wrong number of representations", 2, inflorescence.getRepresentations().size());
assertEquals("Wrong vocabulary label", vocLabel, termVoc.getTitleCache());
assertEquals(82, termVoc.getTerms().size());
+ Set<DefinedTermBase> terms = termVoc.getTerms();
+ for (DefinedTermBase definedTermBase : terms) {
+ List<String> termProperties = new ArrayList<>();
+ termProperties.add("sources");
+ definedTermBase = termService.load(definedTermBase.getUuid(), termProperties);
+ Set<IdentifiableSource> sources = definedTermBase.getSources();
+ assertTrue("Import source is missing for term: "+definedTermBase, !sources.isEmpty());
+ assertTrue("import source type not found", sources.stream().anyMatch(source->OriginalSourceType.Import.getKey().equals(source.getType().getKey())));
+ }
+
}
@Override
public void createTestDataSet() throws FileNotFoundException {}