ref #7980 minor changes to aggregation tests
authorAndreas Müller <a.mueller@bgbm.org>
Wed, 6 Oct 2021 12:31:59 +0000 (14:31 +0200)
committerAndreas Müller <a.mueller@bgbm.org>
Wed, 6 Oct 2021 12:31:59 +0000 (14:31 +0200)
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/description/StructuredDescriptionAggregationTest.java

index 56c5bf0a3add4432476dbcb6e0a6403248bce197..b52bddd79ad5811716f6cefaf79327b40b518d92 100644 (file)
@@ -174,7 +174,9 @@ public class StructuredDescriptionAggregationTest extends CdmTransactionalIntegr
         // 1st aggregation
         UpdateResult result = engine.invoke(config, repository);
         testStatusOk(result);
+        commitAndStartNewTransaction();
         testAggregatedDescription(false, false);
+
         addSomeDataToFirstAggregation();
         commitAndStartNewTransaction();
         testAggregatedDescription(true, false);
@@ -182,6 +184,7 @@ public class StructuredDescriptionAggregationTest extends CdmTransactionalIntegr
         // 2nd aggregation
         result = engine.invoke(config, repository);
         testStatusOk(result);
+        commitAndStartNewTransaction();
         testAggregatedDescription(false, false);
     }
 
@@ -189,7 +192,8 @@ public class StructuredDescriptionAggregationTest extends CdmTransactionalIntegr
         Taxon taxLapsanaCommunisAlpina = (Taxon)taxonService.find(T_LAPSANA_COMMUNIS_ALPINA_UUID);
         TaxonDescription taxonDescription = taxLapsanaCommunisAlpina.getDescriptions().stream()
                 .filter(desc->desc.getTypes().contains(DescriptionType.AGGREGATED_STRUC_DESC))
-                .collect(Collectors.toList()).iterator().next();
+                .filter(desc->!desc.getTypes().contains(DescriptionType.CLONE_FOR_SOURCE))
+                .findFirst().get();
 
         addCategoricalData(taxonDescription, uuidFeatureLeafPA, State.uuidPresent);
     }
@@ -386,6 +390,12 @@ public class StructuredDescriptionAggregationTest extends CdmTransactionalIntegr
         Assert.assertEquals(1, taxonDescriptionMap.get(T_LAPSANA_COMMUNIS_UUID).size());
         Assert.assertNotEquals(aggrDescLapsanaCommunis, taxonDescriptionMap.get(T_LAPSANA_COMMUNIS_UUID).get(0));
 
+        //total description count
+        List<DescriptionBase> descs = descriptionService.list(null, null, null, null, null);
+        Assert.assertEquals("Should have 4 specimen desc, 1 literature desc, 2 individual association holder, "
+                + "4 aggregated descriptions, 4 cloned specimen descriptions, (3/4 cloned aggregated descriptions?) = 18/19",
+                18+intLit, descs.size());
+
     }
 
     private Map<UUID, List<TaxonDescription>> getSourceTaxonDescriptionMap(TaxonDescription desc) {