diff options
author | Léo Geoffroy <leo.geoffroy@sonarsource.com> | 2024-11-07 17:50:37 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2024-11-08 20:02:47 +0000 |
commit | bb1614bf5cd26b41c7e11fd39d8c6b76641dc6cc (patch) | |
tree | e243e7261ac3f517d26ecd7bb604b601ba9c001d /server/sonar-db-migration | |
parent | bdd5959fa8f2589d305a8f5f22b19ee9d9fbdcc0 (diff) | |
download | sonarqube-bb1614bf5cd26b41c7e11fd39d8c6b76641dc6cc.tar.gz sonarqube-bb1614bf5cd26b41c7e11fd39d8c6b76641dc6cc.zip |
SGB-215 Fix types of metrics for flaky tests in Oracle DB
Diffstat (limited to 'server/sonar-db-migration')
-rw-r--r-- | server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v108/MigrateProjectMeasuresDeprecatedMetricsTest.java | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v108/MigrateProjectMeasuresDeprecatedMetricsTest.java b/server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v108/MigrateProjectMeasuresDeprecatedMetricsTest.java index 6eba63a3096..6c714afc7ca 100644 --- a/server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v108/MigrateProjectMeasuresDeprecatedMetricsTest.java +++ b/server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v108/MigrateProjectMeasuresDeprecatedMetricsTest.java @@ -72,13 +72,14 @@ class MigrateProjectMeasuresDeprecatedMetricsTest { assertThat(db.select("select metric_uuid, value from project_measures where metric_uuid in (%s)" .formatted(replacementMetrics.values().stream().map(s -> "'" + s + "'").collect(Collectors.joining(","))))) - .hasSize(6) - .contains((Map.of("metric_uuid", replacementMetrics.get(SOFTWARE_QUALITY_MAINTAINABILITY_ISSUES_KEY), "value", 1.0))) - .contains((Map.of("metric_uuid", replacementMetrics.get(SOFTWARE_QUALITY_RELIABILITY_ISSUES_KEY), "value", 3.0))) - .contains((Map.of("metric_uuid", replacementMetrics.get(SOFTWARE_QUALITY_SECURITY_ISSUES_KEY), "value", 5.0))) - .contains((Map.of("metric_uuid", replacementMetrics.get(NEW_SOFTWARE_QUALITY_MAINTAINABILITY_ISSUES_KEY), "value", 11.0))) - .contains((Map.of("metric_uuid", replacementMetrics.get(NEW_SOFTWARE_QUALITY_RELIABILITY_ISSUES_KEY), "value", 13.0))) - .contains((Map.of("metric_uuid", replacementMetrics.get(NEW_SOFTWARE_QUALITY_SECURITY_ISSUES_KEY), "value", 15.0))); + .hasSize(6) + .map(m -> Map.of("metric_uuid", m.get("metric_uuid"), "value", ((Number) m.get("value")).longValue())) + .contains((Map.of("metric_uuid", replacementMetrics.get(SOFTWARE_QUALITY_MAINTAINABILITY_ISSUES_KEY), "value", 1L))) + .contains((Map.of("metric_uuid", replacementMetrics.get(SOFTWARE_QUALITY_RELIABILITY_ISSUES_KEY), "value", 3L))) + .contains((Map.of("metric_uuid", replacementMetrics.get(SOFTWARE_QUALITY_SECURITY_ISSUES_KEY), "value", 5L))) + .contains((Map.of("metric_uuid", replacementMetrics.get(NEW_SOFTWARE_QUALITY_MAINTAINABILITY_ISSUES_KEY), "value", 11L))) + .contains((Map.of("metric_uuid", replacementMetrics.get(NEW_SOFTWARE_QUALITY_RELIABILITY_ISSUES_KEY), "value", 13L))) + .contains((Map.of("metric_uuid", replacementMetrics.get(NEW_SOFTWARE_QUALITY_SECURITY_ISSUES_KEY), "value", 15L))); } @Test @@ -104,9 +105,10 @@ class MigrateProjectMeasuresDeprecatedMetricsTest { assertThat(db.select("select metric_uuid, value from project_measures where metric_uuid in (%s)" .formatted(replacementMetrics.values().stream().map(s -> "'" + s + "'").collect(Collectors.joining(","))))) - .hasSize(2) - .contains((Map.of("metric_uuid", replacementMetrics.get(SOFTWARE_QUALITY_MAINTAINABILITY_ISSUES_KEY), "value", 1.0))) - .contains((Map.of("metric_uuid", replacementMetrics.get(SOFTWARE_QUALITY_SECURITY_ISSUES_KEY), "value", 5.0))); + .hasSize(2) + .map(m -> Map.of("metric_uuid", m.get("metric_uuid"), "value", ((Number) m.get("value")).longValue())) + .contains((Map.of("metric_uuid", replacementMetrics.get(SOFTWARE_QUALITY_MAINTAINABILITY_ISSUES_KEY), "value", 1L))) + .contains((Map.of("metric_uuid", replacementMetrics.get(SOFTWARE_QUALITY_SECURITY_ISSUES_KEY), "value", 5L))); } @Test @@ -121,13 +123,12 @@ class MigrateProjectMeasuresDeprecatedMetricsTest { assertThat(db.select("select metric_uuid, value, analysis_uuid from project_measures where metric_uuid in (%s)" .formatted(replacementMetrics.values().stream().map(s -> "'" + s + "'").collect(Collectors.joining(","))))) - .hasSize(3) - .contains((Map.of("metric_uuid", replacementMetrics.get(SOFTWARE_QUALITY_MAINTAINABILITY_ISSUES_KEY), "value", 1.0, "analysis_uuid" - , ANALYSIS_UUID_1))) - .contains((Map.of("metric_uuid", replacementMetrics.get(SOFTWARE_QUALITY_MAINTAINABILITY_ISSUES_KEY), "value", 4.0, "analysis_uuid" - , ANALYSIS_UUID_2))) - .contains((Map.of("metric_uuid", replacementMetrics.get(SOFTWARE_QUALITY_SECURITY_ISSUES_KEY), "value", 5.0, "analysis_uuid", - ANALYSIS_UUID_2))); + .hasSize(3) + .map(m -> Map.of("metric_uuid", m.get("metric_uuid"), "value", ((Number) m.get("value")).longValue(), "analysis_uuid", m.get("analysis_uuid"))) + .contains((Map.of("metric_uuid", replacementMetrics.get(SOFTWARE_QUALITY_MAINTAINABILITY_ISSUES_KEY), "value", 1L, "analysis_uuid", ANALYSIS_UUID_1))) + .contains((Map.of("metric_uuid", replacementMetrics.get(SOFTWARE_QUALITY_MAINTAINABILITY_ISSUES_KEY), "value", 4L, "analysis_uuid", ANALYSIS_UUID_2))) + .contains((Map.of("metric_uuid", replacementMetrics.get(SOFTWARE_QUALITY_SECURITY_ISSUES_KEY), "value", 5L, "analysis_uuid", + ANALYSIS_UUID_2))); } private void createProjectMeasureForDeprecatedMetric(String metricUuid, String analysisUuid, String totalIssues) { |