Remove unnecessary Objects.equals() call on collections

This fixes a bug where collections of incompatible types are being tested for equality to each other (e.g.: Set<Foo> equals Set<Integer> should never return true unless both sets are empty, a bit of a vacuous assertion).

This change is necessary to unblock future improvements to the static analysis capabilities of the java compiler.
Tested:
    TAP --sample for global presubmit queue
    []

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=178798071
This commit is contained in:
glorioso 2017-12-12 12:28:46 -08:00 committed by jianglai
parent fb25b86212
commit 08b068b7bf

View file

@ -18,7 +18,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.truth.Truth.assertAbout; import static com.google.common.truth.Truth.assertAbout;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import com.google.common.collect.ImmutableSet;
import com.google.common.truth.FailureMetadata; import com.google.common.truth.FailureMetadata;
import com.google.common.truth.SimpleSubjectBuilder; import com.google.common.truth.SimpleSubjectBuilder;
import google.registry.model.domain.DomainApplication; import google.registry.model.domain.DomainApplication;
@ -58,13 +57,11 @@ public final class DomainApplicationSubject
public And<DomainApplicationSubject> hasExactlyEncodedSignedMarks( public And<DomainApplicationSubject> hasExactlyEncodedSignedMarks(
EncodedSignedMark... encodedSignedMarks) { EncodedSignedMark... encodedSignedMarks) {
if (!Objects.equals(
ImmutableSet.copyOf(actual().getEncodedSignedMarks()), assertThat(actual().getEncodedSignedMarks())
ImmutableSet.of(encodedSignedMarks))) { .named("the encoded signed marks of " + actualAsString())
assertThat(actual().getEncodedSignedMarks()) .containsExactly((Object[]) encodedSignedMarks);
.named("the encoded signed marks of " + actualAsString())
.containsExactly((Object[]) encodedSignedMarks);
}
return andChainer(); return andChainer();
} }