diff options
author | David Gageot <david@gageot.net> | 2012-07-11 11:07:32 +0200 |
---|---|---|
committer | David Gageot <david@gageot.net> | 2012-07-11 11:14:58 +0200 |
commit | 8ff07c056e873426723912c9484cdcb9f411d8d1 (patch) | |
tree | 10d46a31c47ca0081081c1a544c132eb40419490 /sonar-batch/src/main/java/org/sonar/batch/index | |
parent | 04d5626ca8bec412d2c92d9bafb499c87339e7eb (diff) | |
download | sonarqube-8ff07c056e873426723912c9484cdcb9f411d8d1.tar.gz sonarqube-8ff07c056e873426723912c9484cdcb9f411d8d1.zip |
SONAR-3437 Improve code coverage and fix measure data update
Diffstat (limited to 'sonar-batch/src/main/java/org/sonar/batch/index')
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java b/sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java index d791be13e93..0c0cf825354 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java +++ b/sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java @@ -115,11 +115,15 @@ public final class MeasurePersister { && measure.getTendency() == null && measure.getUrl() == null && !measure.hasData() - && (measure.getVariation1() == null || NumberUtils.compare(measure.getVariation1().doubleValue(), 0.0) == 0) - && (measure.getVariation2() == null || NumberUtils.compare(measure.getVariation2().doubleValue(), 0.0) == 0) - && (measure.getVariation3() == null || NumberUtils.compare(measure.getVariation3().doubleValue(), 0.0) == 0) - && (measure.getVariation4() == null || NumberUtils.compare(measure.getVariation4().doubleValue(), 0.0) == 0) - && (measure.getVariation5() == null || NumberUtils.compare(measure.getVariation5().doubleValue(), 0.0) == 0); + && isZeroVariation(measure.getVariation1()) + && isZeroVariation(measure.getVariation2()) + && isZeroVariation(measure.getVariation3()) + && isZeroVariation(measure.getVariation4()) + && isZeroVariation(measure.getVariation5()); + } + + private static boolean isZeroVariation(Double variation) { + return (variation == null) || NumberUtils.compare(variation.doubleValue(), 0.0) == 0; } private List<MeasureModel> getMeasuresToSave() { @@ -223,6 +227,10 @@ public final class MeasurePersister { MeasureMapper mapper = session.getMapper(MeasureMapper.class); mapper.update(value); + mapper.deleteData(value); + if (value.getMeasureData() != null) { + mapper.insertData(value); + } session.commit(); } finally { |