aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Keppler2018-04-05 12:36:56 -0400
committerMichael Keppler2018-04-05 12:36:56 -0400
commit5fad06251c0b68aa4743fbfde25ad474d73f1a46 (patch)
tree84b232f1ae8ad6186de2161ca6479050d6ab71f2
parent569149b9dd4044017f83b50567491205b1738631 (diff)
downloadegit-github-5fad06251c0b68aa4743fbfde25ad474d73f1a46.zip
egit-github-5fad06251c0b68aa4743fbfde25ad474d73f1a46.tar.gz
egit-github-5fad06251c0b68aa4743fbfde25ad474d73f1a46.tar.xz
Silence unusual equals() argument type warnings
Since Oxygen the compiler can show a warning for non fitting equals argument types. This change silences the warnings by masking out the runtime type. Change-Id: I6ce095e38d1e59e70672c18a35426b2364f60684 Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/LabelTest.java3
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/RepositoryIdTest.java3
-rwxr-xr-xorg.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/SearchRepositoryTest.java285
3 files changed, 147 insertions, 144 deletions
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/LabelTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/LabelTest.java
index ca00498..7bab9c3 100644
--- a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/LabelTest.java
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/LabelTest.java
@@ -59,7 +59,8 @@ public class LabelTest {
l1.setName("a");
Label l3 = new Label().setName("a");
assertTrue(l1.equals(l1));
- assertFalse(l1.equals("a"));
+ Object string = "a";
+ assertFalse(l1.equals(string));
assertFalse(l1.equals(l2));
assertTrue(l1.equals(l3));
assertEquals(l1.hashCode(), l3.hashCode());
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/RepositoryIdTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/RepositoryIdTest.java
index 6e50007..1c85cb0 100644
--- a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/RepositoryIdTest.java
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/RepositoryIdTest.java
@@ -201,7 +201,8 @@ public class RepositoryIdTest {
assertTrue(id1.equals(id1));
assertTrue(id1.equals(id2));
assertFalse(id1.equals(id3));
- assertFalse(id1.equals("content"));
+ Object string = "content";
+ assertFalse(id1.equals(string));
assertEquals(id1.hashCode(), id2.hashCode());
assertEquals(id1.toString(), id2.toString());
}
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/SearchRepositoryTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/SearchRepositoryTest.java
index 4c638c0..86c430c 100755
--- a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/SearchRepositoryTest.java
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/SearchRepositoryTest.java
@@ -1,142 +1,143 @@
-/*******************************************************************************
- * Copyright (c) 2011 Christian Trutz
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Christian Trutz - initial API and implementation
- *******************************************************************************/
-package org.eclipse.egit.github.core.tests;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import org.eclipse.egit.github.core.SearchRepository;
-import org.junit.Test;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-
-/**
- * Unit tests of {@link SearchRepository}
- */
-public class SearchRepositoryTest {
-
- private static final Gson gson = new GsonBuilder().setDateFormat(
- "yyyy-MM-dd").create();
-
- /**
- * Test default state of search repository
- */
- @Test
- public void defaultState() {
- SearchRepository repo = new SearchRepository("a", "b");
- assertEquals("a/b", repo.generateId());
- assertNull(repo.getCreatedAt());
- assertNull(repo.getDescription());
- assertEquals(0, repo.getForks());
- assertNull(repo.getHomepage());
- assertEquals("a/b", repo.getId());
- assertNull(repo.getLanguage());
- assertEquals("b", repo.getName());
- assertEquals(0, repo.getOpenIssues());
- assertEquals("a", repo.getOwner());
- assertNull(repo.getPushedAt());
- assertEquals(0, repo.getSize());
- assertNull(repo.getUrl());
- assertEquals(0, repo.getWatchers());
- assertFalse(repo.isFork());
- assertFalse(repo.isHasDownloads());
- assertFalse(repo.isHasIssues());
- assertFalse(repo.isHasWiki());
- assertFalse(repo.isPrivate());
- }
-
- /**
- * Verify search repository equality
- */
- @Test
- public void equality() {
- SearchRepository repo1 = new SearchRepository("a", "b");
- SearchRepository repo2 = new SearchRepository("a", "c");
- SearchRepository repo3 = new SearchRepository("a", "b");
- assertTrue(repo1.equals(repo1));
- assertFalse(repo1.equals("repo1"));
- assertFalse(repo1.equals(repo2));
- assertTrue(repo1.equals(repo3));
- assertEquals(repo1.hashCode(), repo3.hashCode());
- assertEquals(repo1.toString(), repo3.toString());
- }
-
- /**
- * Create with null owner
- */
- @Test(expected = IllegalArgumentException.class)
- public void createNullOwner() {
- new SearchRepository(null, "name");
- }
-
- /**
- * Create with empty owner
- */
- @Test(expected = IllegalArgumentException.class)
- public void createEmptyOwner() {
- new SearchRepository("", "name");
- }
-
- /**
- * Create with null name
- */
- @Test(expected = IllegalArgumentException.class)
- public void createNullName() {
- new SearchRepository("owner", null);
- }
-
- /**
- * Create with empty name
- */
- @Test(expected = IllegalArgumentException.class)
- public void createEmptyName() {
- new SearchRepository("owner", "");
- }
-
- /**
- * Verify repository with no generated id
- */
- @Test
- public void noGeneratedId() {
- SearchRepository repo = gson.fromJson("{}", SearchRepository.class);
- assertNull(repo.generateId());
- repo = gson.fromJson("{name:\"\", owner:\"use\"}",
- SearchRepository.class);
- assertNull(repo.generateId());
- repo = gson.fromJson("{owner:\"\"}", SearchRepository.class);
- assertNull(repo.generateId());
- }
-
- /**
- * Test non-mutable created at date
- */
- @Test
- public void getCreatedAtReferenceMutableObject() {
- SearchRepository repository = gson.fromJson(
- "{createdAt : '2003-10-10'}", SearchRepository.class);
- repository.getCreatedAt().setTime(0);
- assertTrue(repository.getCreatedAt().getTime() != 0);
- }
-
- /**
- * Test non-mutable pushed at date
- */
- @Test
- public void getPushedAtReferenceMutableObject() {
- SearchRepository repository = gson.fromJson(
- "{pushedAt : '2003-10-10'}", SearchRepository.class);
- repository.getPushedAt().setTime(0);
- assertTrue(repository.getPushedAt().getTime() != 0);
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2011 Christian Trutz
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christian Trutz - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.egit.github.core.tests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import org.eclipse.egit.github.core.SearchRepository;
+import org.junit.Test;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+/**
+ * Unit tests of {@link SearchRepository}
+ */
+public class SearchRepositoryTest {
+
+ private static final Gson gson = new GsonBuilder().setDateFormat(
+ "yyyy-MM-dd").create();
+
+ /**
+ * Test default state of search repository
+ */
+ @Test
+ public void defaultState() {
+ SearchRepository repo = new SearchRepository("a", "b");
+ assertEquals("a/b", repo.generateId());
+ assertNull(repo.getCreatedAt());
+ assertNull(repo.getDescription());
+ assertEquals(0, repo.getForks());
+ assertNull(repo.getHomepage());
+ assertEquals("a/b", repo.getId());
+ assertNull(repo.getLanguage());
+ assertEquals("b", repo.getName());
+ assertEquals(0, repo.getOpenIssues());
+ assertEquals("a", repo.getOwner());
+ assertNull(repo.getPushedAt());
+ assertEquals(0, repo.getSize());
+ assertNull(repo.getUrl());
+ assertEquals(0, repo.getWatchers());
+ assertFalse(repo.isFork());
+ assertFalse(repo.isHasDownloads());
+ assertFalse(repo.isHasIssues());
+ assertFalse(repo.isHasWiki());
+ assertFalse(repo.isPrivate());
+ }
+
+ /**
+ * Verify search repository equality
+ */
+ @Test
+ public void equality() {
+ SearchRepository repo1 = new SearchRepository("a", "b");
+ SearchRepository repo2 = new SearchRepository("a", "c");
+ SearchRepository repo3 = new SearchRepository("a", "b");
+ assertTrue(repo1.equals(repo1));
+ Object string = "repo1";
+ assertFalse(repo1.equals(string));
+ assertFalse(repo1.equals(repo2));
+ assertTrue(repo1.equals(repo3));
+ assertEquals(repo1.hashCode(), repo3.hashCode());
+ assertEquals(repo1.toString(), repo3.toString());
+ }
+
+ /**
+ * Create with null owner
+ */
+ @Test(expected = IllegalArgumentException.class)
+ public void createNullOwner() {
+ new SearchRepository(null, "name");
+ }
+
+ /**
+ * Create with empty owner
+ */
+ @Test(expected = IllegalArgumentException.class)
+ public void createEmptyOwner() {
+ new SearchRepository("", "name");
+ }
+
+ /**
+ * Create with null name
+ */
+ @Test(expected = IllegalArgumentException.class)
+ public void createNullName() {
+ new SearchRepository("owner", null);
+ }
+
+ /**
+ * Create with empty name
+ */
+ @Test(expected = IllegalArgumentException.class)
+ public void createEmptyName() {
+ new SearchRepository("owner", "");
+ }
+
+ /**
+ * Verify repository with no generated id
+ */
+ @Test
+ public void noGeneratedId() {
+ SearchRepository repo = gson.fromJson("{}", SearchRepository.class);
+ assertNull(repo.generateId());
+ repo = gson.fromJson("{name:\"\", owner:\"use\"}",
+ SearchRepository.class);
+ assertNull(repo.generateId());
+ repo = gson.fromJson("{owner:\"\"}", SearchRepository.class);
+ assertNull(repo.generateId());
+ }
+
+ /**
+ * Test non-mutable created at date
+ */
+ @Test
+ public void getCreatedAtReferenceMutableObject() {
+ SearchRepository repository = gson.fromJson(
+ "{createdAt : '2003-10-10'}", SearchRepository.class);
+ repository.getCreatedAt().setTime(0);
+ assertTrue(repository.getCreatedAt().getTime() != 0);
+ }
+
+ /**
+ * Test non-mutable pushed at date
+ */
+ @Test
+ public void getPushedAtReferenceMutableObject() {
+ SearchRepository repository = gson.fromJson(
+ "{pushedAt : '2003-10-10'}", SearchRepository.class);
+ repository.getPushedAt().setTime(0);
+ assertTrue(repository.getPushedAt().getTime() != 0);
+ }
+}