Fix warnings.
* Mark methods as static where reported.
* Don't use depredated new Integer()
* Remove redundant type declarations.
Change-Id: Iad30c7b08602900c769d6713e4be0f788897e502
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/service/DefaultMarketplaceServiceTest.java b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/service/DefaultMarketplaceServiceTest.java
index 7f31128..26bbf42 100644
--- a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/service/DefaultMarketplaceServiceTest.java
+++ b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/service/DefaultMarketplaceServiceTest.java
@@ -235,7 +235,7 @@
return result;
}
- private ICategory findCategory(IMarket toolsMarket, String categoryName) {
+ private static ICategory findCategory(IMarket toolsMarket, String categoryName) {
ICategory namedCategory = null;
for (ICategory category : toolsMarket.getCategory()) {
if (categoryName.equals(category.getName())) {
diff --git a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/service/SolutionCompatibilityFilterTest.java b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/service/SolutionCompatibilityFilterTest.java
index 1e60bcf..77d7f07 100644
--- a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/service/SolutionCompatibilityFilterTest.java
+++ b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/service/SolutionCompatibilityFilterTest.java
@@ -12,13 +12,8 @@
*******************************************************************************/
package org.eclipse.epp.mpc.tests.service;
-import static org.hamcrest.Matchers.empty;
-import static org.hamcrest.Matchers.hasItems;
-import static org.hamcrest.Matchers.hasSize;
-import static org.hamcrest.Matchers.isEmptyOrNullString;
-import static org.hamcrest.Matchers.not;
-import static org.junit.Assume.assumeFalse;
-import static org.junit.Assume.assumeTrue;
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assume.*;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -225,12 +220,15 @@
private final System[] systems;
+ private final boolean installable;
+
private Solution(String shortName, EclipseRelease minRelease, EclipseRelease maxRelease, System... systems) {
this.id = null;
this.shortName = shortName;
this.minRelease = minRelease;
this.maxRelease = maxRelease;
this.systems = systems;
+ this.installable = true;//TODO
}
public String id() {
@@ -250,8 +248,7 @@
}
public boolean installable() {
- //TODO
- return true;
+ return installable;
}
public EclipseRelease minRelease() {
diff --git a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/service/xml/UnmarshallerTest.java b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/service/xml/UnmarshallerTest.java
index ba8a9d9..5dab8c8 100644
--- a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/service/xml/UnmarshallerTest.java
+++ b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/service/xml/UnmarshallerTest.java
@@ -14,7 +14,13 @@
package org.eclipse.epp.mpc.tests.service.xml;
import static org.hamcrest.Matchers.containsString;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -143,7 +149,7 @@
assertNotNull(node.getCreated());
assertEquals(1259955243L, node.getCreated().getTime() / 1000);
- assertEquals(new Integer(3), node.getFavorited());
+ assertEquals(Integer.valueOf(3), node.getFavorited());
assertEquals(Boolean.TRUE, node.getFoundationmember());
assertNotNull(node.getChanged());
assertEquals(1259964722L, node.getChanged().getTime() / 1000);
@@ -531,7 +537,7 @@
}
}
- private IStatus getErrorContentInfo(UnmarshalException e) {
+ private static IStatus getErrorContentInfo(UnmarshalException e) {
IStatus status = e.getStatus();
assertTrue(status.isMultiStatus());
IStatus[] children = status.getChildren();
@@ -540,7 +546,7 @@
return contentChild;
}
- private ByteBuffer readResource(String resource, ByteBuffer buffer) throws IOException {
+ private static ByteBuffer readResource(String resource, ByteBuffer buffer) throws IOException {
ReadableByteChannel in = Channels.newChannel(getResourceAsStream(resource));
if (buffer == null) {
buffer = ByteBuffer.allocate(32768);
@@ -560,7 +566,7 @@
return buffer;
}
- private InputStream getResourceAsStream(String resource) {
+ private static InputStream getResourceAsStream(String resource) {
InputStream in = UnmarshallerTest.class.getResourceAsStream(resource);
if (in == null) {
throw new IllegalStateException(resource);
diff --git a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/MarketplaceClientUiTest.java b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/MarketplaceClientUiTest.java
index fb4461a..103ac0a 100644
--- a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/MarketplaceClientUiTest.java
+++ b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/MarketplaceClientUiTest.java
@@ -82,7 +82,7 @@
assertTrue(status.getMessage().startsWith(expectedMessage));
}
- private Exception wrapInCoreException(Throwable rootCause) {
+ private static Exception wrapInCoreException(Throwable rootCause) {
return new CoreException(new Status(IStatus.ERROR, "org.eclipse.epp.mpc.tests", "Nested Core Exception",
rootCause));
}
diff --git a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/catalog/MarketplaceInfoSerializationTest.java b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/catalog/MarketplaceInfoSerializationTest.java
index e39f9d4..d654f50 100644
--- a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/catalog/MarketplaceInfoSerializationTest.java
+++ b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/catalog/MarketplaceInfoSerializationTest.java
@@ -13,9 +13,18 @@
*******************************************************************************/
package org.eclipse.epp.mpc.tests.ui.catalog;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.doCallRealMethod;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
import java.io.File;
import java.io.FileOutputStream;
@@ -458,7 +467,7 @@
return registry;
}
- private void copyRegistryFile(File target, int percent) throws Exception {
+ private static void copyRegistryFile(File target, int percent) throws Exception {
URL registryContent = MarketplaceInfoSerializationTest.class.getResource("MarketplaceInfo.xml");
ReadableByteChannel in = null;
FileChannel out = null;
@@ -484,7 +493,7 @@
}
}
- private void createEmptyRegistryFile(File target) throws IOException {
+ private static void createEmptyRegistryFile(File target) throws IOException {
target.getParentFile().mkdirs();
assertTrue(target.getParentFile().isDirectory());
target.createNewFile();
diff --git a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/catalog/MarketplaceInfoTest.java b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/catalog/MarketplaceInfoTest.java
index 5e05c1b..bf63402 100644
--- a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/catalog/MarketplaceInfoTest.java
+++ b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/catalog/MarketplaceInfoTest.java
@@ -153,7 +153,7 @@
assertEquals(item.getData().getUrl(), installedCatalogNodeIds.iterator().next().getUrl());
}
- private InstallableUnit addIU(Map<String, IInstallableUnit> installedIus, String id) {
+ private static InstallableUnit addIU(Map<String, IInstallableUnit> installedIus, String id) {
InstallableUnit installableUnit = (InstallableUnit) installedIus.get(id);
if (installableUnit == null) {
installableUnit = new InstallableUnit();
diff --git a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/wizard/AbstractMarketplaceWizardBotTest.java b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/wizard/AbstractMarketplaceWizardBotTest.java
index ffd7524..3bfe7a1 100644
--- a/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/wizard/AbstractMarketplaceWizardBotTest.java
+++ b/org.eclipse.epp.mpc.tests/src/org/eclipse/epp/mpc/tests/ui/wizard/AbstractMarketplaceWizardBotTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2018 The Eclipse Foundation and others.
+ * Copyright (c) 2010, 2019 The Eclipse Foundation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
@@ -15,8 +15,16 @@
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.widgetOfType;
import static org.eclipse.swtbot.swt.finder.waits.Conditions.shellIsActive;
import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.Matchers.allOf;
+import static org.hamcrest.Matchers.empty;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.File;
import java.lang.management.ManagementFactory;
@@ -305,7 +313,7 @@
}
}
- private void dumpThreads() {
+ private static void dumpThreads() {
if (!dumpThreadsOnTearDownError) {
return;
}
@@ -325,7 +333,7 @@
}
}
- private String captureShellScreenshot(SWTBotShell botShell) {
+ private static String captureShellScreenshot(SWTBotShell botShell) {
if (botShell.isVisible()) {
try {
//try to bring to front
@@ -343,7 +351,7 @@
return "";
}
- private String describeShell(SWTBotShell botShell) {
+ private static String describeShell(SWTBotShell botShell) {
StringBuilder description = new StringBuilder(" Shell(\"").append(botShell.getText()).append("\")");
try {
@@ -480,7 +488,7 @@
return links;
}
- private StyleRange[] findStyleRanges(final SWTBotStyledText styledText) {
+ private static StyleRange[] findStyleRanges(final SWTBotStyledText styledText) {
StyleRange[] ranges = UIThreadRunnable.syncExec((ArrayResult<StyleRange>) () -> styledText.widget
.getStyleRanges());
return ranges;
@@ -522,7 +530,7 @@
checkSelected(filter, choice);
}
- private void checkSelected(AbstractTagFilter filter, String selection) {
+ private static void checkSelected(AbstractTagFilter filter, String selection) {
Set<Tag> selected = filter.getSelected();
if (selection == null) {
assertTrue(selected.isEmpty());
diff --git a/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/catalog/MarketplaceCatalog.java b/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/catalog/MarketplaceCatalog.java
index c2707f8..1a3ab6c 100644
--- a/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/catalog/MarketplaceCatalog.java
+++ b/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/catalog/MarketplaceCatalog.java
@@ -144,7 +144,7 @@
Map<String, IInstallableUnit> installedIUs = calculateInstalledIUs(progress.newChild(100000));
List<MarketplaceNodeCatalogItem> updateCheckNeeded = new ArrayList<>();
List<CatalogItem> updateCheckItems = getUpdateCheckItems(progress.newChild(100000));
- List<MarketplaceNodeCatalogItem> updateableItems = new ArrayList<MarketplaceNodeCatalogItem>();
+ List<MarketplaceNodeCatalogItem> updateableItems = new ArrayList<>();
for (CatalogItem item : updateCheckItems) {
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
diff --git a/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/catalog/MarketplaceDiscoveryStrategy.java b/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/catalog/MarketplaceDiscoveryStrategy.java
index c2732d3..d05292a 100644
--- a/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/catalog/MarketplaceDiscoveryStrategy.java
+++ b/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/catalog/MarketplaceDiscoveryStrategy.java
@@ -903,7 +903,7 @@
try {
List<CatalogCategory> categories = getCategories();
if (categories == null) {
- categories = new ArrayList<CatalogCategory>();
+ categories = new ArrayList<>();
setCategories(categories);
}
for (CatalogCategory candidate : categories) {
diff --git a/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/wizards/FeatureSelectionWizardPage.java b/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/wizards/FeatureSelectionWizardPage.java
index 74ee0ca..f49f4a4 100644
--- a/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/wizards/FeatureSelectionWizardPage.java
+++ b/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/wizards/FeatureSelectionWizardPage.java
@@ -306,7 +306,7 @@
if (i == 0) {
i = s1.compareTo(s2);
if (i == 0) {
- i = new Integer(System.identityHashCode(e1)).compareTo(System.identityHashCode(e2));
+ i = Integer.valueOf(System.identityHashCode(e1)).compareTo(System.identityHashCode(e2));
}
}
return i;