Skip to content

Commit b02a658

Browse files
cpovirkGoogle Java Core Libraries
authored andcommitted
Migrate most usages of Truth8.assertThat to equivalent usages of Truth.assertThat, and qualify others.
By "qualify," I mean that, instead of static importing `Truth8.assertThat`, we write "`Truth8.assertThat(...)`" at the call site. This is normally the opposite of what we recommend. However, it's a necessary step in our migration: We are copying all the `Truth8` methods to `Truth`, and we can't do that if any files static import both `Truth.assertThat` and `Truth8.assertThat` (because it produces a compile error about ambiguous overloads). To unblock that, we're moving callers away from the static import. We will update static analysis to stop suggesting the import. A later step will migrate these callers to the new `Truth.assertThat` methods, which we will static import. The `Truth8` methods will be hidden in the future. All callers will use `Truth`. This continues our work on #746. PiperOrigin-RevId: 603151738
1 parent 0999369 commit b02a658

File tree

3 files changed

+61
-63
lines changed

3 files changed

+61
-63
lines changed

extensions/java8/src/test/java/com/google/common/truth/IntStreamSubjectTest.java

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import static com.google.common.truth.FailureAssertions.assertFailureKeys;
1919
import static com.google.common.truth.FailureAssertions.assertFailureValue;
2020
import static com.google.common.truth.IntStreamSubject.intStreams;
21-
import static com.google.common.truth.Truth8.assertThat;
2221
import static java.util.Arrays.asList;
2322
import static org.junit.Assert.fail;
2423

@@ -39,7 +38,7 @@ public final class IntStreamSubjectTest {
3938
@Test
4039
public void testIsEqualTo() throws Exception {
4140
IntStream stream = IntStream.of(42);
42-
assertThat(stream).isEqualTo(stream);
41+
Truth8.assertThat(stream).isEqualTo(stream);
4342
}
4443

4544
@Test
@@ -53,7 +52,7 @@ public void testIsEqualToList() throws Exception {
5352
public void testNullStream_fails() throws Exception {
5453
IntStream nullStream = null;
5554
try {
56-
assertThat(nullStream).isEmpty();
55+
Truth8.assertThat(nullStream).isEmpty();
5756
fail();
5857
} catch (NullPointerException expected) {
5958
}
@@ -62,18 +61,18 @@ public void testNullStream_fails() throws Exception {
6261
@Test
6362
public void testNullStreamIsNull() throws Exception {
6463
IntStream nullStream = null;
65-
assertThat(nullStream).isNull();
64+
Truth8.assertThat(nullStream).isNull();
6665
}
6766

6867
@Test
6968
public void testIsSameInstanceAs() throws Exception {
7069
IntStream stream = IntStream.of(1);
71-
assertThat(stream).isSameInstanceAs(stream);
70+
Truth8.assertThat(stream).isSameInstanceAs(stream);
7271
}
7372

7473
@Test
7574
public void testIsEmpty() throws Exception {
76-
assertThat(IntStream.of()).isEmpty();
75+
Truth8.assertThat(IntStream.of()).isEmpty();
7776
}
7877

7978
@Test
@@ -84,7 +83,7 @@ public void testIsEmpty_fails() throws Exception {
8483

8584
@Test
8685
public void testIsNotEmpty() throws Exception {
87-
assertThat(IntStream.of(42)).isNotEmpty();
86+
Truth8.assertThat(IntStream.of(42)).isNotEmpty();
8887
}
8988

9089
@Test
@@ -95,7 +94,7 @@ public void testIsNotEmpty_fails() throws Exception {
9594

9695
@Test
9796
public void testHasSize() throws Exception {
98-
assertThat(IntStream.of(42)).hasSize(1);
97+
Truth8.assertThat(IntStream.of(42)).hasSize(1);
9998
}
10099

101100
@Test
@@ -106,7 +105,7 @@ public void testHasSize_fails() throws Exception {
106105

107106
@Test
108107
public void testContainsNoDuplicates() throws Exception {
109-
assertThat(IntStream.of(42)).containsNoDuplicates();
108+
Truth8.assertThat(IntStream.of(42)).containsNoDuplicates();
110109
}
111110

112111
@Test
@@ -117,7 +116,7 @@ public void testContainsNoDuplicates_fails() throws Exception {
117116

118117
@Test
119118
public void testContains() throws Exception {
120-
assertThat(IntStream.of(42)).contains(42);
119+
Truth8.assertThat(IntStream.of(42)).contains(42);
121120
}
122121

123122
@Test
@@ -128,7 +127,7 @@ public void testContains_fails() throws Exception {
128127

129128
@Test
130129
public void testContainsAnyOf() throws Exception {
131-
assertThat(IntStream.of(42)).containsAnyOf(42, 43);
130+
Truth8.assertThat(IntStream.of(42)).containsAnyOf(42, 43);
132131
}
133132

134133
@Test
@@ -139,7 +138,7 @@ public void testContainsAnyOf_fails() throws Exception {
139138

140139
@Test
141140
public void testContainsAnyIn() throws Exception {
142-
assertThat(IntStream.of(42)).containsAnyIn(asList(42, 43));
141+
Truth8.assertThat(IntStream.of(42)).containsAnyIn(asList(42, 43));
143142
}
144143

145144
@Test
@@ -151,7 +150,7 @@ public void testContainsAnyIn_fails() throws Exception {
151150

152151
@Test
153152
public void testDoesNotContain() throws Exception {
154-
assertThat(IntStream.of(42)).doesNotContain(43);
153+
Truth8.assertThat(IntStream.of(42)).doesNotContain(43);
155154
}
156155

157156
@Test
@@ -162,7 +161,7 @@ public void testDoesNotContain_fails() throws Exception {
162161

163162
@Test
164163
public void testContainsNoneOf() throws Exception {
165-
assertThat(IntStream.of(42)).containsNoneOf(43, 44);
164+
Truth8.assertThat(IntStream.of(42)).containsNoneOf(43, 44);
166165
}
167166

168167
@Test
@@ -173,7 +172,7 @@ public void testContainsNoneOf_fails() throws Exception {
173172

174173
@Test
175174
public void testContainsNoneIn() throws Exception {
176-
assertThat(IntStream.of(42)).containsNoneIn(asList(43, 44));
175+
Truth8.assertThat(IntStream.of(42)).containsNoneIn(asList(43, 44));
177176
}
178177

179178
@Test
@@ -185,7 +184,7 @@ public void testContainsNoneIn_fails() throws Exception {
185184

186185
@Test
187186
public void testContainsAtLeast() throws Exception {
188-
assertThat(IntStream.of(42, 43)).containsAtLeast(42, 43);
187+
Truth8.assertThat(IntStream.of(42, 43)).containsAtLeast(42, 43);
189188
}
190189

191190
@Test
@@ -197,7 +196,7 @@ public void testContainsAtLeast_fails() throws Exception {
197196

198197
@Test
199198
public void testContainsAtLeast_inOrder() throws Exception {
200-
assertThat(IntStream.of(42, 43)).containsAtLeast(42, 43).inOrder();
199+
Truth8.assertThat(IntStream.of(42, 43)).containsAtLeast(42, 43).inOrder();
201200
}
202201

203202
@Test
@@ -216,7 +215,7 @@ public void testContainsAtLeast_inOrder_fails() throws Exception {
216215

217216
@Test
218217
public void testContainsAtLeastElementsIn() throws Exception {
219-
assertThat(IntStream.of(42, 43)).containsAtLeastElementsIn(asList(42, 43));
218+
Truth8.assertThat(IntStream.of(42, 43)).containsAtLeastElementsIn(asList(42, 43));
220219
}
221220

222221
@Test
@@ -231,7 +230,7 @@ public void testContainsAtLeastElementsIn_fails() throws Exception {
231230

232231
@Test
233232
public void testContainsAtLeastElementsIn_inOrder() throws Exception {
234-
assertThat(IntStream.of(42, 43)).containsAtLeastElementsIn(asList(42, 43)).inOrder();
233+
Truth8.assertThat(IntStream.of(42, 43)).containsAtLeastElementsIn(asList(42, 43)).inOrder();
235234
}
236235

237236
@Test
@@ -253,7 +252,7 @@ public void testContainsAtLeastElementsIn_inOrder_fails() throws Exception {
253252

254253
@Test
255254
public void testContainsExactly() throws Exception {
256-
assertThat(IntStream.of(42, 43)).containsExactly(42, 43);
255+
Truth8.assertThat(IntStream.of(42, 43)).containsExactly(42, 43);
257256
}
258257

259258
@Test
@@ -266,7 +265,7 @@ public void testContainsExactly_fails() throws Exception {
266265

267266
@Test
268267
public void testContainsExactly_inOrder() throws Exception {
269-
assertThat(IntStream.of(42, 43)).containsExactly(42, 43).inOrder();
268+
Truth8.assertThat(IntStream.of(42, 43)).containsExactly(42, 43).inOrder();
270269
}
271270

272271
@Test
@@ -281,8 +280,8 @@ public void testContainsExactly_inOrder_fails() throws Exception {
281280

282281
@Test
283282
public void testContainsExactlyElementsIn() throws Exception {
284-
assertThat(IntStream.of(42, 43)).containsExactlyElementsIn(asList(42, 43));
285-
assertThat(IntStream.of(42, 43)).containsExactlyElementsIn(asList(43, 42));
283+
Truth8.assertThat(IntStream.of(42, 43)).containsExactlyElementsIn(asList(42, 43));
284+
Truth8.assertThat(IntStream.of(42, 43)).containsExactlyElementsIn(asList(43, 42));
286285
}
287286

288287
@Test
@@ -297,7 +296,7 @@ public void testContainsExactlyElementsIn_fails() throws Exception {
297296

298297
@Test
299298
public void testContainsExactlyElementsIn_inOrder() throws Exception {
300-
assertThat(IntStream.of(42, 43)).containsExactlyElementsIn(asList(42, 43)).inOrder();
299+
Truth8.assertThat(IntStream.of(42, 43)).containsExactlyElementsIn(asList(42, 43)).inOrder();
301300
}
302301

303302
@Test
@@ -315,14 +314,14 @@ public void testContainsExactlyElementsIn_inOrder_fails() throws Exception {
315314

316315
@Test
317316
public void testContainsExactlyElementsIn_inOrder_intStream() throws Exception {
318-
assertThat(IntStream.of(1, 2, 3, 4)).containsExactly(1, 2, 3, 4).inOrder();
317+
Truth8.assertThat(IntStream.of(1, 2, 3, 4)).containsExactly(1, 2, 3, 4).inOrder();
319318
}
320319

321320
@Test
322321
public void testIsInOrder() {
323-
assertThat(IntStream.of()).isInOrder();
324-
assertThat(IntStream.of(1)).isInOrder();
325-
assertThat(IntStream.of(1, 1, 2, 3, 3, 3, 4)).isInOrder();
322+
Truth8.assertThat(IntStream.of()).isInOrder();
323+
Truth8.assertThat(IntStream.of(1)).isInOrder();
324+
Truth8.assertThat(IntStream.of(1, 1, 2, 3, 3, 3, 4)).isInOrder();
326325
}
327326

328327
@Test
@@ -333,9 +332,9 @@ public void testIsInOrder_fails() {
333332

334333
@Test
335334
public void testIsInStrictOrder() {
336-
assertThat(IntStream.of()).isInStrictOrder();
337-
assertThat(IntStream.of(1)).isInStrictOrder();
338-
assertThat(IntStream.of(1, 2, 3, 4)).isInStrictOrder();
335+
Truth8.assertThat(IntStream.of()).isInStrictOrder();
336+
Truth8.assertThat(IntStream.of(1)).isInStrictOrder();
337+
Truth8.assertThat(IntStream.of(1, 2, 3, 4)).isInStrictOrder();
339338
}
340339

341340
@Test

0 commit comments

Comments
 (0)