aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-testing-harness/src/test
diff options
context:
space:
mode:
authorDavid Gageot <david@gageot.net>2012-05-22 11:56:58 +0200
committerDavid Gageot <david@gageot.net>2012-05-22 11:56:58 +0200
commitfd7f6a27f9bfc895298a57be47fe7511d9d004b4 (patch)
tree038e8769718bb18dbb2091604aa6a3f384f72315 /sonar-testing-harness/src/test
parent70a99389ba85ae3e7d20c8f56acb571d2ee915a7 (diff)
downloadsonarqube-fd7f6a27f9bfc895298a57be47fe7511d9d004b4.tar.gz
sonarqube-fd7f6a27f9bfc895298a57be47fe7511d9d004b4.zip
SONAR-3016 More work on extension point for filter template
Recognize more filter criterias
Diffstat (limited to 'sonar-testing-harness/src/test')
-rw-r--r--sonar-testing-harness/src/test/java/org/sonar/test/MoreConditionsTest.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/sonar-testing-harness/src/test/java/org/sonar/test/MoreConditionsTest.java b/sonar-testing-harness/src/test/java/org/sonar/test/MoreConditionsTest.java
index 86ba9114c6e..ad83811e999 100644
--- a/sonar-testing-harness/src/test/java/org/sonar/test/MoreConditionsTest.java
+++ b/sonar-testing-harness/src/test/java/org/sonar/test/MoreConditionsTest.java
@@ -21,7 +21,11 @@ package org.sonar.test;
import org.junit.Test;
+import java.util.Arrays;
+import java.util.Collection;
+
import static org.fest.assertions.Assertions.assertThat;
+import static org.sonar.test.MoreConditions.contains;
import static org.sonar.test.MoreConditions.equalsIgnoreEOL;
public class MoreConditionsTest {
@@ -49,4 +53,37 @@ public class MoreConditionsTest {
assertThat("").satisfies(equalsIgnoreEOL("\n\r"));
assertThat("\n\r").satisfies(equalsIgnoreEOL(""));
}
+
+ @Test
+ public void should_find_value_in_collection() {
+ Collection<String> collection = Arrays.asList("ONE", "TWO");
+
+ assertThat(collection).satisfies(contains("ONE"));
+ assertThat(collection).satisfies(contains("TWO"));
+ assertThat(collection).doesNotSatisfy(contains("THREE"));
+ }
+
+ @Test
+ public void should_find_value_in_collection_using_reflection() {
+ Collection<Bean> collection = Arrays.asList(
+ new Bean("key1", "value1"),
+ null,
+ new Bean("key2", "value2"));
+
+ assertThat(collection).satisfies(contains(new Bean("key1", "value1")));
+ assertThat(collection).satisfies(contains(new Bean("key2", "value2")));
+ assertThat(collection).doesNotSatisfy(contains(new Bean("key1", "value2")));
+ assertThat(collection).doesNotSatisfy(contains(new Bean("key2", "value1")));
+ assertThat(collection).doesNotSatisfy(contains(new Bean("", "")));
+ }
+
+ static final class Bean {
+ final String key;
+ final String value;
+
+ Bean(String key, String value) {
+ this.key = key;
+ this.value = value;
+ }
+ }
}