diff options
author | Evgeny Mandrikov <mandrikov@gmail.com> | 2012-03-29 10:54:40 +0600 |
---|---|---|
committer | Evgeny Mandrikov <mandrikov@gmail.com> | 2012-03-29 11:01:42 +0600 |
commit | 2a93969813f040f9072fe261ac94f1c9b65738bb (patch) | |
tree | 480c59ed8da563af0a2292ae94f6fab53f5f0a52 /plugins/sonar-jacoco-plugin | |
parent | 9f7cdba5e642faa17cb556f2b7882d7dd5adab0c (diff) | |
download | sonarqube-2a93969813f040f9072fe261ac94f1c9b65738bb.tar.gz sonarqube-2a93969813f040f9072fe261ac94f1c9b65738bb.zip |
Fix some quality flaws
Diffstat (limited to 'plugins/sonar-jacoco-plugin')
4 files changed, 21 insertions, 22 deletions
diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoMavenInitializer.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoMavenInitializer.java index 2af3cc8c9e5..1f0cabd8e06 100644 --- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoMavenInitializer.java +++ b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JacocoMavenInitializer.java @@ -38,7 +38,8 @@ public class JacocoMavenInitializer extends Initializer implements CoverageExten @Override public boolean shouldExecuteOnProject(Project project) { - return project.getAnalysisType().equals(Project.AnalysisType.DYNAMIC) && project.getFileSystem().hasTestFiles(Java.INSTANCE); + return project.getAnalysisType().equals(Project.AnalysisType.DYNAMIC) + && !project.getFileSystem().testFiles(Java.KEY).isEmpty(); } @Override diff --git a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoMavenPluginHandlerTest.java b/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoMavenPluginHandlerTest.java index 8bb93a1a865..0dc3f3127a7 100644 --- a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoMavenPluginHandlerTest.java +++ b/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoMavenPluginHandlerTest.java @@ -19,16 +19,6 @@ */ package org.sonar.plugins.jacoco; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.io.File; - -import org.apache.commons.configuration.BaseConfiguration; import org.junit.Before; import org.junit.Test; import org.sonar.api.batch.maven.MavenPlugin; @@ -38,6 +28,12 @@ import org.sonar.api.config.Settings; import org.sonar.api.resources.Project; import org.sonar.api.test.MavenTestUtils; +import java.io.File; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.mockito.Mockito.*; + /** * @author Evgeny Mandrikov */ diff --git a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JacocoConfigurationTest.java b/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JacocoConfigurationTest.java index fc776e86de4..2939ca6337b 100644 --- a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JacocoConfigurationTest.java +++ b/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JacocoConfigurationTest.java @@ -19,7 +19,6 @@ */ package org.sonar.plugins.jacoco; -import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; import org.sonar.api.config.PropertyDefinitions; diff --git a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JacocoMavenInitializerTest.java b/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JacocoMavenInitializerTest.java index 8a47ee7efc9..4f8c02216a8 100644 --- a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JacocoMavenInitializerTest.java +++ b/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JacocoMavenInitializerTest.java @@ -19,20 +19,21 @@ */ package org.sonar.plugins.jacoco; -import static org.hamcrest.Matchers.instanceOf; -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.argThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.when; - import org.junit.Before; import org.junit.Test; +import org.sonar.api.resources.InputFile; import org.sonar.api.resources.Java; import org.sonar.api.resources.Project; import org.sonar.api.resources.ProjectFileSystem; +import java.util.Collections; + +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; +import static org.mockito.Matchers.argThat; +import static org.mockito.Mockito.*; + public class JacocoMavenInitializerTest { private JaCoCoMavenPluginHandler mavenPluginHandler; private JacocoMavenInitializer initializer; @@ -54,7 +55,8 @@ public class JacocoMavenInitializerTest { @Test public void shouldExecuteMaven() { Project project = mockProject(); - when(project.getFileSystem().hasTestFiles(argThat(is(Java.INSTANCE)))).thenReturn(true); + InputFile inputFile = mock(InputFile.class); + when(project.getFileSystem().testFiles(Java.KEY)).thenReturn(Collections.singletonList(inputFile)); when(project.getAnalysisType()).thenReturn(Project.AnalysisType.DYNAMIC); assertThat(initializer.shouldExecuteOnProject(project), is(true)); @@ -64,7 +66,8 @@ public class JacocoMavenInitializerTest { @Test public void shouldNotExecuteMavenWhenReuseReports() { Project project = mockProject(); - when(project.getFileSystem().hasTestFiles(argThat(is(Java.INSTANCE)))).thenReturn(true); + InputFile inputFile = mock(InputFile.class); + when(project.getFileSystem().testFiles(Java.KEY)).thenReturn(Collections.singletonList(inputFile)); when(project.getAnalysisType()).thenReturn(Project.AnalysisType.REUSE_REPORTS); assertThat(initializer.shouldExecuteOnProject(project), is(false)); |