From c8bc6ece1b249d1aeef8fed01e4f0efc7545bd65 Mon Sep 17 00:00:00 2001 From: Dmitriy Barbul Date: Sat, 4 Nov 2023 19:37:53 +0200 Subject: [PATCH] Small fixes --- .../mqtt/hivemq/MqttClientActorIT.java | 265 ++++-------------- .../utils/test/docker/ContainerFactory.java | 2 +- .../docker/mongo/MongoContainerFactory.java | 3 +- .../mosquitto/MosquittoContainerFactory.java | 8 +- 4 files changed, 65 insertions(+), 213 deletions(-) diff --git a/connectivity/service/src/test/java/org/eclipse/ditto/connectivity/service/messaging/mqtt/hivemq/MqttClientActorIT.java b/connectivity/service/src/test/java/org/eclipse/ditto/connectivity/service/messaging/mqtt/hivemq/MqttClientActorIT.java index b56cac9656..78d6b88cc7 100644 --- a/connectivity/service/src/test/java/org/eclipse/ditto/connectivity/service/messaging/mqtt/hivemq/MqttClientActorIT.java +++ b/connectivity/service/src/test/java/org/eclipse/ditto/connectivity/service/messaging/mqtt/hivemq/MqttClientActorIT.java @@ -17,7 +17,11 @@ import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import java.time.Duration; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Map; +import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.function.Consumer; import java.util.stream.Stream; @@ -35,7 +39,11 @@ import org.eclipse.ditto.base.model.auth.DittoAuthorizationContextType; import org.eclipse.ditto.base.model.headers.DittoHeaders; import org.eclipse.ditto.connectivity.api.BaseClientState; -import org.eclipse.ditto.connectivity.model.*; +import org.eclipse.ditto.connectivity.model.Connection; +import org.eclipse.ditto.connectivity.model.ConnectionId; +import org.eclipse.ditto.connectivity.model.ConnectionType; +import org.eclipse.ditto.connectivity.model.ConnectivityModelFactory; +import org.eclipse.ditto.connectivity.model.ConnectivityStatus; import org.eclipse.ditto.connectivity.model.mqtt.IllegalSessionExpiryIntervalSecondsException; import org.eclipse.ditto.connectivity.model.mqtt.ReceiveMaximum; import org.eclipse.ditto.connectivity.model.mqtt.SessionExpiryInterval; @@ -51,7 +59,12 @@ import org.eclipse.ditto.json.JsonFactory; import org.eclipse.ditto.things.model.ThingId; import org.eclipse.ditto.things.model.signals.commands.modify.MergeThing; -import org.junit.*; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Rule; +import org.junit.Test; import org.junit.rules.TestName; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -105,15 +118,13 @@ public static Collection parameters() { private static final ConnectionId CONNECTION_ID = ConnectionId.of("connection"); private static final String CLIENT_ID_DITTO = "ditto"; - private static final String TOPIC_NAME = "data"; - private static final String ANOTHER_TOPIC_NAME = "data2"; + private static final String TOPIC_NAME = "topic"; + private static final String ANOTHER_TOPIC_NAME = "topic2"; private static final AuthorizationContext AUTHORIZATION_CONTEXT = AuthorizationModelFactory.newAuthContext(DittoAuthorizationContextType.PRE_AUTHENTICATED_CONNECTION, AuthorizationModelFactory.newAuthSubject("nginx:ditto")); private static final FiniteDuration CONNECTION_TIMEOUT = FiniteDuration.apply(30, TimeUnit.SECONDS); private static final FiniteDuration COMMAND_TIMEOUT = FiniteDuration.apply(5, TimeUnit.SECONDS); private static final FiniteDuration NO_MESSAGE_TIMEOUT = FiniteDuration.apply(3, TimeUnit.SECONDS); - // https://github.com/eclipse-ditto/ditto/issues/1767 - private static final int TIMEOUT_BEFORE_PUBLISH = 3; private static final int MESSAGES_FROM_PREVIOUS_SESSION_TIMEOUT = 3; private static final SessionExpiryInterval SESSION_EXPIRY_INTERVAL; @@ -138,7 +149,6 @@ public static Collection parameters() { @BeforeClass public static void beforeClass() { actorsTestConfig = ConfigFactory.load("test.conf"); -// mongoClient = provideClientWrapper(); } @Before @@ -146,19 +156,15 @@ public void before() { actorSystem = ActorSystem.create(getClass().getSimpleName(), actorsTestConfig); commandForwarderProbe = TestProbe.apply("commandForwarder", actorSystem); cleanPreviousSession(); -// thingsCollection = mongoClient.getDefaultDatabase().getCollection("PersistenceConstants.THINGS_COLLECTION_NAME"); } private void cleanPreviousSession() { - final var mqttClient = getMqttClient(CLIENT_ID_DITTO); + final var mqttClient = getMqttClient(getDittoClientId()); mqttClient.cleanSession(); } @After public void after() { -// if (mongoClient != null) { -// thingsCollection.drop(); -// } if (actorSystem != null) { TestKit.shutdownActorSystem(actorSystem); actorSystem = null; @@ -169,21 +175,18 @@ public void after() { public void testSingleTopic() { new TestKit(actorSystem) {{ final var underTest = getMqttClientActor(getConnection(new String[] { TOPIC_NAME })); - underTest.tell(OpenConnection.of(CONNECTION_ID, DittoHeaders.empty()), getRef()); - expectMsg(CONNECTION_TIMEOUT, new Status.Success(BaseClientState.CONNECTED)); - - sleep(TIMEOUT_BEFORE_PUBLISH); + connect(underTest, this); final var mqttClient = getMqttClient(name.getMethodName()); mqttClient.connect(); publishMergeThingMessage(mqttClient, TOPIC_NAME, "key", "test"); + publishMergeThingMessage(mqttClient, ANOTHER_TOPIC_NAME, "key2", "test2"); mqttClient.disconnect(); expectMergeThingMessage(commandForwarderProbe, "key", "test"); commandForwarderProbe.expectNoMessage(NO_MESSAGE_TIMEOUT); - underTest.tell(CloseConnection.of(CONNECTION_ID, DittoHeaders.empty()), getRef()); - expectMsg(CONNECTION_TIMEOUT, new Status.Success(BaseClientState.DISCONNECTED)); + disconnect(underTest, this); ensureAllMessagesAcknowledged(); }}; @@ -193,10 +196,7 @@ public void testSingleTopic() { public void testMultipleTopics() { new TestKit(actorSystem) {{ final var underTest = getMqttClientActor(getConnection(new String[] { TOPIC_NAME, ANOTHER_TOPIC_NAME })); - underTest.tell(OpenConnection.of(CONNECTION_ID, DittoHeaders.empty()), getRef()); - expectMsg(CONNECTION_TIMEOUT, new Status.Success(BaseClientState.CONNECTED)); - - sleep(TIMEOUT_BEFORE_PUBLISH); + connect(underTest, this); final var mqttClient = getMqttClient(name.getMethodName()); mqttClient.connect(); @@ -208,8 +208,7 @@ public void testMultipleTopics() { expectMergeThingMessage(commandForwarderProbe, "key2", "test2"); expectNoMessage(NO_MESSAGE_TIMEOUT); - underTest.tell(CloseConnection.of(CONNECTION_ID, DittoHeaders.empty()), getRef()); - expectMsg(CONNECTION_TIMEOUT, new Status.Success(BaseClientState.DISCONNECTED)); + disconnect(underTest, this); ensureAllMessagesAcknowledged(); }}; @@ -219,10 +218,7 @@ public void testMultipleTopics() { public void testMultipleSources() { new TestKit(actorSystem) {{ final var underTest = getMqttClientActor(getConnection(new String[] { TOPIC_NAME }, new String[] { ANOTHER_TOPIC_NAME })); - underTest.tell(OpenConnection.of(CONNECTION_ID, DittoHeaders.empty()), getRef()); - expectMsg(CONNECTION_TIMEOUT, new Status.Success(BaseClientState.CONNECTED)); - - sleep(TIMEOUT_BEFORE_PUBLISH); + connect(underTest, this); final var mqttClient = getMqttClient(name.getMethodName()); mqttClient.connect(); @@ -235,40 +231,29 @@ public void testMultipleSources() { "key2", "test2")); commandForwarderProbe.expectNoMessage(NO_MESSAGE_TIMEOUT); - underTest.tell(CloseConnection.of(CONNECTION_ID, DittoHeaders.empty()), getRef()); - expectMsg(CONNECTION_TIMEOUT, new Status.Success(BaseClientState.DISCONNECTED)); + disconnect(underTest, this); // https://github.com/eclipse-ditto/ditto/issues/1768 // ensureAllMessagesAcknowledged(); }};} @Test - @Ignore("https://github.com/eclipse-ditto/ditto/issues/1767") public void testPersistentSession() { new TestKit(actorSystem) {{ final var underTest = getMqttClientActor(getConnection(new String[] { TOPIC_NAME })); // create session - System.out.println("Connecting to create session..."); - underTest.tell(OpenConnection.of(CONNECTION_ID, DittoHeaders.empty()), getRef()); - expectMsg(CONNECTION_TIMEOUT, new Status.Success(BaseClientState.CONNECTED)); - System.out.println("Connected"); - underTest.tell(CloseConnection.of(CONNECTION_ID, DittoHeaders.empty()), getRef()); - expectMsg(CONNECTION_TIMEOUT, new Status.Success(BaseClientState.DISCONNECTED)); - System.out.println("Disconnected"); + connect(underTest, this); + disconnect(underTest, this); final var mqttClient = getMqttClient(name.getMethodName()); mqttClient.connect(); publishMergeThingMessage(mqttClient, TOPIC_NAME, "key", "test"); mqttClient.disconnect(); - underTest.tell(OpenConnection.of(CONNECTION_ID, DittoHeaders.empty()), getRef()); - expectMsg(CONNECTION_TIMEOUT, new Status.Success(BaseClientState.CONNECTED)); - + connect(underTest, this); expectMergeThingMessageIfNotCleanSession(commandForwarderProbe, "key", "test"); - - underTest.tell(CloseConnection.of(CONNECTION_ID, DittoHeaders.empty()), getRef()); - expectMsg(CONNECTION_TIMEOUT, new Status.Success(BaseClientState.DISCONNECTED)); + disconnect(underTest, this); ensureAllMessagesAcknowledged(); }}; @@ -278,8 +263,9 @@ public void testPersistentSession() { public void testPersistentSessionMessageFromTopicWhichIsNoLongerSubscribed() { new TestKit(actorSystem) {{ final var underTest = getMqttClientActor(getConnection(new String[] { TOPIC_NAME })); + // create session for ditto client ID with subscription to 2 topics - final var dittoMqttClient = getMqttClient(CLIENT_ID_DITTO); + final var dittoMqttClient = getMqttClient(getDittoClientId()); dittoMqttClient.connect(GenericMqttConnect.newInstance(false, KeepAliveInterval.defaultKeepAlive(), SESSION_EXPIRY_INTERVAL, ReceiveMaximum.defaultReceiveMaximum())); dittoMqttClient.subscribe(GenericMqttSubscribe.of(Set.of( GenericMqttSubscription.newInstance(MqttTopicFilter.of(TOPIC_NAME), MqttQos.EXACTLY_ONCE), @@ -292,13 +278,9 @@ public void testPersistentSessionMessageFromTopicWhichIsNoLongerSubscribed() { publishMergeThingMessage(mqttClient, ANOTHER_TOPIC_NAME, "key2", "test2"); mqttClient.disconnect(); - underTest.tell(OpenConnection.of(CONNECTION_ID, DittoHeaders.empty()), getRef()); - expectMsg(CONNECTION_TIMEOUT, new Status.Success(BaseClientState.CONNECTED)); - + connect(underTest, this); expectMergeThingMessageIfNotCleanSession(commandForwarderProbe, "key", "test"); - - underTest.tell(CloseConnection.of(CONNECTION_ID, DittoHeaders.empty()), getRef()); - expectMsg(CONNECTION_TIMEOUT, new Status.Success(BaseClientState.DISCONNECTED)); + disconnect(underTest, this); ensureAllMessagesAcknowledged(); }}; @@ -313,7 +295,11 @@ private ActorRef getMqttClientActor(final Connection connection) { ConfigFactory.empty())); } - private static Connection getConnection(final String[]... sourcesTopics) { + private String getDittoClientId() { + return CLIENT_ID_DITTO + "-" + name.getMethodName(); + } + + private Connection getConnection(final String[]... sourcesTopics) { return ConnectivityModelFactory.newConnectionBuilder(CONNECTION_ID, mqttVersion.equals(MqttVersion.MQTT_3_1_1) ? ConnectionType.MQTT : ConnectionType.MQTT_5, ConnectivityStatus.CLOSED, @@ -332,6 +318,16 @@ private static Connection getConnection(final String[]... sourcesTopics) { .build(); } + private static void connect(final ActorRef underTest, final TestKit testKit) { + underTest.tell(OpenConnection.of(CONNECTION_ID, DittoHeaders.empty()), testKit.getRef()); + testKit.expectMsg(CONNECTION_TIMEOUT, new Status.Success(BaseClientState.CONNECTED)); + } + + private static void disconnect(final ActorRef underTest, final TestKit testKit) { + underTest.tell(CloseConnection.of(CONNECTION_ID, DittoHeaders.empty()), testKit.getRef()); + testKit.expectMsg(CONNECTION_TIMEOUT, new Status.Success(BaseClientState.DISCONNECTED)); + } + private static void publishMergeThingMessage(final GenericBlockingMqttClient mqttClient, final String topic, final String key, final String value) { mqttClient.publish(GenericMqttPublish.builder(MqttTopic.of(topic), MqttQos.EXACTLY_ONCE) .payload(ByteBuffer.wrap(String.format(""" @@ -350,18 +346,14 @@ private static void publishMergeThingMessage(final GenericBlockingMqttClient mqt ); } - private static void sleep(int seconds) { - if (seconds == 0) { - return; - } - + private static void sleep(final int seconds) { try { Thread.sleep(seconds * 1000L); } catch (InterruptedException ignored) { } } - private static GenericBlockingMqttClient getMqttClient(final String clientId) { + private GenericBlockingMqttClient getMqttClient(final String clientId) { return GenericBlockingMqttClientBuilder.newInstance(mqttVersion, MOSQUITTO_RESOURCE.getBindIp(), MOSQUITTO_RESOURCE.getPort()) .clientIdentifier(clientId) .build(); @@ -389,8 +381,10 @@ private void expectMergeThingMessage(final TestProbe testProbe, final String key } private void expectMergeThingMessages(final TestProbe testProbe, final Map updates) { - final var messages = CollectionConverters.SeqHasAsJava(testProbe.receiveN(2, COMMAND_TIMEOUT)).asJava(); - assertThat(messages).hasSize(2); + final var messages = CollectionConverters.SeqHasAsJava(testProbe.receiveN(updates.size(), COMMAND_TIMEOUT)).asJava(); + assertThat(messages).hasSize(updates.size()); + // Can't create map here, because in case of error the key might duplicate, and we'll get ugly error instead of + // pretty assertion failure. final var actualUpdates = messages.stream() .filter(MergeThing.class::isInstance) .map(MergeThing.class::cast) @@ -401,8 +395,8 @@ private void expectMergeThingMessages(final TestProbe testProbe, final Map(); mqttClient.setPublishesCallback(MqttGlobalPublishFilter.ALL, unacknowledgedPublishes::add); @@ -455,7 +449,7 @@ private static final class Mqtt3BlockingMqttClient implements GenericBlockingMqt private final Mqtt3BlockingClient client; - private Mqtt3BlockingMqttClient(GenericBlockingMqttClientBuilder builder) { + private Mqtt3BlockingMqttClient(final GenericBlockingMqttClientBuilder builder) { var mqtt3ClientBuilder = MqttClient.builder() .useMqttVersion3() .serverHost(builder.host) @@ -508,7 +502,7 @@ private static final class Mqtt5BlockingMqttClient implements GenericBlockingMqt private final Mqtt5BlockingClient client; - private Mqtt5BlockingMqttClient(GenericBlockingMqttClientBuilder builder) { + private Mqtt5BlockingMqttClient(final GenericBlockingMqttClientBuilder builder) { var mqtt5ClientBuilder = MqttClient.builder() .useMqttVersion5() .serverHost(builder.host) @@ -558,145 +552,4 @@ public void subscribe(final GenericMqttSubscribe subscribe) { } } - /*@Test - public void testStream() { - new TestKit(actorSystem) {{ - final ActorRef underTest = actorSystem.actorOf(MqttClientActor.props(queryParser, readPersistence, - actorSystem.deadLetters())); - - insertTestThings(); - - underTest.tell(queryThings(null, null), getRef()); - - final SourceRef response = expectMsgClass(SourceRef.class); - final JsonArray searchResult = response.getSource() - .runWith(Sink.seq(), actorSystem) - .toCompletableFuture() - .join() - .stream() - .map(thingId -> wrapAsSearchResult((String) thingId)) - .collect(JsonCollectors.valuesToArray()); - - assertThat(searchResult).isEqualTo(expectedIds(4, 2, 0, 1, 3)); - }}; - } - - @Test - public void testCursorSearch() { - new TestKit(actorSystem) {{ - final ActorRef underTest = actorSystem.actorOf(MqttClientActor.props(queryParser, readPersistence, - actorSystem.deadLetters())); - final Supplier noCursor = - () -> new AssertionError("No cursor where a cursor is expected"); - - insertTestThings(); - - underTest.tell(queryThings(1, null), getRef()); - final QueryThingsResponse response0 = expectMsgClass(QueryThingsResponse.class); - assertThat(response0.getSearchResult().getItems()).isEqualTo(expectedIds(4)); - - underTest.tell(queryThings(1, response0.getSearchResult().getCursor().orElseThrow(noCursor)), getRef()); - final QueryThingsResponse response1 = expectMsgClass(QueryThingsResponse.class); - assertThat(response1.getSearchResult().getItems()).isEqualTo(expectedIds(2)); - - underTest.tell(queryThings(1, response1.getSearchResult().getCursor().orElseThrow(noCursor)), getRef()); - final QueryThingsResponse response2 = expectMsgClass(QueryThingsResponse.class); - assertThat(response2.getSearchResult().getItems()).isEqualTo(expectedIds(0)); - - underTest.tell(queryThings(1, response2.getSearchResult().getCursor().orElseThrow(noCursor)), getRef()); - final QueryThingsResponse response3 = expectMsgClass(QueryThingsResponse.class); - assertThat(response3.getSearchResult().getItems()).isEqualTo(expectedIds(1)); - - underTest.tell(queryThings(1, response3.getSearchResult().getCursor().orElseThrow(noCursor)), getRef()); - final QueryThingsResponse response4 = expectMsgClass(QueryThingsResponse.class); - assertThat(response4.getSearchResult().getItems()).isEqualTo(expectedIds(3)); - - assertThat(response4.getSearchResult().getCursor()).isEmpty(); - }}; - } - - private static Command queryThings(@Nullable final Integer size, final @Nullable String cursor) { - final List options = new ArrayList<>(); - final String sort = "sort(-attributes/c,+attributes/b,-attributes/a,+attributes/null/1,-attributes/null/2)"; - if (cursor == null) { - options.add(sort); - } - if (size != null) { - options.add("size(" + size + ")"); - } - if (cursor != null) { - options.add("cursor(" + cursor + ")"); - } - final DittoHeaders dittoHeaders = DittoHeaders.newBuilder() - .authorizationContext(AUTH_CONTEXT) - .build(); - final String filter = "and(eq(attributes/x,5),eq(_metadata/attributes/x/type,\"x attribute\"))"; - if (size != null) { - return QueryThings.of(filter, options, null, null, dittoHeaders); - } else { - return StreamThings.of(filter, null, sort, null, dittoHeaders); - } - } - - private void insertTestThings() { - final Thing baseThing = ThingsModelFactory.newThingBuilder() - .setId(ThingId.of("thing", "00")) - .setRevision(1234L) - .setAttribute(JsonPointer.of("x"), JsonValue.of(5)) - .setMetadata(MetadataModelFactory.newMetadataBuilder() - .set("attributes", JsonObject.newBuilder() - .set("x", JsonObject.newBuilder() - .set("type", "x attribute") - .build()) - .build()) - .build()) - .build(); - - final Thing irrelevantThing = baseThing.toBuilder().removeAllAttributes().build(); - - writePersistence.write(template(baseThing, 0, "a"), policy, 0L) - .concat(writePersistence.write(template(baseThing, 1, "b"), policy, 0L)) - .concat(writePersistence.write(template(baseThing, 2, "a"), policy, 0L)) - .concat(writePersistence.write(template(baseThing, 3, "b"), policy, 0L)) - .concat(writePersistence.write(template(baseThing, 4, "c"), policy, 0L)) - .concat(writePersistence.write(template(irrelevantThing, 5, "c"), policy, 0L)) - .runWith(Sink.ignore(), actorSystem) - .toCompletableFuture() - .join(); - } - - private static Policy createPolicy() { - final Collection subjects = - AUTH_CONTEXT.getAuthorizationSubjectIds().stream() - .map(subjectId -> Subject.newInstance(subjectId, SubjectType.GENERATED)) - .toList(); - final Collection resources = Collections.singletonList(Resource.newInstance( - ResourceKey.newInstance("thing:/"), - EffectedPermissions.newInstance(Collections.singletonList("READ"), Collections.emptyList()) - )); - final PolicyEntry policyEntry = PolicyEntry.newInstance("viewer", subjects, resources); - return PoliciesModelFactory.newPolicyBuilder(POLICY_ID) - .set(policyEntry) - .setRevision(1L) - .build(); - } - - private static JsonArray expectedIds(final int... thingOrdinals) { - return Arrays.stream(thingOrdinals) - .mapToObj(i -> "thing:" + i) - .map(MqttClientActorIT::wrapAsSearchResult) - .collect(JsonCollectors.valuesToArray()); - } - - private static JsonValue wrapAsSearchResult(final CharSequence thingId) { - return JsonFactory.readFrom(String.format("{\"thingId\":\"%s\"}", thingId)); - } - - private static Thing template(final Thing thing, final int i, final CharSequence attribute) { - return thing.toBuilder() - .setId(ThingId.of("thing", String.valueOf(i))) - .setAttribute(JsonPointer.of(attribute), JsonValue.of(i)) - .build(); - }*/ - } diff --git a/internal/utils/test/src/test/java/org/eclipse/ditto/internal/utils/test/docker/ContainerFactory.java b/internal/utils/test/src/test/java/org/eclipse/ditto/internal/utils/test/docker/ContainerFactory.java index 04e523aa08..5068bb2a04 100644 --- a/internal/utils/test/src/test/java/org/eclipse/ditto/internal/utils/test/docker/ContainerFactory.java +++ b/internal/utils/test/src/test/java/org/eclipse/ditto/internal/utils/test/docker/ContainerFactory.java @@ -65,7 +65,7 @@ protected ContainerFactory(final String imageIdentifier, final int... ports) { } } - protected CreateContainerCmd configureContainer(CreateContainerCmd createContainerCmd) { + protected CreateContainerCmd configureContainer(final CreateContainerCmd createContainerCmd) { return createContainerCmd; } diff --git a/internal/utils/test/src/test/java/org/eclipse/ditto/internal/utils/test/docker/mongo/MongoContainerFactory.java b/internal/utils/test/src/test/java/org/eclipse/ditto/internal/utils/test/docker/mongo/MongoContainerFactory.java index 546502d5c4..b03d5e8c83 100644 --- a/internal/utils/test/src/test/java/org/eclipse/ditto/internal/utils/test/docker/mongo/MongoContainerFactory.java +++ b/internal/utils/test/src/test/java/org/eclipse/ditto/internal/utils/test/docker/mongo/MongoContainerFactory.java @@ -12,7 +12,6 @@ */ package org.eclipse.ditto.internal.utils.test.docker.mongo; -import java.io.Closeable; import java.io.IOException; import java.util.List; @@ -48,7 +47,7 @@ static MongoContainerFactory of(final String mongoVersion) { } @Override - protected CreateContainerCmd configureContainer(CreateContainerCmd createContainerCmd) { + protected CreateContainerCmd configureContainer(final CreateContainerCmd createContainerCmd) { return createContainerCmd.withCmd(MONGO_COMMANDS); } diff --git a/internal/utils/test/src/test/java/org/eclipse/ditto/internal/utils/test/docker/mosquitto/MosquittoContainerFactory.java b/internal/utils/test/src/test/java/org/eclipse/ditto/internal/utils/test/docker/mosquitto/MosquittoContainerFactory.java index 5338c630ad..06b75a4d55 100644 --- a/internal/utils/test/src/test/java/org/eclipse/ditto/internal/utils/test/docker/mosquitto/MosquittoContainerFactory.java +++ b/internal/utils/test/src/test/java/org/eclipse/ditto/internal/utils/test/docker/mosquitto/MosquittoContainerFactory.java @@ -16,14 +16,14 @@ import java.nio.file.Path; import java.util.Objects; -import com.github.dockerjava.api.model.AccessMode; -import com.google.common.base.MoreObjects; import org.eclipse.ditto.internal.utils.test.docker.ContainerFactory; import com.github.dockerjava.api.command.CreateContainerCmd; +import com.github.dockerjava.api.model.AccessMode; import com.github.dockerjava.api.model.Bind; import com.github.dockerjava.api.model.HostConfig; import com.github.dockerjava.api.model.Volume; +import com.google.common.base.MoreObjects; /** * Responsible for creating and configuring the mosquitto docker container that should be started for tests. @@ -47,7 +47,7 @@ private MosquittoContainerFactory(final String configResourceName, final String } } - private String getResourceAbsolutePath(String resourceName) throws URISyntaxException { + private String getResourceAbsolutePath(final String resourceName) throws URISyntaxException { return Path.of(Objects.requireNonNull(getClass().getClassLoader().getResource(resourceName)).toURI()).toAbsolutePath().toString(); } @@ -59,7 +59,7 @@ static MosquittoContainerFactory of(final String configResourceName) { } @Override - protected CreateContainerCmd configureContainer(CreateContainerCmd createContainerCmd) { + protected CreateContainerCmd configureContainer(final CreateContainerCmd createContainerCmd) { final var hostConfig = MoreObjects.firstNonNull(createContainerCmd.getHostConfig(), HostConfig.newHostConfig()) .withBinds(new Bind(CONFIG_RESOURCES_PATH, new Volume(CONFIG_CONTAINER_PATH), AccessMode.ro)); return createContainerCmd.withHostConfig(hostConfig);