use of org.sonarqube.ws.Hotspots.SearchWsResponse in project sonarqube by SonarSource.
the class SearchActionTest method returns_specified_hotspots.
@Test
public void returns_specified_hotspots() {
ComponentDto project = dbTester.components().insertPublicProject();
userSessionRule.registerComponents(project);
indexPermissions();
ComponentDto file = dbTester.components().insertComponent(newFileDto(project));
RuleDefinitionDto rule = newRule(SECURITY_HOTSPOT);
int total = 1 + RANDOM.nextInt(20);
List<IssueDto> hotspots = IntStream.range(0, total).mapToObj(i -> dbTester.issues().insertHotspot(rule, project, file, t -> t.setLine(i))).collect(toList());
Collections.shuffle(hotspots);
List<IssueDto> selectedHotspots = hotspots.stream().limit(total == 1 ? 1 : 1 + RANDOM.nextInt(total - 1)).collect(toList());
indexIssues();
SearchWsResponse response = newRequest(selectedHotspots.stream().map(IssueDto::getKey).collect(toList())).executeProtobuf(SearchWsResponse.class);
assertThat(response.getHotspotsList()).extracting(SearchWsResponse.Hotspot::getKey).containsExactlyInAnyOrder(selectedHotspots.stream().map(IssueDto::getKey).toArray(String[]::new));
}
use of org.sonarqube.ws.Hotspots.SearchWsResponse in project sonarqube by SonarSource.
the class SearchActionTest method succeeds_on_private_application_with_permission.
@Test
public void succeeds_on_private_application_with_permission() {
ComponentDto application = dbTester.components().insertPrivateApplication();
userSessionRule.logIn().registerApplication(application).addProjectPermission(USER, application);
SearchWsResponse response = newRequest(application).executeProtobuf(SearchWsResponse.class);
assertThat(response.getHotspotsList()).isEmpty();
assertThat(response.getComponentsList()).isEmpty();
}
use of org.sonarqube.ws.Hotspots.SearchWsResponse in project sonarqube by SonarSource.
the class SearchActionTest method returns_empty_if_none_of_hotspot_keys_exist.
@Test
public void returns_empty_if_none_of_hotspot_keys_exist() {
ComponentDto project = dbTester.components().insertPublicProject();
userSessionRule.registerComponents(project);
indexPermissions();
ComponentDto file = dbTester.components().insertComponent(newFileDto(project));
RuleDefinitionDto rule = newRule(SECURITY_HOTSPOT);
List<IssueDto> hotspots = IntStream.range(0, 1 + RANDOM.nextInt(15)).mapToObj(i -> dbTester.issues().insertHotspot(rule, project, file, t -> t.setLine(i))).collect(toList());
indexIssues();
SearchWsResponse response = newRequest(IntStream.range(0, 1 + RANDOM.nextInt(30)).mapToObj(i -> "key_" + i).collect(toList())).executeProtobuf(SearchWsResponse.class);
verify(issueIndexSyncProgressChecker).checkIfIssueSyncInProgress(any());
assertThat(response.getHotspotsList()).isEmpty();
}
Aggregations