use of org.sonar.server.issue.SearchRequest in project sonarqube by SonarSource.
the class IssueQueryFactoryTest method add_unknown_when_no_component_found.
@Test
public void add_unknown_when_no_component_found() {
SearchRequest request = new SearchRequest().setComponents(asList("does_not_exist"));
IssueQuery query = underTest.create(request);
assertThat(query.componentUuids()).containsOnly("<UNKNOWN>");
}
use of org.sonar.server.issue.SearchRequest in project sonarqube by SonarSource.
the class IssueQueryFactoryTest method new_code_period_does_not_rely_on_date_for_reference_branch.
@Test
public void new_code_period_does_not_rely_on_date_for_reference_branch() {
ComponentDto project = db.components().insertPublicProject();
ComponentDto file = db.components().insertComponent(newFileDto(project));
SnapshotDto analysis = db.components().insertSnapshot(project, s -> s.setPeriodMode(REFERENCE_BRANCH.name()).setPeriodParam("master"));
SearchRequest request = new SearchRequest().setComponentUuids(Collections.singletonList(file.uuid())).setOnComponentOnly(true).setInNewCodePeriod(true);
IssueQuery query = underTest.create(request);
assertThat(query.componentUuids()).containsOnly(file.uuid());
assertThat(query.newCodeOnReference()).isTrue();
assertThat(query.createdAfter()).isNull();
}
use of org.sonar.server.issue.SearchRequest in project sonarqube by SonarSource.
the class IssueQueryFactoryTest method leak_period_does_not_rely_on_date_for_reference_branch.
@Test
public void leak_period_does_not_rely_on_date_for_reference_branch() {
long leakPeriodStart = addDays(new Date(), -14).getTime();
ComponentDto project = db.components().insertPublicProject();
ComponentDto file = db.components().insertComponent(newFileDto(project));
SnapshotDto analysis = db.components().insertSnapshot(project, s -> s.setPeriodMode(REFERENCE_BRANCH.name()).setPeriodParam("master"));
SearchRequest request = new SearchRequest().setComponentUuids(Collections.singletonList(file.uuid())).setOnComponentOnly(true).setSinceLeakPeriod(true);
IssueQuery query = underTest.create(request);
assertThat(query.componentUuids()).containsOnly(file.uuid());
assertThat(query.newCodeOnReference()).isTrue();
assertThat(query.createdAfter()).isNull();
}
use of org.sonar.server.issue.SearchRequest in project sonarqube by SonarSource.
the class ComponentTagsAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
String componentUuid = request.mandatoryParam(PARAM_COMPONENT_UUID);
checkIfAnyComponentsNeedIssueSync(componentUuid);
SearchRequest searchRequest = new SearchRequest().setComponentUuids(singletonList(componentUuid)).setTypes(ISSUE_TYPE_NAMES).setResolved(false).setCreatedAfter(request.param(PARAM_CREATED_AFTER));
IssueQuery query = queryService.create(searchRequest);
int pageSize = request.mandatoryParamAsInt(PAGE_SIZE);
try (JsonWriter json = response.newJsonWriter()) {
json.beginObject().name("tags").beginArray();
for (Map.Entry<String, Long> tag : issueIndex.countTags(query, pageSize).entrySet()) {
json.beginObject().prop("key", tag.getKey()).prop("value", tag.getValue()).endObject();
}
json.endArray().endObject();
}
}
use of org.sonar.server.issue.SearchRequest in project sonarqube by SonarSource.
the class ComponentTagsActionTest method should_return_tag_list_with_created_after.
@Test
public void should_return_tag_list_with_created_after() {
Map<String, Long> tags = ImmutableMap.<String, Long>builder().put("convention", 2771L).put("brain-overload", 998L).put("cwe", 89L).put("bug", 32L).put("cert", 2L).build();
ArgumentCaptor<SearchRequest> captor = ArgumentCaptor.forClass(SearchRequest.class);
when(issueQueryFactory.create(captor.capture())).thenReturn(mock(IssueQuery.class));
when(service.countTags(any(IssueQuery.class), eq(5))).thenReturn(tags);
String componentUuid = "polop";
String createdAfter = "2011-04-25";
TestResponse response = tester.newRequest().setParam("componentUuid", componentUuid).setParam("createdAfter", createdAfter).setParam("ps", "5").execute();
assertJson(response.getInput()).isSimilarTo(getClass().getResource("ComponentTagsActionTest/component-tags.json"));
assertThat(captor.getValue().getTypes()).containsExactlyInAnyOrder(ISSUE_RULE_TYPES);
assertThat(captor.getValue().getComponentUuids()).containsOnly(componentUuid);
assertThat(captor.getValue().getResolved()).isFalse();
assertThat(captor.getValue().getCreatedAfter()).isEqualTo(createdAfter);
verify(issueIndexSyncProgressChecker).checkIfComponentNeedIssueSync(any(), eq("KEY_polop"));
}
Aggregations