Skip to content

Commit

Permalink
test: add integration test using SKOS codelist reader
Browse files Browse the repository at this point in the history
...to test shadowed dependencies used in that library.
  • Loading branch information
stempler committed Aug 30, 2024
1 parent 73567e8 commit 0200d82
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
64 changes: 64 additions & 0 deletions src/test/groovy/to/wetransform/halecli/SKOSCodeListTest.java
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();
}

}
12 changes: 12 additions & 0 deletions src/test/resources/testdata/skos/test1.rdf
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>

0 comments on commit 0200d82

Please sign in to comment.