merging delete functionality into trunk
[cdmlib.git] / cdmlib-persistence / src / test / java / eu / etaxonomy / cdm / persistence / dao / hibernate / description / DescriptionDaoHibernateImplTest.java
index b3be669159fe78c6d6a5f12aa641b8c00cd96983..2761810d8ff9f179a198995388dd677cfde0cdf0 100644 (file)
@@ -38,7 +38,6 @@ import eu.etaxonomy.cdm.model.description.DescriptionBase;
 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
 import eu.etaxonomy.cdm.model.description.Distribution;
 import eu.etaxonomy.cdm.model.description.Feature;
-import eu.etaxonomy.cdm.model.description.IModifiable;
 import eu.etaxonomy.cdm.model.description.PresenceTerm;
 import eu.etaxonomy.cdm.model.description.SpecimenDescription;
 import eu.etaxonomy.cdm.model.description.TaxonDescription;
@@ -409,65 +408,65 @@ public class DescriptionDaoHibernateImplTest extends CdmTransactionalIntegration
         int n2 = this.descriptionDao.count();
         Assert.assertEquals(1, n2-n1);
 
-               DefinedTerm scope = DefinedTerm.SEX_FEMALE();
-               description.addScope(scope);
+        DefinedTerm scope = DefinedTerm.SEX_FEMALE();
+        description.addScope(scope);
 
         this.descriptionDao.saveOrUpdate(description);
 
     }
 
-       @Test
-       public void testListTaxonDescriptionWithMarker(){
-               Taxon taxon = (Taxon)this.taxonDao.findByUuid(UUID.fromString("b04cc9cb-2b4a-4cc4-a94a-3c93a2158b06"));
-               Set<DefinedTerm> scopes = null;
-               Set<NamedArea> geographicalScope = null;
-               Integer pageSize = null;
-               Integer pageNumber = null;
-               List<String> propertyPaths = null;
-               
-               //complete
-               MarkerType completeMarkerType = (MarkerType)this.definedTermDao.findByUuid(UUID.fromString("b4b1b2ab-89a8-4ce6-8110-d60b8b1bc433")); //Marker "complete"
-               Assert.assertNotNull("MarkerType for 'complete' should exist", completeMarkerType);
-               Set<MarkerType> markerTypes = new HashSet<MarkerType>();
-               markerTypes.add(completeMarkerType);
-               int n1 = this.descriptionDao.countTaxonDescriptions(taxon, scopes, geographicalScope, markerTypes);
-               Assert.assertEquals("There should be 1 description marked 'complete'", 1, n1);
-               List<TaxonDescription> descriptions = this.descriptionDao.listTaxonDescriptions(taxon, scopes, geographicalScope, markerTypes, pageSize, pageNumber, propertyPaths);
-               Assert.assertEquals("There should be 1 description marked 'complete'", 1, descriptions.size());
-               
-               //doubtful
-               MarkerType isDoubtfulMarkerType = (MarkerType)this.definedTermDao.findByUuid(UUID.fromString("b51325c8-05fe-421a-832b-d86fc249ef6e")); //Marker "doubtful"
-               Assert.assertNotNull("MarkerType for 'doubtful' should exist", isDoubtfulMarkerType);
-               markerTypes = new HashSet<MarkerType>();  //reset
-               markerTypes.add(isDoubtfulMarkerType);
-               int n2 = this.descriptionDao.countTaxonDescriptions(taxon, scopes, geographicalScope, markerTypes);
-               Assert.assertEquals("There should be no description marked 'doubtful'", 0, n2);
-               descriptions = this.descriptionDao.listTaxonDescriptions(taxon, scopes, geographicalScope, markerTypes, pageSize, pageNumber, propertyPaths);
-               Assert.assertEquals("There should be 0 description marked 'doubtful'", 0, descriptions.size());
-               
-               //imported = false
-               UUID uuidImported = UUID.fromString("96878790-4ceb-42a2-9738-a2242079b679");
-               MarkerType importedMarkerType = (MarkerType)this.definedTermDao.findByUuid(uuidImported); 
-               Assert.assertNotNull("MarkerType for 'imported' should exist", completeMarkerType);
-               markerTypes = new HashSet<MarkerType>();
-               markerTypes.add(importedMarkerType);
-               int n3 = this.descriptionDao.countTaxonDescriptions(taxon, scopes, geographicalScope, markerTypes);
-               Assert.assertEquals("There should be no description marked 'imported' as true", 0, n3);
-               descriptions = this.descriptionDao.listTaxonDescriptions(taxon, scopes, geographicalScope, markerTypes, pageSize, pageNumber, propertyPaths);
-               Assert.assertEquals("There should be no description marked 'imported' as true", 0, descriptions.size());
-               markerTypes = null;
-               descriptions = this.descriptionDao.listTaxonDescriptions(taxon, scopes, geographicalScope, markerTypes, pageSize, pageNumber, propertyPaths);
-               Assert.assertEquals("There should be 1 description", 1, descriptions.size());
-               TaxonDescription desc = descriptions.iterator().next();
-               boolean hasMarkerImportedAsFalse = desc.hasMarker(importedMarkerType, false);
-               Assert.assertTrue("The only description should have a negative marker on 'imported'", hasMarkerImportedAsFalse);
-               
-       }
-       
+    @Test
+    public void testListTaxonDescriptionWithMarker(){
+        Taxon taxon = (Taxon)this.taxonDao.findByUuid(UUID.fromString("b04cc9cb-2b4a-4cc4-a94a-3c93a2158b06"));
+        Set<DefinedTerm> scopes = null;
+        Set<NamedArea> geographicalScope = null;
+        Integer pageSize = null;
+        Integer pageNumber = null;
+        List<String> propertyPaths = null;
+
+        //complete
+        MarkerType completeMarkerType = (MarkerType)this.definedTermDao.findByUuid(UUID.fromString("b4b1b2ab-89a8-4ce6-8110-d60b8b1bc433")); //Marker "complete"
+        Assert.assertNotNull("MarkerType for 'complete' should exist", completeMarkerType);
+        Set<MarkerType> markerTypes = new HashSet<MarkerType>();
+        markerTypes.add(completeMarkerType);
+        int n1 = this.descriptionDao.countTaxonDescriptions(taxon, scopes, geographicalScope, markerTypes);
+        Assert.assertEquals("There should be 1 description marked 'complete'", 1, n1);
+        List<TaxonDescription> descriptions = this.descriptionDao.listTaxonDescriptions(taxon, scopes, geographicalScope, markerTypes, pageSize, pageNumber, propertyPaths);
+        Assert.assertEquals("There should be 1 description marked 'complete'", 1, descriptions.size());
+
+        //doubtful
+        MarkerType isDoubtfulMarkerType = (MarkerType)this.definedTermDao.findByUuid(UUID.fromString("b51325c8-05fe-421a-832b-d86fc249ef6e")); //Marker "doubtful"
+        Assert.assertNotNull("MarkerType for 'doubtful' should exist", isDoubtfulMarkerType);
+        markerTypes = new HashSet<MarkerType>();  //reset
+        markerTypes.add(isDoubtfulMarkerType);
+        int n2 = this.descriptionDao.countTaxonDescriptions(taxon, scopes, geographicalScope, markerTypes);
+        Assert.assertEquals("There should be no description marked 'doubtful'", 0, n2);
+        descriptions = this.descriptionDao.listTaxonDescriptions(taxon, scopes, geographicalScope, markerTypes, pageSize, pageNumber, propertyPaths);
+        Assert.assertEquals("There should be 0 description marked 'doubtful'", 0, descriptions.size());
+
+        //imported = false
+        UUID uuidImported = UUID.fromString("96878790-4ceb-42a2-9738-a2242079b679");
+        MarkerType importedMarkerType = (MarkerType)this.definedTermDao.findByUuid(uuidImported);
+        Assert.assertNotNull("MarkerType for 'imported' should exist", completeMarkerType);
+        markerTypes = new HashSet<MarkerType>();
+        markerTypes.add(importedMarkerType);
+        int n3 = this.descriptionDao.countTaxonDescriptions(taxon, scopes, geographicalScope, markerTypes);
+        Assert.assertEquals("There should be no description marked 'imported' as true", 0, n3);
+        descriptions = this.descriptionDao.listTaxonDescriptions(taxon, scopes, geographicalScope, markerTypes, pageSize, pageNumber, propertyPaths);
+        Assert.assertEquals("There should be no description marked 'imported' as true", 0, descriptions.size());
+        markerTypes = null;
+        descriptions = this.descriptionDao.listTaxonDescriptions(taxon, scopes, geographicalScope, markerTypes, pageSize, pageNumber, propertyPaths);
+        Assert.assertEquals("There should be 1 description", 1, descriptions.size());
+        TaxonDescription desc = descriptions.iterator().next();
+        boolean hasMarkerImportedAsFalse = desc.hasMarker(importedMarkerType, false);
+        Assert.assertTrue("The only description should have a negative marker on 'imported'", hasMarkerImportedAsFalse);
+
+    }
+
 //
 //        //complete
 //        MarkerType completeMarkerType = (MarkerType)this.definedTermDao.findByUuid(UUID.fromString("b4b1b2ab-89a8-4ce6-8110-d60b8b1bc433")); //Marker "complete"
-//        
+//
 //        Assert.assertNotNull("MarkerType for 'complete' should exist", completeMarkerType);
 //        Set<MarkerType> markerTypes = new HashSet<MarkerType>();
 //        markerTypes.add(completeMarkerType);
@@ -613,5 +612,12 @@ public class DescriptionDaoHibernateImplTest extends CdmTransactionalIntegration
 
     }
 
+    @Test
+    @DataSet
+    public void testListNamedAreasInUse(){
+        List<NamedArea> list = descriptionDao.listNamedAreasInUse(null, null, null);
+        Assert.assertEquals(3, list.size());
+    }
+
 
 }