Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor the Registry Integration Tests to include Administrative Information #560

Merged
merged 5 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public AssetInformation buildAasPre1AssetInformation() {
}

public AssetAdministrationShellDescriptor buildAasPre1Descriptor() {
return DummyAasDescriptorFactory.createDummyDescriptor(AAS_PRE1_ID, AAS_PRE1_IDSHORT, AAS_PRE1_GLOBALASSETID, aasRepositoryBasePath);
return DummyAasDescriptorFactory.createDummyDescriptor(AAS_PRE1_ID, AAS_PRE1_IDSHORT, AAS_PRE1_GLOBALASSETID, null, aasRepositoryBasePath);
}

public AssetAdministrationShellDescriptor buildAasPre1Descriptor_withMultipleInterfaces() {
Expand All @@ -100,7 +100,7 @@ public AssetAdministrationShellDescriptor buildAasPre1Descriptor_withMultipleInt
endpoints.add(DummyAasDescriptorFactory.createEndpoint(aasRepositoryBasePath, "AAS-REPOSITORY-3.0"));
endpoints.add(DummyAasDescriptorFactory.createEndpoint(AAS_PRE1_ID, aasRepositoryBasePath, "AAS-3.0"));

return DummyAasDescriptorFactory.createDummyDescriptor(AAS_PRE1_ID, AAS_PRE1_IDSHORT, AAS_PRE1_GLOBALASSETID, endpoints);
return DummyAasDescriptorFactory.createDummyDescriptor(AAS_PRE1_ID, AAS_PRE1_IDSHORT, AAS_PRE1_GLOBALASSETID, null, endpoints);
}

public Reference buildSmPre1Ref() {
Expand All @@ -112,7 +112,7 @@ public Submodel buildSmPre1() {
}

public SubmodelDescriptor buildSmPre1Descriptor() {
return DummySubmodelDescriptorFactory.createDummyDescriptor(SM_PRE1_ID, SM_PRE1_IDSHORT, null, smRepositoryBasePath);
return DummySubmodelDescriptorFactory.createDummyDescriptor(SM_PRE1_ID, SM_PRE1_IDSHORT, null, null, smRepositoryBasePath);
}

public SubmodelDescriptor buildSmPre1Descriptor_withMultipleInterfaces() {
Expand All @@ -121,7 +121,7 @@ public SubmodelDescriptor buildSmPre1Descriptor_withMultipleInterfaces() {
endpoints.add(DummySubmodelDescriptorFactory.createEndpoint(smRepositoryBasePath, "SUBMODEL-REPOSITORY-3.0"));
endpoints.add(DummySubmodelDescriptorFactory.createEndpoint(SM_PRE1_ID, smRepositoryBasePath, "SUBMODEL-3.0"));

return DummySubmodelDescriptorFactory.createDummyDescriptor(SM_PRE1_ID, SM_PRE1_IDSHORT, null, endpoints);
return DummySubmodelDescriptorFactory.createDummyDescriptor(SM_PRE1_ID, SM_PRE1_IDSHORT, null, null, endpoints);
}

public AssetAdministrationShell buildAasPos1() {
Expand All @@ -133,11 +133,11 @@ public AssetInformation buildAasPos1AssetInformation() {
}

public AssetAdministrationShellDescriptor buildAasPos1Descriptor() {
return DummyAasDescriptorFactory.createDummyDescriptor(AAS_POS1_ID, AAS_POS1_IDSHORT, AAS_POS1_GLOBALASSETID, aasRepositoryBasePath);
return DummyAasDescriptorFactory.createDummyDescriptor(AAS_POS1_ID, AAS_POS1_IDSHORT, AAS_POS1_GLOBALASSETID, null, aasRepositoryBasePath);
}

public SubmodelDescriptor buildSmPos1Descriptor() {
return DummySubmodelDescriptorFactory.createDummyDescriptor(SM_POS1_ID, SM_POS1_IDSHORT, new AttributeMapper(ConnectedAasManagerHelper.buildObjectMapper()).mapSemanticId(buildSmPos1SemanticId()), smRepositoryBasePath);
return DummySubmodelDescriptorFactory.createDummyDescriptor(SM_POS1_ID, SM_POS1_IDSHORT, new AttributeMapper(ConnectedAasManagerHelper.buildObjectMapper()).mapSemanticId(buildSmPos1SemanticId()), null, smRepositoryBasePath);
}

public Reference buildSmPos1SemanticId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.LinkedList;
import java.util.List;

import org.eclipse.digitaltwin.basyx.aasregistry.client.model.AdministrativeInformation;
import org.eclipse.digitaltwin.basyx.aasregistry.client.model.AssetAdministrationShellDescriptor;
import org.eclipse.digitaltwin.basyx.aasregistry.client.model.AssetKind;
import org.eclipse.digitaltwin.basyx.aasregistry.client.model.Endpoint;
Expand All @@ -46,7 +47,7 @@
public class DummyAasDescriptorFactory {
private static final String AAS_REPOSITORY_PATH = "/shells";

public static AssetAdministrationShellDescriptor createDummyDescriptor(String aasId, String idShort, String globalAssetId, List<Endpoint> endpoints) {
public static AssetAdministrationShellDescriptor createDummyDescriptor(String aasId, String idShort, String globalAssetId, AdministrativeInformation administrativeInformation, List<Endpoint> endpoints) {

AssetAdministrationShellDescriptor descriptor = new AssetAdministrationShellDescriptor();

Expand All @@ -55,18 +56,27 @@ public static AssetAdministrationShellDescriptor createDummyDescriptor(String aa
descriptor.setAssetKind(AssetKind.INSTANCE);
descriptor.setGlobalAssetId(globalAssetId);
descriptor.setEndpoints(endpoints);
descriptor.setAdministration(administrativeInformation);

return descriptor;
}

public static AssetAdministrationShellDescriptor createDummyDescriptor(String aasId, String idShort, String globalAssetId, String... aasRepoBaseUrls) {
public static AssetAdministrationShellDescriptor createDummyDescriptor(String aasId, String idShort, String globalAssetId, AdministrativeInformation administrativeInformation, String... aasRepoBaseUrls) {
LinkedList<Endpoint> endpoints = new LinkedList<>();

for (String eachUrl : aasRepoBaseUrls) {
endpoints.add(createEndpoint(aasId, eachUrl, "AAS-3.0"));
}

return createDummyDescriptor(aasId, idShort, globalAssetId, endpoints);
return createDummyDescriptor(aasId, idShort, globalAssetId, administrativeInformation, endpoints);
}

public static AdministrativeInformation buildAdministrationInformation(String version, String revision, String templateId) {
AdministrativeInformation administrativeInformation = new AdministrativeInformation();
administrativeInformation.setVersion(version);
administrativeInformation.setRevision(revision);
administrativeInformation.setTemplateId(templateId);
return administrativeInformation;
}

public static Endpoint createEndpoint(String endpointUrl, String endpointInterface) {
Expand All @@ -83,6 +93,7 @@ public static Endpoint createEndpoint(String aasId, String aasRepoBaseUrl, Strin
return createEndpoint(href, endpointInterface);
}


private static ProtocolInformation createProtocolInformation(String href) {
ProtocolInformation protocolInformation = new ProtocolInformation();
protocolInformation.setHref(href);
Expand All @@ -102,4 +113,6 @@ private static String getProtocol(String endpoint) {
throw new RuntimeException();
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public abstract class AasRepositoryRegistryLinkTestSuite {
protected abstract RegistryAndDiscoveryInterfaceApi getAasRegistryApi();

private final AssetAdministrationShellDescriptor DUMMY_DESCRIPTOR = DummyAasDescriptorFactory
.createDummyDescriptor(DUMMY_AAS_ID, DUMMY_IDSHORT, DUMMY_GLOBAL_ASSETID, getAasRepoBaseUrls());
.createDummyDescriptor(DUMMY_AAS_ID, DUMMY_IDSHORT, DUMMY_GLOBAL_ASSETID, DummyAasDescriptorFactory.buildAdministrationInformation("0", "9", "testTemplateId"), getAasRepoBaseUrls());

@Test
public void createAas() throws FileNotFoundException, IOException, ApiException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@
"assetInformation": {
"assetKind": "Instance",
"globalAssetId": "globalAssetId"
},
"administration": {
"version": "0",
"revision": "9",
"templateId": "testTemplateId"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

import org.eclipse.digitaltwin.basyx.core.RepositoryUrlHelper;
import org.eclipse.digitaltwin.basyx.http.Base64UrlEncodedIdentifier;
import org.eclipse.digitaltwin.basyx.submodelregistry.client.model.AdministrativeInformation;
import org.eclipse.digitaltwin.basyx.submodelregistry.client.model.Endpoint;
import org.eclipse.digitaltwin.basyx.submodelregistry.client.model.Key;
import org.eclipse.digitaltwin.basyx.submodelregistry.client.model.KeyTypes;
Expand All @@ -50,24 +51,25 @@
public class DummySubmodelDescriptorFactory {
private static final String SUBMODEL_REPOSITORY_PATH = "/submodels";

public static SubmodelDescriptor createDummyDescriptor(String smId, String idShort, Reference semanticId, List<Endpoint> endpoints) {
public static SubmodelDescriptor createDummyDescriptor(String smId, String idShort, Reference semanticId, AdministrativeInformation administrativeInformation, List<Endpoint> endpoints) {
SubmodelDescriptor descriptor = new SubmodelDescriptor();

descriptor.setId(smId);
descriptor.setIdShort(idShort);
descriptor.setSemanticId(semanticId);
descriptor.setEndpoints(endpoints);
descriptor.administration(administrativeInformation);

return descriptor;
}

public static SubmodelDescriptor createDummyDescriptor(String smId, String idShort, Reference semanticId, String... smRepoBaseUrls) {
public static SubmodelDescriptor createDummyDescriptor(String smId, String idShort, Reference semanticId, AdministrativeInformation administrativeInformation, String... smRepoBaseUrls) {
LinkedList<Endpoint> endpoints = new LinkedList<>();
for (String eachUrl : smRepoBaseUrls) {
endpoints.add(createEndpoint(smId, eachUrl, "SUBMODEL-3.0"));
}

return createDummyDescriptor(smId, idShort, semanticId, endpoints);
return createDummyDescriptor(smId, idShort, semanticId, administrativeInformation, endpoints);
}

public static Reference createSemanticId() {
Expand All @@ -88,6 +90,10 @@ public static Endpoint createEndpoint(String smId, String smRepoBaseUrl, String
return createEndpoint(href, endpointInterface);
}

public static AdministrativeInformation buildAdministrationInformation(String version, String revision, String templateId) {
return new AdministrativeInformation().version(version).revision(revision).templateId(templateId);
}

private static ProtocolInformation createProtocolInformation(String href) {
ProtocolInformation protocolInformation = new ProtocolInformation();
protocolInformation.setHref(href);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public abstract class SubmodelRepositoryRegistryLinkTestSuite {
protected abstract String getSubmodelRegistryUrl();
protected abstract SubmodelRegistryApi getSubmodelRegistryApi();

private final SubmodelDescriptor DUMMY_DESCRIPTOR = DummySubmodelDescriptorFactory.createDummyDescriptor(DUMMY_SUBMODEL_ID, DUMMY_SUBMODEL_IDSHORT, DummySubmodelDescriptorFactory.createSemanticId(), getSubmodelRepoBaseUrls());
private final SubmodelDescriptor DUMMY_DESCRIPTOR = DummySubmodelDescriptorFactory.createDummyDescriptor(DUMMY_SUBMODEL_ID, DUMMY_SUBMODEL_IDSHORT, DummySubmodelDescriptorFactory.createSemanticId(),
DummySubmodelDescriptorFactory.buildAdministrationInformation("0", "9", "testTemplateId"), getSubmodelRepoBaseUrls());

@Test
public void createSubmodel() throws FileNotFoundException, IOException, ApiException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
},
"id": "7A7104BDAB57E184",
"idShort": "TechnicalData",
"administration": {
"version": "0",
"revision": "9",
"templateId": "testTemplateId"
},
"submodelElements": [
{
"modelType": "Property",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
"id": "7A7104BDAB57E184",
"idShort": "TechnicalData",
"kind": "Instance",
"administration": {
"version": "0",
"revision": "9",
"templateId": "testTemplateId"
},
"submodelElements": [
{
"modelType": "Property",
Expand Down
Loading