Project

General

Profile

Revision 7fd3dd3f

ID7fd3dd3ff8a3fa9511e2fa5449b8969f7d11f443
Parent 018d16b7
Child c15d14cd

Added by Andreas Kohlbecker about 7 years ago

adating test to modified number of taxa

View differences:

cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonNodeDaoHibernateImplTest.java
9 9

  
10 10
package eu.etaxonomy.cdm.persistence.dao.hibernate.taxon;
11 11

  
12
import static org.junit.Assert.assertNotNull;
13 12
import static org.junit.Assert.assertEquals;
13
import static org.junit.Assert.assertNotNull;
14 14

  
15 15
import java.util.Arrays;
16
import java.util.HashSet;
17 16
import java.util.List;
18
import java.util.Set;
19 17
import java.util.UUID;
20 18

  
21 19
import org.junit.After;
......
27 25
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
28 26
import eu.etaxonomy.cdm.model.name.BotanicalName;
29 27
import eu.etaxonomy.cdm.model.name.Rank;
30
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
28
import eu.etaxonomy.cdm.model.taxon.Classification;
31 29
import eu.etaxonomy.cdm.model.taxon.Taxon;
32 30
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
33 31
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
34
import eu.etaxonomy.cdm.model.taxon.Classification;
35 32
import eu.etaxonomy.cdm.model.view.context.AuditEventContextHolder;
33
import eu.etaxonomy.cdm.persistence.dao.taxon.IClassificationDao;
36 34
import eu.etaxonomy.cdm.persistence.dao.taxon.ITaxonDao;
37 35
import eu.etaxonomy.cdm.persistence.dao.taxon.ITaxonNodeDao;
38
import eu.etaxonomy.cdm.persistence.dao.taxon.IClassificationDao;
39 36
import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;
40 37

  
41 38
public class TaxonNodeDaoHibernateImplTest extends CdmTransactionalIntegrationTest {
......
52 49
    private UUID uuid1;
53 50
    private UUID uuid2;
54 51
    private UUID uuid3;
55
    
52

  
56 53
    private static final List<String> CLASSIFICATION_INIT_STRATEGY = Arrays.asList(new String[]{
57 54
            "rootNode"
58 55
    });
59 56
    private static final List<String> TAXONNODE_INIT_STRATEGY = Arrays.asList(new String[]{
60
    		"taxon",
57
            "taxon",
61 58
            "childNodes"
62 59
    });
63 60

  
64 61
    @Before
65 62
    public void setUp(){
66
    	uuid1 = UUID.fromString("0b5846e5-b8d2-4ca9-ac51-099286ea4adc");
63
        uuid1 = UUID.fromString("0b5846e5-b8d2-4ca9-ac51-099286ea4adc");
67 64
        uuid3 = UUID.fromString("20c8f083-5870-4cbd-bf56-c5b2b98ab6a7");
68 65
        uuid2 = UUID.fromString("770239f6-4fa8-496b-8738-fe8f7b2ad519");
69 66
        AuditEventContextHolder.clearContext();
......
85 82
    @Test
86 83
    @DataSet
87 84
    public void testFindByUuid() {
88
        TaxonNode taxonNode = (TaxonNode) taxonNodeDao.findByUuid(uuid1);
85
        TaxonNode taxonNode = taxonNodeDao.findByUuid(uuid1);
89 86
        Classification.class.getDeclaredConstructors();
90 87
        assertNotNull("findByUuid should return a taxon node", taxonNode);
91 88
    }
......
93 90
    @Test
94 91
    @DataSet
95 92
    public void testClassification() {
96
    	
93

  
97 94
        Classification classification =  classificationDao.load(UUID.fromString("aeee7448-5298-4991-b724-8d5b75a0a7a9"), CLASSIFICATION_INIT_STRATEGY);
98 95

  
99 96
        assertNotNull("findByUuid should return a taxon tree", classification);
100 97
        assertNotNull("classification should have a name",classification.getName());
101 98
        assertEquals("classification should have a name which is 'Name'",classification.getName().getText(),"Name");
102
        TaxonNode taxNode = (TaxonNode) taxonNodeDao.load(uuid1,TAXONNODE_INIT_STRATEGY);
103
        TaxonNode taxNode2 = (TaxonNode) taxonNodeDao.load(uuid2,TAXONNODE_INIT_STRATEGY);
104
      
105
        TaxonNode taxNode3 = (TaxonNode) taxonNodeDao.load(uuid3, TAXONNODE_INIT_STRATEGY);
106
        
107
        
108
               
99
        TaxonNode taxNode = taxonNodeDao.load(uuid1,TAXONNODE_INIT_STRATEGY);
100
        TaxonNode taxNode2 = taxonNodeDao.load(uuid2,TAXONNODE_INIT_STRATEGY);
101

  
102
        TaxonNode taxNode3 = taxonNodeDao.load(uuid3, TAXONNODE_INIT_STRATEGY);
103

  
104

  
105

  
109 106
        List<TaxonBase> taxa = taxonDao.getAllTaxonBases(10, 0);
110
        assertEquals("there should be six taxa", 6, taxa.size());
107
        assertEquals("there should be 7 taxa", 7, taxa.size());
111 108
        taxNode3 = HibernateProxyHelper.deproxy(taxNode3, TaxonNode.class);
112 109
        taxNode = HibernateProxyHelper.deproxy(taxNode, TaxonNode.class);
113 110
        taxNode2 = HibernateProxyHelper.deproxy(taxNode2, TaxonNode.class);
......
115 112
        rootNode.addChildTaxon(Taxon.NewInstance(BotanicalName.NewInstance(Rank.GENUS()), null), null, null);
116 113
        taxonNodeDao.delete(taxNode3, true);
117 114
        classification = classificationDao.findByUuid(UUID.fromString("aeee7448-5298-4991-b724-8d5b75a0a7a9"));
115

  
118 116
        taxa = taxonDao.getAllTaxonBases(10, 0);
119
        assertEquals("there should be five taxa left", 6, taxa.size());
117
        assertEquals("there should be 7 taxa left", 7, taxa.size());
120 118
        taxonNodeDao.flush();
121
        classificationDao.delete(classification);  
119
        classificationDao.delete(classification);
122 120
        classification = null;
123
        
121

  
124 122
        classificationDao.flush();
125 123
        classification = classificationDao.findByUuid(UUID.fromString("aeee7448-5298-4991-b724-8d5b75a0a7a9"));
126 124
        assertEquals("The tree should be null", null, classification);

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)