From 072085fb716d39aeecda0ca149ee7648f435f36a Mon Sep 17 00:00:00 2001 From: cpovirk Date: Mon, 24 Jan 2022 06:18:45 -0800 Subject: [PATCH] Migrate test input from containsAllIn to its replacement, containsAtLeastElementsIn. containsAllIn hasn't existed since 2019. It's interesting that this test apparently still worked. Refaster must be faily permissive? It's also interesting that this change... breaks the test? Maybe the workaround from CL 78788806 stopped working at some point, but it was after 2019, so we didn't notice? (discovered during https://github.com/google/error-prone/issues/2882#issuecomment-1020061293) PiperOrigin-RevId: 423797769 --- .../testdata/input/WildcardUnificationTemplateExample.java | 3 ++- .../testdata/output/WildcardUnificationTemplateExample.java | 3 ++- .../testdata/template/WildcardUnificationTemplate.java | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/src/test/java/com/google/errorprone/refaster/testdata/input/WildcardUnificationTemplateExample.java b/core/src/test/java/com/google/errorprone/refaster/testdata/input/WildcardUnificationTemplateExample.java index e1e422817771..5f5838061334 100644 --- a/core/src/test/java/com/google/errorprone/refaster/testdata/input/WildcardUnificationTemplateExample.java +++ b/core/src/test/java/com/google/errorprone/refaster/testdata/input/WildcardUnificationTemplateExample.java @@ -27,9 +27,10 @@ */ public class WildcardUnificationTemplateExample { public void example() { + // BUG: The template should remove the hasSize call below! ImmutableList actual = ImmutableList.of("kurt", "kluever"); ImmutableList expected = ImmutableList.of("kluever", "kurt"); assertThat(actual).hasSize(expected.size()); - assertThat(actual).containsAllIn(expected); + assertThat(actual).containsExactlyElementsIn(expected); } } diff --git a/core/src/test/java/com/google/errorprone/refaster/testdata/output/WildcardUnificationTemplateExample.java b/core/src/test/java/com/google/errorprone/refaster/testdata/output/WildcardUnificationTemplateExample.java index 002e818a4a1e..5f5838061334 100644 --- a/core/src/test/java/com/google/errorprone/refaster/testdata/output/WildcardUnificationTemplateExample.java +++ b/core/src/test/java/com/google/errorprone/refaster/testdata/output/WildcardUnificationTemplateExample.java @@ -27,9 +27,10 @@ */ public class WildcardUnificationTemplateExample { public void example() { + // BUG: The template should remove the hasSize call below! ImmutableList actual = ImmutableList.of("kurt", "kluever"); ImmutableList expected = ImmutableList.of("kluever", "kurt"); + assertThat(actual).hasSize(expected.size()); assertThat(actual).containsExactlyElementsIn(expected); - } } diff --git a/core/src/test/java/com/google/errorprone/refaster/testdata/template/WildcardUnificationTemplate.java b/core/src/test/java/com/google/errorprone/refaster/testdata/template/WildcardUnificationTemplate.java index 83c44bcb6c4a..f0b379cc918e 100644 --- a/core/src/test/java/com/google/errorprone/refaster/testdata/template/WildcardUnificationTemplate.java +++ b/core/src/test/java/com/google/errorprone/refaster/testdata/template/WildcardUnificationTemplate.java @@ -30,7 +30,7 @@ public class WildcardUnificationTemplate { @BeforeTemplate static void containsAllOf(IterableSubject subject, Collection expected) { subject.hasSize(expected.size()); - subject.containsAllIn(expected); + subject.containsAtLeastElementsIn(expected); } @AfterTemplate