From 749777704b750f442b1c890bda89cae3477251be Mon Sep 17 00:00:00 2001 From: jannisjung <92165516+jannisjung@users.noreply.github.com> Date: Tue, 28 May 2024 13:10:56 +0200 Subject: [PATCH] Adds feature to get all submodels from a shell (#293) * Adds feature to get all submodels from a shell Signed-off-by: Jannis Jung * Applies Formatter Signed-off-by: Jannis Jung * Fixes Java Doc Signed-off-by: Jannis Jung * Fix minor issues --------- Signed-off-by: Jannis Jung Co-authored-by: Mateus Molina --- .../client/ConnectedAasManager.java | 52 ++++++++++++++- .../NoValidEndpointFoundException.java | 7 ++- .../RegistryHttpRequestException.java | 8 +++ .../resolvers/AasDescriptorResolver.java | 17 ++++- .../client/resolvers/EndpointResolver.java | 48 ++++++++++++-- .../resolvers/SubmodelDescriptorResolver.java | 20 +++++- .../client/TestConnectedAasManager.java | 63 ++++++++++++++----- .../aasenvironment/client/TestFixture.java | 3 +- 8 files changed, 187 insertions(+), 31 deletions(-) diff --git a/basyx.aasenvironment/basyx.aasenvironment-client/src/main/java/org/eclipse/digitaltwin/basyx/aasenvironment/client/ConnectedAasManager.java b/basyx.aasenvironment/basyx.aasenvironment-client/src/main/java/org/eclipse/digitaltwin/basyx/aasenvironment/client/ConnectedAasManager.java index 57ae15b71..bc913e7b4 100644 --- a/basyx.aasenvironment/basyx.aasenvironment-client/src/main/java/org/eclipse/digitaltwin/basyx/aasenvironment/client/ConnectedAasManager.java +++ b/basyx.aasenvironment/basyx.aasenvironment-client/src/main/java/org/eclipse/digitaltwin/basyx/aasenvironment/client/ConnectedAasManager.java @@ -25,8 +25,15 @@ package org.eclipse.digitaltwin.basyx.aasenvironment.client; +import java.util.List; +import java.util.stream.Collectors; + import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.util.AasUtils; import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; +import org.eclipse.digitaltwin.aas4j.v3.model.Key; +import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; +import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes; import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; import org.eclipse.digitaltwin.basyx.aasenvironment.client.exceptions.NoValidEndpointFoundException; import org.eclipse.digitaltwin.basyx.aasenvironment.client.exceptions.RegistryHttpRequestException; @@ -46,7 +53,7 @@ /** * Client component for executing consolidated Repository and Registry requests * - * @author mateusmolina + * @author mateusmolina, jungjan * */ public class ConnectedAasManager { @@ -126,6 +133,22 @@ public ConnectedSubmodelService getSubmodel(String identifier) { return smDescriptorResolver.resolveSubmodelDescriptor(descriptor); } + /** + * Retrieves all registered Submodels of a registered Asset Administration Shell + * + * @param shellIdentifier + * The identifier of the Shell to retrieve. + * @return The retrieved Submodel object. + */ + public List getAllSubmodels(String shellIdentifier) { + AssetAdministrationShell shell = getAas(shellIdentifier).getAAS(); + List submodelReferences = shell.getSubmodels(); + return submodelReferences.parallelStream() + .map(this::extractSubmodelIdentifierFromReference) + .map(this::getSubmodel) + .collect(Collectors.toList()); + } + /** * Deletes an AAS by its identifier. * @@ -199,5 +222,30 @@ public void createSubmodelInAas(String aasIdentifier, Submodel submodel) { aasRepository.addSubmodelReference(aasIdentifier, AasUtils.toReference(submodel)); } -} + private String extractSubmodelIdentifierFromReference(Reference submodelReference) { + assertIsSubmodelReference(submodelReference); + Key submodelKey = extractSubmodelKeyFromReference(submodelReference); + return submodelKey.getValue(); + } + private void assertIsSubmodelReference(Reference submodelReference) { + if (!submodelReference.getType() + .equals(ReferenceTypes.MODEL_REFERENCE)) { + throw new RuntimeException("A submodel reference must be of type MODEL_REFERENCE."); + } + assertFirstKeyIsOfTypeSubmodel(submodelReference); + } + + private void assertFirstKeyIsOfTypeSubmodel(Reference submodelReference) { + if (!extractSubmodelKeyFromReference(submodelReference).getType() + .equals(KeyTypes.SUBMODEL)) { + throw new RuntimeException("The first key of a submodelReference must be of KeyType SUBMODEL submodel.."); + } + } + + private Key extractSubmodelKeyFromReference(Reference submodelReference) { + return submodelReference.getKeys() + .get(0); + } + +} diff --git a/basyx.aasenvironment/basyx.aasenvironment-client/src/main/java/org/eclipse/digitaltwin/basyx/aasenvironment/client/exceptions/NoValidEndpointFoundException.java b/basyx.aasenvironment/basyx.aasenvironment-client/src/main/java/org/eclipse/digitaltwin/basyx/aasenvironment/client/exceptions/NoValidEndpointFoundException.java index 4b700e6c0..826936e7d 100644 --- a/basyx.aasenvironment/basyx.aasenvironment-client/src/main/java/org/eclipse/digitaltwin/basyx/aasenvironment/client/exceptions/NoValidEndpointFoundException.java +++ b/basyx.aasenvironment/basyx.aasenvironment-client/src/main/java/org/eclipse/digitaltwin/basyx/aasenvironment/client/exceptions/NoValidEndpointFoundException.java @@ -33,11 +33,16 @@ */ @SuppressWarnings("serial") public class NoValidEndpointFoundException extends RuntimeException { + /** + * Constructs a NoValidEndpointException + * + * @param endpoints + */ public NoValidEndpointFoundException(String endpoints) { super(getMessage(endpoints)); } - public static String getMessage(String endpoints) { + private static String getMessage(String endpoints) { return "No valid endpoint found in " + endpoints; } } diff --git a/basyx.aasenvironment/basyx.aasenvironment-client/src/main/java/org/eclipse/digitaltwin/basyx/aasenvironment/client/exceptions/RegistryHttpRequestException.java b/basyx.aasenvironment/basyx.aasenvironment-client/src/main/java/org/eclipse/digitaltwin/basyx/aasenvironment/client/exceptions/RegistryHttpRequestException.java index 11662abec..5b8ea3f40 100644 --- a/basyx.aasenvironment/basyx.aasenvironment-client/src/main/java/org/eclipse/digitaltwin/basyx/aasenvironment/client/exceptions/RegistryHttpRequestException.java +++ b/basyx.aasenvironment/basyx.aasenvironment-client/src/main/java/org/eclipse/digitaltwin/basyx/aasenvironment/client/exceptions/RegistryHttpRequestException.java @@ -34,6 +34,14 @@ @SuppressWarnings("serial") public class RegistryHttpRequestException extends RuntimeException { + /** + * Constructs a RegistryHttpRequestExcrption + * + * @param id + * The Identifier of the Identifiable + * @param th + * The original exception + */ public RegistryHttpRequestException(String id, Throwable th) { super(getMessage(id), th); } diff --git a/basyx.aasenvironment/basyx.aasenvironment-client/src/main/java/org/eclipse/digitaltwin/basyx/aasenvironment/client/resolvers/AasDescriptorResolver.java b/basyx.aasenvironment/basyx.aasenvironment-client/src/main/java/org/eclipse/digitaltwin/basyx/aasenvironment/client/resolvers/AasDescriptorResolver.java index b6c8d955d..927586b6c 100644 --- a/basyx.aasenvironment/basyx.aasenvironment-client/src/main/java/org/eclipse/digitaltwin/basyx/aasenvironment/client/resolvers/AasDescriptorResolver.java +++ b/basyx.aasenvironment/basyx.aasenvironment-client/src/main/java/org/eclipse/digitaltwin/basyx/aasenvironment/client/resolvers/AasDescriptorResolver.java @@ -42,10 +42,21 @@ public class AasDescriptorResolver { private final EndpointResolver endpointResolver; + /** + * Creates an AASDescriptorResolver + * + * @param endpointResolver + */ public AasDescriptorResolver(EndpointResolver endpointResolver) { this.endpointResolver = endpointResolver; } + /** + * Resolves an AASDescriptor to a ConnectedAasService + * + * @param aasDescriptor + * @return + */ public ConnectedAasService resolveAasDescriptor(AssetAdministrationShellDescriptor aasDescriptor) { String endpoint = endpointResolver.resolveFirst(aasDescriptor.getEndpoints(), AasDescriptorResolver::parseEndpoint); @@ -54,10 +65,12 @@ public ConnectedAasService resolveAasDescriptor(AssetAdministrationShellDescript private static Optional parseEndpoint(Endpoint endpoint) { try { - if (endpoint == null || endpoint.getProtocolInformation() == null || endpoint.getProtocolInformation().getHref() == null) + if (endpoint == null || endpoint.getProtocolInformation() == null || endpoint.getProtocolInformation() + .getHref() == null) return Optional.empty(); - String baseHref = endpoint.getProtocolInformation().getHref(); + String baseHref = endpoint.getProtocolInformation() + .getHref(); // TODO not working: String queryString = "?" + endpoint.toUrlQueryString(); String queryString = ""; URI uri = new URI(baseHref + queryString); diff --git a/basyx.aasenvironment/basyx.aasenvironment-client/src/main/java/org/eclipse/digitaltwin/basyx/aasenvironment/client/resolvers/EndpointResolver.java b/basyx.aasenvironment/basyx.aasenvironment-client/src/main/java/org/eclipse/digitaltwin/basyx/aasenvironment/client/resolvers/EndpointResolver.java index 0f560bcfd..62675d9f1 100644 --- a/basyx.aasenvironment/basyx.aasenvironment-client/src/main/java/org/eclipse/digitaltwin/basyx/aasenvironment/client/resolvers/EndpointResolver.java +++ b/basyx.aasenvironment/basyx.aasenvironment-client/src/main/java/org/eclipse/digitaltwin/basyx/aasenvironment/client/resolvers/EndpointResolver.java @@ -39,33 +39,69 @@ * */ public class EndpointResolver { - + private int timeout = 3000; + /** + * Creates an EndpointResolver with default timeout + */ public EndpointResolver() { } + /** + * Creates an EndpointResolver with a custom timeout + * + * @param timeout + */ public EndpointResolver(int timeout) { this.timeout = timeout; } + /** + * Resolves the first working Endpoint from a list of endpoints + * + * @param + * @param endpoints + * @param uriParser + * @return + */ public String resolveFirst(List endpoints, URIParser uriParser) { - List uris = endpoints.stream().map(uriParser::parse).flatMap(Optional::stream).toList(); - return findFirstWorkingURI(uris).orElseThrow(() -> new NoValidEndpointFoundException(endpoints.toString())).toString(); + List uris = endpoints.stream() + .map(uriParser::parse) + .flatMap(Optional::stream) + .toList(); + return findFirstWorkingURI(uris).orElseThrow(() -> new NoValidEndpointFoundException(endpoints.toString())) + .toString(); } + /** + * Resolves all working endpoints from a list of endpoints + * + * @param + * @param endpoints + * @param uriParser + * @return + */ public List resolveAll(List endpoints, URIParser uriParser) { - return endpoints.stream().map(uriParser::parse).flatMap(Optional::stream).filter(this::isURIWorking).map(URI::toString).toList(); + return endpoints.stream() + .map(uriParser::parse) + .flatMap(Optional::stream) + .filter(this::isURIWorking) + .map(URI::toString) + .toList(); } private Optional findFirstWorkingURI(List uris) { - return uris.stream().filter(this::isURIWorking).findFirst(); + return uris.stream() + .filter(this::isURIWorking) + .findFirst(); } private boolean isURIWorking(URI uri) { HttpURLConnection connection = null; try { - connection = (HttpURLConnection) uri.toURL().openConnection(); + connection = (HttpURLConnection) uri.toURL() + .openConnection(); connection.setRequestMethod("HEAD"); connection.setConnectTimeout(timeout); connection.setReadTimeout(timeout); diff --git a/basyx.aasenvironment/basyx.aasenvironment-client/src/main/java/org/eclipse/digitaltwin/basyx/aasenvironment/client/resolvers/SubmodelDescriptorResolver.java b/basyx.aasenvironment/basyx.aasenvironment-client/src/main/java/org/eclipse/digitaltwin/basyx/aasenvironment/client/resolvers/SubmodelDescriptorResolver.java index 53dc6b552..dc0cb6c4e 100644 --- a/basyx.aasenvironment/basyx.aasenvironment-client/src/main/java/org/eclipse/digitaltwin/basyx/aasenvironment/client/resolvers/SubmodelDescriptorResolver.java +++ b/basyx.aasenvironment/basyx.aasenvironment-client/src/main/java/org/eclipse/digitaltwin/basyx/aasenvironment/client/resolvers/SubmodelDescriptorResolver.java @@ -33,7 +33,7 @@ import org.eclipse.digitaltwin.basyx.submodelservice.client.ConnectedSubmodelService; /** - * Resolves an SubmodelDescriptor into a Submodel + * Resolves a SubmodelDescriptor into a Submodel * * @author mateusmolina * @@ -42,10 +42,22 @@ public class SubmodelDescriptorResolver { private final EndpointResolver endpointResolver; + /** + * Constructs a SubmodelDescriptorResolver + * + * @param endpointResolver + */ public SubmodelDescriptorResolver(EndpointResolver endpointResolver) { this.endpointResolver = endpointResolver; } + /** + * Resolves a Submodel Descriptor to a Connected SubmodelService + * + * @param smDescriptor + * the Submodel Descriptor to be resolved + * @return the Connected submodelserver + */ public ConnectedSubmodelService resolveSubmodelDescriptor(SubmodelDescriptor smDescriptor) { String endpoint = endpointResolver.resolveFirst(smDescriptor.getEndpoints(), SubmodelDescriptorResolver::parseEndpoint); @@ -54,10 +66,12 @@ public ConnectedSubmodelService resolveSubmodelDescriptor(SubmodelDescriptor smD private static Optional parseEndpoint(Endpoint endpoint) { try { - if (endpoint == null || endpoint.getProtocolInformation() == null || endpoint.getProtocolInformation().getHref() == null) + if (endpoint == null || endpoint.getProtocolInformation() == null || endpoint.getProtocolInformation() + .getHref() == null) return Optional.empty(); - String baseHref = endpoint.getProtocolInformation().getHref(); + String baseHref = endpoint.getProtocolInformation() + .getHref(); // TODO not working: String queryString = "?" + endpoint.toUrlQueryString(); String queryString = ""; URI uri = new URI(baseHref + queryString); diff --git a/basyx.aasenvironment/basyx.aasenvironment-client/src/test/java/org/eclipse/digitaltwin/basyx/aasenvironment/client/TestConnectedAasManager.java b/basyx.aasenvironment/basyx.aasenvironment-client/src/test/java/org/eclipse/digitaltwin/basyx/aasenvironment/client/TestConnectedAasManager.java index d0b941fc7..8ba010436 100644 --- a/basyx.aasenvironment/basyx.aasenvironment-client/src/test/java/org/eclipse/digitaltwin/basyx/aasenvironment/client/TestConnectedAasManager.java +++ b/basyx.aasenvironment/basyx.aasenvironment-client/src/test/java/org/eclipse/digitaltwin/basyx/aasenvironment/client/TestConnectedAasManager.java @@ -33,6 +33,10 @@ import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; import org.eclipse.digitaltwin.basyx.aasenvironment.client.exceptions.NoValidEndpointFoundException; @@ -46,6 +50,7 @@ import org.eclipse.digitaltwin.basyx.submodelregistry.client.model.SubmodelDescriptor; import org.eclipse.digitaltwin.basyx.submodelrepository.SubmodelRepository; import org.eclipse.digitaltwin.basyx.submodelrepository.client.ConnectedSubmodelRepository; +import org.eclipse.digitaltwin.basyx.submodelservice.client.ConnectedSubmodelService; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; @@ -80,7 +85,6 @@ public class TestConnectedAasManager { private ConnectedAasManager aasManager; - @BeforeClass public static void initApplication() { appContext = new SpringApplication(DummyAasEnvironmentComponent.class).run(new String[] {}); @@ -100,7 +104,7 @@ public void setupRepositories() { connectedSmRepository = spy(new ConnectedSubmodelRepository(SM_REPOSITORY_BASE_PATH)); aasRegistryApi = spy(new RegistryAndDiscoveryInterfaceApi(AAS_REGISTRY_BASE_PATH)); smRegistryApi = spy(new SubmodelRegistryApi(SM_REGISTRY_BASE_PATH)); - + aasManager = new ConnectedAasManager(aasRegistryApi, connectedAasRepository, AAS_REPOSITORY_BASE_PATH, smRegistryApi, connectedSmRepository, SM_REPOSITORY_BASE_PATH); cleanUpRegistries(); @@ -120,11 +124,13 @@ public void createAas() throws ApiException { AssetAdministrationShellDescriptor expectedDescriptor = FIXTURE.buildAasPos1Descriptor(); aasManager.createAas(expectedAas); - + InOrder inOrder = inOrder(connectedAasRepository, aasRegistryApi); - inOrder.verify(connectedAasRepository, times(1)).createAas(expectedAas); - inOrder.verify(aasRegistryApi, times(1)).postAssetAdministrationShellDescriptor(expectedDescriptor); + inOrder.verify(connectedAasRepository, times(1)) + .createAas(expectedAas); + inOrder.verify(aasRegistryApi, times(1)) + .postAssetAdministrationShellDescriptor(expectedDescriptor); assertEquals(expectedAas, aasRepository.getAas(TestFixture.AAS_POS1_ID)); assertEquals(expectedDescriptor, new RegistryAndDiscoveryInterfaceApi(AAS_REGISTRY_BASE_PATH).getAssetAdministrationShellDescriptorById(TestFixture.AAS_POS1_ID)); @@ -139,9 +145,12 @@ public void createSubmodelInAas() throws Exception { InOrder inOrder = inOrder(connectedSmRepository, smRegistryApi, connectedAasRepository); - inOrder.verify(connectedSmRepository, times(1)).createSubmodel(expectedSm); - inOrder.verify(smRegistryApi, times(1)).postSubmodelDescriptor(expectedDescriptor); - inOrder.verify(connectedAasRepository, times(1)).addSubmodelReference(eq(TestFixture.AAS_PRE1_ID), any()); + inOrder.verify(connectedSmRepository, times(1)) + .createSubmodel(expectedSm); + inOrder.verify(smRegistryApi, times(1)) + .postSubmodelDescriptor(expectedDescriptor); + inOrder.verify(connectedAasRepository, times(1)) + .addSubmodelReference(eq(TestFixture.AAS_PRE1_ID), any()); assertEquals(expectedSm, smRepository.getSubmodel(TestFixture.SM_POS1_ID)); assertEquals(expectedDescriptor, new SubmodelRegistryApi(SM_REGISTRY_BASE_PATH).getSubmodelDescriptorById(TestFixture.SM_POS1_ID)); @@ -153,8 +162,10 @@ public void deleteAas() throws ApiException { InOrder inOrder = inOrder(aasRegistryApi, connectedAasRepository); - inOrder.verify(aasRegistryApi, times(1)).deleteAssetAdministrationShellDescriptorById(TestFixture.AAS_PRE1_ID); - inOrder.verify(connectedAasRepository, times(1)).deleteAas(TestFixture.AAS_PRE1_ID); + inOrder.verify(aasRegistryApi, times(1)) + .deleteAssetAdministrationShellDescriptorById(TestFixture.AAS_PRE1_ID); + inOrder.verify(connectedAasRepository, times(1)) + .deleteAas(TestFixture.AAS_PRE1_ID); assertThrows(ElementDoesNotExistException.class, () -> aasRepository.getAas(TestFixture.AAS_PRE1_ID)); assertThrows(Exception.class, () -> new RegistryAndDiscoveryInterfaceApi(AAS_REGISTRY_BASE_PATH).getAssetAdministrationShellDescriptorById(TestFixture.AAS_PRE1_ID)); @@ -166,9 +177,12 @@ public void deleteSubmodelOfAas() throws Exception { InOrder inOrder = inOrder(smRegistryApi, connectedAasRepository, connectedSmRepository); - inOrder.verify(smRegistryApi, times(1)).deleteSubmodelDescriptorById(TestFixture.SM_PRE1_ID); - inOrder.verify(connectedAasRepository, times(1)).removeSubmodelReference(TestFixture.AAS_PRE1_ID, TestFixture.SM_PRE1_ID); - inOrder.verify(connectedSmRepository, times(1)).deleteSubmodel(TestFixture.SM_PRE1_ID); + inOrder.verify(smRegistryApi, times(1)) + .deleteSubmodelDescriptorById(TestFixture.SM_PRE1_ID); + inOrder.verify(connectedAasRepository, times(1)) + .removeSubmodelReference(TestFixture.AAS_PRE1_ID, TestFixture.SM_PRE1_ID); + inOrder.verify(connectedSmRepository, times(1)) + .deleteSubmodel(TestFixture.SM_PRE1_ID); assertThrows(ElementDoesNotExistException.class, () -> smRepository.getSubmodel(TestFixture.SM_PRE1_ID)); assertThrows(Exception.class, () -> new SubmodelRegistryApi(SM_REGISTRY_BASE_PATH).getSubmodelDescriptorById(TestFixture.SM_PRE1_ID)); @@ -177,8 +191,9 @@ public void deleteSubmodelOfAas() throws Exception { @Test public void getAas() throws ApiException, NoValidEndpointFoundException { AssetAdministrationShell expectedAas = FIXTURE.buildAasPre1(); - - AssetAdministrationShell actualAas = aasManager.getAas(TestFixture.AAS_PRE1_ID).getAAS(); + + AssetAdministrationShell actualAas = aasManager.getAas(TestFixture.AAS_PRE1_ID) + .getAAS(); assertEquals(expectedAas, actualAas); } @@ -187,11 +202,27 @@ public void getAas() throws ApiException, NoValidEndpointFoundException { public void getSubmodel() throws Exception { Submodel expectedSm = FIXTURE.buildSmPre1(); - Submodel actualSm = aasManager.getSubmodel(TestFixture.SM_PRE1_ID).getSubmodel(); + Submodel actualSm = aasManager.getSubmodel(TestFixture.SM_PRE1_ID) + .getSubmodel(); assertEquals(expectedSm, actualSm); } + @Test + public void getAllSubmodels() { + Submodel otherExpectedSubmodel = FIXTURE.buildSmPos1(); + Submodel[] expectedSubmodels = { FIXTURE.buildSmPre1(), otherExpectedSubmodel }; + + aasManager.createSubmodelInAas(TestFixture.AAS_PRE1_ID, otherExpectedSubmodel); + + List actualSubmodelServices = aasManager.getAllSubmodels(TestFixture.AAS_PRE1_ID); + List actualSubmodels = actualSubmodelServices.stream() + .map(submodelService -> submodelService.getSubmodel()) + .collect(Collectors.toList()); + assertEquals(Arrays.asList(expectedSubmodels), actualSubmodels); + + } + private void populateRegistries() { try { new RegistryAndDiscoveryInterfaceApi(AAS_REGISTRY_BASE_PATH).postAssetAdministrationShellDescriptor(FIXTURE.buildAasPre1Descriptor()); diff --git a/basyx.aasenvironment/basyx.aasenvironment-client/src/test/java/org/eclipse/digitaltwin/basyx/aasenvironment/client/TestFixture.java b/basyx.aasenvironment/basyx.aasenvironment-client/src/test/java/org/eclipse/digitaltwin/basyx/aasenvironment/client/TestFixture.java index 8e6a2fe96..1947c78e0 100644 --- a/basyx.aasenvironment/basyx.aasenvironment-client/src/test/java/org/eclipse/digitaltwin/basyx/aasenvironment/client/TestFixture.java +++ b/basyx.aasenvironment/basyx.aasenvironment-client/src/test/java/org/eclipse/digitaltwin/basyx/aasenvironment/client/TestFixture.java @@ -30,6 +30,7 @@ import org.eclipse.digitaltwin.aas4j.v3.model.AssetKind; import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes; import org.eclipse.digitaltwin.aas4j.v3.model.Reference; +import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes; import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultAssetAdministrationShell; import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultAssetInformation; @@ -89,7 +90,7 @@ public AssetAdministrationShellDescriptor buildAasPre1Descriptor() { } public Reference buildSmPre1Ref() { - return new DefaultReference.Builder().keys(new DefaultKey.Builder().type(KeyTypes.SUBMODEL).value(SM_PRE1_ID).build()).build(); + return new DefaultReference.Builder().type(ReferenceTypes.MODEL_REFERENCE).keys(new DefaultKey.Builder().type(KeyTypes.SUBMODEL).value(SM_PRE1_ID).build()).build(); } public Submodel buildSmPre1() {