2 * Copyright (C) 2014 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
.taxeditor
.session
;
11 import java
.util
.ArrayList
;
12 import java
.util
.HashSet
;
13 import java
.util
.Iterator
;
14 import java
.util
.List
;
17 import java
.util
.UUID
;
19 import org
.apache
.log4j
.Logger
;
20 import org
.junit
.Assert
;
21 import org
.junit
.BeforeClass
;
22 import org
.junit
.Ignore
;
23 import org
.junit
.Test
;
24 import org
.unitils
.dbunit
.annotation
.DataSet
;
26 import eu
.etaxonomy
.cdm
.api
.application
.CdmApplicationState
;
27 import eu
.etaxonomy
.cdm
.api
.service
.DeleteResult
;
28 import eu
.etaxonomy
.cdm
.api
.service
.ICommonService
;
29 import eu
.etaxonomy
.cdm
.api
.service
.IPolytomousKeyNodeService
;
30 import eu
.etaxonomy
.cdm
.api
.service
.IPolytomousKeyService
;
31 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonService
;
32 import eu
.etaxonomy
.cdm
.api
.service
.ITermService
;
33 import eu
.etaxonomy
.cdm
.api
.service
.IUserService
;
34 import eu
.etaxonomy
.cdm
.api
.service
.IVocabularyService
;
35 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
36 import eu
.etaxonomy
.cdm
.model
.agent
.AgentBase
;
37 import eu
.etaxonomy
.cdm
.model
.agent
.Person
;
38 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
39 import eu
.etaxonomy
.cdm
.model
.common
.Credit
;
40 import eu
.etaxonomy
.cdm
.model
.common
.DefinedTermBase
;
41 import eu
.etaxonomy
.cdm
.model
.common
.Extension
;
42 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableSource
;
43 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
44 import eu
.etaxonomy
.cdm
.model
.common
.LanguageString
;
45 import eu
.etaxonomy
.cdm
.model
.common
.TermType
;
46 import eu
.etaxonomy
.cdm
.model
.common
.TermVocabulary
;
47 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
48 import eu
.etaxonomy
.cdm
.model
.description
.KeyStatement
;
49 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKey
;
50 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKeyNode
;
51 import eu
.etaxonomy
.cdm
.model
.media
.Rights
;
52 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
53 import eu
.etaxonomy
.cdm
.persistence
.dto
.MergeResult
;
54 import eu
.etaxonomy
.taxeditor
.httpinvoker
.RemotingSessionAwareTest
;
55 import eu
.etaxonomy
.taxeditor
.httpinvoker
.TestThread
;
64 public class CdmEntitySessionAwareTest
extends RemotingSessionAwareTest
{
66 private static final Logger logger
= Logger
.getLogger(CdmEntitySessionAwareTest
.class);
68 UUID polytomousKeyUuid
= UUID
.fromString("0d53ba20-7de4-4baa-bd8a-401048447d66");
69 UUID subKeyUuid
= UUID
.fromString("9d8bf4f6-a70a-4b80-8556-2ccfb436ff01");
70 //UUID polytomousKeyUuid = UUID.fromString("bab66772-2c83-428a-bb6d-655d12ac6097");
71 UUID taxon1Uuid
= UUID
.fromString("2b336df7-29e8-4f79-985f-66502739d22f");
72 UUID personUuid
= UUID
.fromString("945d08f2-eb92-45b6-9252-6275ea6d338b");
76 IPolytomousKeyService polytomousKeyService
= getRemoteApplicationController().getPolytomousKeyService();
77 IPolytomousKeyNodeService polytomousKeyNodeService
= getRemoteApplicationController().getPolytomousKeyNodeService();
78 ICommonService commonService
= getRemoteApplicationController().getCommonService();
79 ITaxonService taxonService
= getRemoteApplicationController().getTaxonService();
80 IVocabularyService vocabularyService
= getRemoteApplicationController().getVocabularyService();
81 ITermService termService
= getRemoteApplicationController().getTermService();
82 IUserService userService
= getRemoteApplicationController().getUserService();
84 //Language english = Language.getLanguageFromUuid(Language.uuidEnglish);
89 public static void initializePolytomousKeyTest() {
95 public void readAllPolytomousKeys() {
96 List
<PolytomousKey
> pKeys
= polytomousKeyService
.list(PolytomousKey
.class, null, null, null, null);
97 Iterator
<PolytomousKey
> pKeysItr
= pKeys
.iterator();
98 Assert
.assertEquals(pKeysItr
.next().getUuid(),UUID
.fromString("9d8bf4f6-a70a-4b80-8556-2ccfb436ff01"));
99 Assert
.assertEquals(pKeysItr
.next().getUuid(),UUID
.fromString("0d53ba20-7de4-4baa-bd8a-401048447d66"));
104 //@DataSet("PolytomousKeyTest.readPolytmousKeyData.xml")
105 public void readPolytmousKeyData() {
106 PolytomousKey pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
107 Set
<Taxon
> taxonomicScope
= pKey
.getTaxonomicScope();
108 Iterator
<Taxon
> tsItr
= taxonomicScope
.iterator();
109 Taxon taxon
= tsItr
.next();
111 Assert
.assertEquals("Achillea sec. Cyprus", taxon
.getTitleCache());
112 Assert
.assertEquals(tsItr
.hasNext(), false);
114 List
<Credit
> credits
= pKey
.getCredits();
115 AgentBase agent
= credits
.get(0).getAgent();
116 Assert
.assertEquals(agent
.getId(),4809);
117 Assert
.assertEquals(agent
.getTitleCache(),"R. A. Graham");
118 Assert
.assertEquals(credits
.get(0).getText(),"Credits Text Test");
120 Set
<Extension
> exts
= pKey
.getExtensions();
121 Iterator
<Extension
> extItr
= exts
.iterator();
122 Extension ext
= extItr
.next();
123 Assert
.assertEquals(ext
.getValue(), "http://test.com");
125 Set
<Rights
> rights
= pKey
.getRights();
126 Iterator
<Rights
> rightsItr
= rights
.iterator();
127 Rights right
= rightsItr
.next();
128 Assert
.assertEquals(right
.getText(),"Rights Text Test");
130 Set
<IdentifiableSource
> sources
= pKey
.getSources();
131 Iterator
<IdentifiableSource
> sourcesItr
= sources
.iterator();
132 IdentifiableSource source
= sourcesItr
.next();
133 Assert
.assertEquals(source
.getId(), 23710);
134 source
= sourcesItr
.next();
135 Assert
.assertEquals(source
.getId(), 23711);
137 // TO DO : Added tests for Annotations , Markers
143 public void readPolytomousKeyDataFromNodes() {
144 PolytomousKey pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
145 PolytomousKeyNode rootNode
= pKey
.getRoot();
148 Assert
.assertEquals(rootNode
.getId(), 2750);
150 Assert
.assertEquals(rootNode
.getChildAt(0).getId(), 2751);
151 Assert
.assertEquals(rootNode
.getChildAt(0).getParent().getId(), rootNode
.getId());
152 Assert
.assertEquals(rootNode
.getKey().getId(), pKey
.getId());
153 Integer sortIndex
= (Integer
)getFieldValueViaReflection(rootNode
.getChildAt(0), "sortIndex");
154 Assert
.assertEquals(sortIndex
, new Integer(0));
155 String statement
= "Capitula without ligulate ray-florets; leaves entire or subentire";
156 Assert
.assertEquals(rootNode
.getChildAt(0).getStatement().getLabelText(Language
.ENGLISH()), statement
);
158 Assert
.assertEquals(rootNode
.getChildAt(1).getId(), 2753);
159 Assert
.assertEquals(rootNode
.getChildAt(1).getParent().getId(), rootNode
.getId());
160 Assert
.assertEquals(rootNode
.getChildAt(1).getKey().getId(), pKey
.getId());
161 sortIndex
= (Integer
)getFieldValueViaReflection(rootNode
.getChildAt(1), "sortIndex");
162 Assert
.assertEquals(sortIndex
, new Integer(1));
163 statement
= "Capitula with ligulate ray-florets; leaves pinnatisect";
164 Assert
.assertEquals(rootNode
.getChildAt(1).getStatement().getLabelText(Language
.ENGLISH()), statement
);
166 Assert
.assertEquals(rootNode
.getChildAt(1).getChildAt(0).getId(), 2754);
167 Assert
.assertEquals(rootNode
.getChildAt(1).getChildAt(0).getParent().getId(), rootNode
.getChildAt(1).getId());
168 Assert
.assertEquals(rootNode
.getChildAt(1).getChildAt(0).getKey().getId(), pKey
.getId());
169 sortIndex
= (Integer
)getFieldValueViaReflection(rootNode
.getChildAt(1).getChildAt(0), "sortIndex");
170 Assert
.assertEquals(sortIndex
, new Integer(0));
171 statement
= "Ray-florets yellow";
172 Assert
.assertEquals(rootNode
.getChildAt(1).getChildAt(0).getStatement().getLabelText(Language
.ENGLISH()), statement
);
173 Assert
.assertEquals(rootNode
.getChildAt(1).getChildAt(0).getChildAt(0).getTaxon().getTitleCache(), "Achillea arabica Kotschy sec. Cyprus");
178 public void addGrandChildPolytomousKeyNode() {
180 PolytomousKey pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
181 PolytomousKeyNode rootChildNode
= pKey
.getRoot().getChildAt(0);
182 PolytomousKeyNode grandChildNode
= PolytomousKeyNode
.NewInstance();
183 rootChildNode
.addChild(grandChildNode
);
185 MergeResult
<PolytomousKey
> result
= polytomousKeyService
.merge(pKey
, true);
186 pKey
= result
.getMergedEntity();
187 grandChildNode
= pKey
.getRoot().getChildAt(0).getChildAt(0);
188 Assert
.assertTrue(0 != grandChildNode
.getId());
189 KeyStatement ks
= KeyStatement
.NewInstance("test");
190 grandChildNode
.setStatement(ks
);
191 polytomousKeyService
.merge(pKey
, true);
193 //grandChildNode = pKey.getRoot().getChildAt(0).getChildAt(0);
194 //KeyStatement ks = grandChildNode.getStatement();
195 Assert
.assertTrue(0 != ks
.getId());
200 public void addGreatGrandChildPolytomousKeyNode() {
202 PolytomousKey pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
203 PolytomousKeyNode rootChildNode
= pKey
.getRoot().getChildAt(0);
204 PolytomousKeyNode grandChildNode
= PolytomousKeyNode
.NewInstance();
205 rootChildNode
.addChild(grandChildNode
);
208 polytomousKeyNodeService
.merge(grandChildNode
, true);
211 Assert
.assertFalse(pKey
.getRoot().getChildAt(0).getChildAt(0).getId() == 0);
215 public void savePolytomousKeyNodeData() {
216 PolytomousKey pkey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
218 PolytomousKeyNode pkeynode
= pkey
.getRoot();
219 String newQuestion
= "New Question";
220 String newStatement
= "New Statement";
222 Assert
.assertEquals("Question 1",pkeynode
.getQuestion().getLabel().get(Language
.ENGLISH()).getText());
223 for(PolytomousKeyNode node
: pkeynode
.getChildren()) {
225 node
.setQuestion(null);
226 node
.setStatement(null);
228 //FIXME:Remoting Add tests for feature after fixing problem
230 //Feature feature = pkeynode.getFeature();
231 //Assert.assertEquals(feature.getTitleCache(),"Systematics");
232 //pkeynode.setFeature(null);
234 Assert
.assertEquals(pkeynode
.getChildAt(0).getModifyingText().get(Language
.ENGLISH()).getText(),"Modifying Text 1a");
235 String modifyingText
= "Modifying Text 1a updated";
237 //pkeynode.getChildAt(0).putModifyingText(Language.ENGLISH(), modifyingText);
239 Assert
.assertEquals(pkeynode
.getChildAt(0).getSubkey().getId(),751);
240 Assert
.assertEquals("Asphodeline", pkeynode
.getChildAt(0).getSubkey().getTitleCache());
241 Assert
.assertNull(pkeynode
.getChildAt(1).getTaxon());
242 Taxon taxon
= CdmBase
.deproxy(taxonService
.find(taxon1Uuid
),Taxon
.class);
243 pkeynode
.getChildAt(1).setTaxon(taxon
);
245 polytomousKeyService
.merge(pkey
, true);
247 pkey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
250 pkeynode
= pkey
.getRoot();
251 for(PolytomousKeyNode node
: pkeynode
.getChildren()) {
252 Assert
.assertNull(node
.getQuestion());
253 node
.setQuestion(KeyStatement
.NewInstance(Language
.ENGLISH(),newQuestion
));
254 Assert
.assertNull(node
.getStatement());
255 node
.setStatement(KeyStatement
.NewInstance(Language
.ENGLISH(),newStatement
));
258 Assert
.assertEquals(pkeynode
.getChildAt(1).getTaxon(), taxon
);
260 polytomousKeyService
.merge(pkey
, true);
262 pkey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
264 pkeynode
= pkey
.getRoot();
265 for(PolytomousKeyNode node
: pkeynode
.getChildren()) {
266 Assert
.assertNotNull(node
.getQuestion());
267 Map
<Language
, LanguageString
> label
= node
.getQuestion().getLabel();
268 Assert
.assertEquals(newQuestion
, label
.get(Language
.ENGLISH()).getText());
269 Assert
.assertNotNull(node
.getStatement());
270 Assert
.assertEquals(newStatement
, node
.getStatement().getLabel(Language
.ENGLISH()).getText());
272 //Assert.assertEquals(pkeynode.getFeature().getId(), feature.getId());
278 public void savePolytomousKeyNodeDataWithSameSubKey() {
280 PolytomousKey pkey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
283 PolytomousKeyNode pkeynode
= pkey
.getRoot();
285 PolytomousKey subkey1
= CdmBase
.deproxy(pkeynode
.getChildAt(0).getSubkey(), PolytomousKey
.class);
286 String subkey1title
= subkey1
.getTitleCache();
287 subkey1
.setTitleCache(subkey1title
+ "test", true);
290 PolytomousKey subkey2
= CdmBase
.deproxy(pkeynode
.getChildAt(1).getChildAt(0).getSubkey(), PolytomousKey
.class);
291 String subkey2title
= subkey2
.getTitleCache();
292 subkey2
.setTitleCache(subkey2title
+ "test", true);
294 Assert
.assertSame(subkey1
, subkey2
);
296 polytomousKeyService
.merge(pkey
, true);
300 public void savePolytomousKeyNodeDataWithSameSubKeyUsingService() {
302 PolytomousKey pkey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
305 PolytomousKeyNode pkeynode
= pkey
.getRoot();
306 //because of the check for null values in getChildren it isn't a persistent list anymore
307 // PersistentCollection children = (PersistentCollection) pkeynode.getChildren();
308 PolytomousKeyNode childNode0
= (PolytomousKeyNode
)commonService
.get(pkeynode
.getUuid(), "children", 0);
309 PolytomousKey subkey1
= CdmBase
.deproxy(childNode0
.getSubkey(),PolytomousKey
.class);
310 String subkey1title
= subkey1
.getTitleCache();
311 subkey1
.setTitleCache(subkey1title
+ "test", true);
313 PolytomousKeyNode childNode1
= (PolytomousKeyNode
)commonService
.get(pkeynode
.getUuid(), "children", 1);
314 PolytomousKey subkey2
= CdmBase
.deproxy(childNode1
.getSubkey(),PolytomousKey
.class);
315 String subkey2title
= subkey2
.getTitleCache();
316 subkey2
.setTitleCache(subkey2title
+ "test", true);
318 Assert
.assertNotSame(childNode0
, childNode1
);
320 Assert
.assertSame(subkey1
, subkey2
);
322 polytomousKeyService
.merge(pkey
, true);
328 public void savePolytomousKeyNodeDataWithSameLanguageInLabel() {
330 PolytomousKey pkey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
331 PolytomousKeyNode pkeynode
= pkey
.getRoot();
333 Map
<Language
, LanguageString
> label1
= pkeynode
.getQuestion().getLabel();
337 Map
<Language
, LanguageString
> label2
= pkeynode
.getChildAt(0).getStatement().getLabel();
341 polytomousKeyService
.merge(pkey
, true);
345 public void deleteSubKeyInPolytomousSubKeyWithoutInitializing() {
346 PolytomousKey pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
349 PolytomousKeyNode rootNode
= pKey
.getRoot();
351 PolytomousKeyNode childNode
= rootNode
.getChildAt(0);
352 PolytomousKey subKey
= HibernateProxyHelper
.deproxy( childNode
.getSubkey(), PolytomousKey
.class);;
355 DeleteResult result
= polytomousKeyService
.delete(subKey
.getUuid());
356 //A used subKey can't be deleted
362 Set
<Integer
> ids
= new HashSet
<Integer
>();
366 List
<PolytomousKeyNode
> nodes
= polytomousKeyNodeService
.findById(ids
);
367 for (PolytomousKeyNode child
:nodes
){
368 child
.setSubkey(null);
369 // polytomousKeyNodeService.merge(child);
371 polytomousKeyNodeService
.merge(nodes
, true);
372 result
= polytomousKeyService
.delete(subKey
.getUuid());
380 // retrieving subkey shows its null
381 subKey
= CdmBase
.deproxy(polytomousKeyService
.find(subKeyUuid
),PolytomousKey
.class);
382 Assert
.assertNull(subKey
);
384 pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
391 public void deleteSubKeyInPolytomousNode() {
392 PolytomousKey pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
395 PolytomousKeyNode rootNode
= pKey
.getRoot();
396 List
<PolytomousKeyNode
> children
= rootNode
.getChildren();
397 PolytomousKeyNode child
= rootNode
.getChildAt(0);
398 polytomousKeyNodeService
.delete(child
.getUuid(), true);
400 pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
402 rootNode
= pKey
.getRoot();
403 children
= rootNode
.getChildren();
404 Assert
.assertFalse(children
.contains(child
));
408 public void deleteSubKeyInPolytomousSubKeyAfterInitializing() {
409 PolytomousKey pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
412 PolytomousKeyNode rootNode
= pKey
.getRoot();
413 PolytomousKeyNode child
= rootNode
.getChildAt(0);
414 PolytomousKey subKey
= child
.getSubkey();
415 // this call initializes the subkey
418 polytomousKeyService
.delete(subKey
);
420 // since subKey was initialized before the delete, it will be
421 // accesible even after the delete. This behaviour is similar
422 // to hibernate session delete where the deleted object is
423 // made transient, but not deleted from the object graph
425 PolytomousKeyNode subKeyRootNode
= subKey
.getRoot();
426 Assert
.assertNotNull(subKey
);
430 public void saveNewTermVocabulary() {
431 TermVocabulary termVocabulary
=
432 TermVocabulary
.NewInstance(TermType
.Feature
,
438 List
<TermVocabulary
<DefinedTermBase
>> vocabularies
= vocabularyService
.findByTermType(TermType
.Feature
);
440 for(TermVocabulary vocab
: vocabularies
) {
441 vocab
.getTermsOrderedByLabels(Language
.ENGLISH());
444 termVocabulary
= vocabularyService
.merge(termVocabulary
);
445 vocabularies
.add(termVocabulary
);
446 termVocabulary
.setLabel("Test");
447 vocabularyService
.merge(new ArrayList
<TermVocabulary
>(vocabularies
));
449 vocabularyService
.delete(termVocabulary
);
454 public void saveNewTerm() {
455 UUID vocNameFeatureUuid
= UUID
.fromString("fa7ca3eef-4092-49e1-beec-ed5096193e5e");
456 UUID vocFeatureUuid
= UUID
.fromString("b187d555-f06f-4d65-9e53-da7c93f8eaa8");
457 DefinedTermBase newTerm
= TermType
.Feature
.getEmptyDefinedTermBase();
458 newTerm
.setLabel("CreateTest");
461 List
<Feature
> features
= termService
.list(Feature
.class, 100, 0, null, null);
462 List
<UUID
> updateTerms
= new ArrayList
<UUID
>();
463 for (Feature feature
:features
){
464 if (feature
.getLabel().equals("UpdateTest")){
465 updateTerms
.add(feature
.getUuid());
468 termService
.delete(updateTerms
);
470 // if(termService.findByRepresentationText("UpdateTest", Feature.class, null, null) != null) {
471 // Pager<Feature> terms = termService.findByRepresentationText("UpdateTest", Feature.class, null, null);
472 // if (!terms.getRecords().isEmpty()){
473 // termService.delete(terms.getRecords().get(0).getUuid());
477 Assert
.assertNotNull(newTerm
);
478 TermVocabulary vocNameFeature
= vocabularyService
.find(vocNameFeatureUuid
);
479 TermVocabulary vocFeature
= vocabularyService
.find(vocFeatureUuid
);
481 List
<TermVocabulary
> vocs
= new ArrayList
<TermVocabulary
>();
483 vocs
.add(vocNameFeature
);
484 vocs
.add(vocFeature
);
486 vocNameFeature
.addTerm(newTerm
);
488 List
<MergeResult
<TermVocabulary
>> mergeResults
= vocabularyService
.merge(vocs
, true);
490 for(MergeResult
<TermVocabulary
> result
: mergeResults
){
491 TermVocabulary voc
= result
.getMergedEntity();
492 if(voc
.getUuid().equals(vocNameFeatureUuid
)) {
493 vocNameFeature
= voc
;
497 Assert
.assertTrue(vocNameFeature
.getTerms().contains(newTerm
));
499 for(Object obj
: vocNameFeature
.getTerms()) {
500 DefinedTermBase dtb
= (DefinedTermBase
)obj
;
501 if("CreateTest".equals(dtb
.getLabel())) {
503 Assert
.assertNotNull(dtb
.getCreatedBy());
504 Assert
.assertNotNull(dtb
.getCreated());
506 System
.err
.println(dtb
.getLabel() + " " + dtb
.getCreatedBy() + " " + dtb
.getUuid());
507 Assert
.assertNull(dtb
.getCreatedBy());
510 newTerm
.setLabel("UpdateTest");
511 newTerm
= termService
.merge(newTerm
);
512 Assert
.assertNotNull(newTerm
.getUpdatedBy());
513 Assert
.assertNotNull(newTerm
.getUpdated());
515 Assert
.assertNull(vocNameFeature
.getCreatedBy());
516 Assert
.assertNull(vocFeature
.getCreatedBy());
518 if(termService
.find(newTerm
.getUuid()) != null) {
519 termService
.delete(newTerm
.getUuid());
526 public void updatePerson() {
528 Person person
= (Person
) CdmApplicationState
.getCurrentAppConfig().getAgentService().load(personUuid
);
529 person
.setFirstname("Me");
530 CdmApplicationState
.getCurrentAppConfig().getAgentService().merge(person
, true);
535 public void createPerson() {
537 Person person
= Person
.NewInstance();
538 person
= (Person
) CdmApplicationState
.getCurrentAppConfig().getAgentService().merge(person
);
539 person
= (Person
) CdmApplicationState
.getCurrentAppConfig().getAgentService().load(person
.getUuid());
540 person
.setFirstname("Some");
541 CdmApplicationState
.getCurrentAppConfig().getAgentService().merge(person
, true);
545 public void testThreadLocalActiveSession() throws InterruptedException
{
546 MockSessionOwner
<CdmBase
> so1
= new MockSessionOwner
<CdmBase
>();
547 final ICdmEntitySession activeSession
= getCdmEntitySessionManager().newSession(so1
, true);
548 TestThread thread
= new TestThread(true) {
550 public void doRun() throws InterruptedException
{
551 ICdmEntitySession threadLocalActiveSession
= getCdmEntitySessionManager().getActiveSession();
552 Assert
.assertEquals(threadLocalActiveSession
, activeSession
);
555 invokeThread(thread
);
556 MockSessionOwner
<CdmBase
> so2
= new MockSessionOwner
<CdmBase
>();
557 ICdmEntitySession newActiveSession
= getCdmEntitySessionManager().newSession(so2
, true);
558 Assert
.assertFalse(activeSession
.equals(newActiveSession
));