Project

General

Profile

« Previous | Next » 

Revision 22abd4ac

Added by Andreas Müller over 7 years ago

ref #6089 Remove all calls and methods for taxonomicChildrenCount and taxonomicParentCache

View differences:

cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonDaoHibernateImplTest.java
13 13
import static org.junit.Assert.assertFalse;
14 14
import static org.junit.Assert.assertNotNull;
15 15
import static org.junit.Assert.assertNull;
16
import static org.junit.Assert.assertSame;
17 16
import static org.junit.Assert.assertTrue;
18 17
import static org.junit.Assert.fail;
19 18

  
......
43 42
import eu.etaxonomy.cdm.model.common.MarkerType;
44 43
import eu.etaxonomy.cdm.model.location.NamedArea;
45 44
import eu.etaxonomy.cdm.model.name.NonViralName;
46
import eu.etaxonomy.cdm.model.name.Rank;
47 45
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
48 46
import eu.etaxonomy.cdm.model.reference.Reference;
49 47
import eu.etaxonomy.cdm.model.taxon.Classification;
......
64 62
import eu.etaxonomy.cdm.persistence.dao.taxon.IClassificationDao;
65 63
import eu.etaxonomy.cdm.persistence.dao.taxon.ITaxonDao;
66 64
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
67
import eu.etaxonomy.cdm.persistence.fetch.CdmFetch;
68 65
import eu.etaxonomy.cdm.persistence.query.GroupByCount;
69 66
import eu.etaxonomy.cdm.persistence.query.GroupByDate;
70 67
import eu.etaxonomy.cdm.persistence.query.Grouping;
......
162 159
        assertNotNull("Instance of IReferenceDao expected",referenceDao);
163 160
    }
164 161

  
165
    /**
166
     * Test method for
167
     * {@link eu.etaxonomy.cdm.persistence.dao.hibernate.taxon.TaxonDaoHibernateImpl#getRootTaxa(eu.etaxonomy.cdm.model.reference.Reference)}
168
     * .
169
     */
170
    @Test
171
    @DataSet
172
    public void testGetRootTaxa() {
173
        Reference sec1 = referenceDao.findById(1);
174
        assert sec1 != null : "sec1 must exist";
175
        Reference sec2 = referenceDao.findById(2);
176
        assert sec2 != null : "sec2 must exist";
177

  
178
        List<Taxon> rootTaxa = taxonDao.getRootTaxa(sec1);
179
        assertNotNull("getRootTaxa should return a List", rootTaxa);
180
        assertFalse("The list should not be empty", rootTaxa.isEmpty());
181
        assertEquals("There should be one root taxon", 1, rootTaxa.size());
182

  
183
        rootTaxa = taxonDao.getRootTaxa(sec1, CdmFetch.FETCH_CHILDTAXA(), true, false);
184
        assertNotNull("getRootTaxa should return a List", rootTaxa);
185
        assertFalse("The list should not be empty", rootTaxa.isEmpty());
186
        assertEquals("There should be one root taxon", 1, rootTaxa.size());
187

  
188
        rootTaxa = taxonDao.getRootTaxa(Rank.GENUS(), sec1, CdmFetch.FETCH_CHILDTAXA(), true, false, null);
189
        assertNotNull("getRootTaxa should return a List", rootTaxa);
190
        assertFalse("The list should not be empty", rootTaxa.isEmpty());
191
        assertEquals("There should be one root taxon", 1, rootTaxa.size());
192

  
193
        rootTaxa = taxonDao.getRootTaxa(Rank.FAMILY(), sec2, CdmFetch.FETCH_CHILDTAXA(), true, false, null);
194
        if (logger.isDebugEnabled()) {
195
            logger.debug("Root taxa rank Family (" + rootTaxa.size() + "):");
196
            for (Taxon taxon : rootTaxa) {
197
                logger.debug(taxon.getTitleCache());
198
            }
199
        }
200
        assertEquals("There should be one root taxon rank Family", 1, rootTaxa.size());
201
        rootTaxa = taxonDao.getRootTaxa(Rank.GENUS(), sec2, CdmFetch.FETCH_CHILDTAXA(), true, false, null);
202
        assertNotNull("getRootTaxa should return a List", rootTaxa);
203
        assertFalse("The list should not be empty", rootTaxa.isEmpty());
204
        if (logger.isDebugEnabled()) {
205
            logger.debug("Root taxa rank Genus (" + rootTaxa.size() + "):");
206
            for (Taxon taxon : rootTaxa) {
207
                logger.debug(taxon.getTitleCache());
208
            }
209
        }
210
        assertEquals("There should be 22 root taxa rank Genus", 22, rootTaxa.size());
211

  
212
        rootTaxa = taxonDao.getRootTaxa(Rank.SPECIES(), sec2, CdmFetch.FETCH_CHILDTAXA(), true, false, null);
213
        if (logger.isDebugEnabled()) {
214
            logger.debug("Root taxa rank Species (" + rootTaxa.size() + "):");
215
            for (Taxon taxon : rootTaxa) {
216
                logger.debug(taxon.getTitleCache());
217
            }
218
        }
219
        assertEquals("There should be 4 root taxa rank Species", 3, rootTaxa.size());
220
    }
221

  
222 162
    /**
223 163
     * Test method for {@link eu.etaxonomy.cdm.persistence.dao.hibernate.taxon.TaxonDaoHibernateImpl#getTaxaByName(java.lang.String, eu.etaxonomy.cdm.model.reference.Reference)}.
224 164
     */
......
790 730
//        }
791 731
    }
792 732

  
793
    @Test
794
    @DataSet
795
    public void testDeleteWithChildren() {
796
        Taxon taxonWithChildren = (Taxon)taxonDao.findByUuid(mimas);
797
        assert taxonWithChildren != null : "taxon must exist";
798
        assertEquals(taxonWithChildren.getTaxonomicChildrenCount(), 2);
799
        Taxon parent = (Taxon)taxonDao.findByUuid(sphingidae);
800
        assertSame(taxonWithChildren.getTaxonomicParent(), parent);
801
        assertEquals(parent.getTaxonomicChildrenCount(), 204);
802
        taxonDao.delete(taxonWithChildren);
803
        assertEquals(parent.getTaxonomicChildrenCount(), 203);
804
    }
805

  
806 733
    @Test
807 734
    @DataSet("TaxonDaoHibernateImplTest.testFindDeleted.xml")
808 735
    public void testFindDeleted() {
......
929 856
        Taxon taxon = (Taxon)taxonDao.findByUuid(acherontiaLachesis);
930 857
        assert taxon != null : "taxon cannot be null";
931 858

  
932
        assertEquals("getTaxonomicChildrenCount should return 1 in this view",1,taxon.getTaxonomicChildrenCount());
933
        assertEquals("getRelationsToThisTaxon should contain 1 TaxonRelationship in this view",1,taxon.getRelationsToThisTaxon().size());
859
       assertEquals("getRelationsToThisTaxon should contain 1 TaxonRelationship in this view",1,taxon.getRelationsToThisTaxon().size());
934 860
    }
935 861

  
936 862
    @Test
......
940 866
        Taxon taxon = (Taxon)taxonDao.findByUuid(acherontiaLachesis);
941 867
        assert taxon != null : "taxon cannot be null";
942 868

  
943
        assertEquals("getTaxonomicChildrenCount should return 0 in this view",0,taxon.getTaxonomicChildrenCount());
944 869
        assertTrue("getRelationsToThisTaxon should contain 0 TaxonRelationship in this view",taxon.getRelationsToThisTaxon().isEmpty());
945 870
    }
946 871

  

Also available in: Unified diff