Skip to content
Snippets Groups Projects
Commit 2890c8f5 authored by Jesper Zedlitz's avatar Jesper Zedlitz
Browse files

Test

parent 46abcd3f
Branches
Tags
1 merge request!4Resolve "dcat:mediaType korrigieren"
Pipeline #399 failed
...@@ -57,9 +57,9 @@ public class CatalogFilterTest { ...@@ -57,9 +57,9 @@ public class CatalogFilterTest {
@Test @Test
public void work() throws Exception { public void work() throws Exception {
final InputStream inputStream = getClass().getResourceAsStream("/catalog.xml"); try (final InputStream inputStream = getClass().getResourceAsStream("/catalog.xml")) {
catalogFilter.work(inputStream); catalogFilter.work(inputStream);
inputStream.close(); }
} }
@Test @Test
...@@ -145,13 +145,13 @@ public class CatalogFilterTest { ...@@ -145,13 +145,13 @@ public class CatalogFilterTest {
*/ */
@Test @Test
public void work_will_preseve_collections() throws Exception { public void work_will_preseve_collections() throws Exception {
final InputStream inputStream = getClass().getResourceAsStream("/with_collection.xml"); try (final InputStream inputStream = getClass().getResourceAsStream("/with_collection.xml")) {
final Model model = catalogFilter.work(inputStream); final Model model = catalogFilter.work(inputStream);
Assertions.assertEquals(8, countInstances(model, DCAT.Dataset)); Assertions.assertEquals(8, countInstances(model, DCAT.Dataset));
Assertions.assertEquals(7, countInstances(model, DCAT.Distribution)); Assertions.assertEquals(7, countInstances(model, DCAT.Distribution));
inputStream.close(); }
} }
/** /**
...@@ -160,23 +160,22 @@ public class CatalogFilterTest { ...@@ -160,23 +160,22 @@ public class CatalogFilterTest {
*/ */
@Test @Test
public void work_will_add_accessRights() throws Exception { public void work_will_add_accessRights() throws Exception {
final InputStream inputStream = getClass().getResourceAsStream("/with_collection.xml"); try (final InputStream inputStream = getClass().getResourceAsStream("/with_collection.xml")) {
final Model model = catalogFilter.work(inputStream); final Model model = catalogFilter.work(inputStream);
// Every dataset has a dct:accessRights statement // Every dataset has a dct:accessRights statement
final ResIterator it = model.listSubjectsWithProperty(RDF.type, DCAT.Dataset); final ResIterator it = model.listSubjectsWithProperty(RDF.type, DCAT.Dataset);
int count = 0; int count = 0;
while (it.hasNext()) { while (it.hasNext()) {
final Resource distribution = it.next(); final Resource distribution = it.next();
count++; count++;
final Resource accessRights = distribution.getPropertyResourceValue(DCTerms.accessRights); final Resource accessRights = distribution.getPropertyResourceValue(DCTerms.accessRights);
assertNotNull(accessRights); assertNotNull(accessRights);
assertEquals("http://publications.europa.eu/resource/authority/access-right/PUBLIC", accessRights.getURI()); assertEquals("http://publications.europa.eu/resource/authority/access-right/PUBLIC", accessRights.getURI());
}
assertEquals(8, count);
} }
assertEquals(8, count);
inputStream.close();
} }
/** /**
...@@ -184,24 +183,23 @@ public class CatalogFilterTest { ...@@ -184,24 +183,23 @@ public class CatalogFilterTest {
*/ */
@Test @Test
public void work_will_add_rights() throws Exception { public void work_will_add_rights() throws Exception {
final InputStream inputStream = getClass().getResourceAsStream("/with_collection.xml"); try (final InputStream inputStream = getClass().getResourceAsStream("/with_collection.xml")) {
final Model model = catalogFilter.work(inputStream); final Model model = catalogFilter.work(inputStream);
// Every dataset has a dct:accessRights statement // Every dataset has a dct:accessRights statement
final ResIterator it = model.listSubjectsWithProperty(RDF.type, DCAT.Distribution); final ResIterator it = model.listSubjectsWithProperty(RDF.type, DCAT.Distribution);
int count = 0; int count = 0;
while (it.hasNext()) { while (it.hasNext()) {
final Resource distribution = it.next(); final Resource distribution = it.next();
count++; count++;
final Resource rights = distribution.getPropertyResourceValue(DCTerms.rights); final Resource rights = distribution.getPropertyResourceValue(DCTerms.rights);
final Resource license = distribution.getPropertyResourceValue(DCTerms.license); final Resource license = distribution.getPropertyResourceValue(DCTerms.license);
assertNotNull(rights); assertNotNull(rights);
assertEquals(license, rights); assertEquals(license, rights);
}
assertEquals(7, count);
} }
assertEquals(7, count);
inputStream.close();
} }
/** /**
...@@ -211,7 +209,7 @@ public class CatalogFilterTest { ...@@ -211,7 +209,7 @@ public class CatalogFilterTest {
@Test @Test
public void work_invalid_iri() { public void work_invalid_iri() {
final InputStream inputStream = getClass().getResourceAsStream("/invalid_iri.xml"); final InputStream inputStream = getClass().getResourceAsStream("/invalid_iri.xml");
final Model model = catalogFilter.work(inputStream); catalogFilter.work(inputStream);
} }
/** /**
...@@ -221,13 +219,12 @@ public class CatalogFilterTest { ...@@ -221,13 +219,12 @@ public class CatalogFilterTest {
public void work_will_remove_non_government_organization() throws IOException { public void work_will_remove_non_government_organization() throws IOException {
catalogFilter.unwantedPublishers = Collections.singletonList("https://opendata.schleswig-holstein.de/organization/ee4df032-ec5f-4726-b7ad-a2c708fb53ec"); catalogFilter.unwantedPublishers = Collections.singletonList("https://opendata.schleswig-holstein.de/organization/ee4df032-ec5f-4726-b7ad-a2c708fb53ec");
final InputStream inputStream = getClass().getResourceAsStream("/two-organizations.xml"); try (final InputStream inputStream = getClass().getResourceAsStream("/two-organizations.xml")) {
final Model model = catalogFilter.work(inputStream); final Model model = catalogFilter.work(inputStream);
Assertions.assertEquals(1, countInstances(model, DCAT.Dataset));
Assertions.assertEquals(1, countInstances(model, DCAT.Distribution));
inputStream.close(); Assertions.assertEquals(1, countInstances(model, DCAT.Dataset));
Assertions.assertEquals(1, countInstances(model, DCAT.Distribution));
}
} }
/** /**
...@@ -235,9 +232,24 @@ public class CatalogFilterTest { ...@@ -235,9 +232,24 @@ public class CatalogFilterTest {
* catalog proxy must be able to cope with this. * catalog proxy must be able to cope with this.
*/ */
@Test @Test
public void work_invalid_uri() { public void work_invalid_uri() throws IOException {
final InputStream inputStream = getClass().getResourceAsStream("/invalid_uri.xml"); try (InputStream inputStream = getClass().getResourceAsStream("/invalid_uri.xml")) {
catalogFilter.work(inputStream); catalogFilter.work(inputStream);
}
} }
@Test
@org.junit.jupiter.api.Disabled
public void repairMediaType() {
final Model model = parseRdf(getClass().getResourceAsStream("/with_downloadURL.xml"));
catalogFilter.rewriteDownloadAndAccessURLs(model);
final ResIterator it = model.listSubjectsWithProperty(RDF.type, DCAT.Distribution);
final Resource distribution = it.next();
final Resource mediaType = distribution.getPropertyResourceValue(DCAT.mediaType);
assertNotNull(mediaType);
assertEquals("https://www.iana.org/assignments/media-types/text/csv", mediaType.getURI());
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment