Skip to content

Commit

Permalink
test: refactor DummyAasDescriptorFactory to include AdmInfo in the co…
Browse files Browse the repository at this point in the history
…nstructor
  • Loading branch information
mateusmolina-iese committed Dec 9, 2024
1 parent 1003de7 commit 9fd5129
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
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 Down Expand Up @@ -133,7 +133,7 @@ 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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,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 @@ -56,19 +56,27 @@ public static AssetAdministrationShellDescriptor createDummyDescriptor(String aa
descriptor.setAssetKind(AssetKind.INSTANCE);
descriptor.setGlobalAssetId(globalAssetId);
descriptor.setEndpoints(endpoints);
descriptor.setAdministration(buildAdministrationInformation());
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 @@ -85,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 @@ -105,12 +114,5 @@ private static String getProtocol(String endpoint) {
}
}

private static AdministrativeInformation buildAdministrationInformation() {
AdministrativeInformation administrativeInformation = new AdministrativeInformation();
administrativeInformation.setVersion("0");
administrativeInformation.setRevision("9");
administrativeInformation.setTemplateId("testTemplateId");
return administrativeInformation;
}

}
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

0 comments on commit 9fd5129

Please sign in to comment.