@DataSet(value="DistributionAggregationTest.xml"),
})
public void test_ignore() throws JvmLimitsException {
-
+ PresenceAbsenceTerm endemic = PresenceAbsenceTerm.ENDEMIC_FOR_THE_RELEVANT_AREA();
addDistributions(
T_LAPSANA_COMMUNIS_ALPINA_UUID,
Arrays.asList(new Distribution[] {
Distribution.NewInstance(yug_mn, PresenceAbsenceTerm.ENDEMIC_FOR_THE_RELEVANT_AREA()),
// should be ignored by area aggregation
// => LAPSANA_COMMUNIS will wave distribution with yug_ko and INTRODUCED_FORMERLY_INTRODUCED
- Distribution.NewInstance(yug_ko, PresenceAbsenceTerm.INTRODUCED_FORMERLY_INTRODUCED()),
+ Distribution.NewInstance(yug_ko, PresenceAbsenceTerm.INTRODUCED_DOUBTFULLY_INTRODUCED()),
})
);
Taxon lapsana_communis_alpina = (Taxon) taxonService.load(T_LAPSANA_COMMUNIS_ALPINA_UUID);
assertEquals(2, lapsana_communis_alpina.getDescriptions().size());
- // TODO test for yug => ENDEMIC_FOR_THE_RELEVANT_AREA in computed description
-
- Taxon lapsana_communis = (Taxon) taxonService.load(T_LAPSANA_COMMUNIS_UUID);
- assertEquals(1, lapsana_communis.getDescriptions().size());
- TaxonDescription description = lapsana_communis.getDescriptions().iterator().next();
- assertEquals(1, description.getElements().size());
- int numExpectedFound = 0;
- for (DescriptionElementBase element : description.getElements()){
- Distribution distribution = (Distribution)element;
- if(distribution.getArea().equals(yug_ko)){
- numExpectedFound++;
- assertEquals("aggregated status of area YUG-KO wrong", PresenceAbsenceTerm.INTRODUCED_FORMERLY_INTRODUCED(), distribution.getStatus());
- }
- }
- assertEquals("All three expected areas should have been found before", numExpectedFound, 1);
+ assertEquals("LCA must have 1 computed description", 1, lapsana_communis_alpina.getDescriptions().stream()
+ .filter(td->td.isAggregatedDistribution()).count());
+ assertEquals("Endemic in yug is missing", 1, lapsana_communis_alpina.getDescriptions().stream()
+ .filter(td->td.isAggregatedDistribution())
+ .flatMap(td->td.getElements().stream())
+ .filter(deb->deb.isInstanceOf(Distribution.class))
+ .map(deb->((Distribution)deb))
+ .filter(db->db.getStatus().equals(endemic)&&db.getArea().equals(yug)).count());
+
+ //TODO decide if absent status should aggregate along rank, originally they were not ignored
+// Taxon lapsana_communis = (Taxon) taxonService.load(T_LAPSANA_COMMUNIS_UUID);
+// assertEquals(1, lapsana_communis.getDescriptions().size());
+// TaxonDescription description = lapsana_communis.getDescriptions().iterator().next();
+// assertEquals(1, description.getElements().size());
+// int numExpectedFound = 0;
+// for (DescriptionElementBase element : description.getElements()){
+// Distribution distribution = (Distribution)element;
+// if(distribution.getArea().equals(yug_ko)){
+// numExpectedFound++;
+// assertEquals("aggregated status of area YUG-KO wrong", PresenceAbsenceTerm.INTRODUCED_FORMERLY_INTRODUCED(), distribution.getStatus());
+// }
+// }
+// assertEquals("YUG-KO should have been found before", numExpectedFound, 1);
}
@Test