Project

General

Profile

Revision 0df21dfd

ID0df21dfdb1e8ee960a055946d3c17d61bb833993
Parent fe0c2ae8
Child e11ed28f

Added by Andreas Müller over 3 years ago

ref #7478 add test to pro parte hql search

View differences:

cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonDaoHibernateImplTest.java
92 92
    private UUID rethera;
93 93
    private UUID retheraSecCdmtest;
94 94
    private UUID atroposAgassiz; // a Synonym
95
    private UUID atroposOken;  // a Synonym
95 96
    private UUID atroposLeach; // a Synonym
96 97
    private UUID acherontiaLachesis;
98
    private UUID aus;
97 99

  
98 100
    private AuditEvent previousAuditEvent;
99 101
    private AuditEvent mostRecentAuditEvent;
......
105 107
    private UUID classificationUuid;
106 108

  
107 109
    private boolean includeUnpublished = true;
110
    private boolean NO_UNPUBLISHED = false;
108 111

  
109 112
    private static final boolean doTaxa = true;
110 113
    private static final boolean noTaxa = false;
......
131 134
        acherontia = UUID.fromString("c5cc8674-4242-49a4-aada-72d63194f5fa");
132 135
        acherontiaLachesis = UUID.fromString("b04cc9cb-2b4a-4cc4-a94a-3c93a2158b06");
133 136
        atroposAgassiz = UUID.fromString("d75b2e3d-7394-4ada-b6a5-93175b8751c1");
137
        atroposOken = UUID.fromString("6bfedf25-6dbc-4d5c-9d56-84f9052f3b2a");
134 138
        atroposLeach =  UUID.fromString("3da4ab34-6c50-4586-801e-732615899b07");
135 139
        rethera = UUID.fromString("a9f42927-e507-4fda-9629-62073a908aae");
136 140
        retheraSecCdmtest = UUID.fromString("a9f42927-e507-4fda-9629-62073a908aae");
141
        aus = UUID.fromString("496b1325-be50-4b0a-9aa2-3ecd610215f2");
137 142

  
138 143
        previousAuditEvent = new AuditEvent();
139 144
        previousAuditEvent.setRevisionNumber(1025);
......
530 535
    }
531 536

  
532 537
    @Test
538
    @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="TaxonDaoHibernateImplTest.testGetTaxaByNameAndArea.xml")
539
    public void testGetTaxaByNameProParteSynonym(){
540

  
541
        @SuppressWarnings("rawtypes")
542
        List<TaxonBase> taxa = taxonDao.getTaxaByName(noTaxa, doSynonyms, noMisapplied, noCommonNames, false, "A", null,
543
                MatchMode.BEGINNING, null, includeUnpublished, null, null, null, null);
544
        Assert.assertEquals("2 synonyms and 1 pro parte synonym should be returned.", 3, taxa.size());
545
        assertTrue("Pro parte should exist", existsInCollection(taxa, acherontiaLachesis));
546
        assertTrue("Normal synonym should exist", existsInCollection(taxa, atroposAgassiz));
547
        assertTrue("2. normal synonym should exist", existsInCollection(taxa, atroposOken));
548
        //TODO shouldn't we also find orphaned synonyms (without accepted taxon) like Atropos Leach?
549

  
550
        taxa = taxonDao.getTaxaByName(noTaxa, doSynonyms, noMisapplied, noCommonNames, false, "A", null,
551
                MatchMode.BEGINNING, null, NO_UNPUBLISHED, null, null, null, null);
552
        Assert.assertEquals("2 synonyms and no pro parte synonym should be returned.", 2, taxa.size());
553
        assertTrue("Normal synonym should exist", existsInCollection(taxa, atroposAgassiz));
554
        assertTrue("2. normal synonym should exist", existsInCollection(taxa, atroposOken));
555

  
556
        taxa = taxonDao.getTaxaByName(noTaxa, noSynonyms, doMisapplied, noCommonNames, false, "A", null,
557
                MatchMode.BEGINNING, null, includeUnpublished, null, null, null, null);
558
        Assert.assertEquals("1 misapplied name, no pro parte synonym should be returned.", 1, taxa.size());
559
        assertTrue("Pro parte should exist", existsInCollection(taxa, aus));
560

  
561
    }
562

  
563
    @Test
533 564
    @DataSet
534 565
    public void testFindByUuid() {
535 566
        Taxon taxon = (Taxon)taxonDao.findByUuid(uuid);
cdmlib-persistence/src/test/resources/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonDaoHibernateImplTest.testGetTaxaByNameAndArea.xml
90 90
  <REFERENCE  ID="2" CREATED="2008-12-10 09:56:07.0" UUID="ad4322b7-4b05-48af-be70-f113e46c545e" TITLECACHE="cate-sphingidae.org" PROTECTEDTITLECACHE="true" PROTECTEDABBREVTITLECACHE="false" ABBREVTITLECACHE="Sp. Pl." ABBREVTITLE="Sp. Pl." NOMENCLATURALLYRELEVANT="false" PARSINGPROBLEM="0" PROBLEMENDS="-1" PROBLEMSTARTS="-1"/>
91 91
  <REFERENCE  ID="3" CREATED="2008-12-10 09:56:07.0" UUID="3eea6f96-0682-4025-8cdd-aaaf7c915ae2" TITLECACHE="cate-araceae.org"    PROTECTEDTITLECACHE="true" PROTECTEDABBREVTITLECACHE="false" ABBREVTITLECACHE="Sp. Pl." ABBREVTITLE="Sp. Pl." NOMENCLATURALLYRELEVANT="false" PARSINGPROBLEM="0" PROBLEMENDS="-1" PROBLEMSTARTS="-1"/>
92 92

  
93
  <TAXONBASE DTYPE="Taxon" ID="1"  SEC_ID="1" CREATED="2008-12-10 09:56:07.0" UUID="496b1325-be50-4b0a-9aa2-3ecd610215f2" TITLECACHE=" sec. ???"                                                      PROTECTEDTITLECACHE="true" DOUBTFUL="false" USENAMECACHE="false" TAXONSTATUSUNKNOWN="false"  NAME_ID="1" PUBLISH="true"/>
94
  <TAXONBASE DTYPE="Taxon" ID="2"  SEC_ID="1" CREATED="2008-12-10 09:56:07.0" UUID="822d98dc-9ef7-44b7-a870-94573a3bcb46" TITLECACHE="  sec. ???"                                                     PROTECTEDTITLECACHE="true" DOUBTFUL="false" USENAMECACHE="false" TAXONSTATUSUNKNOWN="false"  NAME_ID="2" PUBLISH="true"/>
93
  <TAXONBASE DTYPE="Taxon" ID="1"  SEC_ID="1" CREATED="2008-12-10 09:56:07.0" UUID="496b1325-be50-4b0a-9aa2-3ecd610215f2" TITLECACHE="Aus sec. Lorem ipsum"                                           PROTECTEDTITLECACHE="true" DOUBTFUL="false" USENAMECACHE="false" TAXONSTATUSUNKNOWN="false"  NAME_ID="1" PUBLISH="true"/>
94
  <TAXONBASE DTYPE="Taxon" ID="2"  SEC_ID="1" CREATED="2008-12-10 09:56:07.0" UUID="822d98dc-9ef7-44b7-a870-94573a3bcb46" TITLECACHE="Aus aus sec. Lorem ipsum"                                       PROTECTEDTITLECACHE="true" DOUBTFUL="false" USENAMECACHE="false" TAXONSTATUSUNKNOWN="false"  NAME_ID="2" PUBLISH="true"/>
95 95
  <TAXONBASE DTYPE="Taxon" ID="12" SEC_ID="2" CREATED="2008-12-10 09:56:07.0" UUID="7748d6f0-04d8-4052-9904-c43f55682419" TITLECACHE="Akbesia Rothschild &amp; Jordan, 1903 sec. cate-sphingidae.org" PROTECTEDTITLECACHE="true" DOUBTFUL="false" USENAMECACHE="false" TAXONSTATUSUNKNOWN="false"  NAME_ID="12" PUBLISH="true"/>
96 96
  <TAXONBASE DTYPE="Taxon" ID="13" SEC_ID="2" CREATED="2008-12-10 09:56:07.0" UUID="63f251fa-f283-46bb-ad42-7390f0a1e806" TITLECACHE="Sphinx Linnaeus, 1758 sec. cate-sphingidae.org"                 PROTECTEDTITLECACHE="true" DOUBTFUL="false" USENAMECACHE="false" TAXONSTATUSUNKNOWN="false"  NAME_ID="13" PUBLISH="true"/>
97 97
  <TAXONBASE DTYPE="Taxon" ID="14" SEC_ID="2" CREATED="2008-12-10 09:56:07.0" UUID="00245994-149e-4cc4-8186-aefd48d4acf8" TITLECACHE="Agrius Hübner, 1819 sec. cate-sphingidae.org"                   PROTECTEDTITLECACHE="true" DOUBTFUL="false" USENAMECACHE="false" TAXONSTATUSUNKNOWN="false"  NAME_ID="14" PUBLISH="true"/>
......
109 109
  <TAXONBASE DTYPE="Synonym" ID="30" SEC_ID="2" CREATED="2008-12-10 09:56:07.0" UUID="f017e915-0266-4f6d-8db4-eff4e8d6af5c" TITLECACHE="Manduca Hübner, 1806 sec. cate-sphingidae.org"                PROTECTEDTITLECACHE="true" DOUBTFUL="false" USENAMECACHE="false" TAXONSTATUSUNKNOWN="false"  NAME_ID="30" PUBLISH="true" ACCEPTEDTAXON_ID="[null]" PARTIAL="false" PROPARTE="false" TYPE_ID="846"/>
110 110
  <TAXONBASE DTYPE="Synonym" ID="31" SEC_ID="2" CREATED="2008-12-10 09:56:07.0" UUID="3da4ab34-6c50-4586-801e-732615899b07" TITLECACHE="Atropos Leach, 1815 sec. cate-sphingidae.org"                 PROTECTEDTITLECACHE="true" DOUBTFUL="false" USENAMECACHE="false" TAXONSTATUSUNKNOWN="false"  NAME_ID="31" PUBLISH="true" ACCEPTEDTAXON_ID="[null]" PARTIAL="false" PROPARTE="false" TYPE_ID="846"/>
111 111
  <TAXONBASE DTYPE="Taxon" ID="35" SEC_ID="2" CREATED="2008-12-10 09:56:07.0" UUID="4cab3cc5-eb80-477c-ac1b-be3c3d0a5a85" TITLECACHE="Acherontia atropos (Linnaeus, 1758) sec. cate-sphingidae.org"   PROTECTEDTITLECACHE="true" DOUBTFUL="false" USENAMECACHE="false" TAXONSTATUSUNKNOWN="false"  NAME_ID="35" PUBLISH="true"/>
112
  <TAXONBASE DTYPE="Taxon" ID="36" SEC_ID="2" CREATED="2008-12-10 09:56:07.0" UUID="b04cc9cb-2b4a-4cc4-a94a-3c93a2158b06" TITLECACHE="Acherontia lachesis (Fabricius, 1798) sec. cate-sphingidae.org" PROTECTEDTITLECACHE="true" DOUBTFUL="false" USENAMECACHE="false" TAXONSTATUSUNKNOWN="false"  NAME_ID="36" PUBLISH="true"/>
112
  <TAXONBASE DTYPE="Taxon" ID="36" SEC_ID="2" CREATED="2008-12-10 09:56:07.0" UUID="b04cc9cb-2b4a-4cc4-a94a-3c93a2158b06" TITLECACHE="Acherontia lachesis (Fabricius, 1798) sec. cate-sphingidae.org" PROTECTEDTITLECACHE="true" DOUBTFUL="false" USENAMECACHE="false" TAXONSTATUSUNKNOWN="false"  NAME_ID="36" PUBLISH="false"/>
113 113
  <TAXONBASE DTYPE="Taxon" ID="37" SEC_ID="2" CREATED="2008-12-10 09:56:07.0" UUID="7b8b5cb3-37ba-4dba-91ac-4c6ffd6ac331" TITLECACHE="Acherontia styx Westwood, 1847 sec. cate-sphingidae.org"        PROTECTEDTITLECACHE="true" DOUBTFUL="false" USENAMECACHE="false" TAXONSTATUSUNKNOWN="false"  NAME_ID="37" PUBLISH="true"/>
114 114
  <TAXONBASE DTYPE="Taxon" ID="38" SEC_ID="3" CREATED="2008-12-10 09:56:07.0" UUID="bc09aca6-06fd-4905-b1e7-cbf7cc65d783" TITLECACHE="Cryptocoryne x purpurea nothovar borneoensis N.Jacobsen, Bastm. &amp; Yuji Sasaki sec. cate-sphingidae.org" PROTECTEDTITLECACHE="true" DOUBTFUL="false" USENAMECACHE="false" TAXONSTATUSUNKNOWN="false"  NAME_ID="38" PUBLISH="true"/>
115 115
  <TAXONBASE DTYPE="Taxon" ID="39" SEC_ID="2" CREATED="2008-12-10 09:56:07.0" UUID="a9f42927-e507-433a-9629-62073a908aae" TITLECACHE="Rethera Rothschild &amp; Jordan, 1903 sec. cdm test"            PROTECTEDTITLECACHE="true" DOUBTFUL="false" USENAMECACHE="false" TAXONSTATUSUNKNOWN="false"  NAME_ID="19" PUBLISH="true"/>
116 116
  <TAXONBASE DTYPE="Taxon" ID="40" SEC_ID="2" CREATED="2008-12-10 09:56:07.0" UUID="a9f42927-e507-433a-9629-62073a908aaf" TITLECACHE="Picris asplenioides L. subsp. asplenioides sec. cate-sphingidae.org" PROTECTEDTITLECACHE="true" DOUBTFUL="false" USENAMECACHE="false" TAXONSTATUSUNKNOWN="false"  NAME_ID="40" PUBLISH="true"/>
117 117
  <TAXONBASE DTYPE="Taxon" ID="41" SEC_ID="3" CREATED="2008-12-10 09:56:07.0" UUID="2fb85004-bdf3-4660-be25-ab6dadfe20ef" TITLECACHE="Ricris asplenioides L. subsp. asplenioides sec. cdm test"       PROTECTEDTITLECACHE="true" DOUBTFUL="false" USENAMECACHE="false" TAXONSTATUSUNKNOWN="false"  NAME_ID="41" PUBLISH="true"/>
118 118

  
119
  <TAXONNAME NAMETYPE="ICZN"   ID="1"  CREATED="2008-12-10 09:56:07.0" UUID="a49a3963-c4ea-4047-8588-2f8f15352730" TITLECACHE=""                                           PROTECTEDTITLECACHE="true" PARSINGPROBLEM="0" FULLTITLECACHE="" PROBLEMENDS="-1" PROBLEMSTARTS="-1" PROTECTEDFULLTITLECACHE="true" AUTHORSHIPCACHE=""                   NAMECACHE="Aus"          PROTECTEDAUTHORSHIPCACHE="true" PROTECTEDNAMECACHE="true" ANAMORPHIC="false" BINOMHYBRID="false" HYBRIDFORMULA="false" MONOMHYBRID="false" TRINOMHYBRID="false" HOMOTYPICALGROUP_ID="1" RANK_ID="774" GENUSORUNINOMIAL="Aus" NOMENCLATURALREFERENCE_ID="1"/>
120
  <TAXONNAME NAMETYPE="ICNAFP" ID="2"  CREATED="2008-12-10 09:56:07.0" UUID="05a438d6-065f-49ef-84db-c7dc2c259975" TITLECACHE=" "                                          PROTECTEDTITLECACHE="true" PARSINGPROBLEM="0" FULLTITLECACHE=" " PROBLEMENDS="-1" PROBLEMSTARTS="-1" PROTECTEDFULLTITLECACHE="true" AUTHORSHIPCACHE=""                  NAMECACHE="Aus aus"      PROTECTEDAUTHORSHIPCACHE="true" PROTECTEDNAMECACHE="true" ANAMORPHIC="false" BINOMHYBRID="false" HYBRIDFORMULA="false" MONOMHYBRID="false" TRINOMHYBRID="false" HOMOTYPICALGROUP_ID="2" RANK_ID="765" GENUSORUNINOMIAL="Aus" SPECIFICEPITHET="aus"  NOMENCLATURALREFERENCE_ID="1"/>
119
  <TAXONNAME NAMETYPE="ICZN"   ID="1"  CREATED="2008-12-10 09:56:07.0" UUID="a49a3963-c4ea-4047-8588-2f8f15352730" TITLECACHE="Aus"                                        PROTECTEDTITLECACHE="true" PARSINGPROBLEM="0" FULLTITLECACHE="" PROBLEMENDS="-1" PROBLEMSTARTS="-1" PROTECTEDFULLTITLECACHE="true" AUTHORSHIPCACHE=""                  NAMECACHE="Aus"          PROTECTEDAUTHORSHIPCACHE="true" PROTECTEDNAMECACHE="true" ANAMORPHIC="false" BINOMHYBRID="false" HYBRIDFORMULA="false" MONOMHYBRID="false" TRINOMHYBRID="false" HOMOTYPICALGROUP_ID="1" RANK_ID="774" GENUSORUNINOMIAL="Aus" NOMENCLATURALREFERENCE_ID="1"/>
120
  <TAXONNAME NAMETYPE="ICNAFP" ID="2"  CREATED="2008-12-10 09:56:07.0" UUID="05a438d6-065f-49ef-84db-c7dc2c259975" TITLECACHE="Aus aus"                                    PROTECTEDTITLECACHE="true" PARSINGPROBLEM="0" FULLTITLECACHE=" " PROBLEMENDS="-1" PROBLEMSTARTS="-1" PROTECTEDFULLTITLECACHE="true" AUTHORSHIPCACHE=""                 NAMECACHE="Aus aus"      PROTECTEDAUTHORSHIPCACHE="true" PROTECTEDNAMECACHE="true" ANAMORPHIC="false" BINOMHYBRID="false" HYBRIDFORMULA="false" MONOMHYBRID="false" TRINOMHYBRID="false" HOMOTYPICALGROUP_ID="2" RANK_ID="765" GENUSORUNINOMIAL="Aus" SPECIFICEPITHET="aus"  NOMENCLATURALREFERENCE_ID="1"/>
121 121
  <TAXONNAME NAMETYPE="ICZN"   ID="12" CREATED="2008-12-10 09:56:07.0" UUID="c1864a99-c025-47e1-87f5-5917b905cca1" TITLECACHE="Akbesia Rothschild &amp; Jordan, 1903"      PROTECTEDTITLECACHE="true" PARSINGPROBLEM="0" FULLTITLECACHE="" PROBLEMENDS="-1" PROBLEMSTARTS="-1" PROTECTEDFULLTITLECACHE="true" AUTHORSHIPCACHE="Rothschild &amp; Jordan, 1903" NAMECACHE="Akbesia" PROTECTEDAUTHORSHIPCACHE="true" PROTECTEDNAMECACHE="true" ANAMORPHIC="false"  BINOMHYBRID="false" HYBRIDFORMULA="false" MONOMHYBRID="false" TRINOMHYBRID="false" HOMOTYPICALGROUP_ID="12" RANK_ID="774" GENUSORUNINOMIAL="Akbesia" NOMENCLATURALREFERENCE_ID="1"/>
122 122
  <TAXONNAME NAMETYPE="ICZN"   ID="13" CREATED="2008-12-10 09:56:07.0" UUID="071a336b-3f31-44d8-bc81-4505dd7ca50b" TITLECACHE="Sphinx Linnaeus, 1758"                      PROTECTEDTITLECACHE="true" PARSINGPROBLEM="0" FULLTITLECACHE="" PROBLEMENDS="-1" PROBLEMSTARTS="-1" PROTECTEDFULLTITLECACHE="true" AUTHORSHIPCACHE="Linnaeus, 1758"    NAMECACHE="Sphinx"        PROTECTEDAUTHORSHIPCACHE="true" PROTECTEDNAMECACHE="true" ANAMORPHIC="false"  BINOMHYBRID="false" HYBRIDFORMULA="false" MONOMHYBRID="false" TRINOMHYBRID="false" HOMOTYPICALGROUP_ID="13" RANK_ID="774" GENUSORUNINOMIAL="Sphinx" NOMENCLATURALREFERENCE_ID="1"/>
123 123
  <TAXONNAME NAMETYPE="ICZN"   ID="14" CREATED="2008-12-10 09:56:07.0" UUID="e8bf37f5-5b87-43dc-8481-a2e58e4f1e71" TITLECACHE="Agrius Hübner, 1819"                        PROTECTEDTITLECACHE="true" PARSINGPROBLEM="0" FULLTITLECACHE="" PROBLEMENDS="-1" PROBLEMSTARTS="-1" PROTECTEDFULLTITLECACHE="true" AUTHORSHIPCACHE="Hübner, 1819"      NAMECACHE="Agrius"        PROTECTEDAUTHORSHIPCACHE="true" PROTECTEDNAMECACHE="true" ANAMORPHIC="false"  BINOMHYBRID="false" HYBRIDFORMULA="false" MONOMHYBRID="false" TRINOMHYBRID="false" HOMOTYPICALGROUP_ID="14" RANK_ID="774" GENUSORUNINOMIAL="Agrius" NOMENCLATURALREFERENCE_ID="1"/>
......
155 155
  <TAXONRELATIONSHIP ID="1" CREATED="2009-06-18 13:47:59.0" UUID="1e7afe1f-306c-4b9f-8e30-4b05f7478822" RELATEDFROM_ID="39" RELATEDTO_ID="19" DOUBTFUL="false" TYPE_ID="888"/>
156 156
  <TAXONRELATIONSHIP ID="2" CREATED="2009-06-18 13:47:59.0" UUID="8d50cecd-c59c-4567-b6f3-4595550c49fa" RELATEDFROM_ID="1"  RELATEDTO_ID="19" DOUBTFUL="false" TYPE_ID="888"/>
157 157
  <TAXONRELATIONSHIP ID="3" CREATED="2009-06-18 13:47:59.0" UUID="f802fd48-26cf-4aec-8d15-6ff542711829" RELATEDFROM_ID="20" RELATEDTO_ID="21" DOUBTFUL="false" TYPE_ID="888"/>
158
  <TAXONRELATIONSHIP ID="4" CREATED="2009-06-18 13:47:59.0" UUID="ee681e41-bfc8-49ed-8236-04c4dd19f817" RELATEDFROM_ID="36" RELATEDTO_ID="35" DOUBTFUL="false" TYPE_ID="2066"/>
158 159
</dataset>
cdmlib-test/src/main/java/eu/etaxonomy/cdm/test/integration/CdmIntegrationTest.java
13 13
import java.io.OutputStream;
14 14
import java.sql.SQLException;
15 15
import java.util.ArrayList;
16
import java.util.Collection;
16 17
import java.util.List;
18
import java.util.UUID;
17 19

  
18 20
import javax.sql.DataSource;
19 21
import javax.xml.transform.Source;
......
38 40
import org.unitils.spring.annotation.SpringBeanByType;
39 41

  
40 42
import eu.etaxonomy.cdm.database.DataBaseTablePrinter;
43
import eu.etaxonomy.cdm.model.common.CdmBase;
44
import eu.etaxonomy.cdm.test.unitils.FlatFullXmlWriter;
41 45

  
42 46
/**
43 47
 * Abstract base class for integration testing a spring / hibernate application using
......
384 388
    }
385 389

  
386 390

  
391
    protected <T extends CdmBase> T getEntityFromCollection(Collection<T> cdmBases, UUID uuid) {
392
        for (T cdmBase : cdmBases){
393
            if (cdmBase.getUuid().equals(uuid)){
394
                return cdmBase;
395
            }
396
        }
397
        return null;
398
    }
399

  
400
    protected boolean existsInCollection(Collection<? extends CdmBase> cdmBases, UUID uuid) {
401
         return getEntityFromCollection(cdmBases, uuid) != null;
402
    }
403

  
404

  
387 405
    /**
388 406
     * This is the common method to create test data xml files for integration tests.
389 407
     *

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)