2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.cdm
.persistence
.hibernate
.replace
;
13 import java
.io
.FileOutputStream
;
14 import java
.util
.UUID
;
16 import org
.apache
.log4j
.Logger
;
17 import org
.junit
.Before
;
18 import org
.junit
.Test
;
19 import org
.unitils
.dbunit
.annotation
.DataSet
;
20 import org
.unitils
.dbunit
.annotation
.ExpectedDataSet
;
21 import org
.unitils
.spring
.annotation
.SpringBeanByType
;
23 import eu
.etaxonomy
.cdm
.model
.agent
.Institution
;
24 import eu
.etaxonomy
.cdm
.model
.agent
.Person
;
25 import eu
.etaxonomy
.cdm
.model
.description
.MediaKey
;
26 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
27 import eu
.etaxonomy
.cdm
.model
.name
.BotanicalName
;
28 import eu
.etaxonomy
.cdm
.persistence
.dao
.agent
.IAgentDao
;
29 import eu
.etaxonomy
.cdm
.test
.integration
.CdmIntegrationTest
;
30 import eu
.etaxonomy
.cdm
.test
.integration
.CdmTransactionalIntegrationTest
;
37 public class ReferringObjectMetadataFactoryTest
extends CdmTransactionalIntegrationTest
{
38 @SuppressWarnings("unused")
39 private static Logger logger
= Logger
.getLogger(ReferringObjectMetadataFactoryTest
.class);
42 private ReferringObjectMetadataFactory referringObjectMetadataFactory
;
45 private IAgentDao agentDao
;
47 private UUID institution1
;
49 private UUID institution2
;
58 * @throws java.lang.Exception
61 public void setUp() throws Exception
{
62 institution1
= UUID
.fromString("18679846-7343-4e5f-b14e-5eb56b967989");
63 institution2
= UUID
.fromString("28f6aaa5-e03e-4831-9ce2-71eaf56cdebe");
64 person1
= UUID
.fromString("ed6ac546-8c6c-48c4-9b91-40b1157c05c6");
65 person2
= UUID
.fromString("e4ec436a-3e8c-4166-a834-3bb84c2b5ad6");
66 person3
= UUID
.fromString("c62cd389-d787-47f4-99c3-b80eb12a1ef2");
70 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.hibernate.common.CdmEntityDaoBase#CdmEntityDaoBase(java.lang.Class)}.
74 public void testReferringObjectMetadataFactory() throws Exception
{
75 referringObjectMetadataFactory
.get(Person
.class);
80 public void testReplaceUnmapped() throws Exception
{
81 Institution x
= (Institution
)agentDao
.findByUuid(institution1
);
82 Institution y
= (Institution
)agentDao
.findByUuid(institution2
);
87 agentDao
.replace(x
,y
);
93 public void testReplaceToOneProperty() throws Exception
{
94 Person x
= (Person
)agentDao
.findByUuid(person1
);
95 Person y
= (Person
)agentDao
.findByUuid(person2
);
100 agentDao
.replace(x
,y
);
102 this.endTransaction();
109 public void testReplaceToManyProperty() throws Exception
{
110 Person x
= (Person
)agentDao
.findByUuid(person3
);
111 Person y
= (Person
)agentDao
.findByUuid(person2
);
116 agentDao
.replace(x
,y
);
120 public void testIgnoreBidirectionalRelationship() {
121 referringObjectMetadataFactory
.get(BotanicalName
.class);