|
20 | 20 | import java.io.ByteArrayInputStream;
|
21 | 21 | import java.io.IOException;
|
22 | 22 | import java.io.InputStream;
|
| 23 | +import java.net.URL; |
23 | 24 | import java.util.List;
|
24 | 25 | import java.util.function.Consumer;
|
25 | 26 |
|
|
31 | 32 | import org.eclipse.digitaltwin.aas4j.v3.dataformat.json.JsonDeserializer;
|
32 | 33 | import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.XmlDeserializer;
|
33 | 34 | import org.eclipse.digitaltwin.aas4j.v3.model.Environment;
|
34 |
| -import org.junit.jupiter.api.Disabled; |
35 | 35 | import org.junit.jupiter.api.Test;
|
36 | 36 | import org.junit.jupiter.params.ParameterizedTest;
|
37 | 37 | import org.junit.jupiter.params.provider.EnumSource;
|
38 | 38 |
|
39 | 39 | class AasToAspectModelGeneratorTest {
|
40 | 40 |
|
41 | 41 | @Test
|
42 |
| - @Disabled( "IDTA-provided sample files can currently not be read with AAS4J" ) |
43 | 42 | void testTranslateDigitalNameplate() {
|
44 | 43 | final InputStream aasx = AasToAspectModelGeneratorTest.class.getClassLoader()
|
45 |
| - .getResourceAsStream( "Sample_ZVEI_Digital_Nameplate_V10.aasx" ); |
| 44 | + .getResourceAsStream( "idta/Sample_ZVEI_Digital_Nameplate_V10.aasx" ); |
46 | 45 | final AasToAspectModelGenerator aspectModelGenerator = AasToAspectModelGenerator.fromAasx( aasx );
|
47 | 46 | assertThatCode( aspectModelGenerator::generateAspects ).doesNotThrowAnyException();
|
48 | 47 | }
|
49 | 48 |
|
| 49 | + @Test |
| 50 | + void testSeeReferences() { |
| 51 | + final InputStream inputStream = AasToAspectModelGeneratorTest.class.getClassLoader().getResourceAsStream( |
| 52 | + "idta/IDTA 02022-1-0_Template_Wireless Communication.aasx" ); |
| 53 | + final AasToAspectModelGenerator aspectModelGenerator = AasToAspectModelGenerator.fromAasx( inputStream ); |
| 54 | + final List<Aspect> aspects = aspectModelGenerator.generateAspects(); |
| 55 | + |
| 56 | + assertThatCode( aspectModelGenerator::generateAspects ).doesNotThrowAnyException(); |
| 57 | + |
| 58 | + aspects.stream() |
| 59 | + .flatMap( aspect -> aspect.getProperties().stream() ) |
| 60 | + .flatMap( property -> property.getSee().stream() ) |
| 61 | + .forEach( see -> { |
| 62 | + assertThat( see ).doesNotContain( "/ " ); |
| 63 | + } ); |
| 64 | + } |
| 65 | + |
50 | 66 | @ParameterizedTest
|
51 | 67 | @EnumSource( TestAspect.class )
|
52 | 68 | void testRoundtripConversion( final TestAspect testAspect ) throws DeserializationException {
|
@@ -134,4 +150,15 @@ private Environment loadEnvironment( final String name ) {
|
134 | 150 | }
|
135 | 151 | return null;
|
136 | 152 | }
|
| 153 | + |
| 154 | + private InputStream getIdtaModel( final String path ) { |
| 155 | + try { |
| 156 | + final URL url = new URL( |
| 157 | + "https://github.com/admin-shell-io/submodel-templates/raw/refs/heads/main/published/" + path.replaceAll( " ", "%20" ) ); |
| 158 | + return url.openStream(); |
| 159 | + } catch ( Exception e ) { |
| 160 | + e.printStackTrace(); |
| 161 | + return null; |
| 162 | + } |
| 163 | + } |
137 | 164 | }
|
0 commit comments