Skip to content

Commit

Permalink
Refactor Before in TestMongoDBAggregator.java to clean up
Browse files Browse the repository at this point in the history
Signed-off-by: Zai Müller-Zhang <[email protected]>
  • Loading branch information
zhangzai123 committed Sep 8, 2023
1 parent b881e15 commit 4e6e634
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ private void addSubmodelsFromDB(MultiSubmodelProvider provider, AssetAdministrat
List<String> submodelIdShorts = getSubmodelIdShortsFromSubmodelReferences(submodelRefs);
submodelIdentificationIds = completeSubmodelIdentificationsIdsByIdShorts(submodelIdentificationIds, submodelIdShorts);

createProviderForSubmodels(provider, submodelIdentificationIds);
createProviderForSubmodels(provider, submodelIdentificationIds);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand All @@ -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<String, Object> submodelObject = (Map<String, Object>) aasProvider.getValue(PREFIX_SUBMODEL_PATH + SM_IDSHORT + SUFFIX_SUBMODEL_PATH);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ registry.authorization=Disabled
# ###########################
# TaggedDirectory
# ###########################
#registry.taggedDirectory=Enabled
# registry.taggedDirectory=Enabled
registry.taggedDirectory=Disabled

0 comments on commit 4e6e634

Please sign in to comment.