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.testSortindexForJavassist2-result.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
import java.util.List;
import java.util.UUID;
+import javassist.util.proxy.Proxy;
+
import org.junit.After;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.unitils.dbunit.annotation.DataSet;
@Test
@DataSet(value="TaxonNodeDaoHibernateImplTest.testSortindexForJavassist.xml")
@ExpectedDataSet("TaxonNodeDaoHibernateImplTest.testSortindexForJavassist-result.xml")
+ //test if TaxonNode.remove(index) works correctly with proxies
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"));
+ Taxon taxonWithLazyLoadedParentNodeOnTopLevel = (Taxon)taxonDao.findByUuid(UUID.fromString("bc09aca6-06fd-4905-b1e7-cbf7cc65d783"));
+ TaxonNode parent = taxonWithLazyLoadedParentNodeOnTopLevel.getTaxonNodes().iterator().next().getParent();
+ Assert.assertTrue("Parent node must be proxy, otherwise test does not work", parent instanceof Proxy);
+ Taxon firstTopLevelTaxon = (Taxon)taxonDao.findByUuid(UUID.fromString("7b8b5cb3-37ba-4dba-91ac-4c6ffd6ac331"));
+ Classification classification = classificationDao.findByUuid(ClassificationUuid);
+ classification.addParentChild(taxonWithLazyLoadedParentNodeOnTopLevel, firstTopLevelTaxon, null, null);
+ commitAndStartNewTransaction( new String[]{"TaxonNode"});
+ }
+
+ @Test
+ @DataSet(value="TaxonNodeDaoHibernateImplTest.testSortindexForJavassist.xml")
+ @ExpectedDataSet("TaxonNodeDaoHibernateImplTest.testSortindexForJavassist2-result.xml")
+ //test if TaxonNode.addNode(node) works correctly with proxies
+ public void testSortindexForJavassist2(){
+ Taxon taxonWithLazyLoadedParentNodeOnTopLevel = (Taxon)taxonDao.findByUuid(UUID.fromString("bc09aca6-06fd-4905-b1e7-cbf7cc65d783"));
+ TaxonNode parent = taxonWithLazyLoadedParentNodeOnTopLevel.getTaxonNodes().iterator().next().getParent();
+ Assert.assertTrue("Parent node must be proxy, otherwise test does not work", parent instanceof Proxy);
+ Taxon newTaxon = Taxon.NewInstance(null, null);
Classification classification = classificationDao.findByUuid(ClassificationUuid);
- classification.addParentChild(newParentTaxon, firstTopLevelChildTaxon, null, null);
+ classification.addChildTaxon(newTaxon, 0, null, null);
commitAndStartNewTransaction( new String[]{"TaxonNode"});
}
+
}
--- /dev/null
+<?xml version='1.0' encoding='UTF-8'?>\r
+<dataset>\r
+ <TAXONNODE ID="1" CREATED="2009-06-18 13:47:59.0" UUID="cf0316c9-1963-4268-8c2e-8d833c460ac3" SORTINDEX="-1" TREEINDEX="#t1#1#" COUNTCHILDREN="4" CLASSIFICATION_ID="1"/>\r
+ <TAXONNODE ID="2" CREATED="2009-06-18 13:47:59.0" UUID="770239f6-4fa8-496b-8738-fe8f7b2ad519" SORTINDEX="1" TREEINDEX="#t1#1#2#" COUNTCHILDREN="0" CLASSIFICATION_ID="1" PARENT_ID="4" TAXON_ID="37"/>\r
+ <TAXONNODE ID="3" CREATED="2009-06-18 13:47:59.0" UUID="20c8f083-5870-4cbd-bf56-c5b2b98ab6a7" SORTINDEX="2" TREEINDEX="#t1#1#3#" COUNTCHILDREN="1" CLASSIFICATION_ID="1" PARENT_ID="1" TAXON_ID="36"/>\r
+ <TAXONNODE ID="4" CREATED="2009-06-18 13:47:59.0" UUID="0b5846e5-b8d2-4ca9-ac51-099286ea4adc" SORTINDEX="0" TREEINDEX="#t1#1#3#4#" COUNTCHILDREN="0" CLASSIFICATION_ID="1" PARENT_ID="3" TAXON_ID="38"/>\r
+ <TAXONNODE ID="5" CREATED="2009-06-18 13:47:59.0" UUID="4f73adcc-a535-4fbe-a97a-c05ee8b12191" SORTINDEX="3" TREEINDEX="#t1#1#5#" COUNTCHILDREN="0" CLASSIFICATION_ID="1" PARENT_ID="1" TAXON_ID="42"/>\r
+</dataset>
\ No newline at end of file