use of org.sonar.api.resources.Languages in project sonarqube by SonarSource.
the class ExportAction method define.
@Override
public void define(WebService.NewController controller) {
NewAction action = controller.createAction("export").setSince("5.2").setDescription("Export a quality profile.").setResponseExample(getClass().getResource("export-example.xml")).setHandler(this);
action.createParam(PARAM_PROFILE_NAME).setDescription("The name of the quality profile to export. If left empty, will export the default profile for the language.").setExampleValue("My Sonar way");
action.createParam(PARAM_LANGUAGE).setDescription("The language for the quality profile.").setExampleValue(LanguageParamUtils.getExampleValue(languages)).setPossibleValues(LanguageParamUtils.getLanguageKeys(languages)).setRequired(true);
Set<String> exporterKeys = Arrays.stream(languages.all()).map(language -> exporters.exportersForLanguage(language.getKey())).flatMap(Collection::stream).map(ProfileExporter::getKey).collect(Collectors.toSet());
if (!exporterKeys.isEmpty()) {
action.createParam(PARAM_FORMAT).setDescription("Output format. If left empty, the same format as api/qualityprofiles/backup is used. " + "Possible values are described by api/qualityprofiles/exporters.").setPossibleValues(exporterKeys).setDeprecatedKey("format", "6.3");
}
}
use of org.sonar.api.resources.Languages in project sonarqube by SonarSource.
the class ComponentsWsTest method setUp.
@Before
public void setUp() {
Languages languages = mock(Languages.class, RETURNS_DEEP_STUBS);
when(languages.all()).thenReturn(new Language[0]);
WsTester tester = new WsTester(new ComponentsWs(new AppAction(mock(DbClient.class), userSessionRule, mock(ComponentFinder.class)), new SuggestionsAction(mock(DbClient.class), mock(ComponentIndex.class)), new SearchAction(mock(DbClient.class), mock(ResourceTypes.class), mock(I18n.class), userSessionRule, languages, TestDefaultOrganizationProvider.fromUuid("foo"))));
controller = tester.controller("api/components");
}
use of org.sonar.api.resources.Languages in project sonarqube by SonarSource.
the class DeleteActionTest method setUp.
@Before
public void setUp() {
xoo1 = LanguageTesting.newLanguage("xoo1");
xoo2 = LanguageTesting.newLanguage("xoo2");
tester = new WsTester(new QProfilesWs(mock(RuleActivationActions.class), mock(BulkRuleActivationActions.class), new DeleteAction(new Languages(xoo1, xoo2), new QProfileFactory(dbClient, defaultOrganizationProvider), dbClient, new QProfileWsSupport(userSessionRule, defaultOrganizationProvider))));
}
use of org.sonar.api.resources.Languages in project sonarqube by SonarSource.
the class QProfileRefTest method define_ws_parameters.
@Test
public void define_ws_parameters() {
WsTester wsTester = new WsTester();
WebService.NewController controller = wsTester.context().createController("api/qualityprofiles");
WebService.NewAction newAction = controller.createAction("do").setHandler((request, response) -> {
});
Languages languages = new Languages(new FakeLanguage("java"), new FakeLanguage("js"));
QProfileRef.defineParams(newAction, languages);
controller.done();
WebService.Action action = wsTester.controller("api/qualityprofiles").action("do");
assertThat(action.param("language")).isNotNull();
assertThat(action.param("language").possibleValues()).containsOnly("java", "js");
assertThat(action.param("profileKey")).isNotNull();
assertThat(action.param("profileName")).isNotNull();
}
use of org.sonar.api.resources.Languages in project sonarqube by SonarSource.
the class SearchActionTest method setUp.
@Before
public void setUp() {
xoo1 = LanguageTesting.newLanguage("xoo1");
xoo2 = LanguageTesting.newLanguage("xoo2");
Languages languages = new Languages(xoo1, xoo2);
ws = new WsActionTester(new SearchAction(new SearchDataLoader(languages, new QProfileLookup(dbClient), new QProfileFactory(dbClient, defaultOrganizationProvider), dbClient, new ComponentFinder(dbClient), activeRuleIndex), languages));
}
Aggregations