Browse Source

SONAR-18219 Change type of telemetry data

tags/10.0.0.68432
Antoine Vinot 1 year ago
parent
commit
57c2c0ce44

+ 8
- 8
server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryData.java View File

@@ -294,8 +294,8 @@ public class TelemetryData {
private final Long bugs;
private final Long vulnerabilities;
private final Long securityHotspots;
private final Double technicalDebt;
private final Double developmentCost;
private final Long technicalDebt;
private final Long developmentCost;

ProjectStatistics(Builder builder) {
this.projectUuid = builder.projectUuid;
@@ -352,11 +352,11 @@ public class TelemetryData {
return Optional.ofNullable(securityHotspots);
}

public Optional<Double> getTechnicalDebt() {
public Optional<Long> getTechnicalDebt() {
return Optional.ofNullable(technicalDebt);
}

public Optional<Double> getDevelopmentCost() {
public Optional<Long> getDevelopmentCost() {
return Optional.ofNullable(developmentCost);
}

@@ -371,8 +371,8 @@ public class TelemetryData {
private Long bugs;
private Long vulnerabilities;
private Long securityHotspots;
private Double technicalDebt;
private Double developmentCost;
private Long technicalDebt;
private Long developmentCost;

public Builder setProjectUuid(String projectUuid) {
this.projectUuid = projectUuid;
@@ -425,12 +425,12 @@ public class TelemetryData {
}

public Builder setTechnicalDebt(@Nullable Number technicalDebt) {
this.technicalDebt = technicalDebt != null ? technicalDebt.doubleValue() : null;
this.technicalDebt = technicalDebt != null ? technicalDebt.longValue() : null;
return this;
}

public Builder setDevelopmentCost(@Nullable Number developmentCost) {
this.developmentCost = developmentCost != null ? developmentCost.doubleValue() : null;
this.developmentCost = developmentCost != null ? developmentCost.longValue() : null;
return this;
}


+ 7
- 7
server/sonar-server-common/src/test/java/org/sonar/server/telemetry/TelemetryDataJsonWriterTest.java View File

@@ -364,7 +364,7 @@ public class TelemetryDataJsonWriterTest {
}

@Test
public void writes_all_projects_stats_with_analyzed_languages() {
public void writeTelemetryData_whenAnalyzedLanguages_shouldwriteAllProjectsStats() {
TelemetryData data = telemetryBuilder()
.setProjectStatistics(attachProjectStatsWithMetrics())
.build();
@@ -385,8 +385,8 @@ public class TelemetryDataJsonWriterTest {
"bugs": 2,
"vulnerabilities": 3,
"securityHotspots": 4,
"technicalDebt": 60.0,
"developmentCost": 30.0
"technicalDebt": 60,
"developmentCost": 30
},
{
"projectUuid": "uuid-1",
@@ -399,8 +399,8 @@ public class TelemetryDataJsonWriterTest {
"bugs": 4,
"vulnerabilities": 6,
"securityHotspots": 8,
"technicalDebt": 120.0,
"developmentCost": 60.0
"technicalDebt": 120,
"developmentCost": 60
},
{
"projectUuid": "uuid-2",
@@ -413,8 +413,8 @@ public class TelemetryDataJsonWriterTest {
"bugs": 6,
"vulnerabilities": 9,
"securityHotspots": 12,
"technicalDebt": 180.0,
"developmentCost": 90.0
"technicalDebt": 180,
"developmentCost": 90
}
]
}

+ 1
- 1
server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDataLoaderImplTest.java View File

@@ -226,7 +226,7 @@ public class TelemetryDataLoaderImplTest {
TelemetryData.ProjectStatistics::getBugs, TelemetryData.ProjectStatistics::getVulnerabilities, TelemetryData.ProjectStatistics::getSecurityHotspots,
TelemetryData.ProjectStatistics::getDevelopmentCost, TelemetryData.ProjectStatistics::getTechnicalDebt)
.containsExactlyInAnyOrder(
tuple(1L, 0L, qualityGate1.getUuid(), "scm-1", "ci-1", "azure_devops_cloud", Optional.of(1L), Optional.of(1L), Optional.of(1L), Optional.of(50.0), Optional.of(5.0)),
tuple(1L, 0L, qualityGate1.getUuid(), "scm-1", "ci-1", "azure_devops_cloud", Optional.of(1L), Optional.of(1L), Optional.of(1L), Optional.of(50L), Optional.of(5L)),
tuple(1L, 0L, builtInDefaultQualityGate.getUuid(), "scm-2", "ci-2", "github_cloud", Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()));
assertThat(data.getQualityGates())
.extracting(TelemetryData.QualityGate::uuid, TelemetryData.QualityGate::isCaycCompliant)

Loading…
Cancel
Save