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 * Test method for {@link eu.etaxonomy.cdm.persistence.hibernate.CdmDeleteListener#onDelete(org.hibernate.event.DeleteEvent, java.util.Set)}.
62 @DataSet("CdmDeleteListenerTest.xml")
64 public void testOnDelete() {
65 NonViralName name1
= (NonViralName
)taxonNameDao
.findByUuid(name1Uuid
);
67 Set
<NameRelationship
> relations
= name1
.getNameRelations();
68 Assert
.assertEquals("There must be 1 name relationship", 1, relations
.size());
69 name1
.removeNameRelationship(relations
.iterator().next());
71 Set
<HybridRelationship
> hybridRels
= name1
.getParentRelationships();
72 Assert
.assertEquals("There must be 1 parent relationship", 1, hybridRels
.size());
74 taxonNameDao
.saveOrUpdate(name1
);