diff options
author | Claire Villard <claire.villard@sonarsource.com> | 2024-09-17 17:53:01 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2024-10-09 20:02:46 +0000 |
commit | c94654fc488cdd8d8f875631f0534d75d36630ab (patch) | |
tree | 64d72cfed073fb7077013b3955bf2f74bdc9c71c /server/sonar-db-dao | |
parent | 79e63e6affafb432602bd559de2782a9a291a822 (diff) | |
download | sonarqube-c94654fc488cdd8d8f875631f0534d75d36630ab.tar.gz sonarqube-c94654fc488cdd8d8f875631f0534d75d36630ab.zip |
SONAR-22925 Import/export of JSON measures
Diffstat (limited to 'server/sonar-db-dao')
-rw-r--r-- | server/sonar-db-dao/src/it/java/org/sonar/db/measure/MeasureDaoIT.java (renamed from server/sonar-db-dao/src/test/java/org/sonar/db/measure/MeasureDaoTest.java) | 6 | ||||
-rw-r--r-- | server/sonar-db-dao/src/main/java/org/sonar/db/measure/MeasureDao.java | 1 | ||||
-rw-r--r-- | server/sonar-db-dao/src/testFixtures/java/org/sonar/db/measure/MeasureTesting.java | 4 |
3 files changed, 7 insertions, 4 deletions
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/measure/MeasureDaoTest.java b/server/sonar-db-dao/src/it/java/org/sonar/db/measure/MeasureDaoIT.java index da55449e229..a80d2e7c4be 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/measure/MeasureDaoTest.java +++ b/server/sonar-db-dao/src/it/java/org/sonar/db/measure/MeasureDaoIT.java @@ -53,7 +53,7 @@ import static org.sonar.db.component.ComponentTesting.newFileDto; import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; import static org.sonar.db.measure.MeasureTesting.newMeasure; -class MeasureDaoTest { +class MeasureDaoIT { @RegisterExtension public final DbTester db = DbTester.create(System2.INSTANCE); @@ -63,7 +63,11 @@ class MeasureDaoTest { @Test void insert_measure() { MeasureDto dto = newMeasure(); + assertThat(dto.getJsonValueHash()).isNull(); + int count = underTest.insert(db.getSession(), dto); + + assertThat(dto.getJsonValueHash()).isNotNull(); assertThat(count).isEqualTo(1); verifyTableSize(1); verifyPersisted(dto); diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/MeasureDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/MeasureDao.java index 326e7e5dc05..7feb6a6795a 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/MeasureDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/MeasureDao.java @@ -43,6 +43,7 @@ public class MeasureDao implements Dao { } public int insert(DbSession dbSession, MeasureDto dto) { + dto.computeJsonValueHash(); return mapper(dbSession).insert(dto, system2.now()); } diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/measure/MeasureTesting.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/measure/MeasureTesting.java index 4982aacdefc..fc98033eddc 100644 --- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/measure/MeasureTesting.java +++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/measure/MeasureTesting.java @@ -104,11 +104,9 @@ public class MeasureTesting { } private static MeasureDto newMeasure(String componentUuid, String branchUuid, String metricKey, Object value) { - MeasureDto measureDto = new MeasureDto() + return new MeasureDto() .setComponentUuid(componentUuid) .setBranchUuid(branchUuid) .addValue(metricKey, value); - measureDto.computeJsonValueHash(); - return measureDto; } } |