Skip to content

Commit

Permalink
openhab#16308 openhab#16310 Removed unrequired dependencies and skip …
Browse files Browse the repository at this point in the history
…some tests if docker is missing.

Signed-off-by: René Ulbricht <rene_ulbricht@outlook.com>
  • Loading branch information
ulbi committed Jan 28, 2024
1 parent 63104d3 commit e243747
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 27 deletions.
18 changes: 0 additions & 18 deletions bundles/org.openhab.persistence.mongodb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@
<version>1.5.5-3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.lastnpe.eea</groupId>
<artifactId>eea-all</artifactId>
<version>2.2.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>bson-record-codec</artifactId>
Expand All @@ -69,18 +63,6 @@
<version>1.44.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mongodb</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.openhab.core.types.State;
import org.osgi.framework.BundleContext;
import org.slf4j.LoggerFactory;
import org.testcontainers.DockerClientFactory;

import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;
Expand Down Expand Up @@ -133,19 +134,25 @@ public static Stream<Arguments> provideOpenhabItemTypes() {
*
* Each argument is a DatabaseTestContainer instance. Some instances use a MemoryBackend,
* while others use a MongoDBContainer with a specific MongoDB version.
* In case there is no Docker available, only the MemoryBackend is used.
*
* @return A stream of Arguments, each containing a DatabaseTestContainer instance.
*/
public static Stream<Arguments> provideDatabaseBackends() {
// Create a stream of Arguments
return Stream.of(
// Create a DatabaseTestContainer with a MemoryBackend
Arguments.of(new DatabaseTestContainer(new MemoryBackend())),
// Create DatabaseTestContainers with MongoDBContainers of specific versions
Arguments.of(new DatabaseTestContainer("mongo:3.6")),
Arguments.of(new DatabaseTestContainer("mongo:4.4")),
Arguments.of(new DatabaseTestContainer("mongo:5.0")),
Arguments.of(new DatabaseTestContainer("mongo:6.0")));
if (DockerClientFactory.instance().isDockerAvailable()) {
// If Docker is available, create a stream of Arguments with all backends
return Stream.of(
// Create a DatabaseTestContainer with a MemoryBackend
Arguments.of(new DatabaseTestContainer(new MemoryBackend())),
// Create DatabaseTestContainers with MongoDBContainers of specific versions
Arguments.of(new DatabaseTestContainer("mongo:3.6")),
Arguments.of(new DatabaseTestContainer("mongo:4.4")),
Arguments.of(new DatabaseTestContainer("mongo:5.0")),
Arguments.of(new DatabaseTestContainer("mongo:6.0")));
} else {
// If Docker is not available, create a stream of Arguments with only the MemoryBackend
return Stream.of(Arguments.of(new DatabaseTestContainer(new MemoryBackend())));
}
}

/**
Expand Down

0 comments on commit e243747

Please sign in to comment.