Skip to content

Commit

Permalink
Add csvw:property test, rename tests according to convention
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew-Kulich committed Aug 8, 2022
1 parent 4243c78 commit a20a23b
Show file tree
Hide file tree
Showing 9 changed files with 293 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,22 @@ void checkDefaultConfigurationAgainstExemplaryModelOutput() throws URISyntaxExce



@Test
void execute_checkTableSchema() throws URISyntaxException, IOException {
@DisplayName("Executes Tabular module with or without csvw:property.")
@ParameterizedTest(name = "{index} => message=''Test {0} (csvw:property) in the schema''")
@ValueSource(strings = {"withProperty", "withoutProperty"})
void executeSelfChecksSchemaWithoutProperty(String folderName) throws URISyntaxException, IOException {
module.setSourceResource(
StreamResourceUtils.getStreamResource(DATA_PREFIX,getFilePath("examples/01/input.tsv"))
StreamResourceUtils.getStreamResource(DATA_PREFIX, getFilePath("examples/" + folderName + "/input.tsv"))
);

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

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

Model expectedModel = ModelFactory.createDefaultModel()
.read(getFilePath("examples/01/expected-output.ttl").toString());

.read(getFilePath("examples/" + folderName + "/expected-output.ttl").toString());
assertTrue(actualModel.isIsomorphicWith(expectedModel));
}

Expand All @@ -113,7 +114,7 @@ void execute_checkTableSchema() throws URISyntaxException, IOException {
@DisplayName("Executes Tabular module with the different number of columns in the schema.")
@ParameterizedTest(name = "{index} => message=''{0} in the schema''")
@ValueSource(strings = {"moreColumns", "lessColumns", "noColumns"})
void executeTabularModule_throwsException(String folderName) throws URISyntaxException, IOException {
void executeSelfThrowsException(String folderName) throws URISyntaxException, IOException {
assumeTrue(ExecutionConfig.isExitOnError());
module.setSourceResource(
StreamResourceUtils.getStreamResource(DATA_PREFIX,getFilePath("examples/" + folderName + "/input.tsv"))
Expand All @@ -126,7 +127,7 @@ void executeTabularModule_throwsException(String folderName) throws URISyntaxExc
}

@Test
void executeTabularModule_withDataSchemaNoHeader_returnsNamedColumnsFromSchema()
void executeSelfWithDataSchemaNoHeaderReturnsNamedColumnsFromSchema()
throws URISyntaxException, IOException {
module.setSkipHeader(true);

Expand All @@ -151,7 +152,7 @@ void executeTabularModule_withDataSchemaNoHeader_returnsNamedColumnsFromSchema()
}

@Test
void checksCSVTransformation_noDataSchemaNoHeader_returnsAutonamedColumns()
void executeSelfWithNoDataSchemaNoHeaderReturnsAutonamedColumns()
throws URISyntaxException, IOException {
module.setSkipHeader(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@
:bookingno_i_column a csvw:Column;
csvw:name "bookingno_i" ;
csvw:property :bookingno_i ;
csvw:title "bookingno_i"
.
:Employee_No_column a csvw:Column;
csvw:name "Employee_No" ;
csvw:property :Employee_No ;
csvw:title "Employee No"
.

csvw:property a rdf:Property .
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,28 @@
:bookingno_i_column a csvw:Column;
csvw:name "bookingno_i" ;
csvw:property :bookingno_i ;
csvw:title "bookingno_i"
.
:Employee_No_column a csvw:Column;
csvw:name "Employee_No" ;
csvw:property :Employee_No ;
csvw:title "Employee No"
.
:user_sign_column a csvw:Column;
csvw:name "user_sign" ;
csvw:property :user_sign ;
csvw:title "user_sign"
.
:Start_Date_column a csvw:Column;
csvw:name "Start_Date" ;
csvw:property :Start_Date ;
csvw:title "Start Date"
.

:Start_Time_column a csvw:Column;
csvw:name "Start_Time" ;
csvw:property :Start_Time ;
csvw:title "Start Time"
.

:End_Date_column a csvw:Column;
csvw:name "End_Date" ;
csvw:property :End_Date ;
csvw:title "End Date"
.

csvw:property a rdf:Property .
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
_:b0 <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#uriTemplate> ;
<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/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/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#uriTemplate> ;
<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 <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#uriTemplate> ;
<http://www.w3.org/ns/csvw#title>
"user_sign" .

_:b2 <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#uriTemplate> ;
<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 <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#uriTemplate> ;
<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 <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#uriTemplate> ;
<http://www.w3.org/ns/csvw#title>
"End Date" .

_:b5 <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#uriTemplate> ;
<http://www.w3.org/ns/csvw#title>
"Employee No" .

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@prefix : <http://onto.fel.cvut.cz/ontologies/csat/time-analysis-0.1/> .
@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#> .
Expand All @@ -18,37 +18,37 @@

:bookingno_i_column a csvw:Column;
csvw:name "bookingno_i" ;
csvw:property :bookingno_i ;
csvw:property :bookingno_i_p ;
.
:Employee_No_column a csvw:Column;
csvw:name "Employee No" ;
csvw:property :Employee_No ;
csvw:name "Employee_No" ;
csvw:property :Employee_No_p ;
.
:user_sign_column a csvw:Column;
csvw:name "user_sign" ;
csvw:property :user_sign ;
csvw:property :user_sign_p ;
.
:Start_Date_column a csvw:Column;
csvw:name "Start Date" ;
csvw:property :Start_Date ;
csvw:name "Start_Date" ;
csvw:property :Start_Date_p ;
.

:Start_Time_column a csvw:Column;
csvw:name "Start Time" ;
csvw:property :Start_Time ;
csvw:name "Start_Time" ;
csvw:property :Start_Time_p ;
.

:End_Date_column a csvw:Column;
csvw:name "End Date" ;
csvw:property :End_Date ;
csvw:name "End_Date" ;
csvw:property :End_Date_p ;
.

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

:bookingno_i a rdf:Property .
:Employee_No a rdf:Property .
:user_sign a rdf:Property .
:Start_Date a rdf:Property .
:Start_Time a rdf:Property .
:End_Date a 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,111 @@
_:b0 <http://www.w3.org/ns/csvw#name>
"bookingno_i" ;
<http://www.w3.org/ns/csvw#propertyUrl>
"http://onto.fel.cvut.cz/data/bookingno_i" ;
<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/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/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#uriTemplate> ;
<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 <http://www.w3.org/ns/csvw#name>
"user_sign" ;
<http://www.w3.org/ns/csvw#propertyUrl>
"http://onto.fel.cvut.cz/data/user_sign" ;
<http://www.w3.org/ns/csvw#title>
"user sign" .

_:b2 <http://www.w3.org/ns/csvw#name>
"Start_Time" ;
<http://www.w3.org/ns/csvw#propertyUrl>
"http://onto.fel.cvut.cz/data/Start_Time" ;
<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>
"59999" ;
<http://onto.fel.cvut.cz/data/End_Date>
"06.03.2022" ;
<http://onto.fel.cvut.cz/data/Start_Date>
"06.02.2022" ;
<http://onto.fel.cvut.cz/data/Start_Time>
"14:00" ;
<http://onto.fel.cvut.cz/data/bookingno_i>
"6797451" ;
<http://onto.fel.cvut.cz/data/user_sign>
"KULICMAT" .

_:b3 <http://www.w3.org/ns/csvw#name>
"Start_Date" ;
<http://www.w3.org/ns/csvw#propertyUrl>
"http://onto.fel.cvut.cz/data/Start_Date" ;
<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>
"59999" ;
<http://onto.fel.cvut.cz/data/End_Date>
"09.04.2022" ;
<http://onto.fel.cvut.cz/data/Start_Date>
"08.04.2022" ;
<http://onto.fel.cvut.cz/data/Start_Time>
"16:00" ;
<http://onto.fel.cvut.cz/data/bookingno_i>
"6568520" ;
<http://onto.fel.cvut.cz/data/user_sign>
"KULICMAT" .

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

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

0 comments on commit a20a23b

Please sign in to comment.