1
|
/**
|
2
|
* Copyright (C) 2007 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
|
|
10
|
package eu.etaxonomy.cdm.io.sdd.in;
|
11
|
|
12
|
import static org.junit.Assert.assertNotNull;
|
13
|
|
14
|
import java.io.FileNotFoundException;
|
15
|
import java.net.URISyntaxException;
|
16
|
import java.net.URL;
|
17
|
import java.util.UUID;
|
18
|
|
19
|
import org.junit.Assert;
|
20
|
import org.junit.Before;
|
21
|
import org.junit.Test;
|
22
|
import org.unitils.dbunit.annotation.DataSet;
|
23
|
import org.unitils.dbunit.annotation.DataSets;
|
24
|
import org.unitils.spring.annotation.SpringBeanByType;
|
25
|
|
26
|
import eu.etaxonomy.cdm.api.service.IPolytomousKeyService;
|
27
|
import eu.etaxonomy.cdm.common.URI;
|
28
|
import eu.etaxonomy.cdm.io.sdd.ikeyplus.IkeyPlusImport;
|
29
|
import eu.etaxonomy.cdm.model.description.PolytomousKey;
|
30
|
import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;
|
31
|
|
32
|
public class IkeyPlusImportTest extends CdmTransactionalIntegrationTest {
|
33
|
|
34
|
@SpringBeanByType
|
35
|
private IkeyPlusImport ikeyPlusImport;
|
36
|
|
37
|
@SpringBeanByType
|
38
|
private IPolytomousKeyService polytomousKeyService;
|
39
|
|
40
|
private URI sddUri;
|
41
|
|
42
|
@Before
|
43
|
public void setUp() throws URISyntaxException {
|
44
|
String xxx = "/eu/etaxonomy/cdm/io/sdd/SDDImportTest-input.xml";
|
45
|
String yyy = "/eu/etaxonomy/cdm/io/sdd/Cichorieae-fullSDD.xml";
|
46
|
|
47
|
URL url = this.getClass().getResource(yyy);
|
48
|
URI uri = URI.fromUrl(url);
|
49
|
Assert.assertNotNull(url);
|
50
|
// configurator = SDDImportConfigurator.NewInstance(uri, null);
|
51
|
sddUri = uri;
|
52
|
}
|
53
|
|
54
|
@Test
|
55
|
public void testInit() {
|
56
|
assertNotNull("sddUri must not be null", sddUri);
|
57
|
}
|
58
|
|
59
|
@Test
|
60
|
@DataSets({
|
61
|
@DataSet(/*loadStrategy=CleanSweepInsertLoadStrategy.class,*/ value="/eu/etaxonomy/cdm/database/ClearDB_with_Terms_DataSet.xml"),
|
62
|
@DataSet(value="/eu/etaxonomy/cdm/database/TermsDataSet-with_auditing_info.xml")
|
63
|
})
|
64
|
public void testDoInvoke() {
|
65
|
|
66
|
UUID newKeyUuid = null;
|
67
|
try {
|
68
|
ikeyPlusImport.getKey(sddUri, null);
|
69
|
newKeyUuid = ikeyPlusImport.getCdmKey().getUuid();
|
70
|
} catch (Exception e) {
|
71
|
throw new RuntimeException(e);
|
72
|
}
|
73
|
commitAndStartNewTransaction(null);
|
74
|
PolytomousKey pk = polytomousKeyService.find(newKeyUuid);
|
75
|
Assert.assertNotNull(pk);
|
76
|
|
77
|
// assertEquals("Number of TaxonNames should be 1", 1, nameService.count(null));
|
78
|
}
|
79
|
|
80
|
@Override
|
81
|
public void createTestDataSet() throws FileNotFoundException {}
|
82
|
}
|