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
.util
.UUID
;
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
;
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
;
36 public class PolytomousKeyServiceImplTest
extends CdmTransactionalIntegrationTest
{
37 private static final Logger logger
= Logger
.getLogger(PolytomousKeyServiceImplTest
.class);
40 private IPolytomousKeyService service
;
43 private IPolytomousKeyNodeService nodeService
;
46 * @throws java.lang.Exception
49 public static void setUpBeforeClass() throws Exception
{
53 * @throws java.lang.Exception
56 public void setUp() throws Exception
{
59 //************************* TESTS ********************************************/
62 * Test method for {@link eu.etaxonomy.cdm.api.service.ServiceBase#count(java.lang.Class)}.
65 public void testCount() {
66 PolytomousKey key
= PolytomousKey
.NewTitledInstance("My test key");
68 Taxon taxon
= Taxon
.NewInstance(null, null);
71 key
.addTaxonomicScope(taxon
);
73 // Annotation annotation = Annotation.NewInstance("Any annotation", Language.DEFAULT());
74 // key.addAnnotation(annotation);
76 PolytomousKeyNode child
= PolytomousKeyNode
.NewInstance();
77 Taxon taxon2
= Taxon
.NewInstance(null, null);
79 child
.setTaxon(taxon2
);
80 key
.getRoot().addChild(child
);
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);
97 * Test method for {@link eu.etaxonomy.cdm.api.service.ServiceBase#delete(eu.etaxonomy.cdm.model.common.CdmBase)}.
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"});
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
);
120 System
.out
.println("Delete End");
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"});
130 * Test method for {@link eu.etaxonomy.cdm.api.service.ServiceBase#exists(java.util.UUID)}.
133 public void testExists() {
134 logger
.warn("testExists not yet implemented");