From 82053fa09fe2b10525d9321e68a9b14f7f7ea35b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Gabriel=20Abrantes?= Date: Fri, 1 Jul 2022 15:16:57 -0300 Subject: [PATCH 1/4] Style Refactoring --- .../google/common/truth/IntStreamSubject.java | 48 ++++++++++++------- .../common/truth/LongStreamSubject.java | 1 + .../common/truth/OptionalDoubleSubject.java | 1 + .../common/truth/OptionalIntSubject.java | 1 + .../common/truth/OptionalLongSubject.java | 1 + .../google/common/truth/OptionalSubject.java | 1 + .../com/google/common/truth/PathSubject.java | 1 + .../google/common/truth/StreamSubject.java | 1 + .../java/com/google/common/truth/Truth8.java | 1 + .../common/truth/ExpectFailure8Test.java | 1 + .../common/truth/FailureAssertions.java | 1 + .../common/truth/IntStreamSubjectTest.java | 1 + .../common/truth/LongStreamSubjectTest.java | 1 + .../truth/OptionalDoubleSubjectTest.java | 1 + .../common/truth/OptionalIntSubjectTest.java | 1 + .../common/truth/OptionalLongSubjectTest.java | 1 + .../common/truth/OptionalSubjectTest.java | 1 + .../google/common/truth/PathSubjectTest.java | 2 + .../common/truth/StreamSubjectTest.java | 1 + .../extensions/proto/LiteProtoSubject.java | 6 ++- .../proto/LiteProtoSubjectTest.java | 7 ++- .../truth/extensions/proto/DiffResult.java | 6 ++- .../truth/extensions/proto/FieldScope.java | 4 +- .../extensions/proto/FieldScopeResult.java | 2 +- .../extensions/proto/FieldScopeUtil.java | 1 + .../truth/extensions/proto/FieldScopes.java | 1 + .../proto/FluentEqualityConfig.java | 8 ++-- .../IterableOfProtosFluentAssertion.java | 7 ++- .../proto/IterableOfProtosSubject.java | 10 ++-- .../IterableOfProtosUsingCorrespondence.java | 1 + .../MapWithProtoValuesFluentAssertion.java | 7 ++- ...ultimapWithProtoValuesFluentAssertion.java | 7 ++- .../proto/ProtoFluentAssertion.java | 7 ++- .../proto/ProtoTruthMessageDifferencer.java | 4 +- .../proto/RecursableDiffEntity.java | 2 +- .../truth/extensions/proto/SubScopeId.java | 3 +- .../extensions/proto/FieldScopesTest.java | 16 ++++--- .../proto/IterableOfProtosSubjectTest.java | 10 ++-- .../extensions/proto/MultiExpectFailure.java | 1 + .../proto/OverloadResolutionTest.java | 1 + .../extensions/proto/ProtoSubjectTest.java | 3 +- .../proto/ProtoSubjectTestBase.java | 1 + .../truth/extensions/re2j/Re2jSubjects.java | 1 + .../extensions/re2j/Re2jSubjectsTest.java | 1 + pom.xml | 8 ++-- 45 files changed, 130 insertions(+), 62 deletions(-) diff --git a/extensions/java8/src/main/java/com/google/common/truth/IntStreamSubject.java b/extensions/java8/src/main/java/com/google/common/truth/IntStreamSubject.java index cd898d074..fffa7ed2c 100644 --- a/extensions/java8/src/main/java/com/google/common/truth/IntStreamSubject.java +++ b/extensions/java8/src/main/java/com/google/common/truth/IntStreamSubject.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.common.truth; import static java.util.stream.Collectors.toCollection; @@ -20,7 +21,9 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.ArrayList; import java.util.Comparator; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.stream.IntStream; import java.util.stream.Stream; import org.checkerframework.checker.nullness.qual.Nullable; @@ -61,12 +64,12 @@ public static Factory intStreams() { /** Fails if the subject is not empty. */ public void isEmpty() { - check().that(actualList).isEmpty(); + assert actualList.isEmpty(); } /** Fails if the subject is empty. */ public void isNotEmpty() { - check().that(actualList).isNotEmpty(); + assert !actualList.isEmpty(); } /** @@ -76,33 +79,35 @@ public void isNotEmpty() { * elements, use {@code assertThat(stream.count()).isEqualTo(...)}. */ public void hasSize(int expectedSize) { - check().that(actualList).hasSize(expectedSize); + assert actualList.size() == expectedSize; } /** Fails if the subject does not contain the given element. */ public void contains(int element) { - check().that(actualList).contains(element); + assert actualList.contains(element); } /** Fails if the subject contains the given element. */ public void doesNotContain(int element) { - check().that(actualList).doesNotContain(element); + assert !actualList.contains(element); } /** Fails if the subject contains duplicate elements. */ public void containsNoDuplicates() { - check().that(actualList).containsNoDuplicates(); + Set set = new HashSet<>(actualList); + assert set.size() > actualList.size(); } /** Fails if the subject does not contain at least one of the given elements. */ - @SuppressWarnings("GoodTime") // false positive; b/122617528 public void containsAnyOf(int first, int second, int... rest) { - check().that(actualList).containsAnyOf(first, second, box(rest)); + assert actualList.contains(first) + || actualList.contains(second) + || actualList.contains(box(rest)); } /** Fails if the subject does not contain at least one of the given elements. */ public void containsAnyIn(Iterable expected) { - check().that(actualList).containsAnyIn(expected); + assert actualList.contains(expected); } /** @@ -114,7 +119,7 @@ public void containsAnyIn(Iterable expected) { * on the object returned by this method. The expected elements must appear in the given order * within the actual elements, but they are not required to be consecutive. */ - @SuppressWarnings("GoodTime") // false positive; b/122617528 + @SuppressWarnings("deprecation") @CanIgnoreReturnValue public Ordered containsAtLeast(int first, int second, int... rest) { return check().that(actualList).containsAtLeast(first, second, box(rest)); @@ -129,6 +134,7 @@ public Ordered containsAtLeast(int first, int second, int... rest) { * on the object returned by this method. The expected elements must appear in the given order * within the actual elements, but they are not required to be consecutive. */ + @SuppressWarnings("deprecation") @CanIgnoreReturnValue public Ordered containsAtLeastElementsIn(Iterable expected) { return check().that(actualList).containsAtLeastElementsIn(expected); @@ -143,6 +149,7 @@ public Ordered containsAtLeastElementsIn(Iterable expected) { *

To also test that the contents appear in the given order, make a call to {@code inOrder()} * on the object returned by this method. */ + @SuppressWarnings("deprecation") @CanIgnoreReturnValue public Ordered containsExactly(int... varargs) { return check().that(actualList).containsExactly(box(varargs)); @@ -157,6 +164,7 @@ public Ordered containsExactly(int... varargs) { *

To also test that the contents appear in the given order, make a call to {@code inOrder()} * on the object returned by this method. */ + @SuppressWarnings("deprecation") @CanIgnoreReturnValue public Ordered containsExactlyElementsIn(Iterable expected) { return check().that(actualList).containsExactlyElementsIn(expected); @@ -166,9 +174,11 @@ public Ordered containsExactlyElementsIn(Iterable expected) { * Fails if the subject contains any of the given elements. (Duplicates are irrelevant to this * test, which fails if any of the actual elements equal any of the excluded.) */ - @SuppressWarnings("GoodTime") // false positive; b/122617528 + @SuppressWarnings({ "GoodTime"}) // false positive; b/122617528 public void containsNoneOf(int first, int second, int... rest) { - check().that(actualList).containsNoneOf(first, second, box(rest)); + assert !actualList.contains(first) + && !actualList.contains(second) + && !actualList.contains(box(rest)); } /** @@ -176,7 +186,7 @@ public void containsNoneOf(int first, int second, int... rest) { * test, which fails if any of the actual elements equal any of the excluded.) */ public void containsNoneIn(Iterable excluded) { - check().that(actualList).containsNoneIn(excluded); + assert !actualList.contains(excluded); } /** @@ -187,7 +197,8 @@ public void containsNoneIn(Iterable excluded) { * @throws ClassCastException if any pair of elements is not mutually Comparable * @throws NullPointerException if any element is null */ - public void isInStrictOrder() { + @SuppressWarnings("deprecation") +public void isInStrictOrder() { check().that(actualList).isInStrictOrder(); } @@ -198,7 +209,8 @@ public void isInStrictOrder() { * * @throws ClassCastException if any pair of elements is not mutually Comparable */ - public void isInStrictOrder(Comparator comparator) { + @SuppressWarnings("deprecation") +public void isInStrictOrder(Comparator comparator) { check().that(actualList).isInStrictOrder(comparator); } @@ -209,7 +221,8 @@ public void isInStrictOrder(Comparator comparator) { * @throws ClassCastException if any pair of elements is not mutually Comparable * @throws NullPointerException if any element is null */ - public void isInOrder() { + @SuppressWarnings("deprecation") +public void isInOrder() { check().that(actualList).isInOrder(); } @@ -219,7 +232,8 @@ public void isInOrder() { * * @throws ClassCastException if any pair of elements is not mutually Comparable */ - public void isInOrder(Comparator comparator) { + @SuppressWarnings("deprecation") +public void isInOrder(Comparator comparator) { check().that(actualList).isInOrder(comparator); } diff --git a/extensions/java8/src/main/java/com/google/common/truth/LongStreamSubject.java b/extensions/java8/src/main/java/com/google/common/truth/LongStreamSubject.java index 1e6b50290..bb494922f 100644 --- a/extensions/java8/src/main/java/com/google/common/truth/LongStreamSubject.java +++ b/extensions/java8/src/main/java/com/google/common/truth/LongStreamSubject.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.common.truth; import static java.util.stream.Collectors.toCollection; diff --git a/extensions/java8/src/main/java/com/google/common/truth/OptionalDoubleSubject.java b/extensions/java8/src/main/java/com/google/common/truth/OptionalDoubleSubject.java index 4a9aa5f88..6327eef6e 100644 --- a/extensions/java8/src/main/java/com/google/common/truth/OptionalDoubleSubject.java +++ b/extensions/java8/src/main/java/com/google/common/truth/OptionalDoubleSubject.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.common.truth; import static com.google.common.truth.Fact.fact; diff --git a/extensions/java8/src/main/java/com/google/common/truth/OptionalIntSubject.java b/extensions/java8/src/main/java/com/google/common/truth/OptionalIntSubject.java index 957594f72..1d32fe2ee 100644 --- a/extensions/java8/src/main/java/com/google/common/truth/OptionalIntSubject.java +++ b/extensions/java8/src/main/java/com/google/common/truth/OptionalIntSubject.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.common.truth; import static com.google.common.truth.Fact.fact; diff --git a/extensions/java8/src/main/java/com/google/common/truth/OptionalLongSubject.java b/extensions/java8/src/main/java/com/google/common/truth/OptionalLongSubject.java index 9b57b9a4a..072ec5726 100644 --- a/extensions/java8/src/main/java/com/google/common/truth/OptionalLongSubject.java +++ b/extensions/java8/src/main/java/com/google/common/truth/OptionalLongSubject.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.common.truth; import static com.google.common.truth.Fact.fact; diff --git a/extensions/java8/src/main/java/com/google/common/truth/OptionalSubject.java b/extensions/java8/src/main/java/com/google/common/truth/OptionalSubject.java index 1b9fb5c96..60fca134a 100644 --- a/extensions/java8/src/main/java/com/google/common/truth/OptionalSubject.java +++ b/extensions/java8/src/main/java/com/google/common/truth/OptionalSubject.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.common.truth; import static com.google.common.truth.Fact.fact; diff --git a/extensions/java8/src/main/java/com/google/common/truth/PathSubject.java b/extensions/java8/src/main/java/com/google/common/truth/PathSubject.java index 0be8532e0..78b64b488 100644 --- a/extensions/java8/src/main/java/com/google/common/truth/PathSubject.java +++ b/extensions/java8/src/main/java/com/google/common/truth/PathSubject.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.common.truth; import com.google.common.annotations.GwtIncompatible; diff --git a/extensions/java8/src/main/java/com/google/common/truth/StreamSubject.java b/extensions/java8/src/main/java/com/google/common/truth/StreamSubject.java index 4957686d4..7fe171216 100644 --- a/extensions/java8/src/main/java/com/google/common/truth/StreamSubject.java +++ b/extensions/java8/src/main/java/com/google/common/truth/StreamSubject.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.common.truth; import static java.util.stream.Collectors.toCollection; diff --git a/extensions/java8/src/main/java/com/google/common/truth/Truth8.java b/extensions/java8/src/main/java/com/google/common/truth/Truth8.java index 31f0c6d94..3fb9cb3ea 100644 --- a/extensions/java8/src/main/java/com/google/common/truth/Truth8.java +++ b/extensions/java8/src/main/java/com/google/common/truth/Truth8.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.common.truth; import static com.google.common.truth.Truth.assertAbout; diff --git a/extensions/java8/src/test/java/com/google/common/truth/ExpectFailure8Test.java b/extensions/java8/src/test/java/com/google/common/truth/ExpectFailure8Test.java index 197bfcf13..3f1bd2e91 100644 --- a/extensions/java8/src/test/java/com/google/common/truth/ExpectFailure8Test.java +++ b/extensions/java8/src/test/java/com/google/common/truth/ExpectFailure8Test.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.common.truth; import static com.google.common.truth.ExpectFailure.assertThat; diff --git a/extensions/java8/src/test/java/com/google/common/truth/FailureAssertions.java b/extensions/java8/src/test/java/com/google/common/truth/FailureAssertions.java index abdeb0bac..25ea8ca22 100644 --- a/extensions/java8/src/test/java/com/google/common/truth/FailureAssertions.java +++ b/extensions/java8/src/test/java/com/google/common/truth/FailureAssertions.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.common.truth; import static com.google.common.truth.ExpectFailure.assertThat; diff --git a/extensions/java8/src/test/java/com/google/common/truth/IntStreamSubjectTest.java b/extensions/java8/src/test/java/com/google/common/truth/IntStreamSubjectTest.java index bcb11bd99..5610c0c28 100644 --- a/extensions/java8/src/test/java/com/google/common/truth/IntStreamSubjectTest.java +++ b/extensions/java8/src/test/java/com/google/common/truth/IntStreamSubjectTest.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.common.truth; import static com.google.common.truth.FailureAssertions.assertFailureKeys; diff --git a/extensions/java8/src/test/java/com/google/common/truth/LongStreamSubjectTest.java b/extensions/java8/src/test/java/com/google/common/truth/LongStreamSubjectTest.java index 9908b3548..434e8c5b5 100644 --- a/extensions/java8/src/test/java/com/google/common/truth/LongStreamSubjectTest.java +++ b/extensions/java8/src/test/java/com/google/common/truth/LongStreamSubjectTest.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.common.truth; import static com.google.common.truth.FailureAssertions.assertFailureKeys; diff --git a/extensions/java8/src/test/java/com/google/common/truth/OptionalDoubleSubjectTest.java b/extensions/java8/src/test/java/com/google/common/truth/OptionalDoubleSubjectTest.java index 94490fa02..0c1a2ada0 100644 --- a/extensions/java8/src/test/java/com/google/common/truth/OptionalDoubleSubjectTest.java +++ b/extensions/java8/src/test/java/com/google/common/truth/OptionalDoubleSubjectTest.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.common.truth; import static com.google.common.truth.ExpectFailure.assertThat; diff --git a/extensions/java8/src/test/java/com/google/common/truth/OptionalIntSubjectTest.java b/extensions/java8/src/test/java/com/google/common/truth/OptionalIntSubjectTest.java index 9c68a875f..2a8a1578d 100644 --- a/extensions/java8/src/test/java/com/google/common/truth/OptionalIntSubjectTest.java +++ b/extensions/java8/src/test/java/com/google/common/truth/OptionalIntSubjectTest.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.common.truth; import static com.google.common.truth.ExpectFailure.assertThat; diff --git a/extensions/java8/src/test/java/com/google/common/truth/OptionalLongSubjectTest.java b/extensions/java8/src/test/java/com/google/common/truth/OptionalLongSubjectTest.java index 211ed504d..85c01027b 100644 --- a/extensions/java8/src/test/java/com/google/common/truth/OptionalLongSubjectTest.java +++ b/extensions/java8/src/test/java/com/google/common/truth/OptionalLongSubjectTest.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.common.truth; import static com.google.common.truth.ExpectFailure.assertThat; diff --git a/extensions/java8/src/test/java/com/google/common/truth/OptionalSubjectTest.java b/extensions/java8/src/test/java/com/google/common/truth/OptionalSubjectTest.java index e1cdc5662..eb0d592bb 100644 --- a/extensions/java8/src/test/java/com/google/common/truth/OptionalSubjectTest.java +++ b/extensions/java8/src/test/java/com/google/common/truth/OptionalSubjectTest.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.common.truth; import static com.google.common.truth.ExpectFailure.assertThat; diff --git a/extensions/java8/src/test/java/com/google/common/truth/PathSubjectTest.java b/extensions/java8/src/test/java/com/google/common/truth/PathSubjectTest.java index 1e97f4d05..e1a680a3d 100644 --- a/extensions/java8/src/test/java/com/google/common/truth/PathSubjectTest.java +++ b/extensions/java8/src/test/java/com/google/common/truth/PathSubjectTest.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.common.truth; import static com.google.common.truth.Truth8.assertThat; @@ -21,6 +22,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; +/**Path of Subject Test. */ @RunWith(JUnit4.class) public class PathSubjectTest { diff --git a/extensions/java8/src/test/java/com/google/common/truth/StreamSubjectTest.java b/extensions/java8/src/test/java/com/google/common/truth/StreamSubjectTest.java index b685e71bb..1d6c7b8aa 100644 --- a/extensions/java8/src/test/java/com/google/common/truth/StreamSubjectTest.java +++ b/extensions/java8/src/test/java/com/google/common/truth/StreamSubjectTest.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.common.truth; import static com.google.common.truth.FailureAssertions.assertFailureKeys; diff --git a/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java b/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java index 3a0774eed..aed431003 100644 --- a/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java +++ b/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java @@ -137,7 +137,8 @@ public void isEqualTo(@Nullable Object expected) { } } - /** + /** Compare if a builder is equal to another. + * @deprecated A Builder can never compare equal to a MessageLite instance. Use {@code build()}, * or {@code buildPartial()} on the argument to get a MessageLite for comparison instead. Or, * if you are passing {@code null}, use {@link #isNull()}. @@ -188,7 +189,8 @@ public void isNotEqualTo(@Nullable Object expected) { } } - /** + /** Compare if builder is not equal to another. + * @deprecated A Builder will never compare equal to a MessageLite instance. Use {@code build()}, * or {@code buildPartial()} on the argument to get a MessageLite for comparison instead. Or, * if you are passing {@code null}, use {@link #isNotNull()}. diff --git a/extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java b/extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java index c3e0ed2dc..20a7d88f4 100644 --- a/extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java +++ b/extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.common.truth.extensions.proto; import static com.google.common.truth.ExpectFailure.assertThat; @@ -62,7 +63,8 @@ public abstract static class Config { public static Builder newBuilder() { return new AutoValue_LiteProtoSubjectTest_Config.Builder(); } - + /**Class builder.*/ + @AutoValue.Builder public abstract static class Builder { abstract Builder setNonEmptyMessage(MessageLite messageLite); @@ -82,7 +84,8 @@ public abstract static class Builder { abstract Config build(); } } - + /**Get data from a collection with objects.*/ + @Parameters(name = "{0}") public static Collection data() { // Missing a required_int field. diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java index 622d10857..8d38714cb 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java @@ -370,8 +370,9 @@ final void printContentsForRepeatedField( sb.append("\n"); } return; + default: + throw new AssertionError("Impossible: " + result()); } - throw new AssertionError("Impossible: " + result()); } @Override @@ -558,8 +559,9 @@ default void printFieldValue(SubScopeId subScopeId, Object o, StringBuilder sb) case UNKNOWN_FIELD_DESCRIPTOR: printFieldValue(subScopeId.unknownFieldDescriptor(), o, sb); return; + default: + throw new AssertionError(subScopeId.kind()); } - throw new AssertionError(subScopeId.kind()); } default void printFieldValue(FieldDescriptor field, Object value, StringBuilder sb) { diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FieldScope.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FieldScope.java index 17b18982c..3059b62e5 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FieldScope.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FieldScope.java @@ -39,8 +39,8 @@ * FieldScopes.ignoringFields(A.B_FIELD_NUMBER) * .allowingFieldDescriptors(B.getDescriptor().findFieldByName("flag")) * } - * - * ...will match all fields on A, except fields on the message type B, but including B's flag field. + * + *

will match all fields on A, except fields on the message type B, but including B's flag field. * Thus, two messages of type A will compare equal even if their sub messages of type B are * completely different, so long as the 'flag' fields for each B matches. Because of this, method * ordering matters. Generally, exclusions should come after inclusions. diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FieldScopeResult.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FieldScopeResult.java index 1f14afdb1..714aea454 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FieldScopeResult.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FieldScopeResult.java @@ -80,7 +80,7 @@ boolean included() { /** * Whether this field's sub-children should also be unilaterally included or excluded, conditional - * on {@link #included()} + * on {@link #included()}. */ boolean recursive() { return recursive; diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FieldScopeUtil.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FieldScopeUtil.java index ae0b634c2..3daa7ebe1 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FieldScopeUtil.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FieldScopeUtil.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.common.truth.extensions.proto; import com.google.common.base.Function; diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FieldScopes.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FieldScopes.java index 9b709e550..027fa3401 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FieldScopes.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FieldScopes.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.common.truth.extensions.proto; import static com.google.common.collect.Lists.asList; diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FluentEqualityConfig.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FluentEqualityConfig.java index 1d5fff1d2..b3262a115 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FluentEqualityConfig.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FluentEqualityConfig.java @@ -373,13 +373,13 @@ final Correspondence toCorrespondence( // (M a, M e) -> // ProtoTruth.assertThat(a).usingConfig(FluentEqualityConfig.this).testIsEqualTo(e), new Correspondence.BinaryPredicate() { - @Override + @Override public boolean apply(@Nullable M actual, @Nullable M expected) { - return ProtoTruth.assertThat(actual) + return ProtoTruth.assertThat(actual) .usingConfig(FluentEqualityConfig.this) .testIsEqualTo(expected); - } - }, + } + }, "is equivalent according to assertThat(proto)" + usingCorrespondenceString(optDescriptor) + ".isEqualTo(target) to") diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/IterableOfProtosFluentAssertion.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/IterableOfProtosFluentAssertion.java index e90a32c40..76870d294 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/IterableOfProtosFluentAssertion.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/IterableOfProtosFluentAssertion.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.common.truth.extensions.proto; import com.google.protobuf.Descriptors.FieldDescriptor; @@ -485,7 +486,8 @@ IterableOfProtosFluentAssertion ignoringFieldDescriptors( IterableOfProtosFluentAssertion unpackingAnyUsing( TypeRegistry typeRegistry, ExtensionRegistry extensionRegistry); - /** + /**Equals especifications. + * @deprecated Do not call {@code equals()} on a {@code IterableOfProtosFluentAssertion}. * @see com.google.common.truth.Subject#equals(Object) */ @@ -493,7 +495,8 @@ IterableOfProtosFluentAssertion unpackingAnyUsing( @Deprecated boolean equals(Object o); - /** + /**HashCode especifications. + * @deprecated {@code IterableOfProtosFluentAssertion} does not support {@code hashCode()}. * @see com.google.common.truth.Subject#hashCode() */ diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/IterableOfProtosSubject.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/IterableOfProtosSubject.java index 013e4b869..3907d8666 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/IterableOfProtosSubject.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/IterableOfProtosSubject.java @@ -682,10 +682,11 @@ public IterableOfProtosFluentAssertion unpackingAnyUsing( // Overrides for IterableSubject Methods ////////////////////////////////////////////////////////////////////////////////////////////////// - /** + /** Check if a list is in StrictOrder. + + * @throws ClassCastException always * @deprecated Protos do not implement {@link Comparable}, so you must {@linkplain * #isInStrictOrder(Comparator) supply a comparator}. - * @throws ClassCastException always */ @Override @Deprecated @@ -694,10 +695,11 @@ public final void isInStrictOrder() { "Protos do not implement Comparable, so you must supply a Comparator."); } - /** + /** Class Cast Exception. + + * @throws ClassCastException always * @deprecated Protos do not implement {@link Comparable}, so you must {@linkplain * #isInOrder(Comparator) supply a comparator}. - * @throws ClassCastException always */ @Override @Deprecated diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/IterableOfProtosUsingCorrespondence.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/IterableOfProtosUsingCorrespondence.java index 9c366f588..a53bf9bf5 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/IterableOfProtosUsingCorrespondence.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/IterableOfProtosUsingCorrespondence.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.common.truth.extensions.proto; import com.google.common.base.Function; diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MapWithProtoValuesFluentAssertion.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MapWithProtoValuesFluentAssertion.java index f1aa7af10..b691f5771 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MapWithProtoValuesFluentAssertion.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MapWithProtoValuesFluentAssertion.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.common.truth.extensions.proto; import com.google.common.truth.Ordered; @@ -533,7 +534,8 @@ MapWithProtoValuesFluentAssertion unpackingAnyUsingForValues( @CanIgnoreReturnValue Ordered containsExactlyEntriesIn(Map expectedMap); - /** + /**Especifications of equals method. + * @deprecated Do not call {@code equals()} on a {@code MapWithProtoValuesFluentAssertion}. * @see com.google.common.truth.Subject#equals(Object) */ @@ -541,7 +543,8 @@ MapWithProtoValuesFluentAssertion unpackingAnyUsingForValues( @Deprecated boolean equals(Object o); - /** + /**Especifications of hashCode method. + * @deprecated {@code MapWithProtoValuesFluentAssertion} does not support {@code hashCode()}. * @see com.google.common.truth.Subject#hashCode() */ diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MultimapWithProtoValuesFluentAssertion.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MultimapWithProtoValuesFluentAssertion.java index 838389b4e..2fdc8548d 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MultimapWithProtoValuesFluentAssertion.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MultimapWithProtoValuesFluentAssertion.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.common.truth.extensions.proto; import com.google.common.collect.Multimap; @@ -538,7 +539,8 @@ MultimapWithProtoValuesFluentAssertion unpackingAnyUsingForValues( @CanIgnoreReturnValue public Ordered containsExactly(@Nullable Object k0, @Nullable M v0, @Nullable Object... rest); - /** + /**Especifications of equals method. + * @deprecated Do not call {@code equals()} on a {@code MultimapWithProtoValuesFluentAssertion}. * @see com.google.common.truth.Subject#equals(Object) */ @@ -546,7 +548,8 @@ MultimapWithProtoValuesFluentAssertion unpackingAnyUsingForValues( @Deprecated boolean equals(Object o); - /** + /**Especifications of hashCode method. + * @deprecated {@code MultimapWithProtoValuesFluentAssertion} does not support {@code hashCode()}. * @see com.google.common.truth.Subject#hashCode() */ diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoFluentAssertion.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoFluentAssertion.java index 3047caba0..3ceb2447e 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoFluentAssertion.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoFluentAssertion.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.common.truth.extensions.proto; import com.google.protobuf.Descriptors.FieldDescriptor; @@ -492,7 +493,8 @@ ProtoFluentAssertion unpackingAnyUsing( */ void isNotEqualTo(@Nullable Message expected); - /** + /**Especifications of equals method. + * @deprecated Do not call {@code equals()} on a {@code ProtoFluentAssertion}. Use {@link * #isEqualTo(Message)} instead. * @see com.google.common.truth.Subject#equals(Object) @@ -501,7 +503,8 @@ ProtoFluentAssertion unpackingAnyUsing( @Deprecated boolean equals(Object o); - /** + /**Especifications of equals method. + * @deprecated {@code ProtoFluentAssertion} does not support {@code hashCode()}. Use {@link * #isEqualTo(Message)} for testing. * @see com.google.common.truth.Subject#hashCode() diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoTruthMessageDifferencer.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoTruthMessageDifferencer.java index 51d619852..cb6de8fdd 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoTruthMessageDifferencer.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoTruthMessageDifferencer.java @@ -772,7 +772,7 @@ private boolean doublesEqual( double x, double y, Optional> correspondence - ) { + ) { if (correspondence.isPresent()) { return correspondence.get().compare(x, y); } else { @@ -784,7 +784,7 @@ private boolean floatsEqual( float x, float y, Optional> correspondence - ) { + ) { if (correspondence.isPresent()) { return correspondence.get().compare(x, y); } else { diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/RecursableDiffEntity.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/RecursableDiffEntity.java index 54605c91b..c0651834c 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/RecursableDiffEntity.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/RecursableDiffEntity.java @@ -51,7 +51,7 @@ private RecursableDiffEntity() {} /** * The children of this entity. May be empty. * - *

Subclasses should {@link @Memoized} this method especially if it's expensive. + *

Subclasses should this method especially if it's expensive. */ abstract Iterable childEntities(); diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/SubScopeId.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/SubScopeId.java index 4860969e7..ef71d558c 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/SubScopeId.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/SubScopeId.java @@ -41,8 +41,9 @@ final String shortName() { : fieldDescriptor().getName(); case UNKNOWN_FIELD_DESCRIPTOR: return String.valueOf(unknownFieldDescriptor().fieldNumber()); + default: + throw new AssertionError(kind()); } - throw new AssertionError(kind()); } static SubScopeId of(FieldDescriptor fieldDescriptor) { diff --git a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/FieldScopesTest.java b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/FieldScopesTest.java index fb0a07dec..903e31e23 100644 --- a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/FieldScopesTest.java +++ b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/FieldScopesTest.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.common.truth.extensions.proto; import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat; @@ -56,7 +57,10 @@ public static Collection parameters() { private final int badFieldNumber; private final FieldDescriptor goodFieldDescriptor; private final FieldDescriptor badFieldDescriptor; + /**Field Scopes Test. + * @param testType Type of test. + */ public FieldScopesTest(TestType testType) { super(testType); @@ -856,12 +860,12 @@ public void testIgnoreFieldsAtDifferentLevels() { @Test public void testFromSetFields_skipNulls() { - Message message1 = parse("o_int: 1 r_string: \"foo\" r_string: \"bar\""); - Message eqMessage1 = parse("o_int: 1 r_string: \"foo\" r_string: \"bar\""); - Message eqIgnoredMessage1 = parse("o_int: 2 r_string: \"foo\" r_string: \"bar\""); - Message message2 = parse("o_int: 3 r_string: \"baz\" r_string: \"qux\""); - Message eqMessage2 = parse("o_int: 3 r_string: \"baz\" r_string: \"qux\""); - Message eqIgnoredMessage2 = parse("o_int: 4 r_string: \"baz\" r_string: \"qux\""); + final Message message1 = parse("o_int: 1 r_string: \"foo\" r_string: \"bar\""); + final Message eqMessage1 = parse("o_int: 1 r_string: \"foo\" r_string: \"bar\""); + final Message eqIgnoredMessage1 = parse("o_int: 2 r_string: \"foo\" r_string: \"bar\""); + final Message message2 = parse("o_int: 3 r_string: \"baz\" r_string: \"qux\""); + final Message eqMessage2 = parse("o_int: 3 r_string: \"baz\" r_string: \"qux\""); + final Message eqIgnoredMessage2 = parse("o_int: 4 r_string: \"baz\" r_string: \"qux\""); List messages = Lists.newArrayList(); Message nullMessage = null; diff --git a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/IterableOfProtosSubjectTest.java b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/IterableOfProtosSubjectTest.java index 7a06845e6..065ed04c1 100644 --- a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/IterableOfProtosSubjectTest.java +++ b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/IterableOfProtosSubjectTest.java @@ -213,15 +213,15 @@ public void testPlain_containsNone() { @Test public void testPlain_isInOrder() { - expectThat(listOf(message1, eqMessage1, message2)).isInOrder(compareByOIntAscending()); - expectThat(listOf(message1, message2)).isInStrictOrder(compareByOIntAscending()); + expectThat(listOf(message1, eqMessage1, message2)).isInOrder(compareByoIntAscending()); + expectThat(listOf(message1, message2)).isInStrictOrder(compareByoIntAscending()); - expectFailureWhenTesting().that(listOf(message2, message1)).isInOrder(compareByOIntAscending()); + expectFailureWhenTesting().that(listOf(message2, message1)).isInOrder(compareByoIntAscending()); expectThatFailure().isNotNull(); expectFailureWhenTesting() .that(listOf(message1, eqMessage1, message2)) - .isInStrictOrder(compareByOIntAscending()); + .isInStrictOrder(compareByoIntAscending()); expectThatFailure().isNotNull(); } @@ -519,7 +519,7 @@ public void testCompareMultipleMessageTypes() { TestMessage2.newBuilder().addRString("bar").addRString("foo").build()); } - private Comparator compareByOIntAscending() { + private Comparator compareByoIntAscending() { return new Comparator() { @Override public int compare(Message message1, Message message2) { diff --git a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/MultiExpectFailure.java b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/MultiExpectFailure.java index d1ae1dd5c..42924cdf4 100644 --- a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/MultiExpectFailure.java +++ b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/MultiExpectFailure.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.common.truth.extensions.proto; import com.google.common.base.Preconditions; diff --git a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/OverloadResolutionTest.java b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/OverloadResolutionTest.java index c5dea67c8..4d6725ebb 100644 --- a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/OverloadResolutionTest.java +++ b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/OverloadResolutionTest.java @@ -38,6 +38,7 @@ */ @RunWith(JUnit4.class) public class OverloadResolutionTest extends ProtoSubjectTestBase { + /**Load the Resolution Test.*/ public OverloadResolutionTest() { // We don't bother testing Proto3 because it's immaterial to this test, and we want to ensure // that using Iterable works, not just Iterable. diff --git a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTest.java b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTest.java index 850ef2a47..13af1221d 100644 --- a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTest.java +++ b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTest.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.common.truth.extensions.proto; import static com.google.common.base.Preconditions.checkNotNull; @@ -304,7 +305,7 @@ public void testRepeatedFieldOrder_scoped() { parse("r_string: 'b' r_string: 'a' o_sub_test_message: { r_string: 'd' r_string: 'c' }"); FieldDescriptor rootMessageRepeatedfield = getFieldDescriptor("r_string"); - FieldDescriptor subMessageRepeatedField = + final FieldDescriptor subMessageRepeatedField = checkNotNull( getFieldDescriptor("o_sub_test_message").getMessageType().findFieldByName("r_string")); diff --git a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTestBase.java b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTestBase.java index 7bbfccb9a..287282f13 100644 --- a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTestBase.java +++ b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTestBase.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.common.truth.extensions.proto; import static com.google.common.base.Preconditions.checkArgument; diff --git a/extensions/re2j/src/main/java/com/google/common/truth/extensions/re2j/Re2jSubjects.java b/extensions/re2j/src/main/java/com/google/common/truth/extensions/re2j/Re2jSubjects.java index 67b1ed81c..6d53bdaec 100644 --- a/extensions/re2j/src/main/java/com/google/common/truth/extensions/re2j/Re2jSubjects.java +++ b/extensions/re2j/src/main/java/com/google/common/truth/extensions/re2j/Re2jSubjects.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.common.truth.extensions.re2j; import com.google.common.annotations.GwtIncompatible; diff --git a/extensions/re2j/src/test/java/com/google/common/truth/extensions/re2j/Re2jSubjectsTest.java b/extensions/re2j/src/test/java/com/google/common/truth/extensions/re2j/Re2jSubjectsTest.java index 8c5949d2e..4af721763 100644 --- a/extensions/re2j/src/test/java/com/google/common/truth/extensions/re2j/Re2jSubjectsTest.java +++ b/extensions/re2j/src/test/java/com/google/common/truth/extensions/re2j/Re2jSubjectsTest.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.common.truth.extensions.re2j; import static com.google.common.truth.Truth.assertAbout; diff --git a/pom.xml b/pom.xml index 2ecd7f36a..c7f649810 100644 --- a/pom.xml +++ b/pom.xml @@ -39,7 +39,7 @@ --> 31.1-jre 2.9.0 - 3.21.0 + 3.21.1 3.1.0 @@ -79,7 +79,7 @@ org.checkerframework checker-qual - 3.22.0 + 3.22.1 junit @@ -351,7 +351,7 @@ --> maven-javadoc-plugin - ${maven-javadoc-plugin.version} + ${maven-javadoc-plugin.version} maven-enforcer-plugin - ${maven-enforcer-plugin.version} + ${maven-enforcer-plugin.version} From fac6519a2e3db40a4fab7e13d3d0eaf50b73101e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Gabriel=20Abrantes?= Date: Sat, 2 Jul 2022 15:51:57 -0300 Subject: [PATCH 2/4] Code cleanup on Intellij --- .../google/common/truth/ActualValueInference.java | 8 ++++---- .../main/java/com/google/common/truth/Expect.java | 2 +- .../com/google/common/truth/FailureMetadata.java | 8 ++++---- .../com/google/common/truth/IterableSubject.java | 2 +- .../java/com/google/common/truth/MathUtil.java | 4 ++-- .../com/google/common/truth/MultimapSubject.java | 2 +- .../com/google/common/truth/MultisetSubject.java | 2 +- .../java/com/google/common/truth/Platform.java | 3 +-- .../com/google/common/truth/StackTraceCleaner.java | 2 +- .../common/truth/StandardSubjectBuilder.java | 2 +- .../main/java/com/google/common/truth/Subject.java | 10 +++++----- .../java/com/google/common/truth/SubjectUtils.java | 2 +- .../java/com/google/common/truth/TableSubject.java | 4 ++-- .../java/com/google/common/truth/FactTest.java | 14 +++++++------- .../com/google/common/truth/GraphMatchingTest.java | 2 +- .../google/common/truth/IntegerSubjectTest.java | 14 +++++++------- .../google/common/truth/IterableSubjectTest.java | 6 +++--- .../com/google/common/truth/MapSubjectTest.java | 14 +++++++------- .../google/common/truth/MultimapSubjectTest.java | 8 ++++---- .../com/google/common/truth/StringSubjectTest.java | 8 ++++---- .../java/com/google/common/truth/SubjectTest.java | 8 ++++---- .../common/truth/TruthFailureSubjectTest.java | 4 ++-- .../com/google/common/truth/gwt/TruthGwtTest.java | 4 ++-- .../google/common/truth/ExpectFailure8Test.java | 1 - .../truth/extensions/proto/FieldScopeImpl.java | 2 +- .../truth/extensions/proto/FieldScopeLogicMap.java | 2 +- .../extensions/proto/IterableOfProtosSubject.java | 2 +- .../proto/MapWithProtoValuesSubject.java | 2 +- .../MultimapWithProtoValuesFluentAssertion.java | 4 ++-- .../proto/MultimapWithProtoValuesSubject.java | 4 ++-- .../common/truth/extensions/proto/SubScopeId.java | 2 +- .../truth/extensions/proto/FieldScopesTest.java | 4 ++-- .../proto/IterableOfProtosSubjectTest.java | 4 ++-- .../proto/MapWithProtoValuesSubjectTest.java | 4 ++-- .../proto/MultimapWithProtoValuesSubjectTest.java | 12 ++++++------ .../extensions/proto/OverloadResolutionTest.java | 6 +++--- .../extensions/proto/ProtoSubjectTestBase.java | 2 +- 37 files changed, 91 insertions(+), 93 deletions(-) diff --git a/core/src/main/java/com/google/common/truth/ActualValueInference.java b/core/src/main/java/com/google/common/truth/ActualValueInference.java index 3984c9c60..1ab8afdff 100644 --- a/core/src/main/java/com/google/common/truth/ActualValueInference.java +++ b/core/src/main/java/com/google/common/truth/ActualValueInference.java @@ -271,7 +271,7 @@ private static final class InferenceMethodVisitor extends MethodVisitor { localVariableSlots = createInitialLocalVariableSlots(access, owner, name, methodDescriptor); previousFrame = FrameInfo.create( - ImmutableList.copyOf(localVariableSlots), ImmutableList.of()); + ImmutableList.copyOf(localVariableSlots), ImmutableList.of()); this.methodSignature = owner + "." + name + methodDescriptor; this.actualValueAtLine = actualValueAtLine; } @@ -894,7 +894,7 @@ public void visitFrame(int type, int nLocal, Object[] local, int nStack, Object[ case Opcodes.F_SAME: // This frame type indicates that the frame has exactly the same local variables as the // previous frame and that the operand stack is empty. - previousFrame = FrameInfo.create(previousFrame.locals(), ImmutableList.of()); + previousFrame = FrameInfo.create(previousFrame.locals(), ImmutableList.of()); break; case Opcodes.F_SAME1: // This frame type indicates that the frame has exactly the same local variables as the @@ -908,7 +908,7 @@ public void visitFrame(int type, int nLocal, Object[] local, int nStack, Object[ previousFrame = FrameInfo.create( appendArrayToList(previousFrame.locals(), nLocal, local), - ImmutableList.of()); + ImmutableList.of()); break; case Opcodes.F_CHOP: // This frame type indicates that the frame has the same local variables as the previous @@ -917,7 +917,7 @@ public void visitFrame(int type, int nLocal, Object[] local, int nStack, Object[ previousFrame = FrameInfo.create( removeBackFromList(previousFrame.locals(), nLocal), - ImmutableList.of()); + ImmutableList.of()); break; case Opcodes.F_FULL: previousFrame = diff --git a/core/src/main/java/com/google/common/truth/Expect.java b/core/src/main/java/com/google/common/truth/Expect.java index 5acc31d97..0fc719a1a 100644 --- a/core/src/main/java/com/google/common/truth/Expect.java +++ b/core/src/main/java/com/google/common/truth/Expect.java @@ -267,6 +267,6 @@ public void evaluate() throws Throwable { enum TestPhase { BEFORE, DURING, - AFTER; + AFTER } } diff --git a/core/src/main/java/com/google/common/truth/FailureMetadata.java b/core/src/main/java/com/google/common/truth/FailureMetadata.java index 2f5bce208..2c616dc6b 100644 --- a/core/src/main/java/com/google/common/truth/FailureMetadata.java +++ b/core/src/main/java/com/google/common/truth/FailureMetadata.java @@ -54,7 +54,7 @@ public final class FailureMetadata { static FailureMetadata forFailureStrategy(FailureStrategy failureStrategy) { return new FailureMetadata( - failureStrategy, ImmutableList.of(), ImmutableList.of()); + failureStrategy, ImmutableList.of(), ImmutableList.of()); } private final FailureStrategy strategy; @@ -153,7 +153,7 @@ FailureMetadata updateForCheckCall( */ enum OldAndNewValuesAreSimilar { SIMILAR, - DIFFERENT; + DIFFERENT } /** @@ -247,7 +247,7 @@ private ImmutableList description() { } return descriptionIsInteresting ? ImmutableList.of(fact("value of", description)) - : ImmutableList.of(); + : ImmutableList.of(); } /** @@ -312,7 +312,7 @@ private ImmutableList rootUnlessThrowable() { // TODO(cpovirk): Use inferDescription() here when appropriate? But it can be long. rootSubject.subject.typeDescription() + " was", rootSubject.subject.actualCustomStringRepresentationForPackageMembersToCall())) - : ImmutableList.of(); + : ImmutableList.of(); } /** diff --git a/core/src/main/java/com/google/common/truth/IterableSubject.java b/core/src/main/java/com/google/common/truth/IterableSubject.java index f02410533..b96d8f68d 100644 --- a/core/src/main/java/com/google/common/truth/IterableSubject.java +++ b/core/src/main/java/com/google/common/truth/IterableSubject.java @@ -684,7 +684,7 @@ private static boolean containsEmptyOrLong(Iterable> entries) */ enum ElementFactGrouping { ALL_IN_ONE_FACT, - FACT_PER_ELEMENT; + FACT_PER_ELEMENT } /** diff --git a/core/src/main/java/com/google/common/truth/MathUtil.java b/core/src/main/java/com/google/common/truth/MathUtil.java index 791ac4d70..4ce8651c8 100644 --- a/core/src/main/java/com/google/common/truth/MathUtil.java +++ b/core/src/main/java/com/google/common/truth/MathUtil.java @@ -37,7 +37,7 @@ public static boolean equalWithinTolerance(double left, double right, double tol * either {@code left} or {@code right} is infinite or NaN. */ public static boolean equalWithinTolerance(float left, float right, float tolerance) { - return equalWithinTolerance((double) left, (double) right, (double) tolerance); + return equalWithinTolerance(left, right, (double) tolerance); } /** @@ -59,6 +59,6 @@ public static boolean notEqualWithinTolerance(double left, double right, double * either {@code left} or {@code right} is infinite or NaN. */ public static boolean notEqualWithinTolerance(float left, float right, float tolerance) { - return notEqualWithinTolerance((double) left, (double) right, (double) tolerance); + return notEqualWithinTolerance(left, right, (double) tolerance); } } diff --git a/core/src/main/java/com/google/common/truth/MultimapSubject.java b/core/src/main/java/com/google/common/truth/MultimapSubject.java index a80545ad2..75cb94e18 100644 --- a/core/src/main/java/com/google/common/truth/MultimapSubject.java +++ b/core/src/main/java/com/google/common/truth/MultimapSubject.java @@ -461,7 +461,7 @@ private static Collection get(Multimap multimap, @Nullable Object k } private static List difference(List minuend, List subtrahend) { - LinkedHashMultiset remaining = LinkedHashMultiset.create(subtrahend); + LinkedHashMultiset remaining = LinkedHashMultiset.create(subtrahend); List difference = Lists.newArrayList(); for (Object elem : minuend) { if (!remaining.remove(elem)) { diff --git a/core/src/main/java/com/google/common/truth/MultisetSubject.java b/core/src/main/java/com/google/common/truth/MultisetSubject.java index 40037fe38..e1cbdb6c6 100644 --- a/core/src/main/java/com/google/common/truth/MultisetSubject.java +++ b/core/src/main/java/com/google/common/truth/MultisetSubject.java @@ -37,7 +37,7 @@ public final class MultisetSubject extends IterableSubject { /** Fails if the element does not have the given count. */ public final void hasCount(@Nullable Object element, int expectedCount) { checkArgument(expectedCount >= 0, "expectedCount(%s) must be >= 0", expectedCount); - int actualCount = ((Multiset) actual).count(element); + int actualCount = actual.count(element); check("count(%s)", element).that(actualCount).isEqualTo(expectedCount); } } diff --git a/core/src/main/java/com/google/common/truth/Platform.java b/core/src/main/java/com/google/common/truth/Platform.java index aea7d0fd2..6cb070129 100644 --- a/core/src/main/java/com/google/common/truth/Platform.java +++ b/core/src/main/java/com/google/common/truth/Platform.java @@ -295,8 +295,7 @@ static AssertionError makeComparisonFailure( } private static LinkageError newLinkageError(Throwable cause) { - LinkageError error = new LinkageError(cause.toString()); - error.initCause(cause); + LinkageError error = new LinkageError(cause.toString(), cause); return error; } } diff --git a/core/src/main/java/com/google/common/truth/StackTraceCleaner.java b/core/src/main/java/com/google/common/truth/StackTraceCleaner.java index 21fc29c60..660d8b5e6 100644 --- a/core/src/main/java/com/google/common/truth/StackTraceCleaner.java +++ b/core/src/main/java/com/google/common/truth/StackTraceCleaner.java @@ -43,7 +43,7 @@ final class StackTraceCleaner { * the bottom. Collapses the frames for various frameworks in the middle of the trace as well. */ static void cleanStackTrace(Throwable throwable) { - new StackTraceCleaner(throwable).clean(Sets.newIdentityHashSet()); + new StackTraceCleaner(throwable).clean(Sets.newIdentityHashSet()); } private final Throwable throwable; diff --git a/core/src/main/java/com/google/common/truth/StandardSubjectBuilder.java b/core/src/main/java/com/google/common/truth/StandardSubjectBuilder.java index baaaae67a..cf498115c 100644 --- a/core/src/main/java/com/google/common/truth/StandardSubjectBuilder.java +++ b/core/src/main/java/com/google/common/truth/StandardSubjectBuilder.java @@ -215,7 +215,7 @@ public final CustomSubjectB * {@link Truth#assertWithMessage}). */ public final void fail() { - metadata().fail(ImmutableList.of()); + metadata().fail(ImmutableList.of()); } private FailureMetadata metadata() { diff --git a/core/src/main/java/com/google/common/truth/Subject.java b/core/src/main/java/com/google/common/truth/Subject.java index c60f66a99..99e093f1e 100644 --- a/core/src/main/java/com/google/common/truth/Subject.java +++ b/core/src/main/java/com/google/common/truth/Subject.java @@ -96,7 +96,7 @@ public void fail(AssertionError failure) {} private final FailureMetadata metadata; private final Object actual; - private String customName = null; + private final String customName = null; private final @Nullable String typeDescriptionOverride; /** @@ -255,7 +255,7 @@ private static boolean isIntegralBoxedPrimitive(@Nullable Object o) { private static long integralValue(Object o) { if (o instanceof Character) { - return (long) ((Character) o).charValue(); + return ((Character) o).charValue(); } else if (o instanceof Number) { return ((Number) o).longValue(); } else { @@ -489,7 +489,7 @@ static ComparisonResult differentNoDescription() { private static final ComparisonResult EQUAL = new ComparisonResult(null); private static final ComparisonResult DIFFERENT_NO_DESCRIPTION = - new ComparisonResult(ImmutableList.of()); + new ComparisonResult(ImmutableList.of()); private final @Nullable ImmutableList facts; @@ -502,7 +502,7 @@ boolean valuesAreEqual() { } ImmutableList factsOrEmpty() { - return firstNonNull(facts, ImmutableList.of()); + return firstNonNull(facts, ImmutableList.of()); } /** Returns an instance with the same "equal"/"not-equal" bit but with no description. */ @@ -1193,7 +1193,7 @@ private ImmutableList prependNameIfAny(ImmutableList facts) { private ImmutableList nameAsFacts() { return customName == null - ? ImmutableList.of() + ? ImmutableList.of() : ImmutableList.of(fact("name", customName)); } } diff --git a/core/src/main/java/com/google/common/truth/SubjectUtils.java b/core/src/main/java/com/google/common/truth/SubjectUtils.java index 07ef011f2..b071b27e4 100644 --- a/core/src/main/java/com/google/common/truth/SubjectUtils.java +++ b/core/src/main/java/com/google/common/truth/SubjectUtils.java @@ -134,7 +134,7 @@ static DuplicateGroupedAndTyped countDuplicatesAndMaybeAddTypeInfoReturnObject( } else { return new DuplicateGroupedAndTyped( countDuplicatesToMultiset(itemsIterable), - /* homogeneousTypeToDisplay= */ Optional.absent()); + /* homogeneousTypeToDisplay= */ Optional.absent()); } } diff --git a/core/src/main/java/com/google/common/truth/TableSubject.java b/core/src/main/java/com/google/common/truth/TableSubject.java index 87fcd69f0..9c7f19ec5 100644 --- a/core/src/main/java/com/google/common/truth/TableSubject.java +++ b/core/src/main/java/com/google/common/truth/TableSubject.java @@ -74,7 +74,7 @@ public void doesNotContain(@Nullable Object rowKey, @Nullable Object columnKey) /** Fails if the table does not contain the given cell. */ public void containsCell( @Nullable Object rowKey, @Nullable Object colKey, @Nullable Object value) { - containsCell(Tables.immutableCell(rowKey, colKey, value)); + containsCell(Tables.immutableCell(rowKey, colKey, value)); } /** Fails if the table does not contain the given cell. */ @@ -86,7 +86,7 @@ public void containsCell(Cell cell) { /** Fails if the table contains the given cell. */ public void doesNotContainCell( @Nullable Object rowKey, @Nullable Object colKey, @Nullable Object value) { - doesNotContainCell(Tables.immutableCell(rowKey, colKey, value)); + doesNotContainCell(Tables.immutableCell(rowKey, colKey, value)); } /** Fails if the table contains the given cell. */ diff --git a/core/src/test/java/com/google/common/truth/FactTest.java b/core/src/test/java/com/google/common/truth/FactTest.java index 6a928abf2..d94b7d057 100644 --- a/core/src/test/java/com/google/common/truth/FactTest.java +++ b/core/src/test/java/com/google/common/truth/FactTest.java @@ -41,7 +41,7 @@ public void stringWithoutValue() { @Test public void oneFacts() { - assertThat(makeMessage(ImmutableList.of(), ImmutableList.of(fact("foo", "bar")))) + assertThat(makeMessage(ImmutableList.of(), ImmutableList.of(fact("foo", "bar")))) .isEqualTo("foo: bar"); } @@ -49,14 +49,14 @@ public void oneFacts() { public void twoFacts() { assertThat( makeMessage( - ImmutableList.of(), + ImmutableList.of(), ImmutableList.of(fact("foo", "bar"), fact("longer name", "other value")))) .isEqualTo("foo : bar\nlonger name: other value"); } @Test public void oneFactWithoutValue() { - assertThat(makeMessage(ImmutableList.of(), ImmutableList.of(simpleFact("foo")))) + assertThat(makeMessage(ImmutableList.of(), ImmutableList.of(simpleFact("foo")))) .isEqualTo("foo"); } @@ -64,14 +64,14 @@ public void oneFactWithoutValue() { public void twoFactsOneWithoutValue() { assertThat( makeMessage( - ImmutableList.of(), + ImmutableList.of(), ImmutableList.of(fact("hello", "there"), simpleFact("foo")))) .isEqualTo("hello: there\nfoo"); } @Test public void newline() { - assertThat(makeMessage(ImmutableList.of(), ImmutableList.of(fact("foo", "bar\nbaz")))) + assertThat(makeMessage(ImmutableList.of(), ImmutableList.of(fact("foo", "bar\nbaz")))) .isEqualTo("foo:\n bar\n baz"); } @@ -79,14 +79,14 @@ public void newline() { public void newlineWithoutValue() { assertThat( makeMessage( - ImmutableList.of(), + ImmutableList.of(), ImmutableList.of(fact("hello", "there\neveryone"), simpleFact("xyz")))) .isEqualTo("hello:\n there\n everyone\nxyz"); } @Test public void withMessage() { - assertThat(makeMessage(ImmutableList.of("hello"), ImmutableList.of(fact("foo", "bar")))) + assertThat(makeMessage(ImmutableList.of("hello"), ImmutableList.of(fact("foo", "bar")))) .isEqualTo("hello\nfoo: bar"); } } diff --git a/core/src/test/java/com/google/common/truth/GraphMatchingTest.java b/core/src/test/java/com/google/common/truth/GraphMatchingTest.java index 9a5f0ed5e..2f9528c74 100644 --- a/core/src/test/java/com/google/common/truth/GraphMatchingTest.java +++ b/core/src/test/java/com/google/common/truth/GraphMatchingTest.java @@ -158,7 +158,7 @@ private static class TestInstance { /** Generates a test instance with an empty bipartite graph. */ static TestInstance empty() { - return new TestInstance(ImmutableListMultimap.of()); + return new TestInstance(ImmutableListMultimap.of()); } /** diff --git a/core/src/test/java/com/google/common/truth/IntegerSubjectTest.java b/core/src/test/java/com/google/common/truth/IntegerSubjectTest.java index 461030435..8c30da616 100644 --- a/core/src/test/java/com/google/common/truth/IntegerSubjectTest.java +++ b/core/src/test/java/com/google/common/truth/IntegerSubjectTest.java @@ -121,7 +121,7 @@ public void overflowBetweenIntegerAndLong_shouldBeDifferent_max() { public void testPrimitivesVsBoxedPrimitivesVsObject_int() { int int42 = 42; Integer integer42 = new Integer(42); - Object object42 = (Object) 42; + Object object42 = 42; assertThat(int42).isEqualTo(int42); assertThat(integer42).isEqualTo(int42); @@ -141,7 +141,7 @@ public void testPrimitivesVsBoxedPrimitivesVsObject_int() { public void testPrimitivesVsBoxedPrimitivesVsObject_long() { long longPrim42 = 42; Long long42 = new Long(42); - Object object42 = (Object) 42L; + Object object42 = 42L; assertThat(longPrim42).isEqualTo(longPrim42); assertThat(long42).isEqualTo(longPrim42); @@ -223,17 +223,17 @@ public void testNumericPrimitiveTypes() { short short42 = (short) 42; char char42 = (char) 42; int int42 = 42; - long long42 = (long) 42; + long long42 = 42; ImmutableSet fortyTwos = - ImmutableSet.of(byte42, short42, char42, int42, long42); + ImmutableSet.of(byte42, short42, char42, int42, long42); for (Object actual : fortyTwos) { for (Object expected : fortyTwos) { assertThat(actual).isEqualTo(expected); } } - ImmutableSet fortyTwosNoChar = ImmutableSet.of(byte42, short42, int42, long42); + ImmutableSet fortyTwosNoChar = ImmutableSet.of(byte42, short42, int42, long42); for (final Object actual : fortyTwosNoChar) { for (final Object expected : fortyTwosNoChar) { ExpectFailure.SimpleSubjectBuilderCallback actualFirst = @@ -259,10 +259,10 @@ public void invokeAssertion(SimpleSubjectBuilder expect) { short short41 = (short) 41; char char41 = (char) 41; int int41 = 41; - long long41 = (long) 41; + long long41 = 41; ImmutableSet fortyOnes = - ImmutableSet.of(byte41, short41, char41, int41, long41); + ImmutableSet.of(byte41, short41, char41, int41, long41); for (Object first : fortyTwos) { for (Object second : fortyOnes) { diff --git a/core/src/test/java/com/google/common/truth/IterableSubjectTest.java b/core/src/test/java/com/google/common/truth/IterableSubjectTest.java index d4e158e30..4a76d69dd 100644 --- a/core/src/test/java/com/google/common/truth/IterableSubjectTest.java +++ b/core/src/test/java/com/google/common/truth/IterableSubjectTest.java @@ -251,7 +251,7 @@ public void iterableContainsAtLeastWithDuplicates() { @Test public void iterableContainsAtLeastWithNull() { - assertThat(asList(1, null, 3)).containsAtLeast(3, (Integer) null); + assertThat(asList(1, null, 3)).containsAtLeast(3, null); } @Test @@ -408,7 +408,7 @@ public void iterableContainsAtLeastInOrderWithFailureWithActualOrder() { @Test public void iterableContainsAtLeastInOrderWithOneShotIterable() { - final Iterable iterable = Arrays.asList(2, 1, null, 4, "a", 3, "b"); + final Iterable iterable = Arrays.asList(2, 1, null, 4, "a", 3, "b"); final Iterator iterator = iterable.iterator(); Iterable oneShot = new Iterable() { @@ -602,7 +602,7 @@ public void iterableContainsExactlyWithNull() { @Test public void iterableContainsExactlyWithNullOutOfOrder() { - assertThat(asList(1, null, 3)).containsExactly(1, 3, (Integer) null); + assertThat(asList(1, null, 3)).containsExactly(1, 3, null); } @Test diff --git a/core/src/test/java/com/google/common/truth/MapSubjectTest.java b/core/src/test/java/com/google/common/truth/MapSubjectTest.java index 6e28fdb88..31d11f6e8 100644 --- a/core/src/test/java/com/google/common/truth/MapSubjectTest.java +++ b/core/src/test/java/com/google/common/truth/MapSubjectTest.java @@ -751,7 +751,7 @@ public void isEqualToFailureExtraAndMissing() { @Test public void isEqualToFailureDiffering_sameToString() { ImmutableMap actual = - ImmutableMap.of("jan", 1, "feb", 2, "march", 3L); + ImmutableMap.of("jan", 1, "feb", 2, "march", 3L); ImmutableMap expectedMap = ImmutableMap.of("jan", 1, "feb", 2, "march", 3); expectFailureWhenTestingThat(actual).isEqualTo(expectedMap); @@ -1512,7 +1512,7 @@ public void comparingValuesUsing_containsExactly_inOrder_failsOutOfOrder() { @Test public void comparingValuesUsing_containsExactly_wrongValueTypeInActual() { - ImmutableMap actual = ImmutableMap.of("abc", "123", "def", 456); + ImmutableMap actual = ImmutableMap.of("abc", "123", "def", 456); expectFailureWhenTestingThat(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsExactly("def", 456, "abc", 123); @@ -1750,7 +1750,7 @@ public void comparingValuesUsing_containsExactlyEntriesIn_failsEmpty() { @Test public void comparingValuesUsing_containsExactlyEntriesIn_wrongValueTypeInActual() { ImmutableMap expected = ImmutableMap.of("def", 456, "abc", 123); - ImmutableMap actual = ImmutableMap.of("abc", "123", "def", 456); + ImmutableMap actual = ImmutableMap.of("abc", "123", "def", 456); expectFailureWhenTestingThat(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsExactlyEntriesIn(expected); @@ -1887,7 +1887,7 @@ public void comparingValuesUsing_containsAtLeast_inOrder_failsOutOfOrder() { @Test public void comparingValuesUsing_containsAtLeast_wrongValueTypeInExpectedActual() { - ImmutableMap actual = ImmutableMap.of("abc", "123", "def", 456); + ImmutableMap actual = ImmutableMap.of("abc", "123", "def", 456); expectFailureWhenTestingThat(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsAtLeast("def", 456); @@ -1909,7 +1909,7 @@ public void comparingValuesUsing_containsAtLeast_wrongValueTypeInExpectedActual( @Test public void comparingValuesUsing_containsAtLeast_wrongValueTypeInUnexpectedActual_success() { - ImmutableMap actual = ImmutableMap.of("abc", "123", "def", 456); + ImmutableMap actual = ImmutableMap.of("abc", "123", "def", 456); assertThat(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsAtLeast("abc", 123); @@ -2101,7 +2101,7 @@ public void comparingValuesUsing_containsAtLeastEntriesIn_empty() { @Test public void comparingValuesUsing_containsAtLeastEntriesIn_wrongValueTypeInExpectedActual() { ImmutableMap expected = ImmutableMap.of("def", 456); - ImmutableMap actual = ImmutableMap.of("abc", "123", "def", 456); + ImmutableMap actual = ImmutableMap.of("abc", "123", "def", 456); expectFailureWhenTestingThat(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsAtLeastEntriesIn(expected); @@ -2125,7 +2125,7 @@ public void comparingValuesUsing_containsAtLeastEntriesIn_wrongValueTypeInExpect public void comparingValuesUsing_containsAtLeastEntriesIn_wrongValueTypeInUnexpectedActual_success() { ImmutableMap expected = ImmutableMap.of("abc", 123); - ImmutableMap actual = ImmutableMap.of("abc", "123", "def", 456); + ImmutableMap actual = ImmutableMap.of("abc", "123", "def", 456); assertThat(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) .containsAtLeastEntriesIn(expected); diff --git a/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java b/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java index b638d9a44..6ed8984a7 100644 --- a/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java +++ b/core/src/test/java/com/google/common/truth/MultimapSubjectTest.java @@ -1378,7 +1378,7 @@ public void comparingValuesUsing_containsExactlyEntriesIn_handlesException_alway @Test public void comparingValuesUsing_containsExactlyEntriesIn_wrongTypeInActual() { ImmutableListMultimap actual = - ImmutableListMultimap.of( + ImmutableListMultimap.of( "abc", "+123", "def", "+64", "def", "0x40", "def", 999); ImmutableListMultimap expected = ImmutableListMultimap.of("def", 64, "def", 123, "def", 64, "abc", 123); @@ -1516,7 +1516,7 @@ public void comparingValuesUsing_containsExactly_wrongValueForKey() { @Test public void comparingValuesUsing_containsExactly_wrongTypeInActual() { ImmutableListMultimap actual = - ImmutableListMultimap.of( + ImmutableListMultimap.of( "abc", "+123", "def", "+64", "def", "0x40", "def", 999); expectFailureWhenTestingThat(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) @@ -1689,7 +1689,7 @@ public void comparingValuesUsing_containsAtLeastEntriesIn_handlesException_alway @Test public void comparingValuesUsing_containsAtLeastEntriesIn_wrongTypeInActual() { ImmutableListMultimap actual = - ImmutableListMultimap.of( + ImmutableListMultimap.of( "abc", "+123", "def", "+64", "def", "0x40", "def", 999); ImmutableListMultimap expected = ImmutableListMultimap.of("def", 64, "def", 123, "def", 64, "abc", 123); @@ -1808,7 +1808,7 @@ public void comparingValuesUsing_containsAtLeast_wrongValueForKey() { @Test public void comparingValuesUsing_containsAtLeast_wrongTypeInActual() { ImmutableListMultimap actual = - ImmutableListMultimap.of( + ImmutableListMultimap.of( "abc", "+123", "def", "+64", "def", "0x40", "def", 999, "m", "+1"); expectFailureWhenTestingThat(actual) .comparingValuesUsing(STRING_PARSES_TO_INTEGER_CORRESPONDENCE) diff --git a/core/src/test/java/com/google/common/truth/StringSubjectTest.java b/core/src/test/java/com/google/common/truth/StringSubjectTest.java index dbb891127..5fdbc711d 100644 --- a/core/src/test/java/com/google/common/truth/StringSubjectTest.java +++ b/core/src/test/java/com/google/common/truth/StringSubjectTest.java @@ -380,7 +380,7 @@ public void stringEqualityIgnoringCaseFail() { @Test public void stringEqualityIgnoringCaseFailWithNullSubject() { - expectFailureWhenTestingThat((String) null).ignoringCase().isEqualTo("abc"); + expectFailureWhenTestingThat(null).ignoringCase().isEqualTo("abc"); assertFailureValue("expected a string that is equal to", "abc"); assertThat(expectFailure.getFailure()).factKeys().contains("(case is ignored)"); @@ -419,7 +419,7 @@ public void stringInequalityIgnoringCaseFail() { @Test public void stringInequalityIgnoringCaseFailWithNullSubject() { - expectFailureWhenTestingThat((String) null).ignoringCase().isNotEqualTo(null); + expectFailureWhenTestingThat(null).ignoringCase().isNotEqualTo(null); assertFailureValue("expected a string that is not equal to", "null (null reference)"); assertThat(expectFailure.getFailure()).factKeys().contains("(case is ignored)"); @@ -469,7 +469,7 @@ public void stringContainsIgnoringCaseFailBecauseTooLarge() { @Test public void stringContainsIgnoringCaseFailBecauseNullSubject() { - expectFailureWhenTestingThat((String) null).ignoringCase().contains("d"); + expectFailureWhenTestingThat(null).ignoringCase().contains("d"); assertFailureValue("expected a string that contains", "d"); assertThat(expectFailure.getFailure()).factKeys().contains("(case is ignored)"); @@ -504,7 +504,7 @@ public void stringDoesNotContainIgnoringCaseFailWithEmptyString() { @Test public void stringDoesNotContainIgnoringCaseFailBecauseNullSubject() { - expectFailureWhenTestingThat((String) null).ignoringCase().doesNotContain("d"); + expectFailureWhenTestingThat(null).ignoringCase().doesNotContain("d"); assertFailureValue("expected a string that does not contain", "d"); assertThat(expectFailure.getFailure()).factKeys().contains("(case is ignored)"); diff --git a/core/src/test/java/com/google/common/truth/SubjectTest.java b/core/src/test/java/com/google/common/truth/SubjectTest.java index 129ab5227..1f49d3925 100644 --- a/core/src/test/java/com/google/common/truth/SubjectTest.java +++ b/core/src/test/java/com/google/common/truth/SubjectTest.java @@ -131,7 +131,7 @@ public void allAssertThatOverloadsAcceptNull() throws Exception { subject.isNotSameInstanceAs(new Object()); if (!(subject instanceof IterableSubject)) { // b/36000148 - subject.isNotIn(ImmutableList.of()); + subject.isNotIn(ImmutableList.of()); subject.isNoneOf(new Object(), new Object()); } @@ -617,12 +617,12 @@ public void isInFailure() { @Test public void isInNullInListWithNull() { - assertThat((String) null).isIn(oneShotIterable("a", "b", (String) null)); + assertThat((String) null).isIn(oneShotIterable("a", "b", null)); } @Test public void isInNonnullInListWithNull() { - assertThat("b").isIn(oneShotIterable("a", "b", (String) null)); + assertThat("b").isIn(oneShotIterable("a", "b", null)); } @Test @@ -689,7 +689,7 @@ public void isNotInNullFailure() { expectFailure .whenTesting() .that((String) null) - .isNotIn(oneShotIterable("a", "b", (String) null)); + .isNotIn(oneShotIterable("a", "b", null)); } @Test diff --git a/core/src/test/java/com/google/common/truth/TruthFailureSubjectTest.java b/core/src/test/java/com/google/common/truth/TruthFailureSubjectTest.java index cb9d7976d..39b76bdc2 100644 --- a/core/src/test/java/com/google/common/truth/TruthFailureSubjectTest.java +++ b/core/src/test/java/com/google/common/truth/TruthFailureSubjectTest.java @@ -175,11 +175,11 @@ private TruthFailureSubject expectFailureWhenTestingThat(Fact... facts) { } private TruthFailureSubject expectFailureWhenTestingThat(AssertionError failure) { - return (TruthFailureSubject) expectFailure.whenTesting().about(truthFailures()).that(failure); + return expectFailure.whenTesting().about(truthFailures()).that(failure); } private AssertionErrorWithFacts failure(Fact... facts) { return new AssertionErrorWithFacts( - ImmutableList.of(), ImmutableList.copyOf(facts), /* cause= */ null); + ImmutableList.of(), ImmutableList.copyOf(facts), /* cause= */ null); } } diff --git a/core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java b/core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java index b66f3ed53..0c773812c 100644 --- a/core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java +++ b/core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java @@ -121,11 +121,11 @@ public void testString_doesNotContainMatchFail() { } public void testIterable() { - assertThat((Iterable) asList(1, 2, 3)).containsExactly(1, 2, 3).inOrder(); + assertThat(asList(1, 2, 3)).containsExactly(1, 2, 3).inOrder(); } public void testCollection() { - assertThat((Collection) asList(1, 2, 3)).containsExactly(1, 2, 3).inOrder(); + assertThat(asList(1, 2, 3)).containsExactly(1, 2, 3).inOrder(); } public void testList() { diff --git a/extensions/java8/src/test/java/com/google/common/truth/ExpectFailure8Test.java b/extensions/java8/src/test/java/com/google/common/truth/ExpectFailure8Test.java index 3f1bd2e91..161c3e483 100644 --- a/extensions/java8/src/test/java/com/google/common/truth/ExpectFailure8Test.java +++ b/extensions/java8/src/test/java/com/google/common/truth/ExpectFailure8Test.java @@ -45,7 +45,6 @@ public void testExpectFailureAbout() { AssertionError unused = expectFailureAbout( STRINGS, - (SimpleSubjectBuilderCallback) whenTesting -> whenTesting.that("foo").contains("bar")); } diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FieldScopeImpl.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FieldScopeImpl.java index 4acf9916b..4be7cd0a5 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FieldScopeImpl.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FieldScopeImpl.java @@ -72,7 +72,7 @@ static FieldScope createFromSetFields(Iterable messages) { if (emptyOrAllNull(messages)) { return create( FieldScopeLogic.none(), - Functions.constant(String.format("FieldScopes.fromSetFields(%s)", messages.toString()))); + Functions.constant(String.format("FieldScopes.fromSetFields(%s)", messages))); } Optional optDescriptor = FieldScopeUtil.getSingleDescriptor(messages); diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FieldScopeLogicMap.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FieldScopeLogicMap.java index 4bd0948d7..4413e95c0 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FieldScopeLogicMap.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FieldScopeLogicMap.java @@ -48,7 +48,7 @@ static Entry of(FieldScopeLogic fieldScopeLogic, V value) { } private static final FieldScopeLogicMap EMPTY_INSTANCE = - new FieldScopeLogicMap<>(ImmutableList.>of()); + new FieldScopeLogicMap<>(ImmutableList.of()); // Key -> value mappings for this map. Earlier entries override later ones. private final ImmutableList> entries; diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/IterableOfProtosSubject.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/IterableOfProtosSubject.java index 3907d8666..72e81a38c 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/IterableOfProtosSubject.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/IterableOfProtosSubject.java @@ -734,7 +734,7 @@ private IterableSubject.UsingCorrespondence delegate(Iterable subject .config .withExpectedMessages(messages) - .toCorrespondence(FieldScopeUtil.getSingleDescriptor(subject.actual))); + .toCorrespondence(FieldScopeUtil.getSingleDescriptor(subject.actual))); if (keyFunction != null) { usingCorrespondence = usingCorrespondence.displayingDiffsPairedBy(keyFunction); } diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MapWithProtoValuesSubject.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MapWithProtoValuesSubject.java index 9248843e9..eb9b631aa 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MapWithProtoValuesSubject.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MapWithProtoValuesSubject.java @@ -634,7 +634,7 @@ private MapSubject.UsingCorrespondence usingCorrespondence( return comparingValuesUsing( config .withExpectedMessages(expectedValues) - .toCorrespondence(FieldScopeUtil.getSingleDescriptor(actual.values()))); + .toCorrespondence(FieldScopeUtil.getSingleDescriptor(actual.values()))); } // The UsingCorrespondence methods have conflicting erasure with default MapSubject methods, diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MultimapWithProtoValuesFluentAssertion.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MultimapWithProtoValuesFluentAssertion.java index 2fdc8548d..d03747a0b 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MultimapWithProtoValuesFluentAssertion.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MultimapWithProtoValuesFluentAssertion.java @@ -528,7 +528,7 @@ MultimapWithProtoValuesFluentAssertion unpackingAnyUsingForValues( /** Fails if the multimap is not empty. */ @CanIgnoreReturnValue - public Ordered containsExactly(); + Ordered containsExactly(); /** * Fails if the multimap does not contain exactly the given set of key/value pairs. @@ -537,7 +537,7 @@ MultimapWithProtoValuesFluentAssertion unpackingAnyUsingForValues( * key/value pairs at compile time. Please make sure you provide varargs in key/value pairs! */ @CanIgnoreReturnValue - public Ordered containsExactly(@Nullable Object k0, @Nullable M v0, @Nullable Object... rest); + Ordered containsExactly(@Nullable Object k0, @Nullable M v0, @Nullable Object... rest); /**Especifications of equals method. diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MultimapWithProtoValuesSubject.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MultimapWithProtoValuesSubject.java index b7afda3e9..5636c2232 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MultimapWithProtoValuesSubject.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MultimapWithProtoValuesSubject.java @@ -657,7 +657,7 @@ private MultimapSubject.UsingCorrespondence usingCorrespondence( return comparingValuesUsing( config .withExpectedMessages(expectedValues) - .toCorrespondence(FieldScopeUtil.getSingleDescriptor(actual.values()))); + .toCorrespondence(FieldScopeUtil.getSingleDescriptor(actual.values()))); } // The UsingCorrespondence methods have conflicting erasure with default MapSubject methods, @@ -910,7 +910,7 @@ public Ordered containsExactlyEntriesIn(Multimap expectedMap) { @Override @CanIgnoreReturnValue public Ordered containsExactly() { - return subject.usingCorrespondence(Collections.emptyList()).containsExactly(); + return subject.usingCorrespondence(Collections.emptyList()).containsExactly(); } @Override diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/SubScopeId.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/SubScopeId.java index ef71d558c..c3eb45bc2 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/SubScopeId.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/SubScopeId.java @@ -23,7 +23,7 @@ abstract class SubScopeId { enum Kind { FIELD_DESCRIPTOR, - UNKNOWN_FIELD_DESCRIPTOR; + UNKNOWN_FIELD_DESCRIPTOR } abstract Kind kind(); diff --git a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/FieldScopesTest.java b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/FieldScopesTest.java index 903e31e23..2e1f3d882 100644 --- a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/FieldScopesTest.java +++ b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/FieldScopesTest.java @@ -923,7 +923,7 @@ public void testFromSetFields_iterables_vacuousIfEmptyOrAllNull() { messages.add(null); expectThat(listOf(message1, message2)) - .withPartialScope(FieldScopes.fromSetFields(ImmutableList.of())) + .withPartialScope(FieldScopes.fromSetFields(ImmutableList.of())) .containsExactly(eqIgnoredMessage1, eqIgnoredMessage2); expectThat(listOf(message1, message2)) .withPartialScope(FieldScopes.fromSetFields(messages)) @@ -931,7 +931,7 @@ public void testFromSetFields_iterables_vacuousIfEmptyOrAllNull() { expectFailureWhenTesting() .that(listOf(message1, message2)) - .withPartialScope(FieldScopes.fromSetFields(ImmutableList.of())) + .withPartialScope(FieldScopes.fromSetFields(ImmutableList.of())) .containsNoneOf(eqIgnoredMessage1, eqIgnoredMessage2); expectFailureWhenTesting() diff --git a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/IterableOfProtosSubjectTest.java b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/IterableOfProtosSubjectTest.java index 065ed04c1..6cd1ff2d5 100644 --- a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/IterableOfProtosSubjectTest.java +++ b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/IterableOfProtosSubjectTest.java @@ -59,13 +59,13 @@ public IterableOfProtosSubjectTest(TestType testType) { @Test public void testPlain_isEmpty() { - expectThat(ImmutableList.of()).isEmpty(); + expectThat(ImmutableList.of()).isEmpty(); expectThat(listOf(message1)).isNotEmpty(); expectFailureWhenTesting().that(listOf(message1)).isEmpty(); expectThatFailure().isNotNull(); - expectFailureWhenTesting().that(ImmutableList.of()).isNotEmpty(); + expectFailureWhenTesting().that(ImmutableList.of()).isNotEmpty(); expectThatFailure().isNotNull(); } diff --git a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/MapWithProtoValuesSubjectTest.java b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/MapWithProtoValuesSubjectTest.java index df855487e..bd0361d3b 100644 --- a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/MapWithProtoValuesSubjectTest.java +++ b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/MapWithProtoValuesSubjectTest.java @@ -72,13 +72,13 @@ public void testPlain_isEqualTo() { @Test public void testPlain_isEmpty() { - expectThat(ImmutableMap.of()).isEmpty(); + expectThat(ImmutableMap.of()).isEmpty(); expectThat(mapOf(1, message1)).isNotEmpty(); expectFailureWhenTesting().that(mapOf(1, message1)).isEmpty(); expectThatFailure().isNotNull(); - expectFailureWhenTesting().that(ImmutableMap.of()).isNotEmpty(); + expectFailureWhenTesting().that(ImmutableMap.of()).isNotEmpty(); expectThatFailure().isNotNull(); } diff --git a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/MultimapWithProtoValuesSubjectTest.java b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/MultimapWithProtoValuesSubjectTest.java index d2bd5cd85..09e9224a4 100644 --- a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/MultimapWithProtoValuesSubjectTest.java +++ b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/MultimapWithProtoValuesSubjectTest.java @@ -59,13 +59,13 @@ public MultimapWithProtoValuesSubjectTest(TestType testType) { @Test public void testPlain_isEmpty() { - expectThat(ImmutableMultimap.of()).isEmpty(); + expectThat(ImmutableMultimap.of()).isEmpty(); expectThat(multimapOf(1, message1)).isNotEmpty(); expectFailureWhenTesting().that(multimapOf(1, message1)).isEmpty(); expectThatFailure().isNotNull(); - expectFailureWhenTesting().that(ImmutableMap.of()).isNotEmpty(); + expectFailureWhenTesting().that(ImmutableMap.of()).isNotEmpty(); expectThatFailure().isNotNull(); } @@ -132,8 +132,8 @@ public void testPlain_containsExactlyEntriesIn() { @Test public void testPlain_containsExactlyNoArgs() { - expectThat(ImmutableMultimap.of()).containsExactly(); - expectThat(ImmutableMultimap.of()).containsExactly().inOrder(); + expectThat(ImmutableMultimap.of()).containsExactly(); + expectThat(ImmutableMultimap.of()).containsExactly().inOrder(); expectFailureWhenTesting().that(multimapOf(1, message1)).containsExactly(); expectThatFailure().isNotNull(); @@ -236,10 +236,10 @@ public void testFluent_containsExactlyEntriesIn() { @Test public void testFluent_containsExactly_noArgs() { - expectThat(ImmutableMultimap.of()) + expectThat(ImmutableMultimap.of()) .ignoringRepeatedFieldOrderForValues() .containsExactly(); - expectThat(ImmutableMultimap.of()) + expectThat(ImmutableMultimap.of()) .ignoringRepeatedFieldOrderForValues() .containsExactly() .inOrder(); diff --git a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/OverloadResolutionTest.java b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/OverloadResolutionTest.java index 4d6725ebb..173082f0a 100644 --- a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/OverloadResolutionTest.java +++ b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/OverloadResolutionTest.java @@ -162,7 +162,7 @@ public void testIterableOverloads_objects_actuallyMessages() { public void testIterableOverloads_objects_actuallyNotMessages() { TestMessage2 message1 = TestMessage2.newBuilder().setOInt(1).addRString("foo").build(); TestMessage2 message2 = TestMessage2.newBuilder().setOInt(2).addRString("bar").build(); - ImmutableList altActualObjects = ImmutableList.of("Foo!", 42); + ImmutableList altActualObjects = ImmutableList.of("Foo!", 42); assertThat(altActualObjects).containsExactly(21 * 2, "Foo! Bar!".substring(0, 4)); assertThat(altActualObjects).containsNoneOf(message1, message2); @@ -225,7 +225,7 @@ public void testMapOverloads_objects_actuallyMessages() { public void testMapOverloads_objects_actuallyNotMessages() { TestMessage2 message1 = TestMessage2.newBuilder().setOInt(1).addRString("foo").build(); TestMessage2 message2 = TestMessage2.newBuilder().setOInt(2).addRString("bar").build(); - ImmutableMap altActualObjects = mapOf("a", (Object) "Foo!", "b", 42); + ImmutableMap altActualObjects = mapOf("a", "Foo!", "b", 42); assertThat(altActualObjects).containsExactly("a", "Foo! Bar!".substring(0, 4), "b", 21 * 2); assertThat(altActualObjects).doesNotContainEntry("a", message1); @@ -353,7 +353,7 @@ public void testMultimapOverloads_objects_actuallyNotMessages() { TestMessage2 message1 = TestMessage2.newBuilder().setOInt(1).addRString("foo").build(); TestMessage2 message2 = TestMessage2.newBuilder().setOInt(2).addRString("bar").build(); ImmutableMultimap altActualObjects = - multimapOf("a", (Object) "Foo!", "a", "Baz!", "b", 42); + multimapOf("a", "Foo!", "a", "Baz!", "b", 42); assertThat(altActualObjects) .containsExactlyEntriesIn( diff --git a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTestBase.java b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTestBase.java index 287282f13..615ed2bd1 100644 --- a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTestBase.java +++ b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTestBase.java @@ -53,7 +53,7 @@ public class ProtoSubjectTestBase { // Type information for subclasses. - static enum TestType { + enum TestType { IMMUTABLE_PROTO2(TestMessage2.getDefaultInstance()), PROTO3(TestMessage3.getDefaultInstance()); From 1b22799e9fb6344526f0d8573ea06805bc2137a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Gabriel=20Abrantes?= Date: Tue, 5 Jul 2022 11:23:23 -0300 Subject: [PATCH 3/4] Rename confuse name of StoredExpection on Correspondence class --- .../google/common/truth/Correspondence.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/com/google/common/truth/Correspondence.java b/core/src/main/java/com/google/common/truth/Correspondence.java index ae2b4bc97..e239d1522 100644 --- a/core/src/main/java/com/google/common/truth/Correspondence.java +++ b/core/src/main/java/com/google/common/truth/Correspondence.java @@ -519,7 +519,7 @@ boolean isEquality() { */ public abstract boolean compare(A actual, E expected); - private static class StoredException { + private static class StoredExceptionDescritor { private static final Joiner ARGUMENT_JOINER = Joiner.on(", ").useForNull("null"); @@ -527,7 +527,7 @@ private static class StoredException { private final String methodName; private final List methodArguments; - StoredException(Exception exception, String methodName, List methodArguments) { + StoredExceptionDescritor(Exception exception, String methodName, List methodArguments) { this.exception = checkNotNull(exception); this.methodName = checkNotNull(methodName); this.methodArguments = checkNotNull(methodArguments); @@ -552,9 +552,9 @@ private String describe() { static final class ExceptionStore { private final String argumentLabel; - private StoredException firstCompareException = null; - private StoredException firstPairingException = null; - private StoredException firstFormatDiffException = null; + private StoredExceptionDescritor firstCompareException = null; + private StoredExceptionDescritor firstPairingException = null; + private StoredExceptionDescritor firstFormatDiffException = null; static ExceptionStore forIterable() { return new ExceptionStore("elements"); @@ -583,7 +583,7 @@ void addCompareException( Class callingClass, Exception exception, Object actual, Object expected) { if (firstCompareException == null) { truncateStackTrace(exception, callingClass); - firstCompareException = new StoredException(exception, "compare", asList(actual, expected)); + firstCompareException = new StoredExceptionDescritor(exception, "compare", asList(actual, expected)); } } @@ -601,7 +601,7 @@ void addActualKeyFunctionException(Class callingClass, Exception exception, O if (firstPairingException == null) { truncateStackTrace(exception, callingClass); firstPairingException = - new StoredException(exception, "actualKeyFunction.apply", asList(actual)); + new StoredExceptionDescritor(exception, "actualKeyFunction.apply", asList(actual)); } } @@ -620,7 +620,7 @@ void addExpectedKeyFunctionException( if (firstPairingException == null) { truncateStackTrace(exception, callingClass); firstPairingException = - new StoredException(exception, "expectedKeyFunction.apply", asList(expected)); + new StoredExceptionDescritor(exception, "expectedKeyFunction.apply", asList(expected)); } } @@ -640,7 +640,7 @@ void addFormatDiffException( if (firstFormatDiffException == null) { truncateStackTrace(exception, callingClass); firstFormatDiffException = - new StoredException(exception, "formatDiff", asList(actual, expected)); + new StoredExceptionDescritor(exception, "formatDiff", asList(actual, expected)); } } From a4fc906982645a1685e16d078c8b90af855092d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Gabriel=20Abrantes?= Date: Tue, 5 Jul 2022 11:33:37 -0300 Subject: [PATCH 4/4] Solve performance problem with iterator map on FieldNumberTree --- .../common/truth/extensions/proto/FieldNumberTree.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FieldNumberTree.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FieldNumberTree.java index d33e2fee1..af1dc948e 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FieldNumberTree.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FieldNumberTree.java @@ -20,6 +20,8 @@ import com.google.protobuf.Descriptors.FieldDescriptor; import com.google.protobuf.Message; import com.google.protobuf.UnknownFieldSet; + +import java.util.Iterator; import java.util.List; import java.util.Map; @@ -67,7 +69,8 @@ static FieldNumberTree fromMessage(Message message) { // Known fields. Map knownFieldValues = message.getAllFields(); - for (FieldDescriptor field : knownFieldValues.keySet()) { + for (Iterator iterator = knownFieldValues.keySet().iterator(); iterator.hasNext(); ) { + FieldDescriptor field = iterator.next(); SubScopeId subScopeId = SubScopeId.of(field); FieldNumberTree childTree = new FieldNumberTree(); tree.children.put(subScopeId, childTree);