From 4e6e6347c3d4f670b09888a7368a9fca9f60a909 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zai=20M=C3=BCller-Zhang?= <97607180+zhangzai123@users.noreply.github.com> Date: Fri, 8 Sep 2023 15:58:20 +0200 Subject: [PATCH] Refactor Before in TestMongoDBAggregator.java to clean up MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Zai Müller-Zhang <97607180+zhangzai123@users.noreply.github.com> --- .../aas/mongodb/MongoDBAASAPIFactory.java | 3 +-- .../aas/mongodb/MongoDBAASAggregator.java | 2 +- .../AASServer/mongodb/TestMongoDBAggregator.java | 13 +++++-------- .../src/main/resources/registry.properties | 2 +- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/basyx.components/basyx.components.docker/basyx.components.AASServer/src/main/java/org/eclipse/basyx/components/aas/mongodb/MongoDBAASAPIFactory.java b/basyx.components/basyx.components.docker/basyx.components.AASServer/src/main/java/org/eclipse/basyx/components/aas/mongodb/MongoDBAASAPIFactory.java index 609b739b..8f0f70ca 100644 --- a/basyx.components/basyx.components.docker/basyx.components.AASServer/src/main/java/org/eclipse/basyx/components/aas/mongodb/MongoDBAASAPIFactory.java +++ b/basyx.components/basyx.components.docker/basyx.components.AASServer/src/main/java/org/eclipse/basyx/components/aas/mongodb/MongoDBAASAPIFactory.java @@ -67,8 +67,7 @@ public IAASAPI getAASApi(AssetAdministrationShell shell) { @Override public IAASAPI create(IIdentifier aasId) { - MongoDBAASAPI api = new MongoDBAASAPI(storageAPI, aasId.getId()); - return api; + return new MongoDBAASAPI(storageAPI, aasId.getId()); } } diff --git a/basyx.components/basyx.components.docker/basyx.components.AASServer/src/main/java/org/eclipse/basyx/components/aas/mongodb/MongoDBAASAggregator.java b/basyx.components/basyx.components.docker/basyx.components.AASServer/src/main/java/org/eclipse/basyx/components/aas/mongodb/MongoDBAASAggregator.java index 5f3fd452..623e76f4 100644 --- a/basyx.components/basyx.components.docker/basyx.components.AASServer/src/main/java/org/eclipse/basyx/components/aas/mongodb/MongoDBAASAggregator.java +++ b/basyx.components/basyx.components.docker/basyx.components.AASServer/src/main/java/org/eclipse/basyx/components/aas/mongodb/MongoDBAASAggregator.java @@ -437,7 +437,7 @@ private void addSubmodelsFromDB(MultiSubmodelProvider provider, AssetAdministrat List submodelIdShorts = getSubmodelIdShortsFromSubmodelReferences(submodelRefs); submodelIdentificationIds = completeSubmodelIdentificationsIdsByIdShorts(submodelIdentificationIds, submodelIdShorts); - createProviderForSubmodels(provider, submodelIdentificationIds); + createProviderForSubmodels(provider, submodelIdentificationIds); } diff --git a/basyx.components/basyx.components.docker/basyx.components.AASServer/src/test/java/org/eclipse/basyx/regression/AASServer/mongodb/TestMongoDBAggregator.java b/basyx.components/basyx.components.docker/basyx.components.AASServer/src/test/java/org/eclipse/basyx/regression/AASServer/mongodb/TestMongoDBAggregator.java index ad6e9ccc..380a0db0 100644 --- a/basyx.components/basyx.components.docker/basyx.components.AASServer/src/test/java/org/eclipse/basyx/regression/AASServer/mongodb/TestMongoDBAggregator.java +++ b/basyx.components/basyx.components.docker/basyx.components.AASServer/src/test/java/org/eclipse/basyx/regression/AASServer/mongodb/TestMongoDBAggregator.java @@ -109,7 +109,11 @@ public static void setUpClass() throws ParserConfigurationException, SAXExceptio component.setRegistry(registry); component.startComponent(); + } + @Override + public void setup() { + super.setup(); createAssetAdministrationShell(AAS_ID); createSubmodel(SM_IDSHORT, SM_IDENTIFICATION, AAS_ID); } @@ -203,8 +207,6 @@ protected IAASAggregator getAggregator() { @SuppressWarnings("deprecation") @Test public void checkInitialSetupAfterCreatingAndRegisteringAasAndSubmodel() { - createAssetAdministrationShell(AAS_ID); - createSubmodel(SM_IDSHORT, SM_IDENTIFICATION, AAS_ID); MongoDBAASAggregator aggregator = new MongoDBAASAggregator(mongoDBConfig, registry); ISubmodel persistentSubmodel = getSubmodelFromAggregator(aggregator, AAS_ID, SM_IDSHORT); @@ -247,9 +249,6 @@ private void assertSubmodelsAreResolvedCorrectly(ISubmodel persistentSubmodel, I } private void createAASWithSubmodelWithCollidingIdShort() { - createAssetAdministrationShell(AAS_ID); - createSubmodel(SM_IDSHORT, SM_IDENTIFICATION, AAS_ID); - createAssetAdministrationShell(AAS_ID_2); createSubmodel(SM_IDSHORT, SM_IDENTIFICATION_2, AAS_ID_2); } @@ -272,9 +271,7 @@ public void checkNoExceptionIsObservedAfterPassingRegistry() { restartAasServer(); MongoDBAASAggregator aggregator = new MongoDBAASAggregator(mongoDBConfig, registry); - // Create two AASs - createAssetAdministrationShell(AAS_ID); - createSubmodel(SM_IDSHORT, SM_IDENTIFICATION, AAS_ID); + MultiSubmodelProvider aasProvider = (MultiSubmodelProvider) getAssetAdministrationShellProviderFromMongoDBAggregator(aggregator, AAS_ID, SM_IDSHORT); Map submodelObject = (Map) aasProvider.getValue(PREFIX_SUBMODEL_PATH + SM_IDSHORT + SUFFIX_SUBMODEL_PATH); diff --git a/basyx.components/basyx.components.docker/basyx.components.registry/src/main/resources/registry.properties b/basyx.components/basyx.components.docker/basyx.components.registry/src/main/resources/registry.properties index 4cb23871..16fa2124 100644 --- a/basyx.components/basyx.components.docker/basyx.components.registry/src/main/resources/registry.properties +++ b/basyx.components/basyx.components.docker/basyx.components.registry/src/main/resources/registry.properties @@ -44,5 +44,5 @@ registry.authorization=Disabled # ########################### # TaggedDirectory # ########################### -#registry.taggedDirectory=Enabled +# registry.taggedDirectory=Enabled registry.taggedDirectory=Disabled