import java.util.List;
import java.util.Optional;
-import org.sonar.api.PropertyType;
import org.sonar.api.config.PropertyDefinition;
import org.sonar.api.config.PropertyDefinitions;
import org.sonar.api.config.PropertyFieldDefinition;
propertyDefinitions.getAll().stream()
.filter(definition -> qualifier.isPresent() ? definition.qualifiers().contains(qualifier.get()) : definition.global())
- .filter(definition -> !definition.type().equals(PropertyType.LICENSE))
.forEach(definition -> addDefinition(definition, wsResponse));
return wsResponse.build();
}
}
List<PropertyFieldDefinition> fields = definition.fields();
if (!fields.isEmpty()) {
- fields.stream()
- .filter(fieldDefinition -> !fieldDefinition.type().equals(PropertyType.LICENSE))
- .forEach(fieldDefinition -> addField(fieldDefinition, builder));
+ fields.forEach(fieldDefinition -> addField(fieldDefinition, builder));
}
}
import java.io.IOException;
import javax.annotation.Nullable;
+import org.assertj.core.groups.Tuple;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import static org.sonar.db.component.ComponentTesting.newProjectDto;
import static org.sonarqube.ws.MediaTypes.JSON;
import static org.sonarqube.ws.Settings.Type.BOOLEAN;
+import static org.sonarqube.ws.Settings.Type.LICENSE;
import static org.sonarqube.ws.Settings.Type.PROPERTY_SET;
import static org.sonarqube.ws.Settings.Type.SINGLE_SELECT_LIST;
import static org.sonarqube.ws.Settings.Type.STRING;
}
@Test
- public void does_not_return_license_type_property_set() throws Exception {
+ public void return_license_type_property_set() throws Exception {
setUserAsSystemAdmin();
propertyDefinitions.addComponent(PropertyDefinition
.builder("foo")
ListDefinitionsWsResponse result = executeRequest();
assertThat(result.getDefinitionsList()).hasSize(1);
- assertThat(result.getDefinitions(0).getFieldsList()).isEmpty();
+ assertThat(result.getDefinitions(0).getFieldsList()).extracting(Settings.Field::getKey, Settings.Field::getType).containsOnly(Tuple.tuple("license", LICENSE));
}
@Test
}
@Test
- public void does_not_return_license_type() throws Exception {
+ public void return_license_type() throws Exception {
setUserAsSystemAdmin();
propertyDefinitions.addComponent(PropertyDefinition.builder("license").type(PropertyType.LICENSE).build());
ListDefinitionsWsResponse result = executeRequest();
- assertThat(result.getDefinitionsList()).isEmpty();
+ assertThat(result.getDefinitionsList()).extracting(Settings.Definition::getKey, Settings.Definition::getType).containsOnly(Tuple.tuple("license", LICENSE));
}
@Test