Merge "Remove nested variant from ISubModelAPI"
diff --git a/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/aas/AddSubmodelToAAS.java b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/aas/AddSubmodelToAAS.java
new file mode 100644
index 0000000..62bfe8f
--- /dev/null
+++ b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/aas/AddSubmodelToAAS.java
@@ -0,0 +1,40 @@
+package org.eclipse.basyx.examples.snippets.aas;
+
+import org.eclipse.basyx.aas.manager.ConnectedAssetAdministrationShellManager;
+import org.eclipse.basyx.aas.registration.proxy.AASRegistryProxy;
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IIdentifier;
+import org.eclipse.basyx.submodel.metamodel.map.SubModel;
+
+/**
+ * This snippet showcases how to add a Submodel to an AAS,
+ * that already exists on a server
+ *
+ * @author conradi
+ *
+ */
+public class AddSubmodelToAAS {
+
+ /**
+ * Adds a Submodel to an AAS and registers it
+ *
+ * @param submodel the Submodel to be added
+ * @param aasIdentifier the Identifier of the AAS the Submodel should be added to
+ * @param registryServerURL the URL of the registry server
+ */
+ public static void addSubmodelToAAS(SubModel submodel, IIdentifier aasIdentifier, String registryServerURL) {
+
+ // Create a proxy pointing to the registry server
+ AASRegistryProxy registryProxy = new AASRegistryProxy(registryServerURL);
+
+ // Create a ConnectedAASManager using the registryProxy as its registry
+ ConnectedAssetAdministrationShellManager manager =
+ new ConnectedAssetAdministrationShellManager(registryProxy);
+
+ // Add the submodel to the AAS using the ConnectedAASManager
+ // The manager pushes the submodel to the server and registers it
+ // For this to work, the Identification of the Submodel has to be set
+ manager.createSubModel(aasIdentifier, submodel);
+
+ }
+
+}
diff --git a/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/aas/DeleteAAS.java b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/aas/DeleteAAS.java
new file mode 100644
index 0000000..b79efdf
--- /dev/null
+++ b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/aas/DeleteAAS.java
@@ -0,0 +1,34 @@
+package org.eclipse.basyx.examples.snippets.aas;
+
+import org.eclipse.basyx.aas.manager.ConnectedAssetAdministrationShellManager;
+import org.eclipse.basyx.aas.registration.proxy.AASRegistryProxy;
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IIdentifier;
+
+/**
+ * Snippet that showcases how to delete an AAS from a server
+ *
+ * @author conradi
+ *
+ */
+public class DeleteAAS {
+
+ /**
+ * Removes an AAS from the server
+ *
+ * @param aasIdentifier the Identifier of the AAS to be deleted
+ * @param registryServerURL the URL of the registry server (e.g. http://localhost:8080/registry)
+ */
+ public static void deleteAAS(IIdentifier aasIdentifier, String registryServerURL) {
+
+ // Create a proxy pointing to the registry server
+ AASRegistryProxy registryProxy = new AASRegistryProxy(registryServerURL);
+
+ // Create a ConnectedAASManager using the registryProxy as its registry
+ ConnectedAssetAdministrationShellManager manager =
+ new ConnectedAssetAdministrationShellManager(registryProxy);
+
+ // Delete the AAS
+ // Automatically deregisters it
+ manager.deleteAAS(aasIdentifier);
+ }
+}
diff --git a/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/aas/DeleteSubmodelFromAAS.java b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/aas/DeleteSubmodelFromAAS.java
new file mode 100644
index 0000000..a6e0809
--- /dev/null
+++ b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/aas/DeleteSubmodelFromAAS.java
@@ -0,0 +1,35 @@
+package org.eclipse.basyx.examples.snippets.aas;
+
+import org.eclipse.basyx.aas.manager.ConnectedAssetAdministrationShellManager;
+import org.eclipse.basyx.aas.registration.proxy.AASRegistryProxy;
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IIdentifier;
+
+/**
+ * Snippet that showcases how to delete a Submodel from a server
+ *
+ * @author conradi
+ *
+ */
+public class DeleteSubmodelFromAAS {
+
+ /**
+ * Removes a Submodel from an AAS
+ *
+ * @param smIdentifier the Identifier of the Submodel to be deleted
+ * @param aasIdentifier the Identifier of the AAS the Submodel belongs to
+ * @param registryServerURL the URL of the registry server (e.g. http://localhost:8080/registry)
+ */
+ public static void deleteSubmodelFromAAS(IIdentifier smIdentifier, IIdentifier aasIdentifier, String registryServerURL) {
+
+ // Create a proxy pointing to the registry server
+ AASRegistryProxy registryProxy = new AASRegistryProxy(registryServerURL);
+
+ // Create a ConnectedAASManager using the registryProxy as its registry
+ ConnectedAssetAdministrationShellManager manager =
+ new ConnectedAssetAdministrationShellManager(registryProxy);
+
+ // Delete the Submodel
+ // Automatically deregisters it
+ manager.deleteSubModel(aasIdentifier, smIdentifier);
+ }
+}
\ No newline at end of file
diff --git a/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/aas/LookupAAS.java b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/aas/LookupAAS.java
new file mode 100644
index 0000000..e7ed77c
--- /dev/null
+++ b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/aas/LookupAAS.java
@@ -0,0 +1,31 @@
+package org.eclipse.basyx.examples.snippets.aas;
+
+import org.eclipse.basyx.aas.metamodel.map.descriptor.AASDescriptor;
+import org.eclipse.basyx.aas.registration.proxy.AASRegistryProxy;
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IIdentifier;
+
+/**
+ * Snippet that showcases how to look up an AAS in a RegistryComponent
+ *
+ * @author conradi
+ *
+ */
+public class LookupAAS {
+
+ /**
+ * Gets the Descriptor of the requested AAS from a registry
+ *
+ * @param aasIdentifier the Identifier of the AAS to be looked up in the registry
+ * @param registryServerURL the URL of the registry server
+ * @return the AASDescriptor looked up in the registry
+ */
+ public static AASDescriptor lookupAAS(IIdentifier aasIdentifier, String registryServerURL) {
+
+ // Create a proxy pointing to the registry
+ AASRegistryProxy registryProxy = new AASRegistryProxy(registryServerURL);
+
+ // Lookup the AAS in the registry
+ return registryProxy.lookupAAS(aasIdentifier);
+ }
+
+}
diff --git a/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/aas/PushAASToServer.java b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/aas/PushAASToServer.java
new file mode 100644
index 0000000..7a78f28
--- /dev/null
+++ b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/aas/PushAASToServer.java
@@ -0,0 +1,37 @@
+package org.eclipse.basyx.examples.snippets.aas;
+
+import org.eclipse.basyx.aas.manager.ConnectedAssetAdministrationShellManager;
+import org.eclipse.basyx.aas.metamodel.map.AssetAdministrationShell;
+import org.eclipse.basyx.aas.registration.proxy.AASRegistryProxy;
+
+
+/**
+ * This snippet showcases how to push a AAS to a server
+ *
+ * @author conradi
+ *
+ */
+public class PushAASToServer {
+
+ /**
+ * Pushes the AAS to a server and registers it
+ *
+ * @param aas the AssetAdministrationShell to be pushed to the server
+ * @param aasServerURL the URL of the aas server (e.g. http://localhost:8080/aasComponent)
+ * @param registryServerURL the URL of the registry server (e.g. http://localhost:8080/registry)
+ */
+ public static void pushAAS(AssetAdministrationShell aas, String aasServerURL, String registryServerURL) {
+
+ // Create a proxy pointing to the registry server
+ AASRegistryProxy registryProxy = new AASRegistryProxy(registryServerURL);
+
+ // Create a ConnectedAASManager using the registryProxy as its registry
+ ConnectedAssetAdministrationShellManager manager =
+ new ConnectedAssetAdministrationShellManager(registryProxy);
+
+ // The ConnectedAASManager automatically pushes the given AAS
+ // to the server to which the address was given
+ // It also registers the AAS in the registry it got in its ctor
+ manager.createAAS(aas, aasServerURL);
+ }
+}
\ No newline at end of file
diff --git a/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/aas/RegisterAAS.java b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/aas/RegisterAAS.java
new file mode 100644
index 0000000..02e96b3
--- /dev/null
+++ b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/aas/RegisterAAS.java
@@ -0,0 +1,34 @@
+package org.eclipse.basyx.examples.snippets.aas;
+
+import org.eclipse.basyx.aas.metamodel.api.IAssetAdministrationShell;
+import org.eclipse.basyx.aas.metamodel.map.descriptor.AASDescriptor;
+import org.eclipse.basyx.aas.registration.proxy.AASRegistryProxy;
+
+/**
+ * Snippet that showcases how to register a given AAS in a RegistryComponent
+ *
+ * @author conradi
+ *
+ */
+public class RegisterAAS {
+
+ /**
+ * Registers a given AssetAdministrationShell in a registry.
+ *
+ * @param aas the AssetAdministrationShell to be registered
+ * @param aasEndpoint the address where the AAS will be hosted (e.g. http://localhost:8080/aasList/{aasId}/aas)
+ * @param registryServerURL the address of the registry
+ */
+ public static void registerAAS(IAssetAdministrationShell aas, String aasEndpoint, String registryServerURL) {
+
+ // Create a proxy pointing to the registry
+ AASRegistryProxy registryProxy = new AASRegistryProxy(registryServerURL);
+
+ // Create a Descriptor for the AAS using the endpoint where it will be hosted
+ AASDescriptor descriptor = new AASDescriptor(aas, aasEndpoint);
+
+ // Register this Descriptor in the registry
+ registryProxy.register(descriptor);
+ }
+
+}
diff --git a/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/aas/RetrieveRemoteAAS.java b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/aas/RetrieveRemoteAAS.java
new file mode 100644
index 0000000..d50c408
--- /dev/null
+++ b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/aas/RetrieveRemoteAAS.java
@@ -0,0 +1,36 @@
+package org.eclipse.basyx.examples.snippets.aas;
+
+import org.eclipse.basyx.aas.manager.ConnectedAssetAdministrationShellManager;
+import org.eclipse.basyx.aas.metamodel.api.IAssetAdministrationShell;
+import org.eclipse.basyx.aas.registration.proxy.AASRegistryProxy;
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IIdentifier;
+
+/**
+ * This snippet showcases how to retrieve an AAS from a server
+ *
+ * @author conradi
+ *
+ */
+public class RetrieveRemoteAAS {
+
+ /**
+ * Get an AAS from a server
+ *
+ * @param aasIdentifier the Identifier of the requested AAS
+ * @param registryServerURL the URL of the registry server
+ * @return The requested AAS as ConnectedAAS
+ */
+ public static IAssetAdministrationShell retrieveRemoteAAS(IIdentifier aasIdentifier, String registryServerURL) {
+
+ // Create a proxy pointing to the registry server
+ AASRegistryProxy registryProxy = new AASRegistryProxy(registryServerURL);
+
+ // Create a ConnectedAASManager using the registryProxy as its registry
+ ConnectedAssetAdministrationShellManager manager =
+ new ConnectedAssetAdministrationShellManager(registryProxy);
+
+ // Get the requested AAS from the manager
+ return manager.retrieveAAS(aasIdentifier);
+ }
+
+}
diff --git a/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/aas/RetrieveSubmodelFromAAS.java b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/aas/RetrieveSubmodelFromAAS.java
new file mode 100644
index 0000000..1404875
--- /dev/null
+++ b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/aas/RetrieveSubmodelFromAAS.java
@@ -0,0 +1,38 @@
+package org.eclipse.basyx.examples.snippets.aas;
+
+import org.eclipse.basyx.aas.manager.ConnectedAssetAdministrationShellManager;
+import org.eclipse.basyx.aas.registration.proxy.AASRegistryProxy;
+import org.eclipse.basyx.submodel.metamodel.api.ISubModel;
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IIdentifier;
+
+
+/**
+ * This snippet showcases how to retrieve a Submodel from a AAS on a server
+ *
+ * @author conradi
+ *
+ */
+public class RetrieveSubmodelFromAAS {
+
+ /**
+ * Gets a Submodel from an AAS
+ *
+ * @param smIdentifier the Identifier of the requested Submodel
+ * @param aasIdentifier the Identifier of the AAS the Submodel belongs to
+ * @param registryServerURL the URL of the registry server
+ * @return the requested Submodel as ConnectedSubModel
+ */
+ public static ISubModel retrieveSubmodelFromAAS(IIdentifier smIdentifier, IIdentifier aasIdentifier, String registryServerURL) {
+
+ // Create a proxy pointing to the registry server
+ AASRegistryProxy registryProxy = new AASRegistryProxy(registryServerURL);
+
+ // Create a ConnectedAASManager using the registryProxy as its registry
+ ConnectedAssetAdministrationShellManager manager =
+ new ConnectedAssetAdministrationShellManager(registryProxy);
+
+ // Get the requested Submodel from the ConnectedAASManager using the Identifiers of the AAS and the SM
+ return manager.retrieveSubModel(aasIdentifier, smIdentifier);
+ }
+
+}
diff --git a/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/submodel/AddSubmodelElement.java b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/submodel/AddSubmodelElement.java
new file mode 100644
index 0000000..a33e08d
--- /dev/null
+++ b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/submodel/AddSubmodelElement.java
@@ -0,0 +1,35 @@
+package org.eclipse.basyx.examples.snippets.submodel;
+
+import org.eclipse.basyx.examples.snippets.aas.RetrieveSubmodelFromAAS;
+import org.eclipse.basyx.submodel.metamodel.api.ISubModel;
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IIdentifier;
+import org.eclipse.basyx.submodel.metamodel.map.submodelelement.SubmodelElement;
+
+/**
+ * This snippet showcases how add to a SubmodelElement to a Submodel,
+ * that already exists on a server
+ *
+ * @author conradi
+ *
+ */
+public class AddSubmodelElement {
+
+ /**
+ * Adds a SubmodelElement to a remote Submodel
+ *
+ * @param smElement the SubmodelElement to be added
+ * @param smIdentifier the Identifier of the Submodel the element should be added to
+ * @param aasIdentifier the Identifier of the AAS the Submodel belongs to
+ * @param registryServerURL the URL of the registry server
+ */
+ public static void addSubmodelElement(SubmodelElement smElement, IIdentifier smIdentifier, IIdentifier aasIdentifier, String registryServerURL) {
+
+ // Get the ConnectedSubmodel
+ ISubModel submodel = RetrieveSubmodelFromAAS.retrieveSubmodelFromAAS(smIdentifier, aasIdentifier, registryServerURL);
+
+ // Add the element to it
+ submodel.addSubModelElement(smElement);
+
+ }
+
+}
\ No newline at end of file
diff --git a/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/submodel/DeleteSubmodelElement.java b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/submodel/DeleteSubmodelElement.java
new file mode 100644
index 0000000..8e31408
--- /dev/null
+++ b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/submodel/DeleteSubmodelElement.java
@@ -0,0 +1,31 @@
+package org.eclipse.basyx.examples.snippets.submodel;
+
+import org.eclipse.basyx.examples.snippets.aas.RetrieveSubmodelFromAAS;
+import org.eclipse.basyx.submodel.metamodel.api.ISubModel;
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IIdentifier;
+
+/**
+ * Snippet that showcases how to delete a SubmodelElement from a Submodel
+ *
+ * @author conradi
+ *
+ */
+public class DeleteSubmodelElement {
+
+ /**
+ * Removes a SubmodelElement from a Submodel
+ *
+ * @param elementId the Id of the Element to be deleted (can also be a path if the Element is in a Collection)
+ * @param smIdentifier the Identifier of the Submodel the Element belongs to
+ * @param aasIdentifier the Identifier of the AAS the Submodel belongs to
+ * @param registryServerURL the URL of the registry server (e.g. http://localhost:8080/registry)
+ */
+ public static void deleteSubmodelElement(String elementId, IIdentifier smIdentifier, IIdentifier aasIdentifier, String registryServerURL) {
+
+ // Retrieve the Submodel from the server as a ConnectedSubmodel
+ ISubModel submodel = RetrieveSubmodelFromAAS.retrieveSubmodelFromAAS(smIdentifier, aasIdentifier, registryServerURL);
+
+ // Delete the Element from the Submodel
+ submodel.deleteSubmodelElement(elementId);
+ }
+}
diff --git a/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/submodel/ExecuteOperation.java b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/submodel/ExecuteOperation.java
new file mode 100644
index 0000000..74d5774
--- /dev/null
+++ b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/submodel/ExecuteOperation.java
@@ -0,0 +1,45 @@
+package org.eclipse.basyx.examples.snippets.submodel;
+
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IIdentifier;
+import org.eclipse.basyx.submodel.metamodel.api.submodelelement.ISubmodelElement;
+import org.eclipse.basyx.submodel.metamodel.api.submodelelement.operation.IOperation;
+
+/**
+ * Snippet that showcases how to execute an Operation contained in a Submodel
+ *
+ * @author conradi
+ *
+ */
+public class ExecuteOperation {
+
+ /**
+ * Executes an Operation with the given parameters and return the result.
+ * The execution itself is run on the remote server
+ *
+ * @param operationId the idShort of the Operation to be executed
+ * @param operationParameters the parameters for the execution
+ * @param smIdentifier the Identifier of the Submodel the Operation belongs to
+ * @param aasIdentifier the Identifier of the AAS the Submodel belongs to
+ * @param registryServerURL the URL of the registry server
+ * @return the result of the execution
+ * @throws Exception thrown if the execution of the Operation threw an Exception
+ */
+ public static Object executeOperation(String operationId, Object[] operationParameters, IIdentifier smIdentifier, IIdentifier aasIdentifier, String registryServerURL) throws Exception {
+
+ // Get the Operation from the Submodel
+ ISubmodelElement element = RetrieveSubmodelElement.retrieveSubmodelElement(operationId, smIdentifier, aasIdentifier, registryServerURL);
+
+ // Check if the element is really an Operation
+ if( ! (element instanceof IOperation)) {
+ // The element with the given Id is not an Operation
+ throw new IllegalArgumentException("The SubmodelElement '" + operationId + "' is not an Operation");
+ }
+
+ // Cast the retrieved ISubmodelElement to an IOperation
+ IOperation operation = (IOperation) element;
+
+ // Invoke the Operation and return the Result
+ return operation.invoke(operationParameters);
+ }
+
+}
diff --git a/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/submodel/LookupSubmodel.java b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/submodel/LookupSubmodel.java
new file mode 100644
index 0000000..1b3e4f4
--- /dev/null
+++ b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/submodel/LookupSubmodel.java
@@ -0,0 +1,32 @@
+package org.eclipse.basyx.examples.snippets.submodel;
+
+import org.eclipse.basyx.aas.metamodel.map.descriptor.SubmodelDescriptor;
+import org.eclipse.basyx.aas.registration.proxy.AASRegistryProxy;
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IIdentifier;
+
+/**
+ * Snippet that showcases how to look up a Submodel in a RegistryComponent
+ *
+ * @author conradi
+ *
+ */
+public class LookupSubmodel {
+
+ /**
+ * Gets the Descriptor of the requested Submodel from a registry
+ *
+ * @param smIdentifier the Identifier of the Submodel to be looked up in the registry
+ * @param aasIdentifier the Identifier of the AAS the Submodel belongs to
+ * @param registryServerURL the URL of the registry server
+ * @return the SubmodelDescriptor looked up in the registry
+ */
+ public static SubmodelDescriptor lookupSubmodel(IIdentifier smIdentifier, IIdentifier aasIdentifier, String registryServerURL) {
+
+ // Create a proxy pointing to the registry
+ AASRegistryProxy registryProxy = new AASRegistryProxy(registryServerURL);
+
+ // Lookup the Submodel in the registry
+ return registryProxy.lookupSubmodel(aasIdentifier, smIdentifier);
+ }
+
+}
diff --git a/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/submodel/RegisterSubmodel.java b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/submodel/RegisterSubmodel.java
new file mode 100644
index 0000000..6c4a751
--- /dev/null
+++ b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/submodel/RegisterSubmodel.java
@@ -0,0 +1,35 @@
+package org.eclipse.basyx.examples.snippets.submodel;
+
+import org.eclipse.basyx.aas.metamodel.map.descriptor.SubmodelDescriptor;
+import org.eclipse.basyx.aas.registration.proxy.AASRegistryProxy;
+import org.eclipse.basyx.submodel.metamodel.api.ISubModel;
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IIdentifier;
+
+/**
+ * Snippet that showcases how to register a given Submodel in a RegistryComponent
+ *
+ * @author conradi
+ *
+ */
+public class RegisterSubmodel {
+
+ /**
+ * Registers a given Submodel in a registry.
+ *
+ * @param submodel the Submodel to be registered
+ * @param smEndpoint the address where the SM will be hosted (e.g. http://localhost:8080/aasList/{aasId}/aas/submodels/{smId})
+ * @param registryServerURL the address of the registry
+ */
+ public static void registerSubmodel(ISubModel submodel, String smEndpoint, IIdentifier aasIdentifier, String registryServerURL) {
+
+ // Create a proxy pointing to the registry
+ AASRegistryProxy registryProxy = new AASRegistryProxy(registryServerURL);
+
+ // Create a Descriptor for the sm using the endpoint where it will be hosted
+ SubmodelDescriptor descriptor = new SubmodelDescriptor(submodel, smEndpoint);
+
+ // Register this Descriptor in the registry
+ registryProxy.register(aasIdentifier, descriptor);
+ }
+
+}
diff --git a/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/submodel/RetrieveSubmodelElement.java b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/submodel/RetrieveSubmodelElement.java
new file mode 100644
index 0000000..cfce36e
--- /dev/null
+++ b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/snippets/submodel/RetrieveSubmodelElement.java
@@ -0,0 +1,34 @@
+package org.eclipse.basyx.examples.snippets.submodel;
+
+import org.eclipse.basyx.examples.snippets.aas.RetrieveSubmodelFromAAS;
+import org.eclipse.basyx.submodel.metamodel.api.ISubModel;
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IIdentifier;
+import org.eclipse.basyx.submodel.metamodel.api.submodelelement.ISubmodelElement;
+
+/**
+ * This snippet showcases how to retrieve a SubmodelElement from a remote Submodel
+ *
+ * @author conradi
+ *
+ */
+public class RetrieveSubmodelElement {
+
+ /**
+ * Gets a SubmodelElement from a remote Submodel
+ *
+ * @param elementId the idShort SubmodelElement to be retrieved
+ * @param smIdentifier the Identifier of the Submodel the element belongs to
+ * @param aasIdentifier the Identifier of the AAS the Submodel belongs to
+ * @param registryServerURL the URL of the registry server
+ * @return the requested SubmodelElement
+ */
+ public static ISubmodelElement retrieveSubmodelElement(String elementId, IIdentifier smIdentifier, IIdentifier aasIdentifier, String registryServerURL) {
+
+ // Get the ConnectedSubmodel
+ ISubModel submodel = RetrieveSubmodelFromAAS.retrieveSubmodelFromAAS(smIdentifier, aasIdentifier, registryServerURL);
+
+ // Add the element to it
+ return submodel.getSubmodelElement(elementId);
+
+ }
+}
\ No newline at end of file
diff --git a/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/support/ExampleAASComponent.java b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/support/ExampleAASComponent.java
new file mode 100644
index 0000000..4260956
--- /dev/null
+++ b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/support/ExampleAASComponent.java
@@ -0,0 +1,53 @@
+package org.eclipse.basyx.examples.support;
+
+import org.eclipse.basyx.aas.registration.api.IAASRegistryService;
+import org.eclipse.basyx.components.aas.AASServerComponent;
+import org.eclipse.basyx.components.configuration.BaSyxContextConfiguration;
+
+/**
+ * This class is used to startup an AAS-Server using the AASServerComponent
+ *
+ * @author conradi
+ *
+ */
+public class ExampleAASComponent {
+
+ public static final String CONTEXT_PATH = "aasComponent";
+
+ private int port;
+
+ private IAASRegistryService registry;
+
+ // Hold a reference to the server to be able to shut it down
+ private AASServerComponent aasServer = null;
+
+
+ public ExampleAASComponent(int port, IAASRegistryService registry) {
+ this.port = port;
+ this.registry = registry;
+ }
+
+ public void startupAASServer() {
+ // Create a Configuration telling the component the port to use and the contextPath
+ // The contextPath is attached to the address of the server "http://localhost:8080/{contextPath}"
+ BaSyxContextConfiguration contextConfig = new BaSyxContextConfiguration(port, CONTEXT_PATH);
+ aasServer = new AASServerComponent(contextConfig);
+
+ // Set the registry to be used by the server
+ aasServer.setRegistry(registry);
+
+ // Startup the AASServer
+ aasServer.startComponent();
+ }
+
+ public void shutdownAASServer() {
+ // If an AASServer was started -> stop it
+ if(aasServer != null) {
+ aasServer.stopComponent();
+ }
+ }
+
+ public String getAASServerPath() {
+ return "http://localhost:" + port + "/" + CONTEXT_PATH;
+ }
+}
diff --git a/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/support/ExampleComponentBuilder.java b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/support/ExampleComponentBuilder.java
new file mode 100644
index 0000000..7db04ec
--- /dev/null
+++ b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/support/ExampleComponentBuilder.java
@@ -0,0 +1,75 @@
+package org.eclipse.basyx.examples.support;
+
+import org.eclipse.basyx.aas.metamodel.map.AssetAdministrationShell;
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IdentifierType;
+import org.eclipse.basyx.submodel.metamodel.map.SubModel;
+import org.eclipse.basyx.submodel.metamodel.map.submodelelement.SubmodelElementCollection;
+import org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.Property;
+
+/**
+ * This class is used to build AssetAdministrationShells and Submodels
+ * for the scenarios and snippets.
+ *
+ * Please note that the generated objects are just for showcasing,
+ * several mandatory attributes are missing.
+ *
+ * @author conradi
+ *
+ */
+public class ExampleComponentBuilder {
+
+ public static final String PROPERTY_ID = "prop";
+ public static final int PROPERTY_VALUE = 123;
+
+ public static final String COLLECTION_ID = "collection";
+ public static final String COLLECTION_PROPERTY_ID = "propInCollection";
+ public static final String COLLECTION_PROPERTY_VALUE = "TheValue";
+
+ /**
+ * Builds a Submodel containing a Property and a Collection with a Property
+ *
+ * @param idShort the idShort for the new Submodel
+ * @return the new Submodel
+ */
+ public static SubModel buildExampleSubmodel(String idShort, String id) {
+ SubModel submodel = new SubModel();
+ submodel.setIdShort(idShort);
+ submodel.setIdentification(IdentifierType.CUSTOM, id);
+
+ // Add a Property to the Submodel
+ Property property = new Property();
+ property.setIdShort(PROPERTY_ID);
+ property.setValue(PROPERTY_VALUE);
+ submodel.addSubModelElement(property);
+
+ // Add a SubmodelElementCollection
+ SubmodelElementCollection collection = new SubmodelElementCollection();
+ collection.setIdShort(COLLECTION_ID);
+
+ // Add a Property to the SubmodelElementCollection
+ Property property2 = new Property();
+ property2.setIdShort(COLLECTION_PROPERTY_ID);
+ property2.setValue(COLLECTION_PROPERTY_VALUE);
+ collection.addSubModelElement(property2);
+ submodel.addSubModelElement(collection);
+
+ return submodel;
+ }
+
+ /**
+ * Builds an AssetAdministrationShell
+ *
+ * @param idShort the idShort for the new AAS
+ * @param id the id to be used in Identification
+ * @return the new AAS
+ */
+ public static AssetAdministrationShell buildExampleAAS(String idShort, String id) {
+ AssetAdministrationShell aas = new AssetAdministrationShell();
+ aas.setIdShort(idShort);
+
+ aas.setIdentification(IdentifierType.CUSTOM, id);
+
+ return aas;
+ }
+
+}
diff --git a/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/support/ExampleRegistryComponent.java b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/support/ExampleRegistryComponent.java
new file mode 100644
index 0000000..6f6e8a5
--- /dev/null
+++ b/examples/basys.examples/src/main/java/org/eclipse/basyx/examples/support/ExampleRegistryComponent.java
@@ -0,0 +1,53 @@
+package org.eclipse.basyx.examples.support;
+
+import org.eclipse.basyx.components.configuration.BaSyxContextConfiguration;
+import org.eclipse.basyx.components.registry.RegistryComponent;
+import org.eclipse.basyx.components.registry.configuration.BaSyxRegistryConfiguration;
+import org.eclipse.basyx.components.registry.configuration.RegistryBackend;
+
+/**
+ * This class is used to startup a registry using the RegistryComponent
+ *
+ * @author conradi
+ *
+ */
+public class ExampleRegistryComponent {
+
+ public static final String CONTEXT_PATH = "registry";
+
+ private int port;
+
+ // Hold a reference to the server to be able to shut it down
+ private RegistryComponent registry = null;
+
+
+ public ExampleRegistryComponent(int port) {
+ this.port = port;
+ }
+
+
+ public void startupRegistry() {
+ // Create a Configuration telling the component the port to use and the contextPath
+ // The contextPath is attached to the address of the server "http://localhost:8080/{contextPath}"
+ BaSyxContextConfiguration contextConfig = new BaSyxContextConfiguration(port, CONTEXT_PATH);
+
+ // Create a RegistrationConfiguration telling the component to hold the whole registry in memory
+ BaSyxRegistryConfiguration registryConfig = new BaSyxRegistryConfiguration(RegistryBackend.INMEMORY);
+
+ registry = new RegistryComponent(contextConfig, registryConfig);
+
+ // Startup the Registry
+ registry.startComponent();
+ }
+
+ public void shutdownRegistry() {
+ // If a registry was started -> stop it
+ if(registry != null) {
+ registry.stopComponent();
+ }
+ }
+
+ public String getRegistryPath() {
+ return "http://localhost:" + port + "/" + CONTEXT_PATH;
+ }
+}
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/AbstractSnippetTest.java b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/AbstractSnippetTest.java
new file mode 100644
index 0000000..1a5260c
--- /dev/null
+++ b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/AbstractSnippetTest.java
@@ -0,0 +1,76 @@
+package org.eclipse.basyx.examples.snippets;
+
+import org.eclipse.basyx.aas.manager.ConnectedAssetAdministrationShellManager;
+import org.eclipse.basyx.aas.metamodel.map.AssetAdministrationShell;
+import org.eclipse.basyx.aas.registration.proxy.AASRegistryProxy;
+import org.eclipse.basyx.examples.support.ExampleAASComponent;
+import org.eclipse.basyx.examples.support.ExampleComponentBuilder;
+import org.eclipse.basyx.examples.support.ExampleRegistryComponent;
+import org.eclipse.basyx.submodel.metamodel.map.SubModel;
+import org.junit.After;
+import org.junit.Before;
+
+/**
+ * This class provides the server environment required by all snippet test
+ *
+ * @author conradi
+ *
+ */
+public abstract class AbstractSnippetTest {
+
+
+ protected static final String AAS_ID_SHORT = "aasIdShort";
+ protected static final String AAS_ID = "aasId";
+ protected static final String AAS_ENDPOINT = "http://localhost:8080/aasComponent/shells/" + AAS_ID + "/aas";
+
+ protected static final String SM_ID_SHORT = "smIdShort";
+ protected static final String SM_ID = "smId";
+ protected static final String SM_ENDPOINT = AAS_ENDPOINT + "/submodels/" + SM_ID_SHORT + "/submodel";
+
+ protected ExampleAASComponent aasComponent;
+ protected ExampleRegistryComponent registryComponent;
+
+ @Before
+ public void setupServers() {
+ registryComponent = new ExampleRegistryComponent(8081);
+ registryComponent.startupRegistry();
+ aasComponent = new ExampleAASComponent(8080, new AASRegistryProxy(registryComponent.getRegistryPath()));
+ aasComponent.startupAASServer();
+
+ // Populate the Server with an example AAS/SM
+ populateServer();
+ }
+
+ @After
+ public void shutdownServers() {
+ aasComponent.shutdownAASServer();
+ registryComponent.shutdownRegistry();
+ }
+
+ /**
+ * Pushes and registers an AAS and a Submodel to the test server
+ */
+ private void populateServer() {
+ ConnectedAssetAdministrationShellManager manager = getManager();
+
+ // Get the example AAS and Submodel
+ AssetAdministrationShell aas = ExampleComponentBuilder.buildExampleAAS(AAS_ID_SHORT, AAS_ID);
+ SubModel sm = ExampleComponentBuilder.buildExampleSubmodel(SM_ID_SHORT, SM_ID);
+
+ // Push and register the AAS
+ manager.createAAS(aas, aasComponent.getAASServerPath());
+
+ // Push and register the Submodel
+ manager.createSubModel(aas.getIdentification(), sm);
+ }
+
+ /**
+ * Creates a ConnectedAASManager using the started registryComponent
+ *
+ * @return the created ConnectedAASManager
+ */
+ protected ConnectedAssetAdministrationShellManager getManager() {
+ AASRegistryProxy registryProxy = new AASRegistryProxy(registryComponent.getRegistryPath());
+ return new ConnectedAssetAdministrationShellManager(registryProxy);
+ }
+}
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/AccessAASProperties.java b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/AccessAASProperties.java
deleted file mode 100644
index c6347e1..0000000
--- a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/AccessAASProperties.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package org.eclipse.basyx.examples.snippets.aas;
-
-import static org.junit.Assert.assertTrue;
-
-import org.eclipse.basyx.aas.metamodel.map.AssetAdministrationShell;
-import org.junit.Test;
-
-/**
- * This code snippet illustrates the creation of an Asset Administration Shell (AAS) data structure
- * and how to access its properties via different kinds of access operations
- *
- * @author kuhn
- *
- */
-public class AccessAASProperties {
-
-
- /**
- * Code snippet that illustrates the instantiation and use of AAS
- */
- @Test
- public void snippet() throws Exception {
-
- // Create Asset Administration Shell
- AssetAdministrationShell aas = new AssetAdministrationShell();
-
- // Access predefined AAS properties
- // - Set AAS property via generic access method. For the generic access method,
- // the user must know the name of the accessed property. This kind of access
- // is discouraged, as it is not portable to new meta model versions. However,
- // it is illustrated for completeness.
- aas.put("idShort", "DeviceIDShort");
- // - Access AAS property via the specific access operation. This is the preferred
- // approach for accessing Asset Administration Shell and sub model properties,
- // as well as meta data.
- Object deviceIDValue = aas.getIdShort();
-
-
- // Compared received value to expected value
- assertTrue(deviceIDValue.equals("DeviceIDShort"));
- }
-}
-
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/CreateAAS.java b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/CreateAAS.java
deleted file mode 100644
index d2afd50..0000000
--- a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/CreateAAS.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package org.eclipse.basyx.examples.snippets.aas;
-
-import static org.junit.Assert.assertEquals;
-
-import org.eclipse.basyx.aas.metamodel.map.AssetAdministrationShell;
-import org.junit.Test;
-
-/**
- * Code snippet that illustrates the creation of an Asset Administration Shell (AAS) by extending an SDK class
- *
- * @author kuhn
- *
- */
-public class CreateAAS {
-
-
- /**
- * Example Asset Administration Shell
- */
- static class ExampleAssetAdministrationShell extends AssetAdministrationShell {
- /**
- * Constructor
- */
- public ExampleAssetAdministrationShell() {
- // Set Asset Administration Shell ID
- setIdShort("aas-001");
- }
- }
-
- /**
- * Run code snippet. Connect to AAS on server, access AAS properties.
- */
- @Test
- public void createAAS() throws Exception {
- // Create Asset Administration Shell
- ExampleAssetAdministrationShell aas = new ExampleAssetAdministrationShell();
-
- // Retrieve AAS ID value
- Object propertyId = aas.getIdShort();
-
-
- // Check result
- assertEquals("aas-001", propertyId);
- }
-}
-
-
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/TestAddSubmodelToAAS.java b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/TestAddSubmodelToAAS.java
new file mode 100644
index 0000000..4ab8821
--- /dev/null
+++ b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/TestAddSubmodelToAAS.java
@@ -0,0 +1,46 @@
+package org.eclipse.basyx.examples.snippets.aas;
+
+import static org.junit.Assert.assertEquals;
+
+import org.eclipse.basyx.aas.manager.ConnectedAssetAdministrationShellManager;
+import org.eclipse.basyx.examples.snippets.AbstractSnippetTest;
+import org.eclipse.basyx.examples.support.ExampleComponentBuilder;
+import org.eclipse.basyx.submodel.metamodel.api.ISubModel;
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IIdentifier;
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IdentifierType;
+import org.eclipse.basyx.submodel.metamodel.map.SubModel;
+import org.eclipse.basyx.submodel.metamodel.map.identifier.Identifier;
+import org.junit.Test;
+
+/**
+ * Test for the AddSubmodelToAAS snippet
+ *
+ * @author conradi
+ *
+ */
+public class TestAddSubmodelToAAS extends AbstractSnippetTest {
+
+ private static final String NEW_SM_ID_SHORT = "smIdShort_New";
+ private static final String NEW_SM_ID = "smId_New";
+
+ @Test
+ public void testAddSubmodelToAAS() {
+
+ // Get the example AAS and Submodel
+ SubModel submodel = ExampleComponentBuilder.buildExampleSubmodel(NEW_SM_ID_SHORT, NEW_SM_ID);
+
+ // Get the Identifiers for the AAS and the Submodel
+ IIdentifier aasIdentifier = new Identifier(IdentifierType.CUSTOM, AAS_ID);
+ IIdentifier smIdentifier = submodel.getIdentification();
+
+ // Add the Submodel to the AAS
+ AddSubmodelToAAS.addSubmodelToAAS(submodel, aasIdentifier, registryComponent.getRegistryPath());
+
+ // Check if the Submodel was correctly added
+ ConnectedAssetAdministrationShellManager manager = getManager();
+ ISubModel remoteSM = manager.retrieveSubModel(aasIdentifier, smIdentifier);
+ assertEquals(NEW_SM_ID_SHORT, remoteSM.getIdShort());
+
+ }
+
+}
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/TestDeleteAAS.java b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/TestDeleteAAS.java
new file mode 100644
index 0000000..f3d795f
--- /dev/null
+++ b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/TestDeleteAAS.java
@@ -0,0 +1,38 @@
+package org.eclipse.basyx.examples.snippets.aas;
+
+import static org.junit.Assert.fail;
+
+import org.eclipse.basyx.examples.snippets.AbstractSnippetTest;
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IIdentifier;
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IdentifierType;
+import org.eclipse.basyx.submodel.metamodel.map.identifier.Identifier;
+import org.eclipse.basyx.vab.exception.provider.ResourceNotFoundException;
+import org.junit.Test;
+
+/**
+ * Test for the DeleteAAS snippet
+ *
+ * @author conradi
+ *
+ */
+public class TestDeleteAAS extends AbstractSnippetTest {
+
+ @Test
+ public void testDeleteAAS() {
+
+ // Get the Identifier of the example AAS
+ IIdentifier aasIdentifier = new Identifier(IdentifierType.CUSTOM, AAS_ID);
+
+ // Delete the AAS
+ DeleteAAS.deleteAAS(aasIdentifier, registryComponent.getRegistryPath());
+
+ // Try to retrieve deleted AAS; should throw ResourceNotFoundException
+ try {
+ RetrieveRemoteAAS.retrieveRemoteAAS(aasIdentifier, registryComponent.getRegistryPath());
+ fail();
+ } catch (ResourceNotFoundException e) {
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/TestDeleteSubmodelFromAAS.java b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/TestDeleteSubmodelFromAAS.java
new file mode 100644
index 0000000..504c406
--- /dev/null
+++ b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/TestDeleteSubmodelFromAAS.java
@@ -0,0 +1,40 @@
+package org.eclipse.basyx.examples.snippets.aas;
+
+import static org.junit.Assert.fail;
+
+import org.eclipse.basyx.examples.snippets.AbstractSnippetTest;
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IIdentifier;
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IdentifierType;
+import org.eclipse.basyx.submodel.metamodel.map.identifier.Identifier;
+import org.eclipse.basyx.vab.exception.provider.ResourceNotFoundException;
+import org.junit.Test;
+
+/**
+ * Test for the DeleteSubmodelFromAAS snippet
+ *
+ * @author conradi
+ *
+ */
+public class TestDeleteSubmodelFromAAS extends AbstractSnippetTest {
+
+ @Test
+ public void testDeleteSubmodel() {
+
+ // Get the Identifier of the example AAS and Submodel
+ IIdentifier aasIdentifier = new Identifier(IdentifierType.CUSTOM, AAS_ID);
+ IIdentifier smIdentifier = new Identifier(IdentifierType.CUSTOM, SM_ID);
+
+ // Delete the Submodel
+ DeleteSubmodelFromAAS.deleteSubmodelFromAAS(smIdentifier, aasIdentifier, registryComponent.getRegistryPath());
+
+ // Try to retrieve deleted Submodel; should throw ResourceNotFoundException
+ try {
+ RetrieveSubmodelFromAAS.retrieveSubmodelFromAAS(
+ smIdentifier, aasIdentifier, registryComponent.getRegistryPath());
+ fail();
+ } catch (ResourceNotFoundException e) {
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/TestLookupAAS.java b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/TestLookupAAS.java
new file mode 100644
index 0000000..339a0cc
--- /dev/null
+++ b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/TestLookupAAS.java
@@ -0,0 +1,34 @@
+package org.eclipse.basyx.examples.snippets.aas;
+
+import static org.junit.Assert.assertEquals;
+
+import org.eclipse.basyx.aas.metamodel.map.descriptor.AASDescriptor;
+import org.eclipse.basyx.examples.snippets.AbstractSnippetTest;
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IIdentifier;
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IdentifierType;
+import org.eclipse.basyx.submodel.metamodel.map.identifier.Identifier;
+import org.junit.Test;
+
+/**
+ * Test for the LookupAAS snippet
+ *
+ * @author conradi
+ *
+ */
+public class TestLookupAAS extends AbstractSnippetTest {
+
+ @Test
+ public void testLookupAAS() {
+
+ // Get the Identifier of the example AAS
+ IIdentifier aasIdentifier = new Identifier(IdentifierType.CUSTOM, AAS_ID);
+
+ // Lookup the AAS in the registry
+ AASDescriptor descriptor = LookupAAS.lookupAAS(aasIdentifier, registryComponent.getRegistryPath());
+
+ // Check if the returned Descriptor is as expected
+ assertEquals(AAS_ENDPOINT, descriptor.getFirstEndpoint());
+
+ }
+
+}
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/TestPushAASToServer.java b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/TestPushAASToServer.java
new file mode 100644
index 0000000..1b57fd1
--- /dev/null
+++ b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/TestPushAASToServer.java
@@ -0,0 +1,38 @@
+package org.eclipse.basyx.examples.snippets.aas;
+
+import static org.junit.Assert.assertEquals;
+
+import org.eclipse.basyx.aas.manager.ConnectedAssetAdministrationShellManager;
+import org.eclipse.basyx.aas.metamodel.api.IAssetAdministrationShell;
+import org.eclipse.basyx.aas.metamodel.map.AssetAdministrationShell;
+import org.eclipse.basyx.examples.snippets.AbstractSnippetTest;
+import org.eclipse.basyx.examples.support.ExampleComponentBuilder;
+import org.junit.Test;
+
+/**
+ * Test for the PushAASToServer snippet
+ *
+ * @author conradi
+ *
+ */
+public class TestPushAASToServer extends AbstractSnippetTest {
+
+ protected static final String NEW_AAS_ID_SHORT = "aasIdShort_New";
+ protected static final String NEW_AAS_ID = "aasId_New";
+
+ @Test
+ public void testPushAAS() throws Exception {
+
+ // Get the example AAS
+ AssetAdministrationShell aas = ExampleComponentBuilder.buildExampleAAS(NEW_AAS_ID_SHORT, NEW_AAS_ID);
+
+ // Push the AAS to the server
+ PushAASToServer.pushAAS(aas, aasComponent.getAASServerPath(), registryComponent.getRegistryPath());
+
+ // Check if the AAS is present on the server
+ ConnectedAssetAdministrationShellManager manager = getManager();
+ IAssetAdministrationShell remoteAAS = manager.retrieveAAS(aas.getIdentification());
+ assertEquals(NEW_AAS_ID_SHORT, remoteAAS.getIdShort());
+ }
+
+}
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/TestRegisterAAS.java b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/TestRegisterAAS.java
new file mode 100644
index 0000000..717f533
--- /dev/null
+++ b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/TestRegisterAAS.java
@@ -0,0 +1,40 @@
+package org.eclipse.basyx.examples.snippets.aas;
+
+import static org.junit.Assert.assertEquals;
+
+import org.eclipse.basyx.aas.metamodel.map.AssetAdministrationShell;
+import org.eclipse.basyx.aas.metamodel.map.descriptor.AASDescriptor;
+import org.eclipse.basyx.aas.registration.proxy.AASRegistryProxy;
+import org.eclipse.basyx.examples.snippets.AbstractSnippetTest;
+import org.eclipse.basyx.examples.support.ExampleComponentBuilder;
+import org.junit.Test;
+
+/**
+ * Test for the RegisterAAS snippet
+ *
+ * @author conradi
+ *
+ */
+public class TestRegisterAAS extends AbstractSnippetTest {
+
+ protected static final String NEW_AAS_ID_SHORT = "aasIdShort_New";
+ protected static final String NEW_AAS_ID = "aasId_New";
+ protected static final String NEW_AAS_ENDPOINT = "http://localhost:8080/aasComponent/shells/" + NEW_AAS_ID + "/aas";
+
+ @Test
+ public void testRegisterAAS() {
+
+ // Get the example AAS
+ AssetAdministrationShell aas = ExampleComponentBuilder.buildExampleAAS(NEW_AAS_ID_SHORT, NEW_AAS_ID);
+
+ // Register this AAS
+ RegisterAAS.registerAAS(aas, NEW_AAS_ENDPOINT, registryComponent.getRegistryPath());
+
+ // Check if the AAS was correctly registered
+ AASRegistryProxy registryProxy = new AASRegistryProxy(registryComponent.getRegistryPath());
+ AASDescriptor descriptor = registryProxy.lookupAAS(aas.getIdentification());
+ assertEquals(NEW_AAS_ENDPOINT, descriptor.getFirstEndpoint());
+
+ }
+
+}
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/TestRetrieveRemoteAAS.java b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/TestRetrieveRemoteAAS.java
new file mode 100644
index 0000000..933eed8
--- /dev/null
+++ b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/TestRetrieveRemoteAAS.java
@@ -0,0 +1,33 @@
+package org.eclipse.basyx.examples.snippets.aas;
+
+import static org.junit.Assert.assertEquals;
+
+import org.eclipse.basyx.aas.metamodel.api.IAssetAdministrationShell;
+import org.eclipse.basyx.examples.snippets.AbstractSnippetTest;
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IIdentifier;
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IdentifierType;
+import org.eclipse.basyx.submodel.metamodel.map.identifier.Identifier;
+import org.junit.Test;
+
+/**
+ * Test for the RetrieveRemoteAAS snippet
+ *
+ * @author conradi
+ *
+ */
+public class TestRetrieveRemoteAAS extends AbstractSnippetTest {
+
+ @Test
+ public void testRetrieveRemoteAAS() {
+
+ // Get the Identifier of the example AAS
+ IIdentifier aasIdentifier = new Identifier(IdentifierType.CUSTOM, AAS_ID);
+
+ // Retrieve the AAS from the server
+ IAssetAdministrationShell remoteAAS =
+ RetrieveRemoteAAS.retrieveRemoteAAS(aasIdentifier, registryComponent.getRegistryPath());
+
+ // Check if the retrieved AAS can be used correctly
+ assertEquals(AAS_ID_SHORT, remoteAAS.getIdShort());
+ }
+}
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/TestRetrieveSubmodelFromAAS.java b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/TestRetrieveSubmodelFromAAS.java
new file mode 100644
index 0000000..03f98a8
--- /dev/null
+++ b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/TestRetrieveSubmodelFromAAS.java
@@ -0,0 +1,36 @@
+package org.eclipse.basyx.examples.snippets.aas;
+
+import static org.junit.Assert.assertEquals;
+
+import org.eclipse.basyx.examples.snippets.AbstractSnippetTest;
+import org.eclipse.basyx.submodel.metamodel.api.ISubModel;
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IIdentifier;
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IdentifierType;
+import org.eclipse.basyx.submodel.metamodel.map.identifier.Identifier;
+import org.junit.Test;
+
+/**
+ * Test for the RetrieveSubmodelFromAAS snippet
+ *
+ * @author conradi
+ *
+ */
+public class TestRetrieveSubmodelFromAAS extends AbstractSnippetTest {
+
+
+ @Test
+ public void testRetrieveSubmodelFromAAS() {
+
+ // Get the Identifiers of the AAS and Submodel
+ IIdentifier aasIdentifier = new Identifier(IdentifierType.CUSTOM, AAS_ID);
+ IIdentifier smIdentifier = new Identifier(IdentifierType.CUSTOM, SM_ID);
+
+ // Get the Submodel from the server
+ ISubModel remoteSubmodel = RetrieveSubmodelFromAAS.retrieveSubmodelFromAAS(
+ smIdentifier, aasIdentifier, registryComponent.getRegistryPath());
+
+ // Check if the Submodel can be used correctly
+ assertEquals(SM_ID_SHORT, remoteSubmodel.getIdShort());
+ }
+
+}
\ No newline at end of file
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/deployment/device/DeviceAASDeployment.java b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/deployment/device/DeviceAASDeployment.java
deleted file mode 100644
index e5a4db2..0000000
--- a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/deployment/device/DeviceAASDeployment.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package org.eclipse.basyx.examples.snippets.aas.deployment.device;
-
-import static org.junit.Assert.assertTrue;
-
-import org.eclipse.basyx.aas.manager.ConnectedAssetAdministrationShellManager;
-import org.eclipse.basyx.aas.metamodel.api.IAssetAdministrationShell;
-import org.eclipse.basyx.aas.metamodel.map.AssetAdministrationShell;
-import org.eclipse.basyx.aas.metamodel.map.descriptor.ModelUrn;
-import org.eclipse.basyx.aas.restapi.AASModelProvider;
-import org.eclipse.basyx.aas.restapi.VABMultiSubmodelProvider;
-import org.eclipse.basyx.examples.support.directory.ExampleAASRegistry;
-import org.eclipse.basyx.vab.protocol.basyx.connector.BaSyxConnectorProvider;
-import org.eclipse.basyx.vab.protocol.basyx.server.BaSyxTCPServer;
-import org.junit.Test;
-
-/**
- * Code snippet that illustrates the deployment of an AAS to a device, and connects to that AAS
- *
- * The AAS is deployed to a dynamic BaSyxTCPServer that exports the AAS using the BaSyx TCP protocol.
- *
- * @author kuhn
- *
- */
-public class DeviceAASDeployment {
-
-
- /**
- * Run code snippet. Connect to AAS on server, access AAS properties.
- */
- @Test
- public void createExportAndAccessSubModel() throws Exception {
-
-
- // Create AAS sub model and sub model properties
- // - Create AAS
- AssetAdministrationShell aas = new AssetAdministrationShell();
- // - Set sub model ID
- aas.setIdShort("urn:de.FHG:devices.es.iese:AAS:1.0:3:x-509#003");
-
-
- // Export AAS via BaSyx server
- AASModelProvider modelProvider = new AASModelProvider(aas);
- VABMultiSubmodelProvider aasProvider = new VABMultiSubmodelProvider(modelProvider);
- BaSyxTCPServer<VABMultiSubmodelProvider> server = new BaSyxTCPServer<VABMultiSubmodelProvider>(aasProvider, 9998);
- // - Start local BaSyx/TCP server
- server.start();
-
-
-
- // - We pre-register the aas endpoints to the dynamic BaSyx server
- ExampleAASRegistry registry = new ExampleAASRegistry();
- registry.addAASMapping("dynamicAAS", "basyx://localhost:9998/aas");
-
- // Create connected aas manager to connect with the dynamic server
- ConnectedAssetAdministrationShellManager manager = new ConnectedAssetAdministrationShellManager(registry,
- // We connect via BaSyx TCP protocol
- new BaSyxConnectorProvider());
-
-
- // Retrieve the AAS with ID "dynamicAAS" from the AAS server with SDK connector
- // - IAssetAdministrationShell is the interface for the local AAS proxy
- IAssetAdministrationShell shell = manager.retrieveAAS(new ModelUrn("dynamicAAS"));
- // - Retrieve AAS values and compare to expected values
- Object propertyId = shell.getIdShort();
-
-
- // Check value
- assertTrue(propertyId.equals("urn:de.FHG:devices.es.iese:AAS:1.0:3:x-509#003"));
-
-
- // Stop local BaSyx/TCP server
- server.stop();
- }
-}
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/deployment/device/DeviceAASDeploymentVAB.java b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/deployment/device/DeviceAASDeploymentVAB.java
deleted file mode 100644
index a8783db..0000000
--- a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/deployment/device/DeviceAASDeploymentVAB.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package org.eclipse.basyx.examples.snippets.aas.deployment.device;
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.Map;
-
-import org.eclipse.basyx.aas.metamodel.map.AssetAdministrationShell;
-import org.eclipse.basyx.aas.restapi.AASModelProvider;
-import org.eclipse.basyx.aas.restapi.VABMultiSubmodelProvider;
-import org.eclipse.basyx.vab.coder.json.connector.JSONConnector;
-import org.eclipse.basyx.vab.protocol.basyx.connector.BaSyxConnector;
-import org.eclipse.basyx.vab.protocol.basyx.server.BaSyxTCPServer;
-import org.junit.Test;
-
-/**
- * Code snippet that illustrates the deployment of an AAS to a device, and connects to that AAS
- *
- * The AAS is deployed to a dynamic BaSyxTCPServer that exports the AAS using the BaSyx TCP protocol.
- *
- * @author kuhn
- *
- */
-public class DeviceAASDeploymentVAB {
-
-
- /**
- * Run code snippet. Connect to AAS on server, access AAS properties.
- */
- @SuppressWarnings("unchecked")
- @Test
- public void createExportAndAccessSubModel() throws Exception {
-
-
- // Create AAS sub model and sub model properties
- // - Create AAS
- AssetAdministrationShell aas = new AssetAdministrationShell();
- // - Set sub model ID
- aas.setIdShort("urn:de.FHG:devices.es.iese:AAS:1.0:3:x-509#003");
-
-
- // Export AAS via BaSyx server
- AASModelProvider modelProvider = new AASModelProvider(aas);
- VABMultiSubmodelProvider aasProvider = new VABMultiSubmodelProvider(modelProvider);
- BaSyxTCPServer<VABMultiSubmodelProvider> server = new BaSyxTCPServer<VABMultiSubmodelProvider>(aasProvider, 9998);
- // - Start local BaSyx/TCP server
- server.start();
-
-
- // Access BaSyx TCP server using Virtual Automation Bus low level BaSyxConnector class
- // - Create BaSyx connector to connect with the sub model
- BaSyxConnector basyxConnector = new BaSyxConnector("localhost", 9998);
- // - Create connection to BaSyx server manager
- JSONConnector toDeviceManager = new JSONConnector(basyxConnector);
- // - Access sub model property, check value
- AssetAdministrationShell shell = AssetAdministrationShell.createAsFacade((Map<String, Object>) toDeviceManager.getModelPropertyValue("aas"));
-
-
- // Check value
- assertTrue(shell.getIdShort().equals("urn:de.FHG:devices.es.iese:AAS:1.0:3:x-509#003"));
-
-
- // Stop local BaSyx/TCP server
- server.stop();
- }
-}
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/deployment/device/DeviceSubModelDeployment.java b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/deployment/device/DeviceSubModelDeployment.java
deleted file mode 100644
index 4761650..0000000
--- a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/deployment/device/DeviceSubModelDeployment.java
+++ /dev/null
@@ -1,96 +0,0 @@
-package org.eclipse.basyx.examples.snippets.aas.deployment.device;
-
-import static org.junit.Assert.assertTrue;
-
-import org.eclipse.basyx.aas.manager.ConnectedAssetAdministrationShellManager;
-import org.eclipse.basyx.aas.metamodel.map.descriptor.ModelUrn;
-import org.eclipse.basyx.aas.restapi.VABMultiSubmodelProvider;
-import org.eclipse.basyx.examples.support.directory.ExampleAASRegistry;
-import org.eclipse.basyx.submodel.metamodel.api.ISubModel;
-import org.eclipse.basyx.submodel.metamodel.api.identifier.IIdentifier;
-import org.eclipse.basyx.submodel.metamodel.map.SubModel;
-import org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.Property;
-import org.eclipse.basyx.submodel.restapi.SubModelProvider;
-import org.eclipse.basyx.vab.protocol.basyx.connector.BaSyxConnectorProvider;
-import org.eclipse.basyx.vab.protocol.basyx.server.BaSyxTCPServer;
-import org.junit.Test;
-
-/**
- * Code snippet that illustrates the deployment of a AAS sub model to a device, and connects to that sub model
- *
- * The AAS sub model is deployed to a dynamic BaSyxTCPServer that exports the sub model using the BaSyx TCP protocol.
- *
- * @author kuhn
- *
- */
-public class DeviceSubModelDeployment {
-
-
- /**
- * Run code snippet. Connect to AAS sub model on server, access sub model properties.
- */
- @Test
- public void createExportAndAccessSubModel() throws Exception {
-
-
- // Create AAS sub model and sub model properties
-
- // - Create sub model
- SubModel submodel = new SubModel();
- // - Set sub model ID "SampleSM" to full qualified ID urn:de.FHG:devices.es.iese:SampleSM:1.0:3:x-509#003
- IIdentifier smId = new ModelUrn("urn:de.FHG:devices.es.iese:SampleSM:1.0:3:x-509#003");
- submodel.setIdShort("SampleSM");
- submodel.setIdentification(smId.getIdType(), smId.getId());
- // - Add example properties
- Property prop1 = new Property(7);
- prop1.setIdShort("prop1");
- submodel.addSubModelElement(prop1);
-
- Property prop2 = new Property("myStr");
- prop2.setIdShort("prop2");
- submodel.addSubModelElement(prop2);
-
-
- // Export sub model via BaSyx server
- SubModelProvider modelProvider = new SubModelProvider(submodel);
- VABMultiSubmodelProvider aasProvider = new VABMultiSubmodelProvider("SampleSM", modelProvider);
- BaSyxTCPServer<VABMultiSubmodelProvider> server = new BaSyxTCPServer<>(aasProvider, 9998);
- // - Start local BaSyx/TCP server
- server.start();
-
-
- // Create connected aas manager to connect with the dynamic server
- // We pre-register the aas endpoints to the dynamic BaSyx server
- ExampleAASRegistry registry = new ExampleAASRegistry();
- registry.addAASMapping("", ""); // No AAS is provided in this example
- registry.addSubmodelMapping("", smId.getId(), "basyx://localhost:9998/aas/submodels/SampleSM");
-
- // Create manager using the directory stub an the HTTPConnectorProvider
- ConnectedAssetAdministrationShellManager manager = new ConnectedAssetAdministrationShellManager(registry,
- // We connect via BaSyx TCP protocol
- new BaSyxConnectorProvider());
-
- // Create and connect SDK connector
- // - Retrieve sub model
- ISubModel subModel = manager.retrieveSubModel(new ModelUrn(""), smId);
-
- // Retrieve sub model values and compare to expected values
- String submodelId = subModel.getIdShort();
- String prop1Id = subModel.getProperties().get("prop1").getIdShort();
- int prop1Val = (int) subModel.getProperties().get("prop1").getValue();
- String prop2Id = subModel.getProperties().get("prop2").getIdShort();
- String prop2Val = (String) subModel.getProperties().get("prop2").getValue();
-
-
- // Compare received property values to expected values
- assertTrue(submodelId.equals("SampleSM"));
- assertTrue(prop1Id.equals("prop1"));
- assertTrue(prop1Val == 7);
- assertTrue(prop2Id.equals("prop2"));
- assertTrue(prop2Val.equals("myStr"));
-
-
- // Stop local BaSyx/TCP server
- server.stop();
- }
-}
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/deployment/device/DeviceSubModelDeploymentVAB.java b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/deployment/device/DeviceSubModelDeploymentVAB.java
deleted file mode 100644
index 5406ade..0000000
--- a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/deployment/device/DeviceSubModelDeploymentVAB.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package org.eclipse.basyx.examples.snippets.aas.deployment.device;
-
-import static org.junit.Assert.assertTrue;
-
-import org.eclipse.basyx.aas.restapi.VABMultiSubmodelProvider;
-import org.eclipse.basyx.submodel.metamodel.map.SubModel;
-import org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.Property;
-import org.eclipse.basyx.submodel.restapi.MultiSubmodelElementProvider;
-import org.eclipse.basyx.submodel.restapi.SubModelProvider;
-import org.eclipse.basyx.vab.coder.json.connector.JSONConnector;
-import org.eclipse.basyx.vab.protocol.basyx.connector.BaSyxConnector;
-import org.eclipse.basyx.vab.protocol.basyx.server.BaSyxTCPServer;
-import org.junit.Test;
-
-/**
- * Code snippet that illustrates the deployment of a AAS sub model to a device, and connects to that sub model using
- * Virtual Automation Bus (VAB) primitives.
- *
- * The AAS sub model is deployed to a dynamic BaSyxTCPServer that exports the sub model using the BaSyx TCP protocol.
- *
- * @author kuhn
- *
- */
-public class DeviceSubModelDeploymentVAB {
-
-
- /**
- * Run code snippet. Connect to AAS sub model on server, access sub model properties using VAB properties.
- */
- @Test
- public void createExportAndAccessSubModel() throws Exception {
-
-
- // Create AAS sub model and sub model properties
- // - Create sub model
- SubModel submodel = new SubModel();
- // - Set sub model ID
- submodel.setIdShort("dynamicSM");
- // - Add example properties
- Property prop1 = new Property(7);
- prop1.setIdShort("prop1");
- submodel.addSubModelElement(prop1);
-
- Property prop2 = new Property("myStr");
- prop2.setIdShort("prop2");
- submodel.addSubModelElement(prop2);
-
-
- // Export sub model via BaSyx server
- SubModelProvider modelProvider = new SubModelProvider(submodel);
- VABMultiSubmodelProvider aasProvider = new VABMultiSubmodelProvider("dynamicSM", modelProvider);
- BaSyxTCPServer<VABMultiSubmodelProvider> server = new BaSyxTCPServer<VABMultiSubmodelProvider>(aasProvider, 9998);
- // - Start local BaSyx/TCP server
- server.start();
-
-
- // Access BaSyx TCP server using low-level BaSyx connector instead of connection manager
- // - Create BaSyx connector to connect with the sub model
- BaSyxConnector basyxConnector = new BaSyxConnector("localhost", 9998);
- // - Create connection to BaSyx server manager
- JSONConnector toDeviceManager = new JSONConnector(basyxConnector);
- // - Access sub model property, check value
- int propVal = (Integer) toDeviceManager
- .getModelPropertyValue("/aas/submodels/dynamicSM/submodel/" + MultiSubmodelElementProvider.ELEMENTS + "/prop1/value");
-
-
- // Check value
- assertTrue(propVal == 7);
-
-
- // Stop local BaSyx/TCP server
- server.stop();
- }
-}
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/deployment/http/ConnectToRemoteAAS.java b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/deployment/http/ConnectToRemoteAAS.java
deleted file mode 100644
index 2a4d1c5..0000000
--- a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/deployment/http/ConnectToRemoteAAS.java
+++ /dev/null
@@ -1,94 +0,0 @@
-package org.eclipse.basyx.examples.snippets.aas.deployment.http;
-
-import static org.junit.Assert.assertTrue;
-
-import org.eclipse.basyx.aas.manager.ConnectedAssetAdministrationShellManager;
-import org.eclipse.basyx.aas.metamodel.api.IAssetAdministrationShell;
-import org.eclipse.basyx.aas.metamodel.map.AssetAdministrationShell;
-import org.eclipse.basyx.aas.metamodel.map.descriptor.ModelUrn;
-import org.eclipse.basyx.components.servlet.aas.AASServlet;
-import org.eclipse.basyx.examples.contexts.BaSyxExamplesContext_Empty;
-import org.eclipse.basyx.examples.deployment.BaSyxDeployment;
-import org.eclipse.basyx.examples.support.directory.ExampleAASRegistry;
-import org.eclipse.basyx.vab.protocol.http.connector.HTTPConnectorProvider;
-import org.junit.ClassRule;
-import org.junit.Test;
-
-/**
- * Code snippet that illustrates the creation of an Asset Administration Shell (AAS) by extending an SDK class
- *
- * The AAS is deployed to an AASServlet instance running on a Apache Tomcat HTTP server. The AASServlet exports
- * an Asset Administration Shell via the defined BaSyx REST interface.
- *
- * @author kuhn
- *
- */
-public class ConnectToRemoteAAS {
-
-
- /**
- * Example Asset Administration Shell
- */
- static class ExampleAssetAdministrationShell extends AssetAdministrationShell {
- /**
- * Constructor
- */
- public ExampleAssetAdministrationShell() {
- // Set Asset Administration Shell ID
- setIdShort("aas-001");
- }
- }
-
-
-
- /**
- * The BaSyx Deployment instantiates and starts context elements for this example.
- *
- * This example instantiates the BaSyxExamplesContext_1MemoryAASServer_1SQLDirectory
- * example context that creates one AAS server, and one SQL based AAS registry.
- *
- * BaSyxDeployment contexts instantiate all components on the IP address of the host.
- * Therefore, all components use the same IP address.
- */
- @ClassRule
- public static BaSyxDeployment context = new BaSyxDeployment(
- // Servlets for example snippet
- new BaSyxExamplesContext_Empty().
- // Deploy example specific servlets to Tomcat server in this context
- addServletMapping("/Testsuite/components/BaSys/1.0/SampleAAS/*", new AASServlet(new ExampleAssetAdministrationShell()))
- );
-
-
-
- /**
- * Run code snippet. Connect to AAS on server, access AAS properties.
- */
- @Test
- public void connectToAAS() throws Exception {
- // Create AAS Registry to store meta-infomation using aas descriptor
- // This is a pre-configured aas registry that resolves urn to aas-descriptor
- ExampleAASRegistry registry = new ExampleAASRegistry();
- registry.addAASMapping("aas-001",
- "http://localhost:8080/basys.examples/Testsuite/components/BaSys/1.0/SampleAAS/aas");
-
- // Create manager using the directory stub an the HTTPConnectorProvider
- // - Connect to VAB object by ID. The connection manager looks up this ID in
- // its directory
- ConnectedAssetAdministrationShellManager manager = new ConnectedAssetAdministrationShellManager(registry,
- // We connect via HTTP
- new HTTPConnectorProvider());
-
- // Retrieve the AAS from the AAS server with SDK connector
- // - IAssetAdministrationShell is the interface for the local AAS proxy
- IAssetAdministrationShell shell = manager
- .retrieveAAS(new ModelUrn("aas-001"));
- // - Retrieve AAS values and compare to expected values
- Object propertyId = shell.getIdShort();
-
-
- // Check result
- assertTrue(propertyId.equals("aas-001"));
- }
-}
-
-
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/registry/ConnectToAASEndpoints.java b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/registry/ConnectToAASEndpoints.java
deleted file mode 100644
index d105f5c..0000000
--- a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/registry/ConnectToAASEndpoints.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package org.eclipse.basyx.examples.snippets.aas.registry;
-
-import static org.junit.Assert.assertEquals;
-
-import org.eclipse.basyx.aas.manager.ConnectedAssetAdministrationShellManager;
-import org.eclipse.basyx.aas.metamodel.connected.ConnectedAssetAdministrationShell;
-import org.eclipse.basyx.aas.metamodel.map.AssetAdministrationShell;
-import org.eclipse.basyx.aas.metamodel.map.descriptor.ModelUrn;
-import org.eclipse.basyx.aas.registration.proxy.AASRegistryProxy;
-import org.eclipse.basyx.examples.contexts.BaSyxExamplesContext;
-import org.eclipse.basyx.examples.deployment.BaSyxDeployment;
-import org.eclipse.basyx.vab.protocol.http.connector.HTTPConnectorProvider;
-import org.junit.ClassRule;
-import org.junit.Test;
-
-/**
- * Code snippet that registers an AAS descriptor with the AAS registry and connects to the registered AAS endpoint
- *
- * The snippet communicates with a VAB element that is deployed to a VABLambdaServlet on a
- * Apache Tomcat HTTP server instance. The VABLambdaServlet provides an empty container that
- * is able to host any VAB object.
- *
- * @author kuhn
- *
- */
-public class ConnectToAASEndpoints {
-
-
- /**
- * Create VAB connection manager backend
- *
- * The connection manager uses a preconfigured directory for resolving IDs to
- * network addresses, and a HTTP connector to connect to VAB objects.
- */
- protected ConnectedAssetAdministrationShellManager connManager = new ConnectedAssetAdministrationShellManager(
- new AASRegistryProxy("http://localhost:8080" + BaSyxExamplesContext.REGISTRYURL),
- new HTTPConnectorProvider());
-
-
- /**
- * The BaSyx Deployment instantiates and starts context elements for this example.
- *
- * This example instantiates the BaSyxExamplesContext_1MemoryAASServer_1SQLDirectory
- * example context that creates one AAS server, and one SQL based AAS registry.
- *
- * BaSyxDeployment contexts instantiate all components on the IP address of the host.
- * Therefore, all components use the same IP address.
- */
- @ClassRule
- public static BaSyxDeployment context = new BaSyxDeployment(
- new BaSyxExamplesContext()
- );
-
-
-
-
- /**
- * Run code snippet. This code snippet illustrates the creation of an AASDescriptor, the dynamic creation and deployment of AAS,
- * the lookup of the AAS, and the access of the AAS.
- */
- @Test
- public void snippet() throws Exception {
-
- // Create AAS descriptor and sub model descriptors
- ModelUrn aasURN = new ModelUrn("urn:de.FHG:devices.es.iese:aas:1.0:3:x-509#001");
- String aasSrvURL = "http://localhost:8080" + BaSyxExamplesContext.AASSERVERURL + "/shells";
-
- // Create AAS
- AssetAdministrationShell aas = new AssetAdministrationShell();
-
- // - Set AAS ID
- aas.setIdentification(aasURN);
-
- // - Transfer AAS to server
- // - This creates the "urn:de.FHG:devices.es.iese:aas:1.0:3:x-509#001" element on the server, which is the server
- // end point that will host the AAS.
- connManager.createAAS(aas, aasSrvURL);
-
- // Server connections
- // - Connect AAS
- ConnectedAssetAdministrationShell shell = connManager.retrieveAAS(aasURN);
-
- // Retrieve the AAS from the AAS server with SDK connector
- // - IAssetAdministrationShell is the interface for the local AAS proxy
- // - Retrieve AAS values and compare to expected values
- Object aasIDProperty = shell.getIdentification().getId();
-
- // Check property value
- assertEquals(aasURN.getURN(), aasIDProperty);
- }
-}
-
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/registry/ConnectToSubModelEndpoints.java b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/registry/ConnectToSubModelEndpoints.java
deleted file mode 100644
index a742439..0000000
--- a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/registry/ConnectToSubModelEndpoints.java
+++ /dev/null
@@ -1,127 +0,0 @@
-package org.eclipse.basyx.examples.snippets.aas.registry;
-
-import static org.junit.Assert.assertTrue;
-
-import org.eclipse.basyx.aas.manager.ConnectedAssetAdministrationShellManager;
-import org.eclipse.basyx.aas.metamodel.map.AssetAdministrationShell;
-import org.eclipse.basyx.aas.metamodel.map.descriptor.ModelUrn;
-import org.eclipse.basyx.aas.registration.proxy.AASRegistryProxy;
-import org.eclipse.basyx.examples.contexts.BaSyxExamplesContext;
-import org.eclipse.basyx.examples.deployment.BaSyxDeployment;
-import org.eclipse.basyx.submodel.metamodel.api.ISubModel;
-import org.eclipse.basyx.submodel.metamodel.api.identifier.IIdentifier;
-import org.eclipse.basyx.submodel.metamodel.api.identifier.IdentifierType;
-import org.eclipse.basyx.submodel.metamodel.map.SubModel;
-import org.eclipse.basyx.submodel.metamodel.map.identifier.Identifier;
-import org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.Property;
-import org.eclipse.basyx.vab.protocol.http.connector.HTTPConnectorProvider;
-import org.junit.ClassRule;
-import org.junit.Test;
-
-/**
- * Code snippet that registers an AAS descriptor with the AAS registry and connects to a sub model of
- * the registered AAS endpoint
- *
- * The snippet communicates with a VAB element that is deployed to a VABLambdaServlet on a
- * Apache Tomcat HTTP server instance. The VABLambdaServlet provides an empty container that
- * is able to host any VAB object.
- *
- * @author kuhn
- *
- */
-public class ConnectToSubModelEndpoints {
- /**
- * Create VAB connection manager backend
- *
- * The connection manager uses a preconfigured directory for resolving IDs to
- * network addresses, and a HTTP connector to connect to VAB objects.
- */
- protected ConnectedAssetAdministrationShellManager connManager = new ConnectedAssetAdministrationShellManager(
- new AASRegistryProxy("http://localhost:8080" + BaSyxExamplesContext.REGISTRYURL),
- new HTTPConnectorProvider());
-
-
- /**
- * The BaSyx Deployment instantiates and starts context elements for this example.
- *
- * This example instantiates the BaSyxExamplesContext_1MemoryAASServer_1SQLDirectory
- * example context that creates one AAS server, and one SQL based AAS registry.
- *
- * BaSyxDeployment contexts instantiate all components on the IP address of the host.
- * Therefore, all components use the same IP address.
- */
- @ClassRule
- public static BaSyxDeployment context = new BaSyxDeployment(
- new BaSyxExamplesContext()
- );
-
-
-
-
- /**
- * Run code snippet. This code snippet illustrates the creation of an AASDescriptor, the dynamic creation and deployment of an AAS sub model,
- * the lookup of the AAS sub model, and the access of the AAS sub model.
- */
- @Test
- public void snippet() throws Exception {
-
- // Create AAS descriptor and sub model descriptors
- ModelUrn aasURN = new ModelUrn("urn:de.FHG:devices.es.iese:aas:1.0:3:x-509#001");
- String aasSrvURL = "http://localhost:8080" + BaSyxExamplesContext.AASSERVERURL;
-
- // Create AAS
- AssetAdministrationShell aas = new AssetAdministrationShell();
-
- // - Set AAS ID
- aas.setIdentification(aasURN);
-
- // - Transfer AAS to server
- // - This creates the "urn:de.FHG:devices.es.iese:aas:1.0:3:x-509#001" element
- // on the server, which is the server
- // end point that will host the AAS.
- connManager.createAAS(aas, aasSrvURL);
-
- // - Sub model ID
- String smIdShort = "exampleSM";
- IIdentifier smId = new Identifier(IdentifierType.CUSTOM, "exampleSMId");
-
- // Create sub model
- SubModel submodel = new SubModel();
- submodel.setIdShort(smIdShort);
- submodel.setIdentification(smId.getIdType(), smId.getId());
-
- // - Add example properties to sub model
- Property prop1 = new Property(7);
- prop1.setIdShort("prop1");
- submodel.addSubModelElement(prop1);
-
- Property prop2 = new Property("myStr");
- prop2.setIdShort("prop2");
- submodel.addSubModelElement(prop2);
- // - Transfer sub model to server
- // - This creates the "exampleSM" element on the server, which is the server
- // end point that will host the AAS sub model.
- connManager.createSubModel(aasURN, submodel);
-
-
- // Connect to sub model using BaSyx SDK
- ISubModel connSM = connManager.retrieveSubModel(aasURN, smId);
-
-
- // Read property values from sub model
- String smID = connSM.getIdShort();
- String prop1Id = connSM.getProperties().get("prop1").getIdShort();
- int prop1Val = (int) connSM.getProperties().get("prop1").getValue();
- String prop2Id = connSM.getProperties().get("prop2").getIdShort();
- String prop2Val = (String) connSM.getProperties().get("prop2").getValue();
-
-
- // Check property values
- assertTrue(smID.equals(smIdShort));
- assertTrue(prop1Id.equals("prop1"));
- assertTrue(prop1Val == 7);
- assertTrue(prop2Id.equals("prop2"));
- assertTrue(prop2Val.equals("myStr"));
- }
-}
-
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/registry/RegisterRetrieveAASEndpoints.java b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/registry/RegisterRetrieveAASEndpoints.java
deleted file mode 100644
index cb6c73e..0000000
--- a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/registry/RegisterRetrieveAASEndpoints.java
+++ /dev/null
@@ -1,99 +0,0 @@
-package org.eclipse.basyx.examples.snippets.aas.registry;
-
-import static org.junit.Assert.assertEquals;
-
-import org.eclipse.basyx.aas.metamodel.map.descriptor.AASDescriptor;
-import org.eclipse.basyx.aas.metamodel.map.descriptor.ModelUrn;
-import org.eclipse.basyx.aas.metamodel.map.descriptor.SubmodelDescriptor;
-import org.eclipse.basyx.aas.registration.api.IAASRegistryService;
-import org.eclipse.basyx.aas.registration.proxy.AASRegistryProxy;
-import org.eclipse.basyx.examples.contexts.BaSyxExamplesContext;
-import org.eclipse.basyx.examples.deployment.BaSyxDeployment;
-import org.eclipse.basyx.examples.support.directory.ExamplesPreconfiguredDirectory;
-import org.eclipse.basyx.vab.manager.VABConnectionManager;
-import org.eclipse.basyx.vab.modelprovider.VABPathTools;
-import org.eclipse.basyx.vab.protocol.http.connector.HTTPConnectorProvider;
-import org.junit.ClassRule;
-import org.junit.Test;
-
-/**
- * Code snippet that registers an AAS descriptor with the AAS registry and accesses the registry using HTTP calls
- *
- * The snippet communicates with a VAB element that is deployed to a VABLambdaServlet on a
- * Apache Tomcat HTTP server instance. The VABLambdaServlet provides an empty container that
- * is able to host any VAB object.
- *
- * @author kuhn
- *
- */
-public class RegisterRetrieveAASEndpoints {
-
-
- /**
- * Create VAB connection manager backend
- *
- * The connection manager uses a preconfigured directory for resolving IDs to
- * network addresses, and a HTTP connector to connect to VAB objects.
- */
- protected VABConnectionManager connManager = new VABConnectionManager(new ExamplesPreconfiguredDirectory(), new HTTPConnectorProvider());
-
-
- /**
- * The BaSyx Deployment instantiates and starts context elements for this example.
- *
- * This example instantiates the BaSyxExamplesContext_1MemoryAASServer_1SQLDirectory
- * example context that creates one AAS server, and one SQL based AAS registry.
- *
- * BaSyxDeployment contexts instantiate all components on the IP address of the host.
- * Therefore, all components use the same IP address.
- */
- @ClassRule
- public static BaSyxDeployment context = new BaSyxDeployment(
- new BaSyxExamplesContext()
- );
-
-
-
-
- /**
- * Run code snippet. This code snippet illustrates the creation of an AASDescriptor, its registration, and
- * the lookup of the AAS using HTTP REST calls
- */
- @Test
- public void snippet() throws Exception {
-
- // Create AAS descriptor and sub model descriptors
- ModelUrn aasURN = new ModelUrn("urn:de.FHG:devices.es.iese:aas:1.0:3:x-509#001");
- ModelUrn subModelURN = new ModelUrn("urn:de.FHG:devices.es.iese:exampleSM:1.0:3:x-509#001");
- String aasSrvURL = "http://localhost:8080" + BaSyxExamplesContext.AASSERVERURL;
- String aasPath = VABPathTools.concatenatePaths(aasSrvURL, aasURN.getEncodedURN(), "/aas");
- // - Create AAS descriptor
- AASDescriptor aasDescriptor = new AASDescriptor(aasURN, aasPath);
- // - Add sub model descriptor URI
-
- String smPath = VABPathTools.concatenatePaths(aasPath, "/submodels/" + subModelURN.getEncodedURN() + "/submodel");
- SubmodelDescriptor submodelDescriptor = new SubmodelDescriptor("smIdShort", subModelURN, smPath);
- aasDescriptor.addSubmodelDescriptor(submodelDescriptor);
-
-
- // Register AAS and sub model descriptors in directory (push AAS descriptor to server)
- // - Connect to AAS registry
- IAASRegistryService regProxy = new AASRegistryProxy(
- "http://localhost:8080/" + BaSyxExamplesContext.REGISTRYURL);
- // - Register AAS descriptor with AAS and sub model endpoints in registry
- regProxy.register(aasDescriptor);
-
-
- // Lookup AAS descriptor
- AASDescriptor aasDesc = regProxy.lookupAAS(aasURN);
- // - AAS end sub model end points
- String aasEndpointURL = aasDesc.getFirstEndpoint();
- String smEndpointURL = aasDesc.getSubModelDescriptor(subModelURN).getFirstEndpoint();
-
-
- // Check results
- assertEquals(aasPath, aasEndpointURL);
- assertEquals(smPath, smEndpointURL);
- }
-}
-
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/submodels/ConnectToAASSubModelSDK.java b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/submodels/ConnectToAASSubModelSDK.java
deleted file mode 100644
index 6a4402c..0000000
--- a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/submodels/ConnectToAASSubModelSDK.java
+++ /dev/null
@@ -1,137 +0,0 @@
-package org.eclipse.basyx.examples.snippets.aas.submodels;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.Map;
-
-import org.eclipse.basyx.aas.manager.ConnectedAssetAdministrationShellManager;
-import org.eclipse.basyx.components.servlet.submodel.SubmodelServlet;
-import org.eclipse.basyx.examples.contexts.BaSyxExamplesContext_Empty;
-import org.eclipse.basyx.examples.deployment.BaSyxDeployment;
-import org.eclipse.basyx.examples.support.directory.ExampleAASRegistry;
-import org.eclipse.basyx.submodel.metamodel.api.ISubModel;
-import org.eclipse.basyx.submodel.metamodel.api.identifier.IIdentifier;
-import org.eclipse.basyx.submodel.metamodel.api.identifier.IdentifierType;
-import org.eclipse.basyx.submodel.metamodel.api.submodelelement.ISubmodelElement;
-import org.eclipse.basyx.submodel.metamodel.api.submodelelement.ISubmodelElementCollection;
-import org.eclipse.basyx.submodel.metamodel.api.submodelelement.dataelement.IProperty;
-import org.eclipse.basyx.submodel.metamodel.map.SubModel;
-import org.eclipse.basyx.submodel.metamodel.map.identifier.Identifier;
-import org.eclipse.basyx.submodel.metamodel.map.submodelelement.SubmodelElementCollection;
-import org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.Property;
-import org.eclipse.basyx.vab.protocol.http.connector.HTTPConnectorProvider;
-import org.junit.ClassRule;
-import org.junit.Test;
-
-/**
- * Code snippet that illustrates the use of CRUD Virtual Automation Bus (VAB) operations
- *
- * The snippet communicates with a VAB element that is deployed to a VABLambdaServlet on a
- * Apache Tomcat HTTP server instance. The VABLambdaServlet provides an empty container that
- * is able to host any VAB object.
- *
- * @author kuhn
- *
- */
-public class ConnectToAASSubModelSDK {
-
-
- /**
- * Example sub model. This example sub model is created with the BaSyx SDK factory and defines the AAS meta model properties
- */
- static class SampleSubModel extends SubModel {
- /**
- * Constructor - create sub model
- *
- * This sub model contains static properties, i.e. properties that have a static value assigned.
- */
- @SuppressWarnings("unchecked")
- public SampleSubModel() {
- // Set sub model id and name
- setIdShort("smName");
- setIdentification(IdentifierType.CUSTOM, "sm-001");
-
- // Add example properties
- // - Add simple property
- Property prop1 = new Property(234);
- prop1.setIdShort("prop1");
- addSubModelElement(prop1);
-
- Property prop11 = new Property(123);
- prop11.setIdShort("prop11");
- // - Add container property that holds other properties
- SubmodelElementCollection container = new SubmodelElementCollection();
- container.setIdShort("prop2");
- container.addSubModelElement(prop11);
- // - Add container to property map
- addSubModelElement(container);
-
- // Add another property manually to sub model container "properties"
- Property prop3 = new Property(17);
- prop3.setIdShort("prop3");
- ((Map<String, Object>) this.get("submodelElements")).put("prop3", prop3);
- }
- }
-
-
-
- /**
- * The BaSyx Deployment instantiates and starts context elements for this example.
- *
- * This example instantiates the BaSyxExamplesContext_1MemoryAASServer_1SQLDirectory
- * example context that creates one AAS server, and one SQL based AAS registry.
- *
- * BaSyxDeployment contexts instantiate all components on the IP address of the host.
- * Therefore, all components use the same IP address.
- */
- @ClassRule
- public static BaSyxDeployment context = new BaSyxDeployment(
- // Servlets for example snippet
- new BaSyxExamplesContext_Empty().
- // Deploy example specific servlets to Tomcat server in this context
- addServletMapping("/Testsuite/components/BaSys/1.0/SampleModel/*", new SubmodelServlet(new SampleSubModel()))
- );
-
-
- /**
- * Run code snippet. Access sub model, query data
- */
- @Test
- public void accessSubModel() throws Exception {
- // Create the AAS registry
- ExampleAASRegistry registry = new ExampleAASRegistry();
- registry.addAASMapping("aas-001", "http://localhost:8080/basys.examples/Testsuite/components/BaSys/1.0/SampleModel/")
- .addSubmodelMapping("aas-001", "sm-001", "http://localhost:8080/basys.examples/Testsuite/components/BaSys/1.0/SampleModel/");
-
- // Create manager using the directory stub and the HTTPConnectorProvider
- ConnectedAssetAdministrationShellManager manager = new ConnectedAssetAdministrationShellManager(registry,
- // We connect via HTTP
- new HTTPConnectorProvider());
-
-
- // Retrieve sub model (created by factory) with SDK connector
- // - Create and connect SDK connector
- IIdentifier aasId = new Identifier(IdentifierType.CUSTOM, "aas-001");
- IIdentifier smId = new Identifier(IdentifierType.CUSTOM, "sm-001");
- ISubModel subModel = manager.retrieveSubModel(aasId, smId);
-
- // - Retrieve sub model values and compare to expected values
- Map<String, ISubmodelElement> smElements = subModel.getSubmodelElements();
- IProperty prop1 = (IProperty) smElements.get("prop1");
- ISubmodelElementCollection prop2 = (ISubmodelElementCollection) smElements.get("prop2");
- IProperty prop11 = prop2.getProperties().get("prop11");
- IProperty prop3 = (IProperty) smElements.get("prop3");
-
- assertEquals(smId.getId(), subModel.getIdentification().getId());
- assertEquals("smName", subModel.getIdShort());
- assertEquals("prop1", prop1.getIdShort());
- assertEquals(234, prop1.getValue());
- assertEquals("prop2", prop2.getIdShort());
- assertEquals("prop11", prop11.getIdShort());
- assertEquals(123, prop11.getValue());
- assertEquals("prop3", prop3.getIdShort());
- assertEquals(17, prop3.getValue());
- }
-}
-
-
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/submodels/ConnectToAASSubModelVAB.java b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/submodels/ConnectToAASSubModelVAB.java
deleted file mode 100644
index fbb25ed..0000000
--- a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/submodels/ConnectToAASSubModelVAB.java
+++ /dev/null
@@ -1,161 +0,0 @@
-package org.eclipse.basyx.examples.snippets.aas.submodels;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.Map;
-
-import org.eclipse.basyx.aas.manager.ConnectedAssetAdministrationShellManager;
-import org.eclipse.basyx.components.servlet.submodel.SubmodelServlet;
-import org.eclipse.basyx.examples.contexts.BaSyxExamplesContext_Empty;
-import org.eclipse.basyx.examples.deployment.BaSyxDeployment;
-import org.eclipse.basyx.examples.support.directory.ExampleAASRegistry;
-import org.eclipse.basyx.examples.support.directory.ExamplesPreconfiguredDirectory;
-import org.eclipse.basyx.submodel.metamodel.api.identifier.IdentifierType;
-import org.eclipse.basyx.submodel.metamodel.map.SubModel;
-import org.eclipse.basyx.submodel.metamodel.map.identifier.Identifier;
-import org.eclipse.basyx.submodel.metamodel.map.qualifier.Identifiable;
-import org.eclipse.basyx.submodel.metamodel.map.qualifier.Referable;
-import org.eclipse.basyx.submodel.metamodel.map.submodelelement.SubmodelElementCollection;
-import org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.Property;
-import org.eclipse.basyx.submodel.restapi.MultiSubmodelElementProvider;
-import org.eclipse.basyx.vab.manager.VABConnectionManager;
-import org.eclipse.basyx.vab.modelprovider.VABElementProxy;
-import org.eclipse.basyx.vab.protocol.http.connector.HTTPConnectorProvider;
-import org.junit.ClassRule;
-import org.junit.Test;
-
-
-
-/**
- * Code snippet that illustrates the use of CRUD Virtual Automation Bus (VAB) operations
- *
- * The snippet communicates with a VAB element that is deployed to a VABLambdaServlet on a
- * Apache Tomcat HTTP server instance. The VABLambdaServlet provides an empty container that
- * is able to host any VAB object.
- *
- * @author kuhn
- *
- */
-public class ConnectToAASSubModelVAB {
-
-
- /**
- * Example sub model. This example sub model is created with the BaSyx SDK factory and defines the AAS meta model properties
- */
- static class SampleSubModel extends SubModel {
- /**
- * Constructor - create sub model
- *
- * This sub model contains static properties, i.e. properties that have a static value assigned.
- */
- @SuppressWarnings("unchecked")
- public SampleSubModel() {
- // Set sub model id and name
- setIdShort("smName");
- setIdentification(IdentifierType.CUSTOM, "sm-001");
-
- // Add example properties
- // - Add simple property
- Property prop1 = new Property(234);
- prop1.setIdShort("prop1");
- addSubModelElement(prop1);
-
- Property prop11 = new Property(123);
- prop11.setIdShort("prop11");
- // - Add container property that holds other properties
- SubmodelElementCollection container = new SubmodelElementCollection();
- container.setIdShort("prop2");
- container.addSubModelElement(prop11);
- // - Add container to property map
- addSubModelElement(container);
-
- // Add another property manually to sub model container "properties"
- Property prop3 = new Property(17);
- prop3.setIdShort("prop3");
- ((Map<String, Object>) this.get("submodelElements")).put("prop3", prop3);
- }
- }
-
-
-
- /**
- * Create VAB connection manager backend
- *
- * The connection manager uses a preconfigured directory for resolving IDs to
- * network addresses, and a HTTP connector to connect to VAB objects.
- */
- protected VABConnectionManager connManager = new VABConnectionManager(
- // Add example specific mappings
- new ExamplesPreconfiguredDirectory()
- .addMapping("aas-001", "http://localhost:8080/basys.examples/Testsuite/components/BaSys/1.0/SampleModel/")
- .addMapping("sm-001", "http://localhost:8080/basys.examples/Testsuite/components/BaSys/1.0/SampleModel/")
- .addMapping("sm-001VAB", "http://localhost:8080/basys.examples/Testsuite/components/BaSys/1.0/SampleModel/"),
- // We connect via HTTP
- new HTTPConnectorProvider());
-
- protected ConnectedAssetAdministrationShellManager manager = new ConnectedAssetAdministrationShellManager(
- new ExampleAASRegistry()
- .addAASMapping("aas-001", "http://localhost:8080/basys.examples/Testsuite/components/BaSys/1.0/SampleModel/")
- .addSubmodelMapping("aas-001", "sm-001", "http://localhost:8080/basys.examples/Testsuite/components/BaSys/1.0/SampleModel/"),
- // We connect via HTTP
- new HTTPConnectorProvider());
-
-
- /**
- * The BaSyx Deployment instantiates and starts context elements for this example.
- *
- * This example instantiates the BaSyxExamplesContext_1MemoryAASServer_1SQLDirectory
- * example context that creates one AAS server, and one SQL based AAS registry.
- *
- * BaSyxDeployment contexts instantiate all components on the IP address of the host.
- * Therefore, all components use the same IP address.
- */
- @ClassRule
- public static BaSyxDeployment context = new BaSyxDeployment(
- // Servlets for example snippet
- new BaSyxExamplesContext_Empty().
- // Deploy example specific servlets to Tomcat server in this context
- addServletMapping("/Testsuite/components/BaSys/1.0/SampleModel/*", new SubmodelServlet(new SampleSubModel()))
- );
-
-
- /**
- * Run code snippet. Access sub model, query data
- */
- @Test @SuppressWarnings("unchecked")
- public void accessSubModel() throws Exception {
- // Retrieve sub model (created by factory) with SDK connector
- // - Connect to sub model using lower-level VAB interface
- VABElementProxy connSubModel1 = this.connManager.connectToVABElement("sm-001VAB");
- Map<String, Object> submodel = (Map<String, Object>) connSubModel1.getModelPropertyValue("");
- Map<String, Object> smId = (Map<String, Object>) submodel.get(Identifiable.IDENTIFICATION);
-
- // - Read properties
- Map<String, Object> prop1 = (Map<String, Object>) connSubModel1.getModelPropertyValue(MultiSubmodelElementProvider.ELEMENTS + "/prop1");
- Map<String, Object> prop2 = (Map<String, Object>) connSubModel1.getModelPropertyValue(MultiSubmodelElementProvider.ELEMENTS + "/prop2");
- Map<String, Object> prop11 = (Map<String, Object>) connSubModel1.getModelPropertyValue("submodelElements/prop2/prop11");
- Map<String, Object> prop3 = (Map<String, Object>) connSubModel1.getModelPropertyValue(MultiSubmodelElementProvider.ELEMENTS + "/prop3");
-
- // - Change property value using VAB primitive
- connSubModel1.setModelPropertyValue(MultiSubmodelElementProvider.ELEMENTS + "/prop1/value", 456);
-
- // - Read value back using VAB primitive
- Map<String, Object> changedProp1 = (Map<String, Object>) connSubModel1
- .getModelPropertyValue(MultiSubmodelElementProvider.ELEMENTS + "/prop1");
-
- // - Check results
- assertEquals("sm-001", smId.get(Identifier.ID));
- assertEquals("smName", submodel.get(Referable.IDSHORT));
- assertEquals("prop1", prop1.get(Referable.IDSHORT));
- assertEquals(234, prop1.get(Property.VALUE)); // old value of prop1 has been stored locally
- assertEquals(456, changedProp1.get(Property.VALUE)); // new value is 456
- assertEquals("prop2", prop2.get(Referable.IDSHORT));
- assertEquals("prop11", prop11.get(Referable.IDSHORT));
- assertEquals(123, prop11.get(Property.VALUE));
- assertEquals("prop3", prop3.get(Referable.IDSHORT));
- assertEquals(17, prop3.get(Property.VALUE));
-
- }
-}
-
-
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/submodels/CreateAASSubModelSDK.java b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/submodels/CreateAASSubModelSDK.java
deleted file mode 100644
index c19ef23..0000000
--- a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/submodels/CreateAASSubModelSDK.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package org.eclipse.basyx.examples.snippets.aas.submodels;
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.Map;
-
-import org.eclipse.basyx.submodel.metamodel.map.SubModel;
-import org.eclipse.basyx.submodel.metamodel.map.submodelelement.SubmodelElementCollection;
-import org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.Property;
-import org.junit.Test;
-
-
-
-/**
- * Code snippet that illustrates the creation of an AAS sub model
- *
- * @author kuhn
- *
- */
-public class CreateAASSubModelSDK {
-
-
- /**
- * Example sub model. This example sub model is created with the BaSyx SDK factory and defines the AAS meta model properties
- */
- static class SampleSubModel extends SubModel {
- /**
- * Constructor - create sub model
- *
- * This sub model contains static properties, i.e. properties that have a static value assigned.
- */
- @SuppressWarnings("unchecked")
- public SampleSubModel() {
- // Set sub model ID
- setIdShort("sm-001");
-
- // Add example properties
- // - Add simple property
- Property prop1 = new Property(234);
- prop1.setIdShort("prop1");
- addSubModelElement(prop1);
-
- Property prop11 = new Property(123);
- prop11.setIdShort("prop11");
- // - Add container property that holds other properties
- SubmodelElementCollection container = new SubmodelElementCollection();
- container.setIdShort("prop2");
- container.addSubModelElement(prop11);
- // - Add container to property map
- addSubModelElement(container);
-
- // Add another property manually to sub model container "properties"
- Property prop3 = new Property(17);
- prop3.setIdShort("prop3");
- {
- ((Map<String, Object>) this.get("submodelElements")).put("prop3", prop3);
- }
- }
- }
-
-
- /**
- * Run code snippet. Instantiate AAS sub model.
- */
- @Test
- public void accessSubModel() throws Exception {
- // Instantiate AAS sub model
- SampleSubModel sampleSM = new SampleSubModel();
-
- // Access sub model property
- int propertyVal = (int) sampleSM.getPath("submodelElements/prop1/value");
-
- // Check property value
- assertTrue(propertyVal == 234);
- }
-}
-
-
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/submodels/CreateAASSubModelVAB.java b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/submodels/CreateAASSubModelVAB.java
deleted file mode 100644
index 84327cd..0000000
--- a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/submodels/CreateAASSubModelVAB.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package org.eclipse.basyx.examples.snippets.aas.submodels;
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.Map;
-
-import org.eclipse.basyx.submodel.metamodel.map.SubModel;
-import org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.Property;
-import org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.valuetypedef.PropertyValueTypeDefHelper;
-import org.junit.Test;
-
-
-
-/**
- * Code snippet that illustrates the creation of an AAS sub model
- *
- * @author kuhn
- *
- */
-public class CreateAASSubModelVAB {
-
-
- /**
- * Example sub model. This example sub model is created with the BaSyx SDK factory and defines the AAS meta model properties
- */
- static class SampleSubModel extends SubModel {
- /**
- * Constructor - create sub model property
- *
- * This sub model contains static properties, i.e. properties that have a static value assigned.
- */
- @SuppressWarnings("unchecked")
- public SampleSubModel() {
- // Set sub model ID
- setIdShort("sm-001M");
-
- // Add example properties
- // - Add simple property with value and idShort meta elements
- this.putPath("properties/prop1/value", 234);
- this.putPath("properties/prop1/valueType", PropertyValueTypeDefHelper.getTypeWrapperFromObject(234));
- this.putPath("properties/prop1/idShort", "prop1");
-
- // Add container property that holds other properties
- this.putPath("properties/prop2/idShort", "prop2");
- // - Add contained property
- this.putPath("properties/prop2/properties/prop11/value", 123);
- this.putPath("properties/prop2/properties/prop11/valueType", PropertyValueTypeDefHelper.getTypeWrapperFromObject(123).toString());
- this.putPath("properties/prop2/properties/prop11/idShort", "prop11");
-
- // Add another property manually to sub model container "properties"
- // - Using the Property class ensures presence of all meta properties
- Property addedProperty = new Property();
- addedProperty.set(17);
- addedProperty.setIdShort("prop3");
- // - Add property to sub model container "properties"
- {((Map<String, Object>) this.get("properties")).put("prop3", addedProperty);}
- }
- }
-
-
- /**
- * Run code snippet. Instantiate AAS sub model.
- */
- @Test
- public void accessSubModel() throws Exception {
- // Instantiate AAS sub model
- SampleSubModel sampleSM = new SampleSubModel();
-
- // Access sub model property
- int propertyVal = (int) sampleSM.getPath("properties/prop1/value");
-
- // Check property value
- assertTrue(propertyVal == 234);
- }
-}
-
-
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/submodels/DynamicSubModelDeployment.java b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/submodels/DynamicSubModelDeployment.java
deleted file mode 100644
index 0028072..0000000
--- a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/submodels/DynamicSubModelDeployment.java
+++ /dev/null
@@ -1,112 +0,0 @@
-package org.eclipse.basyx.examples.snippets.aas.submodels;
-
-import static org.junit.Assert.assertTrue;
-
-import org.eclipse.basyx.aas.manager.ConnectedAssetAdministrationShellManager;
-import org.eclipse.basyx.aas.metamodel.map.AssetAdministrationShell;
-import org.eclipse.basyx.aas.metamodel.map.descriptor.ModelUrn;
-import org.eclipse.basyx.components.servlet.aas.AASServlet;
-import org.eclipse.basyx.examples.contexts.BaSyxExamplesContext;
-import org.eclipse.basyx.examples.deployment.BaSyxDeployment;
-import org.eclipse.basyx.examples.support.directory.ExampleAASRegistry;
-import org.eclipse.basyx.submodel.metamodel.api.ISubModel;
-import org.eclipse.basyx.submodel.metamodel.map.SubModel;
-import org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.Property;
-import org.eclipse.basyx.vab.protocol.http.connector.HTTPConnectorProvider;
-import org.junit.ClassRule;
-import org.junit.Test;
-
-/**
- * Code snippet that illustrates the creation of an AAS sub model
- *
- * @author kuhn
- *
- */
-public class DynamicSubModelDeployment {
-
- private static final String AAS = "de.FHG:devices.es.iese:aas:1.0:3:x-509#003";
- private static final String STATUS_SM = "de.FHG:devices.es.iese:statusSM:1.0:3:x-509#003";
-
- protected ConnectedAssetAdministrationShellManager aasManager = new ConnectedAssetAdministrationShellManager(
- new ExampleAASRegistry()
- .addAASMapping(AAS,
- "http://localhost:8080/basys.examples/Testsuite/components/BaSys/1.0/dynamicModelRepository/aas/")
- // Ass Example specific mappings
- .addSubmodelMapping(AAS, STATUS_SM,
- "http://localhost:8080/basys.examples/Testsuite/components/BaSys/1.0/dynamicModelRepository/aas/submodels/Status"),
- new HTTPConnectorProvider());
-
- /**
- * The BaSyx Deployment instantiates and starts context elements for this example.
- *
- * This example instantiates the BaSyxExamplesContext_1MemoryAASServer_1SQLDirectory
- * example context that creates one AAS server, and one SQL based AAS registry.
- *
- * BaSyxDeployment contexts instantiate all components on the IP address of the host.
- * Therefore, all components use the same IP address.
- */
- @ClassRule
- public static BaSyxDeployment context = new BaSyxDeployment(
- // Simulated servlets
- // - BaSys topology with one AAS Server and one SQL directory
- new BaSyxExamplesContext()
- // Deploy example specific servlets to Apache Tomcat server in this context
- .addServletMapping("/Testsuite/components/BaSys/1.0/dynamicModelRepository/*",
- new AASServlet(new AssetAdministrationShell()))
- );
-
-
-
-
- /**
- * Run code snippet. This code snippet illustrates the use of CRUD operations to
- * access Virtual Automation Bus objects
- */
- @Test
- public void snippet() throws Exception {
- // Instantiate sub model
- SubModel submodel = new SubModel();
- // - Add example properties to sub model
- submodel.setIdShort("Status");
- Property prop1 = new Property(7);
- prop1.setIdShort("prop1");
- submodel.addSubModelElement(prop1);
-
- Property prop2 = new Property("myStr");
- prop2.setIdShort("prop2");
- submodel.addSubModelElement(prop2);
-
-
-
- // Transfer sub model to server
- aasManager.createSubModel(new ModelUrn(AAS), submodel);
-
-
- // Retrieve sub model with SDK connector
- {
-
- // Server connections
- // - Connect to sub model. Connecting to a sub model by its ID is discouraged, because a sub
- // model ID is not necessarily unique outside the scope of its AAS. If users want to connect
- // directly to sub models, the registry needs to support this, and unique identifies (as here)
- // must be used. For portability, users should connect to sub models instead via an AAS ID and
- // sub model ID tuple, as illustrated in the registry examples.
- ISubModel subModel = aasManager.retrieveSubModel(new ModelUrn(AAS), new ModelUrn(STATUS_SM));
-
- // Read sub model properties
- String smId = subModel.getIdShort();
- String prop1Id = subModel.getProperties().get("prop1").getIdShort();
- int prop1Val = (int) subModel.getProperties().get("prop1").getValue();
- String prop2Id = subModel.getProperties().get("prop2").getIdShort();
- String prop2Val = (String) subModel.getProperties().get("prop2").getValue();
-
- // Compare sub model property values
- assertTrue(smId.equals("Status"));
- assertTrue(prop1Id.equals("prop1"));
- assertTrue(prop1Val == 7);
- assertTrue(prop2Id.equals("prop2"));
- assertTrue(prop2Val.equals("myStr"));
- }
- }
-}
-
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/submodels/DynamicSubModelDeploymentHTTP.java b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/submodels/DynamicSubModelDeploymentHTTP.java
deleted file mode 100644
index cabbd95..0000000
--- a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/submodels/DynamicSubModelDeploymentHTTP.java
+++ /dev/null
@@ -1,117 +0,0 @@
-package org.eclipse.basyx.examples.snippets.aas.submodels;
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.Map;
-
-import org.eclipse.basyx.aas.metamodel.map.AssetAdministrationShell;
-import org.eclipse.basyx.components.servlet.aas.AASServlet;
-import org.eclipse.basyx.examples.contexts.BaSyxExamplesContext;
-import org.eclipse.basyx.examples.deployment.BaSyxDeployment;
-import org.eclipse.basyx.examples.support.directory.ExamplesPreconfiguredDirectory;
-import org.eclipse.basyx.submodel.metamodel.map.SubModel;
-import org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.Property;
-import org.eclipse.basyx.submodel.restapi.MultiSubmodelElementProvider;
-import org.eclipse.basyx.tools.webserviceclient.WebServiceJSONClient;
-import org.eclipse.basyx.vab.manager.VABConnectionManager;
-import org.eclipse.basyx.vab.modelprovider.VABElementProxy;
-import org.eclipse.basyx.vab.protocol.http.connector.HTTPConnectorProvider;
-import org.junit.ClassRule;
-import org.junit.Test;
-
-/**
- * Code snippet that illustrates the creation of an AAS sub model, and the access to the sub model via HTTP REST calls
- *
- * @author kuhn
- *
- */
-public class DynamicSubModelDeploymentHTTP {
-
-
- /**
- * Create VAB connection manager backend
- *
- * The connection manager uses a preconfigured directory for resolving IDs to
- * network addresses, and a HTTP connector to connect to VAB objects.
- */
- protected VABConnectionManager connManager = new VABConnectionManager(
- new ExamplesPreconfiguredDirectory()
- // Add example specific mappings
- .addMapping("urn:de.FHG:devices.es.iese:aas:1.0:3:x-509:003",
- "http://localhost:8080/basys.examples/Testsuite/components/BaSys/1.0/dynamicModelRepository/aas"),
- new HTTPConnectorProvider());
-
-
- /**
- * The BaSyx Deployment instantiates and starts context elements for this example.
- *
- * This example instantiates the BaSyxExamplesContext_1MemoryAASServer_1SQLDirectory
- * example context that creates one AAS server, and one SQL based AAS registry.
- *
- * BaSyxDeployment contexts instantiate all components on the IP address of the host.
- * Therefore, all components use the same IP address.
- */
- @ClassRule
- public static BaSyxDeployment context = new BaSyxDeployment(
- // Simulated servlets
- // - BaSys topology with one AAS Server and one SQL directory
- new BaSyxExamplesContext()
- // Deploy example specific servlets to Apache Tomcat server in this context
- .addServletMapping("/Testsuite/components/BaSys/1.0/dynamicModelRepository/*",
- new AASServlet(new AssetAdministrationShell()))
- );
-
-
-
-
- /**
- * Run code snippet. This code snippet illustrates the dynamic deployment of a sub model and the use of HTTP REST operations to
- * access the sub model
- */
- @Test @SuppressWarnings("unchecked")
- public void snippet() throws Exception {
-
- // Server connections
- // - Connect to sub model. Connecting to a sub model by its ID is discouraged, because a sub
- // model ID is not necessarily unique outside the scope of its AAS. If users want to connect
- // directly to sub models, the registry needs to support this, and unique identifies (as here)
- // must be used. For portability, users should connect to sub models instead via an AAS ID and
- // sub model ID tuple, as illustrated in the registry examples.
- VABElementProxy connSubModels = this.connManager.connectToVABElement("urn:de.FHG:devices.es.iese:aas:1.0:3:x-509:003");
-
- // Add example properties
- SubModel submodel = new SubModel();
- submodel.setIdShort("Status");
- Property prop1 = new Property(7);
- prop1.setIdShort("prop1");
- submodel.addSubModelElement(prop1);
-
- Property prop2 = new Property("myStr");
- prop2.setIdShort("prop2");
- submodel.addSubModelElement(prop2);
-
- // Transfer sub model to server
- connSubModels.setModelPropertyValue("/submodels/" + submodel.getIdShort(), submodel);
-
-
- // Web service client accesses AAS using HTTP REST calls
- WebServiceJSONClient jsonClient = new WebServiceJSONClient();
-
- // Read property values using the WebServiceJSONClient class.
- // - Returned property contains meta data. The actual property is stored in property "entity", property value is in entity property "value"
- String smEndpoint = "http://localhost:8080/basys.examples/Testsuite/components/BaSys/1.0/dynamicModelRepository/aas/submodels/Status/submodel";
- Map<String, Object> sm = ((Map<String, Object>) jsonClient.get(smEndpoint));
- String smId = (String) sm.get("idShort");
- int prop1Val = (int) ((Map<String, Object>) jsonClient.get(smEndpoint + "/" + MultiSubmodelElementProvider.ELEMENTS + "/prop1")).get("value");
- String prop1Id = (String) ((Map<String, Object>) jsonClient.get(smEndpoint + "/" + MultiSubmodelElementProvider.ELEMENTS + "/prop1")).get("idShort");
- String prop2Val = (String) ((Map<String, Object>) jsonClient.get(smEndpoint + "/" + MultiSubmodelElementProvider.ELEMENTS + "/prop2")).get("value");
-
-
- // Check results
- assertTrue(smId.equals("Status"));
- assertTrue(prop1Val == 7);
- assertTrue(prop1Id.equals("prop1"));
- assertTrue(prop2Val.equals("myStr"));
- }
-}
-
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/submodels/InvokeSubModelOperationSDK.java b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/submodels/InvokeSubModelOperationSDK.java
deleted file mode 100644
index d608f14..0000000
--- a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/aas/submodels/InvokeSubModelOperationSDK.java
+++ /dev/null
@@ -1,144 +0,0 @@
-package org.eclipse.basyx.examples.snippets.aas.submodels;
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.Map;
-import java.util.function.Function;
-
-import org.eclipse.basyx.aas.manager.ConnectedAssetAdministrationShellManager;
-import org.eclipse.basyx.aas.metamodel.map.descriptor.ModelUrn;
-import org.eclipse.basyx.components.servlet.submodel.SubmodelServlet;
-import org.eclipse.basyx.examples.contexts.BaSyxExamplesContext_Empty;
-import org.eclipse.basyx.examples.deployment.BaSyxDeployment;
-import org.eclipse.basyx.examples.support.directory.ExampleAASRegistry;
-import org.eclipse.basyx.submodel.metamodel.api.ISubModel;
-import org.eclipse.basyx.submodel.metamodel.api.submodelelement.operation.IOperation;
-import org.eclipse.basyx.submodel.metamodel.map.SubModel;
-import org.eclipse.basyx.submodel.metamodel.map.submodelelement.operation.Operation;
-import org.eclipse.basyx.vab.protocol.http.connector.HTTPConnectorProvider;
-import org.junit.ClassRule;
-import org.junit.Test;
-
-/**
- * Code snippet that illustrates the definition and invocation of sub model operations
- *
- * The snippet communicates with a VAB element that is deployed to a VABLambdaServlet on a
- * Apache Tomcat HTTP server instance. The VABLambdaServlet provides an empty container that
- * is able to host any VAB object.
- *
- * @author kuhn
- *
- */
-public class InvokeSubModelOperationSDK {
-
-
- /**
- * Example sub model. This example sub model is created with the BaSyx SDK factory and defines the AAS meta model properties
- */
- static class SampleSubModel extends SubModel {
- /**
- * Constructor - create sub model
- *
- * This sub model contains operations
- */
- public SampleSubModel() {
- // Set sub model ID
- setIdShort("sm-001");
-
- // Define operations
- Operation op1 = new Operation((Function<Object[], Object>) v -> {
- return operation1();
- });
- op1.setIdShort("operation1");
- addSubModelElement(op1);
-
- Operation op2 = new Operation((Function<Object[], Object>) v -> {
- return operation2((int) v[0], (int) v[1]);
- });
- op2.setIdShort("operation2");
- addSubModelElement(op2);
-
- }
-
- /**
- * Example operation implementation
- */
- public int operation1() {
- return 4;
- }
-
- /**
- * Example operation with parameter
- */
- public int operation2(int par1, int par2) {
- return par1+par2;
- }
- }
-
-
-
- /**
- * Create VAB connection manager backend
- *
- * The connection manager uses a preconfigured directory for resolving IDs to
- * network addresses, and a HTTP connector to connect to VAB objects.
- */
- protected ConnectedAssetAdministrationShellManager manager = new ConnectedAssetAdministrationShellManager(
- // Add example specific mappings
- new ExampleAASRegistry()
- .addAASMapping("aas-001", "http://localhost:8080/basys.examples/Testsuite/components/BaSys/1.0/SampleModel/")
- .addSubmodelMapping("aas-001", "sm-001", "http://localhost:8080/basys.examples/Testsuite/components/BaSys/1.0/SampleModel/"),
- // We connect via HTTP
- new HTTPConnectorProvider());
-
-
- /**
- * The BaSyx Deployment instantiates and starts context elements for this example.
- *
- * This example instantiates the BaSyxExamplesContext_1MemoryAASServer_1SQLDirectory
- * example context that creates one AAS server, and one SQL based AAS registry.
- *
- * BaSyxDeployment contexts instantiate all components on the IP address of the host.
- * Therefore, all components use the same IP address.
- */
- @ClassRule
- public static BaSyxDeployment context = new BaSyxDeployment(
- // Servlets for example snippet
- new BaSyxExamplesContext_Empty().
- // Deploy example specific servlets to Tomcat server in this context
- addServletMapping("/Testsuite/components/BaSys/1.0/SampleModel/*", new SubmodelServlet(new SampleSubModel()))
- );
-
-
- /**
- * Run code snippet. Access sub model, query data
- */
- @Test
- public void accessSubModel() throws Exception {
- // Retrieve sub model (created by factory) with SDK connector
- {
- // Create and connect SDK connector
- ISubModel subModel = manager.retrieveSubModel(new ModelUrn("aas-001"), new ModelUrn("sm-001"));
-
- // Sub model operations
- Map<String, IOperation> operations = subModel.getOperations();
-
- // Get first operation by name
- IOperation op1 = operations.get("operation1");
- // - Invoke operation
- int result1 = (int) op1.invoke();
-
- // Get second operation by name
- IOperation op2 = operations.get("operation2");
- // - Invoke operation
- int result2 = (int) op2.invoke(7, 5);
-
-
- // Check results
- assertTrue(result1 == 4);
- assertTrue(result2 == 12);
- }
- }
-}
-
-
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/submodel/TestAddSubmodelElement.java b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/submodel/TestAddSubmodelElement.java
new file mode 100644
index 0000000..d7af892
--- /dev/null
+++ b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/submodel/TestAddSubmodelElement.java
@@ -0,0 +1,50 @@
+package org.eclipse.basyx.examples.snippets.submodel;
+
+import static org.junit.Assert.assertEquals;
+
+import org.eclipse.basyx.aas.manager.ConnectedAssetAdministrationShellManager;
+import org.eclipse.basyx.examples.snippets.AbstractSnippetTest;
+import org.eclipse.basyx.submodel.metamodel.api.ISubModel;
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IIdentifier;
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IdentifierType;
+import org.eclipse.basyx.submodel.metamodel.api.submodelelement.ISubmodelElement;
+import org.eclipse.basyx.submodel.metamodel.map.identifier.Identifier;
+import org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.Property;
+import org.junit.Test;
+
+/**
+ * Test for the AddSubmodelElement snippet
+ *
+ * @author conradi
+ *
+ */
+public class TestAddSubmodelElement extends AbstractSnippetTest {
+
+ private static final String NEW_PROPERTY_ID = "new_prop";
+ private static final int NEW_PROPERTY_VALUE = 321;
+
+ @Test
+ public void testAddSubmodelElement() {
+
+ // Get the Identifiers of the AAS and Submodel
+ IIdentifier aasIdentifier = new Identifier(IdentifierType.CUSTOM, AAS_ID);
+ IIdentifier smIdentifier = new Identifier(IdentifierType.CUSTOM, SM_ID);
+
+ // Build a new SubmodelElement
+ Property newProperty = new Property();
+ newProperty.setIdShort(NEW_PROPERTY_ID);
+ newProperty.setValue(NEW_PROPERTY_VALUE);
+
+ // Add the new Element to the Submodel
+ AddSubmodelElement.addSubmodelElement(newProperty, smIdentifier, aasIdentifier, registryComponent.getRegistryPath());
+
+ // Get the Element from the server
+ ConnectedAssetAdministrationShellManager manager = getManager();
+ ISubModel remoteSubmodel = manager.retrieveSubModel(aasIdentifier, smIdentifier);
+ ISubmodelElement remoteElement = remoteSubmodel.getSubmodelElement(NEW_PROPERTY_ID);
+
+ // Check if its value is as expected
+ assertEquals(NEW_PROPERTY_VALUE, remoteElement.getValue());
+ }
+
+}
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/submodel/TestDeleteSubmodelElement.java b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/submodel/TestDeleteSubmodelElement.java
new file mode 100644
index 0000000..5da765a
--- /dev/null
+++ b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/submodel/TestDeleteSubmodelElement.java
@@ -0,0 +1,53 @@
+package org.eclipse.basyx.examples.snippets.submodel;
+
+import static org.junit.Assert.fail;
+
+import org.eclipse.basyx.aas.manager.ConnectedAssetAdministrationShellManager;
+import org.eclipse.basyx.aas.registration.proxy.AASRegistryProxy;
+import org.eclipse.basyx.examples.snippets.AbstractSnippetTest;
+import org.eclipse.basyx.examples.support.ExampleComponentBuilder;
+import org.eclipse.basyx.submodel.metamodel.api.ISubModel;
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IIdentifier;
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IdentifierType;
+import org.eclipse.basyx.submodel.metamodel.map.identifier.Identifier;
+import org.eclipse.basyx.vab.exception.provider.ResourceNotFoundException;
+import org.junit.Test;
+
+/**
+ * Test for the DeleteSubmodelElement snippet
+ *
+ * @author conradi
+ *
+ */
+public class TestDeleteSubmodelElement extends AbstractSnippetTest {
+
+ @Test
+ public void testDeleteSubmodelElement() {
+
+ // Get the Identifier of the example AAS and Submodel
+ IIdentifier aasIdentifier = new Identifier(IdentifierType.CUSTOM, AAS_ID);
+ IIdentifier smIdentifier = new Identifier(IdentifierType.CUSTOM, SM_ID);
+
+ // Delete the SubmodelElement
+ DeleteSubmodelElement.deleteSubmodelElement(ExampleComponentBuilder.PROPERTY_ID, smIdentifier, aasIdentifier, registryComponent.getRegistryPath());
+
+ // Create a proxy pointing to the registry server
+ AASRegistryProxy registryProxy = new AASRegistryProxy(registryComponent.getRegistryPath());
+
+ // Create a ConnectedAASManager using the registryProxy as its registry
+ ConnectedAssetAdministrationShellManager manager =
+ new ConnectedAssetAdministrationShellManager(registryProxy);
+
+ // Retrieve the Submodel from the server as a ConnectedSubmodel
+ ISubModel submodel = manager.retrieveSubModel(aasIdentifier, smIdentifier);
+
+ // Try to retrieve deleted SubmodelElement; should throw ResourceNotFoundException
+ try {
+ submodel.getSubmodelElement(ExampleComponentBuilder.PROPERTY_ID);
+ fail();
+ } catch (ResourceNotFoundException e) {
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/submodel/TestExecuteOperation.java b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/submodel/TestExecuteOperation.java
new file mode 100644
index 0000000..6da88ae
--- /dev/null
+++ b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/submodel/TestExecuteOperation.java
@@ -0,0 +1,104 @@
+package org.eclipse.basyx.examples.snippets.submodel;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.function.Function;
+
+import org.eclipse.basyx.aas.metamodel.map.descriptor.SubmodelDescriptor;
+import org.eclipse.basyx.aas.registration.proxy.AASRegistryProxy;
+import org.eclipse.basyx.components.configuration.BaSyxContextConfiguration;
+import org.eclipse.basyx.components.servlet.submodel.SubmodelServlet;
+import org.eclipse.basyx.examples.snippets.AbstractSnippetTest;
+import org.eclipse.basyx.examples.support.ExampleComponentBuilder;
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IIdentifier;
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IdentifierType;
+import org.eclipse.basyx.submodel.metamodel.map.SubModel;
+import org.eclipse.basyx.submodel.metamodel.map.identifier.Identifier;
+import org.eclipse.basyx.submodel.metamodel.map.submodelelement.operation.Operation;
+import org.eclipse.basyx.vab.protocol.http.server.AASHTTPServer;
+import org.eclipse.basyx.vab.protocol.http.server.BaSyxContext;
+import org.junit.After;
+import org.junit.Test;
+
+/**
+ * Test for the ExecuteOperation snippet
+ *
+ * @author conradi
+ *
+ */
+public class TestExecuteOperation extends AbstractSnippetTest {
+
+ private static final String NEW_SM_ID_SHORT = "smIdShort_New";
+ private static final String NEW_SM_ID = "smId_New";
+
+ private static final String OPERATION_ID = "operation";
+
+ private static final Object[] PARAMETERS = {2, 3};
+ private static final int EXPECTED_RESULT = 5;
+
+ private AASHTTPServer server;
+
+ @After
+ public void shutdownServer() {
+ server.shutdown();
+ }
+
+ @Test
+ public void testExecuteOperation() throws Exception {
+
+ SubModel submodel = ExampleComponentBuilder.buildExampleSubmodel(NEW_SM_ID_SHORT, NEW_SM_ID);
+
+ // Add an Operation which calculates the sum of the two parameters
+ Operation operation = new Operation((Function<Object[], Object>) v -> {
+ return (int) v[0] + (int) v[1];
+ });
+ operation.setIdShort(OPERATION_ID);
+ submodel.addSubModelElement(operation);
+
+ // Startup a Server hosting this Submodel
+ provideSubmodel(submodel);
+
+
+ // Get the Identifiers of the AAS and Submodel
+ IIdentifier aasIdentifier = new Identifier(IdentifierType.CUSTOM, AAS_ID);
+ IIdentifier smIdentifier = new Identifier(IdentifierType.CUSTOM, NEW_SM_ID);
+
+ // Execute the Operation and get the result
+ Object result = ExecuteOperation.executeOperation(OPERATION_ID, PARAMETERS, smIdentifier, aasIdentifier, registryComponent.getRegistryPath());
+
+ // Check if the result is the expected value
+ assertEquals(EXPECTED_RESULT, result);
+
+ }
+
+ /**
+ * Starts a new server hosting a given Submodel
+ * This is necessary as an Operation can not be transfered to a server via serialization
+ *
+ * @param submodel the Submodel to be hosted
+ */
+ private void provideSubmodel(SubModel submodel) {
+ // Create a BaSyxConetxt for port 8082 with an empty endpoint
+ BaSyxContextConfiguration contextConfig = new BaSyxContextConfiguration(8082, "");
+ BaSyxContext context = contextConfig.createBaSyxContext();
+
+ // Create a new SubmodelServlet containing the submodel
+ SubmodelServlet smServlet = new SubmodelServlet(submodel);
+
+ // Add the SubmodelServlet mapping to the context at the path "/submodel"
+ context.addServletMapping("/submodel/*", smServlet);
+
+
+ // Create and start a HTTP server with the context created above
+ server = new AASHTTPServer(context);
+ server.start();
+
+ IIdentifier aasIdentifier = new Identifier(IdentifierType.CUSTOM, AAS_ID);
+ SubmodelDescriptor descriptor = new SubmodelDescriptor(submodel, "http://localhost:8082/submodel");
+
+ // Register the new Submodel
+ AASRegistryProxy registry = new AASRegistryProxy(registryComponent.getRegistryPath());
+ registry.register(aasIdentifier, descriptor);
+ }
+
+}
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/submodel/TestLookupSubmodel.java b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/submodel/TestLookupSubmodel.java
new file mode 100644
index 0000000..0305f12
--- /dev/null
+++ b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/submodel/TestLookupSubmodel.java
@@ -0,0 +1,36 @@
+package org.eclipse.basyx.examples.snippets.submodel;
+
+import static org.junit.Assert.assertEquals;
+
+import org.eclipse.basyx.aas.metamodel.map.descriptor.SubmodelDescriptor;
+import org.eclipse.basyx.examples.snippets.AbstractSnippetTest;
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IIdentifier;
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IdentifierType;
+import org.eclipse.basyx.submodel.metamodel.map.identifier.Identifier;
+import org.junit.Test;
+
+/**
+ * Test for the LookupSubmodel snippet
+ *
+ * @author conradi
+ *
+ */
+public class TestLookupSubmodel extends AbstractSnippetTest {
+
+ @Test
+ public void testLookupSubmodel() {
+
+ // Get the Identifiers of the AAS and Submodel
+ IIdentifier aasIdentifier = new Identifier(IdentifierType.CUSTOM, AAS_ID);
+ IIdentifier smIdentifier = new Identifier(IdentifierType.CUSTOM, SM_ID);
+
+ // Lookup the Submodel in the registry
+ SubmodelDescriptor descriptor = LookupSubmodel.lookupSubmodel(
+ smIdentifier, aasIdentifier, registryComponent.getRegistryPath());
+
+ // Check if the returned Descriptor is as expected
+ assertEquals(SM_ENDPOINT, descriptor.getFirstEndpoint());
+
+ }
+
+}
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/submodel/TestRegisterSubmodel.java b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/submodel/TestRegisterSubmodel.java
new file mode 100644
index 0000000..ea7c3bf
--- /dev/null
+++ b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/submodel/TestRegisterSubmodel.java
@@ -0,0 +1,45 @@
+package org.eclipse.basyx.examples.snippets.submodel;
+
+import static org.junit.Assert.assertEquals;
+
+import org.eclipse.basyx.aas.metamodel.map.AssetAdministrationShell;
+import org.eclipse.basyx.aas.metamodel.map.descriptor.SubmodelDescriptor;
+import org.eclipse.basyx.aas.registration.proxy.AASRegistryProxy;
+import org.eclipse.basyx.examples.snippets.AbstractSnippetTest;
+import org.eclipse.basyx.examples.snippets.aas.RegisterAAS;
+import org.eclipse.basyx.examples.support.ExampleComponentBuilder;
+import org.eclipse.basyx.submodel.metamodel.map.SubModel;
+import org.junit.Test;
+
+/**
+ * Test for the RegisterSubmodel snippet
+ *
+ * @author conradi
+ *
+ */
+public class TestRegisterSubmodel extends AbstractSnippetTest {
+
+ private static final String NEW_SM_ID_SHORT = "smIdShort_New";
+ private static final String NEW_SM_ID = "smId_New";
+ private static final String NEW_SM_ENDPOINT = "http://localhost:8080/aasComponent/" + NEW_SM_ID_SHORT + "/submodel";
+
+ @Test
+ public void testRegisterSubmodel() {
+
+ // Get the example AAS and Submodel
+ AssetAdministrationShell aas = ExampleComponentBuilder.buildExampleAAS(AAS_ID_SHORT, AAS_ID);
+ SubModel sm = ExampleComponentBuilder.buildExampleSubmodel(NEW_SM_ID_SHORT, NEW_SM_ID);
+
+ // Register this AAS
+ RegisterAAS.registerAAS(aas, AAS_ENDPOINT, registryComponent.getRegistryPath());
+
+ // Register this Submodel
+ RegisterSubmodel.registerSubmodel(sm, NEW_SM_ENDPOINT, aas.getIdentification(), registryComponent.getRegistryPath());
+
+ // Check if the Submodel was correctly registered
+ AASRegistryProxy registryProxy = new AASRegistryProxy(registryComponent.getRegistryPath());
+ SubmodelDescriptor descriptor = registryProxy.lookupSubmodel(aas.getIdentification(), sm.getIdentification());
+ assertEquals(NEW_SM_ENDPOINT, descriptor.getFirstEndpoint());
+
+ }
+}
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/submodel/TestRetrieveSubmodelElement.java b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/submodel/TestRetrieveSubmodelElement.java
new file mode 100644
index 0000000..7d8d03f
--- /dev/null
+++ b/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/submodel/TestRetrieveSubmodelElement.java
@@ -0,0 +1,41 @@
+package org.eclipse.basyx.examples.snippets.submodel;
+
+import static org.junit.Assert.assertEquals;
+
+import org.eclipse.basyx.examples.snippets.AbstractSnippetTest;
+import org.eclipse.basyx.examples.support.ExampleComponentBuilder;
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IIdentifier;
+import org.eclipse.basyx.submodel.metamodel.api.identifier.IdentifierType;
+import org.eclipse.basyx.submodel.metamodel.api.submodelelement.ISubmodelElement;
+import org.eclipse.basyx.submodel.metamodel.map.identifier.Identifier;
+import org.junit.Test;
+
+/**
+ * Test for the RetrieveSubmodelElement snippet
+ *
+ * @author conradi
+ *
+ */
+public class TestRetrieveSubmodelElement extends AbstractSnippetTest {
+
+
+ @Test
+ public void testRetrieveSubmodelElement() {
+
+ // Get the Identifiers of the AAS and Submodel
+ IIdentifier aasIdentifier = new Identifier(IdentifierType.CUSTOM, AAS_ID);
+ IIdentifier smIdentifier = new Identifier(IdentifierType.CUSTOM, SM_ID);
+
+ // Get the idShort and value of the element to be retrieved
+ String elementId = ExampleComponentBuilder.PROPERTY_ID;
+ int elementValue = ExampleComponentBuilder.PROPERTY_VALUE;
+
+ // Get the SubmodelElement
+ ISubmodelElement element = RetrieveSubmodelElement.retrieveSubmodelElement(
+ elementId, smIdentifier, aasIdentifier, registryComponent.getRegistryPath());
+
+ // Check if the SubmodelElement contains the expected value
+ assertEquals(elementValue, element.getValue());
+ }
+
+}
\ No newline at end of file
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/code/BaSyxCreateProvideUseExampleAASSubmodel.java b/sandbox/Java/basyx.sandbox/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/code/BaSyxCreateProvideUseExampleAASSubmodel.java
similarity index 100%
rename from examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/code/BaSyxCreateProvideUseExampleAASSubmodel.java
rename to sandbox/Java/basyx.sandbox/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/code/BaSyxCreateProvideUseExampleAASSubmodel.java
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/connection/servlet/AASServletConnection.java b/sandbox/Java/basyx.sandbox/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/connection/servlet/AASServletConnection.java
similarity index 100%
rename from examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/connection/servlet/AASServletConnection.java
rename to sandbox/Java/basyx.sandbox/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/connection/servlet/AASServletConnection.java
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/connection/servlet/AASServletConnectionFull.java b/sandbox/Java/basyx.sandbox/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/connection/servlet/AASServletConnectionFull.java
similarity index 100%
rename from examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/connection/servlet/AASServletConnectionFull.java
rename to sandbox/Java/basyx.sandbox/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/connection/servlet/AASServletConnectionFull.java
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/connection/servlet/AASSubModelServletConnectorConnection.java b/sandbox/Java/basyx.sandbox/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/connection/servlet/AASSubModelServletConnectorConnection.java
similarity index 100%
rename from examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/connection/servlet/AASSubModelServletConnectorConnection.java
rename to sandbox/Java/basyx.sandbox/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/connection/servlet/AASSubModelServletConnectorConnection.java
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/connection/servlet/AASSubModelServletVABConnection.java b/sandbox/Java/basyx.sandbox/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/connection/servlet/AASSubModelServletVABConnection.java
similarity index 100%
rename from examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/connection/servlet/AASSubModelServletVABConnection.java
rename to sandbox/Java/basyx.sandbox/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/connection/servlet/AASSubModelServletVABConnection.java
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/dynamic/RunAASDynamicOperationSnippet.java b/sandbox/Java/basyx.sandbox/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/dynamic/RunAASDynamicOperationSnippet.java
similarity index 100%
rename from examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/dynamic/RunAASDynamicOperationSnippet.java
rename to sandbox/Java/basyx.sandbox/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/dynamic/RunAASDynamicOperationSnippet.java
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/dynamic/RunAASManualHTTPOperationsSnippet.java b/sandbox/Java/basyx.sandbox/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/dynamic/RunAASManualHTTPOperationsSnippet.java
similarity index 100%
rename from examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/dynamic/RunAASManualHTTPOperationsSnippet.java
rename to sandbox/Java/basyx.sandbox/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/dynamic/RunAASManualHTTPOperationsSnippet.java
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/dynamic/RunAASPropertiesCRUDAccessSnippet.java b/sandbox/Java/basyx.sandbox/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/dynamic/RunAASPropertiesCRUDAccessSnippet.java
similarity index 100%
rename from examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/dynamic/RunAASPropertiesCRUDAccessSnippet.java
rename to sandbox/Java/basyx.sandbox/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/dynamic/RunAASPropertiesCRUDAccessSnippet.java
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/dynamic/RunAASTailoredSupplierSnippet.java b/sandbox/Java/basyx.sandbox/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/dynamic/RunAASTailoredSupplierSnippet.java
similarity index 100%
rename from examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/dynamic/RunAASTailoredSupplierSnippet.java
rename to sandbox/Java/basyx.sandbox/src/test/java/org/eclipse/basyx/examples/snippets/undoc/aas/dynamic/RunAASTailoredSupplierSnippet.java
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/undoc/vab/connection/RunAASManualHTTPOperationsSnippet.java b/sandbox/Java/basyx.sandbox/src/test/java/org/eclipse/basyx/examples/snippets/undoc/vab/connection/RunAASManualHTTPOperationsSnippet.java
similarity index 100%
rename from examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/undoc/vab/connection/RunAASManualHTTPOperationsSnippet.java
rename to sandbox/Java/basyx.sandbox/src/test/java/org/eclipse/basyx/examples/snippets/undoc/vab/connection/RunAASManualHTTPOperationsSnippet.java
diff --git a/examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/undoc/vab/connection/RunAASPropertiesSnippet.java b/sandbox/Java/basyx.sandbox/src/test/java/org/eclipse/basyx/examples/snippets/undoc/vab/connection/RunAASPropertiesSnippet.java
similarity index 100%
rename from examples/basys.examples/src/test/java/org/eclipse/basyx/examples/snippets/undoc/vab/connection/RunAASPropertiesSnippet.java
rename to sandbox/Java/basyx.sandbox/src/test/java/org/eclipse/basyx/examples/snippets/undoc/vab/connection/RunAASPropertiesSnippet.java
diff --git a/sdks/c++/basys.sdk.cc/include/BaSyx/submodel/simple/common/xsd_types/Time.h b/sdks/c++/basys.sdk.cc/include/BaSyx/submodel/simple/common/xsd_types/Time.h
index 89f5b05..7c4e9ed 100644
--- a/sdks/c++/basys.sdk.cc/include/BaSyx/submodel/simple/common/xsd_types/Time.h
+++ b/sdks/c++/basys.sdk.cc/include/BaSyx/submodel/simple/common/xsd_types/Time.h
@@ -3,7 +3,7 @@
#include "Timezone.h"
-#include <stdint-gcc.h>
+#include <cstdint>
#include <string>
namespace basyx {
@@ -38,4 +38,5 @@
}
}
}
+
#endif /* BASYX_SIMPLE_SDK_TIME_H */
diff --git a/sdks/java/basys.sdk/src/main/java/org/eclipse/basyx/aas/manager/ConnectedAssetAdministrationShellManager.java b/sdks/java/basys.sdk/src/main/java/org/eclipse/basyx/aas/manager/ConnectedAssetAdministrationShellManager.java
index 194c884..2d2c381 100644
--- a/sdks/java/basys.sdk/src/main/java/org/eclipse/basyx/aas/manager/ConnectedAssetAdministrationShellManager.java
+++ b/sdks/java/basys.sdk/src/main/java/org/eclipse/basyx/aas/manager/ConnectedAssetAdministrationShellManager.java
@@ -66,11 +66,8 @@
@Override
public ISubModel retrieveSubModel(IIdentifier aasId, IIdentifier smId) {
- // look up AAS descriptor in the registry
- AASDescriptor aasDescriptor = aasDirectory.lookupAAS(aasId);
-
- // Get submodel descriptor from the aas descriptor
- SubmodelDescriptor smDescriptor = aasDescriptor.getSubModelDescriptorFromIdentifierId(smId.getId());
+ // look up SM descriptor in the registry
+ SubmodelDescriptor smDescriptor = aasDirectory.lookupSubmodel(aasId, smId);
// get address of the submodel descriptor
String addr = smDescriptor.getFirstEndpoint();
diff --git a/sdks/java/basys.sdk/src/test/java/org/eclipse/basyx/testsuite/regression/aas/manager/TestConnectedAssetAdministrationShellManager.java b/sdks/java/basys.sdk/src/test/java/org/eclipse/basyx/testsuite/regression/aas/manager/TestConnectedAssetAdministrationShellManager.java
index d73fcca..5fc2233 100644
--- a/sdks/java/basys.sdk/src/test/java/org/eclipse/basyx/testsuite/regression/aas/manager/TestConnectedAssetAdministrationShellManager.java
+++ b/sdks/java/basys.sdk/src/test/java/org/eclipse/basyx/testsuite/regression/aas/manager/TestConnectedAssetAdministrationShellManager.java
@@ -174,6 +174,62 @@
}
/**
+ * Tries to retrieve a nonexistent AAS
+ */
+ @Test
+ public void testRetrieveNonexistentAAS() {
+ IModelProvider provider = new AASAggregatorProvider(new AASAggregator());
+ prepareConnectorProvider(provider);
+
+ IIdentifier nonexistentAASId = new Identifier(IdentifierType.CUSTOM, "nonexistentAAS");
+
+ // Try to retrieve a nonexistent AAS
+ try {
+ manager.retrieveAAS(nonexistentAASId);
+ fail();
+ } catch (ResourceNotFoundException e) {
+ }
+ }
+
+ /**
+ * Tries to retrieve a nonexistent Submodel from a nonexistent AAS
+ */
+ @Test
+ public void testRetrieveNonexistentSMFromNonexistentSM() {
+ IModelProvider provider = new AASAggregatorProvider(new AASAggregator());
+ prepareConnectorProvider(provider);
+
+ IIdentifier nonexistentAASId = new Identifier(IdentifierType.CUSTOM, "nonexistentAAS");
+ IIdentifier nonexistentSMId = new Identifier(IdentifierType.CUSTOM, "nonexistentSM");
+
+ // Try to retrieve a nonexistent Submodel from a nonexistent AAS
+ try {
+ manager.retrieveSubModel(nonexistentAASId, nonexistentSMId);
+ fail();
+ } catch (ResourceNotFoundException e) {
+ }
+ }
+
+ /**
+ * Tries to retrieve a nonexistent Submodel from an existing AAS
+ */
+ @Test
+ public void testRetrieveNonexistentSMFromExistentAAS() {
+ IModelProvider provider = new AASAggregatorProvider(new AASAggregator());
+ prepareConnectorProvider(provider);
+
+ IIdentifier aasId = new Identifier(IdentifierType.CUSTOM, "aasId");
+ IIdentifier nonexistentSMId = new Identifier(IdentifierType.CUSTOM, "nonexistentSM");
+
+ // Try to retrieve a nonexistent Submodel from an existing AAS
+ try {
+ manager.retrieveSubModel(aasId, nonexistentSMId);
+ fail();
+ } catch (ResourceNotFoundException e) {
+ }
+ }
+
+ /**
* @param provider
*/
private void prepareConnectorProvider(IModelProvider provider) {