3 * Copyright (C) 2014 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
.taxeditor
.session
;
12 import java
.util
.ArrayList
;
13 import java
.util
.HashSet
;
14 import java
.util
.Iterator
;
15 import java
.util
.List
;
18 import java
.util
.UUID
;
20 import org
.apache
.log4j
.Logger
;
21 import org
.junit
.Assert
;
22 import org
.junit
.BeforeClass
;
23 import org
.junit
.Ignore
;
24 import org
.junit
.Test
;
25 import org
.unitils
.dbunit
.annotation
.DataSet
;
27 import eu
.etaxonomy
.cdm
.api
.application
.CdmApplicationState
;
28 import eu
.etaxonomy
.cdm
.api
.service
.DeleteResult
;
29 import eu
.etaxonomy
.cdm
.api
.service
.ICommonService
;
30 import eu
.etaxonomy
.cdm
.api
.service
.IPolytomousKeyNodeService
;
31 import eu
.etaxonomy
.cdm
.api
.service
.IPolytomousKeyService
;
32 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonService
;
33 import eu
.etaxonomy
.cdm
.api
.service
.ITermService
;
34 import eu
.etaxonomy
.cdm
.api
.service
.IUserService
;
35 import eu
.etaxonomy
.cdm
.api
.service
.IVocabularyService
;
36 import eu
.etaxonomy
.cdm
.api
.service
.pager
.Pager
;
37 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
38 import eu
.etaxonomy
.cdm
.model
.agent
.AgentBase
;
39 import eu
.etaxonomy
.cdm
.model
.agent
.Person
;
40 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
41 import eu
.etaxonomy
.cdm
.model
.common
.Credit
;
42 import eu
.etaxonomy
.cdm
.model
.common
.DefinedTermBase
;
43 import eu
.etaxonomy
.cdm
.model
.common
.Extension
;
44 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableSource
;
45 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
46 import eu
.etaxonomy
.cdm
.model
.common
.LanguageString
;
47 import eu
.etaxonomy
.cdm
.model
.common
.TermType
;
48 import eu
.etaxonomy
.cdm
.model
.common
.TermVocabulary
;
49 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
50 import eu
.etaxonomy
.cdm
.model
.description
.KeyStatement
;
51 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKey
;
52 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKeyNode
;
53 import eu
.etaxonomy
.cdm
.model
.media
.Rights
;
54 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
55 import eu
.etaxonomy
.cdm
.persistence
.dto
.MergeResult
;
56 import eu
.etaxonomy
.taxeditor
.httpinvoker
.RemotingSessionAwareTest
;
57 import eu
.etaxonomy
.taxeditor
.httpinvoker
.TestThread
;
66 public class CdmEntitySessionAwareTest
extends RemotingSessionAwareTest
{
68 private static final Logger logger
= Logger
.getLogger(CdmEntitySessionAwareTest
.class);
70 UUID polytomousKeyUuid
= UUID
.fromString("0d53ba20-7de4-4baa-bd8a-401048447d66");
71 UUID subKeyUuid
= UUID
.fromString("9d8bf4f6-a70a-4b80-8556-2ccfb436ff01");
72 //UUID polytomousKeyUuid = UUID.fromString("bab66772-2c83-428a-bb6d-655d12ac6097");
73 UUID taxon1Uuid
= UUID
.fromString("2b336df7-29e8-4f79-985f-66502739d22f");
74 UUID personUuid
= UUID
.fromString("945d08f2-eb92-45b6-9252-6275ea6d338b");
78 IPolytomousKeyService polytomousKeyService
= getRemoteApplicationController().getPolytomousKeyService();
79 IPolytomousKeyNodeService polytomousKeyNodeService
= getRemoteApplicationController().getPolytomousKeyNodeService();
80 ICommonService commonService
= getRemoteApplicationController().getCommonService();
81 ITaxonService taxonService
= getRemoteApplicationController().getTaxonService();
82 IVocabularyService vocabularyService
= getRemoteApplicationController().getVocabularyService();
83 ITermService termService
= getRemoteApplicationController().getTermService();
84 IUserService userService
= getRemoteApplicationController().getUserService();
86 //Language english = Language.getLanguageFromUuid(Language.uuidEnglish);
91 public static void initializePolytomousKeyTest() {
97 public void readAllPolytomousKeys() {
98 List
<PolytomousKey
> pKeys
= polytomousKeyService
.list(PolytomousKey
.class, null, null, null, null);
99 Iterator
<PolytomousKey
> pKeysItr
= pKeys
.iterator();
100 Assert
.assertEquals(pKeysItr
.next().getUuid(),UUID
.fromString("9d8bf4f6-a70a-4b80-8556-2ccfb436ff01"));
101 Assert
.assertEquals(pKeysItr
.next().getUuid(),UUID
.fromString("0d53ba20-7de4-4baa-bd8a-401048447d66"));
106 //@DataSet("PolytomousKeyTest.readPolytmousKeyData.xml")
107 public void readPolytmousKeyData() {
108 PolytomousKey pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
109 Set
<Taxon
> taxonomicScope
= pKey
.getTaxonomicScope();
110 Iterator
<Taxon
> tsItr
= taxonomicScope
.iterator();
111 Taxon taxon
= tsItr
.next();
113 Assert
.assertEquals("Achillea sec. Cyprus", taxon
.getTitleCache());
114 Assert
.assertEquals(tsItr
.hasNext(), false);
116 List
<Credit
> credits
= pKey
.getCredits();
117 AgentBase agent
= credits
.get(0).getAgent();
118 Assert
.assertEquals(agent
.getId(),4809);
119 Assert
.assertEquals(agent
.getTitleCache(),"R. A. Graham");
120 Assert
.assertEquals(credits
.get(0).getText(),"Credits Text Test");
122 Set
<Extension
> exts
= pKey
.getExtensions();
123 Iterator
<Extension
> extItr
= exts
.iterator();
124 Extension ext
= extItr
.next();
125 Assert
.assertEquals(ext
.getValue(), "http://test.com");
127 Set
<Rights
> rights
= pKey
.getRights();
128 Iterator
<Rights
> rightsItr
= rights
.iterator();
129 Rights right
= rightsItr
.next();
130 Assert
.assertEquals(right
.getText(),"Rights Text Test");
132 Set
<IdentifiableSource
> sources
= pKey
.getSources();
133 Iterator
<IdentifiableSource
> sourcesItr
= sources
.iterator();
134 IdentifiableSource source
= sourcesItr
.next();
135 Assert
.assertEquals(source
.getId(), 23710);
136 source
= sourcesItr
.next();
137 Assert
.assertEquals(source
.getId(), 23711);
139 // TO DO : Added tests for Annotations , Markers
145 public void readPolytomousKeyDataFromNodes() {
146 PolytomousKey pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
147 PolytomousKeyNode rootNode
= pKey
.getRoot();
150 Assert
.assertEquals(rootNode
.getId(), 2750);
152 Assert
.assertEquals(rootNode
.getChildAt(0).getId(), 2751);
153 Assert
.assertEquals(rootNode
.getChildAt(0).getParent().getId(), rootNode
.getId());
154 Assert
.assertEquals(rootNode
.getKey().getId(), pKey
.getId());
155 Integer sortIndex
= (Integer
)getFieldValueViaReflection(rootNode
.getChildAt(0), "sortIndex");
156 Assert
.assertEquals(sortIndex
, new Integer(0));
157 String statement
= "Capitula without ligulate ray-florets; leaves entire or subentire";
158 Assert
.assertEquals(rootNode
.getChildAt(0).getStatement().getLabelText(Language
.ENGLISH()), statement
);
160 Assert
.assertEquals(rootNode
.getChildAt(1).getId(), 2753);
161 Assert
.assertEquals(rootNode
.getChildAt(1).getParent().getId(), rootNode
.getId());
162 Assert
.assertEquals(rootNode
.getChildAt(1).getKey().getId(), pKey
.getId());
163 sortIndex
= (Integer
)getFieldValueViaReflection(rootNode
.getChildAt(1), "sortIndex");
164 Assert
.assertEquals(sortIndex
, new Integer(1));
165 statement
= "Capitula with ligulate ray-florets; leaves pinnatisect";
166 Assert
.assertEquals(rootNode
.getChildAt(1).getStatement().getLabelText(Language
.ENGLISH()), statement
);
168 Assert
.assertEquals(rootNode
.getChildAt(1).getChildAt(0).getId(), 2754);
169 Assert
.assertEquals(rootNode
.getChildAt(1).getChildAt(0).getParent().getId(), rootNode
.getChildAt(1).getId());
170 Assert
.assertEquals(rootNode
.getChildAt(1).getChildAt(0).getKey().getId(), pKey
.getId());
171 sortIndex
= (Integer
)getFieldValueViaReflection(rootNode
.getChildAt(1).getChildAt(0), "sortIndex");
172 Assert
.assertEquals(sortIndex
, new Integer(0));
173 statement
= "Ray-florets yellow";
174 Assert
.assertEquals(rootNode
.getChildAt(1).getChildAt(0).getStatement().getLabelText(Language
.ENGLISH()), statement
);
175 Assert
.assertEquals(rootNode
.getChildAt(1).getChildAt(0).getChildAt(0).getTaxon().getTitleCache(), "Achillea arabica Kotschy sec. Cyprus");
180 public void addGrandChildPolytomousKeyNode() {
182 PolytomousKey pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
183 PolytomousKeyNode rootChildNode
= pKey
.getRoot().getChildAt(0);
184 PolytomousKeyNode grandChildNode
= PolytomousKeyNode
.NewInstance();
185 rootChildNode
.addChild(grandChildNode
);
187 MergeResult
<PolytomousKey
> result
= polytomousKeyService
.merge(pKey
, true);
188 pKey
= result
.getMergedEntity();
189 grandChildNode
= pKey
.getRoot().getChildAt(0).getChildAt(0);
190 Assert
.assertTrue(0 != grandChildNode
.getId());
191 KeyStatement ks
= KeyStatement
.NewInstance("test");
192 grandChildNode
.setStatement(ks
);
193 polytomousKeyService
.merge(pKey
, true);
195 //grandChildNode = pKey.getRoot().getChildAt(0).getChildAt(0);
196 //KeyStatement ks = grandChildNode.getStatement();
197 Assert
.assertTrue(0 != ks
.getId());
202 public void addGreatGrandChildPolytomousKeyNode() {
204 PolytomousKey pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
205 PolytomousKeyNode rootChildNode
= pKey
.getRoot().getChildAt(0);
206 PolytomousKeyNode grandChildNode
= PolytomousKeyNode
.NewInstance();
207 rootChildNode
.addChild(grandChildNode
);
210 polytomousKeyNodeService
.merge(grandChildNode
, true);
213 Assert
.assertFalse(pKey
.getRoot().getChildAt(0).getChildAt(0).getId() == 0);
217 public void savePolytomousKeyNodeData() {
218 PolytomousKey pkey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
220 PolytomousKeyNode pkeynode
= pkey
.getRoot();
221 String newQuestion
= "New Question";
222 String newStatement
= "New Statement";
224 Assert
.assertEquals("Question 1",pkeynode
.getQuestion().getLabel().get(Language
.ENGLISH()).getText());
225 for(PolytomousKeyNode node
: pkeynode
.getChildren()) {
227 node
.setQuestion(null);
228 node
.setStatement(null);
230 //FIXME:Remoting Add tests for feature after fixing problem
232 //Feature feature = pkeynode.getFeature();
233 //Assert.assertEquals(feature.getTitleCache(),"Systematics");
234 //pkeynode.setFeature(null);
236 Assert
.assertEquals(pkeynode
.getChildAt(0).getModifyingText().get(Language
.ENGLISH()).getText(),"Modifying Text 1a");
237 String modifyingText
= "Modifying Text 1a updated";
239 //pkeynode.getChildAt(0).putModifyingText(Language.ENGLISH(), modifyingText);
241 Assert
.assertEquals(pkeynode
.getChildAt(0).getSubkey().getId(),751);
242 Assert
.assertEquals("Asphodeline", pkeynode
.getChildAt(0).getSubkey().getTitleCache());
243 Assert
.assertNull(pkeynode
.getChildAt(1).getTaxon());
244 Taxon taxon
= CdmBase
.deproxy(taxonService
.find(taxon1Uuid
),Taxon
.class);
245 pkeynode
.getChildAt(1).setTaxon(taxon
);
247 polytomousKeyService
.merge(pkey
, true);
249 pkey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
252 pkeynode
= pkey
.getRoot();
253 for(PolytomousKeyNode node
: pkeynode
.getChildren()) {
254 Assert
.assertNull(node
.getQuestion());
255 node
.setQuestion(KeyStatement
.NewInstance(Language
.ENGLISH(),newQuestion
));
256 Assert
.assertNull(node
.getStatement());
257 node
.setStatement(KeyStatement
.NewInstance(Language
.ENGLISH(),newStatement
));
260 Assert
.assertEquals(pkeynode
.getChildAt(1).getTaxon(), taxon
);
262 polytomousKeyService
.merge(pkey
, true);
264 pkey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
266 pkeynode
= pkey
.getRoot();
267 for(PolytomousKeyNode node
: pkeynode
.getChildren()) {
268 Assert
.assertNotNull(node
.getQuestion());
269 Map
<Language
, LanguageString
> label
= node
.getQuestion().getLabel();
270 Assert
.assertEquals(newQuestion
, label
.get(Language
.ENGLISH()).getText());
271 Assert
.assertNotNull(node
.getStatement());
272 Assert
.assertEquals(newStatement
, node
.getStatement().getLabel(Language
.ENGLISH()).getText());
274 //Assert.assertEquals(pkeynode.getFeature().getId(), feature.getId());
280 public void savePolytomousKeyNodeDataWithSameSubKey() {
282 PolytomousKey pkey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
285 PolytomousKeyNode pkeynode
= pkey
.getRoot();
287 PolytomousKey subkey1
= CdmBase
.deproxy(pkeynode
.getChildAt(0).getSubkey(), PolytomousKey
.class);
288 String subkey1title
= subkey1
.getTitleCache();
289 subkey1
.setTitleCache(subkey1title
+ "test", true);
292 PolytomousKey subkey2
= CdmBase
.deproxy(pkeynode
.getChildAt(1).getChildAt(0).getSubkey(), PolytomousKey
.class);
293 String subkey2title
= subkey2
.getTitleCache();
294 subkey2
.setTitleCache(subkey2title
+ "test", true);
296 Assert
.assertSame(subkey1
, subkey2
);
298 polytomousKeyService
.merge(pkey
, true);
302 public void savePolytomousKeyNodeDataWithSameSubKeyUsingService() {
304 PolytomousKey pkey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
307 PolytomousKeyNode pkeynode
= pkey
.getRoot();
308 //because of the check for null values in getChildren it isn't a persistent list anymore
309 // PersistentCollection children = (PersistentCollection) pkeynode.getChildren();
310 PolytomousKeyNode childNode0
= (PolytomousKeyNode
)commonService
.get(pkeynode
.getUuid(), "children", 0);
311 PolytomousKey subkey1
= CdmBase
.deproxy(childNode0
.getSubkey(),PolytomousKey
.class);
312 String subkey1title
= subkey1
.getTitleCache();
313 subkey1
.setTitleCache(subkey1title
+ "test", true);
315 PolytomousKeyNode childNode1
= (PolytomousKeyNode
)commonService
.get(pkeynode
.getUuid(), "children", 1);
316 PolytomousKey subkey2
= CdmBase
.deproxy(childNode1
.getSubkey(),PolytomousKey
.class);
317 String subkey2title
= subkey2
.getTitleCache();
318 subkey2
.setTitleCache(subkey2title
+ "test", true);
320 Assert
.assertNotSame(childNode0
, childNode1
);
322 Assert
.assertSame(subkey1
, subkey2
);
324 polytomousKeyService
.merge(pkey
, true);
330 public void savePolytomousKeyNodeDataWithSameLanguageInLabel() {
332 PolytomousKey pkey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
333 PolytomousKeyNode pkeynode
= pkey
.getRoot();
335 Map
<Language
, LanguageString
> label1
= pkeynode
.getQuestion().getLabel();
339 Map
<Language
, LanguageString
> label2
= pkeynode
.getChildAt(0).getStatement().getLabel();
343 polytomousKeyService
.merge(pkey
, true);
347 public void deleteSubKeyInPolytomousSubKeyWithoutInitializing() {
348 PolytomousKey pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
351 PolytomousKeyNode rootNode
= pKey
.getRoot();
353 PolytomousKeyNode childNode
= rootNode
.getChildAt(0);
354 PolytomousKey subKey
= HibernateProxyHelper
.deproxy( childNode
.getSubkey(), PolytomousKey
.class);;
357 DeleteResult result
= polytomousKeyService
.delete(subKey
.getUuid());
358 //A used subKey can't be deleted
364 Set
<Integer
> ids
= new HashSet
<Integer
>();
368 List
<PolytomousKeyNode
> nodes
= polytomousKeyNodeService
.findById(ids
);
369 for (PolytomousKeyNode child
:nodes
){
370 child
.setSubkey(null);
371 // polytomousKeyNodeService.merge(child);
373 polytomousKeyNodeService
.merge(nodes
, true);
374 result
= polytomousKeyService
.delete(subKey
.getUuid());
382 // retrieving subkey shows its null
383 subKey
= CdmBase
.deproxy(polytomousKeyService
.find(subKeyUuid
),PolytomousKey
.class);
384 Assert
.assertNull(subKey
);
386 pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
393 public void deleteSubKeyInPolytomousNode() {
394 PolytomousKey pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
397 PolytomousKeyNode rootNode
= pKey
.getRoot();
398 List
<PolytomousKeyNode
> children
= rootNode
.getChildren();
399 PolytomousKeyNode child
= rootNode
.getChildAt(0);
400 polytomousKeyNodeService
.delete(child
.getUuid(), true);
402 pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
404 rootNode
= pKey
.getRoot();
405 children
= rootNode
.getChildren();
406 Assert
.assertFalse(children
.contains(child
));
410 public void deleteSubKeyInPolytomousSubKeyAfterInitializing() {
411 PolytomousKey pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
414 PolytomousKeyNode rootNode
= pKey
.getRoot();
415 PolytomousKeyNode child
= rootNode
.getChildAt(0);
416 PolytomousKey subKey
= child
.getSubkey();
417 // this call initializes the subkey
420 polytomousKeyService
.delete(subKey
);
422 // since subKey was initialized before the delete, it will be
423 // accesible even after the delete. This behaviour is similar
424 // to hibernate session delete where the deleted object is
425 // made transient, but not deleted from the object graph
427 PolytomousKeyNode subKeyRootNode
= subKey
.getRoot();
428 Assert
.assertNotNull(subKey
);
432 public void saveNewTermVocabulary() {
433 TermVocabulary termVocabulary
=
434 TermVocabulary
.NewInstance(TermType
.Feature
,
440 List
<TermVocabulary
<DefinedTermBase
>> vocabularies
= vocabularyService
.findByTermType(TermType
.Feature
);
442 for(TermVocabulary vocab
: vocabularies
) {
443 vocab
.getTermsOrderedByLabels(Language
.ENGLISH());
446 termVocabulary
= vocabularyService
.merge(termVocabulary
);
447 vocabularies
.add(termVocabulary
);
448 termVocabulary
.setLabel("Test");
449 vocabularyService
.merge(new ArrayList
<TermVocabulary
>(vocabularies
));
451 vocabularyService
.delete(termVocabulary
);
456 public void saveNewTerm() {
457 UUID vocNameFeatureUuid
= UUID
.fromString("fa7ca3eef-4092-49e1-beec-ed5096193e5e");
458 UUID vocFeatureUuid
= UUID
.fromString("b187d555-f06f-4d65-9e53-da7c93f8eaa8");
459 DefinedTermBase newTerm
= TermType
.Feature
.getEmptyDefinedTermBase();
460 newTerm
.setLabel("CreateTest");
463 List
<Feature
> features
= termService
.list(Feature
.class, 100, 0, null, null);
464 List
<UUID
> updateTerms
= new ArrayList
<UUID
>();
465 for (Feature feature
:features
){
466 if (feature
.getLabel().equals("UpdateTest")){
467 updateTerms
.add(feature
.getUuid());
470 termService
.delete(updateTerms
);
472 // if(termService.findByRepresentationText("UpdateTest", Feature.class, null, null) != null) {
473 // Pager<Feature> terms = termService.findByRepresentationText("UpdateTest", Feature.class, null, null);
474 // if (!terms.getRecords().isEmpty()){
475 // termService.delete(terms.getRecords().get(0).getUuid());
479 Assert
.assertNotNull(newTerm
);
480 TermVocabulary vocNameFeature
= vocabularyService
.find(vocNameFeatureUuid
);
481 TermVocabulary vocFeature
= vocabularyService
.find(vocFeatureUuid
);
483 List
<TermVocabulary
> vocs
= new ArrayList
<TermVocabulary
>();
485 vocs
.add(vocNameFeature
);
486 vocs
.add(vocFeature
);
488 vocNameFeature
.addTerm(newTerm
);
490 List
<MergeResult
<TermVocabulary
>> mergeResults
= vocabularyService
.merge(vocs
, true);
492 for(MergeResult
<TermVocabulary
> result
: mergeResults
){
493 TermVocabulary voc
= result
.getMergedEntity();
494 if(voc
.getUuid().equals(vocNameFeatureUuid
)) {
495 vocNameFeature
= voc
;
499 Assert
.assertTrue(vocNameFeature
.getTerms().contains(newTerm
));
501 for(Object obj
: vocNameFeature
.getTerms()) {
502 DefinedTermBase dtb
= (DefinedTermBase
)obj
;
503 if("CreateTest".equals(dtb
.getLabel())) {
505 Assert
.assertNotNull(dtb
.getCreatedBy());
506 Assert
.assertNotNull(dtb
.getCreated());
508 System
.err
.println(dtb
.getLabel() + " " + dtb
.getCreatedBy() + " " + dtb
.getUuid());
509 Assert
.assertNull(dtb
.getCreatedBy());
512 newTerm
.setLabel("UpdateTest");
513 newTerm
= termService
.merge(newTerm
);
514 Assert
.assertNotNull(newTerm
.getUpdatedBy());
515 Assert
.assertNotNull(newTerm
.getUpdated());
517 Assert
.assertNull(vocNameFeature
.getCreatedBy());
518 Assert
.assertNull(vocFeature
.getCreatedBy());
520 if(termService
.find(newTerm
.getUuid()) != null) {
521 termService
.delete(newTerm
.getUuid());
528 public void updatePerson() {
530 Person person
= (Person
) CdmApplicationState
.getCurrentAppConfig().getAgentService().load(personUuid
);
531 person
.setFirstname("Me");
532 CdmApplicationState
.getCurrentAppConfig().getAgentService().merge(person
, true);
537 public void createPerson() {
539 Person person
= Person
.NewInstance();
540 person
= (Person
) CdmApplicationState
.getCurrentAppConfig().getAgentService().merge(person
);
541 person
= (Person
) CdmApplicationState
.getCurrentAppConfig().getAgentService().load(person
.getUuid());
542 person
.setFirstname("Some");
543 CdmApplicationState
.getCurrentAppConfig().getAgentService().merge(person
, true);
547 public void testThreadLocalActiveSession() throws InterruptedException
{
548 MockSessionOwner
<CdmBase
> so1
= new MockSessionOwner
<CdmBase
>();
549 final ICdmEntitySession activeSession
= getCdmEntitySessionManager().newSession(so1
, true);
550 TestThread thread
= new TestThread(true) {
552 public void doRun() throws InterruptedException
{
553 ICdmEntitySession threadLocalActiveSession
= getCdmEntitySessionManager().getActiveSession();
554 Assert
.assertEquals(threadLocalActiveSession
, activeSession
);
557 invokeThread(thread
);
558 MockSessionOwner
<CdmBase
> so2
= new MockSessionOwner
<CdmBase
>();
559 ICdmEntitySession newActiveSession
= getCdmEntitySessionManager().newSession(so2
, true);
560 Assert
.assertFalse(activeSession
.equals(newActiveSession
));