aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Gageot <david@gageot.net>2012-05-23 22:27:10 +0200
committerDavid Gageot <david@gageot.net>2012-05-23 22:34:46 +0200
commit01dd8cde2c85c6f2c87eb9798fd2cc6020302ed3 (patch)
tree301788914ab32e4a2a972716c0ed8db8ac844294
parentfe9e4f3eea867948e25642c24d0ff376907a3f2a (diff)
downloadsonarqube-01dd8cde2c85c6f2c87eb9798fd2cc6020302ed3.tar.gz
sonarqube-01dd8cde2c85c6f2c87eb9798fd2cc6020302ed3.zip
Remove warnings
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrapper/Batch.java12
-rw-r--r--sonar-core/src/test/java/org/sonar/core/persistence/DaoTestCase.java16
-rw-r--r--sonar-core/src/test/java/org/sonar/core/resource/ResourceDaoTest.java61
-rw-r--r--sonar-maven-plugin/src/main/java/org/sonar/maven/SonarMojo.java5
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/BatchExtensionDictionnary.java4
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/measures/RangeDistributionBuilder.java3
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/utils/DeprecatedKeyValueFormatTest.java2
7 files changed, 43 insertions, 60 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/Batch.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/Batch.java
index b5804550322..9deee34e35e 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/Batch.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/Batch.java
@@ -20,14 +20,14 @@
package org.sonar.batch.bootstrapper;
import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
import org.sonar.api.batch.bootstrap.ProjectReactor;
import org.sonar.batch.bootstrap.BootstrapModule;
import org.sonar.batch.bootstrap.Module;
import org.sonar.core.PicoUtils;
-import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
-import java.util.Map;
/**
* Entry point for batch bootstrappers.
@@ -46,7 +46,7 @@ public final class Batch {
components.add(builder.environment);
projectReactor = builder.projectReactor;
if (builder.isEnableLoggingConfiguration()) {
- logging = LoggingConfiguration.create().setProperties((Map) projectReactor.getRoot().getProperties());
+ logging = LoggingConfiguration.create().setProperties(Maps.fromProperties(projectReactor.getRoot().getProperties()));
}
}
@@ -89,7 +89,7 @@ public final class Batch {
public static final class Builder {
private ProjectReactor projectReactor;
private EnvironmentInformation environment;
- private List components = Lists.newArrayList();
+ private List<Object> components = Lists.newArrayList();
private boolean enableLoggingConfiguration = true;
private Builder() {
@@ -105,13 +105,13 @@ public final class Batch {
return this;
}
- public Builder setComponents(List l) {
+ public Builder setComponents(List<Object> l) {
this.components = l;
return this;
}
public Builder addComponents(Object... components) {
- this.components.addAll(Arrays.asList(components));
+ Collections.addAll(this.components, components);
return this;
}
diff --git a/sonar-core/src/test/java/org/sonar/core/persistence/DaoTestCase.java b/sonar-core/src/test/java/org/sonar/core/persistence/DaoTestCase.java
index ffa23b4a523..bf868da93c5 100644
--- a/sonar-core/src/test/java/org/sonar/core/persistence/DaoTestCase.java
+++ b/sonar-core/src/test/java/org/sonar/core/persistence/DaoTestCase.java
@@ -19,6 +19,7 @@
*/
package org.sonar.core.persistence;
+import com.google.common.collect.Maps;
import org.apache.commons.io.IOUtils;
import org.dbunit.Assertion;
import org.dbunit.DataSourceDatabaseTester;
@@ -26,16 +27,23 @@ import org.dbunit.DatabaseUnitException;
import org.dbunit.IDatabaseTester;
import org.dbunit.database.DatabaseConfig;
import org.dbunit.database.IDatabaseConnection;
-import org.dbunit.dataset.*;
+import org.dbunit.dataset.CompositeDataSet;
+import org.dbunit.dataset.DataSetException;
+import org.dbunit.dataset.IDataSet;
+import org.dbunit.dataset.ITable;
+import org.dbunit.dataset.ReplacementDataSet;
import org.dbunit.dataset.filter.DefaultColumnFilter;
import org.dbunit.dataset.xml.FlatXmlDataSet;
-import org.junit.*;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
import org.sonar.api.config.Settings;
import java.io.InputStream;
import java.io.StringWriter;
import java.sql.SQLException;
-import java.util.Map;
import static org.junit.Assert.fail;
@@ -51,7 +59,7 @@ public abstract class DaoTestCase {
@BeforeClass
public static void startDatabase() throws Exception {
Settings settings = new Settings();
- settings.setProperties((Map) System.getProperties());
+ settings.setProperties(Maps.fromProperties(System.getProperties()));
if (settings.hasKey("sonar.jdbc.dialect")) {
database = new DefaultDatabase(settings);
} else {
diff --git a/sonar-core/src/test/java/org/sonar/core/resource/ResourceDaoTest.java b/sonar-core/src/test/java/org/sonar/core/resource/ResourceDaoTest.java
index 8d877d42508..67faa00a489 100644
--- a/sonar-core/src/test/java/org/sonar/core/resource/ResourceDaoTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/resource/ResourceDaoTest.java
@@ -19,21 +19,13 @@
*/
package org.sonar.core.resource;
-import org.fest.assertions.Assertions;
-
-import org.hamcrest.BaseMatcher;
-import org.hamcrest.Description;
-import org.hamcrest.core.Is;
import org.junit.Before;
import org.junit.Test;
import org.sonar.core.persistence.DaoTestCase;
import java.util.List;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
-import static org.junit.matchers.JUnitMatchers.hasItems;
+import static org.fest.assertions.Assertions.assertThat;
public class ResourceDaoTest extends DaoTestCase {
@@ -50,15 +42,16 @@ public class ResourceDaoTest extends DaoTestCase {
List<ResourceDto> resources = dao.getDescendantProjects(1L);
- assertThat(resources.size(), Is.is(1));
- assertThat(resources.get(0).getId(), is(2L));
+ assertThat(resources).onProperty("id").containsOnly(2L);
}
@Test
public void testDescendantProjects_id_not_found() {
setupData("fixture");
- assertThat(dao.getDescendantProjects(33333L).size(), Is.is(0));
+ List<ResourceDto> resources = dao.getDescendantProjects(33333L);
+
+ assertThat(resources).isEmpty();
}
@Test
@@ -66,16 +59,17 @@ public class ResourceDaoTest extends DaoTestCase {
setupData("fixture");
ResourceDto resource = dao.getResource(1L);
- assertThat(resource.getName(), Is.is("Struts"));
- assertThat(resource.getLongName(), Is.is("Apache Struts"));
- assertThat(resource.getScope(), Is.is("PRJ"));
+
+ assertThat(resource.getName()).isEqualTo("Struts");
+ assertThat(resource.getLongName()).isEqualTo("Apache Struts");
+ assertThat(resource.getScope()).isEqualTo("PRJ");
}
@Test
public void getResource_not_found() {
setupData("fixture");
- assertNull(dao.getResource(987654321L));
+ assertThat(dao.getResource(987654321L)).isNull();
}
@Test
@@ -84,7 +78,7 @@ public class ResourceDaoTest extends DaoTestCase {
List<ResourceDto> resources = dao.getResources(ResourceQuery.create());
- assertThat(resources.size(), Is.is(4));
+ assertThat(resources).hasSize(4);
}
@Test
@@ -92,14 +86,13 @@ public class ResourceDaoTest extends DaoTestCase {
setupData("fixture");
List<ResourceDto> resources = dao.getResources(ResourceQuery.create().setQualifiers(new String[]{"TRK", "BRC"}));
- assertThat(resources.size(), Is.is(2));
- assertThat(resources, hasItems(new QualifierMatcher("TRK"), new QualifierMatcher("BRC")));
+ assertThat(resources).onProperty("qualifier").containsOnly("TRK", "BRC");
resources = dao.getResources(ResourceQuery.create().setQualifiers(new String[]{"XXX"}));
- assertThat(resources.size(), Is.is(0));
+ assertThat(resources).isEmpty();
resources = dao.getResources(ResourceQuery.create().setQualifiers(new String[]{}));
- assertThat(resources.size(), Is.is(4));
+ assertThat(resources).hasSize(4);
}
@Test
@@ -108,7 +101,7 @@ public class ResourceDaoTest extends DaoTestCase {
List<Long> ids = dao.getResourceIds(ResourceQuery.create());
- assertThat(ids.size(), Is.is(4));
+ assertThat(ids).hasSize(4);
}
@Test
@@ -116,31 +109,13 @@ public class ResourceDaoTest extends DaoTestCase {
setupData("fixture");
List<Long> ids = dao.getResourceIds(ResourceQuery.create().setQualifiers(new String[]{"TRK", "BRC"}));
- assertThat(ids.size(), Is.is(2));
- assertThat(ids, hasItems(1l, 2l));
+ assertThat(ids).containsOnly(1L, 2L);
ids = dao.getResourceIds(ResourceQuery.create().setQualifiers(new String[]{"XXX"}));
- assertThat(ids.size(), Is.is(0));
+ assertThat(ids).isEmpty();
ids = dao.getResourceIds(ResourceQuery.create().setQualifiers(new String[]{}));
- assertThat(ids.size(), Is.is(4));
- }
-
-
- private static class QualifierMatcher extends BaseMatcher<ResourceDto> {
- private String qualifier;
-
- private QualifierMatcher(String qualifier) {
- this.qualifier = qualifier;
- }
-
- public boolean matches(Object o) {
- return ((ResourceDto) o).getQualifier().equals(qualifier);
- }
-
- public void describeTo(Description description) {
- description.appendText("qualifier " + qualifier);
- }
+ assertThat(ids).hasSize(4);
}
}
diff --git a/sonar-maven-plugin/src/main/java/org/sonar/maven/SonarMojo.java b/sonar-maven-plugin/src/main/java/org/sonar/maven/SonarMojo.java
index 29200ffb1a0..37fcb3896f9 100644
--- a/sonar-maven-plugin/src/main/java/org/sonar/maven/SonarMojo.java
+++ b/sonar-maven-plugin/src/main/java/org/sonar/maven/SonarMojo.java
@@ -19,6 +19,7 @@
*/
package org.sonar.maven;
+import com.google.common.collect.Maps;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.repository.ArtifactRepository;
@@ -40,8 +41,6 @@ import org.sonar.batch.bootstrapper.Batch;
import org.sonar.batch.bootstrapper.EnvironmentInformation;
import org.sonar.batch.bootstrapper.LoggingConfiguration;
-import java.util.Map;
-
/**
* @goal sonar
* @aggregator
@@ -152,7 +151,7 @@ public final class SonarMojo extends AbstractMojo {
}
private void configureLogging(LoggingConfiguration logging) {
- logging.setProperties((Map) session.getExecutionProperties());
+ logging.setProperties(Maps.fromProperties(session.getExecutionProperties()));
logging.setFormat(LoggingConfiguration.FORMAT_MAVEN);
if (getLog().isDebugEnabled()) {
logging.setVerbose(true);
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/BatchExtensionDictionnary.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/BatchExtensionDictionnary.java
index 1f2eedc3631..16cb667c5ef 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/BatchExtensionDictionnary.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/BatchExtensionDictionnary.java
@@ -157,7 +157,7 @@ public class BatchExtensionDictionnary {
protected List evaluateAnnotatedClasses(Object extension, Class annotation) {
- List results = Lists.newArrayList();
+ List<Object> results = Lists.newArrayList();
Class aClass = extension.getClass();
while (aClass != null) {
evaluateClass(aClass, annotation, results);
@@ -174,7 +174,7 @@ public class BatchExtensionDictionnary {
return results;
}
- private void evaluateClass(Class extensionClass, Class annotationClass, List results) {
+ private void evaluateClass(Class extensionClass, Class annotationClass, List<Object> results) {
Annotation annotation = extensionClass.getAnnotation(annotationClass);
if (annotation != null) {
if (annotation.annotationType().isAssignableFrom(DependsUpon.class)) {
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/RangeDistributionBuilder.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/RangeDistributionBuilder.java
index 4e04916761e..a8124545795 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/RangeDistributionBuilder.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/RangeDistributionBuilder.java
@@ -28,6 +28,7 @@ import org.sonar.api.utils.KeyValueFormat;
import org.sonar.api.utils.SonarException;
import java.util.Arrays;
+import java.util.Collections;
import java.util.Map;
import java.util.Set;
@@ -190,7 +191,7 @@ public class RangeDistributionBuilder implements MeasureBuilder {
countBag.clear();
}
if (bottomLimits != null) {
- countBag.addAll(Arrays.asList(bottomLimits));
+ Collections.addAll(countBag, bottomLimits);
}
isEmpty = true;
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/DeprecatedKeyValueFormatTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/DeprecatedKeyValueFormatTest.java
index 9526b65d7fb..a4da99c7e84 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/DeprecatedKeyValueFormatTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/DeprecatedKeyValueFormatTest.java
@@ -62,7 +62,7 @@ public class DeprecatedKeyValueFormatTest {
@Test
public void formatMultiset() {
- Multiset set = TreeMultiset.create();
+ Multiset<String> set = TreeMultiset.create();
set.add("hello", 1);
set.add("key", 3);
assertThat(KeyValueFormat.format(set), is("hello=1;key=3"));