]> source.dussan.org Git - sonarqube.git/commitdiff
Fix quality flaws
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 1 Jul 2014 16:47:44 +0000 (18:47 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 1 Jul 2014 16:48:05 +0000 (18:48 +0200)
plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/UnitTestDecoratorTest.java
sonar-batch/src/main/java/org/sonar/batch/index/ResourceKeyMigration.java

index 86b43609ec678dc86091bf3566786398e53e32c2..007fb9c083b9d8db3dceabf37542d8e1aa2db1e7 100644 (file)
@@ -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);
-  }
-
 }
index 4276fddf6c2c345806da35c3f3eea62acf46e8f6..0cb5a0b182d88a8ad5065c87ee3f31394a9a7252 100644 (file)
@@ -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))) {