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

Commit 801e300

Browse files
committed
added unit test to dataformat-core validating example files using validator
1 parent a8bc8bf commit 801e300

3 files changed

Lines changed: 65 additions & 0 deletions

File tree

dataformat-core/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
<artifactId>model</artifactId>
1818
<version>${model.version}</version>
1919
</dependency>
20+
<dependency>
21+
<groupId>io.admin-shell.aas</groupId>
22+
<artifactId>validator</artifactId>
23+
<version>${revision}</version>
24+
</dependency>
2025
<dependency>
2126
<groupId>com.fasterxml.jackson.core</groupId>
2227
<artifactId>jackson-annotations</artifactId>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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.dataformat.core;
17+
18+
import io.adminshell.aas.v3.model.AssetAdministrationShellEnvironment;
19+
import io.adminshell.aas.v3.model.validator.ShaclValidator;
20+
import io.adminshell.aas.v3.model.validator.ValidationException;
21+
import java.io.IOException;
22+
import org.apache.jena.shacl.ValidationReport;
23+
import org.apache.jena.shacl.lib.ShLib;
24+
import org.junit.Assert;
25+
import static org.junit.Assert.assertTrue;
26+
import org.junit.BeforeClass;
27+
import org.junit.Test;
28+
import org.slf4j.Logger;
29+
import org.slf4j.LoggerFactory;
30+
31+
public class ValidateModelsTest {
32+
33+
private static final Logger log = LoggerFactory.getLogger(ValidateModelsTest.class);
34+
35+
@BeforeClass
36+
private void init() {
37+
ShaclValidator.getInstance().initialize();
38+
}
39+
40+
@Test
41+
public void validateAASFull() throws ValidationException, IOException {
42+
validate(AASFull.ENVIRONMENT);
43+
}
44+
45+
@Test
46+
public void validateAASSimple() throws ValidationException, IOException {
47+
validate(AASSimple.ENVIRONMENT);
48+
}
49+
50+
private void validate(AssetAdministrationShellEnvironment aasEnv) throws ValidationException, IOException {
51+
ValidationReport report = ShaclValidator.getInstance().validateGetReport(aasEnv);
52+
ShLib.printReport(report);
53+
assertTrue(report.conforms());
54+
}
55+
}

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,11 @@
218218
<artifactId>slf4j-api</artifactId>
219219
<version>${slf4j.version}</version>
220220
</dependency>
221+
<dependency>
222+
<groupId>org.slf4j</groupId>
223+
<artifactId>slf4j-simple</artifactId>
224+
<version>${slf4j.version}</version>
225+
</dependency>
221226
</dependencies>
222227

223228
<dependencyManagement>

0 commit comments

Comments
 (0)