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
.Extension
;
41 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableSource
;
42 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
43 import eu
.etaxonomy
.cdm
.model
.common
.LanguageString
;
44 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
45 import eu
.etaxonomy
.cdm
.model
.description
.KeyStatement
;
46 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKey
;
47 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKeyNode
;
48 import eu
.etaxonomy
.cdm
.model
.media
.Rights
;
49 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
50 import eu
.etaxonomy
.cdm
.model
.term
.DefinedTermBase
;
51 import eu
.etaxonomy
.cdm
.model
.term
.TermType
;
52 import eu
.etaxonomy
.cdm
.model
.term
.TermVocabulary
;
53 import eu
.etaxonomy
.cdm
.persistence
.dto
.MergeResult
;
54 import eu
.etaxonomy
.taxeditor
.httpinvoker
.RemotingSessionAwareTest
;
55 import eu
.etaxonomy
.taxeditor
.httpinvoker
.TestThread
;
62 public class CdmEntitySessionAwareTest
extends RemotingSessionAwareTest
{
64 @SuppressWarnings("unused")
65 private static final Logger logger
= Logger
.getLogger(CdmEntitySessionAwareTest
.class);
67 UUID polytomousKeyUuid
= UUID
.fromString("0d53ba20-7de4-4baa-bd8a-401048447d66");
68 UUID subKeyUuid
= UUID
.fromString("9d8bf4f6-a70a-4b80-8556-2ccfb436ff01");
69 //UUID polytomousKeyUuid = UUID.fromString("bab66772-2c83-428a-bb6d-655d12ac6097");
70 UUID taxon1Uuid
= UUID
.fromString("2b336df7-29e8-4f79-985f-66502739d22f");
71 UUID personUuid
= UUID
.fromString("945d08f2-eb92-45b6-9252-6275ea6d338b");
73 IPolytomousKeyService polytomousKeyService
= getRemoteApplicationController().getPolytomousKeyService();
74 IPolytomousKeyNodeService polytomousKeyNodeService
= getRemoteApplicationController().getPolytomousKeyNodeService();
75 ICommonService commonService
= getRemoteApplicationController().getCommonService();
76 ITaxonService taxonService
= getRemoteApplicationController().getTaxonService();
77 IVocabularyService vocabularyService
= getRemoteApplicationController().getVocabularyService();
78 ITermService termService
= getRemoteApplicationController().getTermService();
79 IUserService userService
= getRemoteApplicationController().getUserService();
81 //Language english = Language.getLanguageFromUuid(Language.uuidEnglish);
84 public static void initializePolytomousKeyTest() {
89 public void readAllPolytomousKeys() {
90 List
<PolytomousKey
> pKeys
= polytomousKeyService
.list(PolytomousKey
.class, null, null, null, null);
91 Iterator
<PolytomousKey
> pKeysItr
= pKeys
.iterator();
92 Assert
.assertEquals(pKeysItr
.next().getUuid(),UUID
.fromString("9d8bf4f6-a70a-4b80-8556-2ccfb436ff01"));
93 Assert
.assertEquals(pKeysItr
.next().getUuid(),UUID
.fromString("0d53ba20-7de4-4baa-bd8a-401048447d66"));
97 //@DataSet("PolytomousKeyTest.readPolytmousKeyData.xml")
98 public void readPolytmousKeyData() {
99 PolytomousKey pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
100 Set
<Taxon
> taxonomicScope
= pKey
.getTaxonomicScope();
101 Iterator
<Taxon
> tsItr
= taxonomicScope
.iterator();
102 Taxon taxon
= tsItr
.next();
104 Assert
.assertEquals("Achillea sec. Cyprus", taxon
.getTitleCache());
105 Assert
.assertEquals(tsItr
.hasNext(), false);
107 List
<Credit
> credits
= pKey
.getCredits();
108 AgentBase agent
= credits
.get(0).getAgent();
109 Assert
.assertEquals(agent
.getId(),4809);
110 Assert
.assertEquals(agent
.getTitleCache(),"R. A. Graham");
111 Assert
.assertEquals(credits
.get(0).getText(),"Credits Text Test");
113 Set
<Extension
> exts
= pKey
.getExtensions();
114 Iterator
<Extension
> extItr
= exts
.iterator();
115 Extension ext
= extItr
.next();
116 Assert
.assertEquals(ext
.getValue(), "http://test.com");
118 Set
<Rights
> rights
= pKey
.getRights();
119 Iterator
<Rights
> rightsItr
= rights
.iterator();
120 Rights right
= rightsItr
.next();
121 Assert
.assertEquals(right
.getText(),"Rights Text Test");
123 Set
<IdentifiableSource
> sources
= pKey
.getSources();
124 Iterator
<IdentifiableSource
> sourcesItr
= sources
.iterator();
125 IdentifiableSource source
= sourcesItr
.next();
126 Assert
.assertEquals(source
.getId(), 23710);
127 source
= sourcesItr
.next();
128 Assert
.assertEquals(source
.getId(), 23711);
130 // TO DO : Added tests for Annotations , Markers
134 public void readPolytomousKeyDataFromNodes() {
135 PolytomousKey pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
136 PolytomousKeyNode rootNode
= pKey
.getRoot();
138 Assert
.assertEquals(rootNode
.getId(), 2750);
140 Assert
.assertEquals(rootNode
.getChildAt(0).getId(), 2751);
141 Assert
.assertEquals(rootNode
.getChildAt(0).getParent().getId(), rootNode
.getId());
142 Assert
.assertEquals(rootNode
.getKey().getId(), pKey
.getId());
143 Integer sortIndex
= (Integer
)getFieldValueViaReflection(rootNode
.getChildAt(0), "sortIndex");
144 Assert
.assertEquals(sortIndex
, new Integer(0));
145 String statement
= "Capitula without ligulate ray-florets; leaves entire or subentire";
146 Assert
.assertEquals(rootNode
.getChildAt(0).getStatement().getLabelText(Language
.ENGLISH()), statement
);
148 Assert
.assertEquals(rootNode
.getChildAt(1).getId(), 2753);
149 Assert
.assertEquals(rootNode
.getChildAt(1).getParent().getId(), rootNode
.getId());
150 Assert
.assertEquals(rootNode
.getChildAt(1).getKey().getId(), pKey
.getId());
151 sortIndex
= (Integer
)getFieldValueViaReflection(rootNode
.getChildAt(1), "sortIndex");
152 Assert
.assertEquals(sortIndex
, new Integer(1));
153 statement
= "Capitula with ligulate ray-florets; leaves pinnatisect";
154 Assert
.assertEquals(rootNode
.getChildAt(1).getStatement().getLabelText(Language
.ENGLISH()), statement
);
156 Assert
.assertEquals(rootNode
.getChildAt(1).getChildAt(0).getId(), 2754);
157 Assert
.assertEquals(rootNode
.getChildAt(1).getChildAt(0).getParent().getId(), rootNode
.getChildAt(1).getId());
158 Assert
.assertEquals(rootNode
.getChildAt(1).getChildAt(0).getKey().getId(), pKey
.getId());
159 sortIndex
= (Integer
)getFieldValueViaReflection(rootNode
.getChildAt(1).getChildAt(0), "sortIndex");
160 Assert
.assertEquals(sortIndex
, new Integer(0));
161 statement
= "Ray-florets yellow";
162 Assert
.assertEquals(rootNode
.getChildAt(1).getChildAt(0).getStatement().getLabelText(Language
.ENGLISH()), statement
);
163 Assert
.assertEquals(rootNode
.getChildAt(1).getChildAt(0).getChildAt(0).getTaxon().getTitleCache(), "Achillea arabica Kotschy sec. Cyprus");
168 public void addGrandChildPolytomousKeyNode() {
170 PolytomousKey pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
171 PolytomousKeyNode rootChildNode
= pKey
.getRoot().getChildAt(0);
172 PolytomousKeyNode grandChildNode
= PolytomousKeyNode
.NewInstance();
173 rootChildNode
.addChild(grandChildNode
);
175 MergeResult
<PolytomousKey
> result
= polytomousKeyService
.merge(pKey
, true);
176 pKey
= result
.getMergedEntity();
177 grandChildNode
= pKey
.getRoot().getChildAt(0).getChildAt(0);
178 Assert
.assertTrue(0 != grandChildNode
.getId());
179 KeyStatement ks
= KeyStatement
.NewInstance("test");
180 grandChildNode
.setStatement(ks
);
181 polytomousKeyService
.merge(pKey
, true);
183 //grandChildNode = pKey.getRoot().getChildAt(0).getChildAt(0);
184 //KeyStatement ks = grandChildNode.getStatement();
185 Assert
.assertTrue(0 != ks
.getId());
190 public void addGreatGrandChildPolytomousKeyNode() {
192 PolytomousKey pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
193 PolytomousKeyNode rootChildNode
= pKey
.getRoot().getChildAt(0);
194 PolytomousKeyNode grandChildNode
= PolytomousKeyNode
.NewInstance();
195 rootChildNode
.addChild(grandChildNode
);
197 polytomousKeyNodeService
.merge(grandChildNode
, true);
199 Assert
.assertFalse(pKey
.getRoot().getChildAt(0).getChildAt(0).getId() == 0);
203 public void savePolytomousKeyNodeData() {
204 PolytomousKey pkey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
206 PolytomousKeyNode pkeynode
= pkey
.getRoot();
207 String newQuestion
= "New Question";
208 String newStatement
= "New Statement";
210 Assert
.assertEquals("Question 1",pkeynode
.getQuestion().getLabel().get(Language
.ENGLISH()).getText());
211 for(PolytomousKeyNode node
: pkeynode
.getChildren()) {
213 node
.setQuestion(null);
214 node
.setStatement(null);
216 //FIXME:Remoting Add tests for feature after fixing problem
218 //Feature feature = pkeynode.getFeature();
219 //Assert.assertEquals(feature.getTitleCache(),"Systematics");
220 //pkeynode.setFeature(null);
222 Assert
.assertEquals(pkeynode
.getChildAt(0).getModifyingText().get(Language
.ENGLISH()).getText(),"Modifying Text 1a");
223 String modifyingText
= "Modifying Text 1a updated";
225 //pkeynode.getChildAt(0).putModifyingText(Language.ENGLISH(), modifyingText);
227 Assert
.assertEquals(pkeynode
.getChildAt(0).getSubkey().getId(),751);
228 Assert
.assertEquals("Asphodeline", pkeynode
.getChildAt(0).getSubkey().getTitleCache());
229 Assert
.assertNull(pkeynode
.getChildAt(1).getTaxon());
230 Taxon taxon
= CdmBase
.deproxy(taxonService
.find(taxon1Uuid
),Taxon
.class);
231 pkeynode
.getChildAt(1).setTaxon(taxon
);
233 polytomousKeyService
.merge(pkey
, true);
235 pkey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
237 pkeynode
= pkey
.getRoot();
238 for(PolytomousKeyNode node
: pkeynode
.getChildren()) {
239 Assert
.assertNull(node
.getQuestion());
240 node
.setQuestion(KeyStatement
.NewInstance(Language
.ENGLISH(),newQuestion
));
241 Assert
.assertNull(node
.getStatement());
242 node
.setStatement(KeyStatement
.NewInstance(Language
.ENGLISH(),newStatement
));
245 Assert
.assertEquals(pkeynode
.getChildAt(1).getTaxon(), taxon
);
247 polytomousKeyService
.merge(pkey
, true);
249 pkey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
251 pkeynode
= pkey
.getRoot();
252 for(PolytomousKeyNode node
: pkeynode
.getChildren()) {
253 Assert
.assertNotNull(node
.getQuestion());
254 Map
<Language
, LanguageString
> label
= node
.getQuestion().getLabel();
255 Assert
.assertEquals(newQuestion
, label
.get(Language
.ENGLISH()).getText());
256 Assert
.assertNotNull(node
.getStatement());
257 Assert
.assertEquals(newStatement
, node
.getStatement().getLabel(Language
.ENGLISH()).getText());
259 //Assert.assertEquals(pkeynode.getFeature().getId(), feature.getId());
264 public void savePolytomousKeyNodeDataWithSameSubKey() {
266 PolytomousKey pkey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
268 PolytomousKeyNode pkeynode
= pkey
.getRoot();
270 PolytomousKey subkey1
= CdmBase
.deproxy(pkeynode
.getChildAt(0).getSubkey(), PolytomousKey
.class);
271 String subkey1title
= subkey1
.getTitleCache();
272 subkey1
.setTitleCache(subkey1title
+ "test", true);
274 PolytomousKey subkey2
= CdmBase
.deproxy(pkeynode
.getChildAt(1).getChildAt(0).getSubkey(), PolytomousKey
.class);
275 String subkey2title
= subkey2
.getTitleCache();
276 subkey2
.setTitleCache(subkey2title
+ "test", true);
278 Assert
.assertSame(subkey1
, subkey2
);
280 polytomousKeyService
.merge(pkey
, true);
284 public void savePolytomousKeyNodeDataWithSameSubKeyUsingService() {
286 PolytomousKey pkey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
288 PolytomousKeyNode pkeynode
= pkey
.getRoot();
289 //because of the check for null values in getChildren it isn't a persistent list anymore
290 // PersistentCollection children = (PersistentCollection) pkeynode.getChildren();
291 PolytomousKeyNode childNode0
= (PolytomousKeyNode
)commonService
.get(pkeynode
.getUuid(), "children", 0);
292 PolytomousKey subkey1
= CdmBase
.deproxy(childNode0
.getSubkey(),PolytomousKey
.class);
293 String subkey1title
= subkey1
.getTitleCache();
294 subkey1
.setTitleCache(subkey1title
+ "test", true);
296 PolytomousKeyNode childNode1
= (PolytomousKeyNode
)commonService
.get(pkeynode
.getUuid(), "children", 1);
297 PolytomousKey subkey2
= CdmBase
.deproxy(childNode1
.getSubkey(),PolytomousKey
.class);
298 String subkey2title
= subkey2
.getTitleCache();
299 subkey2
.setTitleCache(subkey2title
+ "test", true);
301 Assert
.assertNotSame(childNode0
, childNode1
);
303 Assert
.assertSame(subkey1
, subkey2
);
305 polytomousKeyService
.merge(pkey
, true);
309 public void savePolytomousKeyNodeDataWithSameLanguageInLabel() {
311 PolytomousKey pkey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
312 PolytomousKeyNode pkeynode
= pkey
.getRoot();
314 Map
<Language
, LanguageString
> label1
= pkeynode
.getQuestion().getLabel();
317 Map
<Language
, LanguageString
> label2
= pkeynode
.getChildAt(0).getStatement().getLabel();
320 polytomousKeyService
.merge(pkey
, true);
324 public void deleteSubKeyInPolytomousSubKeyWithoutInitializing() {
325 PolytomousKey pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
327 PolytomousKeyNode rootNode
= pKey
.getRoot();
329 PolytomousKeyNode childNode
= rootNode
.getChildAt(0);
330 PolytomousKey subKey
= HibernateProxyHelper
.deproxy( childNode
.getSubkey(), PolytomousKey
.class);;
332 DeleteResult result
= polytomousKeyService
.delete(subKey
.getUuid());
333 //A used subKey can't be deleted
338 Set
<Integer
> ids
= new HashSet
<Integer
>();
342 List
<PolytomousKeyNode
> nodes
= polytomousKeyNodeService
.findById(ids
);
343 for (PolytomousKeyNode child
:nodes
){
344 child
.setSubkey(null);
345 // polytomousKeyNodeService.merge(child);
347 polytomousKeyNodeService
.merge(nodes
, true);
348 result
= polytomousKeyService
.delete(subKey
.getUuid());
353 // retrieving subkey shows its null
354 subKey
= CdmBase
.deproxy(polytomousKeyService
.find(subKeyUuid
),PolytomousKey
.class);
355 Assert
.assertNull(subKey
);
357 pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
362 public void deleteSubKeyInPolytomousNode() {
363 PolytomousKey pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
366 PolytomousKeyNode rootNode
= pKey
.getRoot();
367 List
<PolytomousKeyNode
> children
= rootNode
.getChildren();
368 PolytomousKeyNode child
= rootNode
.getChildAt(0);
369 polytomousKeyNodeService
.delete(child
.getUuid(), true);
371 pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
373 rootNode
= pKey
.getRoot();
374 children
= rootNode
.getChildren();
375 Assert
.assertFalse(children
.contains(child
));
379 public void deleteSubKeyInPolytomousSubKeyAfterInitializing() {
380 PolytomousKey pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
383 PolytomousKeyNode rootNode
= pKey
.getRoot();
384 PolytomousKeyNode child
= rootNode
.getChildAt(0);
385 PolytomousKey subKey
= child
.getSubkey();
386 // this call initializes the subkey
389 polytomousKeyService
.delete(subKey
);
391 // since subKey was initialized before the delete, it will be
392 // accesible even after the delete. This behaviour is similar
393 // to hibernate session delete where the deleted object is
394 // made transient, but not deleted from the object graph
396 PolytomousKeyNode subKeyRootNode
= subKey
.getRoot();
397 Assert
.assertNotNull(subKey
);
401 public void saveNewTermVocabulary() {
402 TermVocabulary
<Feature
> termVocabulary
=
403 TermVocabulary
.NewInstance(TermType
.Feature
,
409 List
<TermVocabulary
<?
extends DefinedTermBase
<?
>>> vocabularies
= (List
)vocabularyService
.findByTermType(TermType
.Feature
, null);
411 for(TermVocabulary
<?
> vocab
: vocabularies
) {
412 vocab
.getTermsOrderedByLabels(Language
.ENGLISH());
415 termVocabulary
= vocabularyService
.merge(termVocabulary
);
416 vocabularies
.add(termVocabulary
);
417 termVocabulary
.setLabel("Test");
418 vocabularyService
.merge(new ArrayList
<>(vocabularies
));
420 vocabularyService
.delete(termVocabulary
);
425 public void saveNewTerm() {
426 UUID vocNameFeatureUuid
= UUID
.fromString("fa7ca3eef-4092-49e1-beec-ed5096193e5e");
427 UUID vocFeatureUuid
= UUID
.fromString("b187d555-f06f-4d65-9e53-da7c93f8eaa8");
428 Feature newTerm
= (Feature
)TermType
.Feature
.getEmptyDefinedTermBase();
429 newTerm
.setLabel("CreateTest");
432 List
<Feature
> features
= termService
.list(Feature
.class, 100, 0, null, null);
433 List
<UUID
> updateTerms
= new ArrayList
<>();
434 for (Feature feature
:features
){
435 if (feature
.getLabel().equals("UpdateTest")){
436 updateTerms
.add(feature
.getUuid());
439 termService
.delete(updateTerms
);
441 // if(termService.findByRepresentationText("UpdateTest", Feature.class, null, null) != null) {
442 // Pager<Feature> terms = termService.findByRepresentationText("UpdateTest", Feature.class, null, null);
443 // if (!terms.getRecords().isEmpty()){
444 // termService.delete(terms.getRecords().get(0).getUuid());
448 Assert
.assertNotNull(newTerm
);
449 @SuppressWarnings("unchecked")
450 TermVocabulary
<Feature
> vocNameFeature
= vocabularyService
.find(vocNameFeatureUuid
);
451 @SuppressWarnings("unchecked")
452 TermVocabulary
<Feature
> vocFeature
= vocabularyService
.find(vocFeatureUuid
);
454 @SuppressWarnings("rawtypes")
455 List
<TermVocabulary
> vocs
= new ArrayList
<>();
457 vocs
.add(vocNameFeature
);
458 vocs
.add(vocFeature
);
460 vocNameFeature
.addTerm(newTerm
);
462 List
<MergeResult
<TermVocabulary
<Feature
>>> mergeResults
= (List
)vocabularyService
.merge(vocs
, true);
464 for(MergeResult
<TermVocabulary
<Feature
>> result
: mergeResults
){
465 TermVocabulary
<Feature
> voc
= result
.getMergedEntity();
466 if(voc
.getUuid().equals(vocNameFeatureUuid
)) {
467 vocNameFeature
= voc
;
471 Assert
.assertTrue(vocNameFeature
.getTerms().contains(newTerm
));
473 for(Feature obj
: vocNameFeature
.getTerms()) {
475 if("CreateTest".equals(dtb
.getLabel())) {
477 Assert
.assertNotNull(dtb
.getCreatedBy());
478 Assert
.assertNotNull(dtb
.getCreated());
480 System
.err
.println(dtb
.getLabel() + " " + dtb
.getCreatedBy() + " " + dtb
.getUuid());
481 Assert
.assertNull(dtb
.getCreatedBy());
484 newTerm
.setLabel("UpdateTest");
485 newTerm
= (Feature
)termService
.merge(newTerm
);
486 Assert
.assertNotNull(newTerm
.getUpdatedBy());
487 Assert
.assertNotNull(newTerm
.getUpdated());
489 Assert
.assertNull(vocNameFeature
.getCreatedBy());
490 Assert
.assertNull(vocFeature
.getCreatedBy());
492 if(termService
.find(newTerm
.getUuid()) != null) {
493 termService
.delete(newTerm
.getUuid());
499 public void updatePerson() {
501 Person person
= (Person
) CdmApplicationState
.getCurrentAppConfig().getAgentService().load(personUuid
);
502 person
.setGivenName("Me");
503 CdmApplicationState
.getCurrentAppConfig().getAgentService().merge(person
, true);
507 public void createPerson() {
509 Person person
= Person
.NewInstance();
510 person
= (Person
) CdmApplicationState
.getCurrentAppConfig().getAgentService().merge(person
);
511 person
= (Person
) CdmApplicationState
.getCurrentAppConfig().getAgentService().load(person
.getUuid());
512 person
.setGivenName("Some");
513 CdmApplicationState
.getCurrentAppConfig().getAgentService().merge(person
, true);
517 public void testThreadLocalActiveSession() {
518 MockSessionOwner
<CdmBase
> so1
= new MockSessionOwner
<>();
519 final ICdmEntitySession activeSession
= getCdmEntitySessionManager().newSession(so1
, true);
520 TestThread thread
= new TestThread(true) {
522 public void doRun() throws InterruptedException
{
523 ICdmEntitySession threadLocalActiveSession
= getCdmEntitySessionManager().getActiveSession();
524 Assert
.assertEquals(threadLocalActiveSession
, activeSession
);
527 invokeThread(thread
);
528 MockSessionOwner
<CdmBase
> so2
= new MockSessionOwner
<>();
529 ICdmEntitySession newActiveSession
= getCdmEntitySessionManager().newSession(so2
, true);
530 Assert
.assertFalse(activeSession
.equals(newActiveSession
));