|
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 | | -} |
| 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 static org.junit.Assert.assertTrue; |
| 25 | +import org.junit.BeforeClass; |
| 26 | +import org.junit.Test; |
| 27 | +import org.slf4j.Logger; |
| 28 | +import org.slf4j.LoggerFactory; |
| 29 | + |
| 30 | +public class ValidateModelsTest { |
| 31 | + |
| 32 | + private static final Logger log = LoggerFactory.getLogger(ValidateModelsTest.class); |
| 33 | + |
| 34 | + @BeforeClass |
| 35 | + public static void init() { |
| 36 | + ShaclValidator.getInstance().initialize(); |
| 37 | + } |
| 38 | + |
| 39 | + @Test |
| 40 | + public void validateAASFull() throws ValidationException, IOException { |
| 41 | + validate(AASFull.ENVIRONMENT); |
| 42 | + } |
| 43 | + |
| 44 | + @Test |
| 45 | + public void validateAASSimple() throws ValidationException, IOException { |
| 46 | + validate(AASSimple.ENVIRONMENT); |
| 47 | + } |
| 48 | + |
| 49 | + private void validate(AssetAdministrationShellEnvironment aasEnv) throws ValidationException, IOException { |
| 50 | + ValidationReport report = ShaclValidator.getInstance().validateGetReport(aasEnv); |
| 51 | + ShLib.printReport(report); |
| 52 | + assertTrue(report.conforms()); |
| 53 | + } |
| 54 | +} |
0 commit comments