Replace assertThat(stream.collect(toImmutableList())) with assertThat(stream)

In Truth8, we can do assertThat(stream) directly. It's less verbose and clearer
in most cases.

Note that for the "finishers" (e.g. "containsExactyElementsIn") - streams are
still not allowed. So when there is:
assertThat(stream.map(someTransformation).collect(toList()))
.containsExactlyElementsIn(expecteStream.map(someTransformation).collect(toList()));

I kept the .collect in the assertThat to preserve the symmetry with the
finisher.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=179697587
This commit is contained in:
guyben 2017-12-20 09:48:20 -08:00 committed by Ben McIlwain
parent 50998136b1
commit 7d165a08cf
5 changed files with 14 additions and 48 deletions

View file

@ -14,8 +14,8 @@
package google.registry.tools;
import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.persistPremiumList;
import static google.registry.testing.DatastoreHelper.persistReservedList;
@ -281,12 +281,7 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
public void testSuccess_setReservedLists() throws Exception {
runCommandForced("--reserved_lists=xn--q9jyb4c_r1,xn--q9jyb4c_r2", "xn--q9jyb4c");
assertThat(
Registry.get("xn--q9jyb4c")
.getReservedLists()
.stream()
.map(Key::getName)
.collect(toImmutableList()))
assertThat(Registry.get("xn--q9jyb4c").getReservedLists().stream().map(Key::getName))
.containsExactly("xn--q9jyb4c_r1", "xn--q9jyb4c_r2");
}
@ -296,12 +291,7 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
.setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1", "xn--q9jyb4c_r2"))
.build());
runCommandForced("--reserved_lists=xn--q9jyb4c_r2", "xn--q9jyb4c");
assertThat(
Registry.get("xn--q9jyb4c")
.getReservedLists()
.stream()
.map(Key::getName)
.collect(toImmutableList()))
assertThat(Registry.get("xn--q9jyb4c").getReservedLists().stream().map(Key::getName))
.containsExactly("xn--q9jyb4c_r2");
}
@ -311,12 +301,7 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
.setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1"))
.build());
runCommandForced("--add_reserved_lists=xn--q9jyb4c_r2", "xn--q9jyb4c");
assertThat(
Registry.get("xn--q9jyb4c")
.getReservedLists()
.stream()
.map(Key::getName)
.collect(toImmutableList()))
assertThat(Registry.get("xn--q9jyb4c").getReservedLists().stream().map(Key::getName))
.containsExactly("xn--q9jyb4c_r1", "xn--q9jyb4c_r2");
}
@ -335,12 +320,7 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
.setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1", "xn--q9jyb4c_r2"))
.build());
runCommandForced("--remove_reserved_lists=xn--q9jyb4c_r1", "xn--q9jyb4c");
assertThat(
Registry.get("xn--q9jyb4c")
.getReservedLists()
.stream()
.map(Key::getName)
.collect(toImmutableList()))
assertThat(Registry.get("xn--q9jyb4c").getReservedLists().stream().map(Key::getName))
.containsExactly("xn--q9jyb4c_r2");
}