- added abstract method createTestData() to CdmIntegrationalTest
[cdmlib.git] / cdmlib-services / src / test / java / eu / etaxonomy / cdm / api / service / TaxonServiceImplTest.java
index 3524294e9b37edc454a5055e2d6c23f3dc234cc6..637424944ab471c6cc5330690860779f807c441a 100644 (file)
@@ -14,6 +14,7 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;\r
 import static org.junit.Assert.assertTrue;\r
 \r
+import java.io.FileNotFoundException;\r
 import java.util.ArrayList;\r
 import java.util.Iterator;\r
 import java.util.List;\r
@@ -21,21 +22,21 @@ import java.util.Set;
 import java.util.UUID;\r
 \r
 import org.apache.log4j.Logger;\r
-import org.hibernate.ObjectDeletedException;\r
 import org.junit.Assert;\r
 import org.junit.Test;\r
 import org.unitils.dbunit.annotation.DataSet;\r
 import org.unitils.spring.annotation.SpringBeanByType;\r
 \r
+import eu.etaxonomy.cdm.api.service.config.IncludedTaxonConfiguration;\r
 import eu.etaxonomy.cdm.api.service.config.NameDeletionConfigurator;\r
 import eu.etaxonomy.cdm.api.service.config.SynonymDeletionConfigurator;\r
 import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;\r
 import eu.etaxonomy.cdm.api.service.config.TaxonNodeDeletionConfigurator.ChildHandling;\r
-import eu.etaxonomy.cdm.api.service.exception.DataChangeNoRollbackException;\r
+import eu.etaxonomy.cdm.api.service.dto.IncludedTaxaDTO;\r
 import eu.etaxonomy.cdm.api.service.exception.HomotypicalGroupChangeException;\r
-import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;\r
 import eu.etaxonomy.cdm.datagenerator.TaxonGenerator;\r
 import eu.etaxonomy.cdm.model.common.CdmBase;\r
+import eu.etaxonomy.cdm.model.common.Extension;\r
 import eu.etaxonomy.cdm.model.common.IdentifiableSource;\r
 import eu.etaxonomy.cdm.model.common.Marker;\r
 import eu.etaxonomy.cdm.model.common.MarkerType;\r
@@ -62,6 +63,8 @@ import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
 import eu.etaxonomy.cdm.model.taxon.Taxon;\r
 import eu.etaxonomy.cdm.model.taxon.TaxonBase;\r
 import eu.etaxonomy.cdm.model.taxon.TaxonNode;\r
+import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;\r
+import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;\r
 import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy;\r
 import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;\r
 import eu.etaxonomy.cdm.test.unitils.CleanSweepInsertLoadStrategy;\r
@@ -149,12 +152,12 @@ public class TaxonServiceImplTest extends CdmTransactionalIntegrationTest {
     public final void testRemoveTaxon() {\r
         Taxon taxon = Taxon.NewInstance(BotanicalName.NewInstance(Rank.UNKNOWN_RANK()), null);\r
         UUID uuid = service.save(taxon);\r
-        try {\r
+       // try {\r
                        service.deleteTaxon(taxon, null, null);\r
-               } catch (DataChangeNoRollbackException e) {\r
+               /*} catch (DataChangeNoRollbackException e) {\r
                        // TODO Auto-generated catch block\r
                        e.printStackTrace();\r
-               }\r
+               }*/\r
         TaxonBase<?> actualTaxon = service.find(uuid);\r
         assertNull(actualTaxon);\r
     }\r
@@ -680,9 +683,10 @@ public class TaxonServiceImplTest extends CdmTransactionalIntegrationTest {
         Assert.assertEquals("There should  be 4 names in the database", 4, nNames);\r
         int nRelations = service.countAllRelationships();\r
         Assert.assertEquals("There should be 1 relationship left in the database", 1, nRelations);\r
-        \r
-        synonym1.addMarker(Marker.NewInstance(MarkerType.IMPORTED(), true));\r
-        synonym1.addMarker(Marker.NewInstance(MarkerType.COMPUTED(), true));\r
+        Marker marker1 = Marker.NewInstance(MarkerType.IMPORTED(), true);\r
+        Marker marker2 = Marker.NewInstance(MarkerType.COMPUTED(), true);\r
+        synonym1.addMarker(marker1);\r
+        synonym1.addMarker(marker2);\r
         service.update(synonym1);\r
         synonym1 =(Synonym) service.load(uuidSynonym1);\r
        \r
@@ -692,11 +696,16 @@ public class TaxonServiceImplTest extends CdmTransactionalIntegrationTest {
         UUID markerUUID = marker.getUuid();\r
        // taxon2 = (Taxon)service.load(uuidTaxon2);\r
         synonym1 = (Synonym)service.load(uuidSynonym1);\r
-\r
-        service.deleteSynonym(synonym1, new SynonymDeletionConfigurator());\r
-\r
+        //the marker should not prevent the deletion\r
+        DeleteResult result = service.deleteSynonym(synonym1, new SynonymDeletionConfigurator());\r
+        if (!result.isOk()){\r
+               Assert.fail();\r
+        }\r
+        \r
+       \r
+       \r
+        \r
         commitAndStartNewTransaction(tableNames);\r
-\r
         nSynonyms = service.count(Synonym.class);\r
         Assert.assertEquals("There should be 1 synonym left in the database", 1, nSynonyms);\r
         nNames = nameService.count(TaxonNameBase.class);\r
@@ -730,6 +739,8 @@ public class TaxonServiceImplTest extends CdmTransactionalIntegrationTest {
         Taxon taxon1 = (Taxon)service.load(uuidTaxon1);\r
         Taxon taxon2 = (Taxon)service.load(uuidTaxon2);\r
         Synonym synonym1 = (Synonym)service.load(uuidSynonym1);\r
+        synonym1.addExtension(Extension.NewInstance());\r
+        service.saveOrUpdate(synonym1);\r
        \r
         service.deleteSynonym(synonym1, taxon1, new SynonymDeletionConfigurator());\r
 \r
@@ -851,7 +862,7 @@ public class TaxonServiceImplTest extends CdmTransactionalIntegrationTest {
     }\r
 \r
     @Test\r
-    @DataSet("TaxonServiceImplTest.testDeleteSynonym.xml")\r
+    @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="TaxonServiceImplTest.testDeleteSynonym.xml")\r
     public final void testDeleteSynonymSynonymTaxonBooleanWithRelatedNameIgnoreIsBasionym(){\r
         final String[]tableNames = {"TaxonBase","TaxonBase_AUD", "TaxonNameBase","TaxonNameBase_AUD",\r
                 "SynonymRelationship","SynonymRelationship_AUD",\r
@@ -884,8 +895,13 @@ public class TaxonServiceImplTest extends CdmTransactionalIntegrationTest {
         nameDeletionConfig.setIgnoreIsBasionymFor(true);\r
         config.setNameDeletionConfig(nameDeletionConfig);\r
 \r
-        service.deleteSynonym(synonym1, config);\r
-\r
+        DeleteResult result =service.deleteSynonym(synonym1, config);\r
+        if (!result.isOk()){\r
+               Assert.fail();\r
+        }\r
+        \r
+        \r
+        logger.debug(result);\r
         this.commitAndStartNewTransaction(tableNames);\r
 \r
         nSynonyms = service.count(Synonym.class);\r
@@ -995,7 +1011,7 @@ public class TaxonServiceImplTest extends CdmTransactionalIntegrationTest {
         Classification tree = classificationService.find(classificationUuid);\r
         UUID taxonUuid = UUID.fromString("bc09aca6-06fd-4905-b1e7-cbf7cc65d783");\r
         TaxonBase<?> taxonBase =  service.find(taxonUuid);\r
-        List <TaxonBase> synonyms = service.list(Synonym.class, null, null, null, null);\r
+        List <Synonym> synonyms = service.list(Synonym.class, null, null, null, null);\r
         assertEquals("Number of synonyms should be 2",2,synonyms.size());\r
         Taxon taxon = (Taxon)taxonBase;\r
 \r
@@ -1052,19 +1068,13 @@ public class TaxonServiceImplTest extends CdmTransactionalIntegrationTest {
         TaxonDeletionConfigurator config = new TaxonDeletionConfigurator();\r
         config.setDeleteTaxonNodes(false);\r
         config.setDeleteMisappliedNamesAndInvalidDesignations(false);\r
-        try {\r
+        //try {\r
             //commitAndStartNewTransaction(tableNames);\r
 \r
-            service.deleteTaxon(child1, config, null);\r
+        DeleteResult result = service.deleteTaxon(child1, config, null);\r
+        if (result.isOk()){    \r
             Assert.fail("Delete should throw an error as long as name is used in classification.");\r
-        } catch (DataChangeNoRollbackException e) {\r
-            if (e.getMessage().contains("Taxon can't be deleted as it is used in a classification node")){\r
-                //ok\r
-                commitAndStartNewTransaction(tableNames);\r
-            }else{\r
-                Assert.fail("Unexpected error occurred when trying to delete taxon: " + e.getMessage());\r
-            }\r
-        }\r
+        } \r
 \r
         nTaxa = service.count(Taxon.class);\r
         Assert.assertEquals("There should be 4 taxa in the database", 4, nTaxa);\r
@@ -1087,43 +1097,46 @@ public class TaxonServiceImplTest extends CdmTransactionalIntegrationTest {
         nodeService.save(parentNode);\r
         //commitAndStartNewTransaction(tableNames);\r
 \r
-        try {\r
+       // try {\r
 \r
-            service.deleteTaxon(child1, config, null);\r
-            Assert.fail("Delete should throw an exception because of the determination event");\r
-        } catch (DataChangeNoRollbackException e) {\r
-               commitAndStartNewTransaction(tableNames);\r
-        }\r
+       result = service.deleteTaxon(child1, config, null);\r
+       if (result.isOk()){\r
+               Assert.fail("Delete should throw an exception because of the determination event");\r
+       }\r
+            \r
+           \r
        \r
         //determinationEvent = (DeterminationEvent)eventService.load(eventUUID);\r
         commitAndStartNewTransaction(tableNames);\r
         identifiedUnit = occurenceService.load(identifiedUnitUUID);\r
-        try{\r
-               occurenceService.delete(identifiedUnit);\r
-        }catch (ReferencedObjectUndeletableException e){\r
-               Assert.fail();\r
-        }\r
+        \r
+        occurenceService.delete(identifiedUnit);\r
+       \r
         commitAndStartNewTransaction(tableNames);\r
         child1 = (Taxon)service.find(TaxonGenerator.SPECIES1_UUID);\r
 \r
         assertEquals(0, child1.getTaxonNodes().size());\r
-        try {\r
+       // try {\r
 \r
-            service.deleteTaxon(child1, config, null);\r
-        } catch (DataChangeNoRollbackException e) {\r
+         result = service.deleteTaxon(child1, config, null);\r
+         \r
+         if (!result.isOk()){\r
             Assert.fail("Delete should not throw an exception anymore");\r
-        }\r
+         }\r
+        \r
         nTaxa = service.count(Taxon.class);\r
         Assert.assertEquals("There should be 3 taxa in the database", 3, nTaxa);\r
 \r
         config.setDeleteTaxonNodes(true);\r
         Taxon child2 =(Taxon) service.find(TaxonGenerator.SPECIES2_UUID);\r
 \r
-        try {\r
-            service.deleteTaxon(child2, config, null);\r
-        } catch (DataChangeNoRollbackException e) {\r
+       // try {\r
+        result = service.deleteTaxon(child2, config, null);\r
+        if (!result.isOk()){\r
             Assert.fail("Delete should not throw an exception");\r
         }\r
+        \r
+        \r
         //service.find(uuid);\r
 \r
         nTaxa = service.count(Taxon.class);\r
@@ -1161,12 +1174,10 @@ public class TaxonServiceImplTest extends CdmTransactionalIntegrationTest {
         \r
         \r
 \r
-        try {\r
-            service.deleteTaxon(speciesTaxon, config, null);\r
-        } catch (DataChangeNoRollbackException e) {\r
-            e.printStackTrace();\r
-            Assert.fail();\r
-\r
+       // try {\r
+        DeleteResult result = service.deleteTaxon(speciesTaxon, config, null);\r
+        if (!result.isOk()){\r
+               Assert.fail();\r
         }\r
         commitAndStartNewTransaction(null);\r
 \r
@@ -1179,6 +1190,14 @@ public class TaxonServiceImplTest extends CdmTransactionalIntegrationTest {
         //assertNull(synName);\r
         assertNotNull(taxonName);\r
         assertNull(taxon);\r
+        config.setDeleteNameIfPossible(true);\r
+        Taxon newTaxon = Taxon.NewInstance(BotanicalName.NewInstance(Rank.SPECIES()), null);\r
+        service.save(newTaxon);\r
+        result = service.deleteTaxon(newTaxon, config, null);\r
+        if (!result.isOk()){\r
+               Assert.fail();\r
+        }\r
+        \r
 \r
     }\r
 \r
@@ -1208,12 +1227,10 @@ public class TaxonServiceImplTest extends CdmTransactionalIntegrationTest {
         TaxonDeletionConfigurator config = new TaxonDeletionConfigurator();\r
         config.setDeleteSynonymsIfPossible(false);\r
 \r
-        try {\r
-            service.deleteTaxon(speciesTaxon, config, null);\r
-        } catch (DataChangeNoRollbackException e) {\r
-            e.printStackTrace();\r
-            Assert.fail();\r
-\r
+      \r
+       DeleteResult result = service.deleteTaxon(speciesTaxon, config, null);\r
+        if (!result.isOk()){\r
+               Assert.fail();\r
         }\r
         commitAndStartNewTransaction(null);\r
 \r
@@ -1248,12 +1265,9 @@ public class TaxonServiceImplTest extends CdmTransactionalIntegrationTest {
 \r
         TaxonDeletionConfigurator config = new TaxonDeletionConfigurator();\r
         config.setDeleteNameIfPossible(true);\r
-        try {\r
-            service.deleteTaxon(speciesTaxon, config, null);\r
-        } catch (DataChangeNoRollbackException e) {\r
-\r
-            Assert.fail();\r
-            e.printStackTrace();\r
+        DeleteResult result = service.deleteTaxon(speciesTaxon, config, null);\r
+        if (!result.isOk()){\r
+               Assert.fail();\r
         }\r
         commitAndStartNewTransaction(null);\r
 \r
@@ -1284,10 +1298,10 @@ public class TaxonServiceImplTest extends CdmTransactionalIntegrationTest {
 \r
         secondClassification.addChildTaxon(testTaxon, null, null);\r
         //delete the taxon in all classifications\r
-        try {\r
-            service.deleteTaxon(testTaxon, config, null);\r
-        } catch (DataChangeNoRollbackException e) {\r
-            Assert.fail();\r
+        //try {\r
+       DeleteResult result = service.deleteTaxon(testTaxon, config, null);\r
+       if (!result.isOk()){\r
+               Assert.fail();\r
         }\r
         commitAndStartNewTransaction(null);\r
         Taxon tax = (Taxon)service.find(uuid);\r
@@ -1319,12 +1333,17 @@ public class TaxonServiceImplTest extends CdmTransactionalIntegrationTest {
 \r
         TaxonDeletionConfigurator config = new TaxonDeletionConfigurator() ;\r
         config.setDeleteInAllClassifications(false);\r
-            try {\r
-                service.deleteTaxon(testTaxon, config, secondClassification);\r
-                Assert.fail("The taxon should not be deletable because it is used in a second classification and the configuration is set to deleteInAllClassifications = false");\r
+       //     try {\r
+       DeleteResult result = service.deleteTaxon(testTaxon, config, secondClassification);\r
+/*                Assert.fail("The taxon should not be deletable because it is used in a second classification and the configuration is set to deleteInAllClassifications = false");\r
             } catch (DataChangeNoRollbackException e) {\r
                 logger.debug(e.getMessage());\r
             }\r
+  */          \r
+            \r
+       if (result.isOk()){\r
+               Assert.fail("The taxon should not be deletable because it is used in a second classification and the configuration is set to deleteInAllClassifications = false");\r
+        }\r
 \r
         //commitAndStartNewTransaction(null);\r
         Taxon tax = (Taxon)service.find(uuid);\r
@@ -1344,7 +1363,7 @@ public class TaxonServiceImplTest extends CdmTransactionalIntegrationTest {
 \r
         Taxon topMost = Taxon.NewInstance(BotanicalName.NewInstance(Rank.FAMILY()), null);\r
 \r
-    Iterator<TaxonNode> nodes = testTaxon.getTaxonNodes().iterator();\r
+        Iterator<TaxonNode> nodes = testTaxon.getTaxonNodes().iterator();\r
         TaxonNode node =nodes.next();\r
         Classification classification = node.getClassification();\r
         classification.addParentChild(topMost, testTaxon, null, null);\r
@@ -1353,12 +1372,12 @@ public class TaxonServiceImplTest extends CdmTransactionalIntegrationTest {
         TaxonDeletionConfigurator config = new TaxonDeletionConfigurator() ;\r
         config.getTaxonNodeConfig().setChildHandling(ChildHandling.MOVE_TO_PARENT);\r
 \r
-        try {\r
-            service.deleteTaxon(testTaxon, config, null);\r
-        } catch (DataChangeNoRollbackException e) {\r
-            Assert.fail();\r
-        }\r
-\r
+      \r
+        DeleteResult result = service.deleteTaxon(testTaxon, config, null);\r
+        if(!result.isOk()){ \r
+               Assert.fail();\r
+               }\r
+        \r
         commitAndStartNewTransaction(null);\r
         Taxon tax = (Taxon)service.find(uuid);\r
         assertNull(tax);\r
@@ -1392,12 +1411,11 @@ public class TaxonServiceImplTest extends CdmTransactionalIntegrationTest {
         TaxonDeletionConfigurator config = new TaxonDeletionConfigurator() ;\r
         config.getTaxonNodeConfig().setChildHandling(ChildHandling.DELETE);\r
 \r
-        try {\r
-            service.deleteTaxon(testTaxon, config, null);\r
-        } catch (DataChangeNoRollbackException e) {\r
-            Assert.fail();\r
-        }\r
-\r
+       // try {\r
+        DeleteResult result = service.deleteTaxon(testTaxon, config, null);\r
+        if(!result.isOk()){ \r
+               Assert.fail();\r
+               }\r
         commitAndStartNewTransaction(null);\r
         Taxon tax = (Taxon)service.find(uuid);\r
         assertNull(tax);\r
@@ -1433,12 +1451,11 @@ public class TaxonServiceImplTest extends CdmTransactionalIntegrationTest {
         TaxonDeletionConfigurator config = new TaxonDeletionConfigurator() ;\r
         config.getTaxonNodeConfig().setChildHandling(ChildHandling.DELETE);\r
 \r
-        try {\r
-            service.deleteTaxon(testTaxon, config, null);\r
-        } catch (DataChangeNoRollbackException e) {\r
-            Assert.fail();\r
-        }\r
-\r
+        DeleteResult result = service.deleteTaxon(testTaxon, config, null);\r
+       \r
+        if(!result.isOk()){ \r
+               Assert.fail();\r
+               }\r
         commitAndStartNewTransaction(null);\r
         Taxon tax = (Taxon)service.find(uuid);\r
         assertNull(tax);\r
@@ -1471,12 +1488,10 @@ public class TaxonServiceImplTest extends CdmTransactionalIntegrationTest {
         TaxonDeletionConfigurator config = new TaxonDeletionConfigurator() ;\r
         config.setDeleteMisappliedNamesAndInvalidDesignations(true);\r
 \r
-        try {\r
-            service.deleteTaxon(testTaxon, config, null);\r
-        } catch (DataChangeNoRollbackException e) {\r
-            Assert.fail();\r
-        }\r
-\r
+        DeleteResult result  = service.deleteTaxon(testTaxon, config, null);\r
+        if(!result.isOk()){ \r
+               Assert.fail();\r
+               }\r
         commitAndStartNewTransaction(null);\r
         Taxon tax = (Taxon)service.find(uuid);\r
         assertNull(tax);\r
@@ -1502,12 +1517,10 @@ public class TaxonServiceImplTest extends CdmTransactionalIntegrationTest {
         TaxonDeletionConfigurator config = new TaxonDeletionConfigurator() ;\r
         config.setDeleteMisappliedNamesAndInvalidDesignations(false);\r
 \r
-        try {\r
-            service.deleteTaxon(testTaxon, config, null);\r
-        } catch (DataChangeNoRollbackException e) {\r
-            Assert.fail();\r
-        }\r
-\r
+        DeleteResult result = service.deleteTaxon(testTaxon, config, null);\r
+        if(!result.isOk()){ \r
+               Assert.fail();\r
+               }\r
         commitAndStartNewTransaction(null);\r
         Taxon tax = (Taxon)service.find(uuid);\r
         assertNull(tax);\r
@@ -1536,12 +1549,12 @@ public class TaxonServiceImplTest extends CdmTransactionalIntegrationTest {
         TaxonDeletionConfigurator config = new TaxonDeletionConfigurator() ;\r
 \r
 \r
-        try {\r
+       // try {\r
             service.deleteTaxon(misappliedNameTaxon, config, null);\r
-        } catch (DataChangeNoRollbackException e) {\r
-            e.printStackTrace();\r
+       // } catch (DataChangeNoRollbackException e) {\r
+         //   e.printStackTrace();\r
 \r
-        }\r
+        //}\r
 \r
         commitAndStartNewTransaction(null);\r
         Taxon tax = (Taxon)service.find(uuid);\r
@@ -1553,6 +1566,96 @@ public class TaxonServiceImplTest extends CdmTransactionalIntegrationTest {
         assertNull(name);\r
 \r
     }\r
+    \r
+    @Test\r
+    @DataSet(value="BlankDataSet.xml")\r
+    public final void testLlistIncludedTaxa(){\r
+       Reference<?> citation = null;\r
+       String microcitation = null;\r
+       \r
+       //Data\r
+       Classification cl1 = Classification.NewInstance("testClassification1");\r
+       Classification cl2 = Classification.NewInstance("testClassification2");\r
+       Classification cl3 = Classification.NewInstance("testClassification3");\r
+       \r
+       Taxon c1Genus = Taxon.NewInstance(null, null);c1Genus.setUuid(UUID.fromString("daa24f6f-7e38-4668-b385-10c789212e4e"));\r
+       Taxon c1Species = Taxon.NewInstance(null, null);c1Species.setUuid(UUID.fromString("1c1d0566-67d0-4806-bf23-ecf55f4b9118"));\r
+       Taxon c1SubSpecies1 = Taxon.NewInstance(null, null);c1SubSpecies1.setUuid(UUID.fromString("96ae2fad-76df-429f-b179-42e00838fea4"));\r
+       Taxon c1SubSpecies2 = Taxon.NewInstance(null, null);c1SubSpecies2.setUuid(UUID.fromString("5d3f6147-ca72-40e0-be8a-6c835a09a579"));\r
+       cl1.addParentChild(c1Genus, c1Species, null, null);\r
+       cl1.addParentChild(c1Species, c1SubSpecies1, null, null);\r
+       cl1.addParentChild(c1Species, c1SubSpecies2, null, null);\r
+       \r
+       Taxon c2Genus = Taxon.NewInstance(null, null);c2Genus.setUuid(UUID.fromString("ed0ec006-3ac8-4a12-ae13-fdf2a13dedbe"));\r
+       Taxon c2Species = Taxon.NewInstance(null, null);c2Species.setUuid(UUID.fromString("1027eb18-1c26-450e-a299-981b775ebc3c"));\r
+       Taxon c2SubSpecies1 = Taxon.NewInstance(null, null);c2SubSpecies1.setUuid(UUID.fromString("61f039c8-01f3-4f5d-8e16-1602139774e7"));\r
+       Taxon c2SubSpecies2 = Taxon.NewInstance(null, null);c2SubSpecies2.setUuid(UUID.fromString("2ed6b6f8-05f9-459a-a075-2bca57e3013e"));\r
+       cl2.addParentChild(c2Genus, c2Species, null, null);\r
+       cl2.addParentChild(c2Species, c2SubSpecies1, null, null);\r
+       cl2.addParentChild(c2Species, c2SubSpecies2, null, null);\r
+       \r
+       Taxon c3Genus = Taxon.NewInstance(null, null);c3Genus.setUuid(UUID.fromString("407dfc8d-7a4f-4370-ada4-76c1a8279d1f"));\r
+       Taxon c3Species = Taxon.NewInstance(null, null);c3Species.setUuid(UUID.fromString("b6d34fc7-4aa7-41e5-b633-86f474edbbd5"));\r
+       Taxon c3SubSpecies1 = Taxon.NewInstance(null, null);c3SubSpecies1.setUuid(UUID.fromString("01c07585-a422-40cd-9339-a74c56901d9f"));\r
+       Taxon c3SubSpecies2 = Taxon.NewInstance(null, null);c3SubSpecies2.setUuid(UUID.fromString("390c8e23-e05f-4f89-b417-50cf080f4c91"));\r
+       cl3.addParentChild(c3Genus, c3Species, null, null);\r
+       cl3.addParentChild(c3Species, c3SubSpecies1, null, null);\r
+       cl3.addParentChild(c3Species, c3SubSpecies2, null, null);\r
+       \r
+       classificationService.save(cl1);\r
+       classificationService.save(cl2);\r
+       classificationService.save(cl3);\r
+       \r
+       Taxon c4Genus = Taxon.NewInstance(null, null);c4Genus.setUuid(UUID.fromString("bfd6bbdd-0116-4ab2-a781-9316224aad78"));\r
+       Taxon c4Species = Taxon.NewInstance(null, null);c4Species.setUuid(UUID.fromString("9347a3d9-5ece-4d64-9035-e8aaf5d3ee02"));\r
+       Taxon c4SubSpecies = Taxon.NewInstance(null, null);c4SubSpecies.setUuid(UUID.fromString("777aabbe-4c3a-449c-ab99-a91f2fec9f07"));\r
+       \r
+       TaxonRelationship rel = c1Species.addTaxonRelation(c2Species, TaxonRelationshipType.CONGRUENT_TO(), citation, microcitation);\r
+       rel.setDoubtful(true);\r
+       c1Species.addTaxonRelation(c4Species, TaxonRelationshipType.INCLUDES(), citation, microcitation);\r
+       c2Species.addTaxonRelation(c1SubSpecies2, TaxonRelationshipType.INCLUDES(), citation, microcitation);\r
+       \r
+       service.saveOrUpdate(c1Species);\r
+               service.saveOrUpdate(c2Species);\r
+       \r
+       //Tests\r
+               //default starting at species 1\r
+               IncludedTaxaDTO dto = service.listIncludedTaxa(c1Species.getUuid(), new IncludedTaxonConfiguration(null, true, false));\r
+       Assert.assertNotNull("IncludedTaxaDTO", dto);\r
+       Assert.assertEquals("Result should contain 7 taxa: c1Species", 7, dto.getIncludedTaxa().size());\r
+       Assert.assertNotNull("date should not be null", dto.getDate());\r
+//     Assert.assertTrue(dto.contains(taxonUuid));\r
+        //same without doubtful\r
+       dto = service.listIncludedTaxa(c1Species.getUuid(), new IncludedTaxonConfiguration(null, false, false));\r
+       Assert.assertEquals(4, dto.getIncludedTaxa().size());\r
+\r
+       //other example starting at Genus2\r
+       dto = service.listIncludedTaxa(c2Genus.getUuid(), new IncludedTaxonConfiguration(null, true, false));\r
+       Assert.assertEquals(8, dto.getIncludedTaxa().size());\r
+       //same without doubtful\r
+       dto = service.listIncludedTaxa(c2Genus.getUuid(), new IncludedTaxonConfiguration(null, false, false));\r
+       Assert.assertEquals(5, dto.getIncludedTaxa().size());\r
+       \r
+       //only congruent\r
+       dto = service.listIncludedTaxa(c1Species.getUuid(), new IncludedTaxonConfiguration(null, true, true));\r
+       Assert.assertEquals(2, dto.getIncludedTaxa().size());\r
+       //same without doubtful\r
+       dto = service.listIncludedTaxa(c1Species.getUuid(), new IncludedTaxonConfiguration(null, false, true));\r
+       Assert.assertEquals(1, dto.getIncludedTaxa().size());\r
+               \r
+       \r
+\r
+       \r
+    }\r
+\r
+    /* (non-Javadoc)\r
+     * @see eu.etaxonomy.cdm.test.integration.CdmIntegrationTest#createTestData()\r
+     */\r
+    @Override\r
+    protected void createTestDataSet() throws FileNotFoundException {\r
+        // TODO Auto-generated method stub\r
+        \r
+    }\r
 \r
 \r
 }\r