aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-webserver-ws
diff options
context:
space:
mode:
authorLéo Geoffroy <leo.geoffroy@sonarsource.com>2023-05-03 11:57:57 +0200
committersonartech <sonartech@sonarsource.com>2023-05-03 20:02:57 +0000
commit3df9f54c48861976d48a6a9559d7c9fc3953dfec (patch)
tree104d5e693ec2a83cee10ab3b899b03cd440ac0e3 /server/sonar-webserver-ws
parent5e2065ccc6aed93a3f1fce0ded87d8ba417d3a89 (diff)
downloadsonarqube-3df9f54c48861976d48a6a9559d7c9fc3953dfec.tar.gz
sonarqube-3df9f54c48861976d48a6a9559d7c9fc3953dfec.zip
SONAR-18742 Remove usage of 'BRC' in component/search and component/tree
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()));
+ }
+
}