3 * Copyright (C) 2009 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.api
.service
;
12 import static org
.junit
.Assert
.*;
14 import java
.io
.FileNotFoundException
;
15 import java
.util
.UUID
;
17 import org
.apache
.log4j
.Logger
;
18 import org
.junit
.Assert
;
19 import org
.junit
.Before
;
20 import org
.junit
.BeforeClass
;
21 import org
.junit
.Ignore
;
22 import org
.junit
.Test
;
23 import org
.unitils
.dbunit
.annotation
.DataSet
;
24 import org
.unitils
.spring
.annotation
.SpringBeanByType
;
26 import eu
.etaxonomy
.cdm
.api
.service
.exception
.ReferencedObjectUndeletableException
;
27 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKey
;
28 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKeyNode
;
29 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
30 import eu
.etaxonomy
.cdm
.test
.integration
.CdmTransactionalIntegrationTest
;
38 public class PolytomousKeyServiceImplTest
extends CdmTransactionalIntegrationTest
{
39 private static final Logger logger
= Logger
.getLogger(PolytomousKeyServiceImplTest
.class);
42 private IPolytomousKeyService service
;
45 private IPolytomousKeyNodeService nodeService
;
48 * @throws java.lang.Exception
51 public static void setUpBeforeClass() throws Exception
{
55 * @throws java.lang.Exception
58 public void setUp() throws Exception
{
61 //************************* TESTS ********************************************/
64 * Test method for {@link eu.etaxonomy.cdm.api.service.ServiceBase#count(java.lang.Class)}.
67 public void testCount() {
68 PolytomousKey key
= PolytomousKey
.NewTitledInstance("My test key");
70 Taxon taxon
= Taxon
.NewInstance(null, null);
73 key
.addTaxonomicScope(taxon
);
75 // Annotation annotation = Annotation.NewInstance("Any annotation", Language.DEFAULT());
76 // key.addAnnotation(annotation);
78 PolytomousKeyNode child
= PolytomousKeyNode
.NewInstance();
79 Taxon taxon2
= Taxon
.NewInstance(null, null);
81 child
.setTaxon(taxon2
);
82 key
.getRoot().addChild(child
);
87 System
.out
.println("Count");
88 printDataSet(System
.out
, new String
[]{"PolytomousKey", "POLYTOMOUSKEYNODE", "POLYTOMOUSKEYNODE_LANGUAGESTRING",
89 "POLYTOMOUSKEY_ANNOTATION","POLYTOMOUSKEY_CREDIT",
90 "POLYTOMOUSKEY_EXTENSION", "POLYTOMOUSKEY_MARKER", "POLYTOMOUSKEY_NAMEDAREA",
91 "POLYTOMOUSKEY_ORIGINALSOURCEBASE", "POLYTOMOUSKEY_RIGHTS", "POLYTOMOUSKEY_SCOPE",
92 "POLYTOMOUSKEY_TAXON", "POLYTOMOUSKEY_TAXONBASE",
93 "ANNOTATION","TAXONBASE"});
94 // printDataSet(System.out);
99 * Test method for {@link eu.etaxonomy.cdm.api.service.ServiceBase#delete(eu.etaxonomy.cdm.model.common.CdmBase)}.
103 public void testDelete() {
104 System
.out
.println("Delete start");
105 printDataSet(System
.out
, new String
[]{"PolytomousKey", "POLYTOMOUSKEYNODE", "POLYTOMOUSKEYNODE_LANGUAGESTRING",
106 "POLYTOMOUSKEY_ANNOTATION","POLYTOMOUSKEY_CREDIT",
107 "POLYTOMOUSKEY_EXTENSION", "POLYTOMOUSKEY_MARKER", "POLYTOMOUSKEY_NAMEDAREA",
108 "POLYTOMOUSKEY_ORIGINALSOURCEBASE", "POLYTOMOUSKEY_RIGHTS", "POLYTOMOUSKEY_SCOPE",
109 "POLYTOMOUSKEY_TAXON", "POLYTOMOUSKEY_TAXONBASE",
110 "ANNOTATION","TAXONBASE"});
112 UUID uuid
= UUID
.fromString("0a709940-4f2e-43c1-8db1-f4745f2a4889");
113 PolytomousKey key
= service
.find(uuid
);
114 PolytomousKeyNode someChild
= key
.getRoot().getChildren().iterator().next();
115 // service.delete(key);
116 key
.getRoot().removeChild(someChild
);
117 nodeService
.delete(someChild
);
122 System
.out
.println("Delete End");
124 printDataSet(System
.out
, new String
[]{"PolytomousKey", "POLYTOMOUSKEYNODE", "POLYTOMOUSKEYNODE_LANGUAGESTRING",
125 "POLYTOMOUSKEY_ANNOTATION","POLYTOMOUSKEY_CREDIT",
126 "POLYTOMOUSKEY_EXTENSION", "POLYTOMOUSKEY_MARKER", "POLYTOMOUSKEY_NAMEDAREA",
127 "POLYTOMOUSKEY_ORIGINALSOURCEBASE", "POLYTOMOUSKEY_RIGHTS", "POLYTOMOUSKEY_SCOPE",
128 "POLYTOMOUSKEY_TAXON", "POLYTOMOUSKEY_TAXONBASE"});
132 * Test method for {@link eu.etaxonomy.cdm.api.service.ServiceBase#exists(java.util.UUID)}.
135 public void testExists() {
136 logger
.warn("testExists not yet implemented");
140 * @see eu.etaxonomy.cdm.test.integration.CdmIntegrationTest#createTestData()
143 protected void createTestDataSet() throws FileNotFoundException
{
144 // TODO Auto-generated method stub