Project

General

Profile

Download (4.56 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2009 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.api.service;
10

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

    
14
import org.apache.log4j.Logger;
15
import org.junit.Before;
16
import org.junit.BeforeClass;
17
import org.junit.Ignore;
18
import org.junit.Test;
19
import org.unitils.dbunit.annotation.DataSet;
20
import org.unitils.spring.annotation.SpringBeanByType;
21

    
22
import eu.etaxonomy.cdm.model.description.PolytomousKey;
23
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
24
import eu.etaxonomy.cdm.model.taxon.Taxon;
25
import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;
26

    
27
/**
28
 * @author a.mueller
29
 \* @since 23.08.2011
30
 *
31
 */
32
@Ignore
33
public class PolytomousKeyServiceImplTest extends CdmTransactionalIntegrationTest {
34
	private static final Logger logger = Logger.getLogger(PolytomousKeyServiceImplTest.class);
35

    
36
	@SpringBeanByType
37
	private IPolytomousKeyService service;
38
	
39
	@SpringBeanByType
40
	private IPolytomousKeyNodeService nodeService;
41

    
42
	/**
43
	 * @throws java.lang.Exception
44
	 */
45
	@BeforeClass
46
	public static void setUpBeforeClass() throws Exception {
47
	}
48

    
49
	/**
50
	 * @throws java.lang.Exception
51
	 */
52
	@Before
53
	public void setUp() throws Exception {
54
	}
55
	
56
//************************* TESTS ********************************************/	
57

    
58
	/**
59
	 * Test method for {@link eu.etaxonomy.cdm.api.service.ServiceBase#count(java.lang.Class)}.
60
	 */
61
	@Test
62
	public void testCount() {
63
		PolytomousKey key = PolytomousKey.NewTitledInstance("My test key");
64
		service.save(key);
65
		Taxon taxon = Taxon.NewInstance(null, null);
66
		
67
		
68
		key.addTaxonomicScope(taxon);
69
		
70
//		Annotation annotation = Annotation.NewInstance("Any annotation", Language.DEFAULT());
71
//		key.addAnnotation(annotation);
72
		
73
		PolytomousKeyNode child = PolytomousKeyNode.NewInstance();
74
		Taxon taxon2 = Taxon.NewInstance(null, null);
75
		
76
		child.setTaxon(taxon2);
77
		key.getRoot().addChild(child);
78
		
79
		service.save(key);
80
		setComplete(); 
81
		endTransaction();
82
		System.out.println("Count");
83
		printDataSet(System.out, new String[]{"PolytomousKey", "POLYTOMOUSKEYNODE", "POLYTOMOUSKEYNODE_LANGUAGESTRING", 
84
				"POLYTOMOUSKEY_ANNOTATION","POLYTOMOUSKEY_CREDIT",
85
				"POLYTOMOUSKEY_EXTENSION", "POLYTOMOUSKEY_MARKER", "POLYTOMOUSKEY_NAMEDAREA",
86
				"POLYTOMOUSKEY_ORIGINALSOURCEBASE", "POLYTOMOUSKEY_RIGHTS", "POLYTOMOUSKEY_SCOPE",
87
				"POLYTOMOUSKEY_TAXON", "POLYTOMOUSKEY_TAXONBASE",
88
				"ANNOTATION","TAXONBASE"});
89
//		printDataSet(System.out);
90
		
91
	}
92

    
93
	/**
94
	 * Test method for {@link eu.etaxonomy.cdm.api.service.ServiceBase#delete(eu.etaxonomy.cdm.model.common.CdmBase)}.
95
	 */
96
	@Test
97
	@DataSet
98
	public void testDelete() {
99
		System.out.println("Delete start");
100
		printDataSet(System.out, new String[]{"PolytomousKey", "POLYTOMOUSKEYNODE", "POLYTOMOUSKEYNODE_LANGUAGESTRING", 
101
				"POLYTOMOUSKEY_ANNOTATION","POLYTOMOUSKEY_CREDIT",
102
				"POLYTOMOUSKEY_EXTENSION", "POLYTOMOUSKEY_MARKER", "POLYTOMOUSKEY_NAMEDAREA",
103
				"POLYTOMOUSKEY_ORIGINALSOURCEBASE", "POLYTOMOUSKEY_RIGHTS", "POLYTOMOUSKEY_SCOPE",
104
				"POLYTOMOUSKEY_TAXON", "POLYTOMOUSKEY_TAXONBASE",
105
				"ANNOTATION","TAXONBASE"});
106
		
107
		UUID uuid = UUID.fromString("0a709940-4f2e-43c1-8db1-f4745f2a4889");
108
		PolytomousKey key = service.find(uuid);
109
		PolytomousKeyNode someChild = key.getRoot().getChildren().iterator().next();
110
//		service.delete(key);
111
		key.getRoot().removeChild(someChild);
112
		nodeService.delete(someChild);
113
		
114
		
115
		setComplete(); 
116
		endTransaction();
117
		System.out.println("Delete End");
118
		
119
		printDataSet(System.out, new String[]{"PolytomousKey", "POLYTOMOUSKEYNODE", "POLYTOMOUSKEYNODE_LANGUAGESTRING", 
120
				"POLYTOMOUSKEY_ANNOTATION","POLYTOMOUSKEY_CREDIT",
121
				"POLYTOMOUSKEY_EXTENSION", "POLYTOMOUSKEY_MARKER", "POLYTOMOUSKEY_NAMEDAREA",
122
				"POLYTOMOUSKEY_ORIGINALSOURCEBASE", "POLYTOMOUSKEY_RIGHTS", "POLYTOMOUSKEY_SCOPE",
123
				"POLYTOMOUSKEY_TAXON", "POLYTOMOUSKEY_TAXONBASE"});
124
	}
125

    
126
	/**
127
	 * Test method for {@link eu.etaxonomy.cdm.api.service.ServiceBase#exists(java.util.UUID)}.
128
	 */
129
	@Test
130
	public void testExists() {
131
		logger.warn("testExists not yet implemented");
132
	}
133

    
134
    /* (non-Javadoc)
135
     * @see eu.etaxonomy.cdm.test.integration.CdmIntegrationTest#createTestData()
136
     */
137
    @Override
138
    public void createTestDataSet() throws FileNotFoundException {
139
        // TODO Auto-generated method stub
140
        
141
    }
142

    
143
}
(18-18/35)