#5138 Add test for normal Person load case
authorCherian Mathew <c.mathew@bgbm.org>
Thu, 3 Sep 2015 10:09:39 +0000 (12:09 +0200)
committerCherian Mathew <c.mathew@bgbm.org>
Thu, 3 Sep 2015 10:09:39 +0000 (12:09 +0200)
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/session/CdmEntitySessionAwareTest.java
eu.etaxonomy.taxeditor.test/src/test/resources/eu/etaxonomy/taxeditor/session/CdmEntitySessionAwareTest.xml

index 4da3ed026e91f0cee62d35865783e761c3e9b826..65445fc57b90c4dc08ea76a465c5ffe9b96c54ca 100644 (file)
@@ -34,7 +34,6 @@ import eu.etaxonomy.cdm.api.service.IUserService;
 import eu.etaxonomy.cdm.api.service.IVocabularyService;
 import eu.etaxonomy.cdm.model.agent.AgentBase;
 import eu.etaxonomy.cdm.model.agent.Person;
-import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
 import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.common.Credit;
 import eu.etaxonomy.cdm.model.common.DefinedTermBase;
@@ -65,6 +64,8 @@ public class CdmEntitySessionAwareTest extends RemotingSessionAwareTest {
     UUID subKeyUuid = UUID.fromString("9d8bf4f6-a70a-4b80-8556-2ccfb436ff01");
     //UUID polytomousKeyUuid = UUID.fromString("bab66772-2c83-428a-bb6d-655d12ac6097");
     UUID taxon1Uuid = UUID.fromString("2b336df7-29e8-4f79-985f-66502739d22f");
+    UUID personUuid = UUID.fromString("945d08f2-eb92-45b6-9252-6275ea6d338b");
+
 
 
     IPolytomousKeyService polytomousKeyService = getRemoteApplicationController().getPolytomousKeyService();
@@ -474,18 +475,27 @@ public class CdmEntitySessionAwareTest extends RemotingSessionAwareTest {
 
     @Ignore // activate after fixing #5138
     @Test
-    public void savePerson() {
-        TeamOrPersonBase teamOrPerson = Person.NewInstance();
-        teamOrPerson.setTitleCache("New Person", true);
-        teamOrPerson = (TeamOrPersonBase)CdmApplicationState.getCurrentAppConfig().getAgentService().merge(teamOrPerson);
-        //CdmApplicationState.getCurrentAppConfig().getAgentService().saveOrUpdate(teamOrPerson);
+    public void updatePerson() {
+        Person person = (Person) CdmApplicationState.getCurrentAppConfig().getAgentService().load(personUuid);
+        // Note : at this point the contact field in Person (AgentBase) is initialized even though no
+        //        data related to the Contact class exists in the database.
+        person.setFirstname("Me");
+        CdmApplicationState.getCurrentAppConfig().getAgentService().merge(person);
 
-        Person person = (Person)teamOrPerson;
-//        person.setFirstname("Some");
-//        CdmApplicationState.getCurrentAppConfig().getAgentService().merge(teamOrPerson);
+    }
 
-        person = (Person) CdmApplicationState.getCurrentAppConfig().getAgentService().find(person.getUuid());
+    @Ignore // activate after fixing #5138
+    @Test
+    public void createPerson() {
+
+        Person person = Person.NewInstance();
+        //person.setTitleCache("New Person", true);
+        person = (Person) CdmApplicationState.getCurrentAppConfig().getAgentService().merge(person);
+        //Note : at this point the contact field in Person (AgentBase) is set to null which is
+        //       different behaviour as compared to a load call on an existing Person entity.
+        //       The fact that the contact is null will lead to the all-delete-orphan error.
+        person = (Person) CdmApplicationState.getCurrentAppConfig().getAgentService().load(person.getUuid());
         person.setFirstname("Some");
-        CdmApplicationState.getCurrentAppConfig().getAgentService().merge(teamOrPerson);
+        CdmApplicationState.getCurrentAppConfig().getAgentService().merge(person);
     }
 }
index 1859e37138fe31d674709f99b61f6f55c48e9a70..4448325b156b057b9a3efd1c78ee450e355aed22 100644 (file)
@@ -95,7 +95,7 @@
   <KeyStatement id="2760" created="2014-10-09 15:42:33.0" uuid="b9702653-f620-4208-bda9-a6fe082004d1" updated="2014-10-09 15:42:44.0" createdby_id="10" updatedby_id="10"/>
   <KeyStatement id="2761" created="2014-10-09 15:42:55.0" uuid="688a432f-4b57-4c6f-a8f6-0c468a28cb7c" updated="2014-10-09 15:43:03.0" createdby_id="10" updatedby_id="10"/>
 
-  <AgentBase DTYPE="Person" id="4809" created="2010-12-21 15:09:59.0" uuid="945d08f2-eb92-45b6-9252-6275ea6d338b" protectedtitlecache="false" titleCache="R. A. Graham" nomenclaturaltitle="R. A. Graham" createdby_id="11"/>
+  <AgentBase DTYPE="Person" id="4809" created="2010-12-21 15:09:59.0" uuid="945d08f2-eb92-45b6-9252-6275ea6d338b" protectedtitlecache="false" />
 
   <Extension id="10" created="2014-10-09 15:45:41.0" uuid="0d6f35d7-7e76-446a-a017-7e8355ee1b4c" updated="2014-10-09 15:48:01.0" extendedObj_type="eu.etaxonomy.cdm.model.description.PolytomousKey" extendedObj_id="1550" value="http://test.com" createdby_id="10" updatedby_id="10" type_id="2075"/>
 
   <PolytomousKey id="1550" created="2014-03-10 10:02:35.0" uuid="0d53ba20-7de4-4baa-bd8a-401048447d66" updated="2014-03-10 10:02:42.0" protectedtitlecache="true" titleCache="Achillea"   root_id="2750" startNumber="1"/>
 
   <OriginalSourceBase DTYPE="IdentifiableSource" id="23710" created="2014-03-10 10:06:57.0" uuid="95e05e82-499d-4b8a-ad6b-1085f74a7496" updated="2014-03-10 10:07:33.0" sourcedObj_type="eu.etaxonomy.cdm.model.description.PolytomousKey" sourcedObj_id="1550"    sourceType="PTS"/>
-  <OriginalSourceBase DTYPE="IdentifiableSource" id="23711" created="2014-03-10 10:06:48.0" uuid="f77555fe-0d98-4c9f-98ed-a5bca6b1e342" updated="2014-03-10 10:07:33.0" sourcedObj_type="eu.etaxonomy.cdm.model.description.PolytomousKey" sourcedObj_id="1550"    sourceType="PTS"/>
-
-  <AgentBase/>
+  <OriginalSourceBase DTYPE="IdentifiableSource" id="23711" created="2014-03-10 10:06:48.0" uuid="f77555fe-0d98-4c9f-98ed-a5bca6b1e342" updated="2014-03-10 10:07:33.0" sourcedObj_type="eu.etaxonomy.cdm.model.description.PolytomousKey" sourcedObj_id="1550"    sourceType="PTS"/>   
   
 </dataset>