1
|
/**
|
2
|
* Copyright (C) 2017 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.io.owl.out;
|
10
|
|
11
|
import java.io.File;
|
12
|
import java.io.FileNotFoundException;
|
13
|
import java.util.UUID;
|
14
|
|
15
|
import org.apache.log4j.Logger;
|
16
|
import org.junit.Test;
|
17
|
import org.unitils.dbunit.annotation.DataSet;
|
18
|
import org.unitils.spring.annotation.SpringBeanByName;
|
19
|
import org.unitils.spring.annotation.SpringBeanByType;
|
20
|
|
21
|
import eu.etaxonomy.cdm.api.service.IClassificationService;
|
22
|
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
|
23
|
import eu.etaxonomy.cdm.io.common.CdmApplicationAwareDefaultExport;
|
24
|
import eu.etaxonomy.cdm.io.common.ExportDataWrapper;
|
25
|
import eu.etaxonomy.cdm.io.common.ExportResult;
|
26
|
import eu.etaxonomy.cdm.io.common.IExportConfigurator.TARGET;
|
27
|
import eu.etaxonomy.cdm.io.descriptive.owl.out.OwlExportConfigurator;
|
28
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
29
|
import eu.etaxonomy.cdm.model.description.Feature;
|
30
|
import eu.etaxonomy.cdm.model.description.FeatureNode;
|
31
|
import eu.etaxonomy.cdm.model.description.FeatureTree;
|
32
|
import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;
|
33
|
import eu.etaxonomy.cdm.test.unitils.CleanSweepInsertLoadStrategy;
|
34
|
|
35
|
/**
|
36
|
* @author a.mueller
|
37
|
\* @since 25.06.2017
|
38
|
*
|
39
|
*/
|
40
|
public class OwlExportTest extends CdmTransactionalIntegrationTest{
|
41
|
@SuppressWarnings("unused")
|
42
|
private static final Logger logger = Logger.getLogger(OwlExportTest.class);
|
43
|
|
44
|
@SpringBeanByName
|
45
|
private CdmApplicationAwareDefaultExport<OwlExportConfigurator> defaultExport;
|
46
|
|
47
|
@SpringBeanByType
|
48
|
private IClassificationService classificationService;
|
49
|
|
50
|
@SpringBeanByType
|
51
|
private ITaxonNodeService taxonNodeService;
|
52
|
|
53
|
|
54
|
@Test
|
55
|
@DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="/eu/etaxonomy/cdm/database/BlankDataSet.xml")
|
56
|
public void testEmptyData(){
|
57
|
File destinationFolder = null;
|
58
|
OwlExportConfigurator config = OwlExportConfigurator.NewInstance(null, destinationFolder, createFeatureTree());
|
59
|
config.setTarget(TARGET.EXPORT_DATA);
|
60
|
ExportResult result = defaultExport.invoke(config);
|
61
|
System.out.println(result.createReport());
|
62
|
ExportDataWrapper<?> exportData = result.getExportData();
|
63
|
}
|
64
|
|
65
|
|
66
|
/**
|
67
|
* {@inheritDoc}
|
68
|
*/
|
69
|
public FeatureTree createFeatureTree() {
|
70
|
FeatureTree tree = FeatureTree.NewInstance();
|
71
|
tree.setRoot(FeatureNode.NewInstance());
|
72
|
|
73
|
FeatureNode nodeA = FeatureNode.NewInstance(Feature.NewInstance("A", "A", "A"));
|
74
|
FeatureNode nodeA1 = FeatureNode.NewInstance(Feature.NewInstance("A1", "A1", "A1"));
|
75
|
FeatureNode nodeA2 = FeatureNode.NewInstance(Feature.NewInstance("A2", "A2", "A2"));
|
76
|
FeatureNode nodeB = FeatureNode.NewInstance(Feature.NewInstance("B", "B", "B"));
|
77
|
FeatureNode nodeB1 = FeatureNode.NewInstance(Feature.NewInstance("B", "B1", "B1"));
|
78
|
FeatureNode nodeC = FeatureNode.NewInstance(Feature.NewInstance("C", "C", "C"));
|
79
|
|
80
|
tree.getRoot().addChild(nodeA);
|
81
|
nodeA.addChild(nodeA1);
|
82
|
nodeA.addChild(nodeA2);
|
83
|
tree.getRoot().addChild(nodeB);
|
84
|
nodeB.addChild(nodeB1);
|
85
|
tree.getRoot().addChild(nodeC);
|
86
|
return tree;
|
87
|
}
|
88
|
|
89
|
@Override
|
90
|
public void createTestDataSet() throws FileNotFoundException {
|
91
|
// try {
|
92
|
// writeDbUnitDataSetFile(new String[] {
|
93
|
// "Classification",
|
94
|
// }, "testAttachDnaSampleToDerivedUnit");
|
95
|
// } catch (FileNotFoundException e) {
|
96
|
// e.printStackTrace();
|
97
|
// }
|
98
|
}
|
99
|
|
100
|
|
101
|
private void setUuid(CdmBase cdmBase, String uuidStr) {
|
102
|
cdmBase.setUuid(UUID.fromString(uuidStr));
|
103
|
}
|
104
|
|
105
|
}
|