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;
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 {
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);
- }
-
}
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))) {