Skip to content
This repository was archived by the owner on Feb 15, 2024. It is now read-only.

Commit 46b5cfb

Browse files
authored
Merge pull request #39 from changqin26/feature/example-validation
Feature/example validation
2 parents 6e5eb68 + 693fc8f commit 46b5cfb

9 files changed

Lines changed: 3379 additions & 18 deletions

File tree

dataformat-core/src/test/java/io/adminshell/aas/v3/dataformat/core/AASFull.java

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -250,26 +250,14 @@ public class AASFull {
250250
.build())
251251
.qualifier(new DefaultQualifier.Builder()
252252
.value("100")
253-
.valueId(new DefaultReference.Builder()
254-
.key(new DefaultKey.Builder()
255-
.type(KeyElements.GLOBAL_REFERENCE)
256-
.idType(KeyType.IRI)
257-
.value("100")
258-
.build())
259-
.build())
253+
260254
.valueType("int")
261255
.type("http://acplt.org/Qualifier/ExampleQualifier")
262256
.build())
263257
.qualifier(new DefaultQualifier.Builder()
264258
.value("50")
265-
.valueId(new DefaultReference.Builder()
266-
.key(new DefaultKey.Builder()
267-
.type(KeyElements.GLOBAL_REFERENCE)
268-
.idType(KeyType.IRI)
269-
.value("50")
270-
.build())
271-
.build())
272-
.valueType("int")
259+
260+
.valueType("http://www.w3.org/2001/XMLSchema#int")
273261
.type("http://acplt.org/Qualifier/ExampleQualifier2")
274262
.build())
275263
.value("http://acplt.org/ValueId/ACPLT")

validator/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
<artifactId>dataformat-rdf</artifactId>
1818
<version>${revision}</version>
1919
</dependency>
20+
<dependency>
21+
<groupId>io.admin-shell.aas</groupId>
22+
<artifactId>dataformat-json</artifactId>
23+
<version>${revision}</version>
24+
<scope>test</scope>
25+
</dependency>
2026
<dependency>
2127
<groupId>io.admin-shell.aas</groupId>
2228
<artifactId>dataformat-core</artifactId>

validator/src/main/java/io/adminshell/aas/v3/model/validator/ShaclValidator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ private ShaclValidator() {
130130
//All loaded, let's parse!
131131
//shapes = Shapes.parse(shapesModel);
132132
InputStream shapesInputStream = getClass().getClassLoader().getResourceAsStream("shapes.ttl");
133-
InputStream constraintShapesInputStream = getClass().getClassLoader().getResourceAsStream("constraint_shapes.ttl");
134133
InputStream ontologyInputStream = getClass().getClassLoader().getResourceAsStream("ontology.ttl");
134+
InputStream constraintShapesInputStream = getClass().getClassLoader().getResourceAsStream("constraint_shapes.ttl");
135135
shapesModel.read(shapesInputStream, null, FileUtils.langTurtle);
136136
shapesModel.read(constraintShapesInputStream, null, FileUtils.langTurtle);
137137
shapes = Shapes.parse(shapesModel);
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (c) 2021 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.adminshell.aas.v3.model.validator;
17+
18+
19+
import org.apache.commons.io.IOUtils;
20+
21+
import java.io.IOException;
22+
import java.io.InputStream;
23+
import java.io.StringWriter;
24+
25+
/**
26+
* Helper class for Serializer Tests
27+
*
28+
* @author sbader
29+
*
30+
*/
31+
public class ValidatorUtil {
32+
33+
public static String readResourceToString(String resourceName) throws IOException {
34+
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
35+
InputStream is = classloader.getResourceAsStream(resourceName);
36+
StringWriter writer = new StringWriter();
37+
IOUtils.copy(is, writer, "UTF-8");
38+
return writer.toString();
39+
}
40+
41+
public static String stripWhitespaces(String input) {
42+
return input.replaceAll("\\s+", "");
43+
}
44+
45+
}

validator/src/main/resources/constraint_shapes.ttl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
# AASd-002
3434
aas:IdShortShape a sh:NodeShape ;
35-
sh:targetClass aas:Submodel ;
35+
sh:targetClass aas:Referable ;
3636
sh:property [
3737
a sh:PropertyShape ;
3838
sh:path <https://admin-shell.io/aas/3/0/RC01/Referable/idShort> ;

0 commit comments

Comments
 (0)