From c6dc564b20d039045b6f5ce90232c19dab520abb Mon Sep 17 00:00:00 2001 From: David Gageot Date: Fri, 25 May 2012 09:09:52 +0200 Subject: Technical debt : Replace BaseMatcher with ArgumentMatcher --- .../batch/components/PastSnapshotFinderTest.java | 10 +++------- .../components/TimeMachineConfigurationTest.java | 23 ++++++++++------------ 2 files changed, 13 insertions(+), 20 deletions(-) (limited to 'sonar-batch') diff --git a/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderTest.java b/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderTest.java index 2ab6d29a945..5f03dce9160 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderTest.java @@ -20,10 +20,9 @@ package org.sonar.batch.components; import org.apache.commons.configuration.PropertiesConfiguration; -import org.hamcrest.BaseMatcher; -import org.hamcrest.Description; import org.junit.Before; import org.junit.Test; +import org.mockito.ArgumentMatcher; import org.sonar.api.CoreProperties; import org.sonar.api.database.model.Snapshot; @@ -89,14 +88,11 @@ public class PastSnapshotFinderTest { PastSnapshot variationSnapshot = finder.find(null, 2, "2010-05-18"); - verify(finderByDate).findByDate((Snapshot) anyObject(), argThat(new BaseMatcher() { + verify(finderByDate).findByDate((Snapshot) anyObject(), argThat(new ArgumentMatcher() { + @Override public boolean matches(Object o) { return o.equals(date); } - - public void describeTo(Description description) { - - } })); assertThat(variationSnapshot.getIndex(), is(2)); assertThat(variationSnapshot.getMode(), is("date")); diff --git a/sonar-batch/src/test/java/org/sonar/batch/components/TimeMachineConfigurationTest.java b/sonar-batch/src/test/java/org/sonar/batch/components/TimeMachineConfigurationTest.java index 68468e09e7e..7f378eef08a 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/components/TimeMachineConfigurationTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/components/TimeMachineConfigurationTest.java @@ -19,6 +19,14 @@ */ package org.sonar.batch.components; +import org.apache.commons.configuration.PropertiesConfiguration; +import org.junit.Test; +import org.mockito.ArgumentMatcher; +import org.sonar.api.CoreProperties; +import org.sonar.api.database.model.Snapshot; +import org.sonar.api.resources.Project; +import org.sonar.jpa.test.AbstractDbUnitTestCase; + import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Matchers.argThat; @@ -27,15 +35,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyZeroInteractions; -import org.apache.commons.configuration.PropertiesConfiguration; -import org.hamcrest.BaseMatcher; -import org.hamcrest.Description; -import org.junit.Test; -import org.sonar.api.CoreProperties; -import org.sonar.api.database.model.Snapshot; -import org.sonar.api.resources.Project; -import org.sonar.jpa.test.AbstractDbUnitTestCase; - public class TimeMachineConfigurationTest extends AbstractDbUnitTestCase { @Test @@ -63,13 +62,11 @@ public class TimeMachineConfigurationTest extends AbstractDbUnitTestCase { new TimeMachineConfiguration(getSession(), new Project("my:project"), conf, pastSnapshotFinder); - verify(pastSnapshotFinder).find(argThat(new BaseMatcher() { + verify(pastSnapshotFinder).find(argThat(new ArgumentMatcher() { + @Override public boolean matches(Object o) { return ((Snapshot) o).getResourceId() == 2 /* see database in shared.xml */; } - - public void describeTo(Description description) { - } }), eq(conf), eq(1)); } -- cgit v1.2.3