Project

General

Profile

Revision 2f495573

ID2f4955731bf6c50c5e03a965715fd56a3eb87b24
Parent 889c7e91
Child 4cae9071

Added by Patrick Plitzner almost 3 years ago

ref #6045 Add test for getAncestor()

View differences:

cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/taxon/TaxonNodeTest.java
316 316
		assertEquals("Number of all nodes should be 2", 2, allNodes.size());
317 317
		assertTrue("Taxonomic view should include child", allNodes.contains(child));
318 318
	}
319
	
320

  
321
    
322
    @Test
323
    public void testGetAncestors(){
324
    	/*
325
    	 * Classification
326
    	 *  * Pinus
327
    	 *  `- Pinus pampa
328
    	 *   `- Pinus pampa subsp. persicifolia
329
    	 */
330
    	Classification classification = Classification.NewInstance("Classification");
331
    	BotanicalName pinusName = BotanicalName.NewInstance(null);
332
    	pinusName.setGenusOrUninomial("Pinus");
333
    	Taxon pinus = Taxon.NewInstance(pinusName, null);
334
    	BotanicalName pinusPampaName = BotanicalName.NewInstance(null);
335
    	pinusPampaName.setGenusOrUninomial("Pinus");
336
    	pinusPampaName.setSpecificEpithet("pampa");
337
    	Taxon pinusPampa = Taxon.NewInstance(pinusPampaName, null);
338
    	BotanicalName pinusPampaSubName = BotanicalName.NewInstance(null);
339
    	pinusPampaSubName.setGenusOrUninomial("Pinus");
340
    	pinusPampaSubName.setSpecificEpithet("pampa");
341
    	pinusPampaSubName.setInfraSpecificEpithet("persicifolia");
342
    	Taxon pinusPampaSub = Taxon.NewInstance(pinusPampaSubName, null);
343

  
344
    	TaxonNode pinusNode = classification.addChildTaxon(pinus, null, null);
345
    	TaxonNode pinusPampaNode = classification.addParentChild(pinus, pinusPampa, null, null);
346
    	TaxonNode pinusPampaSubNode = classification.addParentChild(pinusPampa, pinusPampaSub, null, null);
347
    	TaxonNode rootNode = classification.getRootNode();
348
    	
349
    	Set<TaxonNode> ancestors = pinusPampaSubNode.getAncestors();
350
    	assertEquals(3, ancestors.size());
351
    	assertTrue(ancestors.contains(pinusPampaNode));
352
    	assertTrue(ancestors.contains(pinusNode));
353
    	assertTrue(ancestors.contains(rootNode));
354
    	
355
    	Set<TaxonNode> rootAncestors = rootNode.getAncestors();
356
    	assertTrue(rootAncestors.isEmpty());
357
    	
358
    }
319 359

  
320 360
    @Test
321 361
    public void beanTests(){

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)