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

Test

parent 46abcd3f
No related branches found
No related tags found
1 merge request!4Resolve "dcat:mediaType korrigieren"
Pipeline #399 failed
......@@ -57,9 +57,9 @@ public class CatalogFilterTest {
@Test
public void work() throws Exception {
final InputStream inputStream = getClass().getResourceAsStream("/catalog.xml");
try (final InputStream inputStream = getClass().getResourceAsStream("/catalog.xml")) {
catalogFilter.work(inputStream);
inputStream.close();
}
}
@Test
......@@ -145,13 +145,13 @@ public class CatalogFilterTest {
*/
@Test
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);
Assertions.assertEquals(8, countInstances(model, DCAT.Dataset));
Assertions.assertEquals(7, countInstances(model, DCAT.Distribution));
inputStream.close();
}
}
/**
......@@ -160,7 +160,7 @@ public class CatalogFilterTest {
*/
@Test
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);
// Every dataset has a dct:accessRights statement
......@@ -175,8 +175,7 @@ public class CatalogFilterTest {
}
assertEquals(8, count);
inputStream.close();
}
}
/**
......@@ -184,7 +183,7 @@ public class CatalogFilterTest {
*/
@Test
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);
// Every dataset has a dct:accessRights statement
......@@ -200,8 +199,7 @@ public class CatalogFilterTest {
}
assertEquals(7, count);
inputStream.close();
}
}
/**
......@@ -211,7 +209,7 @@ public class CatalogFilterTest {
@Test
public void work_invalid_iri() {
final InputStream inputStream = getClass().getResourceAsStream("/invalid_iri.xml");
final Model model = catalogFilter.work(inputStream);
catalogFilter.work(inputStream);
}
/**
......@@ -221,13 +219,12 @@ public class CatalogFilterTest {
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");
final InputStream inputStream = getClass().getResourceAsStream("/two-organizations.xml");
try (final InputStream inputStream = getClass().getResourceAsStream("/two-organizations.xml")) {
final Model model = catalogFilter.work(inputStream);
Assertions.assertEquals(1, countInstances(model, DCAT.Dataset));
Assertions.assertEquals(1, countInstances(model, DCAT.Distribution));
inputStream.close();
}
}
/**
......@@ -235,9 +232,24 @@ public class CatalogFilterTest {
* catalog proxy must be able to cope with this.
*/
@Test
public void work_invalid_uri() {
final InputStream inputStream = getClass().getResourceAsStream("/invalid_uri.xml");
public void work_invalid_uri() throws IOException {
try (InputStream inputStream = getClass().getResourceAsStream("/invalid_uri.xml")) {
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