3 * Copyright (C) 2015 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
.model
;
12 import java
.util
.UUID
;
14 import org
.apache
.log4j
.Level
;
15 import org
.apache
.log4j
.Logger
;
16 import org
.junit
.Before
;
17 import org
.junit
.BeforeClass
;
18 import org
.junit
.Test
;
19 import org
.unitils
.dbunit
.annotation
.DataSet
;
21 import eu
.etaxonomy
.cdm
.api
.service
.DeleteResult
;
22 import eu
.etaxonomy
.cdm
.api
.service
.IClassificationService
;
23 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonNodeService
;
24 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
25 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
26 import eu
.etaxonomy
.cdm
.model
.name
.BotanicalName
;
27 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalCode
;
28 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
29 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
30 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
31 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
32 import eu
.etaxonomy
.taxeditor
.httpinvoker
.BaseRemotingTest
;
33 import eu
.etaxonomy
.taxeditor
.httpinvoker
.CDMServer
;
34 import eu
.etaxonomy
.taxeditor
.remoting
.cache
.CdmTransientEntityCacher
;
35 import eu
.etaxonomy
.taxeditor
.session
.ICdmEntitySession
;
36 import eu
.etaxonomy
.taxeditor
.session
.ICdmEntitySessionEnabled
;
37 import eu
.etaxonomy
.taxeditor
.session
.MockSessionOwner
;
45 public class TaxonNodeTest
extends BaseRemotingTest
{
47 private static final Logger logger
= Logger
.getLogger(TaxonNodeTest
.class);
49 UUID taxonNodeUuid
= UUID
.fromString("324a1a77-689c-44be-8e65-347d835f4111");
50 private static final UUID classificationUuid
= UUID
.fromString("6c2bc8d9-ee62-4222-be89-4a8e31770878");
52 private static final UUID node1Uuid
= UUID
.fromString("484a1a77-689c-44be-8e65-347d835f47e8");
53 private static final UUID node2Uuid
= UUID
.fromString("2d41f0c2-b785-4f73-a436-cc2d5e93cc5b");
55 private static final UUID rootNodeUuid
= UUID
.fromString("324a1a77-689c-44be-8e65-347d835f4111");
57 ITaxonNodeService taxonNodeService
= getRemoteApplicationController().getTaxonNodeService();
58 IClassificationService classificationService
= getRemoteApplicationController().getClassificationService();
61 private CdmTransientEntityCacher cacher
;
62 private ICdmEntitySessionEnabled sessionOwner
;
64 private ICdmEntitySession cdmEntitySession
;
66 Language english
= Language
.getLanguageFromUuid(Language
.uuidEnglish
);
71 public static void initializePolytomousKeyTest() {
72 logger
.setLevel(Level
.INFO
);
73 CDMServer
.getInstance().setKeepServerRunning(true);
74 initializeController("default",
78 NomenclaturalCode
.ICNAFP
,
84 public void initializeSession() {
85 sessionOwner
= new MockSessionOwner();
86 cdmEntitySession
= cdmEntitySessionManager
.newSession(sessionOwner
, true);
87 cacher
= getCacher(sessionOwner
);
91 public void deleteTaxonNode() {
92 Classification classification
= classificationService
.load(classificationUuid
);
93 TaxonNode node1
= taxonNodeService
.load(node1Uuid
);
94 TaxonNode node2
= taxonNodeService
.load(rootNodeUuid
);
95 node1
= (TaxonNode
)HibernateProxyHelper
.deproxy(node1
);
97 TaxonNode newNode
= node1
.addChildTaxon(Taxon
.NewInstance(BotanicalName
.NewInstance(Rank
.SPECIES()), null), null, null);
98 newNode
= taxonNodeService
.merge(newNode
);
99 newNode
= taxonNodeService
.load(newNode
.getUuid());
100 UUID taxUUID
= newNode
.getTaxon().getUuid();
101 UUID nameUUID
= newNode
.getTaxon().getName().getUuid();
103 DeleteResult result
= taxonNodeService
.deleteTaxonNode(node1
, null);
105 node1
= taxonNodeService
.load(node1Uuid
);