@@ -96,6 +96,19 @@ public void should_create_from_annotation() {
9696 assertThat (def .configScopes ()).containsOnly (ConfigScope .PROJECT , ConfigScope .MODULE );
9797 assertThat (def .multiValues ()).isTrue ();
9898 assertThat (def .fields ()).isEmpty ();
99+ assertThat (def .hidden ()).isFalse ();
100+ }
101+
102+ @ Test
103+ public void should_translate_legacy_global_false_idiom_to_hidden () {
104+ Properties props = AnnotationUtils .getAnnotation (LegacyHiddenIdiom .class , Properties .class );
105+ Property prop = props .value ()[0 ];
106+
107+ PropertyDefinition def = PropertyDefinition .create (prop );
108+
109+ assertThat (def .hidden ()).isTrue ();
110+ assertThat (def .global ()).isTrue ();
111+ assertThat (def .configScopes ()).isEmpty ();
99112 }
100113
101114 @ Test
@@ -108,7 +121,34 @@ public void should_create_hidden_property() {
108121 assertThat (def .key ()).isEqualTo ("hello" );
109122 assertThat (def .qualifiers ()).isEmpty ();
110123 assertThat (def .configScopes ()).isEmpty ();
124+ assertThat (def .global ()).isTrue ();
125+ assertThat (def .hidden ()).isTrue ();
126+ }
127+
128+ @ Test
129+ public void should_create_hidden_property_with_on_config_scopes () {
130+ PropertyDefinition def = PropertyDefinition .builder ("hello" )
131+ .name ("Hello" )
132+ .hidden ()
133+ .onConfigScopes (ConfigScope .PROJECT )
134+ .build ();
135+
136+ assertThat (def .hidden ()).isTrue ();
137+ assertThat (def .global ()).isTrue ();
138+ assertThat (def .configScopes ()).containsExactly (ConfigScope .PROJECT );
139+ }
140+
141+ @ Test
142+ public void should_create_hidden_property_with_only_on_config_scopes () {
143+ PropertyDefinition def = PropertyDefinition .builder ("hello" )
144+ .name ("Hello" )
145+ .hidden ()
146+ .onlyOnConfigScopes (ConfigScope .PROJECT )
147+ .build ();
148+
149+ assertThat (def .hidden ()).isTrue ();
111150 assertThat (def .global ()).isFalse ();
151+ assertThat (def .configScopes ()).containsExactly (ConfigScope .PROJECT );
112152 }
113153
114154 @ Test
@@ -125,6 +165,7 @@ public void should_create_property_with_default_values() {
125165 assertThat (def .description ()).isEmpty ();
126166 assertThat (def .type ()).isEqualTo (PropertyType .STRING );
127167 assertThat (def .global ()).isTrue ();
168+ assertThat (def .hidden ()).isFalse ();
128169 assertThat (def .qualifiers ()).isEmpty ();
129170 assertThat (def .configScopes ()).isEmpty ();
130171 assertThat (def .multiValues ()).isFalse ();
@@ -150,6 +191,7 @@ public void should_create_from_annotation_default_values() {
150191 assertThat (def .configScopes ()).isEmpty ();
151192 assertThat (def .multiValues ()).isFalse ();
152193 assertThat (def .fields ()).isEmpty ();
194+ assertThat (def .hidden ()).isFalse ();
153195 }
154196
155197 @ Test
@@ -320,22 +362,6 @@ public void should_not_create_json_multivalue() {
320362 .hasMessage ("Multivalues are not allowed to be defined for JSON-type property." );
321363 }
322364
323- @ Test
324- public void should_not_authorize_defining_on_qualifiers_and_hidden () {
325- Builder builder = PropertyDefinition .builder ("foo" ).name ("foo" ).onQualifiers (org .sonar .api .resources .Qualifiers .PROJECT ).hidden ();
326- assertThatThrownBy (builder ::build )
327- .isInstanceOf (IllegalArgumentException .class )
328- .hasMessage ("Cannot be hidden and defining qualifiers on which to display" );
329- }
330-
331- @ Test
332- public void should_not_authorize_defining_ony_on_qualifiers_and_hidden () {
333- Builder builder = PropertyDefinition .builder ("foo" ).name ("foo" ).onlyOnQualifiers (org .sonar .api .resources .Qualifiers .PROJECT ).hidden ();
334- assertThatThrownBy (builder ::build )
335- .isInstanceOf (IllegalArgumentException .class )
336- .hasMessage ("Cannot be hidden and defining qualifiers on which to display" );
337- }
338-
339365 @ Test
340366 public void should_not_authorize_defining_on_qualifiers_and_only_on_qualifiers () {
341367 Builder builder = PropertyDefinition .builder ("foo" ).name ("foo" ).onQualifiers (org .sonar .api .resources .Qualifiers .MODULE )
@@ -470,4 +496,8 @@ static class WithPropertySet {
470496 static class DefaultValues {
471497 }
472498
499+ @ Properties (@ Property (key = "hello" , name = "Hello" , global = false ))
500+ static class LegacyHiddenIdiom {
501+ }
502+
473503}
0 commit comments