Skip to content

Commit

Permalink
[Test] Add blank node test, Adjust tests regarding new feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew-Kulich committed Aug 29, 2022
1 parent 36a25a1 commit 354ad84
Show file tree
Hide file tree
Showing 12 changed files with 279 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import java.io.*;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

Expand Down Expand Up @@ -90,8 +91,8 @@ void checkDefaultConfigurationAgainstExemplaryModelOutput() throws URISyntaxExce



@DisplayName("Executes Tabular module with or without csvw:property.")
@ParameterizedTest(name = "{index} => message=''Test {0} (csvw:property) in the schema''")
@DisplayName("Executes Tabular module with or without csvw:propertyUrl.")
@ParameterizedTest(name = "{index} => message=''Test {0} (csvw:propertyUrl) in the schema''")
@ValueSource(strings = {"withProperty", "withoutProperty"})
void executeSelfChecksSchemaWithoutProperty(String folderName) throws URISyntaxException, IOException {
module.setSourceResource(
Expand Down Expand Up @@ -142,7 +143,7 @@ void executeSelfWithDataSchemaNoHeaderReturnsNamedColumnsFromSchema()

String[] columns = new String[]{"col_1", "col_2", "col_3", "col_4", "col_5"};

for (int i = 1; i <= 3; i++) {
for (int i = 2; i <= 4; i++) {
Resource resource = ResourceFactory.createResource(DATA_PREFIX + "#row-" + i);
for (String column: columns) {
Property property = ResourceFactory.createProperty(DATA_PREFIX, column);
Expand All @@ -162,8 +163,7 @@ void executeSelfWithNoDataSchemaNoHeaderReturnsAutonamedColumns()
);

ExecutionContext outputContext = module.executeSelf();

for (int i = 1; i <= 3; i++) {
for (int i = 2; i <= 4; i++) {
Resource resource = ResourceFactory.createResource(DATA_PREFIX + "#row-" + i);
for (int j = 1; j <= 6; j++) {
String columnName = "column_" + j;
Expand All @@ -174,6 +174,23 @@ void executeSelfWithNoDataSchemaNoHeaderReturnsAutonamedColumns()
}
}

@Test
void executeSelfWithBNodesInSchema() throws IOException, URISyntaxException {
module.setSourceResource(
StreamResourceUtils.getStreamResource(DATA_PREFIX, getFilePath("examples/blankNodes/input.tsv"))
);

Model inputModel = JenaTestUtils.laodModelFromResource("/examples/blankNodes/input-data-schema.ttl");
module.setInputContext(ExecutionContextFactory.createContext(inputModel));

ExecutionContext outputContext = module.executeSelf();
Model actualModel = outputContext.getDefaultModel();

Model expectedModel = ModelFactory.createDefaultModel()
.read(getFilePath("examples/blankNodes/expected-output.ttl").toString());
assertTrue(actualModel.isIsomorphicWith(expectedModel));
}

@Override
public String getModuleName() {
return "tabular";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<http://www.w3.org/ns/csvw#describes>
<http://test-file#row-4> ;
<http://www.w3.org/ns/csvw#rownum>
3 ;
"3"^^<http://www.w3.org/2001/XMLSchema#int> ;
<http://www.w3.org/ns/csvw#url>
<http://test-file#row=4>
] ;
Expand All @@ -15,7 +15,7 @@
<http://www.w3.org/ns/csvw#describes>
<http://test-file#row-3> ;
<http://www.w3.org/ns/csvw#rownum>
2 ;
"2"^^<http://www.w3.org/2001/XMLSchema#int> ;
<http://www.w3.org/ns/csvw#url>
<http://test-file#row=3>
] ;
Expand All @@ -24,14 +24,14 @@
<http://www.w3.org/ns/csvw#describes>
<http://test-file#row-2> ;
<http://www.w3.org/ns/csvw#rownum>
1 ;
"1"^^<http://www.w3.org/2001/XMLSchema#int> ;
<http://www.w3.org/ns/csvw#url>
<http://test-file#row=2>
] ;
<http://www.w3.org/ns/csvw#tableSchema>
[ a <http://www.w3.org/ns/csvw#TableSchema> ;
<http://www.w3.org/ns/csvw#aboutUrl>
"http://test-file#row-{_row}"^^<http://www.w3.org/ns/csvw#uriTemplate> ;
"http://test-file#row-{_row}" ;
<http://www.w3.org/ns/csvw#column>
_:b2 , _:b0 , _:b1 , _:b3 ;
<http://www.w3.org/ns/csvw#columns>
Expand All @@ -46,31 +46,35 @@
]
] .

_:b0 <http://www.w3.org/ns/csvw#name>
_:b0 a <http://www.w3.org/ns/csvw#Column> ;
<http://www.w3.org/ns/csvw#name>
"longitude" ;
<http://www.w3.org/ns/csvw#propertyUrl>
"http://onto.fel.cvut.cz/data/longitude" ;
<http://onto.fel.cvut.cz/data/longitude> ;
<http://www.w3.org/ns/csvw#title>
"longitude" .

_:b1 <http://www.w3.org/ns/csvw#name>
_:b1 a <http://www.w3.org/ns/csvw#Column> ;
<http://www.w3.org/ns/csvw#name>
"latitude" ;
<http://www.w3.org/ns/csvw#propertyUrl>
"http://onto.fel.cvut.cz/data/latitude" ;
<http://onto.fel.cvut.cz/data/latitude> ;
<http://www.w3.org/ns/csvw#title>
"latitude" .

_:b2 <http://www.w3.org/ns/csvw#name>
_:b2 a <http://www.w3.org/ns/csvw#Column> ;
<http://www.w3.org/ns/csvw#name>
"name" ;
<http://www.w3.org/ns/csvw#propertyUrl>
"http://onto.fel.cvut.cz/data/name" ;
<http://onto.fel.cvut.cz/data/name> ;
<http://www.w3.org/ns/csvw#title>
"name" .

_:b3 <http://www.w3.org/ns/csvw#name>
_:b3 a <http://www.w3.org/ns/csvw#Column> ;
<http://www.w3.org/ns/csvw#name>
"countryCode" ;
<http://www.w3.org/ns/csvw#propertyUrl>
"http://onto.fel.cvut.cz/data/countryCode" ;
<http://onto.fel.cvut.cz/data/countryCode> ;
<http://www.w3.org/ns/csvw#title>
"countryCode" .

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
_:b0 a <http://www.w3.org/ns/csvw#Column> ;
<http://www.w3.org/ns/csvw#name>
"bookingno_i" ;
<http://www.w3.org/ns/csvw#propertyUrl>
<http://onto.fel.cvut.cz/data/bookingno_i_p> ;
<http://www.w3.org/ns/csvw#title>
"bookingno_i" .

[ a <http://www.w3.org/ns/csvw#TableGroup> ;
<http://www.w3.org/ns/csvw#table>
[ a <http://www.w3.org/ns/csvw#Table> ;
<http://www.w3.org/ns/csvw#row>
[ a <http://www.w3.org/ns/csvw#Row> ;
<http://www.w3.org/ns/csvw#describes>
<http://onto.fel.cvut.cz/data/#row-3> ;
<http://www.w3.org/ns/csvw#rownum>
"2"^^<http://www.w3.org/2001/XMLSchema#int> ;
<http://www.w3.org/ns/csvw#url>
<http://onto.fel.cvut.cz/data/#row=3>
] ;
<http://www.w3.org/ns/csvw#row>
[ a <http://www.w3.org/ns/csvw#Row> ;
<http://www.w3.org/ns/csvw#describes>
<http://onto.fel.cvut.cz/data/#row-2> ;
<http://www.w3.org/ns/csvw#rownum>
"1"^^<http://www.w3.org/2001/XMLSchema#int> ;
<http://www.w3.org/ns/csvw#url>
<http://onto.fel.cvut.cz/data/#row=2>
] ;
<http://www.w3.org/ns/csvw#tableSchema>
[ a <http://www.w3.org/ns/csvw#TableSchema> ;
<http://www.w3.org/ns/csvw#aboutUrl>
"http://onto.fel.cvut.cz/data/#row-{_row}" ;
<http://www.w3.org/ns/csvw#column>
_:b1 , _:b2 , _:b3 , _:b4 , _:b5 , _:b0 ;
<http://www.w3.org/ns/csvw#columns>
( _:b0
_:b5
_:b4
_:b3
_:b2
_:b1
)
] ;
<http://www.w3.org/ns/csvw#url>
<http://onto.fel.cvut.cz/data/>
]
] .

_:b4 a <http://www.w3.org/ns/csvw#Column> ;
<http://www.w3.org/ns/csvw#name>
"user_sign" ;
<http://www.w3.org/ns/csvw#propertyUrl>
<http://onto.fel.cvut.cz/data/user_sign_p> ;
<http://www.w3.org/ns/csvw#title>
"user_sign" .

_:b2 a <http://www.w3.org/ns/csvw#Column> ;
<http://www.w3.org/ns/csvw#name>
"Start_Time" ;
<http://www.w3.org/ns/csvw#propertyUrl>
<http://onto.fel.cvut.cz/data/Start_Time_p> ;
<http://www.w3.org/ns/csvw#title>
"Start Time" .

<http://onto.fel.cvut.cz/data/#row-3>
<http://onto.fel.cvut.cz/data/Employee_No_p>
"59999" ;
<http://onto.fel.cvut.cz/data/End_Date_p>
"06.03.2022" ;
<http://onto.fel.cvut.cz/data/Start_Date_p>
"06.02.2022" ;
<http://onto.fel.cvut.cz/data/Start_Time_p>
"14:00" ;
<http://onto.fel.cvut.cz/data/bookingno_i_p>
"6797451" ;
<http://onto.fel.cvut.cz/data/user_sign_p>
"KULICMAT" .

_:b3 a <http://www.w3.org/ns/csvw#Column> ;
<http://www.w3.org/ns/csvw#name>
"Start_Date" ;
<http://www.w3.org/ns/csvw#propertyUrl>
<http://onto.fel.cvut.cz/data/Start_Date_p> ;
<http://www.w3.org/ns/csvw#title>
"Start Date" .

<http://onto.fel.cvut.cz/data/#row-2>
<http://onto.fel.cvut.cz/data/Employee_No_p>
"59999" ;
<http://onto.fel.cvut.cz/data/End_Date_p>
"09.04.2022" ;
<http://onto.fel.cvut.cz/data/Start_Date_p>
"08.04.2022" ;
<http://onto.fel.cvut.cz/data/Start_Time_p>
"16:00" ;
<http://onto.fel.cvut.cz/data/bookingno_i_p>
"6568520" ;
<http://onto.fel.cvut.cz/data/user_sign_p>
"KULICMAT" .

_:b1 a <http://www.w3.org/ns/csvw#Column> ;
<http://www.w3.org/ns/csvw#name>
"End_Date" ;
<http://www.w3.org/ns/csvw#propertyUrl>
<http://onto.fel.cvut.cz/data/End_Date_p> ;
<http://www.w3.org/ns/csvw#title>
"End Date" .

_:b5 a <http://www.w3.org/ns/csvw#Column> ;
<http://www.w3.org/ns/csvw#name>
"Employee_No" ;
<http://www.w3.org/ns/csvw#propertyUrl>
<http://onto.fel.cvut.cz/data/Employee_No_p> ;
<http://www.w3.org/ns/csvw#title>
"Employee No" .

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
@prefix : <http://onto.fel.cvut.cz/data/> .
@prefix csvw: <http://www.w3.org/ns/csvw#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .


:input-data-schema a owl:Ontology .

:input-table-schema a csvw:TableSchema ;
csvw:column _:bookingno_i_column ,
_:Employee_No_column ,
_:user_sign_column ,
_:Start_Date_column ,
_:Start_Time_column ,
_:End_Date_column
.

_:bookingno_i_column a csvw:Column;
csvw:name "bookingno_i" ;
csvw:propertyUrl :bookingno_i_p ;
.
_:Employee_No_column a csvw:Column;
csvw:name "Employee_No" ;
csvw:propertyUrl :Employee_No_p ;
.
_:user_sign_column a csvw:Column;
csvw:name "user_sign" ;
csvw:propertyUrl :user_sign_p ;
.
_:Start_Date_column a csvw:Column;
csvw:name "Start_Date" ;
csvw:propertyUrl :Start_Date_p ;
.

_:Start_Time_column a csvw:Column;
csvw:name "Start_Time" ;
csvw:propertyUrl :Start_Time_p ;
.

_:End_Date_column a csvw:Column;
csvw:name "End_Date" ;
csvw:propertyUrl :End_Date_p ;
.

csvw:propertyUrl a rdf:Property .
csvw:propertyUrl rdfs:range rdf:Property .

_:bookingno_i_p a rdf:Property .
_:Employee_No_p a rdf:Property .
_:user_sign_p a rdf:Property .
_:Start_Date_p a rdf:Property .
_:Start_Time_p a rdf:Property .
_:End_Date_p a rdf:Property .
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bookingno_i Employee No user_sign Start Date Start Time End Date
6568520 59999 KULICMAT 08.04.2022 16:00 09.04.2022
6797451 59999 KULICMAT 06.02.2022 14:00 06.03.2022
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@

:bookingno_i_column a csvw:Column;
csvw:name "bookingno_i" ;
csvw:property :bookingno_i ;
csvw:propertyUrl :bookingno_i ;
.
:Employee_No_column a csvw:Column;
csvw:name "Employee_No" ;
csvw:property :Employee_No ;
csvw:propertyUrl :Employee_No ;
.

csvw:property a rdf:Property .
csvw:property rdfs:range rdf:Property .
csvw:propertyUrl a rdf:Property .
csvw:propertyUrl rdfs:range rdf:Property .

:bookingno_i a rdf:Property .
:Employee_No a rdf:Property .
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,33 @@

:bookingno_i_column a csvw:Column;
csvw:name "bookingno_i" ;
csvw:property :bookingno_i ;
csvw:propertyUrl :bookingno_i ;
.
:Employee_No_column a csvw:Column;
csvw:name "Employee_No" ;
csvw:property :Employee_No ;
csvw:propertyUrl :Employee_No ;
.
:user_sign_column a csvw:Column;
csvw:name "user_sign" ;
csvw:property :user_sign ;
csvw:propertyUrl :user_sign ;
.
:Start_Date_column a csvw:Column;
csvw:name "Start_Date" ;
csvw:property :Start_Date ;
csvw:propertyUrl :Start_Date ;
.

:Start_Time_column a csvw:Column;
csvw:name "Start_Time" ;
csvw:property :Start_Time ;
csvw:propertyUrl :Start_Time ;
.

:End_Date_column a csvw:Column;
csvw:name "End_Date" ;
csvw:property :End_Date ;
csvw:propertyUrl :End_Date ;
.

csvw:property a rdf:Property .
csvw:property rdfs:range rdf:Property .
csvw:propertyUrl a rdf:Property .
csvw:propertyUrl rdfs:range rdf:Property .

:bookingno_i a rdf:Property .
:Employee_No a rdf:Property .
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
.


csvw:property a rdf:Property .
csvw:property rdfs:range rdf:Property .
csvw:propertyUrl a rdf:Property .
csvw:propertyUrl rdfs:range rdf:Property .
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
csvw:name "col_5" ;
.

csvw:property a rdf:Property .
csvw:property rdfs:range rdf:Property .
csvw:propertyUrl a rdf:Property .
csvw:propertyUrl rdfs:range rdf:Property .

0 comments on commit 354ad84

Please sign in to comment.