2 * Copyright (C) 2009 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.
9 package eu
.etaxonomy
.cdm
.api
.service
;
11 import java
.io
.FileNotFoundException
;
12 import java
.util
.UUID
;
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
;
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
;
33 public class PolytomousKeyServiceImplTest
extends CdmTransactionalIntegrationTest
{
34 private static final Logger logger
= Logger
.getLogger(PolytomousKeyServiceImplTest
.class);
37 private IPolytomousKeyService service
;
40 private IPolytomousKeyNodeService nodeService
;
43 * @throws java.lang.Exception
46 public static void setUpBeforeClass() throws Exception
{
50 * @throws java.lang.Exception
53 public void setUp() throws Exception
{
56 //************************* TESTS ********************************************/
59 * Test method for {@link eu.etaxonomy.cdm.api.service.ServiceBase#count(java.lang.Class)}.
62 public void testCount() {
63 PolytomousKey key
= PolytomousKey
.NewTitledInstance("My test key");
65 Taxon taxon
= Taxon
.NewInstance(null, null);
68 key
.addTaxonomicScope(taxon
);
70 // Annotation annotation = Annotation.NewInstance("Any annotation", Language.DEFAULT());
71 // key.addAnnotation(annotation);
73 PolytomousKeyNode child
= PolytomousKeyNode
.NewInstance();
74 Taxon taxon2
= Taxon
.NewInstance(null, null);
76 child
.setTaxon(taxon2
);
77 key
.getRoot().addChild(child
);
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);
94 * Test method for {@link eu.etaxonomy.cdm.api.service.ServiceBase#delete(eu.etaxonomy.cdm.model.common.CdmBase)}.
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"});
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
);
117 System
.out
.println("Delete End");
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"});
127 * Test method for {@link eu.etaxonomy.cdm.api.service.ServiceBase#exists(java.util.UUID)}.
130 public void testExists() {
131 logger
.warn("testExists not yet implemented");
135 * @see eu.etaxonomy.cdm.test.integration.CdmIntegrationTest#createTestData()
138 public void createTestDataSet() throws FileNotFoundException
{
139 // TODO Auto-generated method stub