Skip to content

Commit

Permalink
[test] Fix compiler warnings during compileTestJava phase (reactor#1139)
Browse files Browse the repository at this point in the history
Use `@SuppressWarnings` rather than IntelliJ comments when possible so
that the compiler will pick these hints up too.
  • Loading branch information
simonbasle committed Mar 22, 2018
1 parent 4b74091 commit 63debe7
Show file tree
Hide file tree
Showing 23 changed files with 139 additions and 77 deletions.
47 changes: 31 additions & 16 deletions reactor-core/src/test/java/reactor/core/ScannableTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.util.Collections;
import java.util.List;
import java.util.stream.Stream;

import org.assertj.core.api.Condition;
import org.junit.Test;
Expand Down Expand Up @@ -206,10 +207,12 @@ public void taggedFluxTest() {
.tag("2", "Two")
.hide();

assertThat(Scannable.from(tagged1).tags())
final Stream<Tuple2<String, String>> scannedTags1 = Scannable.from(tagged1).tags();
assertThat(scannedTags1.iterator())
.containsExactlyInAnyOrder(Tuples.of("1", "One"));

assertThat(Scannable.from(tagged2).tags())
final Stream<Tuple2<String, String>> scannedTags2 = Scannable.from(tagged2).tags();
assertThat(scannedTags2.iterator())
.containsExactlyInAnyOrder(Tuples.of("1", "One"), Tuples.of( "2", "Two"));
}

Expand All @@ -225,10 +228,12 @@ public void taggedHideFluxTest() {
.tag("2", "Two")
.hide();

assertThat(Scannable.from(tagged1).tags())
final Stream<Tuple2<String, String>> scannedTags1 = Scannable.from(tagged1).tags();
assertThat(scannedTags1.iterator())
.containsExactlyInAnyOrder(Tuples.of("1", "One"));

assertThat(Scannable.from(tagged2).tags())
final Stream<Tuple2<String, String>> scannedTags2 = Scannable.from(tagged2).tags();
assertThat(scannedTags2.iterator())
.containsExactlyInAnyOrder(Tuples.of("1", "One"), Tuples.of( "2", "Two"));
}

Expand All @@ -239,7 +244,8 @@ public void taggedAppendedFluxTest() {
.tag("1", "One")
.tag("2", "Two");

assertThat(Scannable.from(tagged1).tags())
final Stream<Tuple2<String, String>> scannedTags = Scannable.from(tagged1).tags();
assertThat(scannedTags.iterator())
.containsExactlyInAnyOrder(Tuples.of("1", "One"), Tuples.of( "2", "Two"));
}

Expand All @@ -251,7 +257,8 @@ public void taggedAppendedHideFluxTest() {
.tag("1", "One")
.tag("2", "Two");

assertThat(Scannable.from(tagged1).tags())
final Stream<Tuple2<String, String>> scannedTags = Scannable.from(tagged1).tags();
assertThat(scannedTags.iterator())
.containsExactlyInAnyOrder(Tuples.of("1", "One"), Tuples.of( "2", "Two"));
}

Expand Down Expand Up @@ -337,10 +344,12 @@ public void taggedMonoTest() {
.tag("2", "Two")
.hide();

assertThat(Scannable.from(tagged1).tags())
final Stream<Tuple2<String, String>> scannedTags1 = Scannable.from(tagged1).tags();
assertThat(scannedTags1.iterator())
.containsExactlyInAnyOrder(Tuples.of("1", "One"));

assertThat(Scannable.from(tagged2).tags())
final Stream<Tuple2<String, String>> scannedTags2 = Scannable.from(tagged2).tags();
assertThat(scannedTags2.iterator())
.containsExactlyInAnyOrder(Tuples.of("1", "One"), Tuples.of( "2", "Two"));
}

Expand All @@ -356,10 +365,12 @@ public void taggedHideMonoTest() {
.tag("2", "Two")
.hide();

assertThat(Scannable.from(tagged1).tags())
final Stream<Tuple2<String, String>> scannedTags1 = Scannable.from(tagged1).tags();
assertThat(scannedTags1.iterator())
.containsExactlyInAnyOrder(Tuples.of("1", "One"));

assertThat(Scannable.from(tagged2).tags())
final Stream<Tuple2<String, String>> scannedTags2 = Scannable.from(tagged2).tags();
assertThat(scannedTags2.iterator())
.containsExactlyInAnyOrder(Tuples.of("1", "One"), Tuples.of( "2", "Two"));
}

Expand All @@ -370,7 +381,8 @@ public void taggedAppendedMonoTest() {
.tag("1", "One")
.tag("2", "Two");

assertThat(Scannable.from(tagged1).tags())
final Stream<Tuple2<String, String>> scannedTags = Scannable.from(tagged1).tags();
assertThat(scannedTags.iterator())
.containsExactlyInAnyOrder(Tuples.of("1", "One"), Tuples.of( "2", "Two"));
}

Expand All @@ -382,7 +394,8 @@ public void taggedAppendedHideMonoTest() {
.tag("1", "One")
.tag("2", "Two");

assertThat(Scannable.from(tagged1).tags())
final Stream<Tuple2<String, String>> scannedTags = Scannable.from(tagged1).tags();
assertThat(scannedTags.iterator())
.containsExactlyInAnyOrder(Tuples.of("1", "One"), Tuples.of( "2", "Two"));
}

Expand Down Expand Up @@ -436,10 +449,11 @@ public void taggedParallelFluxTest() {
.tag("2", "Two")
.hide();

assertThat(Scannable.from(tagged1).tags())
.containsExactlyInAnyOrder(Tuples.of("1", "One"));
Stream<Tuple2<String, String>> scannedTags1 = Scannable.from(tagged1).tags();
assertThat(scannedTags1.iterator()).containsExactlyInAnyOrder(Tuples.of("1", "One"));

assertThat(Scannable.from(tagged2).tags())
Stream<Tuple2<String, String>> scannedTags2 = Scannable.from(tagged2).tags();
assertThat(scannedTags2.iterator())
.containsExactlyInAnyOrder(Tuples.of("1", "One"), Tuples.of( "2", "Two"));
}

Expand All @@ -450,7 +464,8 @@ public void taggedAppendedParallelFluxTest() {
.tag("1", "One")
.tag("2", "Two");

assertThat(Scannable.from(tagged1).tags())
final Stream<Tuple2<String, String>> scannedTags = Scannable.from(tagged1).tags();
assertThat(scannedTags.iterator())
.containsExactlyInAnyOrder(Tuples.of("1", "One"), Tuples.of( "2", "Two"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public void awaitTerminationNanosLong() {
e.printStackTrace();
}
});
@SuppressWarnings("deprecation")
boolean shutResult = test.awaitAndShutdown(1000, TimeUnit.NANOSECONDS);
assertThat(test.executor)
.isNotNull()
Expand Down Expand Up @@ -172,6 +173,7 @@ public void awaitAndShutdownLongInterrupt() throws InterruptedException {
.when(executor).awaitTermination(anyLong(), any());
EventLoopProcessor<String> interruptingProcessor = initProcessor(executor);

@SuppressWarnings("deprecation")
boolean result = interruptingProcessor.awaitAndShutdown(100, TimeUnit.MILLISECONDS);

assertThat(Thread.currentThread().isInterrupted()).as("interrupted").isTrue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ public void concatArrayDelayErrorWithMonoError() {

@Test
public void scanOperator() {
FluxConcatArray s = new FluxConcatArray<>(true);
@SuppressWarnings("unchecked") //vararg of Publisher<String>
FluxConcatArray<String> s = new FluxConcatArray<>(true, Flux.empty());
assertThat(s.scan(Scannable.Attr.DELAY_ERROR)).as("delayError").isTrue();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void fluxInitialValueAvailableImmediately() {

@Test
public void scanOperator() {
FluxJust s = new FluxJust("foo");
FluxJust<String> s = new FluxJust<>("foo");
assertThat(s.scan(Scannable.Attr.BUFFERED)).isEqualTo(1);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ public void mergeAdditionalSource() {
public void scanOperator() {
Flux<Integer> source1 = Flux.just(1).map(Function.identity()); //scannable
Flux<Integer> source2 = Flux.just(2);

@SuppressWarnings("unchecked") //safe varargs
Scannable fmo = new FluxMergeOrdered<>(123, Queues.small(), Comparator.naturalOrder(), source1, source2);

assertThat(fmo.scan(Scannable.Attr.PARENT)).isSameAs(source1);
Expand Down Expand Up @@ -364,7 +366,11 @@ public void mainSubscribersDifferentCountInners() {
new FluxMergeOrdered.MergeOrderedMainProducer<>(actual, Comparator.naturalOrder(), 123, 4);

assertThatIllegalArgumentException()
.isThrownBy(() -> test.subscribe(new Publisher[3]))
.isThrownBy(() -> {
@SuppressWarnings("unchecked")
final Publisher<Integer>[] sources = new Publisher[3];
test.subscribe(sources);
})
.withMessage("must subscribe with 4 sources");
}

Expand Down Expand Up @@ -405,6 +411,7 @@ public void cancel() {
}

@Test
@SuppressWarnings("unchecked") //safe varargs
public void normal1() {
new FluxMergeOrdered<>(2, Queues.small(), Comparator.naturalOrder(),
Flux.just(1), Flux.just(2))
Expand All @@ -414,6 +421,7 @@ public void normal1() {
}

@Test
@SuppressWarnings("unchecked") //safe varargs
public void normal2() {
new FluxMergeOrdered<>(2, Queues.small(), Comparator.naturalOrder(),
Flux.just(1, 3, 5, 7), Flux.just(2, 4, 6, 8))
Expand All @@ -423,6 +431,7 @@ public void normal2() {
}

@Test
@SuppressWarnings("unchecked") //safe varargs
public void normal3() {
new FluxMergeOrdered<>(2, Queues.small(), Comparator.naturalOrder(),
Flux.just(1, 3, 5, 7), Flux.just(2, 4, 6))
Expand All @@ -432,6 +441,7 @@ public void normal3() {
}

@Test
@SuppressWarnings("unchecked") //safe varargs
public void normal4() {
new FluxMergeOrdered<>(2, Queues.small(), Comparator.naturalOrder(),
Flux.just(1, 3, 5, 7), Flux.just(1, 3, 5, 7))
Expand All @@ -441,6 +451,7 @@ public void normal4() {
}

@Test
@SuppressWarnings("unchecked") //safe varargs
public void normal1Hidden() {
new FluxMergeOrdered<>(2, Queues.small(), Comparator.naturalOrder(),
Flux.just(1).hide(), Flux.just(2).hide())
Expand All @@ -450,6 +461,7 @@ public void normal1Hidden() {
}

@Test
@SuppressWarnings("unchecked") //safe varargs
public void normal2Hidden() {
new FluxMergeOrdered<>(2, Queues.small(), Comparator.naturalOrder(),
Flux.just(1, 3, 5, 7).hide(), Flux.just(2, 4, 6, 8).hide())
Expand All @@ -459,6 +471,7 @@ public void normal2Hidden() {
}

@Test
@SuppressWarnings("unchecked") //safe varargs
public void normal3Hidden() {
new FluxMergeOrdered<>(2, Queues.small(), Comparator.naturalOrder(),
Flux.just(1, 3, 5, 7).hide(), Flux.just(2, 4, 6).hide())
Expand All @@ -468,6 +481,7 @@ public void normal3Hidden() {
}

@Test
@SuppressWarnings("unchecked") //safe varargs
public void normal4Hidden() {
new FluxMergeOrdered<>(2, Queues.small(), Comparator.naturalOrder(),
Flux.just(1, 3, 5, 7).hide(), Flux.just(1, 3, 5, 7).hide())
Expand All @@ -477,6 +491,7 @@ public void normal4Hidden() {
}

@Test
@SuppressWarnings("unchecked") //safe varargs
public void backpressure1() {
new FluxMergeOrdered<>(2, Queues.small(), Comparator.naturalOrder(),
Flux.just(1, 3, 5, 7), Flux.just(2, 4, 6, 8))
Expand All @@ -487,6 +502,7 @@ public void backpressure1() {
}

@Test
@SuppressWarnings("unchecked") //safe varargs
public void backpressure2() {
new FluxMergeOrdered<>(2, Queues.small(), Comparator.naturalOrder(),
Flux.just(1), Flux.just(2))
Expand All @@ -497,6 +513,7 @@ public void backpressure2() {
}

@Test
@SuppressWarnings("unchecked") //safe varargs
public void backpressure3() {
new FluxMergeOrdered<>(1, Queues.small(), Comparator.naturalOrder(),
Flux.just(1, 3, 5, 7), Flux.just(2, 4, 6, 8))
Expand All @@ -507,6 +524,7 @@ public void backpressure3() {
}

@Test
@SuppressWarnings("unchecked") //safe varargs
public void take() {
new FluxMergeOrdered<>(2, Queues.small(), Comparator.naturalOrder(),
Flux.just(1, 3, 5, 7), Flux.just(2, 4, 6, 8))
Expand All @@ -517,6 +535,7 @@ public void take() {
}

@Test
@SuppressWarnings("unchecked") //safe varargs
public void firstErrorsDelayed() {
new FluxMergeOrdered<>(2, Queues.small(), Comparator.naturalOrder(),
Flux.error(new IOException("boom")),
Expand All @@ -527,6 +546,7 @@ public void firstErrorsDelayed() {
}

@Test
@SuppressWarnings("unchecked") //safe varargs
public void firstErrorsBackpressuredDelayed() {
new FluxMergeOrdered<>(2, Queues.small(), Comparator.naturalOrder(),
Flux.error(new IOException("boom")),
Expand All @@ -538,6 +558,7 @@ public void firstErrorsBackpressuredDelayed() {
}

@Test
@SuppressWarnings("unchecked") //safe varargs
public void secondErrorsDelayed() {
new FluxMergeOrdered<>(2, Queues.small(), Comparator.naturalOrder(),
Flux.just(1, 3, 5, 7),
Expand All @@ -549,6 +570,7 @@ public void secondErrorsDelayed() {
}

@Test
@SuppressWarnings("unchecked") //safe varargs
public void secondErrorsBackpressuredDelayed() {
new FluxMergeOrdered<>(2, Queues.small(), Comparator.naturalOrder(),
Flux.just(1, 3, 5, 7),
Expand Down Expand Up @@ -584,6 +606,7 @@ public void never() {
}

@Test
@SuppressWarnings("unchecked") //safe varargs
public void fusedThrowsInDrainLoopDelayed() {
new FluxMergeOrdered<>(2, Queues.small(), Comparator.naturalOrder(),
Flux.just(1).map(v -> { throw new IllegalArgumentException("boom"); }),
Expand All @@ -594,6 +617,7 @@ public void fusedThrowsInDrainLoopDelayed() {
}

@Test
@SuppressWarnings("unchecked") //safe varargs
public void fusedThrowsInPostEmissionCheckDelayed() {
new FluxMergeOrdered<>(2, Queues.small(), Comparator.naturalOrder(),
Flux.just(1).map(v -> { throw new IllegalArgumentException("boom"); }),
Expand All @@ -605,6 +629,7 @@ public void fusedThrowsInPostEmissionCheckDelayed() {
}

@Test
@SuppressWarnings("unchecked") //safe varargs
public void nullSecond() {
FluxMergeOrdered<Integer> test = new FluxMergeOrdered<>(2, Queues.small(),
Comparator.naturalOrder(),
Expand All @@ -615,6 +640,7 @@ public void nullSecond() {
}

@Test
@SuppressWarnings("unchecked") //safe varargs
public void nullFirst() {
FluxMergeOrdered<Integer> test = new FluxMergeOrdered<>(2, Queues.small(),
Comparator.naturalOrder(),
Expand All @@ -625,6 +651,7 @@ public void nullFirst() {
}

@Test
@SuppressWarnings("unchecked") //safe varargs
public void comparatorThrows() {
new FluxMergeOrdered<>(2, Queues.small(),
(a, b) -> { throw new IllegalArgumentException("boom"); },
Expand All @@ -634,6 +661,7 @@ public void comparatorThrows() {
}

@Test
@SuppressWarnings("unchecked") //safe varargs
public void naturalOrder() {
new FluxMergeOrdered<>(2, Queues.small(), Comparator.naturalOrder(),
Flux.just(1), Flux.just(2))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.util.HashSet;
import java.util.Set;
import java.util.stream.Stream;

import org.junit.Test;
import reactor.core.Scannable;
Expand All @@ -44,8 +45,9 @@ public void scanOperator() throws Exception {

assertThat(test.scan(Scannable.Attr.NAME)).isEqualTo("foo");

//noinspection unchecked
assertThat(test.scan(Scannable.Attr.TAGS)).containsExactlyInAnyOrder(tag1, tag2);
final Stream<Tuple2<String, String>> scannedTags = test.scan(Scannable.Attr.TAGS);
assertThat(scannedTags).isNotNull();
assertThat(scannedTags.iterator()).containsExactlyInAnyOrder(tag1, tag2);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ public void scanOperator() {
@Test
public void scanSubscriber() {
CoreSubscriber<String> actual = new LambdaSubscriber<>(null, null, null, null);
BackpressureBufferTimeoutSubscriber test = new BackpressureBufferTimeoutSubscriber<>(actual, Duration.ofSeconds(1), Schedulers.immediate(), 123, v -> {});
BackpressureBufferTimeoutSubscriber<String> test = new BackpressureBufferTimeoutSubscriber<>(actual, Duration.ofSeconds(1), Schedulers.immediate(), 123, v -> {});
Subscription s = Operators.emptySubscription();
test.onSubscribe(s);

Expand Down
Loading

0 comments on commit 63debe7

Please sign in to comment.