From 8e03f8be326f8074f49c8c74bd58347740eafb73 Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Thu, 16 Jan 2014 16:20:45 +0100 Subject: SONAR-926 Merge Java package and directory concepts. Display full path of resources as name. --- .../org/sonar/plugins/core/sensors/DirectoriesDecoratorTest.java | 6 +++--- .../java/org/sonar/plugins/design/batch/DsmSerializerTest.java | 8 ++++---- .../org/sonar/plugins/design/batch/DsmSerializerTest/dsm.json | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'plugins') diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/DirectoriesDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/DirectoriesDecoratorTest.java index a365e3d7d87..e2128dde7ea 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/DirectoriesDecoratorTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/DirectoriesDecoratorTest.java @@ -70,12 +70,12 @@ public class DirectoriesDecoratorTest { } @Test - public void packagesAreIgnored() { + public void packagesAreConsideredAsDirectories() { DirectoriesDecorator decorator = new DirectoriesDecorator(); - Resource pac = new JavaPackage("org.foo"); + Resource pac = new JavaPackage("org/foo"); DecoratorContext context = mock(DecoratorContext.class); decorator.decorate(pac, context); - verify(context, never()).saveMeasure(eq(CoreMetrics.DIRECTORIES), anyDouble()); + verify(context).saveMeasure(eq(CoreMetrics.DIRECTORIES), eq(1.0)); } @Test diff --git a/plugins/sonar-design-plugin/src/test/java/org/sonar/plugins/design/batch/DsmSerializerTest.java b/plugins/sonar-design-plugin/src/test/java/org/sonar/plugins/design/batch/DsmSerializerTest.java index bb5dc533e06..2518f12526b 100644 --- a/plugins/sonar-design-plugin/src/test/java/org/sonar/plugins/design/batch/DsmSerializerTest.java +++ b/plugins/sonar-design-plugin/src/test/java/org/sonar/plugins/design/batch/DsmSerializerTest.java @@ -22,7 +22,7 @@ package org.sonar.plugins.design.batch; import org.apache.commons.io.IOUtils; import org.junit.Test; import org.sonar.api.design.Dependency; -import org.sonar.api.resources.JavaPackage; +import org.sonar.api.resources.Directory; import org.sonar.api.resources.Resource; import org.sonar.graph.DirectedGraph; import org.sonar.graph.Dsm; @@ -43,8 +43,8 @@ public class DsmSerializerTest { @Test public void serialize() throws IOException { - Resource foo = new JavaPackage("org.foo").setId(7); - Resource bar = new JavaPackage("org.bar").setId(8); + Resource foo = Directory.create("src/org/foo", "org/foo").setId(7); + Resource bar = Directory.create("src/org/bar", "org/bar").setId(8); Dependency dep = new Dependency(foo, bar).setId(30l).setWeight(1); DirectedGraph graph = new DirectedGraph(); @@ -54,7 +54,7 @@ public class DsmSerializerTest { Dsm dsm = new Dsm(graph); DsmManualSorter.sort(dsm, bar, foo); // for test reproductibility - String json = IOUtils.toString(getClass().getResourceAsStream("/org/sonar/plugins/design/batch/DsmSerializerTest/dsm.json")); + String json = IOUtils.toString(getClass().getResourceAsStream("/org/sonar/plugins/design/batch/DsmSerializerTest/dsm.json")).trim(); assertThat(DsmSerializer.serialize(dsm), is(json)); } } diff --git a/plugins/sonar-design-plugin/src/test/resources/org/sonar/plugins/design/batch/DsmSerializerTest/dsm.json b/plugins/sonar-design-plugin/src/test/resources/org/sonar/plugins/design/batch/DsmSerializerTest/dsm.json index d0b8861b439..76b06c0f37d 100644 --- a/plugins/sonar-design-plugin/src/test/resources/org/sonar/plugins/design/batch/DsmSerializerTest/dsm.json +++ b/plugins/sonar-design-plugin/src/test/resources/org/sonar/plugins/design/batch/DsmSerializerTest/dsm.json @@ -1 +1 @@ -[{"i":8,"n":"org.bar","q":"PAC","v":[{},{"i":30,"w":1}]},{"i":7,"n":"org.foo","q":"PAC","v":[{},{}]}] \ No newline at end of file +[{"i":8,"n":"/src/org/bar","q":"DIR","v":[{},{"i":30,"w":1}]},{"i":7,"n":"/src/org/foo","q":"DIR","v":[{},{}]}] -- cgit v1.2.3