diff options
Diffstat (limited to 'plugins')
2 files changed, 8 insertions, 1 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/ViolationTrackingDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/ViolationTrackingDecorator.java index bab5ee4a374..68aaa853f08 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/ViolationTrackingDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/ViolationTrackingDecorator.java @@ -172,9 +172,11 @@ public class ViolationTrackingDecorator implements Decorator { if (pastViolation != null) { newViolation.setCreatedAt(pastViolation.getCreatedAt()); newViolation.setSwitchedOff(pastViolation.isSwitchedOff()); + newViolation.setNew(false); pastViolationsByRule.remove(newViolation.getRule().getId(), pastViolation); violationMap.put(newViolation, pastViolation); } else { + newViolation.setNew(true); newViolation.setCreatedAt(project.getAnalysisDate()); } } diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/ViolationTrackingDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/ViolationTrackingDecoratorTest.java index 848e990ecad..ba798f14b24 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/ViolationTrackingDecoratorTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/ViolationTrackingDecoratorTest.java @@ -81,6 +81,7 @@ public class ViolationTrackingDecoratorTest { Map<Violation, RuleFailureModel> mapping = decorator.mapViolations(Lists.newArrayList(newViolation), Lists.newArrayList(refernceViolation)); assertThat(mapping.get(newViolation), equalTo(refernceViolation)); + assertThat(newViolation.isNew(), is(false)); } @Test @@ -117,6 +118,7 @@ public class ViolationTrackingDecoratorTest { Map<Violation, RuleFailureModel> mapping = decorator.mapViolations(Lists.newArrayList(newViolation), Lists.newArrayList(referenceViolation)); assertThat(mapping.get(newViolation), is(nullValue())); + assertThat(newViolation.isNew(), is(true)); } @Test @@ -128,6 +130,7 @@ public class ViolationTrackingDecoratorTest { Map<Violation, RuleFailureModel> mapping = decorator.mapViolations(Lists.newArrayList(newViolation), Lists.newArrayList(referenceViolation)); assertThat(mapping.get(newViolation), equalTo(referenceViolation)); + assertThat(newViolation.isNew(), is(false)); } @Test @@ -138,10 +141,11 @@ public class ViolationTrackingDecoratorTest { Map<Violation, RuleFailureModel> mapping = decorator.mapViolations(Lists.newArrayList(newViolation), Collections.<RuleFailureModel>emptyList()); assertThat(mapping.size(), is(0)); assertThat(newViolation.getCreatedAt(), is(analysisDate)); + assertThat(newViolation.isNew(), is(true)); } @Test - public void shouldCopyViolationDate() { + public void shouldCopyDateWhenNotNew() { Violation newViolation = newViolation("message", 1, 50, "checksum"); RuleFailureModel referenceViolation = newReferenceViolation("", 1, 50, "checksum"); Date referenceDate = DateUtils.parseDate("2009-05-18"); @@ -151,6 +155,7 @@ public class ViolationTrackingDecoratorTest { Map<Violation, RuleFailureModel> mapping = decorator.mapViolations(Lists.newArrayList(newViolation), Lists.<RuleFailureModel>newArrayList(referenceViolation)); assertThat(mapping.size(), is(1)); assertThat(newViolation.getCreatedAt(), is(referenceDate)); + assertThat(newViolation.isNew(), is(false)); } private Violation newViolation(String message, int lineId, int ruleId) { |