Project

General

Profile

Download (22.2 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2009 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.persistence.dao.hibernate.taxon;
10

    
11
import static org.junit.Assert.assertEquals;
12
import static org.junit.Assert.assertNotNull;
13
import static org.junit.Assert.assertNull;
14
import static org.junit.Assert.assertTrue;
15

    
16
import java.io.FileNotFoundException;
17
import java.util.ArrayList;
18
import java.util.Arrays;
19
import java.util.Comparator;
20
import java.util.HashSet;
21
import java.util.List;
22
import java.util.Map;
23
import java.util.Set;
24
import java.util.UUID;
25

    
26
import org.hibernate.proxy.HibernateProxy;
27
import org.junit.After;
28
import org.junit.Assert;
29
import org.junit.Before;
30
import org.junit.Test;
31
import org.unitils.dbunit.annotation.DataSet;
32
import org.unitils.dbunit.annotation.ExpectedDataSet;
33
import org.unitils.spring.annotation.SpringBeanByType;
34

    
35
import eu.etaxonomy.cdm.compare.taxon.TaxonNodeSortMode;
36
import eu.etaxonomy.cdm.model.agent.Person;
37
import eu.etaxonomy.cdm.model.common.CdmBase;
38
import eu.etaxonomy.cdm.model.common.Language;
39
import eu.etaxonomy.cdm.model.common.LanguageString;
40
import eu.etaxonomy.cdm.model.name.Rank;
41
import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
42
import eu.etaxonomy.cdm.model.taxon.Classification;
43
import eu.etaxonomy.cdm.model.taxon.Taxon;
44
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
45
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
46
import eu.etaxonomy.cdm.model.taxon.TaxonNodeAgentRelation;
47
import eu.etaxonomy.cdm.model.taxon.TaxonNodeStatus;
48
import eu.etaxonomy.cdm.model.term.DefinedTerm;
49
import eu.etaxonomy.cdm.model.view.context.AuditEventContextHolder;
50
import eu.etaxonomy.cdm.persistence.dao.taxon.IClassificationDao;
51
import eu.etaxonomy.cdm.persistence.dao.taxon.ITaxonDao;
52
import eu.etaxonomy.cdm.persistence.dao.taxon.ITaxonNodeDao;
53
import eu.etaxonomy.cdm.persistence.dao.term.IDefinedTermDao;
54
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
55
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
56
import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;
57

    
58
public class TaxonNodeDaoHibernateImplTest extends CdmTransactionalIntegrationTest {
59

    
60
    private static final UUID ClassificationUuid = UUID.fromString("aeee7448-5298-4991-b724-8d5b75a0a7a9");
61

    
62
	@SpringBeanByType
63
    private ITaxonNodeDao taxonNodeDao;
64

    
65
    @SpringBeanByType
66
    private IClassificationDao classificationDao;
67

    
68
    @SpringBeanByType
69
    private ITaxonDao taxonDao;
70

    
71
    @SpringBeanByType
72
    private IDefinedTermDao termDao;
73

    
74
    private final UUID uuid1 = UUID.fromString("0b5846e5-b8d2-4ca9-ac51-099286ea4adc");
75
    private final UUID uuid2 = UUID.fromString("770239f6-4fa8-496b-8738-fe8f7b2ad519");
76
    private final UUID uuid3  = UUID.fromString("20c8f083-5870-4cbd-bf56-c5b2b98ab6a7");
77
    private final UUID classificationUuid = UUID.fromString("aeee7448-5298-4991-b724-8d5b75a0a7a9");
78

    
79
    boolean includeUnpublished;
80

    
81
    private static final UUID ACHERONTIA_UUID = UUID.fromString("3b2b3e17-5c4a-4d1b-aa39-349f63100d6b");
82
    private static final UUID ACHERONTIA_LACHESIS = UUID.fromString("bc09aca6-06fd-4905-b1e7-cbf7cc65d783");
83
    private static final UUID NODE_ACHERONTIA_UUID = UUID.fromString("20c8f083-5870-4cbd-bf56-c5b2b98ab6a7");
84

    
85
    private static final List<String> CLASSIFICATION_INIT_STRATEGY = Arrays.asList(new String[]{
86
            "rootNode"
87
    });
88
    private static final List<String> TAXONNODE_INIT_STRATEGY = Arrays.asList(new String[]{
89
            "taxon",
90
            "childNodes"
91
    });
92

    
93
    @Before
94
    public void setUp(){
95
        AuditEventContextHolder.clearContext();
96
        includeUnpublished = true;
97
    }
98

    
99
    @After
100
    public void tearDown(){
101
        AuditEventContextHolder.clearContext();
102
    }
103

    
104
    @Test
105
    @DataSet
106
    public void testInit() {
107
        assertNotNull("Instance of ITaxonDao expected",taxonNodeDao);
108
        assertNotNull("Instance of IReferenceDao expected",classificationDao);
109
    }
110

    
111
    @Test
112
    @DataSet
113
    public void testFindByUuid() {
114
        TaxonNode taxonNode = taxonNodeDao.findByUuid(uuid1);
115
        Classification.class.getDeclaredConstructors();
116
        assertNotNull("findByUuid should return a taxon node", taxonNode);
117
    }
118

    
119
    @Test
120
    @DataSet
121
    public void testClassification() {
122

    
123
        Classification classification =  classificationDao.load(ClassificationUuid, CLASSIFICATION_INIT_STRATEGY);
124

    
125
        assertNotNull("findByUuid should return a taxon tree", classification);
126
        assertNotNull("classification should have a name",classification.getName());
127
        assertEquals("classification should have a name which is 'Name'",classification.getName().getText(),"Name");
128
        TaxonNode taxNode = taxonNodeDao.load(uuid1,TAXONNODE_INIT_STRATEGY);
129
        TaxonNode taxNode2 = taxonNodeDao.load(uuid2,TAXONNODE_INIT_STRATEGY);
130

    
131
        TaxonNode taxNode3 = taxonNodeDao.load(uuid3, TAXONNODE_INIT_STRATEGY);
132

    
133
        @SuppressWarnings("rawtypes")
134
        List<TaxonBase> taxa = taxonDao.list(10, 0);
135
        assertEquals("there should be 7 taxa", 7, taxa.size());
136
        taxNode3 = CdmBase.deproxy(taxNode3);
137
        taxNode = CdmBase.deproxy(taxNode);
138
        taxNode2 = CdmBase.deproxy(taxNode2);
139
        TaxonNode rootNode = CdmBase.deproxy(classification.getRootNode());
140
        TaxonNode newNode = rootNode.addChildTaxon(Taxon.NewInstance(TaxonNameFactory.NewBotanicalInstance(Rank.GENUS()), null), null, null);
141
        taxonNodeDao.saveOrUpdate(newNode);
142
        taxonNodeDao.delete(taxNode3, true);
143

    
144
        assertNull(taxonNodeDao.findByUuid(taxNode3.getUuid()));
145
        classification = classificationDao.findByUuid(ClassificationUuid);
146

    
147
        taxa = taxonDao.list(10, 0);
148
        // There should be 4 taxonBases: at the beginning 6 in the classification + 1 orphan taxon;
149
        //1 new created taxon -> 8: delete node3 deleted 4 taxa -> 4 taxa left.
150
        assertEquals("there should be 4 taxa left", 4, taxa.size());
151

    
152
        classificationDao.delete(classification);
153
        classification = null;
154

    
155
       // classificationDao.flush();
156
        classification = classificationDao.findByUuid(ClassificationUuid);
157
        assertEquals("The tree should be null", null, classification);
158
    }
159

    
160
    @Test
161
    @DataSet
162
    public void testListChildren(){
163
        boolean includeUnpublished;
164
        Taxon t_acherontia = (Taxon) taxonDao.load(ACHERONTIA_UUID);
165
        TaxonNode subtree = null;
166
        includeUnpublished = true;
167

    
168
        Classification classification =  classificationDao.load(ClassificationUuid);
169
        List<TaxonNode> children = classificationDao.listChildrenOf(
170
                t_acherontia, classification, subtree, includeUnpublished, null, null, null);
171
        assertNotNull(children);
172
        assertEquals(2, children.size());
173

    
174
        includeUnpublished = false;
175
        children = classificationDao.listChildrenOf(
176
                t_acherontia, classification, subtree, includeUnpublished, null, null, null);
177
        assertNotNull(children);
178
        assertEquals(1, children.size()); //1 is unpublished
179

    
180
        includeUnpublished = true;
181
        TaxonNode t_acherontia_node = taxonNodeDao.load(NODE_ACHERONTIA_UUID);
182
        children =taxonNodeDao.listChildrenOf(t_acherontia_node, null, null, true, includeUnpublished, null, null);
183
        assertNotNull(children);
184
        assertEquals(3, children.size());
185
        //with comparator
186
        Comparator<TaxonNode> comparator = TaxonNodeSortMode.RankAndAlphabeticalOrder.comparator();
187
        children =taxonNodeDao.listChildrenOf(t_acherontia_node, null, null, true, includeUnpublished, null, comparator);
188
        assertEquals("Size should be same as without comparator", 3, children.size());
189
        //not recursive
190
        children =taxonNodeDao.listChildrenOf(t_acherontia_node, null, null, true, includeUnpublished, null, null);
191
        assertEquals("Size should be same as recursive", 3, children.size());
192

    
193
        includeUnpublished = false;
194
        children =taxonNodeDao.listChildrenOf(t_acherontia_node, null, null, true, includeUnpublished, null, null);
195
        assertNotNull(children);
196
        assertEquals(2, children.size()); //1 is unpublished
197
    }
198

    
199
    @Test
200
    @DataSet
201
    public void testListSiblings(){
202
        Taxon t_acherontia_lachesis = (Taxon) taxonDao.load(ACHERONTIA_LACHESIS);
203

    
204
        Classification classification =  classificationDao.load(ClassificationUuid);
205
        long count = classificationDao.countSiblingsOf(t_acherontia_lachesis, classification, includeUnpublished);
206
        assertEquals(2, count);
207
        List<TaxonNode> siblings = classificationDao.listSiblingsOf(
208
                t_acherontia_lachesis, classification, includeUnpublished, null, null, null);
209
        assertNotNull(siblings);
210
        assertEquals(2, siblings.size());
211
    }
212

    
213
    @Test
214
    @DataSet
215
    public void testGetAllTaxaByClassification(){
216
        Classification classification =  classificationDao.load(ClassificationUuid, CLASSIFICATION_INIT_STRATEGY);
217

    
218
        assertNotNull("findByUuid should return a taxon tree", classification);
219
        assertNotNull("classification should have a name",classification.getName());
220
        assertEquals("classification should have a name which is 'Name'",classification.getName().getText(),"Name");
221
        TaxonNode taxNode = taxonNodeDao.load(uuid1,TAXONNODE_INIT_STRATEGY);
222
        TaxonNode taxNode2 = taxonNodeDao.load(uuid2,TAXONNODE_INIT_STRATEGY);
223

    
224
        TaxonNode taxNode3 = taxonNodeDao.load(uuid3, TAXONNODE_INIT_STRATEGY);
225
        Taxon taxon = Taxon.NewInstance(TaxonNameFactory.NewBotanicalInstance(Rank.GENUS()), null);
226
        Taxon taxon1 = Taxon.NewInstance(TaxonNameFactory.NewBotanicalInstance(Rank.GENUS()), null);
227
        Taxon taxon2 = Taxon.NewInstance(TaxonNameFactory.NewBotanicalInstance(Rank.GENUS()), null);
228
        TaxonNode child = taxNode.addChildTaxon(taxon, null, null);
229
        UUID childUuid = taxonNodeDao.saveOrUpdate(child);
230
        child = taxonNodeDao.load(childUuid);
231
        assertNotNull(child);
232
        child = taxNode2.addChildTaxon(taxon1, null, null);
233
        taxonNodeDao.saveOrUpdate(child);
234
        child = taxNode3.addChildTaxon(taxon2, null, null);
235
        taxonNodeDao.saveOrUpdate(child);
236

    
237
        List<TaxonNode> taxas = taxonNodeDao.getTaxonOfAcceptedTaxaByClassification(classification, null, null);
238
        assertEquals("there should be 7 taxa left", 7, taxas.size());
239
        commitAndStartNewTransaction(null);
240

    
241
        taxas = taxonNodeDao.getTaxonOfAcceptedTaxaByClassification(classification, 0, 10);
242
        logger.info(taxas.size());
243
        assertEquals("there should be 7 taxa left", 7, taxas.size());
244

    
245
        int countTaxa = taxonNodeDao.countTaxonOfAcceptedTaxaByClassification(classification);
246
        logger.info(countTaxa);
247
        assertEquals("there should be 7 taxa left", 7, countTaxa);
248
    }
249

    
250
    @Test
251
    @DataSet(value="TaxonNodeDaoHibernateImplTest.testSortindexForHibernateProxy.xml")
252
    @ExpectedDataSet("TaxonNodeDaoHibernateImplTest.testSortindexForHibernateProxy-result.xml")
253
    //test if TaxonNode.remove(index) works correctly with proxies
254
    public void testSortindexForHibernateProxy(){
255
    	Taxon taxonWithLazyLoadedParentNodeOnTopLevel = (Taxon)taxonDao.findByUuid(UUID.fromString("bc09aca6-06fd-4905-b1e7-cbf7cc65d783"));
256
    	TaxonNode parent = taxonWithLazyLoadedParentNodeOnTopLevel.getTaxonNodes().iterator().next().getParent();
257
    	Assert.assertTrue("Parent node must be proxy, otherwise test does not work", parent instanceof HibernateProxy);
258
    	Taxon firstTopLevelTaxon = (Taxon)taxonDao.findByUuid(UUID.fromString("7b8b5cb3-37ba-4dba-91ac-4c6ffd6ac331"));
259
    	Classification classification = classificationDao.findByUuid(ClassificationUuid);
260
    	TaxonNode childNode = classification.addParentChild(taxonWithLazyLoadedParentNodeOnTopLevel, firstTopLevelTaxon, null, null);
261
    	this.taxonNodeDao.saveOrUpdate(childNode);
262
    	commitAndStartNewTransaction( new String[]{"TaxonNode"});
263
    }
264

    
265
    @Test
266
    @DataSet(value="TaxonNodeDaoHibernateImplTest.testSortindexForHibernateProxy.xml")
267
    @ExpectedDataSet("TaxonNodeDaoHibernateImplTest.testSortindexForHibernateProxy2-result.xml")
268
    //test if TaxonNode.addNode(node) works correctly with proxies
269
    public void testSortindexForHibernateProxy2(){
270
    	Taxon taxonWithLazyLoadedParentNodeOnTopLevel = (Taxon)taxonDao.findByUuid(UUID.fromString("bc09aca6-06fd-4905-b1e7-cbf7cc65d783"));
271
    	TaxonNode parent = taxonWithLazyLoadedParentNodeOnTopLevel.getTaxonNodes().iterator().next().getParent();
272
    	Assert.assertTrue("Parent node must be proxy, otherwise test does not work", parent instanceof HibernateProxy);
273
    	Taxon newTaxon = Taxon.NewInstance(null, null);
274
    	Classification classification = classificationDao.findByUuid(ClassificationUuid);
275
    	TaxonNode newNode = classification.addChildTaxon(newTaxon, 0, null, null);
276
    	newNode.setUuid(UUID.fromString("58728644-1155-4520-98f7-309fdb62abd7"));
277
    	this.taxonNodeDao.saveOrUpdate(newNode);
278
    	commitAndStartNewTransaction( new String[]{"TaxonNode"});
279
    }
280

    
281
    @Test
282
    public void testSaveAndLoadTaxonNodeAgentRelation(){
283
        Classification classification = Classification.NewInstance("Me");
284
        Taxon taxon = Taxon.NewInstance(null, null);
285
        Person person = Person.NewInstance();
286
        TaxonNode node = classification.addChildTaxon(taxon, null, null);
287
        DefinedTerm lastScrutiny = (DefinedTerm)termDao.findByUuid(DefinedTerm.uuidLastScrutiny);
288
        TaxonNodeAgentRelation rel = node.addAgentRelation(lastScrutiny, person);
289
        taxonNodeDao.save(node);
290
        commitAndStartNewTransaction(null);
291

    
292
        TaxonNode newNode = taxonNodeDao.load(node.getUuid());
293
        Assert.assertNotSame(node, newNode);
294
        Assert.assertEquals("Node should have agent relation", 1, newNode.getAgentRelations().size());
295
        TaxonNodeAgentRelation newRel = newNode.getAgentRelations().iterator().next();
296
        Assert.assertEquals(rel, newRel);
297
        Assert.assertEquals(rel.getId(), newRel.getId());
298
        Assert.assertNotSame(rel, newRel);
299
    }
300

    
301
    //see comment 7 in #6199
302
    @Test
303
    @DataSet
304
    public void testPersistExcludedInfos(){
305
        //test read
306
        TaxonNode excludedNode = taxonNodeDao.load(UUID.fromString("4f73adcc-a535-4fbe-a97a-c05ee8b12191"));
307
        Assert.assertTrue("Node should be excluded", excludedNode.isExcluded());
308
        TaxonNode unplacedNode = taxonNodeDao.load(UUID.fromString("20c8f083-5870-4cbd-bf56-c5b2b98ab6a7"));
309
        Assert.assertTrue("Node should be unplaced", unplacedNode.isUnplaced());
310
        TaxonNode notSpecialNode = taxonNodeDao.load(UUID.fromString("770239f6-4fa8-496b-8738-fe8f7b2ad519"));
311
        Assert.assertFalse("Node should be neither excluded nor unplaced", notSpecialNode.isUnplaced() || notSpecialNode.isExcluded());
312

    
313
        //read excluded node
314
        Map<Language, LanguageString> map = excludedNode.getStatusNote();
315
        Assert.assertEquals(2, map.size());
316
        Set<Integer> langIds = new HashSet<>();
317
        for (Language lang : map.keySet()){
318
            langIds.add(lang.getId());
319
        }
320
        Assert.assertTrue("Excluded note must contain text for language id = 1", langIds.contains(1));
321
        Assert.assertTrue("", langIds.contains(2));
322
    }
323

    
324
    @Test
325
    @DataSet ("TaxonDaoHibernateImplTest.testGetTaxaByNameAndArea.xml")
326
    public final void testGetTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(){
327
        Classification classification = classificationDao.findByUuid(classificationUuid);
328
        List<UuidAndTitleCache<TaxonNode>> result = taxonNodeDao.getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(classification,  null, null, true);
329
        assertNotNull(result);
330
        assertEquals(7, result.size());
331

    
332
        //test exclude
333
        UUID excludeUUID = UUID.fromString("a9f42927-e507-4fda-9629-62073a908aae");
334
        List<UUID> excludeUUids = new ArrayList<>();
335
        excludeUUids.add(excludeUUID);
336
        result = taxonNodeDao.getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(classification,  null, null, false);
337
        assertEquals(6, result.size());
338

    
339
        //test limit
340
        int limit = 2;
341
        result = taxonNodeDao.getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(classification,  limit, null, false);
342
        assertEquals(2, result.size());
343

    
344
        //test pattern
345
        String pattern = "*Rothschi*";
346
        result = taxonNodeDao.getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(classification, 2, pattern, true);
347
        assertNotNull(result);
348
        assertEquals(1, result.size());
349
        assertEquals("0b5846e5-b8d2-4ca9-ac51-099286ea4adc", result.get(0).getUuid().toString());
350

    
351
        //test pattern
352
        pattern = "*TestBaum*";
353
        result = taxonNodeDao.getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(classification, null, pattern, true);
354
        assertNotNull(result);
355
        assertEquals(1, result.size());
356
        assertEquals("6d6b43aa-3a77-4be5-91d0-00b702fc5d6e", result.get(0).getUuid().toString());
357
    }
358

    
359
    @Test
360
    @DataSet ("TaxonDaoHibernateImplTest.testGetTaxaByNameAndArea.xml")
361
    public final void testGetTaxonNodeUuidAndTitleCache(){
362
        String pattern = "";
363
        List<TaxonNodeDto> result = taxonNodeDao.getUuidAndTitleCache(100, pattern, classificationUuid, true);
364
        assertNotNull(result);
365
        assertEquals(6, result.size());
366

    
367
        //test limit
368
        int limit = 2;
369
        result = taxonNodeDao.getUuidAndTitleCache(limit, pattern, classificationUuid, true);
370
        assertEquals(2, result.size());
371

    
372
        //test pattern & classification
373
        pattern = "*Rothschi*";
374
        result = taxonNodeDao.getUuidAndTitleCache(100, pattern, classificationUuid, true);
375
        assertNotNull(result);
376
        assertEquals(1, result.size());
377
        assertEquals("0b5846e5-b8d2-4ca9-ac51-099286ea4adc", result.get(0).getUuid().toString());
378

    
379
        //test pattern without classification
380
        pattern = "*Rothschi*";
381
        result = taxonNodeDao.getUuidAndTitleCache(100, pattern, null, true);
382
        assertNotNull(result);
383
        assertEquals(2, result.size());
384

    
385
        //test doubtful & pattern
386
        pattern = "Aus*";
387
        result = taxonNodeDao.getUuidAndTitleCache(100, pattern, classificationUuid, true);
388
        assertNotNull(result);
389
        assertEquals(1, result.size());
390
        assertEquals("ebf8ea46-9f24-47be-8fb5-02bd67f90348", result.get(0).getUuid().toString());
391
    }
392

    
393
    @Test
394
    @DataSet ("TaxonNodeDaoHibernateImplTest.findWithoutRank.xml")
395
    public final void testGetTaxonNodeUuidAndTitleCacheOfacceptedTaxaByClassificationForNameWithoutRank(){
396
        //test name without rank
397
        Classification classification = classificationDao.findByUuid(ClassificationUuid);
398
        String pattern = "Acherontia kohlbeckeri*";
399
        List<UuidAndTitleCache<TaxonNode>> result = taxonNodeDao.getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(classification, null, pattern, true);
400
        assertNotNull(result);
401
        assertEquals(1, result.size());
402
        assertEquals("4f73adcc-a535-4fbe-a97a-c05ee8b12191", result.get(0).getUuid().toString()); // titleCache:Acherontia kohlbeckeri rank: Unknown Rank
403
    }
404

    
405
    @Test
406
    @DataSet ("TaxonNodeDaoHibernateImplTest.findWithoutRank.xml")
407
    public final void testGetTaxonNodeDtoWithoutRank(){
408

    
409
        List<TaxonNodeDto> result = taxonNodeDao.getTaxonNodeDto(null, "", null); // cant use "*" here since this is not supported by the method under test
410
        assertNotNull(result);
411
        assertEquals(5, result.size());
412
        assertEquals("20c8f083-5870-4cbd-bf56-c5b2b98ab6a7", result.get(0).getUuid().toString()); // Acherontia(Fabricius, 1798) rank: Genus
413
        assertEquals("0b5846e5-b8d2-4ca9-ac51-099286ea4adc", result.get(1).getUuid().toString()); // titleCache:Acherontia lachesis (Fabricius, 1798) rank: Species
414
        assertEquals("770239f6-4fa8-496b-8738-fe8f7b2ad519", result.get(2).getUuid().toString()); // titleCache:Acherontia styx Westwood, 1847 sec. cate-sphingidae.org rank: Species
415
        assertEquals("4f73adcc-a535-4fbe-a97a-c05ee8b12191", result.get(3).getUuid().toString()); // titleCache:Acherontia kohlbeckeri rank: Unknown Rank
416
    }
417
    
418
    @Test
419
    @DataSet ("TaxonNodeDaoHibernateImplTest.findWithoutRank.xml")
420
    public final void testGetTaxonNodeDtoCheckSortIndex(){
421

    
422
        List<TaxonNodeDto> result = taxonNodeDao.getTaxonNodeDto(null, "", null); 
423
        assertEquals(5, result.size());
424
       
425
        assertTrue(0 == result.get(0).getSortIndex()); // Acherontia(Fabricius, 1798) rank: Genus
426
        assertTrue(0 == result.get(1).getSortIndex()); // titleCache:Acherontia lachesis (Fabricius, 1798) rank: Species
427
        assertTrue(1 == result.get(2).getSortIndex()); // titleCache:Acherontia styx Westwood, 1847 sec. cate-sphingidae.org rank: Species
428
        assertTrue(0 == result.get(3).getSortIndex()); // titleCache:Acherontia kohlbeckeri rank: Unknown Rank
429
    
430
    
431
    }
432
    
433
    @Test
434
    @DataSet ("TaxonNodeDaoHibernateImplTest.findWithoutRank.xml")
435
    public final void testGetTaxonNodeDtoCheckStatus(){
436

    
437
        List<TaxonNodeDto> result = taxonNodeDao.getTaxonNodeDto(null, "", null); 
438
        assertEquals(5, result.size());
439
       
440
        assertEquals(TaxonNodeStatus.UNPLACED, result.get(0).getStatus()); // Acherontia(Fabricius, 1798) rank: Genus
441
        assertEquals(null, result.get(1).getStatus());  // titleCache:Acherontia lachesis (Fabricius, 1798) rank: Species
442
        assertEquals(null, result.get(2).getStatus());  // titleCache:Acherontia styx Westwood, 1847 sec. cate-sphingidae.org rank: Species
443
        assertEquals(TaxonNodeStatus.EXCLUDED, result.get(3).getStatus());  // titleCache:Acherontia kohlbeckeri rank: Unknown Rank
444
    
445
    
446
    }
447

    
448
    @Test
449
    @DataSet ("TaxonNodeDaoHibernateImplTest.findWithoutRank.xml")
450
    public final void testGetTaxonNodeDtoCheckNote(){
451

    
452
        List<TaxonNodeDto> result = taxonNodeDao.getTaxonNodeDto(null, "", null);
453
        assertEquals(5, result.size());
454

    
455
        assertNotNull(result.get(3).getStatusNote()); // Acherontia(Fabricius, 1798) rank: Genus
456
        assertNotNull(result.get(4).getStatusNote());  // titleCache:Acherontia lachesis (Fabricius, 1798) rank: Species
457
//        assertEquals(null, result.get(2).getStatus());  // titleCache:Acherontia styx Westwood, 1847 sec. cate-sphingidae.org rank: Species
458
//        assertEquals(TaxonNodeStatus.EXCLUDED, result.get(3).getStatus());  // titleCache:Acherontia kohlbeckeri rank: Unknown Rank
459
//
460

    
461
    }
462

    
463

    
464
    @Override
465
    public void createTestDataSet() throws FileNotFoundException {}
466

    
467
}
(4-4/5)