Skip to content

Commit

Permalink
Rewerite identification tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cernat-catalin committed Aug 18, 2022
1 parent c32456e commit 57bf773
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,10 @@ public final class NonEmptyMono extends BugChecker implements MethodInvocationTr
"collectMultimap",
"collectSortedList",
"count",
"defaultIfEmpty",
"elementAt",
"hasElement",
"hasElements",
"last",
"reduce",
"reduceWith",
"single"),
instanceMethod()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,91 +28,37 @@ void identification() {
"class A {",
" void m() {",
" // BUG: Diagnostic contains:",
" Flux.just().collect(toImmutableList()).single();",
" Flux.just().all(x -> true).defaultIfEmpty(true);",
" // BUG: Diagnostic contains:",
" Flux.just().collect(toImmutableList()).defaultIfEmpty(ImmutableList.of());",
" // BUG: Diagnostic contains:",
" Flux.just().collect(toImmutableList()).switchIfEmpty(Mono.just(ImmutableList.of()));",
" Flux.just().any(x -> true).single();",
"",
" // BUG: Diagnostic contains:",
" Flux.just().collect(ImmutableList::of, (list, item) -> {}).single();",
" // BUG: Diagnostic contains:",
" Flux.just().collect(ImmutableList::of, (list, item) -> {}).defaultIfEmpty(ImmutableList.of());",
" Flux.just()",
" .collect(ImmutableList::of, (list, item) -> {})",
" // BUG: Diagnostic contains:",
" .switchIfEmpty(Mono.just(ImmutableList.of()));",
"",
" // BUG: Diagnostic contains:",
" Flux.just().collectList().single();",
" Flux.just().collect(toImmutableList()).switchIfEmpty(Mono.just(ImmutableList.of()));",
" // BUG: Diagnostic contains:",
" Flux.just().collectList().defaultIfEmpty(ImmutableList.of());",
" // BUG: Diagnostic contains:",
" Flux.just().collectList().switchIfEmpty(Mono.just(ImmutableList.of()));",
"",
" // BUG: Diagnostic contains:",
" Flux.just().collectSortedList().single();",
" // BUG: Diagnostic contains:",
" Flux.just().collectSortedList().defaultIfEmpty(ImmutableList.of());",
" // BUG: Diagnostic contains:",
" Flux.just().collectSortedList().switchIfEmpty(Mono.just(ImmutableList.of()));",
"",
" // BUG: Diagnostic contains:",
" Flux.just().collectSortedList((o1, o2) -> 1).single();",
" // BUG: Diagnostic contains:",
" Flux.just().collectSortedList((o1, o2) -> 1).defaultIfEmpty(ImmutableList.of());",
" // BUG: Diagnostic contains:",
" Flux.just().collectSortedList((o1, o2) -> 1).switchIfEmpty(Mono.just(ImmutableList.of()));",
"",
" // BUG: Diagnostic contains:",
" Flux.just().collectMap(identity()).single();",
" // BUG: Diagnostic contains:",
" Flux.just().collectMap(identity()).defaultIfEmpty(ImmutableMap.of());",
" // BUG: Diagnostic contains:",
" Flux.just().collectMap(identity()).switchIfEmpty(Mono.just(ImmutableMap.of()));",
"",
" // BUG: Diagnostic contains:",
" Flux.just().collectMap(identity(), identity()).single();",
" // BUG: Diagnostic contains:",
" Flux.just().collectMap(identity(), identity()).defaultIfEmpty(ImmutableMap.of());",
" // BUG: Diagnostic contains:",
" Flux.just().collectMap(identity(), identity()).switchIfEmpty(Mono.just(ImmutableMap.of()));",
"",
" // BUG: Diagnostic contains:",
" Flux.just().collectMap(identity(), identity(), ImmutableMap::of).single();",
" Flux.just()",
" .collectMap(identity(), identity(), ImmutableMap::of)",
" // BUG: Diagnostic contains:",
" .defaultIfEmpty(ImmutableMap.of());",
" Flux.just()",
" .collectMap(identity(), identity(), ImmutableMap::of)",
" .collectMultimap(identity(), identity(), ImmutableMap::of)",
" // BUG: Diagnostic contains:",
" .switchIfEmpty(Mono.just(ImmutableMap.of()));",
" // BUG: Diagnostic contains:",
" Flux.just().collectSortedList((o1, o2) -> 1).defaultIfEmpty(ImmutableList.of());",
"",
" // BUG: Diagnostic contains:",
" Flux.just().collectMultimap(identity()).single();",
" Flux.just().count().single();",
" // BUG: Diagnostic contains:",
" Flux.just().collectMultimap(identity()).defaultIfEmpty(ImmutableMap.of());",
" Flux.just().elementAt(0).defaultIfEmpty(1);",
" // BUG: Diagnostic contains:",
" Flux.just().collectMultimap(identity()).switchIfEmpty(Mono.just(ImmutableMap.of()));",
"",
" Flux.just().hasElement(0).single();",
" // BUG: Diagnostic contains:",
" Flux.just().collectMultimap(identity(), identity()).single();",
" Flux.just().hasElements().switchIfEmpty(Mono.just(true));",
" // BUG: Diagnostic contains:",
" Flux.just().collectMultimap(identity(), identity()).defaultIfEmpty(ImmutableMap.of());",
" Flux.just().last().defaultIfEmpty(1);",
" // BUG: Diagnostic contains:",
" Flux.just().collectMultimap(identity(), identity()).switchIfEmpty(Mono.just(ImmutableMap.of()));",
"",
" Flux.just().reduceWith(() -> 1, (x, y) -> x).single();",
" // BUG: Diagnostic contains:",
" Flux.just().collectMultimap(identity(), identity(), ImmutableMap::of).single();",
" Flux.just()",
" .collectMultimap(identity(), identity(), ImmutableMap::of)",
" // BUG: Diagnostic contains:",
" .defaultIfEmpty(ImmutableMap.of());",
" Flux.just()",
" .collectMultimap(identity(), identity(), ImmutableMap::of)",
" // BUG: Diagnostic contains:",
" .switchIfEmpty(Mono.just(ImmutableMap.of()));",
" Flux.just().single().switchIfEmpty(Mono.just(1));",
" }",
"}")
.doTest();
Expand Down

0 comments on commit 57bf773

Please sign in to comment.