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
.api
.service
.pager
.Pager
;
36 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
37 import eu
.etaxonomy
.cdm
.model
.agent
.AgentBase
;
38 import eu
.etaxonomy
.cdm
.model
.agent
.Person
;
39 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
40 import eu
.etaxonomy
.cdm
.model
.common
.Credit
;
41 import eu
.etaxonomy
.cdm
.model
.common
.DefinedTermBase
;
42 import eu
.etaxonomy
.cdm
.model
.common
.Extension
;
43 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableSource
;
44 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
45 import eu
.etaxonomy
.cdm
.model
.common
.LanguageString
;
46 import eu
.etaxonomy
.cdm
.model
.common
.TermType
;
47 import eu
.etaxonomy
.cdm
.model
.common
.TermVocabulary
;
48 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
49 import eu
.etaxonomy
.cdm
.model
.description
.KeyStatement
;
50 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKey
;
51 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKeyNode
;
52 import eu
.etaxonomy
.cdm
.model
.media
.Rights
;
53 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
54 import eu
.etaxonomy
.cdm
.persistence
.dto
.MergeResult
;
55 import eu
.etaxonomy
.taxeditor
.httpinvoker
.RemotingSessionAwareTest
;
56 import eu
.etaxonomy
.taxeditor
.httpinvoker
.TestThread
;
65 public class CdmEntitySessionAwareTest
extends RemotingSessionAwareTest
{
67 private static final Logger logger
= Logger
.getLogger(CdmEntitySessionAwareTest
.class);
69 UUID polytomousKeyUuid
= UUID
.fromString("0d53ba20-7de4-4baa-bd8a-401048447d66");
70 UUID subKeyUuid
= UUID
.fromString("9d8bf4f6-a70a-4b80-8556-2ccfb436ff01");
71 //UUID polytomousKeyUuid = UUID.fromString("bab66772-2c83-428a-bb6d-655d12ac6097");
72 UUID taxon1Uuid
= UUID
.fromString("2b336df7-29e8-4f79-985f-66502739d22f");
73 UUID personUuid
= UUID
.fromString("945d08f2-eb92-45b6-9252-6275ea6d338b");
77 IPolytomousKeyService polytomousKeyService
= getRemoteApplicationController().getPolytomousKeyService();
78 IPolytomousKeyNodeService polytomousKeyNodeService
= getRemoteApplicationController().getPolytomousKeyNodeService();
79 ICommonService commonService
= getRemoteApplicationController().getCommonService();
80 ITaxonService taxonService
= getRemoteApplicationController().getTaxonService();
81 IVocabularyService vocabularyService
= getRemoteApplicationController().getVocabularyService();
82 ITermService termService
= getRemoteApplicationController().getTermService();
83 IUserService userService
= getRemoteApplicationController().getUserService();
85 //Language english = Language.getLanguageFromUuid(Language.uuidEnglish);
90 public static void initializePolytomousKeyTest() {
96 public void readAllPolytomousKeys() {
97 List
<PolytomousKey
> pKeys
= polytomousKeyService
.list(PolytomousKey
.class, null, null, null, null);
98 Iterator
<PolytomousKey
> pKeysItr
= pKeys
.iterator();
99 Assert
.assertEquals(pKeysItr
.next().getUuid(),UUID
.fromString("9d8bf4f6-a70a-4b80-8556-2ccfb436ff01"));
100 Assert
.assertEquals(pKeysItr
.next().getUuid(),UUID
.fromString("0d53ba20-7de4-4baa-bd8a-401048447d66"));
105 //@DataSet("PolytomousKeyTest.readPolytmousKeyData.xml")
106 public void readPolytmousKeyData() {
107 PolytomousKey pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
108 Set
<Taxon
> taxonomicScope
= pKey
.getTaxonomicScope();
109 Iterator
<Taxon
> tsItr
= taxonomicScope
.iterator();
110 Taxon taxon
= tsItr
.next();
112 Assert
.assertEquals("Achillea sec. Cyprus", taxon
.getTitleCache());
113 Assert
.assertEquals(tsItr
.hasNext(), false);
115 List
<Credit
> credits
= pKey
.getCredits();
116 AgentBase agent
= credits
.get(0).getAgent();
117 Assert
.assertEquals(agent
.getId(),4809);
118 Assert
.assertEquals(agent
.getTitleCache(),"R. A. Graham");
119 Assert
.assertEquals(credits
.get(0).getText(),"Credits Text Test");
121 Set
<Extension
> exts
= pKey
.getExtensions();
122 Iterator
<Extension
> extItr
= exts
.iterator();
123 Extension ext
= extItr
.next();
124 Assert
.assertEquals(ext
.getValue(), "http://test.com");
126 Set
<Rights
> rights
= pKey
.getRights();
127 Iterator
<Rights
> rightsItr
= rights
.iterator();
128 Rights right
= rightsItr
.next();
129 Assert
.assertEquals(right
.getText(),"Rights Text Test");
131 Set
<IdentifiableSource
> sources
= pKey
.getSources();
132 Iterator
<IdentifiableSource
> sourcesItr
= sources
.iterator();
133 IdentifiableSource source
= sourcesItr
.next();
134 Assert
.assertEquals(source
.getId(), 23710);
135 source
= sourcesItr
.next();
136 Assert
.assertEquals(source
.getId(), 23711);
138 // TO DO : Added tests for Annotations , Markers
144 public void readPolytomousKeyDataFromNodes() {
145 PolytomousKey pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
146 PolytomousKeyNode rootNode
= pKey
.getRoot();
149 Assert
.assertEquals(rootNode
.getId(), 2750);
151 Assert
.assertEquals(rootNode
.getChildAt(0).getId(), 2751);
152 Assert
.assertEquals(rootNode
.getChildAt(0).getParent().getId(), rootNode
.getId());
153 Assert
.assertEquals(rootNode
.getKey().getId(), pKey
.getId());
154 Integer sortIndex
= (Integer
)getFieldValueViaReflection(rootNode
.getChildAt(0), "sortIndex");
155 Assert
.assertEquals(sortIndex
, new Integer(0));
156 String statement
= "Capitula without ligulate ray-florets; leaves entire or subentire";
157 Assert
.assertEquals(rootNode
.getChildAt(0).getStatement().getLabelText(Language
.ENGLISH()), statement
);
159 Assert
.assertEquals(rootNode
.getChildAt(1).getId(), 2753);
160 Assert
.assertEquals(rootNode
.getChildAt(1).getParent().getId(), rootNode
.getId());
161 Assert
.assertEquals(rootNode
.getChildAt(1).getKey().getId(), pKey
.getId());
162 sortIndex
= (Integer
)getFieldValueViaReflection(rootNode
.getChildAt(1), "sortIndex");
163 Assert
.assertEquals(sortIndex
, new Integer(1));
164 statement
= "Capitula with ligulate ray-florets; leaves pinnatisect";
165 Assert
.assertEquals(rootNode
.getChildAt(1).getStatement().getLabelText(Language
.ENGLISH()), statement
);
167 Assert
.assertEquals(rootNode
.getChildAt(1).getChildAt(0).getId(), 2754);
168 Assert
.assertEquals(rootNode
.getChildAt(1).getChildAt(0).getParent().getId(), rootNode
.getChildAt(1).getId());
169 Assert
.assertEquals(rootNode
.getChildAt(1).getChildAt(0).getKey().getId(), pKey
.getId());
170 sortIndex
= (Integer
)getFieldValueViaReflection(rootNode
.getChildAt(1).getChildAt(0), "sortIndex");
171 Assert
.assertEquals(sortIndex
, new Integer(0));
172 statement
= "Ray-florets yellow";
173 Assert
.assertEquals(rootNode
.getChildAt(1).getChildAt(0).getStatement().getLabelText(Language
.ENGLISH()), statement
);
174 Assert
.assertEquals(rootNode
.getChildAt(1).getChildAt(0).getChildAt(0).getTaxon().getTitleCache(), "Achillea arabica Kotschy sec. Cyprus");
179 public void addGrandChildPolytomousKeyNode() {
181 PolytomousKey pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
182 PolytomousKeyNode rootChildNode
= pKey
.getRoot().getChildAt(0);
183 PolytomousKeyNode grandChildNode
= PolytomousKeyNode
.NewInstance();
184 rootChildNode
.addChild(grandChildNode
);
186 MergeResult
<PolytomousKey
> result
= polytomousKeyService
.merge(pKey
, true);
187 pKey
= result
.getMergedEntity();
188 grandChildNode
= pKey
.getRoot().getChildAt(0).getChildAt(0);
189 Assert
.assertTrue(0 != grandChildNode
.getId());
190 KeyStatement ks
= KeyStatement
.NewInstance("test");
191 grandChildNode
.setStatement(ks
);
192 polytomousKeyService
.merge(pKey
, true);
194 //grandChildNode = pKey.getRoot().getChildAt(0).getChildAt(0);
195 //KeyStatement ks = grandChildNode.getStatement();
196 Assert
.assertTrue(0 != ks
.getId());
201 public void addGreatGrandChildPolytomousKeyNode() {
203 PolytomousKey pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
204 PolytomousKeyNode rootChildNode
= pKey
.getRoot().getChildAt(0);
205 PolytomousKeyNode grandChildNode
= PolytomousKeyNode
.NewInstance();
206 rootChildNode
.addChild(grandChildNode
);
209 polytomousKeyNodeService
.merge(grandChildNode
, true);
212 Assert
.assertFalse(pKey
.getRoot().getChildAt(0).getChildAt(0).getId() == 0);
216 public void savePolytomousKeyNodeData() {
217 PolytomousKey pkey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
219 PolytomousKeyNode pkeynode
= pkey
.getRoot();
220 String newQuestion
= "New Question";
221 String newStatement
= "New Statement";
223 Assert
.assertEquals("Question 1",pkeynode
.getQuestion().getLabel().get(Language
.ENGLISH()).getText());
224 for(PolytomousKeyNode node
: pkeynode
.getChildren()) {
226 node
.setQuestion(null);
227 node
.setStatement(null);
229 //FIXME:Remoting Add tests for feature after fixing problem
231 //Feature feature = pkeynode.getFeature();
232 //Assert.assertEquals(feature.getTitleCache(),"Systematics");
233 //pkeynode.setFeature(null);
235 Assert
.assertEquals(pkeynode
.getChildAt(0).getModifyingText().get(Language
.ENGLISH()).getText(),"Modifying Text 1a");
236 String modifyingText
= "Modifying Text 1a updated";
238 //pkeynode.getChildAt(0).putModifyingText(Language.ENGLISH(), modifyingText);
240 Assert
.assertEquals(pkeynode
.getChildAt(0).getSubkey().getId(),751);
241 Assert
.assertEquals("Asphodeline", pkeynode
.getChildAt(0).getSubkey().getTitleCache());
242 Assert
.assertNull(pkeynode
.getChildAt(1).getTaxon());
243 Taxon taxon
= CdmBase
.deproxy(taxonService
.find(taxon1Uuid
),Taxon
.class);
244 pkeynode
.getChildAt(1).setTaxon(taxon
);
246 polytomousKeyService
.merge(pkey
, true);
248 pkey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
251 pkeynode
= pkey
.getRoot();
252 for(PolytomousKeyNode node
: pkeynode
.getChildren()) {
253 Assert
.assertNull(node
.getQuestion());
254 node
.setQuestion(KeyStatement
.NewInstance(Language
.ENGLISH(),newQuestion
));
255 Assert
.assertNull(node
.getStatement());
256 node
.setStatement(KeyStatement
.NewInstance(Language
.ENGLISH(),newStatement
));
259 Assert
.assertEquals(pkeynode
.getChildAt(1).getTaxon(), taxon
);
261 polytomousKeyService
.merge(pkey
, true);
263 pkey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
265 pkeynode
= pkey
.getRoot();
266 for(PolytomousKeyNode node
: pkeynode
.getChildren()) {
267 Assert
.assertNotNull(node
.getQuestion());
268 Map
<Language
, LanguageString
> label
= node
.getQuestion().getLabel();
269 Assert
.assertEquals(newQuestion
, label
.get(Language
.ENGLISH()).getText());
270 Assert
.assertNotNull(node
.getStatement());
271 Assert
.assertEquals(newStatement
, node
.getStatement().getLabel(Language
.ENGLISH()).getText());
273 //Assert.assertEquals(pkeynode.getFeature().getId(), feature.getId());
279 public void savePolytomousKeyNodeDataWithSameSubKey() {
281 PolytomousKey pkey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
284 PolytomousKeyNode pkeynode
= pkey
.getRoot();
286 PolytomousKey subkey1
= CdmBase
.deproxy(pkeynode
.getChildAt(0).getSubkey(), PolytomousKey
.class);
287 String subkey1title
= subkey1
.getTitleCache();
288 subkey1
.setTitleCache(subkey1title
+ "test", true);
291 PolytomousKey subkey2
= CdmBase
.deproxy(pkeynode
.getChildAt(1).getChildAt(0).getSubkey(), PolytomousKey
.class);
292 String subkey2title
= subkey2
.getTitleCache();
293 subkey2
.setTitleCache(subkey2title
+ "test", true);
295 Assert
.assertSame(subkey1
, subkey2
);
297 polytomousKeyService
.merge(pkey
, true);
301 public void savePolytomousKeyNodeDataWithSameSubKeyUsingService() {
303 PolytomousKey pkey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
306 PolytomousKeyNode pkeynode
= pkey
.getRoot();
307 //because of the check for null values in getChildren it isn't a persistent list anymore
308 // PersistentCollection children = (PersistentCollection) pkeynode.getChildren();
309 PolytomousKeyNode childNode0
= (PolytomousKeyNode
)commonService
.get(pkeynode
.getUuid(), "children", 0);
310 PolytomousKey subkey1
= CdmBase
.deproxy(childNode0
.getSubkey(),PolytomousKey
.class);
311 String subkey1title
= subkey1
.getTitleCache();
312 subkey1
.setTitleCache(subkey1title
+ "test", true);
314 PolytomousKeyNode childNode1
= (PolytomousKeyNode
)commonService
.get(pkeynode
.getUuid(), "children", 1);
315 PolytomousKey subkey2
= CdmBase
.deproxy(childNode1
.getSubkey(),PolytomousKey
.class);
316 String subkey2title
= subkey2
.getTitleCache();
317 subkey2
.setTitleCache(subkey2title
+ "test", true);
319 Assert
.assertNotSame(childNode0
, childNode1
);
321 Assert
.assertSame(subkey1
, subkey2
);
323 polytomousKeyService
.merge(pkey
, true);
329 public void savePolytomousKeyNodeDataWithSameLanguageInLabel() {
331 PolytomousKey pkey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
332 PolytomousKeyNode pkeynode
= pkey
.getRoot();
334 Map
<Language
, LanguageString
> label1
= pkeynode
.getQuestion().getLabel();
338 Map
<Language
, LanguageString
> label2
= pkeynode
.getChildAt(0).getStatement().getLabel();
342 polytomousKeyService
.merge(pkey
, true);
346 public void deleteSubKeyInPolytomousSubKeyWithoutInitializing() {
347 PolytomousKey pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
350 PolytomousKeyNode rootNode
= pKey
.getRoot();
352 PolytomousKeyNode childNode
= rootNode
.getChildAt(0);
353 PolytomousKey subKey
= HibernateProxyHelper
.deproxy( childNode
.getSubkey(), PolytomousKey
.class);;
356 DeleteResult result
= polytomousKeyService
.delete(subKey
.getUuid());
357 //A used subKey can't be deleted
363 Set
<Integer
> ids
= new HashSet
<Integer
>();
367 List
<PolytomousKeyNode
> nodes
= polytomousKeyNodeService
.findById(ids
);
368 for (PolytomousKeyNode child
:nodes
){
369 child
.setSubkey(null);
370 // polytomousKeyNodeService.merge(child);
372 polytomousKeyNodeService
.merge(nodes
, true);
373 result
= polytomousKeyService
.delete(subKey
.getUuid());
381 // retrieving subkey shows its null
382 subKey
= CdmBase
.deproxy(polytomousKeyService
.find(subKeyUuid
),PolytomousKey
.class);
383 Assert
.assertNull(subKey
);
385 pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
392 public void deleteSubKeyInPolytomousNode() {
393 PolytomousKey pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
396 PolytomousKeyNode rootNode
= pKey
.getRoot();
397 List
<PolytomousKeyNode
> children
= rootNode
.getChildren();
398 PolytomousKeyNode child
= rootNode
.getChildAt(0);
399 polytomousKeyNodeService
.delete(child
.getUuid(), true);
401 pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
403 rootNode
= pKey
.getRoot();
404 children
= rootNode
.getChildren();
405 Assert
.assertFalse(children
.contains(child
));
409 public void deleteSubKeyInPolytomousSubKeyAfterInitializing() {
410 PolytomousKey pKey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
413 PolytomousKeyNode rootNode
= pKey
.getRoot();
414 PolytomousKeyNode child
= rootNode
.getChildAt(0);
415 PolytomousKey subKey
= child
.getSubkey();
416 // this call initializes the subkey
419 polytomousKeyService
.delete(subKey
);
421 // since subKey was initialized before the delete, it will be
422 // accesible even after the delete. This behaviour is similar
423 // to hibernate session delete where the deleted object is
424 // made transient, but not deleted from the object graph
426 PolytomousKeyNode subKeyRootNode
= subKey
.getRoot();
427 Assert
.assertNotNull(subKey
);
431 public void saveNewTermVocabulary() {
432 TermVocabulary termVocabulary
=
433 TermVocabulary
.NewInstance(TermType
.Feature
,
439 List
<TermVocabulary
<DefinedTermBase
>> vocabularies
= vocabularyService
.findByTermType(TermType
.Feature
);
441 for(TermVocabulary vocab
: vocabularies
) {
442 vocab
.getTermsOrderedByLabels(Language
.ENGLISH());
445 termVocabulary
= vocabularyService
.merge(termVocabulary
);
446 vocabularies
.add(termVocabulary
);
447 termVocabulary
.setLabel("Test");
448 vocabularyService
.merge(new ArrayList
<TermVocabulary
>(vocabularies
));
450 vocabularyService
.delete(termVocabulary
);
455 public void saveNewTerm() {
456 UUID vocNameFeatureUuid
= UUID
.fromString("fa7ca3eef-4092-49e1-beec-ed5096193e5e");
457 UUID vocFeatureUuid
= UUID
.fromString("b187d555-f06f-4d65-9e53-da7c93f8eaa8");
458 DefinedTermBase newTerm
= TermType
.Feature
.getEmptyDefinedTermBase();
459 newTerm
.setLabel("CreateTest");
462 List
<Feature
> features
= termService
.list(Feature
.class, 100, 0, null, null);
463 List
<UUID
> updateTerms
= new ArrayList
<UUID
>();
464 for (Feature feature
:features
){
465 if (feature
.getLabel().equals("UpdateTest")){
466 updateTerms
.add(feature
.getUuid());
469 termService
.delete(updateTerms
);
471 // if(termService.findByRepresentationText("UpdateTest", Feature.class, null, null) != null) {
472 // Pager<Feature> terms = termService.findByRepresentationText("UpdateTest", Feature.class, null, null);
473 // if (!terms.getRecords().isEmpty()){
474 // termService.delete(terms.getRecords().get(0).getUuid());
478 Assert
.assertNotNull(newTerm
);
479 TermVocabulary vocNameFeature
= vocabularyService
.find(vocNameFeatureUuid
);
480 TermVocabulary vocFeature
= vocabularyService
.find(vocFeatureUuid
);
482 List
<TermVocabulary
> vocs
= new ArrayList
<TermVocabulary
>();
484 vocs
.add(vocNameFeature
);
485 vocs
.add(vocFeature
);
487 vocNameFeature
.addTerm(newTerm
);
489 List
<MergeResult
<TermVocabulary
>> mergeResults
= vocabularyService
.merge(vocs
, true);
491 for(MergeResult
<TermVocabulary
> result
: mergeResults
){
492 TermVocabulary voc
= result
.getMergedEntity();
493 if(voc
.getUuid().equals(vocNameFeatureUuid
)) {
494 vocNameFeature
= voc
;
498 Assert
.assertTrue(vocNameFeature
.getTerms().contains(newTerm
));
500 for(Object obj
: vocNameFeature
.getTerms()) {
501 DefinedTermBase dtb
= (DefinedTermBase
)obj
;
502 if("CreateTest".equals(dtb
.getLabel())) {
504 Assert
.assertNotNull(dtb
.getCreatedBy());
505 Assert
.assertNotNull(dtb
.getCreated());
507 System
.err
.println(dtb
.getLabel() + " " + dtb
.getCreatedBy() + " " + dtb
.getUuid());
508 Assert
.assertNull(dtb
.getCreatedBy());
511 newTerm
.setLabel("UpdateTest");
512 newTerm
= termService
.merge(newTerm
);
513 Assert
.assertNotNull(newTerm
.getUpdatedBy());
514 Assert
.assertNotNull(newTerm
.getUpdated());
516 Assert
.assertNull(vocNameFeature
.getCreatedBy());
517 Assert
.assertNull(vocFeature
.getCreatedBy());
519 if(termService
.find(newTerm
.getUuid()) != null) {
520 termService
.delete(newTerm
.getUuid());
527 public void updatePerson() {
529 Person person
= (Person
) CdmApplicationState
.getCurrentAppConfig().getAgentService().load(personUuid
);
530 person
.setFirstname("Me");
531 CdmApplicationState
.getCurrentAppConfig().getAgentService().merge(person
, true);
536 public void createPerson() {
538 Person person
= Person
.NewInstance();
539 person
= (Person
) CdmApplicationState
.getCurrentAppConfig().getAgentService().merge(person
);
540 person
= (Person
) CdmApplicationState
.getCurrentAppConfig().getAgentService().load(person
.getUuid());
541 person
.setFirstname("Some");
542 CdmApplicationState
.getCurrentAppConfig().getAgentService().merge(person
, true);
546 public void testThreadLocalActiveSession() throws InterruptedException
{
547 MockSessionOwner
<CdmBase
> so1
= new MockSessionOwner
<CdmBase
>();
548 final ICdmEntitySession activeSession
= getCdmEntitySessionManager().newSession(so1
, true);
549 TestThread thread
= new TestThread(true) {
551 public void doRun() throws InterruptedException
{
552 ICdmEntitySession threadLocalActiveSession
= getCdmEntitySessionManager().getActiveSession();
553 Assert
.assertEquals(threadLocalActiveSession
, activeSession
);
556 invokeThread(thread
);
557 MockSessionOwner
<CdmBase
> so2
= new MockSessionOwner
<CdmBase
>();
558 ICdmEntitySession newActiveSession
= getCdmEntitySessionManager().newSession(so2
, true);
559 Assert
.assertFalse(activeSession
.equals(newActiveSession
));