3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.cdm
.persistence
.hibernate
;
13 import static org
.junit
.Assert
.assertNotNull
;
16 import java
.io
.FileOutputStream
;
18 import java
.util
.UUID
;
20 import org
.apache
.log4j
.Logger
;
21 import org
.junit
.Assert
;
22 import org
.junit
.Ignore
;
23 import org
.junit
.Test
;
24 import org
.unitils
.dbunit
.annotation
.DataSet
;
25 import org
.unitils
.dbunit
.annotation
.ExpectedDataSet
;
26 import org
.unitils
.spring
.annotation
.SpringBeanByType
;
28 import eu
.etaxonomy
.cdm
.model
.name
.BotanicalName
;
29 import eu
.etaxonomy
.cdm
.model
.name
.HybridRelationship
;
30 import eu
.etaxonomy
.cdm
.model
.name
.HybridRelationshipType
;
31 import eu
.etaxonomy
.cdm
.model
.name
.NameRelationship
;
32 import eu
.etaxonomy
.cdm
.model
.name
.NonViralName
;
33 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
34 import eu
.etaxonomy
.cdm
.persistence
.dao
.name
.ITaxonNameDao
;
35 import eu
.etaxonomy
.cdm
.test
.integration
.CdmIntegrationTest
;
42 public class CdmDeleteListenerTest
extends CdmIntegrationTest
{
43 @SuppressWarnings("unused")
44 private static final Logger logger
= Logger
.getLogger(CdmDeleteListenerTest
.class);
47 private ITaxonNameDao taxonNameDao
;
49 private UUID name1Uuid
= UUID
.fromString("a49a3963-c4ea-4047-8588-2f8f15352730");
53 @DataSet("CdmDeleteListenerTest.xml")
54 public void testTaxonNameDao() throws Exception
{
55 assertNotNull("taxonNameDao should exist",taxonNameDao
);
59 @DataSet("CdmDeleteListenerTest.xml")
60 public void testPrintDataset(){
61 BotanicalName botName1
= BotanicalName
.NewInstance(Rank
.SPECIES());
62 BotanicalName botName2
= BotanicalName
.NewInstance(Rank
.SPECIES());
63 //botName1.addRelationshipToName(botName2, NameRelationshipType.ORTHOGRAPHIC_VARIANT(), null);
64 botName1
.addHybridChild(botName2
, HybridRelationshipType
.FEMALE_PARENT(), null);
65 taxonNameDao
.saveOrUpdate(botName1
);
66 //taxonNameDao.flush();
68 File file
= new File("testXXX.txt");
72 //printDataSet(new FileOutputStream(file));
73 } catch (Exception e
) {
80 * Test method for {@link eu.etaxonomy.cdm.persistence.hibernate.CdmDeleteListener#onDelete(org.hibernate.event.DeleteEvent, java.util.Set)}.
83 @DataSet("CdmDeleteListenerTest.xml")
85 public void testOnDelete() {
86 NonViralName name1
= (NonViralName
)taxonNameDao
.findByUuid(name1Uuid
);
88 Set
<NameRelationship
> relations
= name1
.getNameRelations();
89 Assert
.assertEquals("There must be 1 name relationship", 1, relations
.size());
90 name1
.removeNameRelationship(relations
.iterator().next());
92 Set
<HybridRelationship
> hybridRels
= name1
.getParentRelationships();
93 Assert
.assertEquals("There must be 1 parent relationship", 1, hybridRels
.size());
95 taxonNameDao
.saveOrUpdate(name1
);
100 public void testPrintDataset2(){
102 File file
= new File("testXXX.txt");
104 file
.createNewFile();
106 printDataSet(new FileOutputStream(file
));
107 } catch (Exception e
) {