From c3b3b39b5005838e0b45268d003d95f03fb8a878 Mon Sep 17 00:00:00 2001 From: Ben McIlwain Date: Tue, 26 Jan 2021 13:20:48 -0500 Subject: [PATCH] Use nullness parity helper (#944) * Use nullness parity helper --- .../registry/model/ImmutableObjectSubject.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/core/src/test/java/google/registry/model/ImmutableObjectSubject.java b/core/src/test/java/google/registry/model/ImmutableObjectSubject.java index 80f35086a..046cf0e21 100644 --- a/core/src/test/java/google/registry/model/ImmutableObjectSubject.java +++ b/core/src/test/java/google/registry/model/ImmutableObjectSubject.java @@ -16,6 +16,7 @@ package google.registry.model; import static com.google.common.truth.Truth.assertAbout; import static com.google.common.truth.Truth.assertThat; +import static google.registry.testing.truth.TruthUtils.assertNullnessParity; import com.google.common.collect.ImmutableSet; import com.google.common.truth.Correspondence; @@ -62,11 +63,7 @@ public final class ImmutableObjectSubject extends Subject { *

This is used to verify that entities stored in both cloud SQL and Datastore are identical. */ public void isEqualAcrossDatabases(@Nullable ImmutableObject expected) { - if (actual == null) { - assertThat(expected).isNull(); - } else { - assertThat(expected).isNotNull(); - } + assertNullnessParity(actual, expected); if (actual != null) { Map actualFields = filterFields(actual, ImmutableObject.DoNotCompare.class); Map expectedFields = @@ -109,7 +106,8 @@ public final class ImmutableObjectSubject extends Subject { } } - public static Map filterFields(ImmutableObject original, String... ignoredFields) { + private static Map filterFields( + ImmutableObject original, String... ignoredFields) { ImmutableSet ignoredFieldSet = ImmutableSet.copyOf(ignoredFields); Map originalFields = ModelUtils.getFieldValues(original); // don't use ImmutableMap or a stream->collect model since we can have nulls @@ -123,7 +121,7 @@ public final class ImmutableObjectSubject extends Subject { } /** Filter out fields with the given annotation. */ - public static Map filterFields( + private static Map filterFields( ImmutableObject original, Class annotation) { Map originalFields = ModelUtils.getFieldValues(original); // don't use ImmutableMap or a stream->collect model since we can have nulls