Skip to content

Commit 5de3d21

Browse files
committed
Remove deprecated containsAllOf+containsAllIn and isOrdered+isStrictlyOrdered.
(Also, internally remove isSameAs+isNotSameAs, which had already been removed externally.) Relnotes: Removed deprecated `containsAllOf` and `containsAllIn`. Use `containsAtLeast` and `containsAtLeastElementsIn`, which are equivalent. Removed deprecated `isOrdered` and `isStrictlyOrdered`. Use `isInOrder` and `isInStrictOrder`, which are equivalent. [] ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=252840812
1 parent f2cecff commit 5de3d21

23 files changed

+182
-730
lines changed

core/src/main/java/com/google/common/truth/IterableSubject.java

Lines changed: 0 additions & 162 deletions
Original file line numberDiff line numberDiff line change
@@ -219,60 +219,6 @@ public final void containsAnyIn(Object[] expected) {
219219
containsAnyIn(asList(expected));
220220
}
221221

222-
/**
223-
* Checks that the actual iterable contains at least all of the expected elements or fails. If an
224-
* element appears more than once in the expected elements to this call then it must appear at
225-
* least that number of times in the actual elements.
226-
*
227-
* <p>To also test that the contents appear in the given order, make a call to {@code inOrder()}
228-
* on the object returned by this method. The expected elements must appear in the given order
229-
* within the actual elements, but they are not required to be consecutive.
230-
*
231-
* @deprecated Use {@link #containsAtLeast}, which is equivalent.
232-
*/
233-
@CanIgnoreReturnValue
234-
@Deprecated
235-
public final Ordered containsAllOf(
236-
@NullableDecl Object firstExpected,
237-
@NullableDecl Object secondExpected,
238-
@NullableDecl Object... restOfExpected) {
239-
return containsAtLeast(firstExpected, secondExpected, restOfExpected);
240-
}
241-
242-
/**
243-
* Checks that the actual iterable contains at least all of the expected elements or fails. If an
244-
* element appears more than once in the expected elements then it must appear at least that
245-
* number of times in the actual elements.
246-
*
247-
* <p>To also test that the contents appear in the given order, make a call to {@code inOrder()}
248-
* on the object returned by this method. The expected elements must appear in the given order
249-
* within the actual elements, but they are not required to be consecutive.
250-
*
251-
* @deprecated Use {@link #containsAtLeastElementsIn(Iterable)}, which is equivalent.
252-
*/
253-
@CanIgnoreReturnValue
254-
@Deprecated
255-
public final Ordered containsAllIn(Iterable<?> expectedIterable) {
256-
return containsAtLeastElementsIn(expectedIterable);
257-
}
258-
259-
/**
260-
* Checks that the actual iterable contains at least all of the expected elements or fails. If an
261-
* element appears more than once in the expected elements then it must appear at least that
262-
* number of times in the actual elements.
263-
*
264-
* <p>To also test that the contents appear in the given order, make a call to {@code inOrder()}
265-
* on the object returned by this method. The expected elements must appear in the given order
266-
* within the actual elements, but they are not required to be consecutive.
267-
*
268-
* @deprecated Use {@link #containsAtLeastElementsIn(Object[])}, which is equivalent.
269-
*/
270-
@CanIgnoreReturnValue
271-
@Deprecated
272-
public final Ordered containsAllIn(Object[] expected) {
273-
return containsAtLeastElementsIn(expected);
274-
}
275-
276222
/**
277223
* Checks that the actual iterable contains at least all of the expected elements or fails. If an
278224
* element appears more than once in the expected elements to this call then it must appear at
@@ -847,61 +793,6 @@ public boolean check(Object prev, Object next) {
847793
});
848794
}
849795

850-
/**
851-
* Fails if the iterable is not strictly ordered, according to the natural ordering of its
852-
* elements. Strictly ordered means that each element in the iterable is <i>strictly</i> greater
853-
* than the element that preceded it.
854-
*
855-
* @throws ClassCastException if any pair of elements is not mutually Comparable
856-
* @throws NullPointerException if any element is null
857-
* @deprecated Use {@link #isInStrictOrder()}.
858-
*/
859-
@Deprecated
860-
public final void isStrictlyOrdered() {
861-
isInStrictOrder();
862-
}
863-
864-
/**
865-
* Fails if the iterable is not strictly ordered, according to the given comparator. Strictly
866-
* ordered means that each element in the iterable is <i>strictly</i> greater than the element
867-
* that preceded it.
868-
*
869-
* @throws ClassCastException if any pair of elements is not mutually Comparable
870-
* @deprecated Use {@link #isInStrictOrder(Comparator)}.
871-
*/
872-
@Deprecated
873-
@SuppressWarnings({"unchecked"})
874-
public final void isStrictlyOrdered(final Comparator<?> comparator) {
875-
isInStrictOrder(comparator);
876-
}
877-
878-
/**
879-
* Fails if the iterable is not ordered, according to the natural ordering of its elements.
880-
* Ordered means that each element in the iterable is greater than or equal to the element that
881-
* preceded it.
882-
*
883-
* @throws ClassCastException if any pair of elements is not mutually Comparable
884-
* @throws NullPointerException if any element is null
885-
* @deprecated Use {@link #isInOrder()}
886-
*/
887-
@Deprecated
888-
public final void isOrdered() {
889-
isInOrder();
890-
}
891-
892-
/**
893-
* Fails if the iterable is not ordered, according to the given comparator. Ordered means that
894-
* each element in the iterable is greater than or equal to the element that preceded it.
895-
*
896-
* @throws ClassCastException if any pair of elements is not mutually Comparable
897-
* @deprecated Use {@link #isInOrder(Comparator)}.
898-
*/
899-
@Deprecated
900-
@SuppressWarnings({"unchecked"})
901-
public final void isOrdered(final Comparator<?> comparator) {
902-
isInOrder(comparator);
903-
}
904-
905796
private interface PairwiseChecker {
906797
boolean check(Object prev, Object next);
907798
}
@@ -1559,59 +1450,6 @@ private boolean failIfOneToOneMappingHasMissingOrExtra(
15591450
return false;
15601451
}
15611452

1562-
/**
1563-
* Checks that the subject contains elements that corresponds to all of the expected elements,
1564-
* i.e. that there is a 1:1 mapping between any subset of the actual elements and the expected
1565-
* elements where each pair of elements correspond.
1566-
*
1567-
* <p>To also test that the contents appear in the given order, make a call to {@code inOrder()}
1568-
* on the object returned by this method. The elements must appear in the given order within the
1569-
* subject, but they are not required to be consecutive.
1570-
*
1571-
* @deprecated Use {@link #containsAtLeast}, which is equivalent.
1572-
*/
1573-
@SafeVarargs
1574-
@CanIgnoreReturnValue
1575-
@Deprecated
1576-
public final Ordered containsAllOf(
1577-
@NullableDecl E first, @NullableDecl E second, @NullableDecl E... rest) {
1578-
return containsAtLeast(first, second, rest);
1579-
}
1580-
1581-
/**
1582-
* Checks that the subject contains elements that corresponds to all of the expected elements,
1583-
* i.e. that there is a 1:1 mapping between any subset of the actual elements and the expected
1584-
* elements where each pair of elements correspond.
1585-
*
1586-
* <p>To also test that the contents appear in the given order, make a call to {@code inOrder()}
1587-
* on the object returned by this method. The elements must appear in the given order within the
1588-
* subject, but they are not required to be consecutive.
1589-
*
1590-
* @deprecated Use {@link #containsAtLeastElementsIn(Iterable)}, which is equivalent.
1591-
*/
1592-
@CanIgnoreReturnValue
1593-
@Deprecated
1594-
public Ordered containsAllIn(final Iterable<? extends E> expected) {
1595-
return containsAtLeastElementsIn(expected);
1596-
}
1597-
1598-
/**
1599-
* Checks that the subject contains elements that corresponds to all of the expected elements,
1600-
* i.e. that there is a 1:1 mapping between any subset of the actual elements and the expected
1601-
* elements where each pair of elements correspond.
1602-
*
1603-
* <p>To also test that the contents appear in the given order, make a call to {@code inOrder()}
1604-
* on the object returned by this method. The elements must appear in the given order within the
1605-
* subject, but they are not required to be consecutive.
1606-
*
1607-
* @deprecated Use {@link #containsAtLeastElementsIn(Object[])}, which is equivalent.
1608-
*/
1609-
@CanIgnoreReturnValue
1610-
@Deprecated
1611-
public Ordered containsAllIn(E[] expected) {
1612-
return containsAtLeastElementsIn(expected);
1613-
}
1614-
16151453
/**
16161454
* Checks that the subject contains elements that corresponds to all of the expected elements,
16171455
* i.e. that there is a 1:1 mapping between any subset of the actual elements and the expected

core/src/main/java/com/google/common/truth/MultimapSubject.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ public <K, V extends E> Ordered containsAtLeastEntriesIn(Multimap<K, V> expected
748748
.about(iterableEntries())
749749
.that(actual.entries())
750750
.comparingElementsUsing(new EntryCorrespondence<K, A, V>(correspondence))
751-
.containsAllIn(expectedMultimap.entries());
751+
.containsAtLeastElementsIn(expectedMultimap.entries());
752752
}
753753

754754
/**

core/src/main/java/com/google/common/truth/PrimitiveDoubleArraySubject.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -263,17 +263,6 @@ public Ordered containsAtLeast(double[] expected) {
263263
return containsAtLeastElementsIn(Doubles.asList(expected));
264264
}
265265

266-
/**
267-
* As {@link #containsAllOf(Object, Object, Object...)} but taking a primitive double array.
268-
*
269-
* @deprecated Use {@link #containsAtLeast(double[])}, which is equivalent.
270-
*/
271-
@CanIgnoreReturnValue
272-
@Deprecated
273-
public Ordered containsAllOf(double[] expected) {
274-
return containsAtLeast(expected);
275-
}
276-
277266
/** As {@link #containsAnyOf(Object, Object, Object...)} but taking a primitive double array. */
278267
public void containsAnyOf(double[] expected) {
279268
containsAnyIn(Doubles.asList(expected));

core/src/main/java/com/google/common/truth/PrimitiveFloatArraySubject.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -270,17 +270,6 @@ public Ordered containsAtLeast(float[] expected) {
270270
return containsAtLeastElementsIn(Floats.asList(expected));
271271
}
272272

273-
/**
274-
* As {@link #containsAllOf(Object, Object, Object...)} but taking a primitive float array.
275-
*
276-
* @deprecated Use {@link #containsAtLeast(float[])}, which is equivalent.
277-
*/
278-
@CanIgnoreReturnValue
279-
@Deprecated
280-
public Ordered containsAllOf(float[] expected) {
281-
return containsAtLeast(expected);
282-
}
283-
284273
/** As {@link #containsAnyOf(Object, Object, Object...)} but taking a primitive float array. */
285274
public void containsAnyOf(float[] expected) {
286275
containsAnyIn(Floats.asList(expected));

core/src/main/java/com/google/common/truth/Subject.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ public final void isSameInstanceAs(@NullableDecl Object expected) {
259259
/*
260260
* Pass through *whether* the values are equal so that failEqualityCheck() can print that
261261
* information. But remove the description of the difference, which is always about
262-
* content, since people calling isSameAs() are explicitly not interested in content, only
263-
* object identity.
262+
* content, since people calling isSameInstanceAs() are explicitly not interested in
263+
* content, only object identity.
264264
*/
265265
compareForEquality(expected).withoutDescription());
266266
}
@@ -820,7 +820,8 @@ private void failEqualityCheck(
820820
boolean sameToStrings = actualString.equals(expectedString);
821821
boolean sameClassNames = actualClass.equals(expectedClass);
822822
// TODO(cpovirk): Handle "same class name, different class loader."
823-
boolean equal = difference.valuesAreEqual(); // always false for isEqualTo; varies for isSameAs
823+
// `equal` is always false for isEqualTo, but it varies for isSameInstanceAs:
824+
boolean equal = difference.valuesAreEqual();
824825
// TODO(cpovirk): Call attention to differing trailing whitespace.
825826

826827
if (sameToStrings) {

core/src/main/java/com/google/common/truth/ThrowableSubject.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ protected ThrowableSubject(FailureMetadata metadata, @NullableDecl Throwable thr
4242
}
4343

4444
/*
45-
* TODO(cpovirk): consider a special case for isEqualTo and isSameAs that adds |expected| as a
46-
* suppressed exception
45+
* TODO(cpovirk): consider a special case for isEqualTo and isSameInstanceAs that adds |expected|
46+
* as a suppressed exception
4747
*/
4848

4949
/** Returns a {@code StringSubject} to make assertions about the throwable's message. */

core/src/main/java/com/google/common/truth/Truth.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
* assertThat(a).isEqualTo(b);
4747
* assertThat(c).isTrue();
4848
* assertThat(d).contains(a);
49-
* assertThat(d).containsAllOf(a, b);
49+
* assertThat(d).containsAtLeast(a, b);
5050
* assertThat(d).containsAnyOf(a, b, c);
5151
* }</pre>
5252
*

0 commit comments

Comments
 (0)