Search in sources :

Example 1 with PULL_REQUEST

use of org.sonar.db.component.BranchType.PULL_REQUEST in project sonarqube by SonarSource.

the class ComponentTreeActionTest method pull_request.

@Test
public void pull_request() {
    ComponentDto project = db.components().insertPrivateProject();
    ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey("pr-123").setBranchType(PULL_REQUEST));
    SnapshotDto analysis = db.components().insertSnapshot(branch);
    ComponentDto file = db.components().insertComponent(newFileDto(branch));
    MetricDto complexity = db.measures().insertMetric(m -> m.setValueType(INT.name()));
    LiveMeasureDto measure = db.measures().insertLiveMeasure(file, complexity, m -> m.setValue(12.0d));
    ComponentTreeWsResponse response = ws.newRequest().setParam(PARAM_COMPONENT, file.getKey()).setParam(PARAM_PULL_REQUEST, "pr-123").setParam(PARAM_METRIC_KEYS, complexity.getKey()).executeProtobuf(ComponentTreeWsResponse.class);
    assertThat(response.getBaseComponent()).extracting(Component::getKey, Component::getPullRequest).containsExactlyInAnyOrder(file.getKey(), "pr-123");
    assertThat(response.getBaseComponent().getMeasuresList()).extracting(Measure::getMetric, m -> parseDouble(m.getValue())).containsExactlyInAnyOrder(tuple(complexity.getKey(), measure.getValue()));
}
Also used : ComponentFinder(org.sonar.server.component.ComponentFinder) SORT(org.sonar.api.server.ws.WebService.Param.SORT) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) MetricTesting(org.sonar.db.metric.MetricTesting) FILE(org.sonar.api.resources.Qualifiers.FILE) DEPRECATED_ADDITIONAL_PERIODS(org.sonar.server.component.ws.MeasuresWsParameters.DEPRECATED_ADDITIONAL_PERIODS) LEAVES_STRATEGY(org.sonar.server.measure.ws.ComponentTreeAction.LEAVES_STRATEGY) DbSession(org.sonar.db.DbSession) PARAM_QUALIFIERS(org.sonar.server.component.ws.MeasuresWsParameters.PARAM_QUALIFIERS) BadRequestException(org.sonar.server.exceptions.BadRequestException) PULL_REQUEST(org.sonar.db.component.BranchType.PULL_REQUEST) Collections.singletonList(java.util.Collections.singletonList) NEW_SECURITY_RATING_KEY(org.sonar.api.measures.CoreMetrics.NEW_SECURITY_RATING_KEY) Measure(org.sonarqube.ws.Measures.Measure) PARAM_METRIC_SORT(org.sonar.server.component.ws.MeasuresWsParameters.PARAM_METRIC_SORT) Param(org.sonar.api.server.ws.WebService.Param) SnapshotTesting.newAnalysis(org.sonar.db.component.SnapshotTesting.newAnalysis) PARAM_METRIC_KEYS(org.sonar.server.component.ws.MeasuresWsParameters.PARAM_METRIC_KEYS) Component(org.sonarqube.ws.Measures.Component) ComponentTesting(org.sonar.db.component.ComponentTesting) ResourceTypesRule(org.sonar.db.component.ResourceTypesRule) Double.parseDouble(java.lang.Double.parseDouble) DbTester(org.sonar.db.DbTester) APP(org.sonar.api.resources.Qualifiers.APP) System2(org.sonar.api.utils.System2) NAME_SORT(org.sonar.server.measure.ws.ComponentTreeAction.NAME_SORT) METRIC_SORT(org.sonar.server.measure.ws.ComponentTreeAction.METRIC_SORT) CoreMetrics(org.sonar.api.measures.CoreMetrics) NotFoundException(org.sonar.server.exceptions.NotFoundException) String.format(java.lang.String.format) Common(org.sonarqube.ws.Common) DbClient(org.sonar.db.DbClient) List(java.util.List) ComponentDto(org.sonar.db.component.ComponentDto) ForbiddenException(org.sonar.server.exceptions.ForbiddenException) ComponentTreeWsResponse(org.sonarqube.ws.Measures.ComponentTreeWsResponse) ComponentTesting.newDirectory(org.sonar.db.component.ComponentTesting.newDirectory) PARAM_ADDITIONAL_FIELDS(org.sonar.server.component.ws.MeasuresWsParameters.PARAM_ADDITIONAL_FIELDS) Joiner(com.google.common.base.Joiner) IntStream(java.util.stream.IntStream) PARAM_METRIC_SORT_FILTER(org.sonar.server.component.ws.MeasuresWsParameters.PARAM_METRIC_SORT_FILTER) FLOAT(org.sonar.api.measures.Metric.ValueType.FLOAT) ComponentTesting.newFileDto(org.sonar.db.component.ComponentTesting.newFileDto) DISTRIB(org.sonar.api.measures.Metric.ValueType.DISTRIB) PROJECT(org.sonar.api.resources.Qualifiers.PROJECT) RATING(org.sonar.api.measures.Metric.ValueType.RATING) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) ComponentTesting.newProjectCopy(org.sonar.db.component.ComponentTesting.newProjectCopy) WITH_MEASURES_ONLY_METRIC_SORT_FILTER(org.sonar.server.measure.ws.ComponentTreeAction.WITH_MEASURES_ONLY_METRIC_SORT_FILTER) MoreCollectors(org.sonar.core.util.stream.MoreCollectors) PARAM_METRIC_PERIOD_SORT(org.sonar.server.component.ws.MeasuresWsParameters.PARAM_METRIC_PERIOD_SORT) UserSessionRule(org.sonar.server.tester.UserSessionRule) PARAM_STRATEGY(org.sonar.server.component.ws.MeasuresWsParameters.PARAM_STRATEGY) Assertions.tuple(org.assertj.core.api.Assertions.tuple) PeriodValue(org.sonarqube.ws.Measures.PeriodValue) JsonAssert.assertJson(org.sonar.test.JsonAssert.assertJson) DIRECTORY(org.sonar.api.resources.Qualifiers.DIRECTORY) Test(org.junit.Test) PARAM_COMPONENT(org.sonar.server.component.ws.MeasuresWsParameters.PARAM_COMPONENT) WsActionTester(org.sonar.server.ws.WsActionTester) PARAM_PULL_REQUEST(org.sonar.server.component.ws.MeasuresWsParameters.PARAM_PULL_REQUEST) Rule(org.junit.Rule) UserRole(org.sonar.api.web.UserRole) MetricDto(org.sonar.db.metric.MetricDto) LiveMeasureDto(org.sonar.db.measure.LiveMeasureDto) INT(org.sonar.api.measures.Metric.ValueType.INT) UNIT_TEST_FILE(org.sonar.api.resources.Qualifiers.UNIT_TEST_FILE) DateUtils.parseDateTime(org.sonar.api.utils.DateUtils.parseDateTime) METRIC_PERIOD_SORT(org.sonar.server.measure.ws.ComponentTreeAction.METRIC_PERIOD_SORT) I18nRule(org.sonar.server.l18n.I18nRule) ComponentDbTester.toProjectDto(org.sonar.db.component.ComponentDbTester.toProjectDto) SnapshotDto(org.sonar.db.component.SnapshotDto) PARAM_BRANCH(org.sonar.server.component.ws.MeasuresWsParameters.PARAM_BRANCH) Metric(org.sonar.api.measures.Metric) ADDITIONAL_PERIOD(org.sonar.server.component.ws.MeasuresWsParameters.ADDITIONAL_PERIOD) MetricDto(org.sonar.db.metric.MetricDto) SnapshotDto(org.sonar.db.component.SnapshotDto) ComponentDto(org.sonar.db.component.ComponentDto) LiveMeasureDto(org.sonar.db.measure.LiveMeasureDto) ComponentTreeWsResponse(org.sonarqube.ws.Measures.ComponentTreeWsResponse) Test(org.junit.Test)

Example 2 with PULL_REQUEST

use of org.sonar.db.component.BranchType.PULL_REQUEST in project sonarqube by SonarSource.

the class AsyncIssueIndexingImplTest method characteristics_are_defined.

@Test
public void characteristics_are_defined() {
    BranchDto dto = new BranchDto().setBranchType(BRANCH).setKey("branch_1").setUuid("branch_uuid1").setProjectUuid("project_uuid1");
    dbClient.branchDao().insert(dbTester.getSession(), dto);
    dbTester.commit();
    insertSnapshot("analysis_1", "project_uuid1", 1);
    BranchDto dto2 = new BranchDto().setBranchType(PULL_REQUEST).setKey("pr_1").setUuid("pr_uuid_1").setProjectUuid("project_uuid2");
    dbClient.branchDao().insert(dbTester.getSession(), dto2);
    dbTester.commit();
    insertSnapshot("analysis_2", "project_uuid2", 2);
    underTest.triggerOnIndexCreation();
    ArgumentCaptor<Collection<CeTaskSubmit>> captor = ArgumentCaptor.forClass(Collection.class);
    verify(ceQueue, times(1)).massSubmit(captor.capture());
    List<Collection<CeTaskSubmit>> captures = captor.getAllValues();
    assertThat(captures).hasSize(1);
    Collection<CeTaskSubmit> tasks = captures.get(0);
    assertThat(tasks).hasSize(2);
    assertThat(tasks).extracting(p -> p.getCharacteristics().get(BRANCH_TYPE_KEY), p -> p.getCharacteristics().get(CeTaskCharacteristicDto.BRANCH_KEY), p -> p.getCharacteristics().get(CeTaskCharacteristicDto.PULL_REQUEST)).containsExactlyInAnyOrder(tuple("BRANCH", "branch_1", null), tuple("PULL_REQUEST", null, "pr_1"));
}
Also used : BranchDto(org.sonar.db.component.BranchDto) Arrays(java.util.Arrays) BRANCH_TYPE_KEY(org.sonar.db.ce.CeTaskCharacteristicDto.BRANCH_TYPE_KEY) STATUS_PROCESSED(org.sonar.db.component.SnapshotDto.STATUS_PROCESSED) REPORT(org.sonar.db.ce.CeTaskTypes.REPORT) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) HashMap(java.util.HashMap) PULL_REQUEST(org.sonar.db.component.BranchType.PULL_REQUEST) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) CeActivityDto(org.sonar.db.ce.CeActivityDto) ArgumentCaptor(org.mockito.ArgumentCaptor) Map(java.util.Map) BRANCH_ISSUE_SYNC(org.sonar.db.ce.CeTaskTypes.BRANCH_ISSUE_SYNC) CeTaskCharacteristicDto(org.sonar.db.ce.CeTaskCharacteristicDto) Before(org.junit.Before) DbTester(org.sonar.db.DbTester) System2(org.sonar.api.utils.System2) Assertions.tuple(org.assertj.core.api.Assertions.tuple) Collection(java.util.Collection) UuidFactory(org.sonar.core.util.UuidFactory) Test(org.junit.Test) Mockito.times(org.mockito.Mockito.times) Mockito.when(org.mockito.Mockito.when) BRANCH(org.sonar.db.component.BranchType.BRANCH) SequenceUuidFactory(org.sonar.core.util.SequenceUuidFactory) Mockito.verify(org.mockito.Mockito.verify) DbClient(org.sonar.db.DbClient) ArgumentMatchers.anyCollection(org.mockito.ArgumentMatchers.anyCollection) List(java.util.List) Rule(org.junit.Rule) LogTester(org.sonar.api.utils.log.LogTester) CeTaskSubmit(org.sonar.ce.queue.CeTaskSubmit) CeQueueDto(org.sonar.db.ce.CeQueueDto) Optional(java.util.Optional) Status(org.sonar.db.ce.CeActivityDto.Status) SnapshotDto(org.sonar.db.component.SnapshotDto) Assertions.assertThatCode(org.assertj.core.api.Assertions.assertThatCode) LoggerLevel(org.sonar.api.utils.log.LoggerLevel) CeQueue(org.sonar.ce.queue.CeQueue) Mockito.mock(org.mockito.Mockito.mock) BranchDto(org.sonar.db.component.BranchDto) Collection(java.util.Collection) ArgumentMatchers.anyCollection(org.mockito.ArgumentMatchers.anyCollection) CeTaskSubmit(org.sonar.ce.queue.CeTaskSubmit) Test(org.junit.Test)

Example 3 with PULL_REQUEST

use of org.sonar.db.component.BranchType.PULL_REQUEST in project sonarqube by SonarSource.

the class ListActionTest method response_contains_date_of_last_analysis.

@Test
public void response_contains_date_of_last_analysis() {
    Long lastAnalysisNonMainBranch = dateToLong(parseDateTime("2017-04-01T00:00:00+0100"));
    Long previousAnalysisPullRequest = dateToLong(parseDateTime("2017-04-02T00:00:00+0100"));
    Long lastAnalysisPullRequest = dateToLong(parseDateTime("2017-04-03T00:00:00+0100"));
    ComponentDto project = db.components().insertPrivateProject();
    userSession.logIn().addProjectPermission(UserRole.USER, project);
    ComponentDto pullRequest1 = db.components().insertProjectBranch(project, b -> b.setKey("pr1").setBranchType(PULL_REQUEST).setMergeBranchUuid(project.uuid()).setPullRequestData(DbProjectBranches.PullRequestData.newBuilder().setBranch("feature/pr1").build()));
    ComponentDto nonMainBranch2 = db.components().insertProjectBranch(project, b -> b.setBranchType(BranchType.BRANCH));
    ComponentDto pullRequest2 = db.components().insertProjectBranch(project, b -> b.setKey("pr2").setBranchType(PULL_REQUEST).setMergeBranchUuid(nonMainBranch2.uuid()).setPullRequestData(DbProjectBranches.PullRequestData.newBuilder().setBranch("feature/pr2").build()));
    db.getDbClient().snapshotDao().insert(db.getSession(), newAnalysis(nonMainBranch2).setCreatedAt(lastAnalysisNonMainBranch));
    db.getDbClient().snapshotDao().insert(db.getSession(), newAnalysis(pullRequest2).setCreatedAt(previousAnalysisPullRequest).setLast(false));
    db.getDbClient().snapshotDao().insert(db.getSession(), newAnalysis(pullRequest2).setCreatedAt(lastAnalysisPullRequest));
    db.commit();
    indexIssues();
    permissionIndexerTester.allowOnlyAnyone(project);
    ListWsResponse response = ws.newRequest().setParam("project", project.getKey()).executeProtobuf(ListWsResponse.class);
    assertThat(response.getPullRequestsList()).extracting(PullRequest::hasAnalysisDate, b -> "".equals(b.getAnalysisDate()) ? null : dateToLong(parseDateTime(b.getAnalysisDate()))).containsExactlyInAnyOrder(tuple(false, null), tuple(true, lastAnalysisPullRequest));
}
Also used : ComponentFinder(org.sonar.server.component.ComponentFinder) PermissionIndexerTester(org.sonar.server.permission.index.PermissionIndexerTester) GlobalPermission(org.sonar.db.permission.GlobalPermission) PullRequest(org.sonarqube.ws.ProjectPullRequests.PullRequest) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) CODEVIEWER(org.sonar.api.web.UserRole.CODEVIEWER) BUG(org.sonar.api.rules.RuleType.BUG) PULL_REQUEST(org.sonar.db.component.BranchType.PULL_REQUEST) WebService(org.sonar.api.server.ws.WebService) SnapshotTesting.newAnalysis(org.sonar.db.component.SnapshotTesting.newAnalysis) IssueIndex(org.sonar.server.issue.index.IssueIndex) IssueIteratorFactory(org.sonar.server.issue.index.IssueIteratorFactory) ComponentTesting(org.sonar.db.component.ComponentTesting) ResourceTypesRule(org.sonar.db.component.ResourceTypesRule) ResourceTypes(org.sonar.api.resources.ResourceTypes) DbTester(org.sonar.db.DbTester) PARAM_PROJECT(org.sonar.server.branch.pr.ws.PullRequestsWsParameters.PARAM_PROJECT) System2(org.sonar.api.utils.System2) VULNERABILITY(org.sonar.api.rules.RuleType.VULNERABILITY) ListWsResponse(org.sonarqube.ws.ProjectPullRequests.ListWsResponse) Status(org.sonarqube.ws.ProjectPullRequests.Status) BRANCH(org.sonar.db.component.BranchType.BRANCH) NotFoundException(org.sonar.server.exceptions.NotFoundException) String.format(java.lang.String.format) ComponentDto(org.sonar.db.component.ComponentDto) ALERT_STATUS_KEY(org.sonar.api.measures.CoreMetrics.ALERT_STATUS_KEY) ForbiddenException(org.sonar.server.exceptions.ForbiddenException) CODE_SMELL(org.sonar.api.rules.RuleType.CODE_SMELL) SCAN_EXECUTION(org.sonar.core.permission.GlobalPermissions.SCAN_EXECUTION) RuleDefinitionDto(org.sonar.db.rule.RuleDefinitionDto) EsTester(org.sonar.server.es.EsTester) PROJECT(org.sonar.api.resources.Qualifiers.PROJECT) DbProjectBranches(org.sonar.db.protobuf.DbProjectBranches) DateUtils.dateToLong(org.sonar.api.utils.DateUtils.dateToLong) DateUtils(org.sonar.api.utils.DateUtils) WebAuthorizationTypeSupport(org.sonar.server.permission.index.WebAuthorizationTypeSupport) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) RESOLUTION_FALSE_POSITIVE(org.sonar.api.issue.Issue.RESOLUTION_FALSE_POSITIVE) MediaTypes(org.sonarqube.ws.MediaTypes) RESOLUTION_FIXED(org.sonar.api.issue.Issue.RESOLUTION_FIXED) Before(org.junit.Before) UserSessionRule(org.sonar.server.tester.UserSessionRule) BranchType(org.sonar.db.component.BranchType) Assertions.tuple(org.assertj.core.api.Assertions.tuple) JsonAssert.assertJson(org.sonar.test.JsonAssert.assertJson) Test(org.junit.Test) WsActionTester(org.sonar.server.ws.WsActionTester) Rule(org.junit.Rule) UserRole(org.sonar.api.web.UserRole) MetricDto(org.sonar.db.metric.MetricDto) DateUtils.parseDateTime(org.sonar.api.utils.DateUtils.parseDateTime) Change(org.sonar.api.server.ws.Change) IssueIndexer(org.sonar.server.issue.index.IssueIndexer) ListWsResponse(org.sonarqube.ws.ProjectPullRequests.ListWsResponse) DateUtils.dateToLong(org.sonar.api.utils.DateUtils.dateToLong) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 4 with PULL_REQUEST

use of org.sonar.db.component.BranchType.PULL_REQUEST in project sonarqube by SonarSource.

the class ComponentKeyUpdaterDaoTest method updateKey_updates_pull_requests_too.

@Test
public void updateKey_updates_pull_requests_too() {
    ComponentDto project = db.components().insertPublicProject();
    ComponentDto pullRequest = db.components().insertProjectBranch(project, b -> b.setBranchType(PULL_REQUEST));
    db.components().insertComponent(newFileDto(pullRequest));
    db.components().insertComponent(newFileDto(pullRequest));
    int branchComponentCount = 3;
    String oldProjectKey = project.getKey();
    assertThat(dbClient.componentDao().selectAllComponentsFromProjectKey(dbSession, oldProjectKey)).hasSize(1);
    String oldBranchKey = pullRequest.getDbKey();
    assertThat(dbClient.componentDao().selectAllComponentsFromProjectKey(dbSession, oldBranchKey)).hasSize(branchComponentCount);
    String newProjectKey = "newKey";
    String newBranchKey = ComponentDto.generatePullRequestKey(newProjectKey, pullRequest.getPullRequest());
    underTest.updateKey(dbSession, project.uuid(), newProjectKey);
    assertThat(dbClient.componentDao().selectAllComponentsFromProjectKey(dbSession, oldProjectKey)).isEmpty();
    assertThat(dbClient.componentDao().selectAllComponentsFromProjectKey(dbSession, oldBranchKey)).isEmpty();
    assertThat(dbClient.componentDao().selectAllComponentsFromProjectKey(dbSession, newProjectKey)).hasSize(1);
    assertThat(dbClient.componentDao().selectAllComponentsFromProjectKey(dbSession, newBranchKey)).hasSize(branchComponentCount);
    db.select(dbSession, "select kee from components").forEach(map -> map.values().forEach(k -> assertThat(k.toString()).startsWith(newProjectKey)));
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) ComponentTesting.newFileDto(org.sonar.db.component.ComponentTesting.newFileDto) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RekeyedResource(org.sonar.db.component.ComponentKeyUpdaterDao.RekeyedResource) DbSession(org.sonar.db.DbSession) PULL_REQUEST(org.sonar.db.component.BranchType.PULL_REQUEST) BRANCH_KEY_SEPARATOR(org.sonar.db.component.ComponentDto.BRANCH_KEY_SEPARATOR) Strings(com.google.common.base.Strings) ComponentKeyUpdaterDao.computeNewKey(org.sonar.db.component.ComponentKeyUpdaterDao.computeNewKey) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) Map(java.util.Map) ComponentDto.generateBranchKey(org.sonar.db.component.ComponentDto.generateBranchKey) DbTester(org.sonar.db.DbTester) Tuple(org.assertj.core.groups.Tuple) System2(org.sonar.api.utils.System2) Predicate(java.util.function.Predicate) Test(org.junit.Test) Mockito.times(org.mockito.Mockito.times) ComponentKeyNewValue(org.sonar.db.audit.model.ComponentKeyNewValue) Mockito.verify(org.mockito.Mockito.verify) DbClient(org.sonar.db.DbClient) ComponentTesting.newPrivateProjectDto(org.sonar.db.component.ComponentTesting.newPrivateProjectDto) List(java.util.List) AuditPersister(org.sonar.db.audit.AuditPersister) Rule(org.junit.Rule) Qualifiers(org.sonar.api.resources.Qualifiers) ComponentTesting.newDirectory(org.sonar.db.component.ComponentTesting.newDirectory) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Mockito.mock(org.mockito.Mockito.mock) ComponentTesting.newModuleDto(org.sonar.db.component.ComponentTesting.newModuleDto) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 5 with PULL_REQUEST

use of org.sonar.db.component.BranchType.PULL_REQUEST in project sonarqube by SonarSource.

the class SearchHistoryActionTest method pull_request.

@Test
public void pull_request() {
    ComponentDto project = db.components().insertPrivateProject();
    userSession.addProjectPermission(UserRole.USER, project);
    ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey("pr-123").setBranchType(PULL_REQUEST));
    ComponentDto file = db.components().insertComponent(newFileDto(branch));
    SnapshotDto analysis = db.components().insertSnapshot(branch);
    MeasureDto measure = db.measures().insertMeasure(file, analysis, nclocMetric, m -> m.setValue(2d));
    SearchHistoryResponse result = ws.newRequest().setParam(PARAM_COMPONENT, file.getKey()).setParam(PARAM_PULL_REQUEST, "pr-123").setParam(PARAM_METRICS, "ncloc").executeProtobuf(SearchHistoryResponse.class);
    assertThat(result.getMeasuresList()).extracting(HistoryMeasure::getMetric).hasSize(1);
    HistoryMeasure historyMeasure = result.getMeasures(0);
    assertThat(historyMeasure.getMetric()).isEqualTo(nclocMetric.getKey());
    assertThat(historyMeasure.getHistoryList()).extracting(m -> parseDouble(m.getValue())).containsExactlyInAnyOrder(measure.getValue());
}
Also used : MeasureDto(org.sonar.db.measure.MeasureDto) MeasureTesting.newMeasureDto(org.sonar.db.measure.MeasureTesting.newMeasureDto) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) DbSession(org.sonar.db.DbSession) MeasureDto(org.sonar.db.measure.MeasureDto) PULL_REQUEST(org.sonar.db.component.BranchType.PULL_REQUEST) Collections.singletonList(java.util.Collections.singletonList) MetricTesting.newMetricDto(org.sonar.db.metric.MetricTesting.newMetricDto) Param(org.sonar.api.server.ws.WebService.Param) WebService(org.sonar.api.server.ws.WebService) SnapshotTesting.newAnalysis(org.sonar.db.component.SnapshotTesting.newAnalysis) Arrays.asList(java.util.Arrays.asList) DateUtils.formatDateTime(org.sonar.api.utils.DateUtils.formatDateTime) Double.parseDouble(java.lang.Double.parseDouble) DbTester(org.sonar.db.DbTester) System2(org.sonar.api.utils.System2) HistoryMeasure(org.sonarqube.ws.Measures.SearchHistoryResponse.HistoryMeasure) NotFoundException(org.sonar.server.exceptions.NotFoundException) String.format(java.lang.String.format) DbClient(org.sonar.db.DbClient) List(java.util.List) ComponentDto(org.sonar.db.component.ComponentDto) ForbiddenException(org.sonar.server.exceptions.ForbiddenException) PARAM_TO(org.sonar.server.component.ws.MeasuresWsParameters.PARAM_TO) HistoryValue(org.sonarqube.ws.Measures.SearchHistoryResponse.HistoryValue) ComponentTesting.newFileDto(org.sonar.db.component.ComponentTesting.newFileDto) SearchHistoryRequest(org.sonar.server.measure.ws.SearchHistoryAction.SearchHistoryRequest) PARAM_FROM(org.sonar.server.component.ws.MeasuresWsParameters.PARAM_FROM) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) MeasureTesting.newMeasureDto(org.sonar.db.measure.MeasureTesting.newMeasureDto) TestComponentFinder(org.sonar.server.component.TestComponentFinder) MoreCollectors(org.sonar.core.util.stream.MoreCollectors) Before(org.junit.Before) UserSessionRule(org.sonar.server.tester.UserSessionRule) LongStream(java.util.stream.LongStream) Assertions.tuple(org.assertj.core.api.Assertions.tuple) Optional.ofNullable(java.util.Optional.ofNullable) TestRequest(org.sonar.server.ws.TestRequest) JsonAssert.assertJson(org.sonar.test.JsonAssert.assertJson) Paging(org.sonarqube.ws.Common.Paging) Test(org.junit.Test) STATUS_UNPROCESSED(org.sonar.db.component.SnapshotDto.STATUS_UNPROCESSED) PARAM_COMPONENT(org.sonar.server.component.ws.MeasuresWsParameters.PARAM_COMPONENT) WsActionTester(org.sonar.server.ws.WsActionTester) PARAM_PULL_REQUEST(org.sonar.server.component.ws.MeasuresWsParameters.PARAM_PULL_REQUEST) ValueType(org.sonar.api.measures.Metric.ValueType) PARAM_METRICS(org.sonar.server.component.ws.MeasuresWsParameters.PARAM_METRICS) ComponentTesting.newPrivateProjectDto(org.sonar.db.component.ComponentTesting.newPrivateProjectDto) Rule(org.junit.Rule) UserRole(org.sonar.api.web.UserRole) MetricDto(org.sonar.db.metric.MetricDto) SearchHistoryResponse(org.sonarqube.ws.Measures.SearchHistoryResponse) DateUtils.parseDateTime(org.sonar.api.utils.DateUtils.parseDateTime) ComponentDbTester.toProjectDto(org.sonar.db.component.ComponentDbTester.toProjectDto) SnapshotDto(org.sonar.db.component.SnapshotDto) PARAM_BRANCH(org.sonar.server.component.ws.MeasuresWsParameters.PARAM_BRANCH) SnapshotDto(org.sonar.db.component.SnapshotDto) SearchHistoryResponse(org.sonarqube.ws.Measures.SearchHistoryResponse) ComponentDto(org.sonar.db.component.ComponentDto) HistoryMeasure(org.sonarqube.ws.Measures.SearchHistoryResponse.HistoryMeasure) Test(org.junit.Test)

Aggregations

PULL_REQUEST (org.sonar.db.component.BranchType.PULL_REQUEST)10 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)8 Rule (org.junit.Rule)8 Test (org.junit.Test)8 System2 (org.sonar.api.utils.System2)8 UserRole (org.sonar.api.web.UserRole)8 DbTester (org.sonar.db.DbTester)8 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)7 Assertions.tuple (org.assertj.core.api.Assertions.tuple)7 DbClient (org.sonar.db.DbClient)7 SnapshotDto (org.sonar.db.component.SnapshotDto)7 NotFoundException (org.sonar.server.exceptions.NotFoundException)7 String.format (java.lang.String.format)6 List (java.util.List)6 DateUtils.parseDateTime (org.sonar.api.utils.DateUtils.parseDateTime)6 ComponentDto (org.sonar.db.component.ComponentDto)6 MetricDto (org.sonar.db.metric.MetricDto)6 ForbiddenException (org.sonar.server.exceptions.ForbiddenException)6 UserSessionRule (org.sonar.server.tester.UserSessionRule)6 WsActionTester (org.sonar.server.ws.WsActionTester)6