From: David Gageot Date: Fri, 6 Jul 2012 11:39:14 +0000 (+0200) Subject: SONAR-3620 Define a new TEXT widget property type X-Git-Tag: 3.2~205 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=35ac8c8e18298c50898805e6610ddeddb9f3e173;p=sonarqube.git SONAR-3620 Define a new TEXT widget property type --- diff --git a/sonar-server/src/test/java/org/sonar/server/ui/ViewProxyTest.java b/sonar-server/src/test/java/org/sonar/server/ui/ViewProxyTest.java index e3260630791..f1b0d056772 100644 --- a/sonar-server/src/test/java/org/sonar/server/ui/ViewProxyTest.java +++ b/sonar-server/src/test/java/org/sonar/server/ui/ViewProxyTest.java @@ -19,11 +19,9 @@ */ package org.sonar.server.ui; -import org.junit.rules.ExpectedException; - import org.junit.Rule; - import org.junit.Test; +import org.junit.rules.ExpectedException; import org.sonar.api.web.DefaultTab; import org.sonar.api.web.NavigationSection; import org.sonar.api.web.RequiredMeasures; @@ -35,6 +33,7 @@ import org.sonar.api.web.WidgetProperty; import org.sonar.api.web.WidgetPropertyType; import org.sonar.api.web.WidgetScope; +import static com.google.common.collect.Iterables.getOnlyElement; import static org.fest.assertions.Assertions.assertThat; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.Matchers.lessThan; @@ -133,22 +132,29 @@ public class ViewProxyTest { @Test public void widget_should_be_editable() { - ViewProxy proxy = new ViewProxy(new EditableWidget()); + ViewProxy proxy = new ViewProxy(new EditableWidget()); assertThat(proxy.isEditable()).isTrue(); assertThat(proxy.getWidgetProperties()).hasSize(2); } + @Test + public void widget_should_have_text_property() { + ViewProxy proxy = new ViewProxy(new TextWidget()); + + assertThat(getOnlyElement(proxy.getWidgetProperties()).type()).isEqualTo(WidgetPropertyType.TEXT); + } + @Test public void widget_should_not_be_global_by_default() { - ViewProxy proxy = new ViewProxy(new EditableWidget()); + ViewProxy proxy = new ViewProxy(new EditableWidget()); assertThat(proxy.isGlobal()).isFalse(); } @Test public void widget_should_be_global() { - ViewProxy proxy = new ViewProxy(new GlobalWidget()); + ViewProxy proxy = new ViewProxy(new GlobalWidget()); assertThat(proxy.isGlobal()).isTrue(); } @@ -164,13 +170,13 @@ public class ViewProxyTest { @Test public void widgetShouldRequireMandatoryProperties() { - ViewProxy proxy = new ViewProxy(new EditableWidget()); + ViewProxy proxy = new ViewProxy(new EditableWidget()); assertThat(proxy.hasRequiredProperties(), is(true)); } @Test public void widgetShouldDefineOnlyOptionalProperties() { - ViewProxy proxy = new ViewProxy(new WidgetWithOptionalProperties()); + ViewProxy proxy = new ViewProxy(new WidgetWithOptionalProperties()); assertThat(proxy.hasRequiredProperties(), is(false)); } @@ -256,7 +262,6 @@ class FakeView implements View { @WidgetProperty(key = "bar", defaultValue = "30", type = WidgetPropertyType.INTEGER) }) class EditableWidget implements Widget { - public String getId() { return "w1"; } @@ -266,6 +271,17 @@ class EditableWidget implements Widget { } } +@WidgetProperties(@WidgetProperty(key = "message", defaultValue = "", type = WidgetPropertyType.TEXT)) +class TextWidget implements Widget { + public String getId() { + return "text"; + } + + public String getTitle() { + return "TEXT"; + } +} + @WidgetScope("GLOBAL") class GlobalWidget implements Widget { public String getId() { @@ -293,7 +309,6 @@ class WidgetWithInvalidScope implements Widget { @WidgetProperty(key = "bar") }) class WidgetWithOptionalProperties implements Widget { - public String getId() { return "w2"; }