1 |
1087be72
|
Andreas Müller
|
/**
|
2 |
|
|
* Copyright (C) 2007 EDIT
|
3 |
136e16b1
|
Andreas Müller
|
* European Distributed Institute of Taxonomy
|
4 |
1087be72
|
Andreas Müller
|
* http://www.e-taxonomy.eu
|
5 |
136e16b1
|
Andreas Müller
|
*
|
6 |
1087be72
|
Andreas Müller
|
* 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 |
|
|
|
10 |
|
|
package eu.etaxonomy.cdm.io.specimen.excel.in;
|
11 |
|
|
|
12 |
|
|
import static org.junit.Assert.assertEquals;
|
13 |
|
|
import static org.junit.Assert.assertNotNull;
|
14 |
|
|
import static org.junit.Assert.assertTrue;
|
15 |
|
|
|
16 |
d06ba760
|
Patric Plitzner
|
import java.io.FileNotFoundException;
|
17 |
1087be72
|
Andreas Müller
|
import java.net.URISyntaxException;
|
18 |
|
|
import java.net.URL;
|
19 |
|
|
|
20 |
|
|
import org.junit.Before;
|
21 |
|
|
import org.junit.Test;
|
22 |
98eccb8d
|
Andreas Müller
|
import org.unitils.dbunit.annotation.DataSet;
|
23 |
1087be72
|
Andreas Müller
|
import org.unitils.spring.annotation.SpringBeanByName;
|
24 |
|
|
import org.unitils.spring.annotation.SpringBeanByType;
|
25 |
|
|
|
26 |
|
|
import eu.etaxonomy.cdm.api.service.INameService;
|
27 |
|
|
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
|
28 |
|
|
import eu.etaxonomy.cdm.io.common.CdmApplicationAwareDefaultImport;
|
29 |
|
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator;
|
30 |
483579cd
|
Andreas Müller
|
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
|
31 |
c150ee7f
|
Andreas Müller
|
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
|
32 |
16879321
|
Andreas Müller
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
|
33 |
1087be72
|
Andreas Müller
|
import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;
|
34 |
|
|
|
35 |
|
|
/**
|
36 |
|
|
* @author a.mueller
|
37 |
|
|
* @created 29.01.2009
|
38 |
|
|
* @version 1.0
|
39 |
|
|
*/
|
40 |
136e16b1
|
Andreas Müller
|
//@Ignore("Test class is just a copy of the ABCD import test. It still needs to be adapted")
|
41 |
1087be72
|
Andreas Müller
|
public class ExcelImportConfiguratorTest extends CdmTransactionalIntegrationTest {
|
42 |
136e16b1
|
Andreas Müller
|
|
43 |
1087be72
|
Andreas Müller
|
@SpringBeanByName
|
44 |
|
|
CdmApplicationAwareDefaultImport<?> defaultImport;
|
45 |
|
|
|
46 |
|
|
@SpringBeanByType
|
47 |
|
|
INameService nameService;
|
48 |
|
|
|
49 |
|
|
@SpringBeanByType
|
50 |
|
|
IOccurrenceService occurrenceService;
|
51 |
|
|
|
52 |
136e16b1
|
Andreas Müller
|
|
53 |
1087be72
|
Andreas Müller
|
private IImportConfigurator configurator;
|
54 |
136e16b1
|
Andreas Müller
|
|
55 |
1087be72
|
Andreas Müller
|
@Before
|
56 |
16879321
|
Andreas Müller
|
public void setUp() throws URISyntaxException {
|
57 |
1087be72
|
Andreas Müller
|
String inputFile = "/eu/etaxonomy/cdm/io/specimen/excel/in/ExcelImportConfiguratorTest-input.xls";
|
58 |
|
|
URL url = this.getClass().getResource(inputFile);
|
59 |
|
|
assertNotNull("URL for the test file '" + inputFile + "' does not exist", url);
|
60 |
136e16b1
|
Andreas Müller
|
configurator = SpecimenSynthesysExcelImportConfigurator.NewInstance(url.toURI(), null, false);
|
61 |
1087be72
|
Andreas Müller
|
assertNotNull("Configurator could not be created", configurator);
|
62 |
|
|
}
|
63 |
136e16b1
|
Andreas Müller
|
|
64 |
1087be72
|
Andreas Müller
|
@Test
|
65 |
|
|
public void testInit() {
|
66 |
|
|
assertNotNull("import instance should not be null", defaultImport);
|
67 |
|
|
assertNotNull("nameService should not be null", nameService);
|
68 |
|
|
assertNotNull("occurence service should not be null", occurrenceService);
|
69 |
|
|
}
|
70 |
136e16b1
|
Andreas Müller
|
|
71 |
1087be72
|
Andreas Müller
|
@Test
|
72 |
98eccb8d
|
Andreas Müller
|
@DataSet("../../../BlankDataSet.xml")
|
73 |
1087be72
|
Andreas Müller
|
public void testDoInvoke() {
|
74 |
|
|
boolean result = defaultImport.invoke(configurator);
|
75 |
|
|
assertTrue("Return value for import.invoke should be true", result);
|
76 |
16879321
|
Andreas Müller
|
assertEquals("Number of TaxonNames should be 3", 3, nameService.count(null));
|
77 |
|
|
assertEquals("Number of specimen should be 6", 6, occurrenceService.count(SpecimenOrObservationBase.class));
|
78 |
483579cd
|
Andreas Müller
|
assertEquals("Number of specimen should be 3", 3, occurrenceService.count(DerivedUnit.class));
|
79 |
c150ee7f
|
Andreas Müller
|
assertEquals("Number of specimen should be 3", 3, occurrenceService.count(FieldUnit.class));
|
80 |
136e16b1
|
Andreas Müller
|
|
81 |
1087be72
|
Andreas Müller
|
}
|
82 |
|
|
|
83 |
d06ba760
|
Patric Plitzner
|
/* (non-Javadoc)
|
84 |
|
|
* @see eu.etaxonomy.cdm.test.integration.CdmIntegrationTest#createTestData()
|
85 |
|
|
*/
|
86 |
|
|
@Override
|
87 |
68ee041d
|
Patric Plitzner
|
public void createTestDataSet() throws FileNotFoundException {
|
88 |
d06ba760
|
Patric Plitzner
|
// TODO Auto-generated method stub
|
89 |
|
|
|
90 |
|
|
}
|
91 |
|
|
|
92 |
1087be72
|
Andreas Müller
|
}
|