Project

General

Profile

Download (3.52 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
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.
8
*/
9
package eu.etaxonomy.cdm.persistence.hibernate.replace;
10

    
11
import java.io.FileNotFoundException;
12
import java.util.UUID;
13

    
14
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
15
import org.junit.Assert;
16
import org.junit.Before;
17
import org.junit.Ignore;
18
import org.junit.Test;
19
import org.unitils.dbunit.annotation.DataSet;
20
import org.unitils.dbunit.annotation.DataSets;
21
import org.unitils.dbunit.annotation.ExpectedDataSet;
22
import org.unitils.spring.annotation.SpringBeanByType;
23

    
24
import eu.etaxonomy.cdm.model.agent.Institution;
25
import eu.etaxonomy.cdm.model.agent.Person;
26
import eu.etaxonomy.cdm.model.name.TaxonName;
27
import eu.etaxonomy.cdm.persistence.dao.agent.IAgentDao;
28
import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;
29
import eu.etaxonomy.cdm.test.unitils.CleanSweepInsertLoadStrategy;
30

    
31
/**
32
 * @author ben.clark
33
 * @since 22.12.2009
34
 */
35
@Ignore
36
public class ReferringObjectMetadataFactoryTest extends CdmTransactionalIntegrationTest {
37

    
38
    @SuppressWarnings("unused")
39
	private static Logger logger = LogManager.getLogger(ReferringObjectMetadataFactoryTest.class);
40

    
41
	@SpringBeanByType
42
	private ReferringObjectMetadataFactory referringObjectMetadataFactory;
43

    
44
	@SpringBeanByType
45
	private IAgentDao agentDao;
46

    
47
	private UUID institution1;
48

    
49
	private UUID institution2;
50

    
51
    private UUID person1;
52

    
53
	private UUID person2;
54

    
55
	private UUID person3;
56

    
57
	@Before
58
	public void setUp() throws Exception {
59
		institution1 = UUID.fromString("18679846-7343-4e5f-b14e-5eb56b967989");
60
		institution2 = UUID.fromString("28f6aaa5-e03e-4831-9ce2-71eaf56cdebe");
61
		person1 = UUID.fromString("ed6ac546-8c6c-48c4-9b91-40b1157c05c6");
62
		person2 = UUID.fromString("e4ec436a-3e8c-4166-a834-3bb84c2b5ad6");
63
		person3 = UUID.fromString("c62cd389-d787-47f4-99c3-b80eb12a1ef2");
64
	}
65

    
66
	@Test
67
	public void testReferringObjectMetadataFactory() throws Exception {
68
		referringObjectMetadataFactory.get(Person.class);
69
	}
70

    
71
	@Test
72
	@DataSet
73
	public void testReplaceUnmapped() throws Exception {
74
		Institution x = (Institution)agentDao.findByUuid(institution1);
75
		Institution y = (Institution)agentDao.findByUuid(institution2);
76

    
77
		Assert.assertNotNull(x);
78
		Assert.assertNotNull(y);
79

    
80
		agentDao.replace(x,y);
81
	}
82

    
83
	@Test
84
	@DataSets({
85
	        @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="/eu/etaxonomy/cdm/database/ClearDB_with_Terms_DataSet.xml"),
86
	        @DataSet(value="/eu/etaxonomy/cdm/database/TermsDataSet-with_auditing_info.xml"),
87
	        @DataSet(value="ReferringObjectMetadataFactoryTest.xml")
88
	    })
89
	@ExpectedDataSet
90
	public void testReplaceToOneProperty() throws Exception {
91
		Person x = (Person)agentDao.findByUuid(person1);
92
		Person y = (Person)agentDao.findByUuid(person2);
93

    
94
		Assert.assertNotNull(x);
95
		Assert.assertNotNull(y);
96

    
97
		agentDao.replace(x,y);
98
		this.setComplete();
99
		this.endTransaction();
100
	}
101

    
102
	@Test
103
	@DataSet
104
	//@ExpectedDataSet
105
	public void testReplaceToManyProperty() throws Exception {
106
		Person x = (Person)agentDao.findByUuid(person3);
107
		Person y = (Person)agentDao.findByUuid(person2);
108

    
109
		Assert.assertNotNull(x);
110
		Assert.assertNotNull(y);
111

    
112
		agentDao.replace(x,y);
113
	}
114

    
115
	@Test
116
	public void testIgnoreBidirectionalRelationship() {
117
		referringObjectMetadataFactory.get(TaxonName.class);
118
	}
119

    
120
    @Override
121
    public void createTestDataSet() throws FileNotFoundException {}
122
}
    (1-1/1)