From 287126153cceb8deec795faeff3525cdabab3ced Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Fri, 7 Jan 2011 10:46:37 +0100 Subject: [PATCH] override the method WildcardPattern.toString() --- .../main/java/org/sonar/api/utils/WildcardPattern.java | 10 ++++++++++ .../java/org/sonar/api/utils/WildcardPatternTest.java | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/WildcardPattern.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/WildcardPattern.java index 572d2c1d01b..2aa913e1929 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/WildcardPattern.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/WildcardPattern.java @@ -33,8 +33,10 @@ public class WildcardPattern { private static final Map patterns = new HashMap(); private Pattern pattern; + private String stringRepresentation; protected WildcardPattern(String pattern, String directorySeparator) { + this.stringRepresentation = pattern; this.pattern = Pattern.compile(toRegexp(pattern, directorySeparator)); } @@ -80,6 +82,14 @@ public class WildcardPattern { return StringUtils.removeEnd(patternStr, "/"); } + /** + * This method is overridden since version 2.5-RC2. + */ + @Override + public String toString() { + return stringRepresentation; + } + /** * @since 2.4 */ diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/WildcardPatternTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/WildcardPatternTest.java index f57aff8f6e2..970544c7152 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/WildcardPatternTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/WildcardPatternTest.java @@ -21,7 +21,9 @@ package org.sonar.api.utils; import org.junit.Test; +import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; public class WildcardPatternTest { @@ -107,4 +109,9 @@ public class WildcardPatternTest { assertTrue(WildcardPattern.match(patterns, "Bar")); assertFalse(WildcardPattern.match(patterns, "Other")); } + + @Test + public void testToString() { + assertThat(WildcardPattern.create("foo*").toString(), is("foo*")); + } } -- 2.39.5