aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-webserver-ws
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-webserver-ws')
-rw-r--r--server/sonar-webserver-ws/src/main/java/org/sonar/server/ws/WsParameterBuilder.java1
-rw-r--r--server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/WsParameterBuilderTest.java27
2 files changed, 28 insertions, 0 deletions
diff --git a/server/sonar-webserver-ws/src/main/java/org/sonar/server/ws/WsParameterBuilder.java b/server/sonar-webserver-ws/src/main/java/org/sonar/server/ws/WsParameterBuilder.java
index c22b170106a..7cee9dc1473 100644
--- a/server/sonar-webserver-ws/src/main/java/org/sonar/server/ws/WsParameterBuilder.java
+++ b/server/sonar-webserver-ws/src/main/java/org/sonar/server/ws/WsParameterBuilder.java
@@ -85,6 +85,7 @@ public class WsParameterBuilder {
private static Set<String> getAllQualifiers(ResourceTypes resourceTypes) {
return resourceTypes.getAll().stream()
+ .filter(r -> !r.getBooleanProperty("ignored"))
.map(ResourceType::getQualifier)
.collect(Collectors.toCollection(TreeSet::new));
}
diff --git a/server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/WsParameterBuilderTest.java b/server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/WsParameterBuilderTest.java
index d766ab2afd8..0694fea6e0e 100644
--- a/server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/WsParameterBuilderTest.java
+++ b/server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/WsParameterBuilderTest.java
@@ -33,6 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.startsWith;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.sonar.server.ws.WsParameterBuilder.QualifierParameterContext.newQualifierParameterContext;
import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_QUALIFIERS;
@@ -122,4 +123,30 @@ public class WsParameterBuilderTest {
assertThat(newParam).isNotNull();
}
+
+ @Test
+ public void createQualifiersParameter_whenIgnoreIsSetToTrue_shouldNotReturnQualifier(){
+ when(resourceTypes.getAll()).thenReturn(asList(Q1, Q2,ResourceType.builder("Q3").setProperty("ignored", true).build()));
+ when(newAction.createParam(PARAM_QUALIFIERS)).thenReturn(newParam);
+ when(newParam.setPossibleValues(any(Collection.class))).thenReturn(newParam);
+ when(newParam.setDescription(any())).thenReturn(newParam);
+ NewParam newParam = WsParameterBuilder
+ .createQualifiersParameter(newAction, newQualifierParameterContext(i18n, resourceTypes));
+
+ verify(newParam).setPossibleValues(Sets.newHashSet(Q1.getQualifier(), Q2.getQualifier()));
+ }
+
+ @Test
+ public void createQualifiersParameter_whenIgnoreIsSetToFalse_shouldReturnQualifier(){
+ ResourceType q3Qualifier = ResourceType.builder("Q3").setProperty("ignored", false).build();
+ when(resourceTypes.getAll()).thenReturn(asList(Q1, Q2, q3Qualifier));
+ when(newAction.createParam(PARAM_QUALIFIERS)).thenReturn(newParam);
+ when(newParam.setPossibleValues(any(Collection.class))).thenReturn(newParam);
+ when(newParam.setDescription(any())).thenReturn(newParam);
+ NewParam newParam = WsParameterBuilder
+ .createQualifiersParameter(newAction, newQualifierParameterContext(i18n, resourceTypes));
+
+ verify(newParam).setPossibleValues(Sets.newHashSet(Q1.getQualifier(), Q2.getQualifier(), q3Qualifier.getQualifier()));
+ }
+
}