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
.CdmTransactionalIntegrationTest
;
35 public class PolytomousKeyServiceImplTest
extends CdmTransactionalIntegrationTest
{
36 private static final Logger logger
= Logger
.getLogger(PolytomousKeyServiceImplTest
.class);
39 private IPolytomousKeyService service
;
42 private IPolytomousKeyNodeService nodeService
;
45 * @throws java.lang.Exception
48 public static void setUpBeforeClass() throws Exception
{
52 * @throws java.lang.Exception
55 public void setUp() throws Exception
{
58 //************************* TESTS ********************************************/
61 * Test method for {@link eu.etaxonomy.cdm.api.service.ServiceBase#count(java.lang.Class)}.
64 public void testCount() {
65 PolytomousKey key
= PolytomousKey
.NewTitledInstance("My test key");
67 Taxon taxon
= Taxon
.NewInstance(null, null);
70 key
.addTaxonomicScope(taxon
);
72 // Annotation annotation = Annotation.NewInstance("Any annotation", Language.DEFAULT());
73 // key.addAnnotation(annotation);
75 PolytomousKeyNode child
= PolytomousKeyNode
.NewInstance();
76 Taxon taxon2
= Taxon
.NewInstance(null, null);
78 child
.setTaxon(taxon2
);
79 key
.getRoot().addChild(child
);
84 System
.out
.println("Count");
85 printDataSet(System
.out
, new String
[]{"PolytomousKey", "POLYTOMOUSKEYNODE", "POLYTOMOUSKEYNODE_LANGUAGESTRING",
86 "POLYTOMOUSKEY_ANNOTATION","POLYTOMOUSKEY_CREDIT",
87 "POLYTOMOUSKEY_EXTENSION", "POLYTOMOUSKEY_MARKER", "POLYTOMOUSKEY_NAMEDAREA",
88 "POLYTOMOUSKEY_ORIGINALSOURCEBASE", "POLYTOMOUSKEY_RIGHTS", "POLYTOMOUSKEY_SCOPE",
89 "POLYTOMOUSKEY_TAXON", "POLYTOMOUSKEY_TAXONBASE",
90 "ANNOTATION","TAXONBASE"});
91 // printDataSet(System.out);
96 * Test method for {@link eu.etaxonomy.cdm.api.service.ServiceBase#delete(eu.etaxonomy.cdm.model.common.CdmBase)}.
100 public void testDelete() {
101 System
.out
.println("Delete start");
102 printDataSet(System
.out
, new String
[]{"PolytomousKey", "POLYTOMOUSKEYNODE", "POLYTOMOUSKEYNODE_LANGUAGESTRING",
103 "POLYTOMOUSKEY_ANNOTATION","POLYTOMOUSKEY_CREDIT",
104 "POLYTOMOUSKEY_EXTENSION", "POLYTOMOUSKEY_MARKER", "POLYTOMOUSKEY_NAMEDAREA",
105 "POLYTOMOUSKEY_ORIGINALSOURCEBASE", "POLYTOMOUSKEY_RIGHTS", "POLYTOMOUSKEY_SCOPE",
106 "POLYTOMOUSKEY_TAXON", "POLYTOMOUSKEY_TAXONBASE",
107 "ANNOTATION","TAXONBASE"});
109 UUID uuid
= UUID
.fromString("0a709940-4f2e-43c1-8db1-f4745f2a4889");
110 PolytomousKey key
= service
.find(uuid
);
111 PolytomousKeyNode someChild
= key
.getRoot().getChildren().iterator().next();
112 // service.delete(key);
113 key
.getRoot().removeChild(someChild
);
114 nodeService
.delete(someChild
);
119 System
.out
.println("Delete End");
121 printDataSet(System
.out
, new String
[]{"PolytomousKey", "POLYTOMOUSKEYNODE", "POLYTOMOUSKEYNODE_LANGUAGESTRING",
122 "POLYTOMOUSKEY_ANNOTATION","POLYTOMOUSKEY_CREDIT",
123 "POLYTOMOUSKEY_EXTENSION", "POLYTOMOUSKEY_MARKER", "POLYTOMOUSKEY_NAMEDAREA",
124 "POLYTOMOUSKEY_ORIGINALSOURCEBASE", "POLYTOMOUSKEY_RIGHTS", "POLYTOMOUSKEY_SCOPE",
125 "POLYTOMOUSKEY_TAXON", "POLYTOMOUSKEY_TAXONBASE"});
129 * Test method for {@link eu.etaxonomy.cdm.api.service.ServiceBase#exists(java.util.UUID)}.
132 public void testExists() {
133 logger
.warn("testExists not yet implemented");