Skip to content

Commit

Permalink
Merge branch 'eclipse-basyx:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
geso02 authored Sep 11, 2024
2 parents 73323c9 + 51e84c6 commit d3d1e04
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.eclipse.digitaltwin.basyx.aasenvironment.component;

import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.core.MongoTemplate;

@Configuration
public class MongoDbCollectionsTestConfig {
protected static final String CONNECTION_URL = "mongodb://mongoAdmin:mongoPassword@localhost:27017/";
protected static final String DB_NAME = "aas-env";
protected static final String AAS_REPO_COLLECTION = "aas-repo";
protected static final String SM_REPO_COLLECTION = "submodel-repo";
protected static final String CD_REPO_COLLECTION = "cd-repo";

@Bean
public static MongoTemplate buildMongoTemplate() {
MongoClient client = MongoClients.create(CONNECTION_URL);
return new MongoTemplate(client, DB_NAME);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,8 @@ public class TestMongoDbCollections {
private static ConfigurableApplicationContext appContext;

// MongoDB configuration
private static final String CONNECTION_URL = "mongodb://mongoAdmin:mongoPassword@localhost:27017/";
private static final String DB_NAME = "aas-env";
private static final String AAS_REPO_COLLECTION = "aas-repo";
private static final String SM_REPO_COLLECTION = "submodel-repo";
private static final String CD_REPO_COLLECTION = "cd-repo";

private static final MongoTemplate mongoTemplate = buildMongoTemplate(CONNECTION_URL, DB_NAME);
private static final MongoTemplate mongoTemplate = MongoDbCollectionsTestConfig.buildMongoTemplate();

@BeforeClass
public static void startAASEnvironment() throws Exception {
Expand All @@ -64,32 +59,28 @@ public static void startAASEnvironment() throws Exception {
@AfterClass
public static void deleteDatabase() {
appContext.close();
MongoDBUtilities.clearCollection(mongoTemplate, AAS_REPO_COLLECTION);
MongoDBUtilities.clearCollection(mongoTemplate, SM_REPO_COLLECTION);
MongoDBUtilities.clearCollection(mongoTemplate, CD_REPO_COLLECTION);
MongoDBUtilities.clearCollection(mongoTemplate, MongoDbCollectionsTestConfig.AAS_REPO_COLLECTION);
MongoDBUtilities.clearCollection(mongoTemplate, MongoDbCollectionsTestConfig.SM_REPO_COLLECTION);
MongoDBUtilities.clearCollection(mongoTemplate, MongoDbCollectionsTestConfig.CD_REPO_COLLECTION);
}

@Test
public void aasRepoCollectionIsCorrectlyDefined() {
assertMongoDBCollectionExists(AAS_REPO_COLLECTION);
assertMongoDBCollectionExists(MongoDbCollectionsTestConfig.AAS_REPO_COLLECTION);
}

@Test
public void smRepoCollectionIsCorrectlyDefined() {
assertMongoDBCollectionExists(SM_REPO_COLLECTION);
assertMongoDBCollectionExists(MongoDbCollectionsTestConfig.SM_REPO_COLLECTION);
}

@Test
public void cdRepoCollectionIsCorrectlyDefined() {
assertMongoDBCollectionExists(CD_REPO_COLLECTION);
assertMongoDBCollectionExists(MongoDbCollectionsTestConfig.CD_REPO_COLLECTION);
}

private void assertMongoDBCollectionExists(String collectionName) {
assertTrue(mongoTemplate.collectionExists(collectionName));
}

private static MongoTemplate buildMongoTemplate(String connectionUrl, String dbName) {
MongoClient client = MongoClients.create(connectionUrl);
return new MongoTemplate(client, dbName);
}
}
4 changes: 2 additions & 2 deletions basyx.aasregistry/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
<guava.version>33.2.1-jre</guava.version>
<maven-plugin.version>3.9.0</maven-plugin.version>
<maven-project.version>3.0-alpha-2</maven-project.version>
<mustache.compiler.version>0.9.4</mustache.compiler.version>
<mustache.compiler.version>0.9.14</mustache.compiler.version>
<docker.image.name>${project.artifactId}</docker.image.name>
<openapitools.version>6.6.0</openapitools.version>
<openapitools.jacksonnullable.version>0.2.6</openapitools.jacksonnullable.version>
<jsr305.version>3.0.2</jsr305.version>
<jsonpatch.plugin.version>0.5.0</jsonpatch.plugin.version>
<jsonpatch.plugin.version>0.5.1</jsonpatch.plugin.version>
<patch.base-extensions.name>patch-base-extensions.yaml</patch.base-extensions.name>
</properties>

Expand Down
4 changes: 2 additions & 2 deletions basyx.submodelregistry/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
<guava.version>33.2.1-jre</guava.version>
<maven-plugin.version>3.6.0</maven-plugin.version>
<maven-project.version>3.0-alpha-2</maven-project.version>
<mustache.compiler.version>0.9.4</mustache.compiler.version>
<mustache.compiler.version>0.9.14</mustache.compiler.version>
<docker.image.name>${project.artifactId}</docker.image.name>
<openapitools.version>6.6.0</openapitools.version>
<openapitools.jacksonnullable.version>0.2.6</openapitools.jacksonnullable.version>
<jsr305.version>3.0.2</jsr305.version>
<jsonpatch.plugin.version>0.5.0</jsonpatch.plugin.version>
<jsonpatch.plugin.version>0.5.1</jsonpatch.plugin.version>
<patch.base-extensions.name>patch-base-extensions.yaml</patch.base-extensions.name>
</properties>

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>2.2</version>
<version>2.3</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
Expand Down

0 comments on commit d3d1e04

Please sign in to comment.