Project

General

Profile

« Previous | Next » 

Revision a9afeb56

Added by Cherian Mathew over 8 years ago

#5138 Add test for normal Person load case

View differences:

eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/session/CdmEntitySessionAwareTest.java
34 34
import eu.etaxonomy.cdm.api.service.IVocabularyService;
35 35
import eu.etaxonomy.cdm.model.agent.AgentBase;
36 36
import eu.etaxonomy.cdm.model.agent.Person;
37
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
38 37
import eu.etaxonomy.cdm.model.common.CdmBase;
39 38
import eu.etaxonomy.cdm.model.common.Credit;
40 39
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
......
65 64
    UUID subKeyUuid = UUID.fromString("9d8bf4f6-a70a-4b80-8556-2ccfb436ff01");
66 65
    //UUID polytomousKeyUuid = UUID.fromString("bab66772-2c83-428a-bb6d-655d12ac6097");
67 66
    UUID taxon1Uuid = UUID.fromString("2b336df7-29e8-4f79-985f-66502739d22f");
67
    UUID personUuid = UUID.fromString("945d08f2-eb92-45b6-9252-6275ea6d338b");
68

  
68 69

  
69 70

  
70 71
    IPolytomousKeyService polytomousKeyService = getRemoteApplicationController().getPolytomousKeyService();
......
474 475

  
475 476
    @Ignore // activate after fixing #5138
476 477
    @Test
477
    public void savePerson() {
478
        TeamOrPersonBase teamOrPerson = Person.NewInstance();
479
        teamOrPerson.setTitleCache("New Person", true);
480
        teamOrPerson = (TeamOrPersonBase)CdmApplicationState.getCurrentAppConfig().getAgentService().merge(teamOrPerson);
481
        //CdmApplicationState.getCurrentAppConfig().getAgentService().saveOrUpdate(teamOrPerson);
478
    public void updatePerson() {
479
        Person person = (Person) CdmApplicationState.getCurrentAppConfig().getAgentService().load(personUuid);
480
        // Note : at this point the contact field in Person (AgentBase) is initialized even though no
481
        //        data related to the Contact class exists in the database.
482
        person.setFirstname("Me");
483
        CdmApplicationState.getCurrentAppConfig().getAgentService().merge(person);
482 484

  
483
        Person person = (Person)teamOrPerson;
484
//        person.setFirstname("Some");
485
//        CdmApplicationState.getCurrentAppConfig().getAgentService().merge(teamOrPerson);
485
    }
486 486

  
487
        person = (Person) CdmApplicationState.getCurrentAppConfig().getAgentService().find(person.getUuid());
487
    @Ignore // activate after fixing #5138
488
    @Test
489
    public void createPerson() {
490

  
491
        Person person = Person.NewInstance();
492
        //person.setTitleCache("New Person", true);
493
        person = (Person) CdmApplicationState.getCurrentAppConfig().getAgentService().merge(person);
494
        //Note : at this point the contact field in Person (AgentBase) is set to null which is
495
        //       different behaviour as compared to a load call on an existing Person entity.
496
        //       The fact that the contact is null will lead to the all-delete-orphan error.
497
        person = (Person) CdmApplicationState.getCurrentAppConfig().getAgentService().load(person.getUuid());
488 498
        person.setFirstname("Some");
489
        CdmApplicationState.getCurrentAppConfig().getAgentService().merge(teamOrPerson);
499
        CdmApplicationState.getCurrentAppConfig().getAgentService().merge(person);
490 500
    }
491 501
}
eu.etaxonomy.taxeditor.test/src/test/resources/eu/etaxonomy/taxeditor/session/CdmEntitySessionAwareTest.xml
95 95
  <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"/>
96 96
  <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"/>
97 97

  
98
  <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"/>
98
  <AgentBase DTYPE="Person" id="4809" created="2010-12-21 15:09:59.0" uuid="945d08f2-eb92-45b6-9252-6275ea6d338b" protectedtitlecache="false" />
99 99

  
100 100
  <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"/>
101 101

  
......
119 119
  <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"/>
120 120

  
121 121
  <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"/>
122
  <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"/>
123

  
124
  <AgentBase/>
122
  <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"/>   
125 123
  
126 124
</dataset>

Also available in: Unified diff