- added abstract method createTestData() to CdmIntegrationalTest
[cdmlib.git] / cdmlib-services / src / test / java / eu / etaxonomy / cdm / api / service / TaxonServiceImplTest.java
index 7b5bf61f4eaf0852cbf9da189a23a96fe087e08c..637424944ab471c6cc5330690860779f807c441a 100644 (file)
@@ -14,6 +14,8 @@ 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
 import java.util.Set;\r
@@ -25,16 +27,20 @@ import org.junit.Test;
 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.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
+import eu.etaxonomy.cdm.model.common.OriginalSourceType;\r
 import eu.etaxonomy.cdm.model.common.RelationshipBase;\r
 import eu.etaxonomy.cdm.model.description.TaxonDescription;\r
 import eu.etaxonomy.cdm.model.name.BotanicalName;\r
@@ -44,6 +50,10 @@ import eu.etaxonomy.cdm.model.name.NameRelationshipType;
 import eu.etaxonomy.cdm.model.name.NonViralName;\r
 import eu.etaxonomy.cdm.model.name.Rank;\r
 import eu.etaxonomy.cdm.model.name.TaxonNameBase;\r
+import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;\r
+import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;\r
+import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;\r
+import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;\r
 import eu.etaxonomy.cdm.model.reference.Reference;\r
 import eu.etaxonomy.cdm.model.reference.ReferenceFactory;\r
 import eu.etaxonomy.cdm.model.taxon.Classification;\r
@@ -53,6 +63,9 @@ 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
 \r
@@ -62,7 +75,6 @@ import eu.etaxonomy.cdm.test.unitils.CleanSweepInsertLoadStrategy;
 \r
 \r
 public class TaxonServiceImplTest extends CdmTransactionalIntegrationTest {\r
-    @SuppressWarnings("unused")\r
     private static final Logger logger = Logger.getLogger(TaxonServiceImplTest.class);\r
 \r
     @SpringBeanByType\r
@@ -82,8 +94,15 @@ public class TaxonServiceImplTest extends CdmTransactionalIntegrationTest {
 \r
     @SpringBeanByType\r
     private IDescriptionService descriptionService;\r
+    \r
+    @SpringBeanByType\r
+    private IMarkerService markerService;\r
 \r
-\r
+    @SpringBeanByType\r
+    private IEventBaseService eventService;\r
+    \r
+    @SpringBeanByType\r
+    private IOccurrenceService occurenceService;\r
 \r
 \r
 \r
@@ -133,7 +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
-        service.delete(taxon);\r
+       // try {\r
+                       service.deleteTaxon(taxon, null, null);\r
+               /*} catch (DataChangeNoRollbackException e) {\r
+                       // TODO Auto-generated catch block\r
+                       e.printStackTrace();\r
+               }*/\r
         TaxonBase<?> actualTaxon = service.find(uuid);\r
         assertNull(actualTaxon);\r
     }\r
@@ -643,7 +667,10 @@ public class TaxonServiceImplTest extends CdmTransactionalIntegrationTest {
 \r
 \r
         Taxon taxon2 = (Taxon)service.load(uuidTaxon2);\r
-        Synonym synonym1 = (Synonym)service.load(uuidSynonym1);\r
+        \r
+        List<String> initStrat = new ArrayList<String>();\r
+        initStrat.add("markers");\r
+        Synonym synonym1 = (Synonym)service.load(uuidSynonym1, initStrat);\r
 \r
         taxon2.removeSynonym(synonym1, false);\r
         service.saveOrUpdate(taxon2);\r
@@ -656,20 +683,37 @@ 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
+        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
+        \r
+        Set<Marker> markers = synonym1.getMarkers();\r
+        Marker marker = markers.iterator().next();\r
+        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
         Assert.assertEquals("There should be 3 names left in the database", 3, nNames);\r
         nRelations = service.countAllRelationships();\r
         Assert.assertEquals("There should be no relationship left in the database", 0, nRelations);\r
+        marker = markerService.load(markerUUID);\r
+        assertNull(marker);\r
 \r
     }\r
 \r
@@ -695,7 +739,9 @@ 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
-\r
+        synonym1.addExtension(Extension.NewInstance());\r
+        service.saveOrUpdate(synonym1);\r
+       \r
         service.deleteSynonym(synonym1, taxon1, new SynonymDeletionConfigurator());\r
 \r
         this.commitAndStartNewTransaction(tableNames);\r
@@ -706,7 +752,8 @@ public class TaxonServiceImplTest extends CdmTransactionalIntegrationTest {
         Assert.assertEquals("There should be 4 names left in the database (name not deleted as synonym was not deleted)", 4, nNames);\r
         int nRelations = service.countAllRelationships();\r
         Assert.assertEquals("There should be 1 relationship left in the database", 1, nRelations);\r
-\r
+       \r
+        \r
     }\r
 \r
     @Test\r
@@ -815,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
@@ -848,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
@@ -959,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
@@ -995,7 +1047,9 @@ public class TaxonServiceImplTest extends CdmTransactionalIntegrationTest {
                 "PolytomousKeyNode","PolytomousKeyNode_AUD",\r
                 "Media","Media_AUD",\r
                 "WorkingSet","WorkingSet_AUD",\r
-                "DescriptionElementBase","DescriptionElementBase_AUD"};\r
+                "DescriptionElementBase","DescriptionElementBase_AUD",\r
+                       "DeterminationEvent","DeterminationEvent_AUD",\r
+                       "SpecimenOrObservationBase","SpecimenOrObservationBase_AUD"};\r
 \r
         UUID uuidParent=UUID.fromString("b5271d4f-e203-4577-941f-00d76fa9f4ca");\r
         UUID uuidChild1=UUID.fromString("326167f9-0b97-4e7d-b1bf-4ca47b82e21e");\r
@@ -1014,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
@@ -1035,32 +1083,60 @@ public class TaxonServiceImplTest extends CdmTransactionalIntegrationTest {
         Assert.assertEquals("Child should belong to 1 node", 1, child1.getTaxonNodes().size());\r
 \r
         TaxonNode node = child1.getTaxonNodes().iterator().next();\r
+        child1.addSource(IdentifiableSource.NewInstance(OriginalSourceType.Import));\r
+        \r
+        SpecimenOrObservationBase<IIdentifiableEntityCacheStrategy> identifiedUnit = DerivedUnit.NewInstance(SpecimenOrObservationType.DerivedUnit);\r
+        DeterminationEvent determinationEvent = DeterminationEvent.NewInstance(child1, identifiedUnit);\r
+        //UUID eventUUID = eventService.save(determinationEvent);\r
+        UUID identifiedUnitUUID = occurenceService.save(identifiedUnit);\r
+        \r
+        \r
         TaxonNode parentNode = node.getParent();\r
         parentNode =CdmBase.deproxy(parentNode, TaxonNode.class);\r
         parentNode.deleteChildNode(node);\r
         nodeService.save(parentNode);\r
-        commitAndStartNewTransaction(tableNames);\r
+        //commitAndStartNewTransaction(tableNames);\r
+\r
+       // try {\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
+        \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
@@ -1095,13 +1171,13 @@ public class TaxonServiceImplTest extends CdmTransactionalIntegrationTest {
 \r
         TaxonDeletionConfigurator config = new TaxonDeletionConfigurator();\r
         config.setDeleteNameIfPossible(false);\r
+        \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
@@ -1114,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
@@ -1143,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
@@ -1183,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
@@ -1219,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
@@ -1254,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
@@ -1279,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
@@ -1288,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
@@ -1327,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
@@ -1368,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
@@ -1406,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
@@ -1437,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
@@ -1471,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
@@ -1488,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