From 1dfb0dffa770b324711e1a95fe814226e1220306 Mon Sep 17 00:00:00 2001 From: Belen Pruvost Date: Thu, 2 Jun 2022 14:23:15 +0200 Subject: [PATCH] SONAR-16423 - Project license API changes --- .../src/main/java/org/sonar/db/MyBatis.java | 2 ++ .../org/sonar/db/measure/LargestBranchNclocDto.java | 10 ---------- .../org/sonar/db/measure/LiveMeasureMapper.xml | 7 ++----- .../sonar/db/measure/LargestBranchNclocDtoTest.java | 4 +--- .../sonarqube/ws/client/projects/ProjectsService.java | 7 +++---- 5 files changed, 8 insertions(+), 22 deletions(-) diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java b/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java index 112752428a3..76c699ab92c 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java @@ -76,6 +76,7 @@ import org.sonar.db.issue.NewCodeReferenceIssueDto; import org.sonar.db.issue.PrIssueDto; import org.sonar.db.mapping.ProjectMappingDto; import org.sonar.db.mapping.ProjectMappingsMapper; +import org.sonar.db.measure.LargestBranchNclocDto; import org.sonar.db.measure.LiveMeasureMapper; import org.sonar.db.measure.MeasureDto; import org.sonar.db.measure.MeasureMapper; @@ -201,6 +202,7 @@ public class MyBatis { confBuilder.loadAlias("Issue", IssueDto.class); confBuilder.loadAlias("NewCodeReferenceIssue", NewCodeReferenceIssueDto.class); confBuilder.loadAlias("Measure", MeasureDto.class); + confBuilder.loadAlias("LargestBranchNclocDto", LargestBranchNclocDto.class); confBuilder.loadAlias("NotificationQueue", NotificationQueueDto.class); confBuilder.loadAlias("PermissionTemplateCharacteristic", PermissionTemplateCharacteristicDto.class); confBuilder.loadAlias("PermissionTemplateGroup", PermissionTemplateGroupDto.class); diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LargestBranchNclocDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LargestBranchNclocDto.java index 579fe18f344..a6d41c798b0 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LargestBranchNclocDto.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LargestBranchNclocDto.java @@ -27,7 +27,6 @@ public class LargestBranchNclocDto { private long loc; private String branchName; private String branchType; - private long lastAnalysisDate; public String getProjectUuid() { return projectUuid; @@ -82,13 +81,4 @@ public class LargestBranchNclocDto { this.loc = loc; return this; } - - public long getLastAnalysisDate() { - return lastAnalysisDate; - } - - public LargestBranchNclocDto setLastAnalysisDate(long lastAnalysisDate) { - this.lastAnalysisDate = lastAnalysisDate; - return this; - } } diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/measure/LiveMeasureMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/measure/LiveMeasureMapper.xml index 3fe2bcd3fc5..3516f05dcda 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/measure/LiveMeasureMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/measure/LiveMeasureMapper.xml @@ -71,14 +71,13 @@ ) sumncloc - select tie_breaker.projectUuid, tie_breaker.projectName, tie_breaker.projectKey, ncloc as loc, pb.kee as branchName, - pb.branch_type as branchType, - s.created_at as lastAnalysisDate + pb.branch_type as branchType from (select counter.projectUuid as projectUuid, counter.maxncloc ncloc, @@ -107,8 +106,6 @@ group by counter.projectUuid, counter.maxncloc, counter.projectName, counter.projectKey) tie_breaker inner join components c2 on c2.kee = tie_breaker.component_kee inner join project_branches pb on c2.uuid = pb.uuid - inner join snapshots s on s.component_uuid = c2.uuid - where s.islast = ${_true} order by ncloc desc diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/measure/LargestBranchNclocDtoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/measure/LargestBranchNclocDtoTest.java index e5b2f71e2fb..2103a769736 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/measure/LargestBranchNclocDtoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/measure/LargestBranchNclocDtoTest.java @@ -37,7 +37,6 @@ public class LargestBranchNclocDtoTest { assertThat(underTest.getLoc()).isEqualTo(123L); assertThat(underTest.getBranchName()).isEqualTo("branchName"); assertThat(underTest.getBranchType()).isEqualTo("branchType"); - assertThat(underTest.getLastAnalysisDate()).isEqualTo(1L); } private void setUnderTest() { @@ -47,8 +46,7 @@ public class LargestBranchNclocDtoTest { .setProjectKey("projectKey") .setLoc(123L) .setBranchName("branchName") - .setBranchType("branchType") - .setLastAnalysisDate(1L); + .setBranchType("branchType"); } } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/projects/ProjectsService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/projects/ProjectsService.java index 27cc69dbb3a..90781ba4bb2 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/projects/ProjectsService.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/projects/ProjectsService.java @@ -22,7 +22,6 @@ package org.sonarqube.ws.client.projects; import java.util.stream.Collectors; import javax.annotation.Generated; import org.sonarqube.ws.MediaTypes; -import org.sonarqube.ws.Projects; import org.sonarqube.ws.Projects.CreateWsResponse; import org.sonarqube.ws.Projects.SearchMyProjectsWsResponse; import org.sonarqube.ws.Projects.SearchWsResponse; @@ -101,10 +100,10 @@ public class ProjectsService extends BaseService { * @see Further information about this action online (including a response example) * @since 9.4 */ - public String licenseUsage() { + public WsResponse licenseUsage() { GetRequest getRequest = new GetRequest(path("license_usage")) - .setMediaType(MediaTypes.CSV); - return call(getRequest).content(); + .setMediaType(MediaTypes.JSON); + return call(getRequest); } /** -- 2.39.5