Skip to content

Commit

Permalink
stabilize flaky MQTT tests by using random correlationIds in Abstract…
Browse files Browse the repository at this point in the history
…MqttClientActorTest#testConsumeMultipleSources()

Signed-off-by: Thomas Jaeckle <thomas.jaeckle@bosch.io>
  • Loading branch information
thjaeckle committed Nov 3, 2021
1 parent feb758a commit 4fab43e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Expand Up @@ -997,9 +997,14 @@ public static String signalToDittoProtocolJsonString(final Signal<?> signal) {
return jsonifiable.toJsonString();
}


public static String modifyThing() {
final DittoHeaders dittoHeaders = DittoHeaders.newBuilder().correlationId(CORRELATION_ID).putHeader(
ExternalMessage.REPLY_TO_HEADER, "replies").build();
return modifyThing(CORRELATION_ID);
}

public static String modifyThing(final String correlationId) {
final DittoHeaders dittoHeaders = DittoHeaders.newBuilder().correlationId(correlationId)
.putHeader(ExternalMessage.REPLY_TO_HEADER, "replies").build();
final ModifyThing modifyThing = ModifyThing.of(Things.THING_ID, Things.THING, null, dittoHeaders);
final Adaptable adaptable = DittoProtocolAdapter.newInstance().toAdaptable(modifyThing);
final JsonifiableAdaptable jsonifiable = ProtocolFactory.wrapAsJsonifiableAdaptable(adaptable);
Expand Down
Expand Up @@ -22,6 +22,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
Expand Down Expand Up @@ -58,7 +59,6 @@
import org.eclipse.ditto.things.model.signals.events.ThingModifiedEvent;
import org.junit.After;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -339,7 +339,7 @@ public void testConsumeMultipleSources() {
final String[] subscriptions = {"A1", "A1", "A1", "B1", "B1", "B2", "B2", "C1", "C2", "C3"};
final List<M> mockMessages =
Stream.concat(irrelevantTopics.stream(), Arrays.stream(subscriptions))
.map(topic -> mqttMessage(topic, TestConstants.modifyThing()))
.map(topic -> mqttMessage(topic, TestConstants.modifyThing(UUID.randomUUID().toString())))
.collect(Collectors.toList());

final Connection multipleSources =
Expand Down

0 comments on commit 4fab43e

Please sign in to comment.