Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dcat-catalog-proxy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Open-Data
dcat-catalog-proxy
Commits
2890c8f5
Commit
2890c8f5
authored
2 years ago
by
Jesper Zedlitz
Browse files
Options
Downloads
Patches
Plain Diff
Test
parent
46abcd3f
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!4
Resolve "dcat:mediaType korrigieren"
Pipeline
#399
failed
2 years ago
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/java/de/landsh/opendata/catalogproxy/CatalogFilterTest.java
+63
-51
63 additions, 51 deletions
...va/de/landsh/opendata/catalogproxy/CatalogFilterTest.java
with
63 additions
and
51 deletions
src/test/java/de/landsh/opendata/catalogproxy/CatalogFilterTest.java
+
63
−
51
View file @
2890c8f5
...
@@ -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
());
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment