From: Andreas Müller Date: Wed, 2 Jul 2014 13:19:14 +0000 (+0000) Subject: test for #4200 X-Git-Tag: cdmlib-parent-3.3.6~16 X-Git-Url: https://dev.e-taxonomy.eu/gitweb/cdmlib.git/commitdiff_plain/3adca34aa58d422e3b0e67f176eebd38669b5986 test for #4200 --- diff --git a/.gitattributes b/.gitattributes index 8d075c2a05..bb604ea8a7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1644,6 +1644,8 @@ cdmlib-persistence/src/test/resources/eu/etaxonomy/cdm/persistence/dao/hibernate cdmlib-persistence/src/test/resources/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonDaoHibernateImplTest.testFindDeleted.xml -text cdmlib-persistence/src/test/resources/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonDaoHibernateImplTest.testGetTaxaByNameAndArea.xml -text cdmlib-persistence/src/test/resources/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonDaoHibernateImplTest.xml -text +cdmlib-persistence/src/test/resources/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonNodeDaoHibernateImplTest.testSortindexForJavassist-result.xml -text +cdmlib-persistence/src/test/resources/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonNodeDaoHibernateImplTest.testSortindexForJavassist.xml -text cdmlib-persistence/src/test/resources/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonNodeDaoHibernateImplTest.xml -text cdmlib-persistence/src/test/resources/eu/etaxonomy/cdm/persistence/dao/hibernate/view/AuditEventDaoTest.xml -text cdmlib-persistence/src/test/resources/eu/etaxonomy/cdm/persistence/hibernate/CacheStrategyGeneratorTest.testOnSaveOrUpdateAgents-result.xml -text diff --git a/cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonNodeDaoHibernateImplTest.java b/cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonNodeDaoHibernateImplTest.java index e7446bc6ff..15ff9a7aac 100644 --- a/cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonNodeDaoHibernateImplTest.java +++ b/cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonNodeDaoHibernateImplTest.java @@ -20,6 +20,7 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; import org.unitils.dbunit.annotation.DataSet; +import org.unitils.dbunit.annotation.ExpectedDataSet; import org.unitils.spring.annotation.SpringBeanByType; import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; @@ -37,7 +38,9 @@ import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest; public class TaxonNodeDaoHibernateImplTest extends CdmTransactionalIntegrationTest { - @SpringBeanByType + private static final UUID ClassificationUuid = UUID.fromString("aeee7448-5298-4991-b724-8d5b75a0a7a9"); + + @SpringBeanByType private ITaxonNodeDao taxonNodeDao; @SpringBeanByType @@ -94,7 +97,7 @@ public class TaxonNodeDaoHibernateImplTest extends CdmTransactionalIntegrationTe @DataSet public void testClassification() { - Classification classification = classificationDao.load(UUID.fromString("aeee7448-5298-4991-b724-8d5b75a0a7a9"), CLASSIFICATION_INIT_STRATEGY); + Classification classification = classificationDao.load(ClassificationUuid, CLASSIFICATION_INIT_STRATEGY); assertNotNull("findByUuid should return a taxon tree", classification); assertNotNull("classification should have a name",classification.getName()); @@ -114,7 +117,7 @@ public class TaxonNodeDaoHibernateImplTest extends CdmTransactionalIntegrationTe TaxonNode rootNode = HibernateProxyHelper.deproxy(classification.getRootNode(), TaxonNode.class); rootNode.addChildTaxon(Taxon.NewInstance(BotanicalName.NewInstance(Rank.GENUS()), null), null, null); taxonNodeDao.delete(taxNode3, true); - classification = classificationDao.findByUuid(UUID.fromString("aeee7448-5298-4991-b724-8d5b75a0a7a9")); + classification = classificationDao.findByUuid(ClassificationUuid); taxa = taxonDao.getAllTaxonBases(10, 0); assertEquals("there should be 7 taxa left", 7, taxa.size()); @@ -123,7 +126,7 @@ public class TaxonNodeDaoHibernateImplTest extends CdmTransactionalIntegrationTe classification = null; classificationDao.flush(); - classification = classificationDao.findByUuid(UUID.fromString("aeee7448-5298-4991-b724-8d5b75a0a7a9")); + classification = classificationDao.findByUuid(ClassificationUuid); assertEquals("The tree should be null", null, classification); } @@ -133,7 +136,7 @@ public class TaxonNodeDaoHibernateImplTest extends CdmTransactionalIntegrationTe public void testlistChildren(){ Taxon t_acherontia = (Taxon) taxonDao.load(ACHERONTIA_UUID); - Classification classification = classificationDao.load(UUID.fromString("aeee7448-5298-4991-b724-8d5b75a0a7a9")); + Classification classification = classificationDao.load(ClassificationUuid); List children = classificationDao.listChildrenOf(t_acherontia, classification, null, null, null); assertNotNull(children); assertEquals(2, children.size()); @@ -146,7 +149,7 @@ public class TaxonNodeDaoHibernateImplTest extends CdmTransactionalIntegrationTe @Test @DataSet public void testGetAllTaxaByClassification(){ - Classification classification = classificationDao.load(UUID.fromString("aeee7448-5298-4991-b724-8d5b75a0a7a9"), CLASSIFICATION_INIT_STRATEGY); + Classification classification = classificationDao.load(ClassificationUuid, CLASSIFICATION_INIT_STRATEGY); assertNotNull("findByUuid should return a taxon tree", classification); assertNotNull("classification should have a name",classification.getName()); @@ -173,7 +176,17 @@ public class TaxonNodeDaoHibernateImplTest extends CdmTransactionalIntegrationTe int countTaxa = taxonNodeDao.countTaxonOfAcceptedTaxaByClassification(classification); logger.info(countTaxa); assertEquals("there should be 7 taxa left", 7, countTaxa); - - + } + + @Test + @DataSet(value="TaxonNodeDaoHibernateImplTest.testSortindexForJavassist.xml") + @ExpectedDataSet("TaxonNodeDaoHibernateImplTest.testSortindexForJavassist-result.xml") + public void testSortindexForJavassist(){ + Taxon newParentTaxon = (Taxon)taxonDao.findByUuid(UUID.fromString("bc09aca6-06fd-4905-b1e7-cbf7cc65d783")); + Taxon firstTopLevelChildTaxon = (Taxon)taxonDao.findByUuid(UUID.fromString("7b8b5cb3-37ba-4dba-91ac-4c6ffd6ac331")); + Classification classification = classificationDao.findByUuid(ClassificationUuid); + classification.addParentChild(newParentTaxon, firstTopLevelChildTaxon, null, null); + commitAndStartNewTransaction( new String[]{"TaxonNode"}); + } } diff --git a/cdmlib-persistence/src/test/resources/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonNodeDaoHibernateImplTest.testSortindexForJavassist-result.xml b/cdmlib-persistence/src/test/resources/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonNodeDaoHibernateImplTest.testSortindexForJavassist-result.xml new file mode 100644 index 0000000000..450087b67c --- /dev/null +++ b/cdmlib-persistence/src/test/resources/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonNodeDaoHibernateImplTest.testSortindexForJavassist-result.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/cdmlib-persistence/src/test/resources/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonNodeDaoHibernateImplTest.testSortindexForJavassist.xml b/cdmlib-persistence/src/test/resources/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonNodeDaoHibernateImplTest.testSortindexForJavassist.xml new file mode 100644 index 0000000000..c175bd8434 --- /dev/null +++ b/cdmlib-persistence/src/test/resources/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonNodeDaoHibernateImplTest.testSortindexForJavassist.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file