Project

General

Profile

Revision 7d60d703

ID7d60d7030be8688c9f81cc7e5fa1624fffd4a105
Parent 896cca0d
Child c3233f9b

Added by Andreas Kohlbecker about 1 year ago

ref #7331 test created and loging more details at level TRACE

View differences:

cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/initializer/AdvancedBeanInitializer.java
457 457
                query.setParameterList("idSet", idSet);
458 458
                List<Object> list = query.list();
459 459

  
460
                if (logger.isTraceEnabled()){logger.trace("initialize bulk loaded beans of class " +  clazz.getSimpleName());}
460
                if (logger.isTraceEnabled()){
461
//                    String beanList = "";
462
//                    for(Object id : idSet){
463
//                        Set<Serializable> bean = node.getLazyBeans().get(id);
464
//                        beanList += bean.getClass().getSimpleName() + "<" + id + "> ";
465
//                    }
466
                    logger.trace("initialize bulk loaded beans of class " +  clazz.getSimpleName() + ": " + idSet );
467
                }
461 468
                for (Object object : list){
462 469
                    if (object instanceof HibernateProxy){  //TODO remove hibernate dependency
463 470
                        object = initializeInstance(object);
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/initializer/AdvancedBeanInitializerTest.java
8 8
*/
9 9
package eu.etaxonomy.cdm.persistence.dao.initializer;
10 10

  
11
import static org.junit.Assert.assertFalse;
12
import static org.junit.Assert.assertTrue;
13

  
11 14
import java.io.FileNotFoundException;
12 15
import java.net.URI;
13 16
import java.util.ArrayList;
......
17 20
import java.util.Set;
18 21
import java.util.UUID;
19 22

  
23
import org.hibernate.Hibernate;
20 24
import org.junit.Test;
21 25
import org.unitils.dbunit.annotation.DataSet;
22 26
import org.unitils.spring.annotation.SpringBeanByType;
......
27 31
import eu.etaxonomy.cdm.model.location.Country;
28 32
import eu.etaxonomy.cdm.model.location.Point;
29 33
import eu.etaxonomy.cdm.model.location.ReferenceSystem;
34
import eu.etaxonomy.cdm.model.name.Rank;
35
import eu.etaxonomy.cdm.model.name.TaxonName;
36
import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
37
import eu.etaxonomy.cdm.model.reference.Reference;
38
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
30 39
import eu.etaxonomy.cdm.persistence.dao.agent.IAgentDao;
40
import eu.etaxonomy.cdm.persistence.dao.name.ITaxonNameDao;
41
import eu.etaxonomy.cdm.persistence.dao.reference.IReferenceDao;
31 42
import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;
32 43

  
33 44
/**
......
38 49

  
39 50
    private static final UUID personUuid = UUID.fromString("d0568bb1-4dc8-40dc-a405-d0b9e714a7a9");
40 51

  
52
    private static final UUID referenceUuid = UUID.fromString("f48196c6-854a-416e-8f2a-67bd39e988dc");
53

  
54
    private static final UUID nameUuid = UUID.fromString("98cbb643-d521-4ca7-86f7-8180bea85d9f");
55

  
41 56
    @SpringBeanByType
42 57
    private IAgentDao agentDao;
43 58

  
44 59
    @SpringBeanByType
60
    private IReferenceDao referenceDao;
61

  
62
    @SpringBeanByType
63
    private ITaxonNameDao nameDao;
64

  
65
    @SpringBeanByType
45 66
    private AdvancedBeanInitializer initializer;
46 67

  
47 68
    @DataSet
......
59 80
        initializer.initialize(person, propPath);
60 81
    }
61 82

  
83
    /**
84
     * Attempt to reproduce #7331 without success
85
     */
86
    @DataSet
87
    @Test
88
    public void testFullNameGraphWithPreloadedReference() {
89
        // find the reference by iD (not load!)
90
        Reference ref = referenceDao.findById(5000);
91
        TaxonName name = nameDao.findById(5000);
92
        assertFalse("for this test to be significant the authorship must be uninitialized", Hibernate.isInitialized(name.getNomenclaturalReference().getAuthorship()));
93
        initializer.initialize(name, Arrays.asList(new String[]{"nomenclaturalReference.authorship.$"}));
94
        assertTrue(Hibernate.isInitialized(name.getNomenclaturalReference().getAuthorship()));
95
    }
96

  
62 97

  
63 98

  
64 99
    @Override
65
//    @Test
100
    @Test
66 101
    public void createTestDataSet() throws FileNotFoundException {
67
        // 1. create person
102
        // 1. create person and a reference
68 103
        Person person = Person.NewTitledInstance("Hallo you");
69 104
        Set<Address> addresses = new HashSet<Address>();
70 105
        addresses.add(Address.NewInstance(Country.GERMANY(), "locality", "pobox", "postcode", "region", "street", Point.NewInstance(50.02,33.3, ReferenceSystem.GOOGLE_EARTH(), 3)));
......
80 115

  
81 116
        person.setContact(contact);
82 117
        person.setUuid(personUuid);
83
        agentDao.save(person);
118
        person = (Person)agentDao.save(person);
119

  
120
        Reference ref = ReferenceFactory.newBook();
121
        ref.setUuid(referenceUuid);
122
        ref.setAuthorship(person);
123
        ref.setTitleCache("The Book", true);
124
        referenceDao.save(ref);
84 125

  
126
        TaxonName name = TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES());
127
        name.setUuid(nameUuid);
128
        name.setNomenclaturalReference(ref);
129
        name.setTitleCache("Species testii", true);
130
        nameDao.save(name);
85 131

  
86 132
        // 2. end the transaction so that all data is actually written to the db
87 133
        setComplete();
......
97 143
            "ADDRESS", "AGENTBASE","AgentBase_contact_emailaddresses",
98 144
            "AgentBase_contact_faxnumbers","AgentBase_contact_phonenumbers",
99 145
            "AgentBase_contact_urls","AgentBase_Address",
146
            "REFERENCE", "TaxonName", "HomotypicalGroup",
100 147
            "HIBERNATE_SEQUENCES" // IMPORTANT!!!
101 148
            },
102 149
            fileNameAppendix );
cdmlib-persistence/src/test/resources/eu/etaxonomy/cdm/persistence/dao/initializer/AdvancedBeanInitializerTest.xml
1 1
<?xml version='1.0' encoding='UTF-8'?>
2 2
<dataset>
3
  <ADDRESS ID="5000" CREATED="2015-11-17 12:14:53.0" UUID="620744ff-9f9a-49f3-8685-ad5ef3bf230b" UPDATED="[null]" LOCALITY="locality" LOCATION_ERRORRADIUS="3" LOCATION_LATITUDE="33.3" LOCATION_LONGITUDE="50.02" POBOX="pobox" POSTCODE="postcode" REGION="region" STREET="street" CREATEDBY_ID="[null]" UPDATEDBY_ID="[null]" COUNTRY_ID="664" LOCATION_REFERENCESYSTEM_ID="2054"/>
4
  <AGENTBASE DTYPE="Person" ID="5000" CREATED="2015-11-17 12:14:53.0" UUID="d0568bb1-4dc8-40dc-a405-d0b9e714a7a9" UPDATED="[null]" LSID_AUTHORITY="[null]" LSID_LSID="[null]" LSID_NAMESPACE="[null]" LSID_OBJECT="[null]" LSID_REVISION="[null]" PROTECTEDTITLECACHE="true" TITLECACHE="Hallo you" PROTECTEDCOLLECTORTITLECACHE="[null]" COLLECTORTITLE="[null]" PROTECTEDNOMENCLATURALTITLECACHE="[null]" NOMENCLATURALTITLE="Hallo you" CODE="[null]" NAME="[null]" FIRSTNAME="[null]" LASTNAME="[null]" LIFESPAN_END="[null]" LIFESPAN_FREETEXT="[null]" LIFESPAN_START="[null]" PREFIX="[null]" SUFFIX="[null]" HASMOREMEMBERS="[null]" CREATEDBY_ID="[null]" UPDATEDBY_ID="[null]" ISPARTOF_ID="[null]"/>
3
  <ADDRESS ID="5000" CREATED="2018-03-26 14:23:59.0" UUID="c7c6b60e-5439-4455-a049-cc837254db11" UPDATED="[null]" LOCALITY="locality" LOCATION_ERRORRADIUS="3" LOCATION_LATITUDE="33.3" LOCATION_LONGITUDE="50.02" POBOX="pobox" POSTCODE="postcode" REGION="region" STREET="street" CREATEDBY_ID="[null]" UPDATEDBY_ID="[null]" COUNTRY_ID="664" LOCATION_REFERENCESYSTEM_ID="2054"/>
4
  <AGENTBASE DTYPE="Person" ID="5000" CREATED="2018-03-26 14:23:59.0" UUID="d0568bb1-4dc8-40dc-a405-d0b9e714a7a9" UPDATED="[null]" LSID_AUTHORITY="[null]" LSID_LSID="[null]" LSID_NAMESPACE="[null]" LSID_OBJECT="[null]" LSID_REVISION="[null]" PROTECTEDTITLECACHE="true" TITLECACHE="Hallo you" PROTECTEDCOLLECTORTITLECACHE="[null]" COLLECTORTITLE="[null]" PROTECTEDNOMENCLATURALTITLECACHE="[null]" NOMENCLATURALTITLE="Hallo you" CODE="[null]" NAME="[null]" FIRSTNAME="[null]" INITIALS="[null]" LASTNAME="[null]" LIFESPAN_END="[null]" LIFESPAN_FREETEXT="[null]" LIFESPAN_START="[null]" PREFIX="[null]" SUFFIX="[null]" HASMOREMEMBERS="[null]" CREATEDBY_ID="[null]" UPDATEDBY_ID="[null]" ISPARTOF_ID="[null]"/>
5 5
  <AGENTBASE_CONTACT_EMAILADDRESSES AGENTBASE_ID="5000" CONTACT_EMAILADDRESSES_ELEMENT="My.email@web.de"/>
6 6
  <AGENTBASE_CONTACT_FAXNUMBERS AGENTBASE_ID="5000" CONTACT_FAXNUMBERS_ELEMENT="0049-30-1234545"/>
7 7
  <AGENTBASE_CONTACT_PHONENUMBERS AGENTBASE_ID="5000" CONTACT_PHONENUMBERS_ELEMENT="0049-30-1234546"/>
8 8
  <AGENTBASE_CONTACT_URLS AGENTBASE_ID="5000" CONTACT_URLS_ELEMENT="http://www.test.de"/>
9 9
  <AGENTBASE_ADDRESS AGENTBASE_ID="5000" CONTACT_ADDRESSES_ID="5000"/>
10
  <REFERENCE ID="5000" CREATED="2018-03-26 14:23:59.0" UUID="f48196c6-854a-416e-8f2a-67bd39e988dc" UPDATED="[null]" LSID_AUTHORITY="[null]" LSID_LSID="[null]" LSID_NAMESPACE="[null]" LSID_OBJECT="[null]" LSID_REVISION="[null]" PROTECTEDTITLECACHE="true" TITLECACHE="The Book" DATEPUBLISHED_END="[null]" DATEPUBLISHED_FREETEXT="[null]" DATEPUBLISHED_START="[null]" EDITION="[null]" EDITOR="[null]" ISBN="[null]" ISSN="[null]" DOI="[null]" NOMENCLATURALLYRELEVANT="false" ORGANIZATION="[null]" PAGES="[null]" PARSINGPROBLEM="0" PLACEPUBLISHED="[null]" PROBLEMENDS="-1" PROBLEMSTARTS="-1" PUBLISHER="[null]" REFERENCEABSTRACT="[null]" SERIESPART="[null]" TITLE="[null]" ABBREVTITLE="[null]" ABBREVTITLECACHE="Hallo you" PROTECTEDABBREVTITLECACHE="false" REFTYPE="BK" URI="[null]" VOLUME="[null]" ACCESSED="[null]" LASTRETRIEVED="[null]" EXTERNALID="[null]" EXTERNALLINK="[null]" AUTHORITYTYPE="[null]" CREATEDBY_ID="[null]" UPDATEDBY_ID="[null]" AUTHORSHIP_ID="5000" INREFERENCE_ID="[null]" INSTITUTION_ID="[null]" SCHOOL_ID="[null]"/>
11
  <TAXONNAME ID="5000" CREATED="2018-03-26 14:23:59.0" UUID="98cbb643-d521-4ca7-86f7-8180bea85d9f" UPDATED="[null]" NAMETYPE="ICNAFP" LSID_AUTHORITY="[null]" LSID_LSID="[null]" LSID_NAMESPACE="[null]" LSID_OBJECT="[null]" LSID_REVISION="[null]" PROTECTEDTITLECACHE="true" TITLECACHE="Species testii" APPENDEDPHRASE="[null]" FULLTITLECACHE="Species testii, The Book" NOMENCLATURALMICROREFERENCE="[null]" PARSINGPROBLEM="0" PROBLEMENDS="-1" PROBLEMSTARTS="-1" PROTECTEDFULLTITLECACHE="false" AUTHORSHIPCACHE="" BINOMHYBRID="false" GENUSORUNINOMIAL="[null]" HYBRIDFORMULA="false" INFRAGENERICEPITHET="[null]" INFRASPECIFICEPITHET="[null]" MONOMHYBRID="false" NAMECACHE="" PROTECTEDAUTHORSHIPCACHE="false" PROTECTEDNAMECACHE="false" SPECIFICEPITHET="[null]" TRINOMHYBRID="false" NAMEAPPROBATION="[null]" SUBGENUSAUTHORSHIP="[null]" ANAMORPHIC="false" CULTIVARNAME="[null]" ACRONYM="[null]" BREED="[null]" ORIGINALPUBLICATIONYEAR="[null]" PUBLICATIONYEAR="[null]" CREATEDBY_ID="[null]" UPDATEDBY_ID="[null]" HOMOTYPICALGROUP_ID="5000" NOMENCLATURALREFERENCE_ID="5000" RANK_ID="765" BASIONYMAUTHORSHIP_ID="[null]" COMBINATIONAUTHORSHIP_ID="[null]" EXBASIONYMAUTHORSHIP_ID="[null]" EXCOMBINATIONAUTHORSHIP_ID="[null]"/>
12
  <HOMOTYPICALGROUP ID="5000" CREATED="2018-03-26 14:23:59.0" UUID="0d456d8f-ca26-40c1-979b-0b8c42f4553b" UPDATED="[null]" CREATEDBY_ID="[null]" UPDATEDBY_ID="[null]"/>
10 13
  <HIBERNATE_SEQUENCES SEQUENCE_NAME="Address" NEXT_VAL="5001"/>
11 14
  <HIBERNATE_SEQUENCES SEQUENCE_NAME="AgentBase" NEXT_VAL="5001"/>
15
  <HIBERNATE_SEQUENCES SEQUENCE_NAME="AuditEvent" NEXT_VAL="5002"/>
16
  <HIBERNATE_SEQUENCES SEQUENCE_NAME="HomotypicalGroup" NEXT_VAL="5001"/>
17
  <HIBERNATE_SEQUENCES SEQUENCE_NAME="Reference" NEXT_VAL="5001"/>
18
  <HIBERNATE_SEQUENCES SEQUENCE_NAME="TaxonName" NEXT_VAL="5001"/>
12 19
</dataset>

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)