Skip to content

Commit

Permalink
Fix warnings.
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
akurtakov authored and creckord committed Mar 1, 2019
1 parent 7bccf78 commit b60c132
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 32 deletions.
Expand Up @@ -235,7 +235,7 @@ private ISearchResult search(String marketName, String categoryName, String quer
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())) {
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -225,12 +220,15 @@ public static enum Solution {

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() {
Expand All @@ -250,8 +248,7 @@ public String query() {
}

public boolean installable() {
//TODO
return true;
return installable;
}

public EclipseRelease minRelease() {
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -143,7 +149,7 @@ public void node() throws IOException, UnmarshalException {

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);
Expand Down Expand Up @@ -531,7 +537,7 @@ public void invalidContentErrorMessage() throws Exception {
}
}

private IStatus getErrorContentInfo(UnmarshalException e) {
private static IStatus getErrorContentInfo(UnmarshalException e) {
IStatus status = e.getStatus();
assertTrue(status.isMultiStatus());
IStatus[] children = status.getChildren();
Expand All @@ -540,7 +546,7 @@ private IStatus getErrorContentInfo(UnmarshalException e) {
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);
Expand All @@ -560,7 +566,7 @@ private ByteBuffer readResource(String resource, ByteBuffer buffer) throws IOExc
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);
Expand Down
Expand Up @@ -82,7 +82,7 @@ public void testStatusHandling() {
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));
}
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -458,7 +467,7 @@ private TestRegistryFile setupRestrictedRegistry(File... writable) throws IOExce
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;
Expand All @@ -484,7 +493,7 @@ private void copyRegistryFile(File target, int percent) throws Exception {
}
}

private void createEmptyRegistryFile(File target) throws IOException {
private static void createEmptyRegistryFile(File target) throws IOException {
target.getParentFile().mkdirs();
assertTrue(target.getParentFile().isDirectory());
target.createNewFile();
Expand Down
Expand Up @@ -153,7 +153,7 @@ public void computeInstalledCatalogNodeIdsNoMarketplaceInfo() {
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();
Expand Down
@@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -305,7 +313,7 @@ protected void closeWizard() {
}
}

private void dumpThreads() {
private static void dumpThreads() {
if (!dumpThreadsOnTearDownError) {
return;
}
Expand All @@ -325,7 +333,7 @@ private void dumpThreads() {
}
}

private String captureShellScreenshot(SWTBotShell botShell) {
private static String captureShellScreenshot(SWTBotShell botShell) {
if (botShell.isVisible()) {
try {
//try to bring to front
Expand All @@ -343,7 +351,7 @@ private String captureShellScreenshot(SWTBotShell botShell) {
return "";
}

private String describeShell(SWTBotShell botShell) {
private static String describeShell(SWTBotShell botShell) {
StringBuilder description = new StringBuilder(" Shell(\"").append(botShell.getText()).append("\")");

try {
Expand Down Expand Up @@ -480,7 +488,7 @@ protected List<StyleRange> findLinks(final SWTBotStyledText styledText) {
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;
Expand Down Expand Up @@ -522,7 +530,7 @@ protected void select(SWTBotCombo comboBox, Class<?> classifier, String choice)
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());
Expand Down
Expand Up @@ -144,7 +144,7 @@ public IStatus checkForUpdates(final IProgressMonitor monitor) {
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;
Expand Down
Expand Up @@ -903,7 +903,7 @@ protected MarketplaceCategory findMarketplaceCategory(IProgressMonitor monitor)
try {
List<CatalogCategory> categories = getCategories();
if (categories == null) {
categories = new ArrayList<CatalogCategory>();
categories = new ArrayList<>();
setCategories(categories);
}
for (CatalogCategory candidate : categories) {
Expand Down
Expand Up @@ -306,7 +306,7 @@ public int compare(Viewer viewer, Object e1, Object e2) {
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;
Expand Down

0 comments on commit b60c132

Please sign in to comment.