Project

General

Profile

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

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

    
14
import java.io.FileNotFoundException;
15
import java.util.Set;
16
import java.util.UUID;
17

    
18
import org.apache.log4j.Logger;
19
import org.junit.Test;
20
import org.unitils.dbunit.annotation.DataSet;
21
import org.unitils.dbunit.annotation.ExpectedDataSet;
22
import org.unitils.spring.annotation.SpringBeanByType;
23

    
24
import eu.etaxonomy.cdm.api.service.IClassificationService;
25
import eu.etaxonomy.cdm.api.service.IDescriptionService;
26
import eu.etaxonomy.cdm.api.service.INameService;
27
import eu.etaxonomy.cdm.api.service.IReferenceService;
28
import eu.etaxonomy.cdm.api.service.ITaxonService;
29
import eu.etaxonomy.cdm.api.service.TaxonServiceImplTest;
30
import eu.etaxonomy.cdm.datagenerator.TaxonGenerator;
31
import eu.etaxonomy.cdm.model.description.TaxonDescription;
32
import eu.etaxonomy.cdm.model.taxon.Taxon;
33
import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;
34

    
35
/**
36
 * test for the {@link FirstDataInserter}
37
 *
38
 * @author a.kohlbecker
39
 * @date Oct 12, 2012
40
 *
41
 */
42
@DataSet
43
public class FirstDataInserterTest extends CdmTransactionalIntegrationTest {
44

    
45
    private final String[] tableNames = new String[]{"USERACCOUNT", "USERACCOUNT_GRANTEDAUTHORITYIMPL", "GRANTEDAUTHORITYIMPL", "CDMMETADATA"};
46

    
47
    @SuppressWarnings("unused")
48
	private static final Logger logger = Logger.getLogger(TaxonServiceImplTest.class);
49

    
50
    @SpringBeanByType
51
    private ITaxonService taxonService;
52

    
53
    @SpringBeanByType
54
    private INameService nameService;
55

    
56
    @SpringBeanByType
57
    private IReferenceService referenceService;
58

    
59
    @SpringBeanByType
60
    private IClassificationService classificationService;
61

    
62
    @SpringBeanByType
63
    private IDescriptionService descriptionService;
64

    
65
    @Test
66
    @DataSet(value="FirstDataInserterTest.testBlankDB.xml")
67
    @ExpectedDataSet(value="FirstDataInserterTest.testBlankDB-result.xml")
68
    public void testBlankDB(){
69

    
70
        commitAndStartNewTransaction(null);
71
//        printDataSet(System.err, tableNames);
72
    }
73

    
74
    @Test
75
    @DataSet(value="FirstDataInserterTest.testBlankDB.xml")
76
    public void testInsertData(){
77
    	commitAndStartNewTransaction(null);
78
    	TaxonGenerator.getTestTaxon();
79
    	Taxon newTaxon = TaxonGenerator.getTestTaxon();
80
    	UUID taxonUUID = taxonService.save(newTaxon).getUuid();
81

    
82
    	TaxonDescription description = TaxonGenerator.getTestDescription(1);
83
    	newTaxon.addDescription(description);
84
    	Set<TaxonDescription> descriptions = newTaxon.getDescriptions();
85
    	descriptionService.save(description);
86
    	newTaxon = null;
87
    	newTaxon = (Taxon)taxonService.find(taxonUUID);
88
    	descriptions = newTaxon.getDescriptions();
89
    	assertEquals(2, descriptions.size());
90
    }
91

    
92

    
93
    @Override
94
    public void createTestDataSet() throws FileNotFoundException {
95
        // TODO Auto-generated method stub
96
    }
97

    
98
}
    (1-1/1)