diff options
author | David Gageot <david@gageot.net> | 2012-05-25 08:45:45 +0200 |
---|---|---|
committer | David Gageot <david@gageot.net> | 2012-05-25 08:59:32 +0200 |
commit | 7c03664400952bb5497e07a76e4d26bd9a22b7d3 (patch) | |
tree | a47ad18c0f5ae442020d75916baa5e3b9e9e6398 /sonar-testing-harness/src | |
parent | 5e86cfa298427f58bb8d342ed972f5c77a35c816 (diff) | |
download | sonarqube-7c03664400952bb5497e07a76e4d26bd9a22b7d3.tar.gz sonarqube-7c03664400952bb5497e07a76e4d26bd9a22b7d3.zip |
Create 'My Favourites' Dashboard through extension point.
The dashboard is created but not activated.
Diffstat (limited to 'sonar-testing-harness/src')
-rw-r--r-- | sonar-testing-harness/src/main/java/org/sonar/test/MoreConditions.java | 9 | ||||
-rw-r--r-- | sonar-testing-harness/src/test/java/org/sonar/test/MoreConditionsTest.java | 20 |
2 files changed, 29 insertions, 0 deletions
diff --git a/sonar-testing-harness/src/main/java/org/sonar/test/MoreConditions.java b/sonar-testing-harness/src/main/java/org/sonar/test/MoreConditions.java index c06b78a65e6..0f4b24b5a5d 100644 --- a/sonar-testing-harness/src/main/java/org/sonar/test/MoreConditions.java +++ b/sonar-testing-harness/src/main/java/org/sonar/test/MoreConditions.java @@ -59,4 +59,13 @@ public final class MoreConditions { } }; } + + public static Condition<Object> reflectionEqualTo(final Object expected) { + return new Condition<Object>() { + @Override + public boolean matches(Object actual) { + return EqualsBuilder.reflectionEquals(expected, actual); + } + }; + } } 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 ad83811e999..6cdd18b53ad 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 @@ -24,6 +24,8 @@ import org.junit.Test; import java.util.Arrays; import java.util.Collection; +import static org.sonar.test.MoreConditions.reflectionEqualTo; + import static org.fest.assertions.Assertions.assertThat; import static org.sonar.test.MoreConditions.contains; import static org.sonar.test.MoreConditions.equalsIgnoreEOL; @@ -77,6 +79,24 @@ public class MoreConditionsTest { assertThat(collection).doesNotSatisfy(contains(new Bean("", ""))); } + @Test + public void should_compare_using_reflection() { + Bean bean1 = new Bean("key1", "value1"); + Bean bean2 = new Bean("key2", "value2"); + + assertThat(bean1).is(reflectionEqualTo(bean1)); + assertThat(bean2).is(reflectionEqualTo(bean2)); + assertThat(bean1).isNot(reflectionEqualTo(bean2)); + assertThat(bean2).isNot(reflectionEqualTo(bean1)); + assertThat(bean1).isNot(reflectionEqualTo(null)); + assertThat(bean2).isNot(reflectionEqualTo(null)); + assertThat(bean1).isNot(reflectionEqualTo(new Object())); + assertThat(bean2).isNot(reflectionEqualTo(new Object())); + assertThat(bean1).isNot(reflectionEqualTo(new Bean("key1", "value2"))); + assertThat(bean1).isNot(reflectionEqualTo(new Bean("key2", "value1"))); + assertThat(bean1).isNot(reflectionEqualTo(new Bean("", ""))); + } + static final class Bean { final String key; final String value; |