From da03d2e8386d74283212a3f66ecf13eaa640367f Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Tue, 1 Jul 2014 18:47:44 +0200 Subject: [PATCH] Fix quality flaws --- .../core/sensors/UnitTestDecoratorTest.java | 17 ----------------- .../sonar/batch/index/ResourceKeyMigration.java | 6 +++--- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/UnitTestDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/UnitTestDecoratorTest.java index 86b43609ec6..007fb9c083b 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/UnitTestDecoratorTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/UnitTestDecoratorTest.java @@ -21,7 +21,6 @@ package org.sonar.plugins.core.sensors; import org.hamcrest.Matchers; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.sonar.api.batch.DecoratorContext; import org.sonar.api.measures.CoreMetrics; @@ -34,10 +33,8 @@ import java.util.Arrays; import static org.fest.assertions.Assertions.assertThat; import static org.mockito.Matchers.doubleThat; import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; public class UnitTestDecoratorTest { @@ -88,18 +85,4 @@ public class UnitTestDecoratorTest { private void mockChildrenMeasures(Metric metric, double value) { when(context.getChildrenMeasures(metric)).thenReturn(Arrays.asList(new Measure(metric, value), new Measure(metric, value))); } - - @Test - @Ignore("Hack for SONAR-5212") - public void doNotDecorateIfTestsMeasureAlreadyExists() { - Project project = mock(Project.class); - when(context.getMeasure(CoreMetrics.TESTS)).thenReturn(new Measure()); - - decorator.decorate(project, context); - - assertThat(decorator.shouldDecorateResource(project, context)).isFalse(); - verify(context, atLeastOnce()).getMeasure(CoreMetrics.TESTS); - verifyNoMoreInteractions(context); - } - } diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/ResourceKeyMigration.java b/sonar-batch/src/main/java/org/sonar/batch/index/ResourceKeyMigration.java index 4276fddf6c2..0cb5a0b182d 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/index/ResourceKeyMigration.java +++ b/sonar-batch/src/main/java/org/sonar/batch/index/ResourceKeyMigration.java @@ -116,12 +116,12 @@ public class ResourceKeyMigration implements BatchComponent { Resource sonarFile; String parentOldKey; if ("java".equals(resourceModel.getLanguageKey())) { - parentOldKey = module.getEffectiveKey() + ":" + DeprecatedKeyUtils.getJavaFileParentDeprecatedKey(oldKey); + parentOldKey = String.format("%s:%s", module.getEffectiveKey(), DeprecatedKeyUtils.getJavaFileParentDeprecatedKey(oldKey)); } else { sonarFile = new File(oldKey); - parentOldKey = module.getEffectiveKey() + ":" + sonarFile.getParent().getDeprecatedKey(); + parentOldKey = String.format("%s:%s", module.getEffectiveKey(), sonarFile.getParent().getDeprecatedKey()); } - String parentNewKey = module.getEffectiveKey() + ":" + getParentKey(matchedFile); + String parentNewKey = String.format("%s:%s", module.getEffectiveKey(), getParentKey(matchedFile)); if (!deprecatedDirectoryKeyMapper.containsKey(parentOldKey)) { deprecatedDirectoryKeyMapper.put(parentOldKey, parentNewKey); } else if (!parentNewKey.equals(deprecatedDirectoryKeyMapper.get(parentOldKey))) { -- 2.39.5