use of org.sonarqube.ws.client.issues.SearchRequest in project sonar-web by SonarSource.
the class PhpFilesTest method analyzeFileAndCheckIssues.
private void analyzeFileAndCheckIssues(Orchestrator orchestrator) {
SonarScanner build = getSonarRunner();
orchestrator.executeBuild(build);
assertThat(getAnalyzedFilesNumber(orchestrator)).isEqualTo(2);
SearchRequest request = new SearchRequest().setProjects(singletonList(PROJECT_KEY)).setComponentKeys(singletonList(PROJECT_KEY + ":" + "foo.php")).setRules(singletonList("Web:IllegalTabCheck"));
List<Issues.Issue> issues = newWsClient(orchestrator).issues().search(request).getIssuesList();
assertThat(issues).hasSize(1);
}
use of org.sonarqube.ws.client.issues.SearchRequest in project sonar-web by SonarSource.
the class VariousTest method testCommentedOutCodeDetection.
/**
* SONARPLUGINS-1897
*/
@Test
public void testCommentedOutCodeDetection() {
String projectKey = "test";
orchestrator.getServer().provisionProject(projectKey, projectKey);
orchestrator.getServer().associateProjectToQualityProfile(projectKey, "web", "IT");
SonarScanner build = HtmlTestSuite.createSonarScanner().setProjectDir(new File("projects/continuum-webapp/")).setProjectKey(projectKey).setProjectName(projectKey).setProjectVersion("1.0").setSourceDirs("src").setProperty("sonar.sourceEncoding", "UTF-8");
orchestrator.executeBuild(build);
SearchRequest request = new SearchRequest();
request.setComponentKeys(Collections.singletonList(keyFor(projectKey, "WEB-INF/jsp/components/projectGroupNotifierSummaryComponent.jsp"))).setRules(Collections.singletonList("Web:AvoidCommentedOutCodeCheck"));
List<Issues.Issue> issues = newWsClient(orchestrator).issues().search(request).getIssuesList();
assertThat(issues).hasSize(2);
}
use of org.sonarqube.ws.client.issues.SearchRequest in project sonarlint-core by SonarSource.
the class ConnectedDeveloperIssueDownloadTest method prepare.
@BeforeClass
public static void prepare() throws IOException {
var adminWsClient = newAdminWsClient(ORCHESTRATOR);
adminWsClient.users().create(new CreateRequest().setLogin(SONARLINT_USER).setPassword(SONARLINT_PWD).setName("SonarLint"));
sonarUserHome = temp.newFolder().toPath();
engine = new ConnectedSonarLintEngineImpl(ConnectedGlobalConfiguration.builder().setConnectionId("orchestrator").setSonarLintUserHome(sonarUserHome).setExtraProperties(new HashMap<>()).build());
engine.update(endpointParams(ORCHESTRATOR), sqHttpClient(), null);
ORCHESTRATOR.getServer().provisionProject(PROJECT_KEY, "Sample Xoo");
ORCHESTRATOR.getServer().associateProjectToQualityProfile(PROJECT_KEY, "xoo", "SonarLint IT Xoo");
engine.updateProject(endpointParams(ORCHESTRATOR), sqHttpClient(), PROJECT_KEY, false, LONG_BRANCH, null);
// main branch
analyzeProject("sample-xoo-v1");
// short living branch
analyzeProject("sample-xoo-v1", "sonar.branch.name", SHORT_BRANCH);
// long living branch
analyzeProject("sample-xoo-v1", "sonar.branch.name", LONG_BRANCH);
// Second analysis with less issues to have closed issues on the branch
analyzeProject("sample-xoo-v2", "sonar.branch.name", LONG_BRANCH);
// Mark a few issues as closed WF and closed FP on the branch
var issueSearchResponse = adminWsClient.issues().search(new SearchRequest().setStatuses(asList("OPEN")).setTypes(asList("CODE_SMELL")).setComponentKeys(asList(PROJECT_KEY)).setBranch(LONG_BRANCH));
wfIssue = issueSearchResponse.getIssues(0);
fpIssue = issueSearchResponse.getIssues(1);
// Change severity and type
overridenSeverityIssue = issueSearchResponse.getIssues(2);
overridenTypeIssue = issueSearchResponse.getIssues(3);
adminWsClient.issues().doTransition(new DoTransitionRequest().setIssue(wfIssue.getKey()).setTransition("wontfix"));
adminWsClient.issues().doTransition(new DoTransitionRequest().setIssue(fpIssue.getKey()).setTransition("falsepositive"));
adminWsClient.issues().setSeverity(new SetSeverityRequest().setIssue(overridenSeverityIssue.getKey()).setSeverity("BLOCKER"));
adminWsClient.issues().setType(new SetTypeRequest().setIssue(overridenTypeIssue.getKey()).setType("BUG"));
// Ensure an hostpot has been reported on server side
if (ORCHESTRATOR.getServer().version().isGreaterThanOrEquals(8, 2)) {
assertThat(adminWsClient.hotspots().search(new org.sonarqube.ws.client.hotspots.SearchRequest().setProjectKey(PROJECT_KEY).setBranch(LONG_BRANCH)).getHotspotsList()).isNotEmpty();
} else {
assertThat(adminWsClient.issues().search(new SearchRequest().setTypes(asList("SECURITY_HOTSPOT")).setComponentKeys(asList(PROJECT_KEY))).getIssuesList()).isNotEmpty();
}
}
use of org.sonarqube.ws.client.issues.SearchRequest in project sonarlint-core by SonarSource.
the class ConnectedCommunityIssueDownloadTest method prepare.
@BeforeClass
public static void prepare() {
var adminWsClient = newAdminWsClient(ORCHESTRATOR);
adminWsClient.users().create(new CreateRequest().setLogin(SONARLINT_USER).setPassword(SONARLINT_PWD).setName("SonarLint"));
ORCHESTRATOR.getServer().provisionProject(PROJECT_KEY, "Sample Xoo");
ORCHESTRATOR.getServer().associateProjectToQualityProfile(PROJECT_KEY, "xoo", "SonarLint IT Xoo");
analyzeProject("sample-xoo-v1");
// Second analysis with less issues to have closed issues
analyzeProject("sample-xoo-v2");
// Mark a few issues as closed WF and closed FP
var issueSearchResponse = adminWsClient.issues().search(new SearchRequest().setStatuses(asList("OPEN")).setTypes(asList("CODE_SMELL")).setComponentKeys(asList(PROJECT_KEY)));
wfIssue = issueSearchResponse.getIssues(0);
fpIssue = issueSearchResponse.getIssues(1);
// Change severity and type
overridenSeverityIssue = issueSearchResponse.getIssues(2);
overridenTypeIssue = issueSearchResponse.getIssues(3);
adminWsClient.issues().doTransition(new DoTransitionRequest().setIssue(wfIssue.getKey()).setTransition("wontfix"));
adminWsClient.issues().doTransition(new DoTransitionRequest().setIssue(fpIssue.getKey()).setTransition("falsepositive"));
adminWsClient.issues().setSeverity(new SetSeverityRequest().setIssue(overridenSeverityIssue.getKey()).setSeverity("BLOCKER"));
adminWsClient.issues().setType(new SetTypeRequest().setIssue(overridenTypeIssue.getKey()).setType("BUG"));
// Ensure an hostpot has been reported on server side
if (ORCHESTRATOR.getServer().version().isGreaterThanOrEquals(8, 2)) {
assertThat(adminWsClient.hotspots().search(new org.sonarqube.ws.client.hotspots.SearchRequest().setProjectKey(PROJECT_KEY)).getHotspotsList()).isNotEmpty();
} else {
assertThat(adminWsClient.issues().search(new SearchRequest().setTypes(asList("SECURITY_HOTSPOT")).setComponentKeys(asList(PROJECT_KEY))).getIssuesList()).isNotEmpty();
}
}
use of org.sonarqube.ws.client.issues.SearchRequest in project sonarlint-core by SonarSource.
the class TaintVulnerabilitiesDownloadTest method prepare.
@Before
public void prepare() throws Exception {
var adminWsClient = newAdminWsClient(ORCHESTRATOR);
adminWsClient.users().create(new CreateRequest().setLogin(SONARLINT_USER).setPassword(SONARLINT_PWD).setName("SonarLint"));
ORCHESTRATOR.getServer().provisionProject(PROJECT_KEY, "Java With Taint Vulnerabilities");
ORCHESTRATOR.getServer().associateProjectToQualityProfile(PROJECT_KEY, "java", "SonarLint Taint Java");
analyzeMavenProject(PROJECT_KEY);
// Ensure a vulnerability has been reported on server side
assertThat(adminWsClient.issues().search(new SearchRequest().setTypes(asList("VULNERABILITY")).setComponentKeys(asList(PROJECT_KEY))).getIssuesList()).isNotEmpty();
sonarUserHome = temp.newFolder().toPath();
engine = new ConnectedSonarLintEngineImpl(ConnectedGlobalConfiguration.builder().setConnectionId("orchestrator").setSonarLintUserHome(sonarUserHome).setLogOutput((msg, level) -> logs.add(msg)).setExtraProperties(new HashMap<>()).build());
}
Aggregations