8000 Update tests that were manually asserting that objects were not equal… · AnnaQiC/google-http-java-client@3e6c794 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3e6c794

Browse files
nick-someonegarrettjonesgoogle
authored andcommitted
Update tests that were manually asserting that objects were not equals() to an object of an unrelated class to use EqualsTester instead, which exhaustively checks equals() and hashCode().
This CL is in service of enabling a new compile-time error: go/bugpattern/EqualsIncompatibleType This change is part of an go/LSC process. See more about this change: https://docs.google.com/document/d/1iUC8Xpss0Y558wuipOVHvdQAMRMgR_oWHCeSdLV22xw/edit Tested: TAP --sample for global presubmit queue http://test/OCL:149062924:BASE:149043627:1488501672029:8ae9f150 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=149781297
1 parent 1c6049a commit 3e6c794

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

google-http-client/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@
118118
<artifactId>guava-jdk5</artifactId>
119119
<scope>provided</scope>
120120
</dependency>
121+
<dependency>
122+
<groupId>com.google.guava</groupId>
123+
<artifactId>guava-testlib-jdk5</artifactId>
124+
<scope>test</scope>
125+
</dependency>
121126
<dependency>
122127
<groupId>junit</groupId>
123128
<artifactId>junit</artifactId>

google-http-client/src/test/java/com/google/api/client/http/HttpMediaTypeTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
package com.google.api.client.http;
1616

1717
import com.google.common.base.Charsets;
18-
18+
import com.google.common.testing.EqualsTester;
1919
import junit.framework.TestCase;
2020

2121
/**
@@ -184,10 +184,10 @@ public void testEqualsIgnoreParameters_static() {
184184
}
185185

186186
public void testEquals() {
187-
assertEquals(true, new HttpMediaType("foo/bar").equals(new HttpMediaType("foo/bar")));
188-
assertEquals(true, new HttpMediaType("foo/bar; a=c").equals(new HttpMediaType("foo/bar; a=c")));
189-
assertEquals(false, new HttpMediaType("foo/bar; bar=bar").equals(new HttpMediaType("foo/bar")));
190-
assertEquals(false, new HttpMediaType("foo/bar").equals(null));
191-
assertEquals(false, new HttpMediaType("foo/bar").equals(new Integer(5)));
187+
new EqualsTester()
188+
.addEqualityGroup(new HttpMediaType("foo/bar"), new HttpMediaType("foo/bar"))
189+
.addEqualityGroup(new HttpMediaType("foo/bar; a=c"), new HttpMediaType("foo/bar; a=c"))
190+
.addEqualityGroup(new HttpMediaType("foo/bar; bar=bar"))
191+
.testEquals();
192192
}
193193
}

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@
168168
<artifactId>guava-jdk5</artifactId>
169169
<version>${project.guava.version}</version>
170170
</dependency>
171+
<dependency>
172+
<groupId>com.google.guava</groupId>
173+
<artifactId>guava-testlib-jdk5</artifactId>
174+
<version>${project.guava.version}</version>
175+
</dependency>
171176
<dependency>
172177
<groupId>com.google.code.findbugs</groupId>
173178
<artifactId>jsr305</artifactId>

0 commit comments

Comments
 (0)
0