Search in sources :

Example 6 with Languages

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))));
}
Also used : QProfileFactory(org.sonar.server.qualityprofile.QProfileFactory) WsTester(org.sonar.server.ws.WsTester) Languages(org.sonar.api.resources.Languages) Before(org.junit.Before)

Example 7 with Languages

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();
}
Also used : WsTester(org.sonar.server.ws.WsTester) WebService(org.sonar.api.server.ws.WebService) Languages(org.sonar.api.resources.Languages) Test(org.junit.Test)

Example 8 with Languages

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));
}
Also used : ComponentFinder(org.sonar.server.component.ComponentFinder) QProfileFactory(org.sonar.server.qualityprofile.QProfileFactory) Languages(org.sonar.api.resources.Languages) WsActionTester(org.sonar.server.ws.WsActionTester) QProfileLookup(org.sonar.server.qualityprofile.QProfileLookup) Before(org.junit.Before)

Example 9 with Languages

use of org.sonar.api.resources.Languages in project sonarqube by SonarSource.

the class RegisterRulesTest method execute.

private void execute(RulesDefinition... defs) {
    RuleDefinitionsLoader loader = new RuleDefinitionsLoader(mock(DeprecatedRulesDefinitionLoader.class), mock(CommonRuleDefinitionsImpl.class), defs);
    Languages languages = mock(Languages.class);
    when(languages.get("java")).thenReturn(mock(Language.class));
    RegisterRules task = new RegisterRules(loader, ruleActivator, dbClient, ruleIndexer, activeRuleIndexer, languages, system);
    task.start();
    // Execute a commit to refresh session state as the task is using its own session
    dbTester.getSession().commit();
}
Also used : Language(org.sonar.api.resources.Language) Languages(org.sonar.api.resources.Languages)

Example 10 with Languages

use of org.sonar.api.resources.Languages in project sonarqube by SonarSource.

the class QProfilesWsTest method setUp.

@Before
public void setUp() {
    QProfileService profileService = mock(QProfileService.class);
    I18n i18n = mock(I18n.class);
    DbClient dbClient = mock(DbClient.class);
    Languages languages = LanguageTesting.newLanguages(xoo1Key, xoo2Key);
    ProjectAssociationParameters projectAssociationParameters = new ProjectAssociationParameters(languages);
    ProfileImporter[] importers = createImporters(languages);
    controller = new WsTester(new QProfilesWs(new RuleActivationActions(profileService), new BulkRuleActivationActions(profileService, null), new AddProjectAction(projectAssociationParameters, null, null, dbClient), new RemoveProjectAction(projectAssociationParameters, null, null, dbClient), new CreateAction(null, null, null, languages, wsSupport, null, importers), new ImportersAction(importers), new RestoreBuiltInAction(null, languages, wsSupport), new SearchAction(null, languages), new SetDefaultAction(languages, null, null, wsSupport), new ProjectsAction(null, userSessionRule), new BackupAction(dbClient, null, null, languages), new RestoreAction(null, languages, wsSupport), new ChangelogAction(null, mock(QProfileFactory.class), languages, dbClient), new ChangeParentAction(dbClient, null, null, languages, wsSupport), new CompareAction(null, null, languages), new CopyAction(null, languages, wsSupport), new DeleteAction(languages, null, null, wsSupport), new ExportAction(null, null, mock(QProfileExporters.class), languages), new ExportersAction(), new InheritanceAction(null, null, null, null, languages), new RenameAction(null, wsSupport))).controller(QProfilesWs.API_ENDPOINT);
}
Also used : Languages(org.sonar.api.resources.Languages) WsTester(org.sonar.server.ws.WsTester) ProfileImporter(org.sonar.api.profiles.ProfileImporter) I18n(org.sonar.api.i18n.I18n) QProfileExporters(org.sonar.server.qualityprofile.QProfileExporters) QProfileFactory(org.sonar.server.qualityprofile.QProfileFactory) DbClient(org.sonar.db.DbClient) QProfileService(org.sonar.server.qualityprofile.QProfileService) Before(org.junit.Before)

Aggregations

Languages (org.sonar.api.resources.Languages)16 Test (org.junit.Test)10 MapSettings (org.sonar.api.config.MapSettings)9 DefaultLanguagesRepository (org.sonar.scanner.repository.language.DefaultLanguagesRepository)9 LanguagesRepository (org.sonar.scanner.repository.language.LanguagesRepository)8 Settings (org.sonar.api.config.Settings)5 Before (org.junit.Before)4 WsTester (org.sonar.server.ws.WsTester)4 DbClient (org.sonar.db.DbClient)3 QProfileFactory (org.sonar.server.qualityprofile.QProfileFactory)3 I18n (org.sonar.api.i18n.I18n)2 WebService (org.sonar.api.server.ws.WebService)2 MessageException (org.sonar.api.utils.MessageException)2 ComponentFinder (org.sonar.server.component.ComponentFinder)2 QProfileExporters (org.sonar.server.qualityprofile.QProfileExporters)2 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1 StandardCharsets (java.nio.charset.StandardCharsets)1