Skip to content

Commit

Permalink
Formatting of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtSilvio committed Nov 15, 2023
1 parent 9627f41 commit 65ba794
Show file tree
Hide file tree
Showing 23 changed files with 50 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ void publishBothOn_prefetch() {

final AtomicInteger count = new AtomicInteger();
StepVerifier.create(
fluxWithSingle.publishBothOn(Schedulers.fromExecutor(executorService), 16).doOnSingle(stringBuilder -> {
assertEquals("single", stringBuilder.toString());
assertEquals("test_thread", Thread.currentThread().getName());
}).doOnNext(string -> {
assertEquals("next" + count.getAndIncrement(), string);
assertEquals("test_thread", Thread.currentThread().getName());
}), 1)
fluxWithSingle.publishBothOn(Schedulers.fromExecutor(executorService), 16).doOnSingle(stringBuilder -> {
assertEquals("single", stringBuilder.toString());
assertEquals("test_thread", Thread.currentThread().getName());
}).doOnNext(string -> {
assertEquals("next" + count.getAndIncrement(), string);
assertEquals("test_thread", Thread.currentThread().getName());
}), 1)
.expectNext("next0")
.thenRequest(1)
.expectNext("next1")
Expand All @@ -160,8 +160,8 @@ void publishBothOn_prefetch() {

@Test
void publishBothOn_delayError_prefetch() {
final Flux<? extends CharSequence> flux = Flux.<CharSequence>just(new StringBuilder("single")).concatWith(
Flux.range(0, 1024).zipWith(Flux.just("next").repeat(1024), (i, s) -> s + i))
final Flux<? extends CharSequence> flux = Flux.<CharSequence>just(new StringBuilder("single"))
.concatWith(Flux.range(0, 1024).zipWith(Flux.just("next").repeat(1024), (i, s) -> s + i))
.concatWith(Flux.error(new IllegalArgumentException("test")))
.hide();
final FluxWithSingle<String, StringBuilder> fluxWithSingle =
Expand All @@ -172,14 +172,14 @@ void publishBothOn_delayError_prefetch() {

final AtomicInteger count = new AtomicInteger();
StepVerifier.create(fluxWithSingle.publishBothOn(Schedulers.fromExecutor(executorService), true, 1024)
.doOnSingle(stringBuilder -> {
assertEquals("single", stringBuilder.toString());
assertEquals("test_thread", Thread.currentThread().getName());
})
.doOnNext(string -> {
assertEquals("next" + count.getAndIncrement(), string);
assertEquals("test_thread", Thread.currentThread().getName());
}), 1)
.doOnSingle(stringBuilder -> {
assertEquals("single", stringBuilder.toString());
assertEquals("test_thread", Thread.currentThread().getName());
})
.doOnNext(string -> {
assertEquals("next" + count.getAndIncrement(), string);
assertEquals("test_thread", Thread.currentThread().getName());
}), 1)
.expectNext("next0")
.thenRequest(1022)
.expectNextCount(1022)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ void clear_notAcknowledged_noFlow() {

@Test
void getSubscriptions() {
final ImmutableList<MqttSubscription> subscriptions = ImmutableList.of(
final ImmutableList<MqttSubscription> subscriptions = ImmutableList.of( //
new MqttSubscriptionBuilder.Default().topicFilter("abc").build(),
new MqttSubscriptionBuilder.Default().topicFilter("$share/group/abc").build(),
new MqttSubscriptionBuilder.Default().topicFilter("#").build(),
Expand All @@ -777,7 +777,7 @@ void getSubscriptions() {

@Test
void getSubscriptions_sameSubscriptionIdentifiers() {
final ImmutableList<MqttSubscription> subscriptions = ImmutableList.of(
final ImmutableList<MqttSubscription> subscriptions = ImmutableList.of( //
new MqttSubscriptionBuilder.Default().topicFilter("abc").build(),
new MqttSubscriptionBuilder.Default().topicFilter("$share/group/abc").build(),
new MqttSubscriptionBuilder.Default().topicFilter("#").build(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void noStackTrace() {
final TestAsyncRuntimeException exception = new TestAsyncRuntimeException("message");
assertEquals(0, exception.getStackTrace().length);
final TestAsyncRuntimeException thrownException =
assertThrows(TestAsyncRuntimeException.class, () -> { throw exception; });
assertThrows(TestAsyncRuntimeException.class, () -> {throw exception;});
assertEquals(0, thrownException.getStackTrace().length);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void noStackTrace() {
final ConnectionClosedException exception = new ConnectionClosedException("message");
assertEquals(0, exception.getStackTrace().length);
final ConnectionClosedException thrownException =
assertThrows(ConnectionClosedException.class, () -> { throw exception; });
assertThrows(ConnectionClosedException.class, () -> {throw exception;});
assertEquals(0, thrownException.getStackTrace().length);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void noStackTrace() {
final ConnectionFailedException exception = new ConnectionFailedException("message");
assertEquals(0, exception.getStackTrace().length);
final ConnectionFailedException thrownException =
assertThrows(ConnectionFailedException.class, () -> { throw exception; });
assertThrows(ConnectionFailedException.class, () -> {throw exception;});
assertEquals(0, thrownException.getStackTrace().length);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void noStackTrace() {
final MqttClientStateException exception = new MqttClientStateException("message");
assertEquals(0, exception.getStackTrace().length);
final MqttClientStateException thrownException =
assertThrows(MqttClientStateException.class, () -> { throw exception; });
assertThrows(MqttClientStateException.class, () -> {throw exception;});
assertEquals(0, thrownException.getStackTrace().length);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void constructor_message() {
void noStackTrace() {
final MqttDecodeException exception = new MqttDecodeException("message");
assertEquals(0, exception.getStackTrace().length);
final MqttDecodeException thrownException = assertThrows(MqttDecodeException.class, () -> { throw exception; });
final MqttDecodeException thrownException = assertThrows(MqttDecodeException.class, () -> {throw exception;});
assertEquals(0, thrownException.getStackTrace().length);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void constructor_message() {
void noStackTrace() {
final MqttEncodeException exception = new MqttEncodeException("message");
assertEquals(0, exception.getStackTrace().length);
final MqttEncodeException thrownException = assertThrows(MqttEncodeException.class, () -> { throw exception; });
final MqttEncodeException thrownException = assertThrows(MqttEncodeException.class, () -> {throw exception;});
assertEquals(0, thrownException.getStackTrace().length);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void noStackTrace() {
new MqttSessionExpiredException("message", new RuntimeException("cause"));
assertEquals(0, exception.getStackTrace().length);
final MqttSessionExpiredException thrownException =
assertThrows(MqttSessionExpiredException.class, () -> { throw exception; });
assertThrows(MqttSessionExpiredException.class, () -> {throw exception;});
assertEquals(0, thrownException.getStackTrace().length);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void noStackTrace() {
final Mqtt3ConnAckException exception = new Mqtt3ConnAckException(connAck, "message", cause);
assertEquals(0, exception.getStackTrace().length);
final Mqtt3ConnAckException thrownException =
assertThrows(Mqtt3ConnAckException.class, () -> { throw exception; });
assertThrows(Mqtt3ConnAckException.class, () -> {throw exception;});
assertEquals(0, thrownException.getStackTrace().length);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void noStackTrace() {
new Mqtt3DisconnectException(Mqtt3DisconnectView.INSTANCE, "message", cause);
assertEquals(0, exception.getStackTrace().length);
final Mqtt3DisconnectException thrownException =
assertThrows(Mqtt3DisconnectException.class, () -> { throw exception; });
assertThrows(Mqtt3DisconnectException.class, () -> {throw exception;});
assertEquals(0, thrownException.getStackTrace().length);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ void noStackTrace() {
final RuntimeException cause = new RuntimeException("cause");
final Mqtt3PubAckException exception = new Mqtt3PubAckException(Mqtt3PubAckView.INSTANCE, "message", cause);
assertEquals(0, exception.getStackTrace().length);
final Mqtt3PubAckException thrownException =
assertThrows(Mqtt3PubAckException.class, () -> { throw exception; });
final Mqtt3PubAckException thrownException = assertThrows(Mqtt3PubAckException.class, () -> {throw exception;});
assertEquals(0, thrownException.getStackTrace().length);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ void noStackTrace() {
final RuntimeException cause = new RuntimeException("cause");
final Mqtt3PubRecException exception = new Mqtt3PubRecException(Mqtt3PubRecView.INSTANCE, "message", cause);
assertEquals(0, exception.getStackTrace().length);
final Mqtt3PubRecException thrownException =
assertThrows(Mqtt3PubRecException.class, () -> { throw exception; });
final Mqtt3PubRecException thrownException = assertThrows(Mqtt3PubRecException.class, () -> {throw exception;});
assertEquals(0, thrownException.getStackTrace().length);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ void noStackTrace() {
final RuntimeException cause = new RuntimeException("cause");
final Mqtt3SubAckException exception = new Mqtt3SubAckException(subAck, "message", cause);
assertEquals(0, exception.getStackTrace().length);
final Mqtt3SubAckException thrownException =
assertThrows(Mqtt3SubAckException.class, () -> { throw exception; });
final Mqtt3SubAckException thrownException = assertThrows(Mqtt3SubAckException.class, () -> {throw exception;});
assertEquals(0, thrownException.getStackTrace().length);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void noStackTrace() {
new Mqtt3UnsubAckException(Mqtt3UnsubAckView.INSTANCE, "message", cause);
assertEquals(0, exception.getStackTrace().length);
final Mqtt3UnsubAckException thrownException =
assertThrows(Mqtt3UnsubAckException.class, () -> { throw exception; });
assertThrows(Mqtt3UnsubAckException.class, () -> {throw exception;});
assertEquals(0, thrownException.getStackTrace().length);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void noStackTrace() {
final Mqtt5Auth auth = mock(Mqtt5Auth.class);
final Mqtt5AuthException exception = new Mqtt5AuthException(auth, "message");
assertEquals(0, exception.getStackTrace().length);
final Mqtt5AuthException thrownException = assertThrows(Mqtt5AuthException.class, () -> { throw exception; });
final Mqtt5AuthException thrownException = assertThrows(Mqtt5AuthException.class, () -> {throw exception;});
assertEquals(0, thrownException.getStackTrace().length);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void noStackTrace() {
final Mqtt5ConnAckException exception = new Mqtt5ConnAckException(connAck, "message");
assertEquals(0, exception.getStackTrace().length);
final Mqtt5ConnAckException thrownException =
assertThrows(Mqtt5ConnAckException.class, () -> { throw exception; });
assertThrows(Mqtt5ConnAckException.class, () -> {throw exception;});
assertEquals(0, thrownException.getStackTrace().length);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void noStackTrace() {
final Mqtt5DisconnectException exception = new Mqtt5DisconnectException(disconnect, "message");
assertEquals(0, exception.getStackTrace().length);
final Mqtt5DisconnectException thrownException =
assertThrows(Mqtt5DisconnectException.class, () -> { throw exception; });
assertThrows(Mqtt5DisconnectException.class, () -> {throw exception;});
assertEquals(0, thrownException.getStackTrace().length);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ void noStackTrace() {
final Mqtt5PubAck pubAck = mock(Mqtt5PubAck.class);
final Mqtt5PubAckException exception = new Mqtt5PubAckException(pubAck, "message");
assertEquals(0, exception.getStackTrace().length);
final Mqtt5PubAckException thrownException =
assertThrows(Mqtt5PubAckException.class, () -> { throw exception; });
final Mqtt5PubAckException thrownException = assertThrows(Mqtt5PubAckException.class, () -> {throw exception;});
assertEquals(0, thrownException.getStackTrace().length);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ void noStackTrace() {
final Mqtt5PubRec pubRec = mock(Mqtt5PubRec.class);
final Mqtt5PubRecException exception = new Mqtt5PubRecException(pubRec, "message");
assertEquals(0, exception.getStackTrace().length);
final Mqtt5PubRecException thrownException =
assertThrows(Mqtt5PubRecException.class, () -> { throw exception; });
final Mqtt5PubRecException thrownException = assertThrows(Mqtt5PubRecException.class, () -> {throw exception;});
assertEquals(0, thrownException.getStackTrace().length);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ void noStackTrace() {
final Mqtt5SubAck subAck = mock(Mqtt5SubAck.class);
final Mqtt5SubAckException exception = new Mqtt5SubAckException(subAck, "message");
assertEquals(0, exception.getStackTrace().length);
final Mqtt5SubAckException thrownException =
assertThrows(Mqtt5SubAckException.class, () -> { throw exception; });
final Mqtt5SubAckException thrownException = assertThrows(Mqtt5SubAckException.class, () -> {throw exception;});
assertEquals(0, thrownException.getStackTrace().length);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void noStackTrace() {
final Mqtt5UnsubAckException exception = new Mqtt5UnsubAckException(unsubAck, "message");
assertEquals(0, exception.getStackTrace().length);
final Mqtt5UnsubAckException thrownException =
assertThrows(Mqtt5UnsubAckException.class, () -> { throw exception; });
assertThrows(Mqtt5UnsubAckException.class, () -> {throw exception;});
assertEquals(0, thrownException.getStackTrace().length);
}

Expand Down
24 changes: 11 additions & 13 deletions src/test/java/com/hivemq/client2/rx/FlowableWithSingleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,10 @@ void observeBothOn_delayError() throws InterruptedException {

@Test
void observeBothOn_delayError_bufferSize() throws InterruptedException {
final Flowable<? extends CharSequence> flowable =
Flowable.<CharSequence>just(new StringBuilder("single")).concatWith(
Flowable.range(0, 1024).zipWith(Flowable.just("next").repeat(1024), (i, s) -> s + i))
.concatWith(Flowable.error(new IllegalArgumentException("test")))
.hide();
final Flowable<? extends CharSequence> flowable = Flowable.<CharSequence>just(new StringBuilder("single"))
.concatWith(Flowable.range(0, 1024).zipWith(Flowable.just("next").repeat(1024), (i, s) -> s + i))
.concatWith(Flowable.error(new IllegalArgumentException("test")))
.hide();
final FlowableWithSingle<String, StringBuilder> flowableWithSingle =
new FlowableWithSingleSplit<>(flowable, String.class, StringBuilder.class);

Expand Down Expand Up @@ -203,11 +202,10 @@ void observeBothOn_delayError_bufferSize() throws InterruptedException {

@Test
void observeBothOn_delayError_bufferSize_2() {
final Flowable<? extends CharSequence> flowable =
Flowable.<CharSequence>just(new StringBuilder("single")).concatWith(
Flowable.range(0, 1024).zipWith(Flowable.just("next").repeat(1024), (i, s) -> s + i))
.concatWith(Flowable.error(new IllegalArgumentException("test")))
.hide();
final Flowable<? extends CharSequence> flowable = Flowable.<CharSequence>just(new StringBuilder("single"))
.concatWith(Flowable.range(0, 1024).zipWith(Flowable.just("next").repeat(1024), (i, s) -> s + i))
.concatWith(Flowable.error(new IllegalArgumentException("test")))
.hide();
final FlowableWithSingle<String, StringBuilder> flowableWithSingle =
new FlowableWithSingleSplit<>(flowable, String.class, StringBuilder.class);

Expand Down Expand Up @@ -285,9 +283,9 @@ void doOnSingle_multiple(final @NotNull FlowableWithSingle<String, StringBuilder
assertEquals(1, counter.incrementAndGet());
assertNotEquals("test_thread", Thread.currentThread().getName());
}).doOnSingle(stringBuilder -> {
assertEquals(2, counter.incrementAndGet());
assertNotEquals("test_thread", Thread.currentThread().getName());
}).observeBothOn(Schedulers.from(executorService))
assertEquals(2, counter.incrementAndGet());
assertNotEquals("test_thread", Thread.currentThread().getName());
}).observeBothOn(Schedulers.from(executorService))
.doOnSingle(stringBuilder -> {
assertEquals(3, counter.incrementAndGet());
assertEquals("test_thread", Thread.currentThread().getName());
Expand Down

0 comments on commit 65ba794

Please sign in to comment.