diff options
author | David Gageot <david@gageot.net> | 2012-07-16 15:43:31 +0200 |
---|---|---|
committer | David Gageot <david@gageot.net> | 2012-07-16 15:49:39 +0200 |
commit | 592cb1f45be74a17310ab7bb623c3e0e54dbea9f (patch) | |
tree | 2e466b7bcc9e145c0b065ba0021fa8a9924e103d /sonar-plugin-api | |
parent | a15e8577ff0f4b9e88cdf78e6aaed3ebd6259c50 (diff) | |
download | sonarqube-592cb1f45be74a17310ab7bb623c3e0e54dbea9f.tar.gz sonarqube-592cb1f45be74a17310ab7bb623c3e0e54dbea9f.zip |
Use ArgumentMatcher
Diffstat (limited to 'sonar-plugin-api')
3 files changed, 10 insertions, 22 deletions
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/test/IsResource.java b/sonar-plugin-api/src/test/java/org/sonar/api/test/IsResource.java index 9d6474bf087..ea7cc4e39d2 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/test/IsResource.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/test/IsResource.java @@ -21,11 +21,10 @@ package org.sonar.api.test; import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.StringUtils; -import org.hamcrest.BaseMatcher; -import org.hamcrest.Description; +import org.mockito.ArgumentMatcher; import org.sonar.api.resources.Resource; -public class IsResource extends BaseMatcher<Resource> { +public class IsResource extends ArgumentMatcher<Resource> { private String scope; private String qualifier; @@ -41,13 +40,10 @@ public class IsResource extends BaseMatcher<Resource> { this.key = key; } + @Override public boolean matches(Object o) { Resource r = (Resource) o; boolean keyMatch = (key != null) ? StringUtils.equals(r.getKey(), key) : true; return ObjectUtils.equals(r.getScope(), scope) && ObjectUtils.equals(r.getQualifier(), qualifier) && keyMatch; } - - public void describeTo(Description description) { - - } -}
\ No newline at end of file +} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/test/IsRuleMeasure.java b/sonar-plugin-api/src/test/java/org/sonar/api/test/IsRuleMeasure.java index 01a403effd5..55716acf9ef 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/test/IsRuleMeasure.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/test/IsRuleMeasure.java @@ -21,14 +21,13 @@ package org.sonar.api.test; import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.math.NumberUtils; -import org.hamcrest.BaseMatcher; -import org.hamcrest.Description; +import org.mockito.ArgumentMatcher; import org.sonar.api.measures.Measure; import org.sonar.api.measures.Metric; import org.sonar.api.measures.RuleMeasure; import org.sonar.api.rules.Rule; -public class IsRuleMeasure extends BaseMatcher<Measure> { +public class IsRuleMeasure extends ArgumentMatcher<Measure> { private Metric metric = null; private Rule rule = null; @@ -40,6 +39,7 @@ public class IsRuleMeasure extends BaseMatcher<Measure> { this.value = value; } + @Override public boolean matches(Object o) { if (!(o instanceof RuleMeasure)) { return false; @@ -49,8 +49,4 @@ public class IsRuleMeasure extends BaseMatcher<Measure> { ObjectUtils.equals(rule, m.getRule()) && NumberUtils.compare(value, m.getValue()) == 0; } - - public void describeTo(Description description) { - - } } diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/test/IsViolation.java b/sonar-plugin-api/src/test/java/org/sonar/api/test/IsViolation.java index a22211a2322..bdadc7628ad 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/test/IsViolation.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/test/IsViolation.java @@ -19,13 +19,12 @@ */ package org.sonar.api.test; -import org.hamcrest.BaseMatcher; -import org.hamcrest.Description; +import org.mockito.ArgumentMatcher; import org.sonar.api.resources.Resource; import org.sonar.api.rules.Rule; import org.sonar.api.rules.Violation; -public class IsViolation extends BaseMatcher<Violation> { +public class IsViolation extends ArgumentMatcher<Violation> { private Rule rule; private String message; @@ -46,6 +45,7 @@ public class IsViolation extends BaseMatcher<Violation> { this.lineId = lineId; } + @Override public boolean matches(Object o) { Violation violation = (Violation) o; if (lineId != null && !lineId.equals(violation.getLineId())) { @@ -66,8 +66,4 @@ public class IsViolation extends BaseMatcher<Violation> { return true; } - - public void describeTo(Description description) { - - } } |