diff options
author | David Gageot <david@gageot.net> | 2012-09-17 16:27:08 +0200 |
---|---|---|
committer | David Gageot <david@gageot.net> | 2012-09-20 12:07:32 +0200 |
commit | 1b000a65c28f43a3242c55f91a0cc7f6a210e979 (patch) | |
tree | 776139ba456138bd8042ef1f409121a057e10c4f /plugins/sonar-checkstyle-plugin | |
parent | c77bc1df270111bd96c300f4a7a856b71045737d (diff) | |
download | sonarqube-1b000a65c28f43a3242c55f91a0cc7f6a210e979.tar.gz sonarqube-1b000a65c28f43a3242c55f91a0cc7f6a210e979.zip |
Don't use anyObject() matcher
Diffstat (limited to 'plugins/sonar-checkstyle-plugin')
2 files changed, 15 insertions, 10 deletions
diff --git a/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleExecutorTest.java b/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleExecutorTest.java index f92e2259af3..6f7f320aa71 100644 --- a/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleExecutorTest.java +++ b/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleExecutorTest.java @@ -34,7 +34,7 @@ import java.util.Locale; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; import static org.junit.internal.matchers.StringContains.containsString; -import static org.mockito.Matchers.anyObject; +import static org.mockito.Matchers.any; import static org.mockito.Matchers.argThat; import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.mock; @@ -51,8 +51,8 @@ public class CheckstyleExecutorTest { CheckstyleExecutor executor = new CheckstyleExecutor(conf, listener, getClass().getClassLoader()); executor.execute(); - verify(listener, times(1)).auditStarted((AuditEvent) anyObject()); - verify(listener, times(1)).auditFinished((AuditEvent) anyObject()); + verify(listener, times(1)).auditStarted(any(AuditEvent.class)); + verify(listener, times(1)).auditFinished(any(AuditEvent.class)); verify(listener, times(1)).fileStarted(argThat(newFilenameMatcher("Hello.java"))); verify(listener, times(1)).fileFinished(argThat(newFilenameMatcher("Hello.java"))); verify(listener, times(1)).fileStarted(argThat(newFilenameMatcher("World.java"))); @@ -77,7 +77,7 @@ public class CheckstyleExecutorTest { return new ArgumentMatcher<AuditEvent>() { @Override public boolean matches(Object o) { - AuditEvent event = (AuditEvent)o; + AuditEvent event = (AuditEvent) o; return StringUtils.endsWith(event.getFileName(), filename) && StringUtils.equals(event.getSourceName(), rule); } }; @@ -87,7 +87,7 @@ public class CheckstyleExecutorTest { return new ArgumentMatcher<AuditEvent>() { @Override public boolean matches(Object o) { - AuditEvent event = (AuditEvent)o; + AuditEvent event = (AuditEvent) o; return StringUtils.endsWith(event.getFileName(), filename); } }; @@ -101,7 +101,7 @@ public class CheckstyleExecutorTest { CheckstyleConfiguration conf = mock(CheckstyleConfiguration.class); when(conf.getCharset()).thenReturn(Charset.defaultCharset()); when(conf.getCheckstyleConfiguration()).thenReturn(CheckstyleConfiguration.toCheckstyleConfiguration(new File("test-resources/checkstyle-conf.xml"))); - when(conf.getSourceFiles()).thenReturn(Arrays.<File>asList(new File("test-resources/Hello.java"), new File("test-resources/World.java"))); + when(conf.getSourceFiles()).thenReturn(Arrays.<File> asList(new File("test-resources/Hello.java"), new File("test-resources/World.java"))); when(conf.getLocale()).thenReturn(Locale.ENGLISH); return conf; } diff --git a/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleProfileImporterTest.java b/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleProfileImporterTest.java index 6fffd91a7fb..61f89285662 100644 --- a/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleProfileImporterTest.java +++ b/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleProfileImporterTest.java @@ -25,7 +25,11 @@ import org.junit.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.sonar.api.profiles.RulesProfile; -import org.sonar.api.rules.*; +import org.sonar.api.rules.ActiveRule; +import org.sonar.api.rules.Rule; +import org.sonar.api.rules.RuleFinder; +import org.sonar.api.rules.RulePriority; +import org.sonar.api.rules.RuleQuery; import org.sonar.api.utils.ValidationMessages; import org.sonar.test.TestUtils; @@ -37,7 +41,7 @@ import static org.hamcrest.core.IsNull.nullValue; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.anyObject; +import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -115,7 +119,8 @@ public class CheckstyleProfileImporterTest { RulesProfile profile = importer.importProfile(reader, messages); assertNotNull(profile.getActiveRuleByConfigKey("checkstyle", "Checker/JavadocPackage")); - assertThat(profile.getActiveRuleByConfigKey("checkstyle", "Checker/JavadocPackage").getRule().getKey(), is("com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocPackageCheck_12345")); + assertThat(profile.getActiveRuleByConfigKey("checkstyle", "Checker/JavadocPackage").getRule().getKey(), + is("com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocPackageCheck_12345")); assertThat(messages.getWarnings().size(), is(0)); } @@ -139,7 +144,7 @@ public class CheckstyleProfileImporterTest { private RuleFinder newRuleFinder() { RuleFinder ruleFinder = mock(RuleFinder.class); - when(ruleFinder.find((RuleQuery) anyObject())).thenAnswer(new Answer<Rule>() { + when(ruleFinder.find(any(RuleQuery.class))).thenAnswer(new Answer<Rule>() { public Rule answer(InvocationOnMock iom) throws Throwable { RuleQuery query = (RuleQuery) iom.getArguments()[0]; Rule rule = null; |