-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add integration test using SKOS codelist reader
...to test shadowed dependencies used in that library.
- Loading branch information
Showing
2 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
src/test/groovy/to/wetransform/halecli/SKOSCodeListTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
|
||
/* | ||
* Copyright (c) 2024 wetransform GmbH | ||
* | ||
* All rights reserved. This program and the accompanying materials are made | ||
* available under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation, either version 3 of the License, | ||
* or (at your option) any later version. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this distribution. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package to.wetransform.halecli; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import java.net.URI; | ||
import java.util.Collection; | ||
|
||
import org.junit.Test; | ||
|
||
import eu.esdihumboldt.hale.common.codelist.CodeList; | ||
import eu.esdihumboldt.hale.common.codelist.io.CodeListReader; | ||
import eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator; | ||
import eu.esdihumboldt.hale.common.core.io.report.IOReport; | ||
import eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier; | ||
import eu.esdihumboldt.hale.io.codelist.skos.reader.SkosCodeListReader; | ||
|
||
/** | ||
* Tests reading SKOS code lists to test shadowed dependencies in SKOS I/O | ||
* bundle. | ||
*/ | ||
public class SKOSCodeListTest { | ||
|
||
@Test | ||
public void testSKOSFromRDF1() throws Exception { | ||
CodeList codeList = readCodeList( | ||
getClass().getClassLoader().getResource("testdata/skos/test1.rdf").toURI()); | ||
|
||
Collection<CodeList.CodeEntry> entries = codeList.getEntries(); | ||
assertFalse(entries.isEmpty()); | ||
|
||
assertEquals(entries.size(), 1); | ||
|
||
assertNotNull(codeList.getLocation()); | ||
assertNotNull(codeList.getIdentifier()); | ||
|
||
for (CodeList.CodeEntry entry : entries) { | ||
assertEquals("Data scientist", entry.getName()); | ||
} | ||
} | ||
|
||
private CodeList readCodeList(URI source) throws Exception { | ||
CodeListReader reader = new SkosCodeListReader(); | ||
|
||
reader.setSource(new DefaultInputSupplier(source)); | ||
|
||
IOReport report = reader.execute(new LogProgressIndicator()); | ||
assertTrue(report.isSuccess()); | ||
|
||
return reader.getCodeList(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xmlns:dc="http://purl.org/dc/elements/1.1/"> | ||
<skos:Concept rdf:about="http://vocab.to.wetransform/term/W080/1/CONT0006"> | ||
<skos:externalID>SDN:W080:1:CONT0006</skos:externalID> | ||
<skos:prefLabel>Data scientist</skos:prefLabel> | ||
<skos:altLabel/> | ||
<skos:definition> | ||
Relevant contact information about the person or organisation that is responsible for the archiving, quality control and quality assurance of data. | ||
</skos:definition> | ||
<dc:date>2016-12-09T08:56:35.660+0000</dc:date> | ||
</skos:Concept> | ||
</rdf:RDF> |