use of org.sonarqube.ws.Hotspots.Component in project sonarqube by SonarSource.
the class SearchActionTest method returns_hotspots_of_specified_project.
@Test
public void returns_hotspots_of_specified_project() {
ComponentDto project1 = dbTester.components().insertPublicProject();
ComponentDto project2 = dbTester.components().insertPublicProject();
userSessionRule.registerComponents(project1, project2);
indexPermissions();
ComponentDto file1 = dbTester.components().insertComponent(newFileDto(project1));
ComponentDto file2 = dbTester.components().insertComponent(newFileDto(project2));
IssueDto[] hotspots2 = IntStream.range(0, 1 + RANDOM.nextInt(10)).mapToObj(i -> {
RuleDefinitionDto rule = newRule(SECURITY_HOTSPOT);
insertHotspot(project1, file1, rule);
return insertHotspot(project2, file2, rule);
}).toArray(IssueDto[]::new);
indexIssues();
SearchWsResponse responseProject1 = newRequest(project1).executeProtobuf(SearchWsResponse.class);
assertThat(responseProject1.getHotspotsList()).extracting(SearchWsResponse.Hotspot::getKey).doesNotContainAnyElementsOf(Arrays.stream(hotspots2).map(IssueDto::getKey).collect(toList()));
assertThat(responseProject1.getComponentsList()).extracting(Component::getKey).containsOnly(project1.getKey(), file1.getKey());
SearchWsResponse responseProject2 = newRequest(project2).executeProtobuf(SearchWsResponse.class);
assertThat(responseProject2.getHotspotsList()).extracting(SearchWsResponse.Hotspot::getKey).containsOnly(Arrays.stream(hotspots2).map(IssueDto::getKey).toArray(String[]::new));
assertThat(responseProject2.getComponentsList()).extracting(Component::getKey).containsOnly(project2.getKey(), file2.getKey());
}
use of org.sonarqube.ws.Hotspots.Component in project sonarqube by SonarSource.
the class SearchActionTest method returns_hotspots_of_specified_application_branch.
@Test
public void returns_hotspots_of_specified_application_branch() {
ComponentDto application = dbTester.components().insertPublicApplication();
ComponentDto applicationBranch = dbTester.components().insertProjectBranch(application);
ComponentDto project1 = dbTester.components().insertPublicProject();
ComponentDto project2 = dbTester.components().insertPublicProject();
dbTester.components().insertComponent(ComponentTesting.newProjectCopy(project1, application));
dbTester.components().insertComponent(ComponentTesting.newProjectCopy(project2, applicationBranch));
indexViews();
userSessionRule.registerApplication(application, applicationBranch, project1, project2);
indexPermissions();
ComponentDto file1 = dbTester.components().insertComponent(newFileDto(project1));
ComponentDto file2 = dbTester.components().insertComponent(newFileDto(project2));
IssueDto[] hotspots2 = IntStream.range(0, 1 + RANDOM.nextInt(10)).mapToObj(i -> {
RuleDefinitionDto rule = newRule(SECURITY_HOTSPOT);
insertHotspot(project1, file1, rule);
return insertHotspot(project2, file2, rule);
}).toArray(IssueDto[]::new);
indexIssues();
SearchWsResponse responseApplication = newRequest(application).executeProtobuf(SearchWsResponse.class);
assertThat(responseApplication.getHotspotsList()).extracting(SearchWsResponse.Hotspot::getKey).doesNotContainAnyElementsOf(Arrays.stream(hotspots2).map(IssueDto::getKey).collect(toList()));
assertThat(responseApplication.getComponentsList()).extracting(Component::getKey).containsOnly(project1.getKey(), file1.getKey());
SearchWsResponse responseApplicationBranch = newRequest(applicationBranch).executeProtobuf(SearchWsResponse.class);
assertThat(responseApplicationBranch.getHotspotsList()).extracting(SearchWsResponse.Hotspot::getKey).containsOnly(Arrays.stream(hotspots2).map(IssueDto::getKey).toArray(String[]::new));
assertThat(responseApplicationBranch.getComponentsList()).extracting(Component::getKey).containsOnly(project2.getKey(), file2.getKey());
}
use of org.sonarqube.ws.Hotspots.Component in project sonarqube by SonarSource.
the class SearchActionTest method returns_single_component_when_all_hotspots_are_on_project.
@Test
public void returns_single_component_when_all_hotspots_are_on_project() {
ComponentDto project = dbTester.components().insertPublicProject();
userSessionRule.registerComponents(project);
indexPermissions();
IssueDto[] hotspots = IntStream.range(0, 1 + RANDOM.nextInt(10)).mapToObj(i -> {
RuleDefinitionDto rule = newRule(SECURITY_HOTSPOT);
return insertHotspot(project, project, rule);
}).toArray(IssueDto[]::new);
indexIssues();
SearchWsResponse response = newRequest(project).executeProtobuf(SearchWsResponse.class);
assertThat(response.getHotspotsList()).extracting(Hotspots.SearchWsResponse.Hotspot::getKey).containsOnly(Arrays.stream(hotspots).map(IssueDto::getKey).toArray(String[]::new));
assertThat(response.getComponentsList()).extracting(Component::getKey).containsOnly(project.getKey());
}
Aggregations