1
|
/**
|
2
|
* Copyright (C) 2012 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.api.application;
|
10
|
|
11
|
import static org.junit.Assert.assertEquals;
|
12
|
|
13
|
import java.io.FileNotFoundException;
|
14
|
import java.util.Set;
|
15
|
import java.util.UUID;
|
16
|
|
17
|
import org.apache.log4j.Logger;
|
18
|
import org.junit.Ignore;
|
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
|
\* @since 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
|
@Ignore
|
77
|
public void testInsertData(){
|
78
|
commitAndStartNewTransaction(null);
|
79
|
|
80
|
Taxon newTaxon = TaxonGenerator.getTestTaxon();
|
81
|
UUID taxonUUID = taxonService.save(newTaxon).getUuid();
|
82
|
|
83
|
TaxonDescription description = TaxonGenerator.getTestDescription(1);
|
84
|
newTaxon.addDescription(description);
|
85
|
Set<TaxonDescription> descriptions = newTaxon.getDescriptions();
|
86
|
descriptionService.save(description);
|
87
|
|
88
|
newTaxon = null;
|
89
|
newTaxon = (Taxon)taxonService.find(taxonUUID);
|
90
|
descriptions = newTaxon.getDescriptions();
|
91
|
assertEquals(2, descriptions.size());
|
92
|
}
|
93
|
|
94
|
|
95
|
@Override
|
96
|
public void createTestDataSet() throws FileNotFoundException {
|
97
|
// TODO Auto-generated method stub
|
98
|
}
|
99
|
|
100
|
}
|