fixing problem with TaxonServiceImplTest which ocurred only on my machine. The test...
[cdmlib.git] / cdmlib-services / src / test / java / eu / etaxonomy / cdm / api / service / PolytomousKeyServiceImplTest.java
1 // $Id$
2 /**
3 * Copyright (C) 2009 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
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.
9 */
10 package eu.etaxonomy.cdm.api.service;
11
12 import static org.junit.Assert.*;
13
14 import java.util.UUID;
15
16 import org.apache.log4j.Logger;
17 import org.junit.Before;
18 import org.junit.BeforeClass;
19 import org.junit.Ignore;
20 import org.junit.Test;
21 import org.unitils.dbunit.annotation.DataSet;
22 import org.unitils.spring.annotation.SpringBeanByType;
23
24 import eu.etaxonomy.cdm.model.description.PolytomousKey;
25 import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
26 import eu.etaxonomy.cdm.model.taxon.Taxon;
27 import eu.etaxonomy.cdm.test.integration.CdmIntegrationTest;
28 import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;
29
30 /**
31 * @author a.mueller
32 * @date 23.08.2011
33 *
34 */
35 @Ignore
36 public class PolytomousKeyServiceImplTest extends CdmTransactionalIntegrationTest {
37 private static final Logger logger = Logger.getLogger(PolytomousKeyServiceImplTest.class);
38
39 @SpringBeanByType
40 private IPolytomousKeyService service;
41
42 @SpringBeanByType
43 private IPolytomousKeyNodeService nodeService;
44
45 /**
46 * @throws java.lang.Exception
47 */
48 @BeforeClass
49 public static void setUpBeforeClass() throws Exception {
50 }
51
52 /**
53 * @throws java.lang.Exception
54 */
55 @Before
56 public void setUp() throws Exception {
57 }
58
59 //************************* TESTS ********************************************/
60
61 /**
62 * Test method for {@link eu.etaxonomy.cdm.api.service.ServiceBase#count(java.lang.Class)}.
63 */
64 @Test
65 public void testCount() {
66 PolytomousKey key = PolytomousKey.NewTitledInstance("My test key");
67 service.save(key);
68 Taxon taxon = Taxon.NewInstance(null, null);
69
70
71 key.addTaxonomicScope(taxon);
72
73 // Annotation annotation = Annotation.NewInstance("Any annotation", Language.DEFAULT());
74 // key.addAnnotation(annotation);
75
76 PolytomousKeyNode child = PolytomousKeyNode.NewInstance();
77 Taxon taxon2 = Taxon.NewInstance(null, null);
78
79 child.setTaxon(taxon2);
80 key.getRoot().addChild(child);
81
82 service.save(key);
83 setComplete();
84 endTransaction();
85 System.out.println("Count");
86 printDataSet(System.out, new String[]{"PolytomousKey", "POLYTOMOUSKEYNODE", "POLYTOMOUSKEYNODE_LANGUAGESTRING",
87 "POLYTOMOUSKEY_ANNOTATION","POLYTOMOUSKEY_CREDIT",
88 "POLYTOMOUSKEY_EXTENSION", "POLYTOMOUSKEY_MARKER", "POLYTOMOUSKEY_NAMEDAREA",
89 "POLYTOMOUSKEY_ORIGINALSOURCEBASE", "POLYTOMOUSKEY_RIGHTS", "POLYTOMOUSKEY_SCOPE",
90 "POLYTOMOUSKEY_TAXON", "POLYTOMOUSKEY_TAXONBASE",
91 "ANNOTATION","TAXONBASE"});
92 // printDataSet(System.out);
93
94 }
95
96 /**
97 * Test method for {@link eu.etaxonomy.cdm.api.service.ServiceBase#delete(eu.etaxonomy.cdm.model.common.CdmBase)}.
98 */
99 @Test
100 @DataSet
101 public void testDelete() {
102 System.out.println("Delete start");
103 printDataSet(System.out, new String[]{"PolytomousKey", "POLYTOMOUSKEYNODE", "POLYTOMOUSKEYNODE_LANGUAGESTRING",
104 "POLYTOMOUSKEY_ANNOTATION","POLYTOMOUSKEY_CREDIT",
105 "POLYTOMOUSKEY_EXTENSION", "POLYTOMOUSKEY_MARKER", "POLYTOMOUSKEY_NAMEDAREA",
106 "POLYTOMOUSKEY_ORIGINALSOURCEBASE", "POLYTOMOUSKEY_RIGHTS", "POLYTOMOUSKEY_SCOPE",
107 "POLYTOMOUSKEY_TAXON", "POLYTOMOUSKEY_TAXONBASE",
108 "ANNOTATION","TAXONBASE"});
109
110 UUID uuid = UUID.fromString("0a709940-4f2e-43c1-8db1-f4745f2a4889");
111 PolytomousKey key = service.find(uuid);
112 PolytomousKeyNode someChild = key.getRoot().getChildren().iterator().next();
113 // service.delete(key);
114 key.getRoot().removeChild(someChild);
115 nodeService.delete(someChild);
116
117
118 setComplete();
119 endTransaction();
120 System.out.println("Delete End");
121
122 printDataSet(System.out, new String[]{"PolytomousKey", "POLYTOMOUSKEYNODE", "POLYTOMOUSKEYNODE_LANGUAGESTRING",
123 "POLYTOMOUSKEY_ANNOTATION","POLYTOMOUSKEY_CREDIT",
124 "POLYTOMOUSKEY_EXTENSION", "POLYTOMOUSKEY_MARKER", "POLYTOMOUSKEY_NAMEDAREA",
125 "POLYTOMOUSKEY_ORIGINALSOURCEBASE", "POLYTOMOUSKEY_RIGHTS", "POLYTOMOUSKEY_SCOPE",
126 "POLYTOMOUSKEY_TAXON", "POLYTOMOUSKEY_TAXONBASE"});
127 }
128
129 /**
130 * Test method for {@link eu.etaxonomy.cdm.api.service.ServiceBase#exists(java.util.UUID)}.
131 */
132 @Test
133 public void testExists() {
134 logger.warn("testExists not yet implemented");
135 }
136
137 }