]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6278 Stop relying on graph to store tests
authorJulien HENRY <julien.henry@sonarsource.com>
Wed, 20 May 2015 08:10:34 +0000 (10:10 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 20 May 2015 22:00:49 +0000 (00:00 +0200)
144 files changed:
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/AbstractNewCoverageFileAnalyzer.java
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewCoverageFileAnalyzer.java
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewItCoverageFileAnalyzer.java
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewOverallCoverageFileAnalyzer.java
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersister.java
plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/NewCoverageFileAnalyzerTest.java
plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersisterTest.java
pom.xml
server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java
sonar-batch/src/main/java/org/sonar/batch/cpd/index/DbDuplicationsIndex.java
sonar-batch/src/main/java/org/sonar/batch/cpd/index/IndexFactory.java
sonar-batch/src/main/java/org/sonar/batch/deprecated/perspectives/BatchPerspectives.java
sonar-batch/src/main/java/org/sonar/batch/deprecated/perspectives/PerspectiveBuilder.java [new file with mode: 0644]
sonar-batch/src/main/java/org/sonar/batch/deprecated/perspectives/PerspectiveNotFoundException.java [new file with mode: 0644]
sonar-batch/src/main/java/org/sonar/batch/index/BatchComponent.java [new file with mode: 0644]
sonar-batch/src/main/java/org/sonar/batch/index/BatchComponentCache.java [new file with mode: 0644]
sonar-batch/src/main/java/org/sonar/batch/index/BatchResource.java [deleted file]
sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java
sonar-batch/src/main/java/org/sonar/batch/index/ResourceCache.java [deleted file]
sonar-batch/src/main/java/org/sonar/batch/index/ResourcePersister.java
sonar-batch/src/main/java/org/sonar/batch/issue/DefaultIssuable.java
sonar-batch/src/main/java/org/sonar/batch/issue/IssuableFactory.java
sonar-batch/src/main/java/org/sonar/batch/issue/tracking/LocalIssueTracking.java
sonar-batch/src/main/java/org/sonar/batch/issue/tracking/ServerIssueRepository.java
sonar-batch/src/main/java/org/sonar/batch/mediumtest/TaskResult.java
sonar-batch/src/main/java/org/sonar/batch/postjob/DefaultPostJobContext.java
sonar-batch/src/main/java/org/sonar/batch/qualitygate/QualityGateVerifier.java
sonar-batch/src/main/java/org/sonar/batch/report/ComponentsPublisher.java
sonar-batch/src/main/java/org/sonar/batch/report/CoveragePublisher.java
sonar-batch/src/main/java/org/sonar/batch/report/DuplicationsPublisher.java
sonar-batch/src/main/java/org/sonar/batch/report/EventCache.java
sonar-batch/src/main/java/org/sonar/batch/report/IssuesPublisher.java
sonar-batch/src/main/java/org/sonar/batch/report/MeasuresPublisher.java
sonar-batch/src/main/java/org/sonar/batch/report/SourcePublisher.java
sonar-batch/src/main/java/org/sonar/batch/report/TestExecutionAndCoveragePublisher.java
sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java
sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ComponentIndexer.java
sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputPathCache.java
sonar-batch/src/main/java/org/sonar/batch/scan/report/IssuesReport.java
sonar-batch/src/main/java/org/sonar/batch/scan/report/IssuesReportBuilder.java
sonar-batch/src/main/java/org/sonar/batch/scan/report/ResourceReport.java
sonar-batch/src/main/java/org/sonar/batch/scan/report/SourceProvider.java
sonar-batch/src/main/java/org/sonar/batch/scm/DefaultBlameOutput.java
sonar-batch/src/main/java/org/sonar/batch/scm/ScmSensor.java
sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorStorage.java
sonar-batch/src/main/java/org/sonar/batch/source/CodeColorizerSensor.java
sonar-batch/src/main/java/org/sonar/batch/source/DefaultHighlightable.java
sonar-batch/src/main/java/org/sonar/batch/source/DefaultSymbolizable.java
sonar-batch/src/main/java/org/sonar/batch/source/HighlightableBuilder.java
sonar-batch/src/main/java/org/sonar/batch/source/SymbolizableBuilder.java
sonar-batch/src/main/java/org/sonar/batch/test/DefaultCoverageBlock.java [new file with mode: 0644]
sonar-batch/src/main/java/org/sonar/batch/test/DefaultTestCase.java [new file with mode: 0644]
sonar-batch/src/main/java/org/sonar/batch/test/DefaultTestPlan.java [new file with mode: 0644]
sonar-batch/src/main/java/org/sonar/batch/test/DefaultTestable.java [new file with mode: 0644]
sonar-batch/src/main/java/org/sonar/batch/test/TestPlanBuilder.java [new file with mode: 0644]
sonar-batch/src/main/java/org/sonar/batch/test/TestableBuilder.java [new file with mode: 0644]
sonar-batch/src/main/java/org/sonar/batch/test/package-info.java [new file with mode: 0644]
sonar-batch/src/test/java/org/sonar/batch/cpd/index/IndexFactoryTest.java
sonar-batch/src/test/java/org/sonar/batch/deprecated/perspectives/PerspectiveBuilderTest.java [new file with mode: 0644]
sonar-batch/src/test/java/org/sonar/batch/index/BatchComponentCacheTest.java [new file with mode: 0644]
sonar-batch/src/test/java/org/sonar/batch/index/DefaultIndexTest.java
sonar-batch/src/test/java/org/sonar/batch/index/ResourceCacheTest.java [deleted file]
sonar-batch/src/test/java/org/sonar/batch/index/ResourcePersisterTest.java
sonar-batch/src/test/java/org/sonar/batch/issue/DefaultIssuableTest.java
sonar-batch/src/test/java/org/sonar/batch/issue/IssuableFactoryTest.java
sonar-batch/src/test/java/org/sonar/batch/postjob/DefaultPostJobContextTest.java
sonar-batch/src/test/java/org/sonar/batch/qualitygate/QualityGateVerifierTest.java
sonar-batch/src/test/java/org/sonar/batch/report/ComponentsPublisherTest.java
sonar-batch/src/test/java/org/sonar/batch/report/CoveragePublisherTest.java
sonar-batch/src/test/java/org/sonar/batch/report/DuplicationsPublisherTest.java
sonar-batch/src/test/java/org/sonar/batch/report/IssuesPublisherTest.java
sonar-batch/src/test/java/org/sonar/batch/report/MeasuresPublisherTest.java
sonar-batch/src/test/java/org/sonar/batch/report/ReportPublisherTest.java
sonar-batch/src/test/java/org/sonar/batch/report/SourcePublisherTest.java
sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ComponentIndexerTest.java
sonar-batch/src/test/java/org/sonar/batch/sensor/DefaultSensorStorageTest.java
sonar-batch/src/test/java/org/sonar/batch/source/HighlightableBuilderTest.java
sonar-batch/src/test/java/org/sonar/batch/source/SymbolizableBuilderTest.java
sonar-core/pom.xml
sonar-core/src/main/java/org/sonar/core/component/ComponentQuery.java [deleted file]
sonar-core/src/main/java/org/sonar/core/component/ComponentVertex.java [deleted file]
sonar-core/src/main/java/org/sonar/core/component/GraphPerspectiveBuilder.java [deleted file]
sonar-core/src/main/java/org/sonar/core/component/GraphPerspectiveLoader.java [deleted file]
sonar-core/src/main/java/org/sonar/core/component/PerspectiveBuilder.java [deleted file]
sonar-core/src/main/java/org/sonar/core/component/PerspectiveNotFoundException.java [deleted file]
sonar-core/src/main/java/org/sonar/core/component/ResourceComponent.java [deleted file]
sonar-core/src/main/java/org/sonar/core/component/ScanGraph.java [deleted file]
sonar-core/src/main/java/org/sonar/core/component/SnapshotGraph.java [deleted file]
sonar-core/src/main/java/org/sonar/core/graph/BeanEdge.java [deleted file]
sonar-core/src/main/java/org/sonar/core/graph/BeanElement.java [deleted file]
sonar-core/src/main/java/org/sonar/core/graph/BeanElements.java [deleted file]
sonar-core/src/main/java/org/sonar/core/graph/BeanGraph.java [deleted file]
sonar-core/src/main/java/org/sonar/core/graph/BeanIterable.java [deleted file]
sonar-core/src/main/java/org/sonar/core/graph/BeanVertex.java [deleted file]
sonar-core/src/main/java/org/sonar/core/graph/EdgePath.java [deleted file]
sonar-core/src/main/java/org/sonar/core/graph/GraphUtil.java [deleted file]
sonar-core/src/main/java/org/sonar/core/graph/MultipleElementsException.java [deleted file]
sonar-core/src/main/java/org/sonar/core/graph/graphson/ElementFactory.java [deleted file]
sonar-core/src/main/java/org/sonar/core/graph/graphson/ElementPropertyConfig.java [deleted file]
sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphsonException.java [deleted file]
sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphsonMode.java [deleted file]
sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphsonReader.java [deleted file]
sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphsonTokens.java [deleted file]
sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphsonUtil.java [deleted file]
sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphsonWriter.java [deleted file]
sonar-core/src/main/java/org/sonar/core/graph/package-info.java [deleted file]
sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java
sonar-core/src/main/java/org/sonar/core/test/DefaultCoverageBlock.java [deleted file]
sonar-core/src/main/java/org/sonar/core/test/DefaultTestCase.java [deleted file]
sonar-core/src/main/java/org/sonar/core/test/DefaultTestPlan.java [deleted file]
sonar-core/src/main/java/org/sonar/core/test/DefaultTestable.java [deleted file]
sonar-core/src/main/java/org/sonar/core/test/TestPlanBuilder.java [deleted file]
sonar-core/src/main/java/org/sonar/core/test/TestPlanPerspectiveLoader.java [deleted file]
sonar-core/src/main/java/org/sonar/core/test/TestableBuilder.java [deleted file]
sonar-core/src/main/java/org/sonar/core/test/TestablePerspectiveLoader.java [deleted file]
sonar-core/src/main/java/org/sonar/core/test/package-info.java [deleted file]
sonar-core/src/test/java/org/sonar/core/component/ComponentVertexTest.java [deleted file]
sonar-core/src/test/java/org/sonar/core/component/GraphPerspectiveBuilderTest.java [deleted file]
sonar-core/src/test/java/org/sonar/core/component/PerspectiveBuilderTest.java [deleted file]
sonar-core/src/test/java/org/sonar/core/component/ResourceComponentTest.java [deleted file]
sonar-core/src/test/java/org/sonar/core/graph/BeanElementTest.java [deleted file]
sonar-core/src/test/java/org/sonar/core/graph/BeanElementsTest.java [deleted file]
sonar-core/src/test/java/org/sonar/core/graph/BeanGraphTest.java [deleted file]
sonar-core/src/test/java/org/sonar/core/graph/EdgePathTest.java [deleted file]
sonar-core/src/test/java/org/sonar/core/graph/GraphUtilTest.java [deleted file]
sonar-core/src/test/java/org/sonar/core/graph/graphson/GraphsonReaderTest.java [deleted file]
sonar-core/src/test/java/org/sonar/core/graph/graphson/GraphsonUtilTest.java [deleted file]
sonar-core/src/test/java/org/sonar/core/graph/graphson/GraphsonWriterTest.java [deleted file]
sonar-core/src/test/java/org/sonar/core/test/DefaultTestCaseTest.java [deleted file]
sonar-core/src/test/java/org/sonar/core/test/DefaultTestPlanTest.java [deleted file]
sonar-core/src/test/java/org/sonar/core/test/DefaultTestableTest.java [deleted file]
sonar-core/src/test/java/org/sonar/core/test/TestPlanBuilderTest.java [deleted file]
sonar-core/src/test/java/org/sonar/core/test/TestableBuilderTest.java [deleted file]
sonar-plugin-api/src/main/java/org/sonar/api/component/Component.java
sonar-plugin-api/src/main/java/org/sonar/api/component/MutablePerspective.java [deleted file]
sonar-plugin-api/src/main/java/org/sonar/api/component/Perspective.java
sonar-plugin-api/src/main/java/org/sonar/api/component/Perspectives.java [deleted file]
sonar-plugin-api/src/main/java/org/sonar/api/component/ResourcePerspectives.java
sonar-plugin-api/src/main/java/org/sonar/api/test/MutableTestCase.java
sonar-plugin-api/src/main/java/org/sonar/api/test/MutableTestPlan.java
sonar-plugin-api/src/main/java/org/sonar/api/test/MutableTestable.java
sonar-plugin-api/src/main/java/org/sonar/api/test/TestCase.java
sonar-plugin-api/src/main/java/org/sonar/api/test/TestPlan.java
sonar-plugin-api/src/main/java/org/sonar/api/test/Testable.java

index e215fc18fe56e0af5cebbb56e7af4f75bde936b7..35d8a3506e49eb53ee60412781b46eb83b34dfcc 100644 (file)
@@ -37,7 +37,7 @@ import org.sonar.api.resources.Scopes;
 import org.sonar.api.utils.KeyValueFormat;
 import org.sonar.batch.components.Period;
 import org.sonar.batch.components.TimeMachineConfiguration;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.batch.protocol.output.BatchReport;
 import org.sonar.batch.protocol.output.BatchReport.Changesets.Changeset;
 import org.sonar.batch.protocol.output.BatchReportReader;
@@ -59,16 +59,16 @@ public abstract class AbstractNewCoverageFileAnalyzer implements Decorator {
 
   private final List<PeriodStruct> structs;
   private final ReportPublisher publishReportJob;
-  private final ResourceCache resourceCache;
+  private final BatchComponentCache resourceCache;
 
-  public AbstractNewCoverageFileAnalyzer(TimeMachineConfiguration timeMachineConfiguration, ReportPublisher publishReportJob, ResourceCache resourceCache) {
+  public AbstractNewCoverageFileAnalyzer(TimeMachineConfiguration timeMachineConfiguration, ReportPublisher publishReportJob, BatchComponentCache resourceCache) {
     this(Lists.<PeriodStruct>newArrayList(), publishReportJob, resourceCache);
     for (Period period : timeMachineConfiguration.periods()) {
       structs.add(new PeriodStruct(period.getIndex(), period.getDate()));
     }
   }
 
-  AbstractNewCoverageFileAnalyzer(List<PeriodStruct> structs, ReportPublisher publishReportJob, ResourceCache resourceCache) {
+  AbstractNewCoverageFileAnalyzer(List<PeriodStruct> structs, ReportPublisher publishReportJob, BatchComponentCache resourceCache) {
     this.resourceCache = resourceCache;
     this.publishReportJob = publishReportJob;
     this.structs = structs;
index d13df7224ef753b1fdf9b09ba943029461e631a8..79f028966cd5b25f828359d342ec25c9845218d8 100644 (file)
@@ -22,18 +22,18 @@ package org.sonar.plugins.core.timemachine;
 import org.sonar.api.measures.CoreMetrics;
 import org.sonar.api.measures.Metric;
 import org.sonar.batch.components.TimeMachineConfiguration;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.batch.report.ReportPublisher;
 
 import java.util.List;
 
 public class NewCoverageFileAnalyzer extends AbstractNewCoverageFileAnalyzer {
 
-  public NewCoverageFileAnalyzer(TimeMachineConfiguration timeMachineConfiguration, ReportPublisher publishReportJob, ResourceCache resourceCache) {
+  public NewCoverageFileAnalyzer(TimeMachineConfiguration timeMachineConfiguration, ReportPublisher publishReportJob, BatchComponentCache resourceCache) {
     super(timeMachineConfiguration, publishReportJob, resourceCache);
   }
 
-  NewCoverageFileAnalyzer(List<PeriodStruct> structs, ReportPublisher publishReportJob, ResourceCache resourceCache) {
+  NewCoverageFileAnalyzer(List<PeriodStruct> structs, ReportPublisher publishReportJob, BatchComponentCache resourceCache) {
     super(structs, publishReportJob, resourceCache);
   }
 
index f069a633b4ed5cd6636423de6b211ac6310ca57d..2aacf34a9bd6c68f6e686675e248b2f66e59acbe 100644 (file)
@@ -22,12 +22,12 @@ package org.sonar.plugins.core.timemachine;
 import org.sonar.api.measures.CoreMetrics;
 import org.sonar.api.measures.Metric;
 import org.sonar.batch.components.TimeMachineConfiguration;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.batch.report.ReportPublisher;
 
 public class NewItCoverageFileAnalyzer extends AbstractNewCoverageFileAnalyzer {
 
-  public NewItCoverageFileAnalyzer(TimeMachineConfiguration timeMachineConfiguration, ReportPublisher publishReportJob, ResourceCache resourceCache) {
+  public NewItCoverageFileAnalyzer(TimeMachineConfiguration timeMachineConfiguration, ReportPublisher publishReportJob, BatchComponentCache resourceCache) {
     super(timeMachineConfiguration, publishReportJob, resourceCache);
   }
 
index fc61e4eafe3a6632ada2e02188537d5d238ce959..f80da9470bbb9d4496ff7a5df00b8df68a49c24a 100644 (file)
@@ -22,12 +22,12 @@ package org.sonar.plugins.core.timemachine;
 import org.sonar.api.measures.CoreMetrics;
 import org.sonar.api.measures.Metric;
 import org.sonar.batch.components.TimeMachineConfiguration;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.batch.report.ReportPublisher;
 
 public class NewOverallCoverageFileAnalyzer extends AbstractNewCoverageFileAnalyzer {
 
-  public NewOverallCoverageFileAnalyzer(TimeMachineConfiguration timeMachineConfiguration, ReportPublisher publishReportJob, ResourceCache resourceCache) {
+  public NewOverallCoverageFileAnalyzer(TimeMachineConfiguration timeMachineConfiguration, ReportPublisher publishReportJob, BatchComponentCache resourceCache) {
     super(timeMachineConfiguration, publishReportJob, resourceCache);
   }
 
index 49473602e35018e9d75e5a6cbb4eefe45fb28bc7..7427654f1bc4226013977ca302c7c56f95c73612 100644 (file)
@@ -27,7 +27,7 @@ import org.sonar.api.resources.Resource;
 import org.sonar.api.resources.ResourceUtils;
 import org.sonar.batch.components.PastSnapshot;
 import org.sonar.batch.components.TimeMachineConfiguration;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponentCache;
 
 import java.util.List;
 
@@ -38,10 +38,10 @@ import static org.sonar.api.utils.DateUtils.dateToLong;
 public final class TimeMachineConfigurationPersister implements Decorator {
 
   private final TimeMachineConfiguration timeMachineConfiguration;
-  private ResourceCache resourceCache;
+  private BatchComponentCache resourceCache;
   private DatabaseSession session;
 
-  public TimeMachineConfigurationPersister(TimeMachineConfiguration timeMachineConfiguration, ResourceCache resourceCache, DatabaseSession session) {
+  public TimeMachineConfigurationPersister(TimeMachineConfiguration timeMachineConfiguration, BatchComponentCache resourceCache, DatabaseSession session) {
     this.timeMachineConfiguration = timeMachineConfiguration;
     this.resourceCache = resourceCache;
     this.session = session;
index 75297f6578f74ac39071d669680d36ae62d2ed3e..adc6f087b44cc6152b8dd1f7c26d8909b7f07462 100644 (file)
@@ -31,7 +31,7 @@ import org.sonar.api.measures.Metric;
 import org.sonar.api.resources.File;
 import org.sonar.api.resources.Resource;
 import org.sonar.api.utils.DateUtils;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.batch.protocol.output.BatchReport;
 import org.sonar.batch.protocol.output.BatchReport.Changesets.Changeset;
 import org.sonar.batch.protocol.output.BatchReportWriter;
@@ -64,7 +64,7 @@ public class NewCoverageFileAnalyzerTest {
     context = mock(DecoratorContext.class);
     Resource f = File.create("src/Foo.java").setEffectiveKey("foo:src/Foo.java");
     when(context.getResource()).thenReturn(f);
-    ResourceCache cache = new ResourceCache();
+    BatchComponentCache cache = new BatchComponentCache();
     cache.add(f, null);
     List<AbstractNewCoverageFileAnalyzer.PeriodStruct> structs = Arrays.asList(
       new AbstractNewCoverageFileAnalyzer.PeriodStruct(1, newDate("2009-12-25")),
index ae79e7a47d377f80da123549943f7e7c958f7835..ca8c36a51cd4dfc004b6ec58c9f08f8eda98cb1d 100644 (file)
@@ -26,7 +26,7 @@ import org.junit.Test;
 import org.sonar.api.database.model.Snapshot;
 import org.sonar.api.resources.Project;
 import org.sonar.api.utils.DateUtils;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.jpa.test.AbstractDbUnitTestCase;
 
 import java.util.Arrays;
@@ -48,7 +48,7 @@ public class TimeMachineConfigurationPersisterTest extends AbstractDbUnitTestCas
     when(timeMachineConfiguration.getProjectPastSnapshots()).thenReturn(Arrays.asList(vs1, vs3));
     Snapshot projectSnapshot = getSession().getSingleResult(Snapshot.class, "id", 1000);
 
-    ResourceCache resourceCache = new ResourceCache();
+    BatchComponentCache resourceCache = new BatchComponentCache();
     Project project = new Project("foo");
     resourceCache.add(project, null).setSnapshot(projectSnapshot);
 
diff --git a/pom.xml b/pom.xml
index 9c79b6fd3698a26c3688785dfbaeb950138de745..298885efd80c741b59efd29687766132be436d1d 100644 (file)
--- a/pom.xml
+++ b/pom.xml
           </exclusion>
         </exclusions>
       </dependency>
-      <dependency>
-        <groupId>com.tinkerpop.blueprints</groupId>
-        <artifactId>blueprints-core</artifactId>
-        <version>2.2.0</version>
-      </dependency>
       <dependency>
         <groupId>commons-collections</groupId>
         <artifactId>commons-collections</artifactId>
index 987e8901d219b49e250be42f38f6d8eb38f0a921..f829d7ea3bad5a28475024040f9e84aada5d7195 100644 (file)
@@ -44,8 +44,6 @@ import org.sonar.core.qualitygate.db.ProjectQgateAssociationDao;
 import org.sonar.core.qualitygate.db.QualityGateConditionDao;
 import org.sonar.core.qualitygate.db.QualityGateDao;
 import org.sonar.core.resource.DefaultResourcePermissions;
-import org.sonar.core.test.TestPlanPerspectiveLoader;
-import org.sonar.core.test.TestablePerspectiveLoader;
 import org.sonar.core.timemachine.Periods;
 import org.sonar.core.user.DefaultUserFinder;
 import org.sonar.core.user.HibernateUserFinder;
@@ -631,10 +629,6 @@ public class PlatformLevel4 extends PlatformLevel {
       // Properties
       PropertiesWs.class,
 
-      // graphs and perspective related classes
-      TestablePerspectiveLoader.class,
-      TestPlanPerspectiveLoader.class,
-
       // Type validation
       TypeValidations.class,
       IntegerTypeValidation.class,
index 4318e0fa8adb0e4710ed92bf5299d40e91d4feec..70fb4d77b2ad3b27dd0708251af323b901c988fe 100644 (file)
@@ -26,7 +26,7 @@ import org.sonar.api.batch.fs.internal.DefaultInputFile;
 import org.sonar.api.database.DatabaseSession;
 import org.sonar.api.database.model.Snapshot;
 import org.sonar.api.resources.Project;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.core.duplication.DuplicationDao;
 import org.sonar.core.duplication.DuplicationUnitDto;
 import org.sonar.duplications.block.Block;
@@ -51,10 +51,10 @@ public class DbDuplicationsIndex {
   private final String languageKey;
   private final DuplicationDao dao;
   private final DatabaseSession session;
-  private final ResourceCache resourceCache;
+  private final BatchComponentCache resourceCache;
 
   public DbDuplicationsIndex(Project currentProject, DuplicationDao dao,
-    String language, DatabaseSession session, ResourceCache resourceCache) {
+    String language, DatabaseSession session, BatchComponentCache resourceCache) {
     this.dao = dao;
     this.session = session;
     this.resourceCache = resourceCache;
index 9f8fe75c46bb348078d71329a1d5ccf6fe462727..6ee5c5edc7d27e1d3bc0916edc4a0b5bee6c4a68 100644 (file)
@@ -29,7 +29,7 @@ import org.sonar.api.config.Settings;
 import org.sonar.api.database.DatabaseSession;
 import org.sonar.api.resources.Project;
 import org.sonar.batch.bootstrap.DefaultAnalysisMode;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.core.duplication.DuplicationDao;
 
 import javax.annotation.Nullable;
@@ -43,9 +43,9 @@ public class IndexFactory {
   private final DuplicationDao dao;
   private final DefaultAnalysisMode mode;
   private final DatabaseSession session;
-  private final ResourceCache resourceCache;
+  private final BatchComponentCache resourceCache;
 
-  public IndexFactory(DefaultAnalysisMode mode, Settings settings, @Nullable DuplicationDao dao, @Nullable DatabaseSession session, ResourceCache resourceCache) {
+  public IndexFactory(DefaultAnalysisMode mode, Settings settings, @Nullable DuplicationDao dao, @Nullable DatabaseSession session, BatchComponentCache resourceCache) {
     this.mode = mode;
     this.settings = settings;
     this.dao = dao;
@@ -56,7 +56,7 @@ public class IndexFactory {
   /**
    * Used by new sensor mode
    */
-  public IndexFactory(DefaultAnalysisMode mode, Settings settings, ResourceCache resourceCache) {
+  public IndexFactory(DefaultAnalysisMode mode, Settings settings, BatchComponentCache resourceCache) {
     this(mode, settings, null, null, resourceCache);
   }
 
index 445508ab0f5216ebc4bcc6de4369364726e1ae6c..47124c44c29ad670093f767aca201d5b96c6308d 100644 (file)
 package org.sonar.batch.deprecated.perspectives;
 
 import com.google.common.collect.Maps;
+import java.util.Map;
+import javax.annotation.CheckForNull;
 import org.sonar.api.batch.SonarIndex;
 import org.sonar.api.batch.fs.InputDir;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.fs.InputPath;
-import org.sonar.api.component.Component;
 import org.sonar.api.component.Perspective;
 import org.sonar.api.component.ResourcePerspectives;
 import org.sonar.api.resources.Directory;
 import org.sonar.api.resources.File;
 import org.sonar.api.resources.Resource;
-import org.sonar.core.component.PerspectiveBuilder;
-import org.sonar.core.component.PerspectiveNotFoundException;
-import org.sonar.core.component.ResourceComponent;
-
-import javax.annotation.CheckForNull;
-
-import java.util.Map;
+import org.sonar.batch.index.BatchComponentCache;
 
 public class BatchPerspectives implements ResourcePerspectives {
 
   private final Map<Class<?>, PerspectiveBuilder<?>> builders = Maps.newHashMap();
   private final SonarIndex resourceIndex;
+  private final BatchComponentCache componentCache;
 
-  public BatchPerspectives(PerspectiveBuilder[] builders, SonarIndex resourceIndex) {
+  public BatchPerspectives(PerspectiveBuilder[] builders, SonarIndex resourceIndex, BatchComponentCache componentCache) {
     this.resourceIndex = resourceIndex;
+    this.componentCache = componentCache;
     for (PerspectiveBuilder builder : builders) {
-      // TODO check duplications
       this.builders.put(builder.getPerspectiveClass(), builder);
     }
   }
 
-  @Override
-  @CheckForNull
-  public <P extends Perspective> P as(Class<P> perspectiveClass, Component component) {
-    if (component.key() == null) {
-      return null;
-    }
-    PerspectiveBuilder<P> builder = builderFor(perspectiveClass);
-    return builder.loadPerspective(perspectiveClass, component);
-  }
-
   @Override
   @CheckForNull
   public <P extends Perspective> P as(Class<P> perspectiveClass, Resource resource) {
@@ -69,7 +55,8 @@ public class BatchPerspectives implements ResourcePerspectives {
       indexedResource = resourceIndex.getResource(resource);
     }
     if (indexedResource != null) {
-      return as(perspectiveClass, new ResourceComponent(indexedResource));
+      PerspectiveBuilder<P> builder = builderFor(perspectiveClass);
+      return builder.loadPerspective(perspectiveClass, componentCache.get(indexedResource));
     }
     return null;
   }
@@ -84,7 +71,8 @@ public class BatchPerspectives implements ResourcePerspectives {
     } else {
       throw new IllegalArgumentException("Unknow input path type: " + inputPath);
     }
-    return as(perspectiveClass, r);
+    PerspectiveBuilder<P> builder = builderFor(perspectiveClass);
+    return builder.loadPerspective(perspectiveClass, componentCache.get(inputPath));
   }
 
   private <T extends Perspective> PerspectiveBuilder<T> builderFor(Class<T> clazz) {
diff --git a/sonar-batch/src/main/java/org/sonar/batch/deprecated/perspectives/PerspectiveBuilder.java b/sonar-batch/src/main/java/org/sonar/batch/deprecated/perspectives/PerspectiveBuilder.java
new file mode 100644 (file)
index 0000000..6a18b67
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.batch.deprecated.perspectives;
+
+import javax.annotation.CheckForNull;
+import org.sonar.api.batch.BatchSide;
+import org.sonar.api.component.Perspective;
+import org.sonar.batch.index.BatchComponent;
+
+@BatchSide
+public abstract class PerspectiveBuilder<T extends Perspective> {
+
+  private final Class<T> perspectiveClass;
+
+  protected PerspectiveBuilder(Class<T> perspectiveClass) {
+    this.perspectiveClass = perspectiveClass;
+  }
+
+  public Class<T> getPerspectiveClass() {
+    return perspectiveClass;
+  }
+
+  @CheckForNull
+  public abstract T loadPerspective(Class<T> perspectiveClass, BatchComponent component);
+}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/deprecated/perspectives/PerspectiveNotFoundException.java b/sonar-batch/src/main/java/org/sonar/batch/deprecated/perspectives/PerspectiveNotFoundException.java
new file mode 100644 (file)
index 0000000..d75067a
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.batch.deprecated.perspectives;
+
+public class PerspectiveNotFoundException extends RuntimeException {
+  public PerspectiveNotFoundException(String message) {
+    super(message);
+  }
+}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/BatchComponent.java b/sonar-batch/src/main/java/org/sonar/batch/index/BatchComponent.java
new file mode 100644 (file)
index 0000000..38655cc
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.batch.index;
+
+import org.apache.commons.lang.StringUtils;
+import org.sonar.api.batch.fs.InputPath;
+import org.sonar.api.database.model.Snapshot;
+import org.sonar.api.resources.Qualifiers;
+import org.sonar.api.resources.Resource;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+public class BatchComponent {
+
+  private final int batchId;
+  private final Resource r;
+  private Snapshot s;
+  private final BatchComponent parent;
+  private final Collection<BatchComponent> children = new ArrayList<>();
+  private InputPath inputPath;
+
+  public BatchComponent(int batchId, Resource r, @Nullable BatchComponent parent) {
+    this.batchId = batchId;
+    this.r = r;
+    this.parent = parent;
+    if (parent != null) {
+      parent.children.add(this);
+    }
+  }
+
+  public String key() {
+    return r.getEffectiveKey();
+  }
+
+  public int batchId() {
+    return batchId;
+  }
+
+  public Resource resource() {
+    return r;
+  }
+
+  public BatchComponent setSnapshot(Snapshot snapshot) {
+    this.s = snapshot;
+    return this;
+  }
+
+  /**
+   * @return null in database less mode
+   */
+  @CheckForNull
+  public Integer snapshotId() {
+    return s != null ? s.getId() : null;
+  }
+
+  public Snapshot snapshot() {
+    return s;
+  }
+
+  @CheckForNull
+  public BatchComponent parent() {
+    return parent;
+  }
+
+  public Collection<BatchComponent> children() {
+    return children;
+  }
+
+  public boolean isFile() {
+    return Qualifiers.isFile(r) || StringUtils.equals(Qualifiers.UNIT_TEST_FILE, r.getQualifier());
+  }
+
+  public boolean isDir() {
+    return Qualifiers.isDirectory(r);
+  }
+
+  public BatchComponent setInputPath(InputPath inputPath) {
+    this.inputPath = inputPath;
+    return this;
+  }
+
+  @CheckForNull
+  public InputPath inputPath() {
+    return inputPath;
+  }
+}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/BatchComponentCache.java b/sonar-batch/src/main/java/org/sonar/batch/index/BatchComponentCache.java
new file mode 100644 (file)
index 0000000..f030027
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.batch.index;
+
+import com.google.common.base.Preconditions;
+import com.google.common.base.Strings;
+import com.google.common.collect.Maps;
+import java.util.Collection;
+import java.util.Map;
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
+import org.sonar.api.batch.BatchSide;
+import org.sonar.api.batch.fs.InputPath;
+import org.sonar.api.batch.fs.internal.DefaultInputDir;
+import org.sonar.api.batch.fs.internal.DefaultInputFile;
+import org.sonar.api.resources.Resource;
+
+@BatchSide
+public class BatchComponentCache {
+  // components by key
+  private final Map<String, BatchComponent> components = Maps.newLinkedHashMap();
+
+  private BatchComponent root;
+
+  @CheckForNull
+  public BatchComponent get(String componentKey) {
+    return components.get(componentKey);
+  }
+
+  public BatchComponent get(Resource resource) {
+    return components.get(resource.getEffectiveKey());
+  }
+
+  public BatchComponent get(InputPath inputPath) {
+    if (inputPath instanceof DefaultInputFile) {
+      return components.get(((DefaultInputFile) inputPath).key());
+    }
+    return components.get(((DefaultInputDir) inputPath).key());
+  }
+
+  public BatchComponent add(Resource resource, @Nullable Resource parentResource) {
+    String componentKey = resource.getEffectiveKey();
+    Preconditions.checkState(!Strings.isNullOrEmpty(componentKey), "Missing resource effective key");
+    BatchComponent parent = parentResource != null ? get(parentResource.getEffectiveKey()) : null;
+    BatchComponent batchResource = new BatchComponent(components.size() + 1, resource, parent);
+    // Libraries can have the same effective key than a project so we can't cache by effectiveKey
+    components.put(componentKey, batchResource);
+    if (parent == null) {
+      root = batchResource;
+    }
+    return batchResource;
+  }
+
+  public Collection<BatchComponent> all() {
+    return components.values();
+  }
+
+  public BatchComponent getRoot() {
+    return root;
+  }
+}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/BatchResource.java b/sonar-batch/src/main/java/org/sonar/batch/index/BatchResource.java
deleted file mode 100644 (file)
index af4eedd..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.batch.index;
-
-import org.apache.commons.lang.StringUtils;
-import org.sonar.api.batch.fs.InputPath;
-import org.sonar.api.database.model.Snapshot;
-import org.sonar.api.resources.Qualifiers;
-import org.sonar.api.resources.Resource;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-public class BatchResource {
-
-  private final int batchId;
-  private final Resource r;
-  private Snapshot s;
-  private final BatchResource parent;
-  private final Collection<BatchResource> children = new ArrayList<>();
-  private InputPath inputPath;
-
-  public BatchResource(int batchId, Resource r, @Nullable BatchResource parent) {
-    this.batchId = batchId;
-    this.r = r;
-    this.parent = parent;
-    if (parent != null) {
-      parent.children.add(this);
-    }
-  }
-
-  public String key() {
-    return r.getEffectiveKey();
-  }
-
-  public int batchId() {
-    return batchId;
-  }
-
-  public Resource resource() {
-    return r;
-  }
-
-  public BatchResource setSnapshot(Snapshot snapshot) {
-    this.s = snapshot;
-    return this;
-  }
-
-  /**
-   * @return null in database less mode
-   */
-  @CheckForNull
-  public Integer snapshotId() {
-    return s != null ? s.getId() : null;
-  }
-
-  public Snapshot snapshot() {
-    return s;
-  }
-
-  @CheckForNull
-  public BatchResource parent() {
-    return parent;
-  }
-
-  public Collection<BatchResource> children() {
-    return children;
-  }
-
-  public boolean isFile() {
-    return Qualifiers.isFile(r) || StringUtils.equals(Qualifiers.UNIT_TEST_FILE, r.getQualifier());
-  }
-
-  public boolean isDir() {
-    return Qualifiers.isDirectory(r);
-  }
-
-  public BatchResource setInputPath(InputPath inputPath) {
-    this.inputPath = inputPath;
-    return this;
-  }
-
-  @CheckForNull
-  public InputPath inputPath() {
-    return inputPath;
-  }
-}
index bed28c439a533d96efda7715c2802e27b308ccdb..63dac585a2cc17b2b4c678c45e8f537c5d07cd47 100644 (file)
@@ -91,7 +91,7 @@ public class DefaultIndex extends SonarIndex {
     CoreMetrics.DUPLICATIONS_DATA_KEY
     );
 
-  private final ResourceCache resourceCache;
+  private final BatchComponentCache resourceCache;
   private final MetricFinder metricFinder;
   private final MeasureCache measureCache;
   // caches
@@ -100,7 +100,7 @@ public class DefaultIndex extends SonarIndex {
   private DefaultProjectTree projectTree;
   private ModuleIssues moduleIssues;
 
-  public DefaultIndex(ResourceCache resourceCache, DefaultProjectTree projectTree, MetricFinder metricFinder, MeasureCache measureCache) {
+  public DefaultIndex(BatchComponentCache resourceCache, DefaultProjectTree projectTree, MetricFinder metricFinder, MeasureCache measureCache) {
     this.resourceCache = resourceCache;
     this.projectTree = projectTree;
     this.metricFinder = metricFinder;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/ResourceCache.java b/sonar-batch/src/main/java/org/sonar/batch/index/ResourceCache.java
deleted file mode 100644 (file)
index 156ff96..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.batch.index;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Strings;
-import com.google.common.collect.Maps;
-import org.sonar.api.batch.BatchSide;
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.resources.Resource;
-import org.sonar.api.resources.ResourceUtils;
-import org.sonar.core.component.ScanGraph;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-import java.util.Collection;
-import java.util.Map;
-
-@BatchSide
-public class ResourceCache {
-  // resource by component key
-  private final Map<String, BatchResource> resources = Maps.newLinkedHashMap();
-
-  private BatchResource root;
-  private final ScanGraph scanGraph;
-
-  public ResourceCache(ScanGraph scanGraph) {
-    this.scanGraph = scanGraph;
-  }
-
-  @VisibleForTesting
-  public ResourceCache() {
-    this.scanGraph = null;
-  }
-
-  @CheckForNull
-  public BatchResource get(String componentKey) {
-    return resources.get(componentKey);
-  }
-
-  public BatchResource get(Resource resource) {
-    return resources.get(resource.getEffectiveKey());
-  }
-
-  public BatchResource get(InputFile inputFile) {
-    return resources.get(((DefaultInputFile) inputFile).key());
-  }
-
-  public BatchResource add(Resource resource, @Nullable Resource parentResource) {
-    String componentKey = resource.getEffectiveKey();
-    Preconditions.checkState(!Strings.isNullOrEmpty(componentKey), "Missing resource effective key");
-    BatchResource parent = parentResource != null ? get(parentResource.getEffectiveKey()) : null;
-    BatchResource batchResource = new BatchResource(resources.size() + 1, resource, parent);
-    // Libraries can have the same effective key than a project so we can't cache by effectiveKey
-    resources.put(componentKey, batchResource);
-    if (parent == null) {
-      root = batchResource;
-    }
-    if (scanGraph != null && ResourceUtils.isPersistable(batchResource.resource())) {
-      scanGraph.addComponent(batchResource.resource());
-    }
-    return batchResource;
-  }
-
-  public Collection<BatchResource> all() {
-    return resources.values();
-  }
-
-  public BatchResource getRoot() {
-    return root;
-  }
-}
index cf31dfdcaf54e0e24bfdb8e5170d4cfae07f63c4..504286a67af3e4f481905a87568ade5dc2ab59a3 100644 (file)
@@ -20,6 +20,8 @@
 package org.sonar.batch.index;
 
 import com.google.common.annotations.VisibleForTesting;
+import javax.annotation.Nullable;
+import javax.persistence.NonUniqueResultException;
 import org.apache.commons.lang.ObjectUtils;
 import org.apache.commons.lang.StringUtils;
 import org.sonar.api.database.DatabaseSession;
@@ -34,10 +36,6 @@ import org.sonar.api.resources.Scopes;
 import org.sonar.api.security.ResourcePermissions;
 import org.sonar.api.utils.SonarException;
 import org.sonar.api.utils.internal.Uuids;
-import org.sonar.core.component.ScanGraph;
-
-import javax.annotation.Nullable;
-import javax.persistence.NonUniqueResultException;
 
 import static org.sonar.api.utils.DateUtils.dateToLong;
 
@@ -48,29 +46,27 @@ public class ResourcePersister implements ScanPersister {
 
   private final DatabaseSession session;
   private final ResourcePermissions permissions;
-  private final ResourceCache resourceCache;
-  private final ScanGraph scanGraph;
+  private final BatchComponentCache resourceCache;
 
-  public ResourcePersister(DatabaseSession session, ResourcePermissions permissions, ResourceCache resourceCache, ScanGraph scanGraph) {
+  public ResourcePersister(DatabaseSession session, ResourcePermissions permissions, BatchComponentCache resourceCache) {
     this.session = session;
     this.permissions = permissions;
     this.resourceCache = resourceCache;
-    this.scanGraph = scanGraph;
   }
 
   @Override
   public void persist() {
-    for (BatchResource resource : resourceCache.all()) {
+    for (BatchComponent resource : resourceCache.all()) {
       persist(resource);
     }
   }
 
-  private void persist(BatchResource batchResource) {
+  private void persist(BatchComponent batchResource) {
     if (batchResource.snapshot() != null) {
       // already persisted
       return;
     }
-    BatchResource parentBatchResource = batchResource.parent();
+    BatchComponent parentBatchResource = batchResource.parent();
     Snapshot s;
     if (parentBatchResource != null) {
       persist(parentBatchResource);
@@ -80,12 +76,9 @@ public class ResourcePersister implements ScanPersister {
       s = persistProject((Project) batchResource.resource(), null);
     }
     batchResource.setSnapshot(s);
-    if (ResourceUtils.isPersistable(batchResource.resource())) {
-      scanGraph.completeComponent(batchResource.key(), batchResource.resource().getId(), s.getId());
-    }
   }
 
-  private Project findModule(BatchResource batchResource) {
+  private Project findModule(BatchComponent batchResource) {
     if (batchResource.resource() instanceof Project) {
       return (Project) batchResource.resource();
     } else {
@@ -147,7 +140,7 @@ public class ResourcePersister implements ScanPersister {
    * Everything except project and library
    */
   private Snapshot persistFileOrDirectory(Project project, Resource resource, @Nullable Resource parentReference) {
-    BatchResource moduleResource = resourceCache.get(project);
+    BatchComponent moduleResource = resourceCache.get(project);
     Integer moduleId = moduleResource.resource().getId();
     ResourceModel model = findOrCreateModel(resource, parentReference != null ? parentReference : project);
     model.setRootId(moduleId);
index 578bb2bb49ef97af435c0b7ee2985ae9f47d534f..89561865d63a0281522e69b764eb3b76b9cb1555 100644 (file)
 package org.sonar.batch.issue;
 
 import com.google.common.collect.Lists;
-import org.sonar.api.component.Component;
+import java.util.List;
 import org.sonar.api.issue.Issuable;
 import org.sonar.api.issue.Issue;
 import org.sonar.api.issue.internal.DefaultIssue;
 import org.sonar.api.resources.Project;
+import org.sonar.batch.index.BatchComponent;
 import org.sonar.core.issue.DefaultIssueBuilder;
 
-import java.util.List;
-
 /**
  * @since 3.6
  */
@@ -36,10 +35,10 @@ public class DefaultIssuable implements Issuable {
 
   private final ModuleIssues moduleIssues;
   private final IssueCache cache;
-  private final Component component;
+  private final BatchComponent component;
   private final Project project;
 
-  DefaultIssuable(Component component, Project project, ModuleIssues moduleIssues, IssueCache cache) {
+  DefaultIssuable(BatchComponent component, Project project, ModuleIssues moduleIssues, IssueCache cache) {
     this.component = component;
     this.project = project;
     this.moduleIssues = moduleIssues;
@@ -56,32 +55,26 @@ public class DefaultIssuable implements Issuable {
     return moduleIssues.initAndAddIssue((DefaultIssue) issue);
   }
 
-  @SuppressWarnings("unchecked")
   @Override
   public List<Issue> resolvedIssues() {
     List<Issue> result = Lists.newArrayList();
     for (DefaultIssue issue : cache.byComponent(component.key())) {
-      if (issue.resolution()!=null) {
+      if (issue.resolution() != null) {
         result.add(issue);
       }
     }
     return result;
   }
 
-  @SuppressWarnings("unchecked")
   @Override
   public List<Issue> issues() {
     List<Issue> result = Lists.newArrayList();
     for (DefaultIssue issue : cache.byComponent(component.key())) {
-      if (issue.resolution()==null) {
+      if (issue.resolution() == null) {
         result.add(issue);
       }
     }
     return result;
   }
 
-  @Override
-  public Component component() {
-    return component;
-  }
 }
index 51ec2b9fe7e56518ac0c0bc74e61021afb1340cc..1fda7c27513a9f1af4b7554f0a7bb29c3e18b68c 100644 (file)
  */
 package org.sonar.batch.issue;
 
-import org.sonar.api.component.Component;
 import org.sonar.api.issue.Issuable;
-import org.sonar.api.resources.Scopes;
 import org.sonar.batch.DefaultProjectTree;
-import org.sonar.core.component.PerspectiveBuilder;
-import org.sonar.core.component.ResourceComponent;
-
-import javax.annotation.CheckForNull;
+import org.sonar.batch.deprecated.perspectives.PerspectiveBuilder;
+import org.sonar.batch.index.BatchComponent;
 
 /**
  * Create the perspective {@link Issuable} on components.
@@ -45,13 +41,8 @@ public class IssuableFactory extends PerspectiveBuilder<Issuable> {
     this.projectTree = projectTree;
   }
 
-  @CheckForNull
   @Override
-  public Issuable loadPerspective(Class<Issuable> perspectiveClass, Component component) {
-    boolean supported = true;
-    if (component instanceof ResourceComponent) {
-      supported = Scopes.isHigherThanOrEquals(((ResourceComponent) component).scope(), Scopes.FILE);
-    }
-    return supported ? new DefaultIssuable(component, projectTree.getRootProject(), moduleIssues, cache) : null;
+  public Issuable loadPerspective(Class<Issuable> perspectiveClass, BatchComponent component) {
+    return new DefaultIssuable(component, projectTree.getRootProject(), moduleIssues, cache);
   }
 }
index dfba07392e693cd7b2e7f0b3a73262cea9f46fd7..a946c9f7dea3d08802dc8f0f1cc566bcb9f99e12 100644 (file)
@@ -34,8 +34,8 @@ import org.sonar.api.issue.internal.IssueChangeContext;
 import org.sonar.api.resources.Project;
 import org.sonar.api.resources.ResourceUtils;
 import org.sonar.api.rule.RuleKey;
-import org.sonar.batch.index.BatchResource;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponent;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.batch.issue.IssueCache;
 import org.sonar.batch.protocol.input.ProjectRepositories;
 import org.sonar.batch.scan.filesystem.InputPathCache;
@@ -62,12 +62,12 @@ public class LocalIssueTracking {
   private final IssueChangeContext changeContext;
   private final ActiveRules activeRules;
   private final InputPathCache inputPathCache;
-  private final ResourceCache resourceCache;
+  private final BatchComponentCache resourceCache;
   private final ServerIssueRepository serverIssueRepository;
   private final ProjectRepositories projectRepositories;
   private final AnalysisMode analysisMode;
 
-  public LocalIssueTracking(ResourceCache resourceCache, IssueCache issueCache, IssueTracking tracking,
+  public LocalIssueTracking(BatchComponentCache resourceCache, IssueCache issueCache, IssueTracking tracking,
     ServerLineHashesLoader lastLineHashes, IssueWorkflow workflow, IssueUpdater updater,
     ActiveRules activeRules, InputPathCache inputPathCache, ServerIssueRepository serverIssueRepository,
     ProjectRepositories projectRepositories, AnalysisMode analysisMode) {
@@ -93,12 +93,12 @@ public class LocalIssueTracking {
 
     serverIssueRepository.load();
 
-    for (BatchResource component : resourceCache.all()) {
+    for (BatchComponent component : resourceCache.all()) {
       trackIssues(component);
     }
   }
 
-  public void trackIssues(BatchResource component) {
+  public void trackIssues(BatchComponent component) {
 
     Collection<DefaultIssue> issues = Lists.newArrayList();
     for (Issue issue : issueCache.byComponent(component.resource().getEffectiveKey())) {
@@ -136,7 +136,7 @@ public class LocalIssueTracking {
   }
 
   @CheckForNull
-  private SourceHashHolder loadSourceHashes(BatchResource component) {
+  private SourceHashHolder loadSourceHashes(BatchComponent component) {
     SourceHashHolder sourceHashHolder = null;
     if (component.isFile()) {
       DefaultInputFile file = (DefaultInputFile) inputPathCache.getInputPath(component);
@@ -148,7 +148,7 @@ public class LocalIssueTracking {
     return sourceHashHolder;
   }
 
-  private Collection<ServerIssue> loadServerIssues(BatchResource component) {
+  private Collection<ServerIssue> loadServerIssues(BatchComponent component) {
     Collection<ServerIssue> serverIssues = new ArrayList<>();
     for (org.sonar.batch.protocol.input.BatchInput.ServerIssue previousIssue : serverIssueRepository.byComponent(component)) {
       serverIssues.add(new ServerIssueFromWs(previousIssue));
index 81de6745192afa84cf26fecf7fafbda721476cee..79bedb1c1127c61f2a0fe0c83efd8cfcae26e85d 100644 (file)
@@ -29,10 +29,10 @@ import org.sonar.api.batch.fs.InputFile.Status;
 import org.sonar.api.utils.log.Logger;
 import org.sonar.api.utils.log.Loggers;
 import org.sonar.api.utils.log.Profiler;
-import org.sonar.batch.index.BatchResource;
+import org.sonar.batch.index.BatchComponent;
 import org.sonar.batch.index.Cache;
 import org.sonar.batch.index.Caches;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.batch.protocol.input.BatchInput.ServerIssue;
 import org.sonar.batch.repository.ServerIssuesLoader;
 import org.sonar.batch.scan.filesystem.InputPathCache;
@@ -54,11 +54,11 @@ public class ServerIssueRepository {
   private Cache<ServerIssue> issuesCache;
   private final ServerIssuesLoader previousIssuesLoader;
   private final ProjectReactor reactor;
-  private final ResourceCache resourceCache;
+  private final BatchComponentCache resourceCache;
   private final AnalysisMode analysisMode;
   private final InputPathCache inputPathCache;
 
-  public ServerIssueRepository(Caches caches, ServerIssuesLoader previousIssuesLoader, ProjectReactor reactor, ResourceCache resourceCache,
+  public ServerIssueRepository(Caches caches, ServerIssuesLoader previousIssuesLoader, ProjectReactor reactor, BatchComponentCache resourceCache,
     AnalysisMode analysisMode, InputPathCache inputPathCache) {
     this.caches = caches;
     this.previousIssuesLoader = previousIssuesLoader;
@@ -83,7 +83,7 @@ public class ServerIssueRepository {
           return null;
         }
         String componentKey = ComponentKeys.createEffectiveKey(issue.getModuleKey(), issue.hasPath() ? issue.getPath() : null);
-        BatchResource r = resourceCache.get(componentKey);
+        BatchComponent r = resourceCache.get(componentKey);
         if (r == null) {
           // Deleted resource
           issuesCache.put(0, issue.getKey(), issue);
@@ -96,7 +96,7 @@ public class ServerIssueRepository {
     profiler.stopDebug();
   }
 
-  public Iterable<ServerIssue> byComponent(BatchResource component) {
+  public Iterable<ServerIssue> byComponent(BatchComponent component) {
     if (analysisMode.isIncremental()) {
       if (!component.isFile()) {
         throw new UnsupportedOperationException("Incremental mode should only get issues on files");
index 321d495f929dc8afd58d8ae6c9e612317a64c64d..55502e9ba781d66909bcd78369a87ce37aac8dbe 100644 (file)
@@ -41,7 +41,7 @@ import org.sonar.api.issue.internal.DefaultIssue;
 import org.sonar.api.measures.Measure;
 import org.sonar.batch.duplication.DuplicationCache;
 import org.sonar.batch.index.Cache.Entry;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.batch.issue.IssueCache;
 import org.sonar.batch.protocol.output.BatchReport;
 import org.sonar.batch.protocol.output.BatchReport.Component;
@@ -120,7 +120,7 @@ public class TaskResult implements org.sonar.batch.mediumtest.ScanTaskObserver {
   }
 
   private void storeMeasures(ProjectScanContainer container) {
-    ResourceCache resourceCache = container.getComponentByType(ResourceCache.class);
+    BatchComponentCache resourceCache = container.getComponentByType(BatchComponentCache.class);
     for (Entry<Measure> measureEntry : container.getComponentByType(MeasureCache.class).entries()) {
       String componentKey = measureEntry.key()[0].toString();
       InputPath path = resourceCache.get(componentKey).inputPath();
index 56840eb88b4fb7d9fc83a4b88b3b1af9d071e2b9..6f46c012ce98a738fbc4d23635e2661b25d1d4c5 100644 (file)
@@ -30,8 +30,8 @@ import org.sonar.api.batch.rule.Severity;
 import org.sonar.api.config.Settings;
 import org.sonar.api.issue.internal.DefaultIssue;
 import org.sonar.api.rule.RuleKey;
-import org.sonar.batch.index.BatchResource;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponent;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.batch.issue.IssueCache;
 
 import javax.annotation.Nullable;
@@ -41,9 +41,9 @@ public class DefaultPostJobContext implements PostJobContext {
   private final Settings settings;
   private final AnalysisMode analysisMode;
   private final IssueCache cache;
-  private final ResourceCache resourceCache;
+  private final BatchComponentCache resourceCache;
 
-  public DefaultPostJobContext(Settings settings, AnalysisMode analysisMode, IssueCache cache, ResourceCache resourceCache) {
+  public DefaultPostJobContext(Settings settings, AnalysisMode analysisMode, IssueCache cache, BatchComponentCache resourceCache) {
     this.settings = settings;
     this.analysisMode = analysisMode;
     this.cache = cache;
@@ -105,7 +105,7 @@ public class DefaultPostJobContext implements PostJobContext {
 
     @Override
     public InputPath inputPath() {
-      BatchResource component = resourceCache.get(wrapped.componentKey());
+      BatchComponent component = resourceCache.get(wrapped.componentKey());
       return component != null ? component.inputPath() : null;
     }
 
index 657dbaba3036c271d09e2cb7a251a0a74a43e912..54427072235bbffffb72d03cd652529e48d828de 100644 (file)
@@ -34,7 +34,7 @@ import org.sonar.api.resources.Resource;
 import org.sonar.api.resources.ResourceUtils;
 import org.sonar.api.utils.Duration;
 import org.sonar.api.utils.Durations;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.core.qualitygate.db.QualityGateConditionDto;
 import org.sonar.core.timemachine.Periods;
 
@@ -55,9 +55,9 @@ public class QualityGateVerifier implements Decorator {
   private Periods periods;
   private I18n i18n;
   private Durations durations;
-  private ResourceCache resourceCache;
+  private BatchComponentCache resourceCache;
 
-  public QualityGateVerifier(QualityGate qualityGate, ResourceCache resourceCache, Periods periods, I18n i18n, Durations durations) {
+  public QualityGateVerifier(QualityGate qualityGate, BatchComponentCache resourceCache, Periods periods, I18n i18n, Durations durations) {
     this.qualityGate = qualityGate;
     this.resourceCache = resourceCache;
     this.periods = periods;
index 217458bcdea76bac9a42efd03632e5534026783e..2398ec25434136ce40f81145501e5c6787c23033 100644 (file)
@@ -27,8 +27,8 @@ import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.resources.Language;
 import org.sonar.api.resources.Resource;
 import org.sonar.api.resources.ResourceUtils;
-import org.sonar.batch.index.BatchResource;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponent;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.batch.protocol.Constants;
 import org.sonar.batch.protocol.Constants.ComponentLinkType;
 import org.sonar.batch.protocol.output.*;
@@ -43,11 +43,11 @@ import javax.annotation.CheckForNull;
  */
 public class ComponentsPublisher implements ReportPublisherStep {
 
-  private final ResourceCache resourceCache;
+  private final BatchComponentCache resourceCache;
   private final ProjectReactor reactor;
   private final EventCache eventCache;
 
-  public ComponentsPublisher(ProjectReactor reactor, ResourceCache resourceCache, EventCache eventCache) {
+  public ComponentsPublisher(ProjectReactor reactor, BatchComponentCache resourceCache, EventCache eventCache) {
     this.reactor = reactor;
     this.resourceCache = resourceCache;
     this.eventCache = eventCache;
@@ -55,11 +55,11 @@ public class ComponentsPublisher implements ReportPublisherStep {
 
   @Override
   public void publish(BatchReportWriter writer) {
-    BatchResource rootProject = resourceCache.get(reactor.getRoot().getKeyWithBranch());
+    BatchComponent rootProject = resourceCache.get(reactor.getRoot().getKeyWithBranch());
     recursiveWriteComponent(rootProject, writer);
   }
 
-  private void recursiveWriteComponent(BatchResource batchResource, BatchReportWriter writer) {
+  private void recursiveWriteComponent(BatchComponent batchResource, BatchReportWriter writer) {
     Resource r = batchResource.resource();
     BatchReport.Component.Builder builder = BatchReport.Component.newBuilder();
 
@@ -98,7 +98,7 @@ public class ComponentsPublisher implements ReportPublisherStep {
     if (lang != null) {
       builder.setLanguage(lang);
     }
-    for (BatchResource child : batchResource.children()) {
+    for (BatchComponent child : batchResource.children()) {
       builder.addChildRef(child.batchId());
     }
     writeLinks(r, builder);
@@ -106,12 +106,12 @@ public class ComponentsPublisher implements ReportPublisherStep {
     writeEvents(batchResource, builder);
     writer.writeComponent(builder.build());
 
-    for (BatchResource child : batchResource.children()) {
+    for (BatchComponent child : batchResource.children()) {
       recursiveWriteComponent(child, writer);
     }
   }
 
-  private void writeEvents(BatchResource batchResource, Builder builder) {
+  private void writeEvents(BatchComponent batchResource, Builder builder) {
     if (ResourceUtils.isProject(batchResource.resource())) {
       for (Event event : eventCache.getEvents(batchResource.batchId())) {
         builder.addEvent(event);
index 617e4d1b943ff04e9486011b33dd2fc0221d8991..27a64a9e21fe36f2d340ba04196781f4d20b4360 100644 (file)
@@ -26,8 +26,8 @@ import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.measures.CoreMetrics;
 import org.sonar.api.measures.Measure;
 import org.sonar.api.utils.KeyValueFormat;
-import org.sonar.batch.index.BatchResource;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponent;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.batch.protocol.output.BatchReport.Coverage;
 import org.sonar.batch.protocol.output.BatchReport.Coverage.Builder;
 import org.sonar.batch.protocol.output.BatchReportWriter;
@@ -38,17 +38,17 @@ import java.util.Map;
 
 public class CoveragePublisher implements ReportPublisherStep {
 
-  private final ResourceCache resourceCache;
+  private final BatchComponentCache resourceCache;
   private final MeasureCache measureCache;
 
-  public CoveragePublisher(ResourceCache resourceCache, MeasureCache measureCache) {
+  public CoveragePublisher(BatchComponentCache resourceCache, MeasureCache measureCache) {
     this.resourceCache = resourceCache;
     this.measureCache = measureCache;
   }
 
   @Override
   public void publish(BatchReportWriter writer) {
-    for (final BatchResource resource : resourceCache.all()) {
+    for (final BatchComponent resource : resourceCache.all()) {
       if (!resource.isFile()) {
         continue;
       }
index 9b0dde8791185419f718de65587fcf89b0c96718..b40521f355fd0810ce47790ffca6928b75b322e7 100644 (file)
@@ -24,8 +24,8 @@ import com.google.common.collect.Iterables;
 import org.sonar.api.batch.sensor.duplication.Duplication.Block;
 import org.sonar.api.batch.sensor.duplication.internal.DefaultDuplication;
 import org.sonar.batch.duplication.DuplicationCache;
-import org.sonar.batch.index.BatchResource;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponent;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.batch.protocol.output.*;
 import org.sonar.batch.protocol.output.BatchReport.Duplicate;
 import org.sonar.batch.protocol.output.BatchReport.Duplication;
@@ -33,17 +33,17 @@ import org.sonar.batch.protocol.output.BatchReport.Range;
 
 public class DuplicationsPublisher implements ReportPublisherStep {
 
-  private final ResourceCache resourceCache;
+  private final BatchComponentCache resourceCache;
   private final DuplicationCache duplicationCache;
 
-  public DuplicationsPublisher(ResourceCache resourceCache, DuplicationCache duplicationCache) {
+  public DuplicationsPublisher(BatchComponentCache resourceCache, DuplicationCache duplicationCache) {
     this.resourceCache = resourceCache;
     this.duplicationCache = duplicationCache;
   }
 
   @Override
   public void publish(BatchReportWriter writer) {
-    for (final BatchResource resource : resourceCache.all()) {
+    for (final BatchComponent resource : resourceCache.all()) {
       if (!resource.isFile()) {
         continue;
       }
@@ -77,7 +77,7 @@ public class DuplicationsPublisher implements ReportPublisherStep {
       blockBuilder.clear();
       String componentKey = duplicate.resourceKey();
       if (!currentComponentKey.equals(componentKey)) {
-        BatchResource sameProjectComponent = resourceCache.get(componentKey);
+        BatchComponent sameProjectComponent = resourceCache.get(componentKey);
         if (sameProjectComponent != null) {
           blockBuilder.setOtherFileRef(sameProjectComponent.batchId());
         } else {
index c7fdc589677510c68d632ba8526ad9d6ff321884..7ffc48bfd7d4b5827743f932215d4af1058587d1 100644 (file)
@@ -21,7 +21,7 @@ package org.sonar.batch.report;
 
 import org.sonar.api.batch.BatchSide;
 import org.sonar.api.resources.Resource;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.batch.protocol.Constants.EventCategory;
 import org.sonar.batch.protocol.output.BatchReport.Event;
 
@@ -37,9 +37,9 @@ import java.util.Map;
 public class EventCache {
 
   private final Map<Integer, List<Event>> eventsByComponentBatchId = new HashMap<>();
-  private final ResourceCache resourceCache;
+  private final BatchComponentCache resourceCache;
 
-  public EventCache(ResourceCache resourceCache) {
+  public EventCache(BatchComponentCache resourceCache) {
     this.resourceCache = resourceCache;
   }
 
index f2268cd20a9fc37033c9347cbb1923df4d7187a3..e2c70d590db258ad7a6597b3f0373b4803e38f42 100644 (file)
@@ -26,8 +26,8 @@ import org.sonar.api.issue.internal.DefaultIssue;
 import org.sonar.api.issue.internal.FieldDiffs;
 import org.sonar.api.resources.Project;
 import org.sonar.api.utils.KeyValueFormat;
-import org.sonar.batch.index.BatchResource;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponent;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.batch.issue.IssueCache;
 import org.sonar.batch.protocol.Constants;
 import org.sonar.batch.protocol.output.BatchReport;
@@ -41,11 +41,11 @@ import java.util.Iterator;
 
 public class IssuesPublisher implements ReportPublisherStep {
 
-  private final ResourceCache resourceCache;
+  private final BatchComponentCache resourceCache;
   private final IssueCache issueCache;
   private final ProjectReactor reactor;
 
-  public IssuesPublisher(ProjectReactor reactor, ResourceCache resourceCache, IssueCache issueCache) {
+  public IssuesPublisher(ProjectReactor reactor, BatchComponentCache resourceCache, IssueCache issueCache) {
     this.reactor = reactor;
     this.resourceCache = resourceCache;
     this.issueCache = issueCache;
@@ -54,7 +54,7 @@ public class IssuesPublisher implements ReportPublisherStep {
   @Override
   public void publish(BatchReportWriter writer) {
     Collection<Object> deletedComponentKeys = issueCache.componentKeys();
-    for (BatchResource resource : resourceCache.all()) {
+    for (BatchComponent resource : resourceCache.all()) {
       String componentKey = resource.resource().getEffectiveKey();
       Iterable<DefaultIssue> issues = issueCache.byComponent(componentKey);
       writer.writeComponentIssues(resource.batchId(), Iterables.transform(issues, new Function<DefaultIssue, BatchReport.Issue>() {
@@ -74,7 +74,7 @@ public class IssuesPublisher implements ReportPublisherStep {
   }
 
   private void exportMetadata(BatchReportWriter writer, int count) {
-    BatchResource rootProject = resourceCache.get(reactor.getRoot().getKeyWithBranch());
+    BatchComponent rootProject = resourceCache.get(reactor.getRoot().getKeyWithBranch());
     BatchReport.Metadata.Builder builder = BatchReport.Metadata.newBuilder()
       .setAnalysisDate(((Project) rootProject.resource()).getAnalysisDate().getTime())
       .setProjectKey(((Project) rootProject.resource()).key())
index 8c68e6b787fe3e1c39c198cc9d4605c75e846691..07c53cad1f108997b0fa59616b5da94cdd3e4bc0 100644 (file)
@@ -31,8 +31,8 @@ import org.sonar.api.resources.ResourceUtils;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rules.RulePriority;
 import org.sonar.api.technicaldebt.batch.Characteristic;
-import org.sonar.batch.index.BatchResource;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponent;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.batch.protocol.Constants;
 import org.sonar.batch.protocol.Constants.MeasureValueType;
 import org.sonar.batch.protocol.output.BatchReport;
@@ -45,11 +45,11 @@ import java.io.Serializable;
 
 public class MeasuresPublisher implements ReportPublisherStep {
 
-  private final ResourceCache resourceCache;
+  private final BatchComponentCache resourceCache;
   private final MeasureCache measureCache;
   private final MetricFinder metricFinder;
 
-  public MeasuresPublisher(ResourceCache resourceCache, MeasureCache measureCache, MetricFinder metricFinder) {
+  public MeasuresPublisher(BatchComponentCache resourceCache, MeasureCache measureCache, MetricFinder metricFinder) {
     this.resourceCache = resourceCache;
     this.measureCache = measureCache;
     this.metricFinder = metricFinder;
@@ -57,7 +57,7 @@ public class MeasuresPublisher implements ReportPublisherStep {
 
   @Override
   public void publish(BatchReportWriter writer) {
-    for (final BatchResource resource : resourceCache.all()) {
+    for (final BatchComponent resource : resourceCache.all()) {
       Iterable<Measure> batchMeasures = measureCache.byResource(resource.resource());
       batchMeasures = Iterables.filter(batchMeasures, new Predicate<Measure>() {
         @Override
index bd89b7dfe2fe1a96055e07e7953290961f0981d1..c4395e755e96ff40029692a138bbf05a7b19a78b 100644 (file)
@@ -23,8 +23,8 @@ import org.apache.commons.io.ByteOrderMark;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.io.input.BOMInputStream;
 import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.batch.index.BatchResource;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponent;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.batch.protocol.output.BatchReportWriter;
 
 import java.io.BufferedReader;
@@ -37,15 +37,15 @@ import java.nio.charset.StandardCharsets;
 
 public class SourcePublisher implements ReportPublisherStep {
 
-  private final ResourceCache resourceCache;
+  private final BatchComponentCache resourceCache;
 
-  public SourcePublisher(ResourceCache resourceCache) {
+  public SourcePublisher(BatchComponentCache resourceCache) {
     this.resourceCache = resourceCache;
   }
 
   @Override
   public void publish(BatchReportWriter writer) {
-    for (final BatchResource resource : resourceCache.all()) {
+    for (final BatchComponent resource : resourceCache.all()) {
       if (!resource.isFile()) {
         continue;
       }
index 344ba437ce99c5c45692be2e1cb643afc64be9a5..fd430aebc582b8384f8fa8e843bfa0ec83c94802 100644 (file)
@@ -21,25 +21,24 @@ package org.sonar.batch.report;
 
 import com.google.common.base.Function;
 import com.google.common.collect.Iterables;
+import java.util.HashSet;
+import java.util.Set;
+import javax.annotation.Nonnull;
 import org.sonar.api.batch.fs.InputFile.Type;
 import org.sonar.api.batch.fs.internal.DefaultInputFile;
 import org.sonar.api.test.CoverageBlock;
 import org.sonar.api.test.MutableTestCase;
 import org.sonar.api.test.MutableTestPlan;
 import org.sonar.api.test.TestCase;
-import org.sonar.batch.index.BatchResource;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponent;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.batch.protocol.Constants.TestStatus;
 import org.sonar.batch.protocol.output.BatchReport;
 import org.sonar.batch.protocol.output.BatchReport.CoverageDetail;
 import org.sonar.batch.protocol.output.BatchReport.Test;
 import org.sonar.batch.protocol.output.BatchReportWriter;
-import org.sonar.core.test.TestPlanBuilder;
-
-import javax.annotation.Nonnull;
-
-import java.util.HashSet;
-import java.util.Set;
+import org.sonar.batch.test.DefaultTestable;
+import org.sonar.batch.test.TestPlanBuilder;
 
 public class TestExecutionAndCoveragePublisher implements ReportPublisherStep {
 
@@ -95,7 +94,7 @@ public class TestExecutionAndCoveragePublisher implements ReportPublisherStep {
       builder.setTestName(testName);
       for (CoverageBlock block : testCase.coverageBlocks()) {
         coveredBuilder.clear();
-        coveredBuilder.setFileRef(resourceCache.get(block.testable().component().key()).batchId());
+        coveredBuilder.setFileRef(componentCache.get(((DefaultTestable) block.testable()).inputFile().key()).batchId());
         for (int line : block.lines()) {
           coveredBuilder.addCoveredLine(line);
         }
@@ -105,36 +104,36 @@ public class TestExecutionAndCoveragePublisher implements ReportPublisherStep {
     }
   }
 
-  private final ResourceCache resourceCache;
+  private final BatchComponentCache componentCache;
   private final TestPlanBuilder testPlanBuilder;
 
-  public TestExecutionAndCoveragePublisher(ResourceCache resourceCache, TestPlanBuilder testPlanBuilder) {
-    this.resourceCache = resourceCache;
+  public TestExecutionAndCoveragePublisher(BatchComponentCache resourceCache, TestPlanBuilder testPlanBuilder) {
+    this.componentCache = resourceCache;
     this.testPlanBuilder = testPlanBuilder;
   }
 
   @Override
   public void publish(BatchReportWriter writer) {
-    for (final BatchResource resource : resourceCache.all()) {
-      if (!resource.isFile()) {
+    for (final BatchComponent component : componentCache.all()) {
+      if (!component.isFile()) {
         continue;
       }
 
-      DefaultInputFile inputFile = (DefaultInputFile) resource.inputPath();
+      DefaultInputFile inputFile = (DefaultInputFile) component.inputPath();
       if (inputFile.type() != Type.TEST) {
         continue;
       }
 
-      final MutableTestPlan testPlan = testPlanBuilder.get(MutableTestPlan.class, inputFile.key());
+      final MutableTestPlan testPlan = testPlanBuilder.loadPerspective(MutableTestPlan.class, component);
       if (testPlan == null || Iterables.isEmpty(testPlan.testCases())) {
         continue;
       }
 
       final Set<String> testNamesWithCoverage = new HashSet<>();
 
-      writer.writeTests(resource.batchId(), Iterables.transform(testPlan.testCases(), new TestConverter(testNamesWithCoverage)));
+      writer.writeTests(component.batchId(), Iterables.transform(testPlan.testCases(), new TestConverter(testNamesWithCoverage)));
 
-      writer.writeCoverageDetails(resource.batchId(), Iterables.transform(testNamesWithCoverage, new TestCoverageConverter(testPlan)));
+      writer.writeCoverageDetails(component.batchId(), Iterables.transform(testNamesWithCoverage, new TestCoverageConverter(testPlan)));
     }
   }
 }
index a1c3bbb82025563867b1c5003efb3b41159cd11d..85e2a54f232897dc7157168bd1ceeb1ce0af4c76 100644 (file)
@@ -46,7 +46,7 @@ import org.sonar.batch.duplication.DuplicationCache;
 import org.sonar.batch.events.EventBus;
 import org.sonar.batch.index.Caches;
 import org.sonar.batch.index.DefaultIndex;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.batch.index.ResourcePersister;
 import org.sonar.batch.issue.DefaultProjectIssues;
 import org.sonar.batch.issue.IssueCache;
@@ -75,7 +75,8 @@ import org.sonar.batch.scan.measure.DefaultMetricFinder;
 import org.sonar.batch.scan.measure.DeprecatedMetricFinder;
 import org.sonar.batch.scan.measure.MeasureCache;
 import org.sonar.batch.source.CodeColorizers;
-import org.sonar.core.component.ScanGraph;
+import org.sonar.batch.test.TestPlanBuilder;
+import org.sonar.batch.test.TestableBuilder;
 import org.sonar.core.issue.IssueUpdater;
 import org.sonar.core.issue.workflow.FunctionExecutor;
 import org.sonar.core.issue.workflow.IssueWorkflow;
@@ -83,10 +84,6 @@ import org.sonar.core.permission.PermissionFacade;
 import org.sonar.core.platform.ComponentContainer;
 import org.sonar.core.resource.DefaultResourcePermissions;
 import org.sonar.core.technicaldebt.DefaultTechnicalDebtModel;
-import org.sonar.core.test.TestPlanBuilder;
-import org.sonar.core.test.TestPlanPerspectiveLoader;
-import org.sonar.core.test.TestableBuilder;
-import org.sonar.core.test.TestablePerspectiveLoader;
 import org.sonar.core.user.DefaultUserFinder;
 
 public class ProjectScanContainer extends ComponentContainer {
@@ -154,7 +151,7 @@ public class ProjectScanContainer extends ComponentContainer {
       DefaultIndex.class,
       DefaultFileLinesContextFactory.class,
       Caches.class,
-      ResourceCache.class,
+      BatchComponentCache.class,
 
       // file system
       InputPathCache.class,
@@ -177,11 +174,8 @@ public class ProjectScanContainer extends ComponentContainer {
       DeprecatedMetricFinder.class,
 
       // tests
-      TestPlanPerspectiveLoader.class,
-      TestablePerspectiveLoader.class,
       TestPlanBuilder.class,
       TestableBuilder.class,
-      ScanGraph.create(),
 
       // lang
       Languages.class,
index eb0976b77769434d30d5096a36e9a9809377059a..f9ff2fb651119ce829e7b5e2597f17d5621a24da 100644 (file)
@@ -26,7 +26,7 @@ import org.sonar.api.resources.File;
 import org.sonar.api.resources.Languages;
 import org.sonar.api.resources.Project;
 import org.sonar.api.resources.Resource;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.batch.index.ResourcePersister;
 
 import javax.annotation.Nullable;
@@ -43,9 +43,9 @@ public class ComponentIndexer {
   private final SonarIndex sonarIndex;
   private final Project module;
   private final ResourcePersister resourcePersister;
-  private final ResourceCache resourceCache;
+  private final BatchComponentCache resourceCache;
 
-  public ComponentIndexer(Project module, Languages languages, SonarIndex sonarIndex, ResourceCache resourceCache, @Nullable ResourcePersister resourcePersister) {
+  public ComponentIndexer(Project module, Languages languages, SonarIndex sonarIndex, BatchComponentCache resourceCache, @Nullable ResourcePersister resourcePersister) {
     this.module = module;
     this.languages = languages;
     this.sonarIndex = sonarIndex;
@@ -53,7 +53,7 @@ public class ComponentIndexer {
     this.resourcePersister = resourcePersister;
   }
 
-  public ComponentIndexer(Project module, Languages languages, SonarIndex sonarIndex, ResourceCache resourceCache) {
+  public ComponentIndexer(Project module, Languages languages, SonarIndex sonarIndex, BatchComponentCache resourceCache) {
     this(module, languages, sonarIndex, resourceCache, null);
   }
 
index 2eacbf5aac4994a725cbe3265d16aa2778e2e6cf..cbfd8d0c5df883e7dbfe03b3f10790bfa0f04695 100644 (file)
@@ -25,7 +25,7 @@ import org.sonar.api.batch.BatchSide;
 import org.sonar.api.batch.fs.InputDir;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.fs.InputPath;
-import org.sonar.batch.index.BatchResource;
+import org.sonar.batch.index.BatchComponent;
 
 import javax.annotation.CheckForNull;
 
@@ -131,7 +131,7 @@ public class InputPathCache {
   }
 
   @CheckForNull
-  public InputPath getInputPath(BatchResource component) {
+  public InputPath getInputPath(BatchComponent component) {
     if (component.isFile()) {
       return getFile(component.parent().parent().resource().getEffectiveKey(), component.resource().getPath());
     } else if (component.isDir()) {
index 5604537b15f218bfb0b23ef4378e4b516cea34f9..c087219e1f28c10537ec18ff1722f54b3cb51b01 100644 (file)
@@ -23,7 +23,7 @@ import com.google.common.collect.Maps;
 import org.sonar.api.issue.Issue;
 import org.sonar.api.rules.Rule;
 import org.sonar.api.rules.RulePriority;
-import org.sonar.batch.index.BatchResource;
+import org.sonar.batch.index.BatchComponent;
 
 import java.util.ArrayList;
 import java.util.Date;
@@ -37,7 +37,7 @@ public class IssuesReport {
   private Date date;
   private boolean noFile;
   private final ReportSummary summary = new ReportSummary();
-  private final Map<BatchResource, ResourceReport> resourceReportsByResource = Maps.newLinkedHashMap();
+  private final Map<BatchComponent, ResourceReport> resourceReportsByResource = Maps.newLinkedHashMap();
 
   public IssuesReport() {
   }
@@ -70,7 +70,7 @@ public class IssuesReport {
     this.noFile = noFile;
   }
 
-  public Map<BatchResource, ResourceReport> getResourceReportsByResource() {
+  public Map<BatchComponent, ResourceReport> getResourceReportsByResource() {
     return resourceReportsByResource;
   }
 
@@ -78,23 +78,23 @@ public class IssuesReport {
     return new ArrayList<>(resourceReportsByResource.values());
   }
 
-  public List<BatchResource> getResourcesWithReport() {
+  public List<BatchComponent> getResourcesWithReport() {
     return new ArrayList<>(resourceReportsByResource.keySet());
   }
 
-  public void addIssueOnResource(BatchResource resource, Issue issue, Rule rule, RulePriority severity) {
+  public void addIssueOnResource(BatchComponent resource, Issue issue, Rule rule, RulePriority severity) {
     addResource(resource);
     getSummary().addIssue(issue, rule, severity);
     resourceReportsByResource.get(resource).addIssue(issue, rule, RulePriority.valueOf(issue.severity()));
   }
 
-  public void addResolvedIssueOnResource(BatchResource resource, Issue issue, Rule rule, RulePriority severity) {
+  public void addResolvedIssueOnResource(BatchComponent resource, Issue issue, Rule rule, RulePriority severity) {
     addResource(resource);
     getSummary().addResolvedIssue(issue, rule, severity);
     resourceReportsByResource.get(resource).addResolvedIssue(issue, rule, RulePriority.valueOf(issue.severity()));
   }
 
-  private void addResource(BatchResource resource) {
+  private void addResource(BatchComponent resource) {
     if (!resourceReportsByResource.containsKey(resource)) {
       resourceReportsByResource.put(resource, new ResourceReport(resource));
     }
index 4dfcf17d24920fbc4567dfb5805f5657fa422046..72c48f9bb7a704868df6e52f313cdd95d2994066 100644 (file)
@@ -30,8 +30,8 @@ import org.sonar.api.rules.Rule;
 import org.sonar.api.rules.RuleFinder;
 import org.sonar.api.rules.RulePriority;
 import org.sonar.batch.DefaultProjectTree;
-import org.sonar.batch.index.BatchResource;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponent;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.batch.issue.IssueCache;
 import org.sonar.batch.scan.filesystem.InputPathCache;
 
@@ -44,11 +44,11 @@ public class IssuesReportBuilder {
 
   private final IssueCache issueCache;
   private final RuleFinder ruleFinder;
-  private final ResourceCache resourceCache;
+  private final BatchComponentCache resourceCache;
   private final DefaultProjectTree projectTree;
   private final InputPathCache inputPathCache;
 
-  public IssuesReportBuilder(IssueCache issueCache, RuleFinder ruleFinder, ResourceCache resourceCache, DefaultProjectTree projectTree, InputPathCache inputPathCache) {
+  public IssuesReportBuilder(IssueCache issueCache, RuleFinder ruleFinder, BatchComponentCache resourceCache, DefaultProjectTree projectTree, InputPathCache inputPathCache) {
     this.issueCache = issueCache;
     this.ruleFinder = ruleFinder;
     this.resourceCache = resourceCache;
@@ -72,7 +72,7 @@ public class IssuesReportBuilder {
     for (Issue issue : issues) {
       Rule rule = findRule(issue);
       RulePriority severity = RulePriority.valueOf(issue.severity());
-      BatchResource resource = resourceCache.get(issue.componentKey());
+      BatchComponent resource = resourceCache.get(issue.componentKey());
       if (!validate(issue, rule, resource)) {
         continue;
       }
@@ -84,7 +84,7 @@ public class IssuesReportBuilder {
     }
   }
 
-  private boolean validate(Issue issue, Rule rule, BatchResource resource) {
+  private boolean validate(Issue issue, Rule rule, BatchComponent resource) {
     if (rule == null) {
       LOG.warn("Unknow rule for issue {}", issue);
       return false;
index e48ffc3e40ae23042ed3aac3ac2f8ed65ab2827e..4a4329f908d74229223a1d5c6a85cc0e7d47afa9 100644 (file)
@@ -23,7 +23,7 @@ import com.google.common.collect.Maps;
 import org.sonar.api.issue.Issue;
 import org.sonar.api.rules.Rule;
 import org.sonar.api.rules.RulePriority;
-import org.sonar.batch.index.BatchResource;
+import org.sonar.batch.index.BatchComponent;
 
 import java.util.ArrayList;
 import java.util.Collections;
@@ -32,7 +32,7 @@ import java.util.Map;
 import java.util.concurrent.atomic.AtomicInteger;
 
 public final class ResourceReport {
-  private final BatchResource resource;
+  private final BatchComponent resource;
   private final IssueVariation total = new IssueVariation();
   private final Map<ReportRuleKey, RuleReport> ruleReportByRuleKey = Maps.newHashMap();
 
@@ -42,11 +42,11 @@ public final class ResourceReport {
   private Map<Rule, AtomicInteger> issuesByRule = Maps.newHashMap();
   private Map<RulePriority, AtomicInteger> issuesBySeverity = Maps.newHashMap();
 
-  public ResourceReport(BatchResource resource) {
+  public ResourceReport(BatchComponent resource) {
     this.resource = resource;
   }
 
-  public BatchResource getResourceNode() {
+  public BatchComponent getResourceNode() {
     return resource;
   }
 
index 049f581fa2b63a597d9723a2483d61613f6af9db..9ae89557e953116f742cb8e1f7e292ca91447539 100644 (file)
@@ -26,7 +26,7 @@ import org.slf4j.LoggerFactory;
 import org.sonar.api.batch.BatchSide;
 import org.sonar.api.batch.fs.FileSystem;
 import org.sonar.api.batch.fs.InputFile;
-import org.sonar.batch.index.BatchResource;
+import org.sonar.batch.index.BatchComponent;
 import org.sonar.batch.scan.filesystem.InputPathCache;
 
 import java.io.IOException;
@@ -46,7 +46,7 @@ public class SourceProvider {
     this.fs = fs;
   }
 
-  public List<String> getEscapedSource(BatchResource component) {
+  public List<String> getEscapedSource(BatchComponent component) {
     if (!component.isFile()) {
       // Folder
       return Collections.emptyList();
index 399d2d3779f636fb38f569ae08ff6307394ff5d5..33ec11e25f577e11f3d494466aca36fb80612f81 100644 (file)
@@ -26,8 +26,8 @@ import org.slf4j.LoggerFactory;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.scm.BlameCommand.BlameOutput;
 import org.sonar.api.batch.scm.BlameLine;
-import org.sonar.batch.index.BatchResource;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponent;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.batch.protocol.output.BatchReport;
 import org.sonar.batch.protocol.output.BatchReport.Changesets.Builder;
 import org.sonar.batch.protocol.output.BatchReportWriter;
@@ -48,13 +48,13 @@ class DefaultBlameOutput implements BlameOutput {
   private static final Pattern ACCENT_CODES = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
 
   private final BatchReportWriter writer;
-  private final ResourceCache componentCache;
+  private final BatchComponentCache componentCache;
   private final Set<InputFile> allFilesToBlame = new HashSet<>();
   private ProgressReport progressReport;
   private int count;
   private int total;
 
-  DefaultBlameOutput(BatchReportWriter writer, ResourceCache componentCache, List<InputFile> filesToBlame) {
+  DefaultBlameOutput(BatchReportWriter writer, BatchComponentCache componentCache, List<InputFile> filesToBlame) {
     this.writer = writer;
     this.componentCache = componentCache;
     this.allFilesToBlame.addAll(filesToBlame);
@@ -75,7 +75,7 @@ class DefaultBlameOutput implements BlameOutput {
       return;
     }
 
-    BatchResource batchComponent = componentCache.get(file);
+    BatchComponent batchComponent = componentCache.get(file);
     Builder scmBuilder = BatchReport.Changesets.newBuilder();
     scmBuilder.setComponentRef(batchComponent.batchId());
     Map<String, Integer> changesetsIdByRevision = new HashMap<>();
index 24492bbdc7828a3d54849035fe8cbcddf3a6fb7a..a74ad87c3e1ec23ac6dd66d8f212f5de0a45d213 100644 (file)
@@ -29,7 +29,7 @@ import org.sonar.api.batch.fs.InputFile.Status;
 import org.sonar.api.batch.sensor.Sensor;
 import org.sonar.api.batch.sensor.SensorContext;
 import org.sonar.api.batch.sensor.SensorDescriptor;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.batch.protocol.input.FileData;
 import org.sonar.batch.protocol.input.ProjectRepositories;
 import org.sonar.batch.report.ReportPublisher;
@@ -46,11 +46,11 @@ public final class ScmSensor implements Sensor {
   private final ScmConfiguration configuration;
   private final FileSystem fs;
   private final ProjectRepositories projectReferentials;
-  private final ResourceCache resourceCache;
+  private final BatchComponentCache resourceCache;
   private final ReportPublisher publishReportJob;
 
   public ScmSensor(ProjectDefinition projectDefinition, ScmConfiguration configuration,
-    ProjectRepositories projectReferentials, FileSystem fs, InputPathCache inputPathCache, ResourceCache resourceCache,
+    ProjectRepositories projectReferentials, FileSystem fs, InputPathCache inputPathCache, BatchComponentCache resourceCache,
     ReportPublisher publishReportJob) {
     this.projectDefinition = projectDefinition;
     this.configuration = configuration;
index cf4b285971a94708b9f78633bca72eeffdb322b3..208dc809210d1bdefe2d711039dbbf187b3fb2db 100644 (file)
@@ -52,9 +52,9 @@ import org.sonar.api.rule.RuleKey;
 import org.sonar.api.source.Symbol;
 import org.sonar.api.utils.KeyValueFormat;
 import org.sonar.batch.duplication.DuplicationCache;
-import org.sonar.batch.index.BatchResource;
+import org.sonar.batch.index.BatchComponent;
 import org.sonar.batch.index.DefaultIndex;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.batch.issue.ModuleIssues;
 import org.sonar.batch.protocol.output.BatchReport;
 import org.sonar.batch.protocol.output.BatchReport.Range;
@@ -76,12 +76,12 @@ public class DefaultSensorStorage implements SensorStorage {
   private final DefaultIndex sonarIndex;
   private final CoverageExclusions coverageExclusions;
   private final DuplicationCache duplicationCache;
-  private final ResourceCache resourceCache;
+  private final BatchComponentCache resourceCache;
   private final ReportPublisher reportPublisher;
 
   public DefaultSensorStorage(MetricFinder metricFinder, Project project, ModuleIssues moduleIssues,
     Settings settings, FileSystem fs, ActiveRules activeRules, DuplicationCache duplicationCache, DefaultIndex sonarIndex,
-    CoverageExclusions coverageExclusions, ResourceCache resourceCache, ReportPublisher reportPublisher) {
+    CoverageExclusions coverageExclusions, BatchComponentCache resourceCache, ReportPublisher reportPublisher) {
     this.metricFinder = metricFinder;
     this.project = project;
     this.moduleIssues = moduleIssues;
@@ -178,7 +178,7 @@ public class DefaultSensorStorage implements SensorStorage {
   }
 
   private File getFile(InputFile file) {
-    BatchResource r = resourceCache.get(file);
+    BatchComponent r = resourceCache.get(file);
     if (r == null) {
       throw new IllegalStateException("Provided input file is not indexed");
     }
index 7581b44b14d9c634c0ed42eed50c880704a1f64a..0d19be3cdeac137a0c25383bac21785b8119f2a3 100644 (file)
@@ -25,7 +25,7 @@ import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.sensor.Sensor;
 import org.sonar.api.batch.sensor.SensorContext;
 import org.sonar.api.batch.sensor.SensorDescriptor;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.batch.protocol.output.BatchReportReader;
 import org.sonar.batch.report.ReportPublisher;
 import org.sonar.colorizer.CodeColorizer;
@@ -37,10 +37,10 @@ import org.sonar.colorizer.CodeColorizer;
 public final class CodeColorizerSensor implements Sensor {
 
   private final ReportPublisher reportPublisher;
-  private final ResourceCache resourceCache;
+  private final BatchComponentCache resourceCache;
   private final CodeColorizers codeColorizers;
 
-  public CodeColorizerSensor(ReportPublisher reportPublisher, ResourceCache resourceCache, CodeColorizers codeColorizers) {
+  public CodeColorizerSensor(ReportPublisher reportPublisher, BatchComponentCache resourceCache, CodeColorizers codeColorizers) {
     this.reportPublisher = reportPublisher;
     this.resourceCache = resourceCache;
     this.codeColorizers = codeColorizers;
index 741346dd99bafeee40677961ecf51bf27ed2107b..e03531d243e812dfd50fd52ad4f0eff4dff8e6b1 100644 (file)
@@ -23,9 +23,7 @@ import org.sonar.api.batch.fs.internal.DefaultInputFile;
 import org.sonar.api.batch.sensor.highlighting.TypeOfText;
 import org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting;
 import org.sonar.api.batch.sensor.internal.SensorStorage;
-import org.sonar.api.component.Component;
 import org.sonar.api.source.Highlightable;
-import org.sonar.batch.deprecated.InputFileComponent;
 
 /**
  * @since 3.6
@@ -47,11 +45,6 @@ public class DefaultHighlightable implements Highlightable {
     return new DefaultHighlightingBuilder(defaultHighlighting);
   }
 
-  @Override
-  public Component component() {
-    return new InputFileComponent(inputFile);
-  }
-
   private static class DefaultHighlightingBuilder implements HighlightingBuilder {
 
     private final DefaultHighlighting defaultHighlighting;
index 037913f06cd8b0e0d91ff053cc88bf599d23ff4e..f65cb609c21e51c97b3ab6a71fe6e65f2057af36 100644 (file)
@@ -21,9 +21,7 @@
 package org.sonar.batch.source;
 
 import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.component.Component;
 import org.sonar.api.source.Symbolizable;
-import org.sonar.batch.deprecated.InputFileComponent;
 import org.sonar.batch.sensor.DefaultSensorStorage;
 
 public class DefaultSymbolizable implements Symbolizable {
@@ -36,11 +34,6 @@ public class DefaultSymbolizable implements Symbolizable {
     this.sensorStorage = sensorStorage;
   }
 
-  @Override
-  public Component component() {
-    return new InputFileComponent(inputFile);
-  }
-
   @Override
   public SymbolTableBuilder newSymbolTableBuilder() {
     return new DefaultSymbolTable.Builder(inputFile);
index fa9326a160485b846919b042d689629bfca06a9a..2a1a7d3ac5e6faaa9f4f350cca3c5754bed2be06 100644 (file)
  */
 package org.sonar.batch.source;
 
-import com.google.common.collect.ImmutableSet;
+import javax.annotation.CheckForNull;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.fs.internal.DefaultInputFile;
 import org.sonar.api.batch.sensor.internal.SensorStorage;
-import org.sonar.api.component.Component;
-import org.sonar.api.resources.Qualifiers;
 import org.sonar.api.source.Highlightable;
-import org.sonar.batch.index.BatchResource;
-import org.sonar.batch.index.ResourceCache;
-import org.sonar.core.component.PerspectiveBuilder;
-import org.sonar.core.component.ResourceComponent;
-
-import javax.annotation.CheckForNull;
-
-import java.util.Set;
+import org.sonar.batch.deprecated.perspectives.PerspectiveBuilder;
+import org.sonar.batch.index.BatchComponent;
 
 public class HighlightableBuilder extends PerspectiveBuilder<Highlightable> {
 
-  private static final Set<String> SUPPORTED_QUALIFIERS = ImmutableSet.of(Qualifiers.FILE, Qualifiers.UNIT_TEST_FILE);
-  private final ResourceCache cache;
   private final SensorStorage sensorStorage;
 
-  public HighlightableBuilder(ResourceCache cache, SensorStorage sensorStorage) {
+  public HighlightableBuilder(SensorStorage sensorStorage) {
     super(Highlightable.class);
-    this.cache = cache;
     this.sensorStorage = sensorStorage;
   }
 
   @CheckForNull
   @Override
-  public Highlightable loadPerspective(Class<Highlightable> perspectiveClass, Component component) {
-    boolean supported = SUPPORTED_QUALIFIERS.contains(component.qualifier());
-    if (supported && component instanceof ResourceComponent) {
-      BatchResource batchComponent = cache.get(component.key());
-      if (batchComponent != null) {
-        InputFile path = (InputFile) batchComponent.inputPath();
-        if (path != null) {
-          return new DefaultHighlightable((DefaultInputFile) path, sensorStorage);
-        }
-      }
+  public Highlightable loadPerspective(Class<Highlightable> perspectiveClass, BatchComponent component) {
+    if (component.isFile()) {
+      InputFile path = (InputFile) component.inputPath();
+      return new DefaultHighlightable((DefaultInputFile) path, sensorStorage);
     }
     return null;
   }
index 212c31d87b41dade737bc5b17608671113bd1694..05ab9db0a457a35dc4ee4200d004de42db3dc0de 100644 (file)
 
 package org.sonar.batch.source;
 
-import com.google.common.collect.ImmutableSet;
+import javax.annotation.CheckForNull;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.component.Component;
-import org.sonar.api.resources.Qualifiers;
 import org.sonar.api.source.Symbolizable;
-import org.sonar.batch.index.BatchResource;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.deprecated.perspectives.PerspectiveBuilder;
+import org.sonar.batch.index.BatchComponent;
 import org.sonar.batch.sensor.DefaultSensorStorage;
-import org.sonar.core.component.PerspectiveBuilder;
-import org.sonar.core.component.ResourceComponent;
-
-import javax.annotation.CheckForNull;
-
-import java.util.Set;
 
 public class SymbolizableBuilder extends PerspectiveBuilder<Symbolizable> {
 
-  private static final Set<String> SUPPORTED_QUALIFIERS = ImmutableSet.of(Qualifiers.FILE, Qualifiers.UNIT_TEST_FILE);
-  private final ResourceCache cache;
   private final DefaultSensorStorage sensorStorage;
 
-  public SymbolizableBuilder(ResourceCache cache, DefaultSensorStorage sensorStorage) {
+  public SymbolizableBuilder(DefaultSensorStorage sensorStorage) {
     super(Symbolizable.class);
-    this.cache = cache;
     this.sensorStorage = sensorStorage;
   }
 
   @CheckForNull
   @Override
-  public Symbolizable loadPerspective(Class<Symbolizable> perspectiveClass, Component component) {
-    boolean supported = SUPPORTED_QUALIFIERS.contains(component.qualifier());
-    if (supported && component instanceof ResourceComponent) {
-      BatchResource batchComponent = cache.get(component.key());
-      if (batchComponent != null) {
-        InputFile path = (InputFile) batchComponent.inputPath();
-        if (path != null) {
-          return new DefaultSymbolizable((DefaultInputFile) path, sensorStorage);
-        }
-      }
+  public Symbolizable loadPerspective(Class<Symbolizable> perspectiveClass, BatchComponent component) {
+    if (component.isFile()) {
+      InputFile path = (InputFile) component.inputPath();
+      return new DefaultSymbolizable((DefaultInputFile) path, sensorStorage);
     }
     return null;
   }
diff --git a/sonar-batch/src/main/java/org/sonar/batch/test/DefaultCoverageBlock.java b/sonar-batch/src/main/java/org/sonar/batch/test/DefaultCoverageBlock.java
new file mode 100644 (file)
index 0000000..b655268
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.batch.test;
+
+import java.util.List;
+import org.sonar.api.batch.fs.internal.DefaultInputFile;
+import org.sonar.api.test.CoverageBlock;
+import org.sonar.api.test.TestCase;
+import org.sonar.api.test.Testable;
+
+public class DefaultCoverageBlock implements CoverageBlock {
+
+  private final TestCase testCase;
+  private final DefaultInputFile testable;
+  private final List<Integer> lines;
+
+  public DefaultCoverageBlock(TestCase testCase, DefaultInputFile testable, List<Integer> lines) {
+    this.testCase = testCase;
+    this.testable = testable;
+    this.lines = lines;
+  }
+
+  @Override
+  public TestCase testCase() {
+    return testCase;
+  }
+
+  @Override
+  public Testable testable() {
+    return new DefaultTestable(testable);
+  }
+
+  @Override
+  public List<Integer> lines() {
+    return lines;
+  }
+}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/test/DefaultTestCase.java b/sonar-batch/src/main/java/org/sonar/batch/test/DefaultTestCase.java
new file mode 100644 (file)
index 0000000..6cf1af7
--- /dev/null
@@ -0,0 +1,164 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.batch.test;
+
+import com.google.common.base.Preconditions;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import javax.annotation.Nullable;
+import org.sonar.api.batch.fs.InputFile;
+import org.sonar.api.batch.fs.InputFile.Type;
+import org.sonar.api.batch.fs.internal.DefaultInputFile;
+import org.sonar.api.test.CoverageBlock;
+import org.sonar.api.test.MutableTestCase;
+import org.sonar.api.test.TestPlan;
+import org.sonar.api.test.Testable;
+import org.sonar.api.test.exception.CoverageAlreadyExistsException;
+import org.sonar.api.test.exception.IllegalDurationException;
+
+public class DefaultTestCase implements MutableTestCase {
+
+  private final DefaultTestPlan testPlan;
+  private String type;
+  private Long durationInMs;
+  private Status status;
+  private String name;
+  private String message;
+  private String stackTrace;
+  private Map<DefaultInputFile, CoverageBlock> coverageBlocksByTestedFile = new LinkedHashMap<>();
+
+  public DefaultTestCase(DefaultTestPlan testPlan) {
+    this.testPlan = testPlan;
+  }
+
+  @Override
+  public String type() {
+    return type;
+  }
+
+  @Override
+  public MutableTestCase setType(@Nullable String s) {
+    this.type = s;
+    return this;
+  }
+
+  @Override
+  public Long durationInMs() {
+    return durationInMs;
+  }
+
+  @Override
+  public MutableTestCase setDurationInMs(@Nullable Long l) {
+    if (l != null && l < 0) {
+      throw new IllegalDurationException("Test duration must be positive (got: " + l + ")");
+    }
+    this.durationInMs = l;
+    return this;
+  }
+
+  @Override
+  public Status status() {
+    return status;
+  }
+
+  @Override
+  public MutableTestCase setStatus(@Nullable Status s) {
+    this.status = s;
+    ;
+    return this;
+  }
+
+  @Override
+  public String name() {
+    return name;
+  }
+
+  public MutableTestCase setName(String s) {
+    this.name = s;
+    return this;
+  }
+
+  @Override
+  public String message() {
+    return message;
+  }
+
+  @Override
+  public MutableTestCase setMessage(String s) {
+    this.message = s;
+    return this;
+  }
+
+  @Override
+  public String stackTrace() {
+    return stackTrace;
+  }
+
+  @Override
+  public MutableTestCase setStackTrace(String s) {
+    this.stackTrace = s;
+    return this;
+  }
+
+  @Override
+  public MutableTestCase setCoverageBlock(Testable testable, List<Integer> lines) {
+    DefaultInputFile coveredFile = ((DefaultTestable) testable).inputFile();
+    return setCoverageBlock(coveredFile, lines);
+  }
+
+  @Override
+  public MutableTestCase setCoverageBlock(InputFile mainFile, List<Integer> lines) {
+    Preconditions.checkArgument(mainFile.type() == Type.MAIN, "Test file can only cover a main file");
+    DefaultInputFile coveredFile = (DefaultInputFile) mainFile;
+    if (coverageBlocksByTestedFile.containsKey(coveredFile)) {
+      throw new CoverageAlreadyExistsException("The link between " + name() + " and " + coveredFile.key() + " already exists");
+    }
+    coverageBlocksByTestedFile.put(coveredFile, new DefaultCoverageBlock(this, coveredFile, lines));
+    return this;
+  }
+
+  @Override
+  public TestPlan testPlan() {
+    return testPlan;
+  }
+
+  @Override
+  public boolean doesCover() {
+    return !coverageBlocksByTestedFile.isEmpty();
+  }
+
+  @Override
+  public int countCoveredLines() {
+    throw new UnsupportedOperationException("Not supported since SQ 5.2");
+  }
+
+  @Override
+  public Iterable<CoverageBlock> coverageBlocks() {
+    return coverageBlocksByTestedFile.values();
+  }
+
+  @Override
+  public CoverageBlock coverageBlock(final Testable testable) {
+    DefaultInputFile coveredFile = ((DefaultTestable) testable).inputFile();
+    return coverageBlocksByTestedFile.get(coveredFile);
+  }
+
+}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/test/DefaultTestPlan.java b/sonar-batch/src/main/java/org/sonar/batch/test/DefaultTestPlan.java
new file mode 100644 (file)
index 0000000..79adc92
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.batch.test;
+
+import com.google.common.collect.Lists;
+import java.util.ArrayList;
+import java.util.List;
+import javax.annotation.CheckForNull;
+import org.sonar.api.test.MutableTestCase;
+import org.sonar.api.test.MutableTestPlan;
+
+public class DefaultTestPlan implements MutableTestPlan {
+  private List<MutableTestCase> testCases = new ArrayList<>();
+
+  @Override
+  @CheckForNull
+  public Iterable<MutableTestCase> testCasesByName(String name) {
+    List<MutableTestCase> result = Lists.newArrayList();
+    for (MutableTestCase testCase : testCases()) {
+      if (name.equals(testCase.name())) {
+        result.add(testCase);
+      }
+    }
+    return result;
+  }
+
+  @Override
+  public MutableTestCase addTestCase(String name) {
+    DefaultTestCase testCase = new DefaultTestCase(this);
+    testCase.setName(name);
+    testCases.add(testCase);
+    return testCase;
+  }
+
+  @Override
+  public Iterable<MutableTestCase> testCases() {
+    return testCases;
+  }
+
+}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/test/DefaultTestable.java b/sonar-batch/src/main/java/org/sonar/batch/test/DefaultTestable.java
new file mode 100644 (file)
index 0000000..6bfe739
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.batch.test;
+
+import java.util.List;
+import java.util.Map;
+import java.util.SortedSet;
+import org.sonar.api.batch.fs.internal.DefaultInputFile;
+import org.sonar.api.test.CoverageBlock;
+import org.sonar.api.test.MutableTestable;
+import org.sonar.api.test.TestCase;
+
+public class DefaultTestable implements MutableTestable {
+
+  private final DefaultInputFile inputFile;
+
+  public DefaultTestable(DefaultInputFile inputFile) {
+    this.inputFile = inputFile;
+  }
+
+  public DefaultInputFile inputFile() {
+    return inputFile;
+  }
+
+  @Override
+  public List<TestCase> testCases() {
+    throw unsupported();
+  }
+
+  @Override
+  public TestCase testCaseByName(final String name) {
+    throw unsupported();
+  }
+
+  @Override
+  public int countTestCasesOfLine(Integer line) {
+    throw unsupported();
+  }
+
+  @Override
+  public Map<Integer, Integer> testCasesByLines() {
+    throw unsupported();
+  }
+
+  @Override
+  public List<TestCase> testCasesOfLine(int line) {
+    throw unsupported();
+  }
+
+  @Override
+  public SortedSet<Integer> testedLines() {
+    throw unsupported();
+  }
+
+  @Override
+  public CoverageBlock coverageBlock(final TestCase testCase) {
+    throw unsupported();
+  }
+
+  @Override
+  public Iterable<CoverageBlock> coverageBlocks() {
+    throw unsupported();
+  }
+
+  private UnsupportedOperationException unsupported() {
+    return new UnsupportedOperationException("No more available since SQ 5.2");
+  }
+
+}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/test/TestPlanBuilder.java b/sonar-batch/src/main/java/org/sonar/batch/test/TestPlanBuilder.java
new file mode 100644 (file)
index 0000000..296bc87
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.batch.test;
+
+import java.util.HashMap;
+import java.util.Map;
+import javax.annotation.CheckForNull;
+import org.sonar.api.batch.fs.InputFile;
+import org.sonar.api.batch.fs.InputFile.Type;
+import org.sonar.api.test.MutableTestPlan;
+import org.sonar.batch.deprecated.perspectives.PerspectiveBuilder;
+import org.sonar.batch.index.BatchComponent;
+
+public class TestPlanBuilder extends PerspectiveBuilder<MutableTestPlan> {
+
+  private Map<InputFile, DefaultTestPlan> testPlanByFile = new HashMap<>();
+
+  public TestPlanBuilder() {
+    super(MutableTestPlan.class);
+  }
+
+  @CheckForNull
+  @Override
+  public MutableTestPlan loadPerspective(Class<MutableTestPlan> perspectiveClass, BatchComponent component) {
+    if (component.isFile()) {
+      InputFile inputFile = (InputFile) component.inputPath();
+      if (inputFile.type() == Type.TEST) {
+        if (!testPlanByFile.containsKey(inputFile)) {
+          testPlanByFile.put(inputFile, new DefaultTestPlan());
+        }
+        return testPlanByFile.get(inputFile);
+      }
+    }
+    return null;
+  }
+
+}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/test/TestableBuilder.java b/sonar-batch/src/main/java/org/sonar/batch/test/TestableBuilder.java
new file mode 100644 (file)
index 0000000..e1927ec
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.batch.test;
+
+import javax.annotation.CheckForNull;
+import org.sonar.api.batch.fs.InputFile;
+import org.sonar.api.batch.fs.InputFile.Type;
+import org.sonar.api.batch.fs.internal.DefaultInputFile;
+import org.sonar.api.test.MutableTestable;
+import org.sonar.batch.deprecated.perspectives.PerspectiveBuilder;
+import org.sonar.batch.index.BatchComponent;
+
+public class TestableBuilder extends PerspectiveBuilder<MutableTestable> {
+
+  public TestableBuilder() {
+    super(MutableTestable.class);
+  }
+
+  @CheckForNull
+  @Override
+  public MutableTestable loadPerspective(Class<MutableTestable> perspectiveClass, BatchComponent component) {
+    if (component.isFile()) {
+      InputFile inputFile = (InputFile) component.inputPath();
+      if (inputFile.type() == Type.MAIN) {
+        return new DefaultTestable((DefaultInputFile) inputFile);
+      }
+    }
+    return null;
+  }
+}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/test/package-info.java b/sonar-batch/src/main/java/org/sonar/batch/test/package-info.java
new file mode 100644 (file)
index 0000000..0c5f5e4
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+@ParametersAreNonnullByDefault
+package org.sonar.batch.test;
+
+import javax.annotation.ParametersAreNonnullByDefault;
index f4aef8284d42341c1b1465171e92755cea1810c5..7028bfcceba710042766b485aab028f5185b15ea 100644 (file)
@@ -27,7 +27,7 @@ import org.sonar.api.config.Settings;
 import org.sonar.api.database.DatabaseSession;
 import org.sonar.api.resources.Project;
 import org.sonar.batch.bootstrap.DefaultAnalysisMode;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.core.duplication.DuplicationDao;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -48,7 +48,7 @@ public class IndexFactoryTest {
     project = new Project("foo");
     settings = new Settings();
     analysisMode = mock(DefaultAnalysisMode.class);
-    factory = new IndexFactory(analysisMode, settings, mock(DuplicationDao.class), mock(DatabaseSession.class), new ResourceCache());
+    factory = new IndexFactory(analysisMode, settings, mock(DuplicationDao.class), mock(DatabaseSession.class), new BatchComponentCache());
     logger = mock(Logger.class);
   }
 
diff --git a/sonar-batch/src/test/java/org/sonar/batch/deprecated/perspectives/PerspectiveBuilderTest.java b/sonar-batch/src/test/java/org/sonar/batch/deprecated/perspectives/PerspectiveBuilderTest.java
new file mode 100644 (file)
index 0000000..917a733
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.batch.deprecated.perspectives;
+
+import org.junit.Test;
+import org.sonar.api.component.Perspective;
+import org.sonar.batch.index.BatchComponent;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class PerspectiveBuilderTest {
+  @Test
+  public void testGetPerspectiveClass() throws Exception {
+    PerspectiveBuilder<FakePerspective> builder = new PerspectiveBuilder<FakePerspective>(FakePerspective.class) {
+      @Override
+      public FakePerspective loadPerspective(Class<FakePerspective> perspectiveClass, BatchComponent component) {
+        return null;
+      }
+    };
+
+    assertThat(builder.getPerspectiveClass()).isEqualTo(FakePerspective.class);
+  }
+
+  static interface FakePerspective extends Perspective {
+
+  }
+}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/index/BatchComponentCacheTest.java b/sonar-batch/src/test/java/org/sonar/batch/index/BatchComponentCacheTest.java
new file mode 100644 (file)
index 0000000..4262d00
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.batch.index;
+
+import org.junit.Test;
+import org.sonar.api.resources.File;
+import org.sonar.api.resources.Resource;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.fail;
+
+public class BatchComponentCacheTest {
+  @Test
+  public void should_cache_resource() {
+    BatchComponentCache cache = new BatchComponentCache();
+    String componentKey = "struts:src/org/struts/Action.java";
+    Resource resource = File.create("org/struts/Action.java").setEffectiveKey(componentKey);
+    cache.add(resource, null);
+
+    assertThat(cache.get(componentKey).resource()).isSameAs(resource);
+    assertThat(cache.get("other")).isNull();
+  }
+
+  @Test
+  public void should_fail_if_missing_component_key() {
+    BatchComponentCache cache = new BatchComponentCache();
+    Resource resource = File.create("org/struts/Action.java").setEffectiveKey(null);
+    try {
+      cache.add(resource, null);
+      fail();
+    } catch (IllegalStateException e) {
+      // success
+      assertThat(e).hasMessage("Missing resource effective key");
+    }
+  }
+}
index bab64fa049b04a46b8ea9d41e54b66e6f8ea3fa3..29cdc0e6f24b42889c589e9edb0002c9f3a3debd 100644 (file)
@@ -68,7 +68,7 @@ public class DefaultIndexTest {
     ruleFinder = mock(RuleFinder.class);
 
     DefaultProjectTree projectTree = mock(DefaultProjectTree.class);
-    ResourceCache resourceCache = new ResourceCache();
+    BatchComponentCache resourceCache = new BatchComponentCache();
     index = new DefaultIndex(resourceCache, projectTree, metricFinder, mock(MeasureCache.class));
 
     baseDir = temp.newFolder();
diff --git a/sonar-batch/src/test/java/org/sonar/batch/index/ResourceCacheTest.java b/sonar-batch/src/test/java/org/sonar/batch/index/ResourceCacheTest.java
deleted file mode 100644 (file)
index 461a9a4..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.batch.index;
-
-import org.junit.Test;
-import org.sonar.api.resources.File;
-import org.sonar.api.resources.Resource;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.fail;
-
-public class ResourceCacheTest {
-  @Test
-  public void should_cache_resource() {
-    ResourceCache cache = new ResourceCache();
-    String componentKey = "struts:src/org/struts/Action.java";
-    Resource resource = File.create("org/struts/Action.java").setEffectiveKey(componentKey);
-    cache.add(resource, null);
-
-    assertThat(cache.get(componentKey).resource()).isSameAs(resource);
-    assertThat(cache.get("other")).isNull();
-  }
-
-  @Test
-  public void should_fail_if_missing_component_key() {
-    ResourceCache cache = new ResourceCache();
-    Resource resource = File.create("org/struts/Action.java").setEffectiveKey(null);
-    try {
-      cache.add(resource, null);
-      fail();
-    } catch (IllegalStateException e) {
-      // success
-      assertThat(e).hasMessage("Missing resource effective key");
-    }
-  }
-}
index 4ef7d6173e61182dfd1f414f2f7910f5d617fb83..4c83e9da457ce9c7c46953fa620cccc1818ae10a 100644 (file)
  */
 package org.sonar.batch.index;
 
+import java.io.IOException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import javax.persistence.Query;
 import org.apache.ibatis.session.SqlSession;
 import org.junit.Before;
 import org.junit.Rule;
@@ -38,16 +42,9 @@ import org.sonar.api.security.ResourcePermissions;
 import org.sonar.batch.DefaultProjectTree;
 import org.sonar.batch.scan.measure.MeasureCache;
 import org.sonar.core.component.ComponentDto;
-import org.sonar.core.component.ScanGraph;
 import org.sonar.core.component.db.ComponentMapper;
 import org.sonar.jpa.test.AbstractDbUnitTestCase;
 
-import javax.persistence.Query;
-
-import java.io.IOException;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
@@ -64,7 +61,7 @@ public class ResourcePersisterTest extends AbstractDbUnitTestCase {
   public TemporaryFolder temp = new TemporaryFolder();
 
   private Project singleProject, singleCopyProject, multiModuleProject, moduleA, moduleB, moduleB1, existingProject;
-  private ResourceCache resourceCache;
+  private BatchComponentCache resourceCache;
 
   private ResourcePersister persister;
 
@@ -74,7 +71,7 @@ public class ResourcePersisterTest extends AbstractDbUnitTestCase {
 
   @Before
   public void before() throws ParseException {
-    resourceCache = new ResourceCache();
+    resourceCache = new BatchComponentCache();
 
     SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
     singleProject = newProject("foo", "java");
@@ -106,7 +103,7 @@ public class ResourcePersisterTest extends AbstractDbUnitTestCase {
 
     projectTree = mock(DefaultProjectTree.class);
     permissions = mock(ResourcePermissions.class);
-    persister = new ResourcePersister(getSession(), permissions, resourceCache, mock(ScanGraph.class));
+    persister = new ResourcePersister(getSession(), permissions, resourceCache);
   }
 
   @Test
index 26d1fccd0601dfe58aedb56e8145744fc4dae92d..42843ddd8ecc6c7948afd326e67fa92a0c56e162 100644 (file)
  */
 package org.sonar.batch.issue;
 
+import java.util.Arrays;
+import java.util.List;
 import org.junit.Test;
-import org.sonar.api.component.Component;
 import org.sonar.api.issue.Issue;
 import org.sonar.api.issue.internal.DefaultIssue;
 import org.sonar.api.resources.Project;
-
-import java.util.Arrays;
-import java.util.List;
+import org.sonar.batch.index.BatchComponent;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
@@ -37,7 +36,7 @@ public class DefaultIssuableTest {
   ModuleIssues moduleIssues = mock(ModuleIssues.class);
   IssueCache cache = mock(IssueCache.class);
   Project project = mock(Project.class);
-  Component component = mock(Component.class);
+  BatchComponent component = mock(BatchComponent.class);
 
   @Test
   public void test_unresolved_issues() throws Exception {
index ac390520311ed4e7ae5661bc7ded67baec1c691d..c124a40fc496769db549862784b607a3350c2a01 100644 (file)
@@ -21,12 +21,11 @@ package org.sonar.batch.issue;
 
 import org.junit.Test;
 import org.mockito.Mockito;
-import org.sonar.api.component.Component;
 import org.sonar.api.issue.Issuable;
 import org.sonar.api.resources.File;
 import org.sonar.api.resources.Project;
 import org.sonar.batch.DefaultProjectTree;
-import org.sonar.core.component.ResourceComponent;
+import org.sonar.batch.index.BatchComponent;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
@@ -40,22 +39,20 @@ public class IssuableFactoryTest {
   @Test
   public void file_should_be_issuable() {
     IssuableFactory factory = new IssuableFactory(moduleIssues, cache, projectTree);
-    Component component = new ResourceComponent(File.create("foo/bar.c").setEffectiveKey("foo/bar.c"));
+    BatchComponent component = new BatchComponent(1, File.create("foo/bar.c").setEffectiveKey("foo/bar.c"), null);
     Issuable issuable = factory.loadPerspective(Issuable.class, component);
 
     assertThat(issuable).isNotNull();
-    assertThat(issuable.component()).isSameAs(component);
     assertThat(issuable.issues()).isEmpty();
   }
 
   @Test
   public void project_should_be_issuable() {
     IssuableFactory factory = new IssuableFactory(moduleIssues, cache, projectTree);
-    Component component = new ResourceComponent(new Project("Foo").setEffectiveKey("foo"));
+    BatchComponent component = new BatchComponent(1, new Project("Foo").setEffectiveKey("foo"), null);
     Issuable issuable = factory.loadPerspective(Issuable.class, component);
 
     assertThat(issuable).isNotNull();
-    assertThat(issuable.component()).isSameAs(component);
     assertThat(issuable.issues()).isEmpty();
   }
 }
index 9ca6dd4077111ad4956d2eb191b887759bc2f636..5db240ddeb50bd1bbbb967d8c864d774c5f16482 100644 (file)
@@ -28,7 +28,7 @@ import org.sonar.api.batch.rule.Severity;
 import org.sonar.api.config.Settings;
 import org.sonar.api.issue.internal.DefaultIssue;
 import org.sonar.api.resources.File;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.batch.issue.IssueCache;
 
 import java.util.Arrays;
@@ -40,7 +40,7 @@ import static org.mockito.Mockito.when;
 public class DefaultPostJobContextTest {
 
   private IssueCache issueCache;
-  private ResourceCache resourceCache;
+  private BatchComponentCache resourceCache;
   private AnalysisMode analysisMode;
   private DefaultPostJobContext context;
   private Settings settings;
@@ -48,7 +48,7 @@ public class DefaultPostJobContextTest {
   @Before
   public void prepare() {
     issueCache = mock(IssueCache.class);
-    resourceCache = new ResourceCache();
+    resourceCache = new BatchComponentCache();
     analysisMode = mock(AnalysisMode.class);
     settings = new Settings();
     context = new DefaultPostJobContext(settings, analysisMode, issueCache, resourceCache);
index 759471b4677162fca55bbbcfbf109d1497f91be7..12194f753cab09f67673ec47e87b8c72827e3094 100644 (file)
@@ -39,7 +39,7 @@ import org.sonar.api.resources.Resource;
 import org.sonar.api.test.IsMeasure;
 import org.sonar.api.utils.Duration;
 import org.sonar.api.utils.Durations;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.core.qualitygate.db.QualityGateConditionDto;
 import org.sonar.core.timemachine.Periods;
 
@@ -70,7 +70,7 @@ public class QualityGateVerifierTest {
   Periods periods;
   I18n i18n;
   Durations durations;
-  private ResourceCache resourceCache;
+  private BatchComponentCache resourceCache;
 
   @Before
   public void before() {
@@ -94,7 +94,7 @@ public class QualityGateVerifierTest {
 
     project = new Project("foo");
 
-    resourceCache = new ResourceCache();
+    resourceCache = new BatchComponentCache();
     resourceCache.add(project, null).setSnapshot(snapshot);
 
     verifier = new QualityGateVerifier(qualityGate, resourceCache, periods, i18n, durations);
index 2d2a97e234d9b714e00d90c7bab47367c22e229f..ead29534e983f2eb97cc8106293ff46ab799c7f5 100644 (file)
@@ -32,7 +32,7 @@ import org.sonar.api.resources.Directory;
 import org.sonar.api.resources.Java;
 import org.sonar.api.resources.Project;
 import org.sonar.api.utils.DateUtils;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.batch.protocol.Constants.ComponentLinkType;
 import org.sonar.batch.protocol.Constants.EventCategory;
 import org.sonar.batch.protocol.output.BatchReport.Component;
@@ -54,7 +54,7 @@ public class ComponentsPublisherTest {
   public TemporaryFolder temp = new TemporaryFolder();
 
   private ProjectReactor reactor;
-  private ResourceCache resourceCache;
+  private BatchComponentCache resourceCache;
   private ComponentsPublisher publisher;
   private EventCache eventCache;
 
@@ -62,7 +62,7 @@ public class ComponentsPublisherTest {
   public void prepare() {
     reactor = new ProjectReactor(ProjectDefinition.create().setKey("foo"));
     reactor.getRoot().properties().put(CoreProperties.PROJECT_VERSION_PROPERTY, "1.0");
-    resourceCache = new ResourceCache();
+    resourceCache = new BatchComponentCache();
     eventCache = mock(EventCache.class);
     publisher = new ComponentsPublisher(reactor, resourceCache, eventCache);
   }
index f799843baba08673bc4c974b831bc937e3788328..b8e4b7acfb3c1cb084ea36b2ac7b8fdf35fdf640 100644 (file)
@@ -29,7 +29,7 @@ import org.sonar.api.database.model.Snapshot;
 import org.sonar.api.measures.CoreMetrics;
 import org.sonar.api.measures.Measure;
 import org.sonar.api.resources.Project;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.batch.protocol.output.BatchReport;
 import org.sonar.batch.protocol.output.BatchReport.Coverage;
 import org.sonar.batch.protocol.output.BatchReportReader;
@@ -60,7 +60,7 @@ public class CoveragePublisherTest {
   @Before
   public void prepare() {
     Project p = new Project("foo").setAnalysisDate(new Date(1234567L));
-    ResourceCache resourceCache = new ResourceCache();
+    BatchComponentCache resourceCache = new BatchComponentCache();
     sampleFile = org.sonar.api.resources.File.create("src/Foo.php").setEffectiveKey("foo:src/Foo.php");
     resourceCache.add(p, null).setSnapshot(new Snapshot().setId(2));
     resourceCache.add(sampleFile, null).setInputPath(new DefaultInputFile("foo", "src/Foo.php").setLines(5));
index a3536f2ada17642e82573ee5a91b11817e6fe71d..4c64bd4b2c9806d3fd8cb2fec59e4c3d14639c63 100644 (file)
@@ -27,7 +27,7 @@ import org.sonar.api.batch.sensor.duplication.Duplication;
 import org.sonar.api.batch.sensor.duplication.internal.DefaultDuplication;
 import org.sonar.api.resources.Project;
 import org.sonar.batch.duplication.DuplicationCache;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.batch.protocol.output.BatchReportReader;
 import org.sonar.batch.protocol.output.BatchReportWriter;
 
@@ -51,7 +51,7 @@ public class DuplicationsPublisherTest {
 
   @Before
   public void prepare() {
-    ResourceCache resourceCache = new ResourceCache();
+    BatchComponentCache resourceCache = new BatchComponentCache();
     Project p = new Project("foo");
     resourceCache.add(p, null);
     org.sonar.api.resources.Resource sampleFile = org.sonar.api.resources.File.create("src/Foo.php").setEffectiveKey("foo:src/Foo.php");
index ecfd2377b170aaf737648664ad5002b8eaed4416..f4299ae0df695ec3fc7390cc1a2c0dc06307b62f 100644 (file)
@@ -31,7 +31,7 @@ import org.sonar.api.issue.internal.FieldDiffs;
 import org.sonar.api.resources.Project;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.utils.Duration;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.batch.issue.IssueCache;
 import org.sonar.batch.protocol.output.BatchReport.Metadata;
 import org.sonar.batch.protocol.output.BatchReportReader;
@@ -59,7 +59,7 @@ public class IssuesPublisherTest {
   public void prepare() {
     ProjectDefinition root = ProjectDefinition.create().setKey("foo");
     Project p = new Project("foo").setAnalysisDate(new Date(1234567L));
-    ResourceCache resourceCache = new ResourceCache();
+    BatchComponentCache resourceCache = new BatchComponentCache();
     org.sonar.api.resources.Resource sampleFile = org.sonar.api.resources.File.create("src/Foo.php").setEffectiveKey("foo:src/Foo.php");
     resourceCache.add(p, null).setSnapshot(new Snapshot().setId(2));
     resourceCache.add(sampleFile, null);
index bc22f032a19a7996ea25208fa841bd590210ee43..658cafcc62db6669eb51fb5e67d8a93a3eeb53b8 100644 (file)
@@ -36,7 +36,7 @@ import org.sonar.api.resources.Resource;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rules.RulePriority;
 import org.sonar.api.technicaldebt.batch.Characteristic;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.batch.protocol.output.BatchReportReader;
 import org.sonar.batch.protocol.output.BatchReportWriter;
 import org.sonar.batch.scan.measure.MeasureCache;
@@ -66,7 +66,7 @@ public class MeasuresPublisherTest {
   @Before
   public void prepare() {
     Project p = new Project("foo").setAnalysisDate(new Date(1234567L));
-    ResourceCache resourceCache = new ResourceCache();
+    BatchComponentCache resourceCache = new BatchComponentCache();
     sampleFile = org.sonar.api.resources.File.create("src/Foo.php").setEffectiveKey("foo:src/Foo.php");
     resourceCache.add(p, null).setSnapshot(new Snapshot().setId(2));
     resourceCache.add(sampleFile, null);
index 4a6e27960d2d9054b6bb646a20bc8847a13f05e0..dcb0438619f8c59edaa2cef4f44c1cdcc155d8a7 100644 (file)
@@ -30,7 +30,7 @@ import org.sonar.api.platform.Server;
 import org.sonar.api.utils.TempFolder;
 import org.sonar.batch.bootstrap.DefaultAnalysisMode;
 import org.sonar.batch.bootstrap.ServerClient;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.jpa.test.AbstractDbUnitTestCase;
 
 import static org.mockito.Mockito.mock;
@@ -41,7 +41,7 @@ public class ReportPublisherTest extends AbstractDbUnitTestCase {
 
   private DefaultAnalysisMode mode;
 
-  ResourceCache resourceCache = mock(ResourceCache.class);
+  BatchComponentCache resourceCache = mock(BatchComponentCache.class);
 
   private ProjectReactor reactor;
 
index bfe6067b6923832d9cc941b7535a6c74ebc5e635..0125a4bb5ba5d8b4ba7a87af2653f358c564c6db 100644 (file)
@@ -28,7 +28,7 @@ import org.sonar.api.batch.fs.internal.DefaultInputFile;
 import org.sonar.api.database.model.Snapshot;
 import org.sonar.api.resources.Project;
 import org.sonar.api.resources.Qualifiers;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.batch.protocol.output.BatchReportWriter;
 
 import java.io.File;
@@ -54,7 +54,7 @@ public class SourcePublisherTest {
   @Before
   public void prepare() throws IOException {
     Project p = new Project("foo").setAnalysisDate(new Date(1234567L));
-    ResourceCache resourceCache = new ResourceCache();
+    BatchComponentCache resourceCache = new BatchComponentCache();
     sampleFile = org.sonar.api.resources.File.create("src/Foo.php");
     sampleFile.setEffectiveKey("foo:src/Foo.php");
     resourceCache.add(p, null).setSnapshot(new Snapshot().setId(2));
index b5b8732d5f910bc8ba2543b63511d96cc6ec2c2a..df55eddc1f799217bb7e6f1354e701eb27dd642b 100644 (file)
@@ -35,8 +35,8 @@ import org.sonar.api.resources.Languages;
 import org.sonar.api.resources.Project;
 import org.sonar.api.resources.Qualifiers;
 import org.sonar.api.resources.Resource;
-import org.sonar.batch.index.BatchResource;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponent;
+import org.sonar.batch.index.BatchComponentCache;
 
 import java.io.File;
 import java.io.IOException;
@@ -100,8 +100,8 @@ public class ComponentIndexerTest {
   }
 
   private ComponentIndexer createIndexer(Languages languages) {
-    ResourceCache resourceCache = mock(ResourceCache.class);
-    when(resourceCache.get(any(Resource.class))).thenReturn(new BatchResource(1, org.sonar.api.resources.File.create("foo.php"), null));
+    BatchComponentCache resourceCache = mock(BatchComponentCache.class);
+    when(resourceCache.get(any(Resource.class))).thenReturn(new BatchComponent(1, org.sonar.api.resources.File.create("foo.php"), null));
     return new ComponentIndexer(project, languages, sonarIndex, resourceCache);
   }
 
index e3135e79a34fe121c9e0bc848600b85875da1d9b..b03d9baf3bda9994abb5f0a675f5ebf520b6443f 100644 (file)
@@ -46,7 +46,7 @@ import org.sonar.api.resources.Resource;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.batch.duplication.DuplicationCache;
 import org.sonar.batch.index.DefaultIndex;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.batch.issue.ModuleIssues;
 import org.sonar.batch.report.ReportPublisher;
 import org.sonar.batch.sensor.coverage.CoverageExclusions;
@@ -74,7 +74,7 @@ public class DefaultSensorStorageTest {
   private Project project;
   private DefaultIndex sonarIndex;
 
-  private ResourceCache resourceCache;
+  private BatchComponentCache resourceCache;
 
   @Before
   public void prepare() throws Exception {
@@ -89,7 +89,7 @@ public class DefaultSensorStorageTest {
     sonarIndex = mock(DefaultIndex.class);
     CoverageExclusions coverageExclusions = mock(CoverageExclusions.class);
     when(coverageExclusions.accept(any(Resource.class), any(Measure.class))).thenReturn(true);
-    resourceCache = new ResourceCache();
+    resourceCache = new BatchComponentCache();
     sensorStorage = new DefaultSensorStorage(metricFinder, project,
       moduleIssues, settings, fs, activeRules, mock(DuplicationCache.class), sonarIndex, coverageExclusions, resourceCache, mock(ReportPublisher.class));
   }
index e98f3bad906ed4aecbcca059ed7b12389fd22900..3d05b7eb3ed5055f8e38c059397f64fded882e4a 100644 (file)
 package org.sonar.batch.source;
 
 import org.junit.Test;
-import org.sonar.api.batch.fs.internal.DefaultInputFile;
 import org.sonar.api.batch.sensor.internal.SensorStorage;
-import org.sonar.api.component.Component;
 import org.sonar.api.resources.File;
 import org.sonar.api.resources.Project;
 import org.sonar.api.resources.Resource;
 import org.sonar.api.source.Highlightable;
-import org.sonar.batch.index.BatchResource;
-import org.sonar.batch.index.ResourceCache;
-import org.sonar.core.component.ResourceComponent;
+import org.sonar.batch.index.BatchComponent;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
 
 public class HighlightableBuilderTest {
 
   @Test
   public void should_load_default_perspective() {
     Resource file = File.create("foo.c").setEffectiveKey("myproject:path/to/foo.c");
-    Component component = new ResourceComponent(file);
+    BatchComponent component = new BatchComponent(1, file, null);
 
-    ResourceCache resourceCache = mock(ResourceCache.class);
-    when(resourceCache.get(file.getEffectiveKey())).thenReturn(new BatchResource(1, file, null).setInputPath(new DefaultInputFile("myproject", "path/to/foo.c")));
-    HighlightableBuilder builder = new HighlightableBuilder(resourceCache, mock(SensorStorage.class));
+    HighlightableBuilder builder = new HighlightableBuilder(mock(SensorStorage.class));
     Highlightable perspective = builder.loadPerspective(Highlightable.class, component);
 
     assertThat(perspective).isNotNull().isInstanceOf(DefaultHighlightable.class);
-    assertThat(perspective.component().key()).isEqualTo(component.key());
   }
 
   @Test
   public void project_should_not_be_highlightable() {
-    Component component = new ResourceComponent(new Project("struts").setEffectiveKey("org.struts"));
+    BatchComponent component = new BatchComponent(1, new Project("struts").setEffectiveKey("org.struts"), null);
 
-    HighlightableBuilder builder = new HighlightableBuilder(mock(ResourceCache.class), mock(SensorStorage.class));
+    HighlightableBuilder builder = new HighlightableBuilder(mock(SensorStorage.class));
     Highlightable perspective = builder.loadPerspective(Highlightable.class, component);
 
     assertThat(perspective).isNull();
index 8a1d3cbe580e5766482107879418eedfd5941cbf..9b29c6ff3c32147c23cffe2ae83f7519035b112e 100644 (file)
 package org.sonar.batch.source;
 
 import org.junit.Test;
-import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.component.Component;
 import org.sonar.api.component.Perspective;
 import org.sonar.api.resources.File;
 import org.sonar.api.resources.Project;
 import org.sonar.api.resources.Resource;
 import org.sonar.api.source.Symbolizable;
-import org.sonar.batch.index.BatchResource;
-import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.BatchComponent;
 import org.sonar.batch.sensor.DefaultSensorStorage;
-import org.sonar.core.component.ResourceComponent;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
 
 public class SymbolizableBuilderTest {
 
   @Test
   public void should_load_perspective() {
     Resource file = File.create("foo.c").setEffectiveKey("myproject:path/to/foo.c");
-    Component component = new ResourceComponent(file);
+    BatchComponent component = new BatchComponent(1, file, null);
 
-    ResourceCache resourceCache = mock(ResourceCache.class);
-    when(resourceCache.get(file.getEffectiveKey())).thenReturn(new BatchResource(1, file, null).setInputPath(new DefaultInputFile("myproject", "path/to/foo.c")));
-
-    SymbolizableBuilder perspectiveBuilder = new SymbolizableBuilder(resourceCache, mock(DefaultSensorStorage.class));
+    SymbolizableBuilder perspectiveBuilder = new SymbolizableBuilder(mock(DefaultSensorStorage.class));
     Perspective perspective = perspectiveBuilder.loadPerspective(Symbolizable.class, component);
 
     assertThat(perspective).isInstanceOf(Symbolizable.class);
-    assertThat(perspective.component().key()).isEqualTo(component.key());
   }
 
   @Test
   public void project_should_not_be_highlightable() {
-    Component component = new ResourceComponent(new Project("struts").setEffectiveKey("org.struts"));
+    BatchComponent component = new BatchComponent(1, new Project("struts").setEffectiveKey("org.struts"), null);
 
-    SymbolizableBuilder builder = new SymbolizableBuilder(mock(ResourceCache.class), mock(DefaultSensorStorage.class));
+    SymbolizableBuilder builder = new SymbolizableBuilder(mock(DefaultSensorStorage.class));
     Perspective perspective = builder.loadPerspective(Symbolizable.class, component);
 
     assertThat(perspective).isNull();
index cb59be1290bd47442c2f614dd9e7993f8b294028..4a2b1b40f900759b562f03828d2b3634f07a4e72 100644 (file)
       <groupId>com.googlecode.json-simple</groupId>
       <artifactId>json-simple</artifactId>
     </dependency>
-    <dependency>
-      <groupId>com.tinkerpop.blueprints</groupId>
-      <artifactId>blueprints-core</artifactId>
-      <exclusions>
-        <exclusion>
-          <groupId>org.codehaus.jackson</groupId>
-          <artifactId>jackson-core-asl</artifactId>
-        </exclusion>
-        <exclusion>
-          <groupId>org.codehaus.jackson</groupId>
-          <artifactId>jackson-mapper-asl</artifactId>
-        </exclusion>
-        <exclusion>
-          <groupId>org.codehaus.jettison</groupId>
-          <artifactId>jettison</artifactId>
-        </exclusion>
-        <exclusion>
-          <groupId>colt</groupId>
-          <artifactId>colt</artifactId>
-        </exclusion>
-      </exclusions>
-    </dependency>
     <dependency>
       <groupId>org.codehaus.sonar</groupId>
       <artifactId>sonar-graph</artifactId>
diff --git a/sonar-core/src/main/java/org/sonar/core/component/ComponentQuery.java b/sonar-core/src/main/java/org/sonar/core/component/ComponentQuery.java
deleted file mode 100644 (file)
index 53ffd32..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.component;
-
-import com.google.common.collect.Sets;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-
-/**
- * @since 4.3
- */
-public class ComponentQuery {
-
-  private Collection<Long> ids;
-
-  private Collection<String> qualifiers;
-
-  private ComponentQuery() {
-    this.ids = Sets.newHashSet();
-    this.qualifiers = Sets.newHashSet();
-  }
-
-  public static ComponentQuery create() {
-    return new ComponentQuery();
-  }
-
-  public Collection<Long> ids() {
-    return Collections.unmodifiableCollection(ids);
-  }
-
-  public ComponentQuery addIds(Long... ids) {
-    this.ids.addAll(Arrays.asList(ids));
-    return this;
-  }
-
-  public Collection<String> qualifiers() {
-    return Collections.unmodifiableCollection(qualifiers);
-  }
-
-  public ComponentQuery addQualifiers(String... qualifiers) {
-    this.qualifiers.addAll(Arrays.asList(qualifiers));
-    return this;
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/component/ComponentVertex.java b/sonar-core/src/main/java/org/sonar/core/component/ComponentVertex.java
deleted file mode 100644 (file)
index 6be36ff..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.component;
-
-import org.sonar.api.component.Component;
-import org.sonar.core.graph.BeanVertex;
-
-public class ComponentVertex extends BeanVertex implements Component {
-
-  @Override
-  public String key() {
-    return (String) getProperty("key");
-  }
-
-  @Override
-  public String path() {
-    return (String) getProperty("path");
-  }
-
-  @Override
-  public String name() {
-    return (String) getProperty("name");
-  }
-
-  @Override
-  public String longName() {
-    return (String) getProperty("longName");
-  }
-
-  @Override
-  public String qualifier() {
-    return (String) getProperty("qualifier");
-  }
-
-  void copyFrom(Component component) {
-    setProperty("key", component.key());
-    setProperty("path", component.path());
-    setProperty("name", component.name());
-    setProperty("longName", component.longName());
-    setProperty("qualifier", component.qualifier());
-  }
-
-  @Override
-  public String toString() {
-    return key();
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/component/GraphPerspectiveBuilder.java b/sonar-core/src/main/java/org/sonar/core/component/GraphPerspectiveBuilder.java
deleted file mode 100644 (file)
index 8e0f64e..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.component;
-
-import org.sonar.api.component.Component;
-import org.sonar.api.component.Perspective;
-import org.sonar.core.graph.EdgePath;
-
-public abstract class GraphPerspectiveBuilder<T extends Perspective> extends PerspectiveBuilder<T> {
-
-  protected final ScanGraph graph;
-  protected final EdgePath path;
-  protected final GraphPerspectiveLoader<T> perspectiveLoader;
-
-  protected GraphPerspectiveBuilder(ScanGraph graph, Class<T> perspectiveClass, EdgePath path,
-    GraphPerspectiveLoader<T> perspectiveLoader) {
-    super(perspectiveClass);
-    this.graph = graph;
-    this.path = path;
-    this.perspectiveLoader = perspectiveLoader;
-  }
-
-  public T create(ComponentVertex component) {
-    return (T) component.beanGraph().createAdjacentVertex(component, perspectiveLoader.getBeanClass(),
-      perspectiveLoader.getPerspectiveKey());
-  }
-
-  public EdgePath path() {
-    return path;
-  }
-
-  public GraphPerspectiveLoader<T> getPerspectiveLoader() {
-    return perspectiveLoader;
-  }
-
-  @Override
-  public T loadPerspective(Class<T> perspectiveClass, Component component) {
-    ComponentVertex vertex;
-    if (component instanceof ComponentVertex) {
-      vertex = (ComponentVertex) component;
-    } else {
-      vertex = graph.getComponent(component.key());
-    }
-
-    if (vertex != null) {
-      T perspective = perspectiveLoader.load(vertex);
-      if (perspective == null) {
-        perspective = create(vertex);
-      }
-      return perspective;
-    }
-    return null;
-  }
-
-  public T get(Class<T> perspectiveClass, String componentKey) {
-    ComponentVertex vertex = graph.getComponent(componentKey);
-    if (vertex != null) {
-      T perspective = perspectiveLoader.load(vertex);
-      if (perspective != null) {
-        return perspective;
-      }
-    }
-    return null;
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/component/GraphPerspectiveLoader.java b/sonar-core/src/main/java/org/sonar/core/component/GraphPerspectiveLoader.java
deleted file mode 100644 (file)
index 968ba28..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.component;
-
-import com.tinkerpop.blueprints.Direction;
-import com.tinkerpop.blueprints.Vertex;
-import org.sonar.api.component.Perspective;
-import org.sonar.core.graph.BeanVertex;
-import org.sonar.core.graph.GraphUtil;
-
-public abstract class GraphPerspectiveLoader<T extends Perspective> {
-
-  protected final String perspectiveKey;
-  protected final Class<T> perspectiveClass;
-
-  protected GraphPerspectiveLoader(String perspectiveKey, Class<T> perspectiveClass) {
-    this.perspectiveKey = perspectiveKey;
-    this.perspectiveClass = perspectiveClass;
-  }
-
-  public T load(ComponentVertex component) {
-    Vertex perspectiveVertex = GraphUtil.singleAdjacent(component.element(), Direction.OUT, getPerspectiveKey());
-    if (perspectiveVertex != null) {
-      return (T) component.beanGraph().wrap(perspectiveVertex, getBeanClass());
-    }
-    return null;
-  }
-
-  public String getPerspectiveKey() {
-    return perspectiveKey;
-  }
-
-  protected Class<T> getPerspectiveClass() {
-    return perspectiveClass;
-  }
-
-  protected abstract Class<? extends BeanVertex> getBeanClass();
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/component/PerspectiveBuilder.java b/sonar-core/src/main/java/org/sonar/core/component/PerspectiveBuilder.java
deleted file mode 100644 (file)
index e31bcf2..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.component;
-
-import org.sonar.api.batch.BatchSide;
-import org.sonar.api.server.ServerSide;
-import org.sonar.api.component.Component;
-import org.sonar.api.component.Perspective;
-
-import javax.annotation.CheckForNull;
-
-@BatchSide
-@ServerSide
-public abstract class PerspectiveBuilder<T extends Perspective> {
-
-  private final Class<T> perspectiveClass;
-
-  protected PerspectiveBuilder(Class<T> perspectiveClass) {
-    this.perspectiveClass = perspectiveClass;
-  }
-
-  public Class<T> getPerspectiveClass() {
-    return perspectiveClass;
-  }
-
-  @CheckForNull
-  public abstract T loadPerspective(Class<T> perspectiveClass, Component component);
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/component/PerspectiveNotFoundException.java b/sonar-core/src/main/java/org/sonar/core/component/PerspectiveNotFoundException.java
deleted file mode 100644 (file)
index 70a0a4c..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.component;
-
-public class PerspectiveNotFoundException extends RuntimeException {
-  public PerspectiveNotFoundException(String message) {
-    super(message);
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/component/ResourceComponent.java b/sonar-core/src/main/java/org/sonar/core/component/ResourceComponent.java
deleted file mode 100644 (file)
index 9680a0f..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.component;
-
-import com.google.common.base.Strings;
-import org.sonar.api.component.Component;
-import org.sonar.api.resources.Resource;
-
-public class ResourceComponent implements Component {
-  private String key;
-  private String path;
-  private String name;
-  private String longName;
-  private String qualifier;
-  private String scope;
-
-  public ResourceComponent(Resource resource) {
-    this.key = resource.getEffectiveKey();
-    this.path = resource.getPath();
-    if (Strings.isNullOrEmpty(key)) {
-      throw new IllegalArgumentException("Missing component key");
-    }
-    this.name = resource.getName();
-    this.longName = resource.getLongName();
-    this.qualifier = resource.getQualifier();
-    this.scope = resource.getScope();
-  }
-
-  @Override
-  public String key() {
-    return key;
-  }
-
-  @Override
-  public String path() {
-    return path;
-  }
-
-  @Override
-  public String name() {
-    return name;
-  }
-
-  @Override
-  public String longName() {
-    return longName;
-  }
-
-  @Override
-  public String qualifier() {
-    return qualifier;
-  }
-
-  public String scope() {
-    return scope;
-  }
-
-  @Override
-  public String toString() {
-    return key;
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/component/ScanGraph.java b/sonar-core/src/main/java/org/sonar/core/component/ScanGraph.java
deleted file mode 100644 (file)
index d7c62c5..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.component;
-
-import com.tinkerpop.blueprints.Direction;
-import com.tinkerpop.blueprints.Graph;
-import com.tinkerpop.blueprints.Vertex;
-import com.tinkerpop.blueprints.impls.tg.TinkerGraph;
-import org.sonar.api.batch.BatchSide;
-import org.sonar.api.component.Component;
-import org.sonar.api.resources.Resource;
-import org.sonar.core.graph.BeanGraph;
-import org.sonar.core.graph.BeanIterable;
-import org.sonar.core.graph.GraphUtil;
-
-@BatchSide
-public class ScanGraph extends BeanGraph {
-
-  private static final String COMPONENT = "component";
-  private final Vertex componentsRoot;
-
-  private ScanGraph(Graph graph) {
-    super(graph);
-    componentsRoot = graph.addVertex(null);
-    componentsRoot.setProperty("root", "components");
-  }
-
-  public static ScanGraph create() {
-    TinkerGraph graph = new TinkerGraph();
-    graph.createKeyIndex("key", Vertex.class);
-    return new ScanGraph(graph);
-  }
-
-  public ComponentVertex wrapComponent(Vertex vertex) {
-    return wrap(vertex, ComponentVertex.class);
-  }
-
-  public ComponentVertex getComponent(String key) {
-    Vertex vertex = GraphUtil.single(getUnderlyingGraph().getVertices("key", key));
-    return vertex != null ? wrapComponent(vertex) : null;
-  }
-
-  public ComponentVertex addComponent(Resource resource) {
-    return addComponent(new ResourceComponent(resource));
-  }
-
-  public void completeComponent(String key, long resourceId, long snapshotId) {
-    ComponentVertex component = getComponent(key);
-    component.setProperty("sid", snapshotId);
-    component.setProperty("rid", resourceId);
-  }
-
-  public Iterable<ComponentVertex> getComponents() {
-    Iterable<Vertex> componentVertices = componentsRoot.getVertices(Direction.OUT, COMPONENT);
-    return new BeanIterable<>(this, ComponentVertex.class, componentVertices);
-  }
-
-  public ComponentVertex addComponent(Component component) {
-    Vertex vertex = getUnderlyingGraph().addVertex(null);
-    getUnderlyingGraph().addEdge(null, componentsRoot, vertex, COMPONENT);
-    ComponentVertex wrapper = wrap(vertex, ComponentVertex.class);
-    wrapper.copyFrom(component);
-    return wrapper;
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/component/SnapshotGraph.java b/sonar-core/src/main/java/org/sonar/core/component/SnapshotGraph.java
deleted file mode 100644 (file)
index 9d9fcc7..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.component;
-
-import com.tinkerpop.blueprints.Graph;
-import com.tinkerpop.blueprints.Vertex;
-import org.sonar.core.graph.BeanGraph;
-
-class SnapshotGraph extends BeanGraph {
-  private final Vertex componentRoot;
-
-  SnapshotGraph(Graph graph, String rootVertexId) {
-    super(graph);
-    componentRoot = graph.getVertex(rootVertexId);
-  }
-
-  Vertex getComponentRoot() {
-    return componentRoot;
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/BeanEdge.java b/sonar-core/src/main/java/org/sonar/core/graph/BeanEdge.java
deleted file mode 100644 (file)
index daa1be3..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.graph;
-
-import com.tinkerpop.blueprints.Direction;
-import com.tinkerpop.blueprints.Edge;
-
-public abstract class BeanEdge extends BeanElement<Edge, BeanEdge> {
-
-  protected final <T extends BeanVertex> T getVertex(Class<T> vertexClass, Direction direction) {
-    return beanGraph().wrap(element().getVertex(direction), vertexClass);
-  }
-
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/BeanElement.java b/sonar-core/src/main/java/org/sonar/core/graph/BeanElement.java
deleted file mode 100644 (file)
index 6a5ecba..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.graph;
-
-import com.tinkerpop.blueprints.Element;
-
-import javax.annotation.Nullable;
-
-import java.util.Set;
-
-public abstract class BeanElement<T extends Element, C extends BeanElement<T, C>> {
-  private T element;
-  private BeanGraph graph;
-
-  public T element() {
-    return element;
-  }
-
-  void setElement(T element) {
-    this.element = element;
-  }
-
-  public BeanGraph beanGraph() {
-    return graph;
-  }
-
-  void setBeanGraph(BeanGraph graph) {
-    this.graph = graph;
-  }
-
-  protected final Object getProperty(String key) {
-    return element.getProperty(key);
-  }
-
-  protected final Set<String> getPropertyKeys() {
-    return element.getPropertyKeys();
-  }
-
-  public final C setProperty(String key, @Nullable Object value) {
-    if (value != null) {
-      element.setProperty(key, value);
-    } else {
-      element.removeProperty(key);
-    }
-    return (C) this;
-  }
-
-  protected final Object removeProperty(String key) {
-    return element.removeProperty(key);
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/BeanElements.java b/sonar-core/src/main/java/org/sonar/core/graph/BeanElements.java
deleted file mode 100644 (file)
index c1e6420..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.graph;
-
-import com.google.common.collect.MapMaker;
-import com.tinkerpop.blueprints.Element;
-
-import java.util.Map;
-
-class BeanElements {
-
-  private final Map<ElementKey, BeanElement> cache;
-
-  BeanElements() {
-    cache = new MapMaker().weakValues().makeMap();
-  }
-
-  <T extends BeanElement> T wrap(Element element, Class<T> beanClass, BeanGraph graph) {
-    ElementKey key = new ElementKey(element, beanClass);
-    T bean = (T) cache.get(key);
-    if (bean == null) {
-      try {
-        bean = (T) key.beanClass.newInstance();
-        bean.setElement(key.element);
-        bean.setBeanGraph(graph);
-        cache.put(key, bean);
-      } catch (InstantiationException e) {
-        throw new IllegalStateException("Class has no default constructor: " + beanClass.getName(), e);
-      } catch (IllegalAccessException e) {
-        throw new IllegalStateException("Can not access to default constructor: " + beanClass.getName(), e);
-      }
-    }
-    return bean;
-  }
-
-  void clear() {
-    cache.clear();
-  }
-
-  private static class ElementKey {
-    Element element;
-    Class<? extends BeanElement> beanClass;
-
-    ElementKey(Element element, Class<? extends BeanElement> beanClass) {
-      this.element = element;
-      this.beanClass = beanClass;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-      if (this == o) {
-        return true;
-      }
-      if (o == null) {
-        return false;
-      }
-      ElementKey that = (ElementKey) o;
-      if (!element.equals(that.element)) {
-        return false;
-      }
-      return beanClass.equals(that.beanClass);
-    }
-
-    @Override
-    public int hashCode() {
-      int result = element.hashCode();
-      result = 31 * result + beanClass.hashCode();
-      return result;
-    }
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/BeanGraph.java b/sonar-core/src/main/java/org/sonar/core/graph/BeanGraph.java
deleted file mode 100644 (file)
index f543b01..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.graph;
-
-import com.tinkerpop.blueprints.Edge;
-import com.tinkerpop.blueprints.Element;
-import com.tinkerpop.blueprints.Graph;
-import com.tinkerpop.blueprints.Vertex;
-import com.tinkerpop.blueprints.impls.tg.TinkerGraph;
-import com.tinkerpop.blueprints.util.ElementHelper;
-
-import javax.annotation.Nullable;
-
-public class BeanGraph {
-  private final Graph graph;
-  private final BeanElements beans;
-
-  public BeanGraph(Graph graph) {
-    this.graph = graph;
-    this.beans = new BeanElements();
-  }
-
-  public static BeanGraph createInMemory() {
-    return new BeanGraph(new TinkerGraph());
-  }
-
-  public final <T extends BeanElement> T wrap(@Nullable Element element, Class<T> beanClass) {
-    return element != null ? beans.wrap(element, beanClass, this) : null;
-  }
-
-  public final <T extends BeanVertex> T createAdjacentVertex(BeanVertex from, Class<T> beanClass, String edgeLabel, String... edgeProperties) {
-    T to = createVertex(beanClass);
-    Edge edge = graph.addEdge(null, from.element(), to.element(), edgeLabel);
-    ElementHelper.setProperties(edge, edgeProperties);
-    return to;
-  }
-
-  public final <T extends BeanVertex> T createVertex(Class<T> beanClass) {
-    Vertex vertex = graph.addVertex(null);
-    return beans.wrap(vertex, beanClass, this);
-  }
-
-  public final Graph getUnderlyingGraph() {
-    return graph;
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/BeanIterable.java b/sonar-core/src/main/java/org/sonar/core/graph/BeanIterable.java
deleted file mode 100644 (file)
index c7c1d99..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.graph;
-
-import com.tinkerpop.blueprints.Element;
-
-import java.util.Iterator;
-
-public class BeanIterable<T extends BeanElement> implements Iterable<T> {
-
-  private final Iterable<? extends Element> iterable;
-  private final BeanGraph graph;
-  private final Class<T> beanClass;
-
-  public BeanIterable(BeanGraph graph, Class<T> beanClass, Iterable<? extends Element> iterable) {
-    this.iterable = iterable;
-    this.graph = graph;
-    this.beanClass = beanClass;
-  }
-
-  @Override
-  public Iterator<T> iterator() {
-    return new Iterator<T>() {
-      private final Iterator<? extends Element> iterator = iterable.iterator();
-
-      @Override
-      public void remove() {
-        throw new UnsupportedOperationException();
-      }
-
-      @Override
-      public boolean hasNext() {
-        return this.iterator.hasNext();
-      }
-
-      @Override
-      public T next() {
-        return graph.wrap(this.iterator.next(), beanClass);
-      }
-    };
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/BeanVertex.java b/sonar-core/src/main/java/org/sonar/core/graph/BeanVertex.java
deleted file mode 100644 (file)
index d1f544b..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.graph;
-
-import com.tinkerpop.blueprints.Direction;
-import com.tinkerpop.blueprints.Vertex;
-
-public abstract class BeanVertex extends BeanElement<Vertex, BeanVertex> {
-
-  protected final <T extends BeanEdge> Iterable<T> getEdges(Class<T> edgeClass, Direction direction, String... labels) {
-    return new BeanIterable<>(beanGraph(), edgeClass, element().getEdges(direction, labels));
-  }
-
-  protected final <T extends BeanVertex> Iterable<T> getVertices(Class<T> vertexClass, Direction direction, String... labels) {
-    return new BeanIterable<>(beanGraph(), vertexClass, element().getVertices(direction, labels));
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/EdgePath.java b/sonar-core/src/main/java/org/sonar/core/graph/EdgePath.java
deleted file mode 100644 (file)
index f99c3b0..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.graph;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableList;
-import com.tinkerpop.blueprints.Direction;
-
-import java.util.List;
-
-public class EdgePath {
-  private List<Object> elements;
-
-  private EdgePath(Object[] elements) {
-    Preconditions.checkArgument(elements != null && elements.length > 0, "Elements can't be null or empty");
-    Preconditions.checkArgument(elements.length % 2 == 0, "Odd number of elements (" + elements.length + ")");
-
-    for (int i = 0; i < elements.length; i++) {
-      if (i % 2 == 0) {
-        Preconditions.checkArgument(elements[i] instanceof Direction,
-          "Element " + i + " must be a " + Direction.class.getName() + " (got " + elements[i].getClass().getName() + ")");
-      } else {
-        Preconditions.checkArgument(elements[i] instanceof String,
-          "Element " + i + " must be a String" + " (got " + elements[i].getClass().getName() + ")");
-      }
-    }
-
-    this.elements = ImmutableList.copyOf(elements);
-  }
-
-  public List<Object> getElements() {
-    return elements;
-  }
-
-  public static EdgePath create(Object... elements) {
-    return new EdgePath(elements);
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/GraphUtil.java b/sonar-core/src/main/java/org/sonar/core/graph/GraphUtil.java
deleted file mode 100644 (file)
index b868a85..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.graph;
-
-import com.google.common.base.Joiner;
-import com.tinkerpop.blueprints.Direction;
-import com.tinkerpop.blueprints.Element;
-import com.tinkerpop.blueprints.Vertex;
-
-import javax.annotation.CheckForNull;
-
-import java.util.Iterator;
-
-public class GraphUtil {
-
-  private GraphUtil() {
-  }
-
-  /**
-   * Get adjacent vertex. It assumes that there are only 0 or 1 results.
-   *
-   * @throws MultipleElementsException if there are more than 1 adjacent vertices with the given criteria.
-   */
-  @CheckForNull
-  public static Vertex singleAdjacent(Vertex from, Direction direction, String... labels) {
-    Iterator<Vertex> vertices = from.getVertices(direction, labels).iterator();
-    Vertex result = null;
-    if (vertices.hasNext()) {
-      result = vertices.next();
-      if (vertices.hasNext()) {
-        throw new MultipleElementsException(String.format("More than one vertex is adjacent to: %s, direction: %s, labels: %s", from, direction, Joiner.on(",").join(labels)));
-      }
-    }
-    return result;
-  }
-
-  public static <T extends Element> T single(Iterable<T> iterable) {
-    Iterator<T> iterator = iterable.iterator();
-    T result = null;
-    if (iterator.hasNext()) {
-      result = iterator.next();
-      if (iterator.hasNext()) {
-        throw new MultipleElementsException("More than one element");
-      }
-    }
-    return result;
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/MultipleElementsException.java b/sonar-core/src/main/java/org/sonar/core/graph/MultipleElementsException.java
deleted file mode 100644 (file)
index 44bfb4e..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.graph;
-
-public class MultipleElementsException extends RuntimeException {
-  public MultipleElementsException(String message) {
-    super(message);
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/graphson/ElementFactory.java b/sonar-core/src/main/java/org/sonar/core/graph/graphson/ElementFactory.java
deleted file mode 100644 (file)
index 0eee36e..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.graph.graphson;
-
-import com.tinkerpop.blueprints.Edge;
-import com.tinkerpop.blueprints.Graph;
-import com.tinkerpop.blueprints.Vertex;
-
-/**
- * The standard factory used for most graph element creation.  It uses an actual
- * Graph implementation to construct vertices and edges
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-class ElementFactory {
-
-  private final Graph graph;
-
-  ElementFactory(Graph g) {
-    this.graph = g;
-  }
-
-  Edge createEdge(Object id, Vertex out, Vertex in, String label) {
-    return this.graph.addEdge(id, out, in, label);
-  }
-
-  Vertex createVertex(Object id) {
-    return this.graph.addVertex(id);
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/graphson/ElementPropertyConfig.java b/sonar-core/src/main/java/org/sonar/core/graph/graphson/ElementPropertyConfig.java
deleted file mode 100644 (file)
index 7dfc3ea..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.graph.graphson;
-
-import java.util.Set;
-
-/**
- * Configure how the GraphSON utility treats edge and vertex properties.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-class ElementPropertyConfig {
-
-  enum ElementPropertiesRule {
-    INCLUDE, EXCLUDE
-  }
-
-  private final Set<String> vertexPropertyKeys;
-  private final Set<String> edgePropertyKeys;
-  private final ElementPropertiesRule vertexPropertiesRule;
-  private final ElementPropertiesRule edgePropertiesRule;
-
-  /**
-   * A configuration that includes all properties of vertices and edges.
-   */
-  static ElementPropertyConfig AllProperties = new ElementPropertyConfig(null, null,
-    ElementPropertiesRule.INCLUDE, ElementPropertiesRule.INCLUDE);
-
-  ElementPropertyConfig(Set<String> vertexPropertyKeys, Set<String> edgePropertyKeys,
-                        ElementPropertiesRule vertexPropertiesRule, ElementPropertiesRule edgePropertiesRule) {
-    this.vertexPropertiesRule = vertexPropertiesRule;
-    this.vertexPropertyKeys = vertexPropertyKeys;
-    this.edgePropertiesRule = edgePropertiesRule;
-    this.edgePropertyKeys = edgePropertyKeys;
-  }
-
-  /**
-   * Construct a configuration that includes the specified properties from both vertices and edges.
-   */
-  static ElementPropertyConfig includeProperties(Set<String> vertexPropertyKeys,
-                                                 Set<String> edgePropertyKeys) {
-    return new ElementPropertyConfig(vertexPropertyKeys, edgePropertyKeys, ElementPropertiesRule.INCLUDE,
-      ElementPropertiesRule.INCLUDE);
-  }
-
-  /**
-   * Construct a configuration that excludes the specified properties from both vertices and edges.
-   */
-  static ElementPropertyConfig excludeProperties(Set<String> vertexPropertyKeys,
-                                                 Set<String> edgePropertyKeys) {
-    return new ElementPropertyConfig(vertexPropertyKeys, edgePropertyKeys, ElementPropertiesRule.EXCLUDE,
-      ElementPropertiesRule.EXCLUDE);
-  }
-
-  Set<String> getVertexPropertyKeys() {
-    return vertexPropertyKeys;
-  }
-
-  Set<String> getEdgePropertyKeys() {
-    return edgePropertyKeys;
-  }
-
-  ElementPropertiesRule getVertexPropertiesRule() {
-    return vertexPropertiesRule;
-  }
-
-  ElementPropertiesRule getEdgePropertiesRule() {
-    return edgePropertiesRule;
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphsonException.java b/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphsonException.java
deleted file mode 100644 (file)
index cfc80c1..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.graph.graphson;
-
-public class GraphsonException extends RuntimeException {
-  public GraphsonException(String message, Throwable cause) {
-    super(message, cause);
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphsonMode.java b/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphsonMode.java
deleted file mode 100644 (file)
index 0e93351..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.graph.graphson;
-
-/**
- * Modes of operation of the GraphSONUtility.
- *
- * @author Stephen Mallette
- */
-public enum GraphsonMode {
-  /**
-   * COMPACT constructs GraphSON on the assumption that all property keys
-   * are fair game for exclusion including _type, _inV, _outV, _label and _id.
-   * It is possible to write GraphSON that cannot be read back into Graph,
-   * if some or all of these keys are excluded.
-   */
-  COMPACT,
-
-  /**
-   * NORMAL includes the _type field and JSON data typing.
-   */
-  NORMAL,
-
-  /**
-   * EXTENDED includes the _type field and explicit data typing.
-   */
-  EXTENDED
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphsonReader.java b/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphsonReader.java
deleted file mode 100644 (file)
index c681aaa..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.graph.graphson;
-
-import com.tinkerpop.blueprints.Graph;
-import com.tinkerpop.blueprints.Vertex;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-import org.json.simple.parser.JSONParser;
-
-import java.io.Reader;
-import java.util.Set;
-
-/**
- * Greatly inspired by the Blueprints implementation based on Jettison/Jackson
- */
-public class GraphsonReader {
-
-  public Graph read(Reader jsonInput, Graph toGraph) {
-    return read(jsonInput, toGraph, null, null);
-  }
-
-  /**
-   * Input the JSON stream data into the graph.
-   * More control over how data is streamed is provided by this method.
-   *
-   * @param toGraph    the graph to populate with the JSON data
-   * @param input      an InputStream of JSON data
-   * @param bufferSize the amount of elements to hold in memory before committing a transactions (only valid for TransactionalGraphs)
-   */
-  public Graph read(Reader input, Graph toGraph, Set<String> edgePropertyKeys, Set<String> vertexPropertyKeys) {
-    try {
-      JSONParser parser = new JSONParser();
-      JSONObject json = (JSONObject) parser.parse(input);
-
-      ElementFactory elementFactory = new ElementFactory(toGraph);
-      GraphsonMode mode = GraphsonMode.valueOf(json.get(GraphsonTokens.MODE).toString());
-      GraphsonUtil graphson = new GraphsonUtil(mode, elementFactory, vertexPropertyKeys, edgePropertyKeys);
-
-      JSONArray vertices = (JSONArray) json.get(GraphsonTokens.VERTICES);
-      for (Object vertice : vertices) {
-        graphson.vertexFromJson((JSONObject) vertice);
-      }
-
-      JSONArray edges = (JSONArray) json.get(GraphsonTokens.EDGES);
-      for (Object edgeObject : edges) {
-        JSONObject edge = (JSONObject) edgeObject;
-        Vertex inV = toGraph.getVertex(edge.get(GraphsonTokens._IN_V));
-        Vertex outV = toGraph.getVertex(edge.get(GraphsonTokens._OUT_V));
-        graphson.edgeFromJson(edge, outV, inV);
-      }
-      toGraph.shutdown();
-      return toGraph;
-    } catch (Exception e) {
-      throw new GraphsonException("Unable to parse GraphSON", e);
-    }
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphsonTokens.java b/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphsonTokens.java
deleted file mode 100644 (file)
index 052da0c..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.graph.graphson;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- * @author Stephen Mallette
- */
-class GraphsonTokens {
-  private GraphsonTokens() {
-  }
-
-  static final String VERTEX = "vertex";
-  static final String EDGE = "edge";
-  static final String _ID = "_id";
-  static final String _LABEL = "_label";
-  static final String _TYPE = "_type";
-  static final String _OUT_V = "_outV";
-  static final String _IN_V = "_inV";
-  static final String VALUE = "value";
-  static final String TYPE = "type";
-  static final String TYPE_LIST = "list";
-  static final String TYPE_STRING = "string";
-  static final String TYPE_DOUBLE = "double";
-  static final String TYPE_INTEGER = "integer";
-  static final String TYPE_FLOAT = "float";
-  static final String TYPE_MAP = "map";
-  static final String TYPE_BOOLEAN = "boolean";
-  static final String TYPE_LONG = "long";
-  static final String TYPE_UNKNOWN = "unknown";
-
-  static final String VERTICES = "vertices";
-  static final String EDGES = "edges";
-  static final String MODE = "mode";
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphsonUtil.java b/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphsonUtil.java
deleted file mode 100644 (file)
index a837bbf..0000000
+++ /dev/null
@@ -1,673 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.graph.graphson;
-
-import com.tinkerpop.blueprints.Direction;
-import com.tinkerpop.blueprints.Edge;
-import com.tinkerpop.blueprints.Element;
-import com.tinkerpop.blueprints.Vertex;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-import org.json.simple.parser.JSONParser;
-import org.json.simple.parser.ParseException;
-
-import javax.annotation.Nullable;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import static org.sonar.core.graph.graphson.ElementPropertyConfig.ElementPropertiesRule;
-
-/**
- * Helps write individual graph elements to TinkerPop JSON format known as GraphSON.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-class GraphsonUtil {
-
-  private final GraphsonMode mode;
-  private final Set<String> vertexPropertyKeys;
-  private final Set<String> edgePropertyKeys;
-  private final ElementFactory factory;
-  private final boolean hasEmbeddedTypes;
-  private final ElementPropertiesRule vertexPropertiesRule;
-  private final ElementPropertiesRule edgePropertiesRule;
-  private final boolean includeReservedVertexId;
-  private final boolean includeReservedEdgeId;
-  private final boolean includeReservedVertexType;
-  private final boolean includeReservedEdgeType;
-  private final boolean includeReservedEdgeLabel;
-  private final boolean includeReservedEdgeOutV;
-  private final boolean includeReservedEdgeInV;
-  private JSONParser parser = new JSONParser();
-
-  /**
-   * A GraphSONUtiltiy that includes all properties of vertices and edges.
-   */
-  GraphsonUtil(GraphsonMode mode, ElementFactory factory) {
-    this(mode, factory, ElementPropertyConfig.AllProperties);
-  }
-
-  /**
-   * A GraphSONUtility that includes the specified properties.
-   */
-  GraphsonUtil(GraphsonMode mode, ElementFactory factory,
-    Set<String> vertexPropertyKeys, Set<String> edgePropertyKeys) {
-    this(mode, factory, ElementPropertyConfig.includeProperties(vertexPropertyKeys, edgePropertyKeys));
-  }
-
-  GraphsonUtil(GraphsonMode mode, ElementFactory factory,
-    ElementPropertyConfig config) {
-    this.vertexPropertyKeys = config.getVertexPropertyKeys();
-    this.edgePropertyKeys = config.getEdgePropertyKeys();
-    this.vertexPropertiesRule = config.getVertexPropertiesRule();
-    this.edgePropertiesRule = config.getEdgePropertiesRule();
-
-    this.mode = mode;
-    this.factory = factory;
-    this.hasEmbeddedTypes = mode == GraphsonMode.EXTENDED;
-
-    this.includeReservedVertexId = includeReservedKey(mode, GraphsonTokens._ID, vertexPropertyKeys, this.vertexPropertiesRule);
-    this.includeReservedEdgeId = includeReservedKey(mode, GraphsonTokens._ID, edgePropertyKeys, this.edgePropertiesRule);
-    this.includeReservedVertexType = includeReservedKey(mode, GraphsonTokens._TYPE, vertexPropertyKeys, this.vertexPropertiesRule);
-    this.includeReservedEdgeType = includeReservedKey(mode, GraphsonTokens._TYPE, edgePropertyKeys, this.edgePropertiesRule);
-    this.includeReservedEdgeLabel = includeReservedKey(mode, GraphsonTokens._LABEL, edgePropertyKeys, this.edgePropertiesRule);
-    this.includeReservedEdgeOutV = includeReservedKey(mode, GraphsonTokens._OUT_V, edgePropertyKeys, this.edgePropertiesRule);
-    this.includeReservedEdgeInV = includeReservedKey(mode, GraphsonTokens._IN_V, edgePropertyKeys, this.edgePropertiesRule);
-  }
-
-  /**
-   * Creates a JSONObject from a graph element.
-   *
-   * @param element      the graph element to convert to JSON.
-   * @param propertyKeys The property keys at the root of the element to serialize.  If null, then all keys are serialized.
-   * @param mode         the type of GraphSON to be generated.
-   */
-  static JSONObject jsonFromElement(Element element, @Nullable Set<String> propertyKeys, GraphsonMode mode) {
-    GraphsonUtil graphson = element instanceof Edge ? new GraphsonUtil(mode, null, null, propertyKeys)
-      : new GraphsonUtil(mode, null, propertyKeys, null);
-    return graphson.jsonFromElement(element);
-  }
-
-  /**
-   * Reads an individual Vertex from JSON.  The vertex must match the accepted GraphSON format.
-   *
-   * @param json         a single vertex in GraphSON format as JSONObject
-   * @param factory      the factory responsible for constructing graph elements
-   * @param mode         the mode of the GraphSON
-   * @param propertyKeys a list of keys to include on reading of element properties
-   */
-  static Vertex vertexFromJson(JSONObject json, ElementFactory factory, GraphsonMode mode,
-    Set<String> propertyKeys) throws IOException {
-    GraphsonUtil graphson = new GraphsonUtil(mode, factory, propertyKeys, null);
-    return graphson.vertexFromJson(json);
-  }
-
-  /**
-   * Reads an individual Vertex from JSON.  The vertex must match the accepted GraphSON format.
-   *
-   * @param json         a single vertex in GraphSON format as a String.
-   * @param factory      the factory responsible for constructing graph elements
-   * @param mode         the mode of the GraphSON
-   * @param propertyKeys a list of keys to include on reading of element properties
-   */
-  static Vertex vertexFromJson(String json, ElementFactory factory, GraphsonMode mode,
-    Set<String> propertyKeys) throws ParseException {
-    GraphsonUtil graphson = new GraphsonUtil(mode, factory, propertyKeys, null);
-    return graphson.vertexFromJson(json);
-  }
-
-  /**
-   * Reads an individual Vertex from JSON.  The vertex must match the accepted GraphSON format.
-   *
-   * @param json         a single vertex in GraphSON format as an InputStream.
-   * @param factory      the factory responsible for constructing graph elements
-   * @param mode         the mode of the GraphSON
-   * @param propertyKeys a list of keys to include on reading of element properties
-   */
-  static Vertex vertexFromJson(InputStream json, ElementFactory factory, GraphsonMode mode,
-    Set<String> propertyKeys) throws IOException, ParseException {
-    GraphsonUtil graphson = new GraphsonUtil(mode, factory, propertyKeys, null);
-    return graphson.vertexFromJson(json);
-  }
-
-  private static boolean includeReservedKey(GraphsonMode mode, String key,
-    Set<String> propertyKeys,
-    ElementPropertiesRule rule) {
-    // the key is always included in modes other than compact. if it is compact, then validate that the
-    // key is in the property key list
-    return mode != GraphsonMode.COMPACT || includeKey(key, propertyKeys, rule);
-  }
-
-  private static boolean includeKey(String key, Set<String> propertyKeys,
-    ElementPropertiesRule rule) {
-    if (propertyKeys == null) {
-      // when null always include the key and shortcut this piece
-      return true;
-    }
-
-    // default the key situation. if it's included then it should be explicitly defined in the
-    // property keys list to be included or the reverse otherwise
-    boolean keySituation = rule == ElementPropertiesRule.INCLUDE;
-
-    if (rule == ElementPropertiesRule.INCLUDE) {
-      keySituation = propertyKeys.contains(key);
-    } else if (rule == ElementPropertiesRule.EXCLUDE) {
-      keySituation = !propertyKeys.contains(key);
-    }
-    return keySituation;
-  }
-
-  /**
-   * Reads an individual Edge from JSON.  The edge must match the accepted GraphSON format.
-   *
-   * @param json         a single edge in GraphSON format as a String
-   * @param factory      the factory responsible for constructing graph elements
-   * @param mode         the mode of the GraphSON
-   * @param propertyKeys a list of keys to include when reading of element properties
-   */
-  static Edge edgeFromJson(String json, Vertex out, Vertex in,
-    ElementFactory factory, GraphsonMode mode,
-    Set<String> propertyKeys) throws IOException, ParseException {
-    GraphsonUtil graphson = new GraphsonUtil(mode, factory, null, propertyKeys);
-    return graphson.edgeFromJson(json, out, in);
-  }
-
-  /**
-   * Reads an individual Edge from JSON.  The edge must match the accepted GraphSON format.
-   *
-   * @param json         a single edge in GraphSON format as an InputStream
-   * @param factory      the factory responsible for constructing graph elements
-   * @param mode         the mode of the GraphSON
-   * @param propertyKeys a list of keys to include when reading of element properties
-   */
-  static Edge edgeFromJson(InputStream json, Vertex out, Vertex in,
-    ElementFactory factory, GraphsonMode mode,
-    Set<String> propertyKeys) throws IOException, ParseException {
-    GraphsonUtil graphson = new GraphsonUtil(mode, factory, null, propertyKeys);
-    return graphson.edgeFromJson(json, out, in);
-  }
-
-  /**
-   * Reads an individual Edge from JSON.  The edge must match the accepted GraphSON format.
-   *
-   * @param json         a single edge in GraphSON format as a JSONObject
-   * @param factory      the factory responsible for constructing graph elements
-   * @param mode         the mode of the GraphSON
-   * @param propertyKeys a list of keys to include when reading of element properties
-   */
-  static Edge edgeFromJson(JSONObject json, Vertex out, Vertex in,
-    ElementFactory factory, GraphsonMode mode,
-    Set<String> propertyKeys) throws IOException {
-    GraphsonUtil graphson = new GraphsonUtil(mode, factory, null, propertyKeys);
-    return graphson.edgeFromJson(json, out, in);
-  }
-
-  static Map<String, Object> readProperties(JSONObject node, boolean ignoreReservedKeys, boolean hasEmbeddedTypes) {
-    Map<String, Object> map = new HashMap<>();
-
-    for (Object objKey : node.keySet()) {
-      String key = (String) objKey;
-      Object value = node.get(key);
-
-      if (!ignoreReservedKeys || !isReservedKey(key)) {
-        map.put(key, readProperty(value, hasEmbeddedTypes));
-      }
-    }
-
-    return map;
-  }
-
-  private static boolean isReservedKey(String key) {
-    return key.equals(GraphsonTokens._ID) || key.equals(GraphsonTokens._TYPE) || key.equals(GraphsonTokens._LABEL)
-      || key.equals(GraphsonTokens._OUT_V) || key.equals(GraphsonTokens._IN_V);
-  }
-
-  private static JSONArray createJSONList(List list, Set<String> propertyKeys, boolean showTypes) {
-    JSONArray jsonList = new JSONArray();
-    for (Object item : list) {
-      if (item instanceof Element) {
-        jsonList.add(jsonFromElement((Element) item, propertyKeys,
-          showTypes ? GraphsonMode.EXTENDED : GraphsonMode.NORMAL));
-      } else if (item instanceof List) {
-        jsonList.add(createJSONList((List) item, propertyKeys, showTypes));
-      } else if (item instanceof Map) {
-        jsonList.add(createJSONMap((Map) item, propertyKeys, showTypes));
-      } else if (item != null && item.getClass().isArray()) {
-        jsonList.add(createJSONList(convertArrayToList(item), propertyKeys, showTypes));
-      } else if (item instanceof Set) {
-        throw new UnsupportedOperationException("Set property is not supported");
-      } else {
-        addObject(jsonList, item);
-      }
-    }
-    return jsonList;
-  }
-
-  //
-  private static JSONObject createJSONMap(Map<Object, Object> map, Set<String> propertyKeys, boolean showTypes) {
-    JSONObject jsonMap = new JSONObject();
-    for (Map.Entry<Object, Object> entry : map.entrySet()) {
-      Object value = entry.getValue();
-      if (value != null) {
-        if (value instanceof List) {
-          value = createJSONList((List) value, propertyKeys, showTypes);
-        } else if (value instanceof Map) {
-          value = createJSONMap((Map) value, propertyKeys, showTypes);
-        } else if (value instanceof Element) {
-          value = jsonFromElement((Element) value, propertyKeys,
-            showTypes ? GraphsonMode.EXTENDED : GraphsonMode.NORMAL);
-        } else if (value.getClass().isArray()) {
-          value = createJSONList(convertArrayToList(value), propertyKeys, showTypes);
-        }
-      }
-
-      putObject(jsonMap, entry.getKey().toString(), getValue(value, showTypes));
-    }
-    return jsonMap;
-
-  }
-
-  private static Object readProperty(Object node, boolean hasEmbeddedTypes) {
-    Object propertyValue;
-
-    if (hasEmbeddedTypes) {
-      JSONObject json = (JSONObject) node;
-      if (json.get(GraphsonTokens.TYPE).equals(GraphsonTokens.TYPE_UNKNOWN)) {
-        propertyValue = null;
-      } else if (json.get(GraphsonTokens.TYPE).equals(GraphsonTokens.TYPE_BOOLEAN)) {
-        propertyValue = json.get(GraphsonTokens.VALUE);
-      } else if (json.get(GraphsonTokens.TYPE).equals(GraphsonTokens.TYPE_FLOAT)) {
-        propertyValue = ((Double) json.get(GraphsonTokens.VALUE)).floatValue();
-      } else if (json.get(GraphsonTokens.TYPE).equals(GraphsonTokens.TYPE_DOUBLE)) {
-        propertyValue = json.get(GraphsonTokens.VALUE);
-      } else if (json.get(GraphsonTokens.TYPE).equals(GraphsonTokens.TYPE_INTEGER)) {
-        propertyValue = ((Long) json.get(GraphsonTokens.VALUE)).intValue();
-      } else if (json.get(GraphsonTokens.TYPE).equals(GraphsonTokens.TYPE_LONG)) {
-        propertyValue = json.get(GraphsonTokens.VALUE);
-      } else if (json.get(GraphsonTokens.TYPE).equals(GraphsonTokens.TYPE_STRING)) {
-        propertyValue = json.get(GraphsonTokens.VALUE);
-      } else if (json.get(GraphsonTokens.TYPE).equals(GraphsonTokens.TYPE_LIST)) {
-        propertyValue = readProperties(((JSONArray) json.get(GraphsonTokens.VALUE)).iterator(), hasEmbeddedTypes);
-      } else if (json.get(GraphsonTokens.TYPE).equals(GraphsonTokens.TYPE_MAP)) {
-        propertyValue = readProperties((JSONObject) json.get(GraphsonTokens.VALUE), false, hasEmbeddedTypes);
-      } else {
-        propertyValue = node.toString();
-      }
-    } else {
-      if (node == null) {
-        propertyValue = null;
-      } else if (node instanceof Boolean) {
-        propertyValue = node;
-      } else if (node instanceof Double) {
-        propertyValue = node;
-      } else if (node instanceof Integer) {
-        propertyValue = node;
-      } else if (node instanceof Long) {
-        propertyValue = node;
-      } else if (node instanceof String) {
-        propertyValue = node;
-      } else if (node instanceof JSONArray) {
-        propertyValue = readProperties(((JSONArray) node).iterator(), hasEmbeddedTypes);
-      } else if (node instanceof JSONObject) {
-        propertyValue = readProperties((JSONObject) node, false, hasEmbeddedTypes);
-      } else {
-        propertyValue = node;
-      }
-    }
-
-    return propertyValue;
-  }
-
-  private static void putObject(JSONObject jsonMap, String key, Object value) {
-    if (value == null) {
-      jsonMap.put(key, null);
-    } else if (value instanceof Boolean) {
-      jsonMap.put(key, value);
-    } else if (value instanceof Long) {
-      jsonMap.put(key, value);
-    } else if (value instanceof Integer) {
-      jsonMap.put(key, value);
-    } else if (value instanceof Float) {
-      jsonMap.put(key, value);
-    } else if (value instanceof Double) {
-      jsonMap.put(key, value);
-    } else if (value instanceof String) {
-      jsonMap.put(key, value);
-    } else if (value instanceof JSONObject) {
-      jsonMap.put(key, value);
-    } else if (value instanceof JSONArray) {
-      jsonMap.put(key, value);
-    } else {
-      jsonMap.put(key, value.toString());
-    }
-  }
-
-  private static List readProperties(Iterator<JSONObject> listOfNodes, boolean hasEmbeddedTypes) {
-    List array = new ArrayList();
-
-    while (listOfNodes.hasNext()) {
-      array.add(readProperty(listOfNodes.next(), hasEmbeddedTypes));
-    }
-
-    return array;
-  }
-
-  private static void addObject(JSONArray jsonList, Object value) {
-    if (value == null) {
-      jsonList.add(null);
-    } else if (value instanceof Boolean) {
-      jsonList.add(value);
-    } else if (value instanceof Long) {
-      jsonList.add(value);
-    } else if (value instanceof Integer) {
-      jsonList.add(value);
-    } else if (value instanceof Float) {
-      jsonList.add(value);
-    } else if (value instanceof Double) {
-      jsonList.add(value);
-    } else if (value instanceof String) {
-      jsonList.add(value);
-    } else if (value instanceof JSONObject) {
-      jsonList.add(value);
-    } else if (value instanceof JSONArray) {
-      jsonList.add(value);
-    } else {
-      jsonList.add(value.toString());
-    }
-  }
-
-  private static Map createPropertyMap(Element element, Set<String> propertyKeys, ElementPropertiesRule rule) {
-    Map map = new HashMap<>();
-
-    if (propertyKeys == null) {
-      for (String key : element.getPropertyKeys()) {
-        map.put(key, element.getProperty(key));
-      }
-    } else {
-      if (rule == ElementPropertiesRule.INCLUDE) {
-        for (String key : propertyKeys) {
-          Object valToPutInMap = element.getProperty(key);
-          if (valToPutInMap != null) {
-            map.put(key, valToPutInMap);
-          }
-        }
-      } else {
-        for (String key : element.getPropertyKeys()) {
-          if (!propertyKeys.contains(key)) {
-            map.put(key, element.getProperty(key));
-          }
-        }
-      }
-    }
-
-    return map;
-  }
-
-  private static Object getValue(Object value, boolean includeType) {
-
-    Object returnValue = value;
-
-    // if the includeType is set to true then show the data types of the properties
-    if (includeType) {
-
-      // type will be one of: map, list, string, long, int, double, float.
-      // in the event of a complex object it will call a toString and store as a
-      // string
-      String type = determineType(value);
-
-      JSONObject valueAndType = new JSONObject();
-      valueAndType.put(GraphsonTokens.TYPE, type);
-
-      if (type.equals(GraphsonTokens.TYPE_LIST)) {
-
-        // values of lists must be accumulated as ObjectNode objects under the value key.
-        // will return as a ArrayNode. called recursively to traverse the entire
-        // object graph of each item in the array.
-        JSONArray list = (JSONArray) value;
-
-        // there is a set of values that must be accumulated as an array under a key
-        JSONArray valueArray = new JSONArray();
-        valueAndType.put(GraphsonTokens.VALUE, valueArray);
-        for (int ix = 0; ix < list.size(); ix++) {
-          // the value of each item in the array is a node object from an ArrayNode...must
-          // get the value of it.
-          addObject(valueArray, getValue(list.get(ix), includeType));
-        }
-
-      } else if (type.equals(GraphsonTokens.TYPE_MAP)) {
-
-        // maps are converted to a ObjectNode. called recursively to traverse
-        // the entire object graph within the map.
-        JSONObject convertedMap = new JSONObject();
-        JSONObject jsonObject = (JSONObject) value;
-
-        Map<Object, Object> jsonObjectMap = jsonObject;
-        for (Map.Entry<Object, Object> entry : jsonObjectMap.entrySet()) {
-
-          // no need to getValue() here as this is already a ObjectNode and should have type info
-          convertedMap.put(entry.getKey(), entry.getValue());
-        }
-
-        valueAndType.put(GraphsonTokens.VALUE, convertedMap);
-
-      } else {
-
-        // this must be a primitive value or a complex object. if a complex
-        // object it will be handled by a call to toString and stored as a
-        // string value
-        putObject(valueAndType, GraphsonTokens.VALUE, value);
-      }
-
-      // this goes back as a JSONObject with data type and value
-      returnValue = valueAndType;
-    }
-
-    return returnValue;
-  }
-
-  private static List convertArrayToList(Object value) {
-
-    // is there seriously no better way to do this...bah!
-    List list = new ArrayList();
-    if (value instanceof int[]) {
-      int[] arr = (int[]) value;
-      for (int ix = 0; ix < arr.length; ix++) {
-        list.add(arr[ix]);
-      }
-    } else if (value instanceof double[]) {
-      double[] arr = (double[]) value;
-      for (int ix = 0; ix < arr.length; ix++) {
-        list.add(arr[ix]);
-      }
-    } else if (value instanceof float[]) {
-      float[] arr = (float[]) value;
-      for (int ix = 0; ix < arr.length; ix++) {
-        list.add(arr[ix]);
-      }
-    } else if (value instanceof long[]) {
-      long[] arr = (long[]) value;
-      for (int ix = 0; ix < arr.length; ix++) {
-        list.add(arr[ix]);
-      }
-    } else if (value instanceof boolean[]) {
-      boolean[] arr = (boolean[]) value;
-      for (int ix = 0; ix < arr.length; ix++) {
-        list.add(arr[ix]);
-      }
-    } else {
-      list = Arrays.asList((Object[]) value);
-    }
-
-    return list;
-  }
-
-  private static String determineType(Object value) {
-    String type = GraphsonTokens.TYPE_STRING;
-    if (value == null) {
-      type = "unknown";
-    } else if (value instanceof Double) {
-      type = GraphsonTokens.TYPE_DOUBLE;
-    } else if (value instanceof Float) {
-      type = GraphsonTokens.TYPE_FLOAT;
-    } else if (value instanceof Integer) {
-      type = GraphsonTokens.TYPE_INTEGER;
-    } else if (value instanceof Long) {
-      type = GraphsonTokens.TYPE_LONG;
-    } else if (value instanceof Boolean) {
-      type = GraphsonTokens.TYPE_BOOLEAN;
-    } else if (value instanceof JSONArray) {
-      type = GraphsonTokens.TYPE_LIST;
-    } else if (value instanceof JSONObject) {
-      type = GraphsonTokens.TYPE_MAP;
-    }
-
-    return type;
-  }
-
-  /**
-   * Creates a vertex from GraphSON using settings supplied in the constructor.
-   */
-  Vertex vertexFromJson(InputStream json) throws ParseException, IOException {
-    return this.vertexFromJson((JSONObject) parser.parse(new InputStreamReader(json, StandardCharsets.UTF_8)));
-  }
-
-  /**
-   * Creates an edge from GraphSON using settings supplied in the constructor.
-   */
-  Edge edgeFromJson(String json, Vertex out, Vertex in) throws IOException, ParseException {
-    return this.edgeFromJson((JSONObject) parser.parse(json), out, in);
-  }
-
-  /**
-   * Creates an edge from GraphSON using settings supplied in the constructor.
-   */
-  Edge edgeFromJson(InputStream json, Vertex out, Vertex in) throws IOException, ParseException {
-    return this.edgeFromJson((JSONObject) parser.parse(new InputStreamReader(json, StandardCharsets.UTF_8)), out, in);
-  }
-
-  /**
-   * Creates an edge from GraphSON using settings supplied in the constructor.
-   */
-  Edge edgeFromJson(JSONObject json, Vertex out, Vertex in) throws IOException {
-    Map<String, Object> props = GraphsonUtil.readProperties(json, true, this.hasEmbeddedTypes);
-
-    Object edgeId = json.get(GraphsonTokens._ID);
-
-    Object nodeLabel = json.get(GraphsonTokens._LABEL);
-    String label = nodeLabel == null ? null : nodeLabel.toString();
-
-    Edge e = factory.createEdge(edgeId, out, in, label);
-
-    for (Map.Entry<String, Object> entry : props.entrySet()) {
-      if (includeKey(entry.getKey(), edgePropertyKeys, this.edgePropertiesRule)) {
-        e.setProperty(entry.getKey(), entry.getValue());
-      }
-    }
-
-    return e;
-  }
-
-  /**
-   * Creates a vertex from GraphSON using settings supplied in the constructor.
-   */
-  Vertex vertexFromJson(String json) throws ParseException {
-    return this.vertexFromJson((JSONObject) parser.parse(json));
-  }
-
-  /**
-   * Creates a vertex from GraphSON using settings supplied in the constructor.
-   */
-  Vertex vertexFromJson(JSONObject json) {
-    Map<String, Object> props = readProperties(json, true, this.hasEmbeddedTypes);
-
-    Object vertexId = json.get(GraphsonTokens._ID);
-    Vertex v = factory.createVertex(vertexId);
-
-    for (Map.Entry<String, Object> entry : props.entrySet()) {
-      if (includeKey(entry.getKey(), vertexPropertyKeys, this.vertexPropertiesRule)) {
-        v.setProperty(entry.getKey(), entry.getValue());
-      }
-    }
-
-    return v;
-  }
-
-  /**
-   * Creates GraphSON for a single graph element.
-   */
-  JSONObject jsonFromElement(Element element) {
-    boolean isEdge = element instanceof Edge;
-    boolean showTypes = mode == GraphsonMode.EXTENDED;
-    Set<String> propertyKeys = isEdge ? this.edgePropertyKeys : this.vertexPropertyKeys;
-    ElementPropertiesRule elementPropertyConfig = isEdge ? this.edgePropertiesRule : this.vertexPropertiesRule;
-
-    JSONObject jsonElement = createJSONMap(createPropertyMap(element, propertyKeys, elementPropertyConfig), propertyKeys, showTypes);
-
-    if ((isEdge && this.includeReservedEdgeId) || (!isEdge && this.includeReservedVertexId)) {
-      putObject(jsonElement, GraphsonTokens._ID, element.getId());
-    }
-
-    // it's important to keep the order of these straight. check Edge first and then Vertex because there
-    // are graph implementations that have Edge extend from Vertex
-    if (element instanceof Edge) {
-      Edge edge = (Edge) element;
-
-      if (this.includeReservedEdgeId) {
-        putObject(jsonElement, GraphsonTokens._ID, element.getId());
-      }
-
-      if (this.includeReservedEdgeType) {
-        jsonElement.put(GraphsonTokens._TYPE, GraphsonTokens.EDGE);
-      }
-
-      if (this.includeReservedEdgeOutV) {
-        putObject(jsonElement, GraphsonTokens._OUT_V, edge.getVertex(Direction.OUT).getId());
-      }
-
-      if (this.includeReservedEdgeInV) {
-        putObject(jsonElement, GraphsonTokens._IN_V, edge.getVertex(Direction.IN).getId());
-      }
-
-      if (this.includeReservedEdgeLabel) {
-        jsonElement.put(GraphsonTokens._LABEL, edge.getLabel());
-      }
-    } else if (element instanceof Vertex) {
-      if (this.includeReservedVertexId) {
-        putObject(jsonElement, GraphsonTokens._ID, element.getId());
-      }
-
-      if (this.includeReservedVertexType) {
-        jsonElement.put(GraphsonTokens._TYPE, GraphsonTokens.VERTEX);
-      }
-    }
-
-    return jsonElement;
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphsonWriter.java b/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphsonWriter.java
deleted file mode 100644 (file)
index 90d7b2c..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.graph.graphson;
-
-import com.tinkerpop.blueprints.Edge;
-import com.tinkerpop.blueprints.Graph;
-import com.tinkerpop.blueprints.Vertex;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-
-import javax.annotation.Nullable;
-
-import java.io.Writer;
-import java.util.Set;
-
-public class GraphsonWriter {
-
-  public void write(Graph graph, Writer output, GraphsonMode mode) {
-    write(graph, output, mode, null, null);
-  }
-
-  /**
-   * Write the data in a Graph to a JSON OutputStream.
-   *
-   * @param output             the JSON Writer to write the Graph data to
-   * @param vertexPropertyKeys the keys of the vertex elements to write to JSON
-   * @param edgePropertyKeys   the keys of the edge elements to write to JSON
-   * @param mode               determines the format of the GraphSON
-   * @throws java.io.IOException thrown if there is an error generating the JSON data
-   */
-  public void write(Graph graph, Writer output, GraphsonMode mode, @Nullable Set<String> vertexPropertyKeys, @Nullable Set<String> edgePropertyKeys) {
-    try {
-      JSONObject root = new JSONObject();
-      GraphsonUtil graphson = new GraphsonUtil(mode, null, vertexPropertyKeys, edgePropertyKeys);
-
-      root.put(GraphsonTokens.MODE, mode.toString());
-
-      JSONArray verticesArray = new JSONArray();
-      for (Vertex v : graph.getVertices()) {
-        verticesArray.add(graphson.jsonFromElement(v));
-      }
-      root.put(GraphsonTokens.VERTICES, verticesArray);
-
-      JSONArray edgesArray = new JSONArray();
-      for (Edge e : graph.getEdges()) {
-        edgesArray.add(graphson.jsonFromElement(e));
-      }
-      root.put(GraphsonTokens.EDGES, edgesArray);
-
-      output.write(root.toString());
-    } catch (Exception e) {
-      throw new GraphsonException("Fail to generate GraphSON", e);
-    }
-  }
-
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/package-info.java b/sonar-core/src/main/java/org/sonar/core/graph/package-info.java
deleted file mode 100644 (file)
index aa8af89..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-@ParametersAreNonnullByDefault
-package org.sonar.core.graph;
-
-import javax.annotation.ParametersAreNonnullByDefault;
index d94752036220061b06902f773825605220612809..c933f606dcb956fd8c616dacc9b2cd71781614ea 100644 (file)
 
 package org.sonar.core.persistence;
 
+import ch.qos.logback.classic.Level;
+import com.google.common.io.Closeables;
 import java.io.InputStream;
-
 import javax.annotation.Nullable;
-
 import org.apache.ibatis.builder.xml.XMLMapperBuilder;
 import org.apache.ibatis.logging.LogFactory;
 import org.apache.ibatis.mapping.Environment;
@@ -139,10 +139,6 @@ import org.sonar.core.user.UserGroupMapper;
 import org.sonar.core.user.UserMapper;
 import org.sonar.core.user.UserRoleDto;
 
-import ch.qos.logback.classic.Level;
-
-import com.google.common.io.Closeables;
-
 @BatchSide
 @ServerSide
 public class MyBatis {
diff --git a/sonar-core/src/main/java/org/sonar/core/test/DefaultCoverageBlock.java b/sonar-core/src/main/java/org/sonar/core/test/DefaultCoverageBlock.java
deleted file mode 100644 (file)
index d2d10cc..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.test;
-
-import com.tinkerpop.blueprints.Direction;
-import org.sonar.api.test.CoverageBlock;
-import org.sonar.api.test.TestCase;
-import org.sonar.api.test.Testable;
-import org.sonar.core.graph.BeanEdge;
-
-import java.util.List;
-
-public class DefaultCoverageBlock extends BeanEdge implements CoverageBlock {
-
-  @Override
-  public TestCase testCase() {
-    return getVertex(DefaultTestCase.class, Direction.OUT);
-  }
-
-  @Override
-  public Testable testable() {
-    return getVertex(DefaultTestable.class, Direction.IN);
-  }
-
-  @Override
-  public List<Integer> lines() {
-    return (List<Integer>) getProperty("lines");
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/test/DefaultTestCase.java b/sonar-core/src/main/java/org/sonar/core/test/DefaultTestCase.java
deleted file mode 100644 (file)
index 3f8c8e8..0000000
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.test;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-import com.tinkerpop.blueprints.Direction;
-import com.tinkerpop.blueprints.Edge;
-import com.tinkerpop.blueprints.Vertex;
-import org.sonar.api.test.CoverageBlock;
-import org.sonar.api.test.MutableTestCase;
-import org.sonar.api.test.TestPlan;
-import org.sonar.api.test.Testable;
-import org.sonar.api.test.exception.CoverageAlreadyExistsException;
-import org.sonar.api.test.exception.IllegalDurationException;
-import org.sonar.core.graph.BeanVertex;
-import org.sonar.core.graph.GraphUtil;
-
-import javax.annotation.Nullable;
-
-import java.util.List;
-
-public class DefaultTestCase extends BeanVertex implements MutableTestCase {
-
-  private static final String DURATION = "duration";
-  private static final String TYPE = "type";
-  private static final String STATUS = "status";
-  private static final String NAME = "name";
-  private static final String MESSAGE = "message";
-  private static final String STACK_TRACE = "stackTrace";
-  private static final String COVERS = "covers";
-  private static final String LINES = "lines";
-  private static final String TESTCASE = "testcase";
-
-  @Override
-  public String type() {
-    return (String) getProperty(TYPE);
-  }
-
-  @Override
-  public MutableTestCase setType(@Nullable String s) {
-    setProperty(TYPE, s);
-    return this;
-  }
-
-  @Override
-  public Long durationInMs() {
-    return (Long) getProperty(DURATION);
-  }
-
-  @Override
-  public MutableTestCase setDurationInMs(@Nullable Long l) {
-    if (l != null && l < 0) {
-      throw new IllegalDurationException("Test duration must be positive (got: " + l + ")");
-    }
-    setProperty(DURATION, l);
-    return this;
-  }
-
-  @Override
-  public Status status() {
-    return Status.of((String) getProperty(STATUS));
-  }
-
-  @Override
-  public MutableTestCase setStatus(@Nullable Status s) {
-    setProperty(STATUS, s == null ? null : s.name());
-    return this;
-  }
-
-  @Override
-  public String name() {
-    return (String) getProperty(NAME);
-  }
-
-  public MutableTestCase setName(String s) {
-    setProperty(NAME, s);
-    return this;
-  }
-
-  @Override
-  public String message() {
-    return (String) getProperty(MESSAGE);
-  }
-
-  @Override
-  public MutableTestCase setMessage(String s) {
-    setProperty(MESSAGE, s);
-    return this;
-  }
-
-  @Override
-  public String stackTrace() {
-    return (String) getProperty(STACK_TRACE);
-  }
-
-  @Override
-  public MutableTestCase setStackTrace(String s) {
-    setProperty(STACK_TRACE, s);
-    return this;
-  }
-
-  @Override
-  public MutableTestCase setCoverageBlock(Testable testable, List<Integer> lines) {
-    if (coverageBlock(testable) != null) {
-      throw new CoverageAlreadyExistsException("The link between " + name() + " and " + testable.component().key() + " already exists");
-    }
-    beanGraph().getUnderlyingGraph().addEdge(null, element(), ((BeanVertex) testable).element(), COVERS).setProperty(LINES, lines);
-    return this;
-  }
-
-  @Override
-  public TestPlan testPlan() {
-    Vertex plan = GraphUtil.singleAdjacent(element(), Direction.IN, TESTCASE);
-    return beanGraph().wrap(plan, DefaultTestPlan.class);
-  }
-
-  @Override
-  public boolean doesCover() {
-    return edgeCovers().iterator().hasNext();
-  }
-
-  @Override
-  public int countCoveredLines() {
-    int result = 0;
-    for (Edge edge : edgeCovers()) {
-      List<Integer> lines = (List<Integer>) edge.getProperty(LINES);
-      result = result + lines.size();
-    }
-    return result;
-  }
-
-  @Override
-  public Iterable<CoverageBlock> coverageBlocks() {
-    return (Iterable) getEdges(DefaultCoverageBlock.class, Direction.OUT, COVERS);
-  }
-
-  @Override
-  public CoverageBlock coverageBlock(final Testable testable) {
-    return Iterables.find(getEdges(DefaultCoverageBlock.class, Direction.OUT, COVERS), new Predicate<CoverageBlock>() {
-      @Override
-      public boolean apply(CoverageBlock input) {
-        return input.testable().component().key().equals(testable.component().key());
-      }
-    }, null);
-  }
-
-  private Iterable<Edge> edgeCovers() {
-    return element().query().labels(COVERS).direction(Direction.OUT).edges();
-  }
-
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/test/DefaultTestPlan.java b/sonar-core/src/main/java/org/sonar/core/test/DefaultTestPlan.java
deleted file mode 100644 (file)
index b701dc2..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.test;
-
-import com.google.common.collect.Lists;
-import com.tinkerpop.blueprints.Direction;
-import com.tinkerpop.blueprints.Vertex;
-import org.sonar.api.component.Component;
-import org.sonar.api.test.MutableTestCase;
-import org.sonar.api.test.MutableTestPlan;
-import org.sonar.core.component.ComponentVertex;
-import org.sonar.core.graph.BeanVertex;
-import org.sonar.core.graph.GraphUtil;
-
-import javax.annotation.CheckForNull;
-
-import java.util.List;
-
-public class DefaultTestPlan extends BeanVertex implements MutableTestPlan {
-  private static final String TESTCASE = "testcase";
-
-  @Override
-  public Component component() {
-    Vertex component = GraphUtil.singleAdjacent(element(), Direction.IN, "testplan");
-    return beanGraph().wrap(component, ComponentVertex.class);
-  }
-
-  @Override
-  @CheckForNull
-  public Iterable<MutableTestCase> testCasesByName(String name) {
-    List<MutableTestCase> result = Lists.newArrayList();
-    for (MutableTestCase testCase : testCases()) {
-      if (name.equals(testCase.name())) {
-        result.add(testCase);
-      }
-    }
-    return result;
-  }
-
-  @Override
-  public MutableTestCase addTestCase(String name) {
-    DefaultTestCase testCase = beanGraph().createAdjacentVertex(this, DefaultTestCase.class, TESTCASE);
-    testCase.setName(name);
-    return testCase;
-  }
-
-  @Override
-  public Iterable<MutableTestCase> testCases() {
-    return (Iterable) getVertices(DefaultTestCase.class, Direction.OUT, TESTCASE);
-  }
-
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/test/DefaultTestable.java b/sonar-core/src/main/java/org/sonar/core/test/DefaultTestable.java
deleted file mode 100644 (file)
index 33e118a..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.test;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSortedSet;
-import com.google.common.collect.Iterables;
-import com.tinkerpop.blueprints.Direction;
-import com.tinkerpop.blueprints.Edge;
-import com.tinkerpop.blueprints.Vertex;
-import org.sonar.api.component.Component;
-import org.sonar.api.test.CoverageBlock;
-import org.sonar.api.test.MutableTestable;
-import org.sonar.api.test.TestCase;
-import org.sonar.core.component.ComponentVertex;
-import org.sonar.core.graph.BeanVertex;
-import org.sonar.core.graph.GraphUtil;
-
-import java.util.List;
-import java.util.Map;
-import java.util.SortedSet;
-
-import static com.google.common.collect.Maps.newHashMap;
-
-public class DefaultTestable extends BeanVertex implements MutableTestable {
-
-  private static final String COVERS = "covers";
-
-  @Override
-  public Component component() {
-    Vertex component = GraphUtil.singleAdjacent(element(), Direction.IN, "testable");
-    return beanGraph().wrap(component, ComponentVertex.class);
-  }
-
-  @Override
-  public List<TestCase> testCases() {
-    ImmutableList.Builder<TestCase> cases = ImmutableList.builder();
-    for (Edge coversEdge : coverEdges()) {
-      Vertex testable = coversEdge.getVertex(Direction.OUT);
-      cases.add(beanGraph().wrap(testable, DefaultTestCase.class));
-    }
-    return cases.build();
-  }
-
-  @Override
-  public TestCase testCaseByName(final String name) {
-    return Iterables.find(testCases(), new Predicate<TestCase>() {
-      @Override
-      public boolean apply(TestCase input) {
-        return input.name().equals(name);
-      }
-    }, null);
-  }
-
-  @Override
-  public int countTestCasesOfLine(Integer line) {
-    int number = 0;
-    for (Edge edge : coverEdges()) {
-      if (Iterables.contains(lines(edge), line)) {
-        number++;
-      }
-    }
-    return number;
-  }
-
-  @Override
-  public Map<Integer, Integer> testCasesByLines() {
-    Map<Integer, Integer> testCasesByLines = newHashMap();
-    for (Integer line : testedLines()) {
-      testCasesByLines.put(line, countTestCasesOfLine(line));
-    }
-    return testCasesByLines;
-  }
-
-  @Override
-  public List<TestCase> testCasesOfLine(int line) {
-    ImmutableList.Builder<TestCase> cases = ImmutableList.builder();
-    for (Edge edge : coverEdges()) {
-      if (lines(edge).contains(line)) {
-        Vertex vertexTestable = edge.getVertex(Direction.OUT);
-        DefaultTestCase testCase = beanGraph().wrap(vertexTestable, DefaultTestCase.class);
-        cases.add(testCase);
-      }
-    }
-    return cases.build();
-  }
-
-  @Override
-  public SortedSet<Integer> testedLines() {
-    ImmutableSortedSet.Builder<Integer> coveredLines = ImmutableSortedSet.naturalOrder();
-    for (Edge edge : coverEdges()) {
-      coveredLines.addAll(lines(edge));
-    }
-    return coveredLines.build();
-  }
-
-  @Override
-  public CoverageBlock coverageBlock(final TestCase testCase) {
-    return Iterables.find(getEdges(DefaultCoverageBlock.class, Direction.IN, COVERS), new Predicate<CoverageBlock>() {
-      @Override
-      public boolean apply(CoverageBlock input) {
-        return input.testCase().name().equals(testCase.name());
-      }
-    }, null);
-  }
-
-  @Override
-  public Iterable<CoverageBlock> coverageBlocks() {
-    return (Iterable) getEdges(DefaultCoverageBlock.class, Direction.IN, COVERS);
-  }
-
-  private Iterable<Edge> coverEdges() {
-    return element().query().labels(COVERS).direction(Direction.IN).edges();
-  }
-
-  private List<Integer> lines(Edge edge) {
-    return (List<Integer>) edge.getProperty("lines");
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/test/TestPlanBuilder.java b/sonar-core/src/main/java/org/sonar/core/test/TestPlanBuilder.java
deleted file mode 100644 (file)
index 2bdbe71..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.test;
-
-import com.tinkerpop.blueprints.Direction;
-import org.sonar.api.test.MutableTestPlan;
-import org.sonar.core.component.GraphPerspectiveBuilder;
-import org.sonar.core.component.ScanGraph;
-import org.sonar.core.graph.EdgePath;
-
-public class TestPlanBuilder extends GraphPerspectiveBuilder<MutableTestPlan> {
-
-  private static final EdgePath PATH = EdgePath.create(
-    Direction.OUT, "testplan",
-    Direction.OUT, "testcase",
-    Direction.OUT, "covers",
-    Direction.IN, "testable"
-  );
-
-  public TestPlanBuilder(ScanGraph graph, TestPlanPerspectiveLoader perspectiveLoader) {
-    super(graph, MutableTestPlan.class, PATH, perspectiveLoader);
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/test/TestPlanPerspectiveLoader.java b/sonar-core/src/main/java/org/sonar/core/test/TestPlanPerspectiveLoader.java
deleted file mode 100644 (file)
index 059946a..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.test;
-
-import org.sonar.api.test.MutableTestPlan;
-import org.sonar.core.component.GraphPerspectiveLoader;
-import org.sonar.core.graph.BeanVertex;
-
-public class TestPlanPerspectiveLoader extends GraphPerspectiveLoader<MutableTestPlan> {
-
-  static final String PERSPECTIVE_KEY = "testplan";
-
-  public TestPlanPerspectiveLoader() {
-    super(PERSPECTIVE_KEY, MutableTestPlan.class);
-  }
-
-  @Override
-  protected Class<? extends BeanVertex> getBeanClass() {
-    return DefaultTestPlan.class;
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/test/TestableBuilder.java b/sonar-core/src/main/java/org/sonar/core/test/TestableBuilder.java
deleted file mode 100644 (file)
index 07df06f..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.test;
-
-import com.tinkerpop.blueprints.Direction;
-import org.sonar.api.test.MutableTestable;
-import org.sonar.core.component.GraphPerspectiveBuilder;
-import org.sonar.core.component.ScanGraph;
-import org.sonar.core.graph.EdgePath;
-
-public class TestableBuilder extends GraphPerspectiveBuilder<MutableTestable> {
-
-  private static final EdgePath PATH = EdgePath.create(
-    Direction.OUT, "testable",
-    Direction.IN,"covers",
-    Direction.IN,"testcase",
-    Direction.IN,"testplan"
-  );
-
-  public TestableBuilder(ScanGraph graph, TestablePerspectiveLoader perspectiveLoader) {
-    super(graph, MutableTestable.class, PATH, perspectiveLoader);
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/test/TestablePerspectiveLoader.java b/sonar-core/src/main/java/org/sonar/core/test/TestablePerspectiveLoader.java
deleted file mode 100644 (file)
index ced3aa5..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.test;
-
-import org.sonar.api.test.MutableTestable;
-import org.sonar.core.component.GraphPerspectiveLoader;
-import org.sonar.core.graph.BeanVertex;
-
-public class TestablePerspectiveLoader extends GraphPerspectiveLoader<MutableTestable> {
-
-  static final String PERSPECTIVE_KEY = "testable";
-
-  public TestablePerspectiveLoader() {
-    super(PERSPECTIVE_KEY, MutableTestable.class);
-  }
-
-  @Override
-  protected Class<? extends BeanVertex> getBeanClass() {
-    return DefaultTestable.class;
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/test/package-info.java b/sonar-core/src/main/java/org/sonar/core/test/package-info.java
deleted file mode 100644 (file)
index aff214e..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-@ParametersAreNonnullByDefault
-package org.sonar.core.test;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/sonar-core/src/test/java/org/sonar/core/component/ComponentVertexTest.java b/sonar-core/src/test/java/org/sonar/core/component/ComponentVertexTest.java
deleted file mode 100644 (file)
index ac0c157..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.component;
-
-import com.tinkerpop.blueprints.impls.tg.TinkerGraph;
-import org.junit.Test;
-import org.sonar.api.component.Component;
-import org.sonar.api.component.mock.MockSourceFile;
-import org.sonar.api.resources.Qualifiers;
-import org.sonar.core.graph.BeanGraph;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class ComponentVertexTest {
-  @Test
-  public void should_copy() {
-    BeanGraph beanGraph = new BeanGraph(new TinkerGraph());
-    ComponentVertex vertex = beanGraph.createVertex(ComponentVertex.class);
-    Component file = MockSourceFile.createMain("myproject:org/Foo.java").setName("Foo.java").setQualifier(Qualifiers.FILE)
-      .setPath("src/org/Foo.java");
-
-    vertex.copyFrom(file);
-
-    assertThat(vertex.key()).isEqualTo("myproject:org/Foo.java");
-    assertThat(vertex.name()).isEqualTo("Foo.java");
-    assertThat(vertex.qualifier()).isEqualTo(Qualifiers.FILE);
-    assertThat(vertex.path()).isEqualTo("src/org/Foo.java");
-  }
-}
diff --git a/sonar-core/src/test/java/org/sonar/core/component/GraphPerspectiveBuilderTest.java b/sonar-core/src/test/java/org/sonar/core/component/GraphPerspectiveBuilderTest.java
deleted file mode 100644 (file)
index d699dc6..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.core.component;
-
-import org.junit.Test;
-import org.sonar.api.component.Component;
-import org.sonar.api.component.MutablePerspective;
-import org.sonar.api.component.Perspective;
-import org.sonar.api.component.mock.MockSourceFile;
-import org.sonar.core.graph.BeanVertex;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class GraphPerspectiveBuilderTest {
-
-  @Test
-  public void should_return_null_on_null_component() {
-
-    String componentKey = "org.foo.Bar";
-
-    Component component = mock(Component.class);
-    when(component.key()).thenReturn(componentKey);
-
-    ScanGraph graph = mock(ScanGraph.class);
-    when(graph.getComponent(componentKey)).thenReturn(null);
-
-    GraphPerspectiveLoader perspectiveLoader = mock(GraphPerspectiveLoader.class);
-
-    GraphPerspectiveBuilder perspectiveBuilder =
-            new GraphPerspectiveBuilder(graph, MutablePerspective.class, null, perspectiveLoader) {};
-
-    Perspective loadedPerspective = perspectiveBuilder.loadPerspective(MutablePerspective.class, component);
-
-    assertThat(loadedPerspective).isNull();
-  }
-
-  @Test
-  public void should_load_perspective() {
-
-    ScanGraph graph = ScanGraph.create();
-    MutablePerspective expectedPerspective = mock(MutablePerspective.class);
-
-    ComponentVertex fileComponent = graph.addComponent(MockSourceFile.createMain("org.foo.Bar"));
-    GraphPerspectiveLoader perspectiveLoader = mock(GraphPerspectiveLoader.class);
-    when(perspectiveLoader.load(fileComponent)).thenReturn(expectedPerspective);
-
-    GraphPerspectiveBuilder perspectiveBuilder =
-            new GraphPerspectiveBuilder(graph, MutablePerspective.class, null, perspectiveLoader) {};
-
-    Perspective loadedPerspective = perspectiveBuilder.loadPerspective(MutablePerspective.class, fileComponent);
-
-    assertThat(loadedPerspective).isEqualTo(expectedPerspective);
-  }
-
-  @Test
-  public void should_create_perspective_when_loaded_one_is_null() {
-
-    String perspectiveKey = "perspectiveKey";
-
-    ScanGraph graph = ScanGraph.create();
-    ComponentVertex fileComponent = graph.addComponent(MockSourceFile.createMain("org.foo.Bar"));
-
-    GraphPerspectiveLoader<DefaultMutablePerspective> perspectiveLoader =
-            new GraphPerspectiveLoader<DefaultMutablePerspective>(perspectiveKey, DefaultMutablePerspective.class) {
-
-              @Override
-              public DefaultMutablePerspective load(ComponentVertex component) {
-                return null;
-              }
-
-              @Override
-              protected Class<? extends BeanVertex> getBeanClass() {
-                return DefaultMutablePerspective.class;
-              }
-            };
-
-    GraphPerspectiveBuilder perspectiveBuilder =
-            new GraphPerspectiveBuilder(graph, MutablePerspective.class, null, perspectiveLoader) {};
-
-    Perspective loadedPerspective = perspectiveBuilder.loadPerspective(MutablePerspective.class, fileComponent);
-
-    assertThat(loadedPerspective).isNotNull();
-    assertThat(loadedPerspective).isInstanceOf(DefaultMutablePerspective.class);
-  }
-
-  public static class DefaultMutablePerspective extends BeanVertex implements MutablePerspective {
-
-    @Override
-    public Component component() {
-      return null;
-    }
-  }
-}
diff --git a/sonar-core/src/test/java/org/sonar/core/component/PerspectiveBuilderTest.java b/sonar-core/src/test/java/org/sonar/core/component/PerspectiveBuilderTest.java
deleted file mode 100644 (file)
index d3bb105..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.component;
-
-import org.junit.Test;
-import org.sonar.api.component.Component;
-import org.sonar.api.component.Perspective;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class PerspectiveBuilderTest {
-  @Test
-  public void testGetPerspectiveClass() throws Exception {
-    PerspectiveBuilder<FakePerspective> builder = new PerspectiveBuilder<FakePerspective>(FakePerspective.class) {
-      @Override
-      public FakePerspective loadPerspective(Class<FakePerspective> perspectiveClass, Component component) {
-        return null;
-      }
-    };
-
-    assertThat(builder.getPerspectiveClass()).isEqualTo(FakePerspective.class);
-  }
-
-  static interface FakePerspective extends Perspective {
-
-  }
-}
diff --git a/sonar-core/src/test/java/org/sonar/core/component/ResourceComponentTest.java b/sonar-core/src/test/java/org/sonar/core/component/ResourceComponentTest.java
deleted file mode 100644 (file)
index f8723d8..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.component;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.api.resources.File;
-import org.sonar.api.resources.Resource;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.fail;
-
-public class ResourceComponentTest {
-
-  private Resource file;
-
-  @Before
-  public void prepare() {
-    file = File.create("foo.c").setEffectiveKey("myproject:path/to/foo.c");
-    file.setKey("path/to/foo.c");
-  }
-
-  @Test
-  public void should_use_effective_key() {
-    ResourceComponent component = new ResourceComponent(file);
-    assertThat(component.key()).isEqualTo("myproject:path/to/foo.c");
-  }
-
-  @Test
-  public void effective_key_should_be_set() {
-    try {
-      File file = File.create("foo.c");
-      new ResourceComponent(file);
-      fail();
-    } catch (IllegalArgumentException e) {
-      assertThat(e).hasMessage("Missing component key");
-    }
-  }
-}
diff --git a/sonar-core/src/test/java/org/sonar/core/graph/BeanElementTest.java b/sonar-core/src/test/java/org/sonar/core/graph/BeanElementTest.java
deleted file mode 100644 (file)
index 69fd68d..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.graph;
-
-import com.tinkerpop.blueprints.Vertex;
-import com.tinkerpop.blueprints.impls.tg.TinkerGraph;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class BeanElementTest {
-
-  BeanGraph beanGraph;
-  BeanVertex beanVertex;
-
-  @Before
-  public void before() {
-    TinkerGraph graph = new TinkerGraph();
-    beanGraph = new BeanGraph(graph);
-
-    Vertex vertex = graph.addVertex(null);
-    beanVertex = new BeanVertex() {
-    };
-    beanVertex.setElement(vertex);
-    beanVertex.setBeanGraph(beanGraph);
-  }
-
-  @Test
-  public void should_set_required_fields() {
-    assertThat(beanVertex.beanGraph()).isSameAs(beanGraph);
-    assertThat(beanVertex.element()).isInstanceOf(Vertex.class);
-  }
-
-  @Test
-  public void no_properties_by_default() {
-    assertThat(beanVertex.getProperty("color")).isNull();
-    assertThat(beanVertex.getProperty("code")).isNull();
-    assertThat(beanVertex.getProperty("alive")).isNull();
-    assertThat(beanVertex.getPropertyKeys()).isEmpty();
-  }
-
-  @Test
-  public void should_set_properties() {
-    beanVertex.setProperty("color", "red");
-    beanVertex.setProperty("code", 123);
-    beanVertex.setProperty("alive", true);
-
-    assertThat(beanVertex.getProperty("color")).isEqualTo("red");
-    assertThat(beanVertex.getProperty("code")).isEqualTo(123);
-    assertThat(beanVertex.getProperty("alive")).isEqualTo(true);
-    assertThat(beanVertex.getPropertyKeys()).containsOnly("color", "code", "alive");
-  }
-
-  @Test
-  public void should_unset_properties_with_null_values() {
-    beanVertex.setProperty("color", "red");
-    beanVertex.setProperty("code", 123);
-    beanVertex.setProperty("alive", true);
-
-    beanVertex.setProperty("color", null);
-    beanVertex.setProperty("code", null);
-    beanVertex.setProperty("alive", null);
-    beanVertex.setProperty("other", null);
-
-    assertThat(beanVertex.getProperty("color")).isNull();
-    assertThat(beanVertex.getProperty("code")).isNull();
-    assertThat(beanVertex.getProperty("alive")).isNull();
-    assertThat(beanVertex.getPropertyKeys()).isEmpty();
-  }
-
-  @Test
-  public void should_remove_property() {
-    beanVertex.setProperty("color", "red");
-    beanVertex.setProperty("code", 123);
-    beanVertex.setProperty("alive", true);
-
-    beanVertex.removeProperty("color");
-    beanVertex.removeProperty("code");
-    beanVertex.removeProperty("alive");
-    beanVertex.removeProperty("other");
-
-    assertThat(beanVertex.getProperty("color")).isNull();
-    assertThat(beanVertex.getProperty("code")).isNull();
-    assertThat(beanVertex.getProperty("alive")).isNull();
-    assertThat(beanVertex.getPropertyKeys()).isEmpty();
-  }
-}
diff --git a/sonar-core/src/test/java/org/sonar/core/graph/BeanElementsTest.java b/sonar-core/src/test/java/org/sonar/core/graph/BeanElementsTest.java
deleted file mode 100644 (file)
index eb5f4d0..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.graph;
-
-import com.tinkerpop.blueprints.Vertex;
-import com.tinkerpop.blueprints.impls.tg.TinkerGraph;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class BeanElementsTest {
-  TinkerGraph graph;
-  Vertex vertex;
-  BeanGraph beanGraph;
-  BeanVertex beanVertex;
-
-  @Rule
-  public ExpectedException thrown = ExpectedException.none();
-
-  @Before
-  public void before() {
-    graph = new TinkerGraph();
-    beanGraph = new BeanGraph(graph);
-
-    vertex = graph.addVertex(null);
-    beanVertex = new BeanVertex() {
-    };
-    beanVertex.setElement(vertex);
-    beanVertex.setBeanGraph(beanGraph);
-  }
-
-  @Test
-  public void should_wrap_vertex_into_bean() {
-    BeanElements elements = new BeanElements();
-    Person bean = elements.wrap(vertex, Person.class, beanGraph);
-
-    assertThat(bean).isNotNull();
-    assertThat(bean.element()).isSameAs(vertex);
-    assertThat(bean.beanGraph()).isSameAs(beanGraph);
-  }
-
-  @Test
-  public void should_keep_cache_of_beans() {
-    BeanElements elements = new BeanElements();
-    Person bean = elements.wrap(vertex, Person.class, beanGraph);
-    Person bean2 = elements.wrap(vertex, Person.class, beanGraph);
-
-    assertThat(bean).isSameAs(bean2);
-  }
-
-  @Test
-  public void should_wrap_different_elements() {
-    BeanElements elements = new BeanElements();
-    Vertex vertex2 = graph.addVertex(null);
-
-    Person bean = elements.wrap(vertex, Person.class, beanGraph);
-    Person bean2 = elements.wrap(vertex2, Person.class, beanGraph);
-
-    assertThat(bean).isNotNull();
-    assertThat(bean).isNotSameAs(bean2);
-  }
-
-  @Test
-  public void should_clear_cache() {
-    BeanElements elements = new BeanElements();
-
-    Person bean = elements.wrap(vertex, Person.class, beanGraph);
-    assertThat(bean).isNotNull();
-    elements.clear();
-
-    Person bean2 = elements.wrap(vertex, Person.class, beanGraph);
-    assertThat(bean2).isNotNull();
-    assertThat(bean2).isNotSameAs(bean);
-  }
-
-  @Test
-  public void element_could_be_wrapped_by_several_beans() {
-    BeanElements elements = new BeanElements();
-    Person person = elements.wrap(vertex, Person.class, beanGraph);
-    Job job = elements.wrap(vertex, Job.class, beanGraph);
-
-    assertThat(person).isNotSameAs(job);
-  }
-
-  @Test
-  public void bean_class_should_have_an_empty_constructor() {
-    thrown.expect(IllegalStateException.class);
-    thrown.expectMessage("Class has no default constructor: org.sonar.core.graph.BeanElementsTest$NoEmptyConstructor");
-
-    BeanElements elements = new BeanElements();
-    elements.wrap(vertex, NoEmptyConstructor.class, beanGraph);
-  }
-
-  @Test
-  public void bean_constructor_should_be_accessible() {
-    thrown.expect(IllegalStateException.class);
-    thrown.expectMessage("Can not access to default constructor: org.sonar.core.graph.BeanElementsTest$PrivateConstructor");
-
-    BeanElements elements = new BeanElements();
-    elements.wrap(vertex, PrivateConstructor.class, beanGraph);
-  }
-
-  static class Person extends BeanVertex {
-
-  }
-
-  static class Job extends BeanVertex {
-
-  }
-
-  static class NoEmptyConstructor extends BeanVertex {
-    private int i;
-
-    NoEmptyConstructor(int i) {
-      this.i = i;
-    }
-  }
-
-  static class PrivateConstructor extends BeanVertex {
-    private PrivateConstructor() {
-
-    }
-  }
-}
diff --git a/sonar-core/src/test/java/org/sonar/core/graph/BeanGraphTest.java b/sonar-core/src/test/java/org/sonar/core/graph/BeanGraphTest.java
deleted file mode 100644 (file)
index 8054f74..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.graph;
-
-import com.tinkerpop.blueprints.Direction;
-import com.tinkerpop.blueprints.Vertex;
-import com.tinkerpop.blueprints.impls.tg.TinkerGraph;
-import org.junit.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class BeanGraphTest {
-
-  @Test
-  public void should_get_underlying_graph() {
-    TinkerGraph graph = new TinkerGraph();
-    BeanGraph beanGraph = new BeanGraph(graph);
-
-    assertThat(beanGraph.getUnderlyingGraph()).isSameAs(graph);
-  }
-
-  @Test
-  public void should_create_bean_vertex() {
-    BeanGraph beanGraph = BeanGraph.createInMemory();
-    Person person = beanGraph.createVertex(Person.class);
-
-    assertThat(person).isNotNull();
-    assertThat(person.element()).isNotNull();
-    assertThat(person.element().getId()).isNotNull();
-    assertThat(person.beanGraph()).isSameAs(beanGraph);
-    assertThat(person.age()).isNull();
-  }
-
-  @Test
-  public void should_wrap_existing_element() {
-    TinkerGraph graph = new TinkerGraph();
-    BeanGraph beanGraph = new BeanGraph(graph);
-    Vertex vertex = graph.addVertex(null);
-    vertex.setProperty("age", 42);
-
-    Person person = beanGraph.wrap(vertex, Person.class);
-    assertThat(person).isNotNull();
-    assertThat(person.element()).isSameAs(vertex);
-    assertThat(person.age()).isEqualTo(42);
-  }
-
-  @Test
-  public void should_create_adjacent_bean_vertex() {
-    BeanGraph beanGraph = BeanGraph.createInMemory();
-    Person person = beanGraph.createVertex(Person.class);
-
-    Person adjacent = beanGraph.createAdjacentVertex(person, Person.class, "knows", "type", "family");
-    assertThat(adjacent).isNotNull();
-    assertThat(person.knows()).hasSize(1);
-    assertThat(person.knows().iterator().next()).isSameAs(adjacent);
-    assertThat(adjacent.knows()).isEmpty();
-  }
-
-  @Test
-  public void should_not_wrap_null_element() {
-    BeanGraph beanGraph = BeanGraph.createInMemory();
-    assertThat(beanGraph.wrap(null, Person.class)).isNull();
-  }
-
-  static class Person extends BeanVertex {
-    Integer age() {
-      return (Integer) getProperty("age");
-    }
-
-    Iterable<Person> knows() {
-      return getVertices(Person.class, Direction.OUT, "knows");
-    }
-  }
-}
diff --git a/sonar-core/src/test/java/org/sonar/core/graph/EdgePathTest.java b/sonar-core/src/test/java/org/sonar/core/graph/EdgePathTest.java
deleted file mode 100644 (file)
index a254e77..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.graph;
-
-import com.tinkerpop.blueprints.Direction;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class EdgePathTest {
-
-  @Rule
-  public ExpectedException thrown = ExpectedException.none();
-
-  @Test
-  public void create_valid_edge_path() {
-    EdgePath path = EdgePath.create(Direction.OUT, "knows", Direction.OUT, "has");
-
-    assertThat(path).isNotNull();
-    assertThat(path.getElements()).hasSize(4);
-    assertThat(path.getElements().get(0)).isEqualTo(Direction.OUT);
-    assertThat(path.getElements().get(1)).isEqualTo("knows");
-    assertThat(path.getElements().get(2)).isEqualTo(Direction.OUT);
-    assertThat(path.getElements().get(3)).isEqualTo("has");
-  }
-
-  @Test
-  public void should_have_even_number_of_elements() {
-    thrown.expect(IllegalArgumentException.class);
-    thrown.expectMessage("Odd number of elements (3)");
-    EdgePath.create(Direction.OUT, "knows", Direction.OUT);
-  }
-
-  @Test
-  public void should_have_sequence_of_directions_and_strings_1() {
-    thrown.expect(IllegalArgumentException.class);
-    thrown.expectMessage("Element 0 must be a com.tinkerpop.blueprints.Direction (got java.lang.String)");
-
-    EdgePath.create("knows", Direction.OUT);
-  }
-
-  @Test
-  public void should_have_sequence_of_directions_and_strings_2() {
-    thrown.expect(IllegalArgumentException.class);
-    thrown.expectMessage("Element 1 must be a String (got com.tinkerpop.blueprints.Direction)");
-
-    EdgePath.create(Direction.OUT, Direction.OUT);
-  }
-}
diff --git a/sonar-core/src/test/java/org/sonar/core/graph/GraphUtilTest.java b/sonar-core/src/test/java/org/sonar/core/graph/GraphUtilTest.java
deleted file mode 100644 (file)
index 748f09a..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.graph;
-
-import com.tinkerpop.blueprints.Direction;
-import com.tinkerpop.blueprints.Vertex;
-import com.tinkerpop.blueprints.impls.tg.TinkerGraph;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class GraphUtilTest {
-
-  @Rule
-  public ExpectedException thrown = ExpectedException.none();
-
-  @Test
-  public void uniqueAdjacent() {
-    TinkerGraph graph = new TinkerGraph();
-    Vertex a = graph.addVertex(null);
-    Vertex b = graph.addVertex(null);
-    Vertex c = graph.addVertex(null);
-    graph.addEdge(null, a, b, "likes");
-    graph.addEdge(null, a, c, "hates");
-
-    assertThat(GraphUtil.singleAdjacent(a, Direction.OUT, "likes")).isEqualTo(b);
-    assertThat(GraphUtil.singleAdjacent(a, Direction.OUT, "likes", "other")).isEqualTo(b);
-    assertThat(GraphUtil.singleAdjacent(a, Direction.OUT, "other")).isNull();
-    assertThat(GraphUtil.singleAdjacent(a, Direction.IN, "likes")).isNull();
-  }
-
-  @Test
-  public void uniqueAdjacent_fail_if_multiple_adjacents() {
-    thrown.expect(MultipleElementsException.class);
-    thrown.expectMessage("More than one vertex is adjacent to: v[0], direction: OUT, labels: likes,hates");
-
-    TinkerGraph graph = new TinkerGraph();
-    Vertex a = graph.addVertex(null);
-    Vertex b = graph.addVertex(null);
-    Vertex c = graph.addVertex(null);
-    graph.addEdge(null, a, b, "likes");
-    graph.addEdge(null, a, c, "likes");
-
-    GraphUtil.singleAdjacent(a, Direction.OUT, "likes", "hates");
-  }
-
-  @Test
-  public void should_extract_single_element() {
-    TinkerGraph graph = new TinkerGraph();
-    Vertex a = graph.addVertex(null);
-
-    Vertex single = GraphUtil.single(graph.getVertices());
-    assertThat(single).isSameAs(a);
-  }
-
-  @Test
-  public void should_extract_null() {
-    TinkerGraph graph = new TinkerGraph();
-    Vertex single = GraphUtil.single(graph.getVertices());
-    assertThat(single).isNull();
-  }
-
-  @Test
-    public void should_fail_to_extract_single_element() {
-      thrown.expect(MultipleElementsException.class);
-      thrown.expectMessage("More than one element");
-
-      TinkerGraph graph = new TinkerGraph();
-      graph.addVertex(null);
-      graph.addVertex(null);
-      graph.addVertex(null);
-
-      GraphUtil.single(graph.getVertices());
-    }
-}
diff --git a/sonar-core/src/test/java/org/sonar/core/graph/graphson/GraphsonReaderTest.java b/sonar-core/src/test/java/org/sonar/core/graph/graphson/GraphsonReaderTest.java
deleted file mode 100644 (file)
index b63cd4d..0000000
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.graph.graphson;
-
-import com.google.common.collect.Sets;
-import com.tinkerpop.blueprints.Direction;
-import com.tinkerpop.blueprints.Edge;
-import com.tinkerpop.blueprints.Vertex;
-import com.tinkerpop.blueprints.impls.tg.TinkerGraph;
-import com.tinkerpop.blueprints.impls.tg.TinkerGraphFactory;
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-public class GraphsonReaderTest {
-
-  @Test
-  public void inputGraphModeExtended() {
-    TinkerGraph graph = new TinkerGraph();
-
-    String json = "{ \"mode\":\"EXTENDED\", \"vertices\": [ {\"_id\":1, \"_type\":\"vertex\", \"test\": { \"type\":\"string\", \"value\":\"please work\"}, \"testlist\":{\"type\":\"list\", \"value\":[{\"type\":\"int\", \"value\":1}, {\"type\":\"int\",\"value\":2}, {\"type\":\"int\",\"value\":3}, {\"type\":\"unknown\",\"value\":null}]}, \"testmap\":{\"type\":\"map\", \"value\":{\"big\":{\"type\":\"long\", \"value\":10000000000}, \"small\":{\"type\":\"double\", \"value\":0.4954959595959}, \"nullKey\":{\"type\":\"unknown\", \"value\":null}}}}, {\"_id\":2, \"_type\":\"vertex\", \"testagain\":{\"type\":\"string\", \"value\":\"please work again\"}}], \"edges\":[{\"_id\":100, \"_type\":\"edge\", \"_outV\":1, \"_inV\":2, \"_label\":\"works\", \"teste\": {\"type\":\"string\", \"value\":\"please worke\"}, \"keyNull\":{\"type\":\"unknown\", \"value\":null}}]}";
-
-    StringReader input = new StringReader(json);
-    new GraphsonReader().read(input, graph);
-
-    Assert.assertEquals(2, getIterableCount(graph.getVertices()));
-    Assert.assertEquals(1, getIterableCount(graph.getEdges()));
-
-    Vertex v1 = graph.getVertex(1);
-    Assert.assertNotNull(v1);
-    Assert.assertEquals("please work", v1.getProperty("test"));
-
-    Map map = (Map) v1.getProperty("testmap");
-    Assert.assertNotNull(map);
-    Assert.assertEquals(10000000000l, Long.parseLong(map.get("big").toString()));
-    Assert.assertEquals(0.4954959595959, Double.parseDouble(map.get("small").toString()), 0);
-    Assert.assertNull(map.get("nullKey"));
-
-    List list = (List) v1.getProperty("testlist");
-    Assert.assertEquals(4, list.size());
-
-    boolean foundNull = false;
-    for (int ix = 0; ix < list.size(); ix++) {
-      if (list.get(ix) == null) {
-        foundNull = true;
-        break;
-      }
-    }
-
-    Assert.assertTrue(foundNull);
-
-    Vertex v2 = graph.getVertex(2);
-    Assert.assertNotNull(v2);
-    Assert.assertEquals("please work again", v2.getProperty("testagain"));
-
-    Edge e = graph.getEdge(100);
-    Assert.assertNotNull(e);
-    Assert.assertEquals("works", e.getLabel());
-    Assert.assertEquals(v1, e.getVertex(Direction.OUT));
-    Assert.assertEquals(v2, e.getVertex(Direction.IN));
-    Assert.assertEquals("please worke", e.getProperty("teste"));
-    Assert.assertNull(e.getProperty("keyNull"));
-
-  }
-
-  @Test
-  public void inputGraphModeNormal() {
-    TinkerGraph graph = new TinkerGraph();
-
-    String json = "{ \"mode\":\"NORMAL\",\"vertices\": [ {\"_id\":1, \"_type\":\"vertex\", \"test\": \"please work\", \"testlist\":[1, 2, 3, null], \"testmap\":{\"big\":10000000000, \"small\":0.4954959595959, \"nullKey\":null}}, {\"_id\":2, \"_type\":\"vertex\", \"testagain\":\"please work again\"}], \"edges\":[{\"_id\":100, \"_type\":\"edge\", \"_outV\":1, \"_inV\":2, \"_label\":\"works\", \"teste\": \"please worke\", \"keyNull\":null}]}";
-
-    StringReader input = new StringReader(json);
-    new GraphsonReader().read(input, graph);
-
-    Assert.assertEquals(2, getIterableCount(graph.getVertices()));
-    Assert.assertEquals(1, getIterableCount(graph.getEdges()));
-
-    Vertex v1 = graph.getVertex(1);
-    Assert.assertNotNull(v1);
-    Assert.assertEquals("please work", v1.getProperty("test"));
-
-    Map map = (Map) v1.getProperty("testmap");
-    Assert.assertNotNull(map);
-    Assert.assertEquals(10000000000l, Long.parseLong(map.get("big").toString()));
-    Assert.assertEquals(0.4954959595959, Double.parseDouble(map.get("small").toString()), 0);
-    Assert.assertNull(map.get("nullKey"));
-
-    List list = (List) v1.getProperty("testlist");
-    Assert.assertEquals(4, list.size());
-
-    boolean foundNull = false;
-    for (int ix = 0; ix < list.size(); ix++) {
-      if (list.get(ix) == null) {
-        foundNull = true;
-        break;
-      }
-    }
-
-    Assert.assertTrue(foundNull);
-
-    Vertex v2 = graph.getVertex(2);
-    Assert.assertNotNull(v2);
-    Assert.assertEquals("please work again", v2.getProperty("testagain"));
-
-    Edge e = graph.getEdge(100);
-    Assert.assertNotNull(e);
-    Assert.assertEquals("works", e.getLabel());
-    Assert.assertEquals(v1, e.getVertex(Direction.OUT));
-    Assert.assertEquals(v2, e.getVertex(Direction.IN));
-    Assert.assertEquals("please worke", e.getProperty("teste"));
-    Assert.assertNull(e.getProperty("keyNull"));
-
-  }
-
-  @Test
-  public void inputGraphModeCompact() {
-    TinkerGraph graph = new TinkerGraph();
-
-    String json = "{ \"mode\":\"COMPACT\",\"vertices\": [ {\"_id\":1, \"test\": \"please work\", \"testlist\":[1, 2, 3, null], \"testmap\":{\"big\":10000000000, \"small\":0.4954959595959, \"nullKey\":null}}, {\"_id\":2, \"testagain\":\"please work again\"}], \"edges\":[{\"_id\":100, \"_outV\":1, \"_inV\":2, \"_label\":\"works\", \"teste\": \"please worke\", \"keyNull\":null}]}";
-
-    StringReader input = new StringReader(json);
-    new GraphsonReader().read(input, graph);
-
-    Assert.assertEquals(2, getIterableCount(graph.getVertices()));
-    Assert.assertEquals(1, getIterableCount(graph.getEdges()));
-
-    Vertex v1 = graph.getVertex(1);
-    Assert.assertNotNull(v1);
-    Assert.assertEquals("please work", v1.getProperty("test"));
-
-    Map map = (Map) v1.getProperty("testmap");
-    Assert.assertNotNull(map);
-    Assert.assertEquals(10000000000l, Long.parseLong(map.get("big").toString()));
-    Assert.assertEquals(0.4954959595959, Double.parseDouble(map.get("small").toString()), 0);
-    Assert.assertNull(map.get("nullKey"));
-
-    List list = (List) v1.getProperty("testlist");
-    Assert.assertEquals(4, list.size());
-
-    boolean foundNull = false;
-    for (Object aList : list) {
-      if (aList == null) {
-        foundNull = true;
-        break;
-      }
-    }
-
-    Assert.assertTrue(foundNull);
-
-    Vertex v2 = graph.getVertex(2);
-    Assert.assertNotNull(v2);
-    Assert.assertEquals("please work again", v2.getProperty("testagain"));
-
-    Edge e = graph.getEdge(100);
-    Assert.assertNotNull(e);
-    Assert.assertEquals("works", e.getLabel());
-    Assert.assertEquals(v1, e.getVertex(Direction.OUT));
-    Assert.assertEquals(v2, e.getVertex(Direction.IN));
-    Assert.assertEquals("please worke", e.getProperty("teste"));
-    Assert.assertNull(e.getProperty("keyNull"));
-
-  }
-
-  @Test
-  public void inputGraphExtendedFullCycle() throws Exception {
-    TinkerGraph graph = TinkerGraphFactory.createTinkerGraph();
-
-    StringWriter stream = new StringWriter();
-
-    GraphsonWriter writer = new GraphsonWriter();
-    writer.write(graph, stream, GraphsonMode.EXTENDED);
-
-    stream.flush();
-    stream.close();
-
-    String jsonString = stream.toString();
-
-    StringReader input = new StringReader(jsonString);
-
-    TinkerGraph emptyGraph = new TinkerGraph();
-    new GraphsonReader().read(input, emptyGraph);
-
-    Assert.assertEquals(6, getIterableCount(emptyGraph.getVertices()));
-    Assert.assertEquals(6, getIterableCount(emptyGraph.getEdges()));
-
-    for (Vertex v : graph.getVertices()) {
-      Vertex found = emptyGraph.getVertex(v.getId());
-
-      Assert.assertNotNull(v);
-
-      for (String key : found.getPropertyKeys()) {
-        Assert.assertEquals(v.getProperty(key), found.getProperty(key));
-      }
-    }
-
-    for (Edge e : graph.getEdges()) {
-      Edge found = emptyGraph.getEdge(e.getId());
-
-      Assert.assertNotNull(e);
-
-      for (String key : found.getPropertyKeys()) {
-        Assert.assertEquals(e.getProperty(key), found.getProperty(key));
-      }
-    }
-
-  }
-
-  @Test
-  public void inputGraphCompactFullCycle() throws Exception {
-    TinkerGraph graph = TinkerGraphFactory.createTinkerGraph();
-
-    StringWriter stream = new StringWriter();
-
-    Set<String> edgeKeys = new HashSet<>();
-    edgeKeys.add(GraphsonTokens._ID);
-    edgeKeys.add(GraphsonTokens._IN_V);
-    edgeKeys.add(GraphsonTokens._OUT_V);
-    edgeKeys.add(GraphsonTokens._LABEL);
-
-    Set<String> vertexKeys = Sets.newHashSet();
-    vertexKeys.add(GraphsonTokens._ID);
-
-    GraphsonWriter writer = new GraphsonWriter();
-    writer.write(graph, stream, GraphsonMode.EXTENDED, vertexKeys, edgeKeys);
-
-    stream.flush();
-    stream.close();
-
-    String jsonString = stream.toString();
-    StringReader input = new StringReader(jsonString);
-
-    TinkerGraph emptyGraph = new TinkerGraph();
-    new GraphsonReader().read(input, emptyGraph);
-
-    Assert.assertEquals(6, getIterableCount(emptyGraph.getVertices()));
-    Assert.assertEquals(6, getIterableCount(emptyGraph.getEdges()));
-
-    for (Vertex v : graph.getVertices()) {
-      Vertex found = emptyGraph.getVertex(v.getId());
-
-      Assert.assertNotNull(v);
-
-      for (String key : found.getPropertyKeys()) {
-        Assert.assertEquals(v.getProperty(key), found.getProperty(key));
-      }
-
-      // no properties should be here
-      Assert.assertEquals(null, found.getProperty("name"));
-    }
-
-    for (Edge e : graph.getEdges()) {
-      Edge found = emptyGraph.getEdge(e.getId());
-
-      Assert.assertNotNull(e);
-
-      for (String key : found.getPropertyKeys()) {
-        Assert.assertEquals(e.getProperty(key), found.getProperty(key));
-      }
-
-      // no properties should be here
-      Assert.assertEquals(null, found.getProperty("weight"));
-    }
-
-  }
-
-  @Test(expected = GraphsonException.class)
-  public void inputGraphCompactFullCycleBroken() throws Exception {
-    TinkerGraph graph = TinkerGraphFactory.createTinkerGraph();
-
-    StringWriter stream = new StringWriter();
-
-    Set<String> edgeKeys = new HashSet<>();
-    edgeKeys.add(GraphsonTokens._IN_V);
-    edgeKeys.add(GraphsonTokens._OUT_V);
-    edgeKeys.add(GraphsonTokens._LABEL);
-
-    Set<String> vertexKeys = Sets.newHashSet();
-
-    GraphsonWriter writer = new GraphsonWriter();
-    writer.write(graph, stream, GraphsonMode.COMPACT, vertexKeys, edgeKeys);
-
-    stream.flush();
-    stream.close();
-
-    String jsonString = writer.toString();
-    StringReader input = new StringReader(jsonString);
-
-    TinkerGraph emptyGraph = new TinkerGraph();
-    new GraphsonReader().read(input, emptyGraph);
-
-  }
-
-  private int getIterableCount(Iterable elements) {
-    int counter = 0;
-
-    Iterator iterator = elements.iterator();
-    while (iterator.hasNext()) {
-      iterator.next();
-      counter++;
-    }
-
-    return counter;
-  }
-}
diff --git a/sonar-core/src/test/java/org/sonar/core/graph/graphson/GraphsonUtilTest.java b/sonar-core/src/test/java/org/sonar/core/graph/graphson/GraphsonUtilTest.java
deleted file mode 100644 (file)
index e021175..0000000
+++ /dev/null
@@ -1,1151 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.graph.graphson;
-
-import com.tinkerpop.blueprints.Direction;
-import com.tinkerpop.blueprints.Edge;
-import com.tinkerpop.blueprints.Graph;
-import com.tinkerpop.blueprints.Vertex;
-import com.tinkerpop.blueprints.impls.tg.TinkerGraph;
-import com.tinkerpop.blueprints.util.io.graphson.GraphSONTokens;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class GraphsonUtilTest {
-  private final String vertexJson1 = "{\"name\":\"marko\",\"age\":29,\"_id\":1,\"_type\":\"vertex\"}";
-  private final String vertexJson2 = "{\"name\":\"vadas\",\"age\":27,\"_id\":2,\"_type\":\"vertex\"}";
-  private final String edgeJsonLight = "{\"weight\":0.5,\"_outV\":1,\"_inV\":2}";
-  private final String edgeJson = "{\"weight\":0.5,\"_id\":7,\"_type\":\"edge\",\"_outV\":1,\"_inV\":2,\"_label\":\"knows\"}";
-  private TinkerGraph graph = new TinkerGraph();
-  private InputStream inputStreamVertexJson1;
-  private InputStream inputStreamEdgeJsonLight;
-
-  @Before
-  public void setUp() {
-    this.graph.clear();
-
-    this.inputStreamVertexJson1 = new ByteArrayInputStream(vertexJson1.getBytes());
-    this.inputStreamEdgeJsonLight = new ByteArrayInputStream(edgeJsonLight.getBytes());
-  }
-
-  @Test
-  public void jsonFromElementEdgeNoPropertiesNoKeysNoTypes() {
-    Vertex v1 = this.graph.addVertex(1);
-    Vertex v2 = this.graph.addVertex(2);
-
-    Edge e = this.graph.addEdge(3, v1, v2, "test");
-    e.setProperty("weight", 0.5f);
-
-    JSONObject json = GraphsonUtil.jsonFromElement(e, null, GraphsonMode.NORMAL);
-
-    assertThat(json).isNotNull();
-    assertThat(json.containsKey(GraphSONTokens._ID)).isTrue();
-    assertThat(json.get(GraphSONTokens._ID)).isEqualTo("3");
-    assertThat(json.containsKey(GraphSONTokens._LABEL)).isTrue();
-    assertThat(json.get(GraphSONTokens._LABEL)).isEqualTo("test");
-    assertThat(json.containsKey(GraphSONTokens._TYPE)).isTrue();
-    assertThat(json.get(GraphSONTokens._TYPE)).isEqualTo("edge");
-    assertThat(json.containsKey(GraphSONTokens._IN_V)).isTrue();
-    assertThat(json.get(GraphSONTokens._IN_V)).isEqualTo("2");
-    assertThat(json.containsKey(GraphSONTokens._OUT_V)).isTrue();
-    assertThat(json.get(GraphSONTokens._OUT_V)).isEqualTo("1");
-    assertThat(json.containsKey("weight")).isTrue();
-    assertThat(json.get("weight")).isEqualTo(0.5f);
-  }
-
-  @Test
-  public void jsonFromElementEdgeCompactIdOnlyAsInclude() {
-    Vertex v1 = this.graph.addVertex(1);
-    Vertex v2 = this.graph.addVertex(2);
-
-    Edge e = this.graph.addEdge(3, v1, v2, "test");
-    e.setProperty("weight", 0.5f);
-
-    Set<String> propertiesToInclude = new HashSet<String>() {{
-      add(GraphSONTokens._ID);
-    }};
-
-    JSONObject json = GraphsonUtil.jsonFromElement(e, propertiesToInclude, GraphsonMode.COMPACT);
-
-    assertThat(json).isNotNull();
-    assertThat(json.containsKey(GraphSONTokens._TYPE)).isFalse();
-    assertThat(json.containsKey(GraphSONTokens._LABEL)).isFalse();
-    assertThat(json.containsKey(GraphSONTokens._IN_V)).isFalse();
-    assertThat(json.containsKey(GraphSONTokens._OUT_V)).isFalse();
-    assertThat(json.containsKey(GraphSONTokens._ID)).isTrue();
-    assertThat(json.containsKey("weight")).isFalse();
-  }
-
-  @Test
-  public void jsonFromElementEdgeCompactIdOnlyAsExclude() {
-    ElementFactory factory = new ElementFactory(this.graph);
-    Vertex v1 = this.graph.addVertex(1);
-    Vertex v2 = this.graph.addVertex(2);
-
-    Edge e = this.graph.addEdge(3, v1, v2, "test");
-    e.setProperty("weight", 0.5f);
-    e.setProperty("x", "y");
-
-    Set<String> propertiesToExclude = new HashSet<String>() {{
-      add(GraphSONTokens._TYPE);
-      add(GraphSONTokens._LABEL);
-      add(GraphSONTokens._IN_V);
-      add(GraphSONTokens._OUT_V);
-      add("weight");
-    }};
-
-    ElementPropertyConfig config = new ElementPropertyConfig(null, propertiesToExclude,
-        ElementPropertyConfig.ElementPropertiesRule.INCLUDE,
-        ElementPropertyConfig.ElementPropertiesRule.EXCLUDE);
-    GraphsonUtil utility = new GraphsonUtil(GraphsonMode.COMPACT, factory, config);
-    JSONObject json = utility.jsonFromElement(e);
-
-    assertThat(json).isNotNull();
-    assertThat(json.containsKey(GraphSONTokens._TYPE)).isFalse();
-    assertThat(json.containsKey(GraphSONTokens._LABEL)).isFalse();
-    assertThat(json.containsKey(GraphSONTokens._IN_V)).isFalse();
-    assertThat(json.containsKey(GraphSONTokens._OUT_V)).isFalse();
-    assertThat(json.containsKey(GraphSONTokens._ID)).isTrue();
-    assertThat(json.containsKey("weight")).isFalse();
-    assertThat(json.containsKey("x")).isTrue();
-    assertThat(json.get("x")).isEqualTo("y");
-  }
-
-  @Test
-  public void jsonFromElementEdgeCompactAllKeys() {
-    Vertex v1 = this.graph.addVertex(1);
-    Vertex v2 = this.graph.addVertex(2);
-
-    Edge e = this.graph.addEdge(3, v1, v2, "test");
-    e.setProperty("weight", 0.5f);
-
-    JSONObject json = GraphsonUtil.jsonFromElement(e, null, GraphsonMode.COMPACT);
-
-    assertThat(json).isNotNull();
-    assertThat(json.containsKey(GraphSONTokens._ID)).isTrue();
-    assertThat(json.containsKey(GraphSONTokens._TYPE)).isTrue();
-    assertThat(json.containsKey(GraphSONTokens._LABEL)).isTrue();
-    assertThat(json.containsKey(GraphSONTokens._IN_V)).isTrue();
-    assertThat(json.containsKey(GraphSONTokens._OUT_V)).isTrue();
-    assertThat(json.get("weight")).isEqualTo(0.5f);
-  }
-
-  @Test
-  public void jsonFromElementVertexNoPropertiesNoKeysNoTypes() {
-    Vertex v = this.graph.addVertex(1);
-    v.setProperty("name", "marko");
-
-    JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphsonMode.NORMAL);
-
-    assertThat(json).isNotNull();
-    assertThat(json.containsKey(GraphSONTokens._ID)).isTrue();
-    assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
-    assertThat(json.containsKey(GraphSONTokens._TYPE)).isTrue();
-    assertThat(json.get(GraphSONTokens._TYPE)).isEqualTo("vertex");
-    assertThat(json.get("name")).isEqualTo("marko");
-  }
-
-  @Test
-  public void jsonFromElementVertexCompactIdOnlyAsInclude() {
-    Vertex v = this.graph.addVertex(1);
-    v.setProperty("name", "marko");
-
-    Set<String> propertiesToInclude = new HashSet<String>() {{
-      add(GraphSONTokens._ID);
-    }};
-
-    JSONObject json = GraphsonUtil.jsonFromElement(v, propertiesToInclude, GraphsonMode.COMPACT);
-
-    assertThat(json).isNotNull();
-    assertThat(json.containsKey(GraphSONTokens._TYPE)).isFalse();
-    assertThat(json.containsKey(GraphSONTokens._ID)).isTrue();
-    assertThat(json.containsKey("name")).isFalse();
-  }
-
-  @Test
-  public void jsonFromElementVertexCompactIdNameOnlyAsExclude() {
-    ElementFactory factory = new ElementFactory(this.graph);
-    Vertex v = this.graph.addVertex(1);
-    v.setProperty("name", "marko");
-
-    Set<String> propertiesToExclude = new HashSet<String>() {{
-      add(GraphSONTokens._TYPE);
-    }};
-
-    ElementPropertyConfig config = new ElementPropertyConfig(propertiesToExclude, null,
-        ElementPropertyConfig.ElementPropertiesRule.EXCLUDE,
-        ElementPropertyConfig.ElementPropertiesRule.EXCLUDE);
-
-    GraphsonUtil utility = new GraphsonUtil(GraphsonMode.COMPACT, factory, config);
-    JSONObject json = utility.jsonFromElement(v);
-
-    assertThat(json).isNotNull();
-    assertThat(json.containsKey(GraphSONTokens._TYPE)).isFalse();
-    assertThat(json.containsKey(GraphSONTokens._ID)).isTrue();
-    assertThat(json.containsKey("name")).isTrue();
-  }
-
-  @Test
-  public void jsonFromElementVertexCompactAllOnly() {
-    Vertex v = this.graph.addVertex(1);
-    v.setProperty("name", "marko");
-
-    JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphsonMode.COMPACT);
-
-    assertThat(json).isNotNull();
-    assertThat(json.containsKey(GraphSONTokens._TYPE)).isTrue();
-    assertThat(json.containsKey(GraphSONTokens._ID)).isTrue();
-    assertThat(json.containsKey("name")).isTrue();
-  }
-
-  @Test
-  public void jsonFromElementVertexPrimitivePropertiesNoKeysNoTypes() {
-    Vertex v = this.graph.addVertex(1);
-    v.setProperty("keyString", "string");
-    v.setProperty("keyLong", 1L);
-    v.setProperty("keyInt", 2);
-    v.setProperty("keyFloat", 3.3f);
-    v.setProperty("keyExponentialDouble", 1312928167.626012);
-    v.setProperty("keyDouble", 4.4);
-    v.setProperty("keyBoolean", true);
-
-    JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphsonMode.NORMAL);
-
-    assertThat(json).isNotNull();
-    assertThat(json.containsKey(GraphSONTokens._ID)).isTrue();
-    assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
-    assertThat(json.containsKey("keyString")).isTrue();
-    assertThat(json.get("keyString")).isEqualTo("string");
-    assertThat(json.containsKey("keyLong")).isTrue();
-    assertThat(json.get("keyLong")).isEqualTo(1L);
-    assertThat(json.containsKey("keyInt")).isTrue();
-    assertThat(json.get("keyInt")).isEqualTo(2);
-    assertThat(json.containsKey("keyFloat")).isTrue();
-    assertThat(json.get("keyFloat")).isEqualTo(3.3f);
-    assertThat(json.containsKey("keyExponentialDouble")).isTrue();
-    assertThat(json.get("keyExponentialDouble")).isEqualTo(1312928167.626012);
-    assertThat(json.containsKey("keyDouble")).isTrue();
-    assertThat(json.get("keyDouble")).isEqualTo(4.4);
-    assertThat(json.containsKey("keyBoolean")).isTrue();
-    assertThat(json.get("keyBoolean")).isEqualTo(true);
-  }
-
-  @Test
-  public void jsonFromElementVertexMapPropertyNoKeysNoTypes() {
-    Vertex v = this.graph.addVertex(1);
-    Map map = new HashMap();
-    map.put("this", "some");
-    map.put("that", 1);
-
-    v.setProperty("keyMap", map);
-
-    JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphsonMode.NORMAL);
-
-    assertThat(json).isNotNull();
-    assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
-    assertThat(json.containsKey("keyMap")).isTrue();
-
-    JSONObject mapAsJSON = (JSONObject) json.get("keyMap");
-    assertThat(mapAsJSON).isNotNull();
-    assertThat(mapAsJSON.containsKey("this")).isTrue();
-    assertThat(mapAsJSON.get("this")).isEqualTo("some");
-    assertThat(mapAsJSON.containsKey("that")).isTrue();
-    assertThat(mapAsJSON.get("that")).isEqualTo(1);
-  }
-
-  @Test
-  public void jsonFromElementVertexListPropertyNoKeysNoTypes() {
-    Vertex v = this.graph.addVertex(1);
-    List<Object> list = new ArrayList<>();
-    list.add("this");
-    list.add("that");
-    list.add("other");
-    list.add(true);
-
-    v.setProperty("keyList", list);
-
-    JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphsonMode.NORMAL);
-
-    assertThat(json).isNotNull();
-    assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
-    assertThat(json.containsKey("keyList")).isTrue();
-
-    JSONArray listAsJSON = (JSONArray) json.get("keyList");
-    assertThat(listAsJSON).isNotNull();
-    assertThat(listAsJSON).hasSize(4);
-  }
-
-  @Test
-  public void jsonFromElementVertexStringArrayPropertyNoKeysNoTypes() {
-    Vertex v = this.graph.addVertex(1);
-    String[] stringArray = new String[]{"this", "that", "other"};
-
-    v.setProperty("keyStringArray", stringArray);
-
-    JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphsonMode.NORMAL);
-
-    assertThat(json).isNotNull();
-    assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
-    assertThat(json.containsKey("keyStringArray")).isTrue();
-
-    JSONArray stringArrayAsJSON = (JSONArray) json.get("keyStringArray");
-    assertThat(stringArrayAsJSON).isNotNull();
-    assertThat(stringArrayAsJSON).hasSize(3);
-  }
-
-  @Test
-  public void jsonFromElementVertexDoubleArrayPropertyNoKeysNoTypes() {
-    Vertex v = this.graph.addVertex(1);
-    double[] doubleArray = new double[]{1.0, 2.0, 3.0};
-
-    v.setProperty("keyDoubleArray", doubleArray);
-
-    JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphsonMode.NORMAL);
-
-    assertThat(json).isNotNull();
-    assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
-    assertThat(json.containsKey("keyDoubleArray")).isTrue();
-
-    JSONArray doubleArrayAsJSON = (JSONArray) json.get("keyDoubleArray");
-    assertThat(doubleArrayAsJSON).isNotNull();
-    assertThat(doubleArrayAsJSON).hasSize(3);
-  }
-
-  @Test
-  public void jsonFromElementVertexIntArrayPropertyNoKeysNoTypes() {
-    Vertex v = this.graph.addVertex(1);
-    int[] intArray = new int[]{1, 2, 3};
-
-    v.setProperty("keyIntArray", intArray);
-
-    JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphsonMode.NORMAL);
-
-    assertThat(json).isNotNull();
-    assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
-    assertThat(json.containsKey("keyIntArray")).isTrue();
-
-    JSONArray intArrayAsJSON = (JSONArray) json.get("keyIntArray");
-    assertThat(intArrayAsJSON).isNotNull();
-    assertThat(intArrayAsJSON).hasSize(3);
-  }
-
-  @Test
-  public void jsonFromElementVertexLongArrayPropertyNoKeysNoTypes() {
-    Vertex v = this.graph.addVertex(1);
-    long[] longArray = new long[]{1l, 2l, 3l};
-
-    v.setProperty("keyLongArray", longArray);
-
-    JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphsonMode.NORMAL);
-
-    assertThat(json).isNotNull();
-    assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
-    assertThat(json.containsKey("keyLongArray")).isTrue();
-
-    JSONArray longArrayAsJSON = (JSONArray) json.get("keyLongArray");
-    assertThat(longArrayAsJSON).isNotNull();
-    assertThat(longArrayAsJSON).hasSize(3);
-  }
-
-  @Test
-  public void jsonFromElementFloatArrayPropertyNoKeysNoTypes() {
-    Vertex v = this.graph.addVertex(1);
-    float[] floatArray = new float[]{1.0f, 2.0f, 3.0f};
-
-    v.setProperty("keyFloatArray", floatArray);
-
-    JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphsonMode.NORMAL);
-
-    assertThat(json).isNotNull();
-    assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
-    assertThat(json.containsKey("keyFloatArray")).isTrue();
-
-    JSONArray floatArrayAsJSON = (JSONArray) json.get("keyFloatArray");
-    assertThat(floatArrayAsJSON).isNotNull();
-    assertThat(floatArrayAsJSON).hasSize(3);
-  }
-
-  @Test
-  public void jsonFromElementBooleanArrayPropertyNoKeysNoTypes() {
-    Vertex v = this.graph.addVertex(1);
-    boolean[] booleanArray = new boolean[]{true, false, true};
-
-    v.setProperty("keyBooleanArray", booleanArray);
-
-    JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphsonMode.NORMAL);
-
-    assertThat(json).isNotNull();
-    assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
-    assertThat(json.containsKey("keyBooleanArray")).isTrue();
-
-    JSONArray booleanArrayAsJSON = (JSONArray) json.get("keyBooleanArray");
-    assertThat(booleanArrayAsJSON).isNotNull();
-    assertThat(booleanArrayAsJSON).hasSize(3);
-  }
-
-  @Test
-  public void jsonFromElementVertexCatPropertyNoKeysNoTypes() {
-    Vertex v = this.graph.addVertex(1);
-    v.setProperty("mycat", new Cat("smithers"));
-
-    JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphsonMode.NORMAL);
-
-    assertThat(json).isNotNull();
-    assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
-    assertThat(json.containsKey("mycat")).isTrue();
-    assertThat(json.get("mycat")).isEqualTo("smithers");
-  }
-
-  @Test
-  public void jsonFromElementVertexCatPropertyNoKeysWithTypes() {
-    Vertex v = this.graph.addVertex(1);
-    v.setProperty("mycat", new Cat("smithers"));
-
-    JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphsonMode.EXTENDED);
-
-    assertThat(json).isNotNull();
-    assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
-    assertThat(json.containsKey("mycat")).isTrue();
-
-    JSONObject jsonObjectCat = (JSONObject) json.get("mycat");
-    assertThat(jsonObjectCat.containsKey("value")).isTrue();
-    assertThat(jsonObjectCat.get("value")).isEqualTo("smithers");
-  }
-
-  @Test
-  public void jsonFromElementVertexCatArrayPropertyNoKeysNoTypes() {
-    Vertex v = this.graph.addVertex(1);
-    List<Cat> cats = new ArrayList<>();
-    cats.add(new Cat("smithers"));
-    cats.add(new Cat("mcallister"));
-
-    v.setProperty("cats", cats);
-
-    JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphsonMode.NORMAL);
-
-    assertThat(json).isNotNull();
-    assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
-    assertThat(json.containsKey("cats")).isTrue();
-
-    JSONArray catListAsJson = (JSONArray) json.get("cats");
-    assertThat(catListAsJson).hasSize(2);
-  }
-
-  @Test
-  public void jsonFromElementCrazyPropertyNoKeysNoTypes() {
-    Vertex v = this.graph.addVertex(1);
-    List mix = new ArrayList();
-    mix.add(new Cat("smithers"));
-    mix.add(true);
-
-    List deepCats = new ArrayList();
-    deepCats.add(new Cat("mcallister"));
-    mix.add(deepCats);
-
-    Map map = new HashMap();
-    map.put("crazy", mix);
-
-    int[] someInts = new int[]{1, 2, 3};
-    map.put("ints", someInts);
-
-    map.put("regular", "stuff");
-
-    Map innerMap = new HashMap();
-    innerMap.put("me", "you");
-
-    map.put("inner", innerMap);
-
-    v.setProperty("crazy-map", map);
-
-    JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphsonMode.NORMAL);
-
-    assertThat(json).isNotNull();
-    assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
-    assertThat(json.containsKey("crazy-map")).isTrue();
-
-    JSONObject mapAsJson = (JSONObject) json.get("crazy-map");
-    assertThat(mapAsJson.containsKey("regular")).isTrue();
-    assertThat(mapAsJson.get("regular")).isEqualTo("stuff");
-
-    assertThat(mapAsJson.containsKey("ints")).isTrue();
-    JSONArray intArrayAsJson = (JSONArray) mapAsJson.get("ints");
-    assertThat(intArrayAsJson).hasSize(3);
-
-    assertThat(mapAsJson.containsKey("crazy")).isTrue();
-    JSONArray deepListAsJSON = (JSONArray) mapAsJson.get("crazy");
-    assertThat(deepListAsJSON).hasSize(3);
-
-    assertThat(mapAsJson.containsKey("inner")).isTrue();
-    JSONObject mapInMapAsJSON = (JSONObject) mapAsJson.get("inner");
-    assertThat(mapInMapAsJSON.containsKey("me")).isTrue();
-    assertThat(mapInMapAsJSON.get("me")).isEqualTo("you");
-
-  }
-
-  @Test
-  public void jsonFromElementVertexNoPropertiesWithKeysNoTypes() {
-    Vertex v = this.graph.addVertex(1);
-    v.setProperty("x", "X");
-    v.setProperty("y", "Y");
-    v.setProperty("z", "Z");
-
-    Set<String> propertiesToInclude = new HashSet<>();
-    propertiesToInclude.add("y");
-    JSONObject json = GraphsonUtil.jsonFromElement(v, propertiesToInclude, GraphsonMode.NORMAL);
-
-    assertThat(json).isNotNull();
-    assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
-    assertThat(json.get(GraphSONTokens._TYPE)).isEqualTo("vertex");
-    assertThat(json.containsKey("x")).isFalse();
-    assertThat(json.containsKey("z")).isFalse();
-    assertThat(json.containsKey("y")).isTrue();
-  }
-
-  @Test
-  public void jsonFromElementVertexVertexPropertiesWithKeysNoTypes() {
-    Vertex v = this.graph.addVertex(1);
-    v.setProperty("x", "X");
-    v.setProperty("y", "Y");
-    v.setProperty("z", "Z");
-
-    Vertex innerV = this.graph.addVertex(2);
-    innerV.setProperty("x", "X");
-    innerV.setProperty("y", "Y");
-    innerV.setProperty("z", "Z");
-
-    v.setProperty("v", innerV);
-
-    Set<String> propertiesToInclude = new HashSet<>();
-    propertiesToInclude.add("y");
-    propertiesToInclude.add("v");
-
-    JSONObject json = GraphsonUtil.jsonFromElement(v, propertiesToInclude, GraphsonMode.NORMAL);
-
-    assertThat(json).isNotNull();
-    assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
-    assertThat(json.get(GraphSONTokens._TYPE)).isEqualTo("vertex");
-    assertThat(json.containsKey("x")).isFalse();
-    assertThat(json.containsKey("z")).isFalse();
-    assertThat(json.containsKey("y")).isTrue();
-    assertThat(json.containsKey("v")).isTrue();
-
-    JSONObject innerJson = (JSONObject) json.get("v");
-    assertThat(innerJson.containsKey("x")).isFalse();
-    assertThat(innerJson.containsKey("z")).isFalse();
-    assertThat(innerJson.containsKey("y")).isTrue();
-    assertThat(innerJson.containsKey("v")).isFalse();
-  }
-
-  @Test
-  public void jsonFromElementVertexPrimitivePropertiesNoKeysWithTypes() {
-    Vertex v = this.graph.addVertex(1);
-    v.setProperty("keyString", "string");
-    v.setProperty("keyLong", 1L);
-    v.setProperty("keyInt", 2);
-    v.setProperty("keyFloat", 3.3f);
-    v.setProperty("keyDouble", 4.4);
-    v.setProperty("keyBoolean", true);
-
-    JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphsonMode.EXTENDED);
-
-    assertThat(json).isNotNull();
-    assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
-    assertThat(json.containsKey("keyString")).isTrue();
-
-    JSONObject valueAsJson = (JSONObject) json.get("keyString");
-    assertThat(valueAsJson.containsKey(GraphSONTokens.TYPE)).isTrue();
-    assertThat(valueAsJson.get(GraphSONTokens.TYPE)).isEqualTo(GraphSONTokens.TYPE_STRING);
-    assertThat(valueAsJson.containsKey(GraphSONTokens.VALUE)).isTrue();
-    assertThat(valueAsJson.get(GraphSONTokens.VALUE)).isEqualTo("string");
-
-    valueAsJson = (JSONObject) json.get("keyLong");
-    assertThat(valueAsJson.containsKey(GraphSONTokens.TYPE)).isTrue();
-    assertThat(valueAsJson.get(GraphSONTokens.TYPE)).isEqualTo(GraphSONTokens.TYPE_LONG);
-    assertThat(valueAsJson.containsKey(GraphSONTokens.VALUE)).isTrue();
-    assertThat(valueAsJson.get(GraphSONTokens.VALUE)).isEqualTo(1L);
-
-    valueAsJson = (JSONObject) json.get("keyInt");
-    assertThat(valueAsJson.containsKey(GraphSONTokens.TYPE)).isTrue();
-    assertThat(valueAsJson.get(GraphSONTokens.TYPE)).isEqualTo(GraphSONTokens.TYPE_INTEGER);
-    assertThat(valueAsJson.containsKey(GraphSONTokens.VALUE)).isTrue();
-    assertThat(valueAsJson.get(GraphSONTokens.VALUE)).isEqualTo(2);
-
-    valueAsJson = (JSONObject) json.get("keyFloat");
-    assertThat(valueAsJson.containsKey(GraphSONTokens.TYPE)).isTrue();
-    assertThat(valueAsJson.get(GraphSONTokens.TYPE)).isEqualTo(GraphSONTokens.TYPE_FLOAT);
-    assertThat(valueAsJson.containsKey(GraphSONTokens.VALUE)).isTrue();
-    assertThat(valueAsJson.get(GraphSONTokens.VALUE)).isEqualTo(3.3f);
-
-    valueAsJson = (JSONObject) json.get("keyDouble");
-    assertThat(valueAsJson.containsKey(GraphSONTokens.TYPE)).isTrue();
-    assertThat(valueAsJson.get(GraphSONTokens.TYPE)).isEqualTo(GraphSONTokens.TYPE_DOUBLE);
-    assertThat(valueAsJson.containsKey(GraphSONTokens.VALUE)).isTrue();
-    assertThat(valueAsJson.get(GraphSONTokens.VALUE)).isEqualTo(4.4);
-
-    valueAsJson = (JSONObject) json.get("keyBoolean");
-    assertThat(valueAsJson.containsKey(GraphSONTokens.TYPE)).isTrue();
-    assertThat(valueAsJson.get(GraphSONTokens.TYPE)).isEqualTo(GraphSONTokens.TYPE_BOOLEAN);
-    assertThat(valueAsJson.containsKey(GraphSONTokens.VALUE)).isTrue();
-    assertThat(valueAsJson.get(GraphSONTokens.VALUE)).isEqualTo(true);
-  }
-
-  @Test
-  public void jsonFromElementVertexListPropertiesNoKeysWithTypes() {
-    Vertex v = this.graph.addVertex(1);
-    List<String> list = new ArrayList<>();
-    list.add("this");
-    list.add("this");
-    list.add("this");
-
-    v.setProperty("keyList", list);
-
-    JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphsonMode.EXTENDED);
-
-    assertThat(json).isNotNull();
-    assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
-    assertThat(json.containsKey("keyList")).isTrue();
-
-    JSONObject listWithTypeAsJson = (JSONObject) json.get("keyList");
-    assertThat(listWithTypeAsJson.containsKey(GraphSONTokens.TYPE)).isTrue();
-    assertThat(listWithTypeAsJson.get(GraphSONTokens.TYPE)).isEqualTo(GraphSONTokens.TYPE_LIST);
-    assertThat(listWithTypeAsJson.containsKey(GraphSONTokens.VALUE)).isTrue();
-
-    JSONArray listAsJSON = (JSONArray) listWithTypeAsJson.get(GraphSONTokens.VALUE);
-    assertThat(listAsJSON).isNotNull();
-    assertThat(listAsJSON).hasSize(3);
-
-    for (int ix = 0; ix < listAsJSON.size(); ix++) {
-      JSONObject valueAsJson = (JSONObject) listAsJSON.get(ix);
-      assertThat(valueAsJson).isNotNull();
-      assertThat(valueAsJson.containsKey(GraphSONTokens.TYPE)).isTrue();
-      assertThat(valueAsJson.get(GraphSONTokens.TYPE)).isEqualTo(GraphSONTokens.TYPE_STRING);
-      assertThat(valueAsJson.containsKey(GraphSONTokens.VALUE)).isTrue();
-      assertThat(valueAsJson.get(GraphSONTokens.VALUE)).isEqualTo("this");
-    }
-  }
-
-  @Test
-  public void jsonFromElementVertexBooleanListPropertiesNoKeysWithTypes() {
-    Vertex v = this.graph.addVertex(1);
-    List<Boolean> list = new ArrayList<>();
-    list.add(true);
-    list.add(true);
-    list.add(true);
-
-    v.setProperty("keyList", list);
-
-    JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphsonMode.EXTENDED);
-
-    assertThat(json).isNotNull();
-    assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
-    assertThat(json.containsKey("keyList")).isTrue();
-
-    JSONObject listWithTypeAsJson = (JSONObject) json.get("keyList");
-    assertThat(listWithTypeAsJson.containsKey(GraphSONTokens.TYPE)).isTrue();
-    assertThat(listWithTypeAsJson.get(GraphSONTokens.TYPE)).isEqualTo(GraphSONTokens.TYPE_LIST);
-    assertThat(listWithTypeAsJson.containsKey(GraphSONTokens.VALUE)).isTrue();
-
-    JSONArray listAsJSON = (JSONArray) listWithTypeAsJson.get(GraphSONTokens.VALUE);
-    assertThat(listAsJSON).isNotNull();
-    assertThat(listAsJSON).hasSize(3);
-
-    for (int ix = 0; ix < listAsJSON.size(); ix++) {
-      JSONObject valueAsJson = (JSONObject) listAsJSON.get(ix);
-      assertThat(valueAsJson).isNotNull();
-      assertThat(valueAsJson.containsKey(GraphSONTokens.TYPE)).isTrue();
-      assertThat(valueAsJson.get(GraphSONTokens.TYPE)).isEqualTo(GraphSONTokens.TYPE_BOOLEAN);
-      assertThat(valueAsJson.containsKey(GraphSONTokens.VALUE)).isTrue();
-      assertThat(valueAsJson.get(GraphSONTokens.VALUE)).isEqualTo(true);
-    }
-  }
-
-  @Test
-  public void jsonFromElementVertexLongListPropertiesNoKeysWithTypes() {
-    Vertex v = this.graph.addVertex(1);
-    List<Long> list = new ArrayList<>();
-    list.add(1000L);
-    list.add(1000L);
-    list.add(1000L);
-
-    v.setProperty("keyList", list);
-
-    JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphsonMode.EXTENDED);
-
-    assertThat(json).isNotNull();
-    assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
-    assertThat(json.containsKey("keyList")).isTrue();
-
-    JSONObject listWithTypeAsJson = (JSONObject) json.get("keyList");
-    assertThat(listWithTypeAsJson.containsKey(GraphSONTokens.TYPE)).isTrue();
-    assertThat(listWithTypeAsJson.get(GraphSONTokens.TYPE)).isEqualTo(GraphSONTokens.TYPE_LIST);
-    assertThat(listWithTypeAsJson.containsKey(GraphSONTokens.VALUE)).isTrue();
-
-    JSONArray listAsJSON = (JSONArray) listWithTypeAsJson.get(GraphSONTokens.VALUE);
-    assertThat(listAsJSON).isNotNull();
-    assertThat(listAsJSON).hasSize(3);
-
-    for (int ix = 0; ix < listAsJSON.size(); ix++) {
-      JSONObject valueAsJson = (JSONObject) listAsJSON.get(ix);
-      assertThat(valueAsJson).isNotNull();
-      assertThat(valueAsJson.containsKey(GraphSONTokens.TYPE)).isTrue();
-      assertThat(valueAsJson.get(GraphSONTokens.TYPE)).isEqualTo(GraphSONTokens.TYPE_LONG);
-      assertThat(valueAsJson.containsKey(GraphSONTokens.VALUE)).isTrue();
-      assertThat(valueAsJson.get(GraphSONTokens.VALUE)).isEqualTo(1000L);
-    }
-  }
-
-  @Test
-  public void jsonFromElementVertexIntListPropertiesNoKeysWithTypes() {
-    Vertex v = this.graph.addVertex(1);
-    List<Integer> list = new ArrayList<>();
-    list.add(1);
-    list.add(1);
-    list.add(1);
-
-    v.setProperty("keyList", list);
-
-    JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphsonMode.EXTENDED);
-
-    assertThat(json).isNotNull();
-    assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
-    assertThat(json.containsKey("keyList")).isTrue();
-
-    JSONObject listWithTypeAsJson = (JSONObject) json.get("keyList");
-    assertThat(listWithTypeAsJson.containsKey(GraphSONTokens.TYPE)).isTrue();
-    assertThat(listWithTypeAsJson.get(GraphSONTokens.TYPE)).isEqualTo(GraphSONTokens.TYPE_LIST);
-    assertThat(listWithTypeAsJson.containsKey(GraphSONTokens.VALUE)).isTrue();
-
-    JSONArray listAsJSON = (JSONArray) listWithTypeAsJson.get(GraphSONTokens.VALUE);
-    assertThat(listAsJSON).isNotNull();
-    assertThat(listAsJSON).hasSize(3);
-
-    for (int ix = 0; ix < listAsJSON.size(); ix++) {
-      JSONObject valueAsJson = (JSONObject) listAsJSON.get(ix);
-      assertThat(valueAsJson).isNotNull();
-      assertThat(valueAsJson.containsKey(GraphSONTokens.TYPE)).isTrue();
-      assertThat(valueAsJson.get(GraphSONTokens.TYPE)).isEqualTo(GraphSONTokens.TYPE_INTEGER);
-      assertThat(valueAsJson.containsKey(GraphSONTokens.VALUE)).isTrue();
-      assertThat(valueAsJson.get(GraphSONTokens.VALUE)).isEqualTo(1);
-    }
-  }
-
-  @Test
-  public void jsonFromElementVertexListOfListPropertiesNoKeysWithTypes() {
-    Vertex v = this.graph.addVertex(1);
-    List<Integer> list = new ArrayList<>();
-    list.add(1);
-    list.add(1);
-    list.add(1);
-
-    List<List<Integer>> listList = new ArrayList<>();
-    listList.add(list);
-
-    v.setProperty("keyList", listList);
-
-    JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphsonMode.EXTENDED);
-
-    assertThat(json).isNotNull();
-    assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
-    assertThat(json.containsKey("keyList")).isTrue();
-
-    JSONObject listWithTypeAsJson = (JSONObject) json.get("keyList");
-    assertThat(listWithTypeAsJson.containsKey(GraphSONTokens.TYPE)).isTrue();
-    assertThat(listWithTypeAsJson.get(GraphSONTokens.TYPE)).isEqualTo(GraphSONTokens.TYPE_LIST);
-    assertThat(listWithTypeAsJson.containsKey(GraphSONTokens.VALUE)).isTrue();
-
-    JSONArray array = (JSONArray) listWithTypeAsJson.get(GraphSONTokens.VALUE);
-    JSONObject obj = (JSONObject) array.get(0);
-    JSONArray listAsJSON = (JSONArray) obj.get(GraphSONTokens.VALUE);
-    assertThat(listAsJSON).isNotNull();
-    assertThat(listAsJSON).hasSize(3);
-
-    for (int ix = 0; ix < listAsJSON.size(); ix++) {
-      JSONObject valueAsJson = (JSONObject) listAsJSON.get(ix);
-      assertThat(valueAsJson).isNotNull();
-      assertThat(valueAsJson.containsKey(GraphSONTokens.TYPE)).isTrue();
-      assertThat(valueAsJson.get(GraphSONTokens.TYPE)).isEqualTo(GraphSONTokens.TYPE_INTEGER);
-      assertThat(valueAsJson.containsKey(GraphSONTokens.VALUE)).isTrue();
-      assertThat(valueAsJson.get(GraphSONTokens.VALUE)).isEqualTo(1);
-    }
-  }
-
-  @Test
-  public void jsonFromElementVertexMapPropertiesNoKeysWithTypes() {
-    Vertex v = this.graph.addVertex(1);
-
-    Map map = new HashMap();
-    map.put("this", "some");
-    map.put("that", 1);
-
-    v.setProperty("keyMap", map);
-
-    JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphsonMode.EXTENDED);
-
-    assertThat(json).isNotNull();
-    assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
-    assertThat(json.containsKey("keyMap")).isTrue();
-
-    JSONObject mapWithTypeAsJSON = (JSONObject) json.get("keyMap");
-    assertThat(mapWithTypeAsJSON).isNotNull();
-    assertThat(mapWithTypeAsJSON.containsKey(GraphSONTokens.TYPE)).isTrue();
-    assertThat(mapWithTypeAsJSON.get(GraphSONTokens.TYPE)).isEqualTo(GraphSONTokens.TYPE_MAP);
-
-    assertThat(mapWithTypeAsJSON.containsKey(GraphSONTokens.VALUE)).isTrue();
-    JSONObject mapAsJSON = (JSONObject) mapWithTypeAsJSON.get(GraphSONTokens.VALUE);
-
-    assertThat(mapAsJSON.containsKey("this")).isTrue();
-    JSONObject thisAsJson = (JSONObject) mapAsJSON.get("this");
-    assertThat(thisAsJson.containsKey(GraphSONTokens.TYPE)).isTrue();
-    assertThat(thisAsJson.get(GraphSONTokens.TYPE)).isEqualTo(GraphSONTokens.TYPE_STRING);
-    assertThat(thisAsJson.containsKey(GraphSONTokens.VALUE)).isTrue();
-    assertThat(thisAsJson.get(GraphSONTokens.VALUE)).isEqualTo("some");
-
-    assertThat(mapAsJSON.containsKey("that")).isTrue();
-    JSONObject thatAsJson = (JSONObject) mapAsJSON.get("that");
-    assertThat(thatAsJson.containsKey(GraphSONTokens.TYPE)).isTrue();
-    assertThat(thatAsJson.get(GraphSONTokens.TYPE)).isEqualTo(GraphSONTokens.TYPE_INTEGER);
-    assertThat(thatAsJson.containsKey(GraphSONTokens.VALUE)).isTrue();
-    assertThat(thatAsJson.get(GraphSONTokens.VALUE)).isEqualTo(1);
-  }
-
-  @Test
-  public void jsonFromElementNullsNoKeysNoTypes() {
-    Graph g = new TinkerGraph();
-    Vertex v = g.addVertex(1);
-    v.setProperty("key", null);
-
-    Map<String, Object> map = new HashMap<>();
-    map.put("innerkey", null);
-
-    List<String> innerList = new ArrayList<>();
-    innerList.add(null);
-    innerList.add("innerstring");
-    map.put("list", innerList);
-
-    v.setProperty("keyMap", map);
-
-    List<String> list = new ArrayList<>();
-    list.add(null);
-    list.add("string");
-    v.setProperty("keyList", list);
-
-    JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphsonMode.NORMAL);
-
-    assertThat(json).isNotNull();
-    assertThat(json.get("key")).isNull();
-    ;
-
-    JSONObject jsonMap = (JSONObject) json.get("keyMap");
-    assertThat(jsonMap).isNotNull();
-    assertThat(jsonMap.get("innerkey")).isNull();
-
-    JSONArray jsonInnerArray = (JSONArray) jsonMap.get("list");
-    assertThat(jsonInnerArray).isNotNull();
-    assertThat(jsonInnerArray.get(0)).isNull();
-    assertThat(jsonInnerArray.get(1)).isEqualTo("innerstring");
-
-    JSONArray jsonArray = (JSONArray) json.get("keyList");
-    assertThat(jsonArray).isNotNull();
-    assertThat(jsonArray.get(0)).isNull();
-    assertThat(jsonArray.get(1)).isEqualTo("string");
-  }
-
-  @Test
-  public void jsonFromElementNullsNoKeysWithTypes() {
-    Graph g = new TinkerGraph();
-    Vertex v = g.addVertex(1);
-    v.setProperty("key", null);
-
-    Map<String, Object> map = new HashMap<>();
-    map.put("innerkey", null);
-
-    List<String> innerList = new ArrayList<>();
-    innerList.add(null);
-    innerList.add("innerstring");
-    map.put("list", innerList);
-
-    v.setProperty("keyMap", map);
-
-    List<String> list = new ArrayList<>();
-    list.add(null);
-    list.add("string");
-    v.setProperty("keyList", list);
-
-    JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphsonMode.EXTENDED);
-
-
-    assertThat(json).isNotNull();
-    JSONObject jsonObjectKey = (JSONObject) json.get("key");
-    assertThat(jsonObjectKey.get(GraphSONTokens.VALUE)).isNull();
-    assertThat(jsonObjectKey.get(GraphSONTokens.TYPE)).isEqualTo(GraphSONTokens.TYPE_UNKNOWN);
-
-    JSONObject keyMap = (JSONObject) json.get("keyMap");
-    JSONObject jsonMap = (JSONObject) keyMap.get(GraphSONTokens.VALUE);
-    assertThat(jsonMap).isNotNull();
-    JSONObject jsonObjectMap = (JSONObject) jsonMap.get("innerkey");
-    assertThat(jsonObjectMap.get(GraphSONTokens.VALUE)).isNull();
-    assertThat(jsonObjectMap.get(GraphSONTokens.TYPE)).isEqualTo(GraphSONTokens.TYPE_UNKNOWN);
-
-    JSONObject listJson = (JSONObject) jsonMap.get("list");
-    JSONArray jsonInnerArray = (JSONArray) listJson.get(GraphSONTokens.VALUE);
-    assertThat(jsonInnerArray).isNotNull();
-    JSONObject jsonObjectInnerListFirst = (JSONObject) jsonInnerArray.get(0);
-    assertThat(jsonObjectInnerListFirst.get(GraphSONTokens.VALUE)).isNull();
-    assertThat(jsonObjectInnerListFirst.get(GraphSONTokens.TYPE)).isEqualTo(GraphSONTokens.TYPE_UNKNOWN);
-
-    JSONObject keyList = (JSONObject) json.get("keyList");
-    JSONArray jsonArray = (JSONArray) keyList.get(GraphSONTokens.VALUE);
-    assertThat(jsonArray).isNotNull();
-    JSONObject jsonObjectListFirst = (JSONObject) jsonArray.get(0);
-    assertThat(jsonObjectListFirst.get(GraphSONTokens.VALUE)).isNull();
-    assertThat(jsonObjectListFirst.get(GraphSONTokens.TYPE)).isEqualTo(GraphSONTokens.TYPE_UNKNOWN);
-  }
-
-  @Test
-  public void vertexFromJsonValid() throws Exception {
-    Graph g = new TinkerGraph();
-    ElementFactory factory = new ElementFactory(g);
-
-    Vertex v = GraphsonUtil.vertexFromJson((JSONObject) JSONValue.parse(vertexJson1), factory, GraphsonMode.NORMAL, null);
-
-    assertThat(v).isSameAs(g.getVertex(1));
-
-    // tinkergraph converts id to string
-    assertThat(v.getId()).isEqualTo("1");
-    assertThat(v.getProperty("name")).isEqualTo("marko");
-    assertThat(v.getProperty("age")).isEqualTo(29L);
-  }
-
-  @Test
-  public void vertexFromJsonStringValid() throws Exception {
-    Graph g = new TinkerGraph();
-    ElementFactory factory = new ElementFactory(g);
-
-    Vertex v = GraphsonUtil.vertexFromJson(vertexJson1, factory, GraphsonMode.NORMAL, null);
-
-    assertThat(v).isSameAs(g.getVertex(1));
-
-    // tinkergraph converts id to string
-    assertThat(v.getId()).isEqualTo("1");
-    assertThat(v.getProperty("name")).isEqualTo("marko");
-    assertThat(v.getProperty("age")).isEqualTo(29L);
-  }
-
-  @Test
-  public void vertexFromJsonStringValidExtended() throws Exception {
-    Graph g = new TinkerGraph();
-    ElementFactory factory = new ElementFactory(g);
-
-    String vertexJson = "{\"person\":{\"value\":\"marko\",\"type\":\"string\"},\"_id\":1,\"_type\":\"vertex\"}";
-    Vertex v = GraphsonUtil.vertexFromJson(vertexJson, factory, GraphsonMode.EXTENDED, null);
-
-    Assert.assertSame(v, g.getVertex(1));
-
-    // tinkergraph converts id to string
-    Assert.assertEquals("1", v.getId());
-    Assert.assertEquals("marko", v.getProperty("person"));
-  }
-
-  @Test
-  public void vertexFromJsonInputStreamValid() throws Exception {
-    Graph g = new TinkerGraph();
-    ElementFactory factory = new ElementFactory(g);
-
-    Vertex v = GraphsonUtil.vertexFromJson(inputStreamVertexJson1, factory, GraphsonMode.NORMAL, null);
-
-    Assert.assertSame(v, g.getVertex(1));
-
-    // tinkergraph converts id to string
-    Assert.assertEquals("1", v.getId());
-    Assert.assertEquals("marko", v.getProperty("name"));
-    Assert.assertEquals(29L, v.getProperty("age"));
-  }
-
-  @Test
-  public void vertexFromJsonIgnoreKeyValid() {
-    Graph g = new TinkerGraph();
-    ElementFactory factory = new ElementFactory(g);
-
-    Set<String> ignoreAge = new HashSet<>();
-    ignoreAge.add("age");
-    ElementPropertyConfig config = ElementPropertyConfig.excludeProperties(ignoreAge, null);
-    GraphsonUtil utility = new GraphsonUtil(GraphsonMode.NORMAL, factory, config);
-    Vertex v = utility.vertexFromJson((JSONObject) JSONValue.parse(vertexJson1));
-
-    Assert.assertSame(v, g.getVertex(1));
-
-    // tinkergraph converts id to string
-    Assert.assertEquals("1", v.getId());
-    Assert.assertEquals("marko", v.getProperty("name"));
-    Assert.assertNull(v.getProperty("age"));
-  }
-
-  @Test
-  public void edgeFromJsonValid() throws Exception {
-    Graph g = new TinkerGraph();
-    ElementFactory factory = new ElementFactory(g);
-
-    Vertex v1 = GraphsonUtil.vertexFromJson((JSONObject) JSONValue.parse(vertexJson1), factory, GraphsonMode.NORMAL, null);
-    Vertex v2 = GraphsonUtil.vertexFromJson((JSONObject) JSONValue.parse(vertexJson2), factory, GraphsonMode.NORMAL, null);
-    Edge e = GraphsonUtil.edgeFromJson((JSONObject) JSONValue.parse(edgeJson), v1, v2, factory, GraphsonMode.NORMAL, null);
-
-    Assert.assertSame(v1, g.getVertex(1));
-    Assert.assertSame(v2, g.getVertex(2));
-    Assert.assertSame(e, g.getEdge(7));
-
-    // tinkergraph converts id to string
-    Assert.assertEquals("7", e.getId());
-    Assert.assertEquals(0.5d, e.getProperty("weight"));
-    Assert.assertEquals("knows", e.getLabel());
-    Assert.assertEquals(v1, e.getVertex(Direction.OUT));
-    Assert.assertEquals(v2, e.getVertex(Direction.IN));
-  }
-
-  @Test
-  public void edgeFromJsonStringValid() throws Exception {
-    Graph g = new TinkerGraph();
-    ElementFactory factory = new ElementFactory(g);
-
-    Vertex v1 = GraphsonUtil.vertexFromJson(vertexJson1, factory, GraphsonMode.NORMAL, null);
-    Vertex v2 = GraphsonUtil.vertexFromJson(vertexJson2, factory, GraphsonMode.NORMAL, null);
-    Edge e = GraphsonUtil.edgeFromJson(edgeJson, v1, v2, factory, GraphsonMode.NORMAL, null);
-
-    Assert.assertSame(v1, g.getVertex(1));
-    Assert.assertSame(v2, g.getVertex(2));
-    Assert.assertSame(e, g.getEdge(7));
-
-    // tinkergraph converts id to string
-    Assert.assertEquals("7", e.getId());
-    Assert.assertEquals(0.5d, e.getProperty("weight"));
-    Assert.assertEquals("knows", e.getLabel());
-    Assert.assertEquals(v1, e.getVertex(Direction.OUT));
-    Assert.assertEquals(v2, e.getVertex(Direction.IN));
-  }
-
-  @Test
-  public void edgeFromJsonIgnoreWeightValid() throws Exception {
-    Graph g = new TinkerGraph();
-    ElementFactory factory = new ElementFactory(g);
-
-    Vertex v1 = GraphsonUtil.vertexFromJson((JSONObject) JSONValue.parse(vertexJson1), factory, GraphsonMode.NORMAL, null);
-    Vertex v2 = GraphsonUtil.vertexFromJson((JSONObject) JSONValue.parse(vertexJson2), factory, GraphsonMode.NORMAL, null);
-
-    Set<String> ignoreWeight = new HashSet<>();
-    ignoreWeight.add("weight");
-    ElementPropertyConfig config = ElementPropertyConfig.excludeProperties(null, ignoreWeight);
-    GraphsonUtil utility = new GraphsonUtil(GraphsonMode.NORMAL, factory, config);
-    Edge e = utility.edgeFromJson((JSONObject) JSONValue.parse(edgeJson), v1, v2);
-
-    Assert.assertSame(v1, g.getVertex(1));
-    Assert.assertSame(v2, g.getVertex(2));
-    Assert.assertSame(e, g.getEdge(7));
-
-    // tinkergraph converts id to string
-    Assert.assertEquals("7", e.getId());
-    Assert.assertNull(e.getProperty("weight"));
-    Assert.assertEquals("knows", e.getLabel());
-    Assert.assertEquals(v1, e.getVertex(Direction.OUT));
-    Assert.assertEquals(v2, e.getVertex(Direction.IN));
-  }
-
-  @Test
-  public void edgeFromJsonNormalLabelOrIdOnEdge() throws Exception {
-    Graph g = new TinkerGraph();
-    ElementFactory factory = new ElementFactory(g);
-
-    Vertex v1 = GraphsonUtil.vertexFromJson((JSONObject) JSONValue.parse(vertexJson1), factory, GraphsonMode.NORMAL, null);
-    Vertex v2 = GraphsonUtil.vertexFromJson((JSONObject) JSONValue.parse(vertexJson2), factory, GraphsonMode.NORMAL, null);
-    Edge e = GraphsonUtil.edgeFromJson((JSONObject) JSONValue.parse(edgeJsonLight), v1, v2, factory, GraphsonMode.NORMAL, null);
-
-    Assert.assertSame(v1, g.getVertex(1));
-    Assert.assertSame(v2, g.getVertex(2));
-    Assert.assertSame(e, g.getEdge(0));
-  }
-
-  @Test
-  public void edgeFromJsonInputStreamCompactLabelOrIdOnEdge() throws Exception {
-    Graph g = new TinkerGraph();
-    ElementFactory factory = new ElementFactory(g);
-
-    Vertex v1 = GraphsonUtil.vertexFromJson((JSONObject) JSONValue.parse(vertexJson1), factory, GraphsonMode.COMPACT, null);
-    Vertex v2 = GraphsonUtil.vertexFromJson((JSONObject) JSONValue.parse(vertexJson2), factory, GraphsonMode.COMPACT, null);
-    Edge e = GraphsonUtil.edgeFromJson(inputStreamEdgeJsonLight, v1, v2, factory, GraphsonMode.COMPACT, null);
-
-    Assert.assertSame(v1, g.getVertex(1));
-    Assert.assertSame(v2, g.getVertex(2));
-    Assert.assertSame(e, g.getEdge(0));
-  }
-
-  @Test
-  public void edgeFromJsonInputStreamCompactNoIdOnEdge() throws Exception {
-    Graph g = new TinkerGraph();
-    ElementFactory factory = new ElementFactory(g);
-
-    Set<String> vertexKeys = new HashSet<String>() {{
-      add(GraphSONTokens._ID);
-    }};
-
-    Set<String> edgeKeys = new HashSet<String>() {{
-      add(GraphSONTokens._IN_V);
-    }};
-
-    GraphsonUtil graphson = new GraphsonUtil(GraphsonMode.COMPACT, factory, vertexKeys, edgeKeys);
-
-    Vertex v1 = graphson.vertexFromJson((JSONObject) JSONValue.parse(vertexJson1));
-    Vertex v2 = graphson.vertexFromJson((JSONObject) JSONValue.parse(vertexJson2));
-    Edge e = graphson.edgeFromJson(inputStreamEdgeJsonLight, v1, v2);
-
-    Assert.assertSame(v1, g.getVertex(1));
-    Assert.assertSame(v2, g.getVertex(2));
-    Assert.assertSame(e, g.getEdge(0));
-  }
-
-  private class Cat {
-    private String name;
-
-    public Cat(String name) {
-      this.name = name;
-    }
-
-    public String getName() {
-      return this.name;
-    }
-
-    @Override
-    public String toString() {
-      return this.name;
-    }
-  }
-}
diff --git a/sonar-core/src/test/java/org/sonar/core/graph/graphson/GraphsonWriterTest.java b/sonar-core/src/test/java/org/sonar/core/graph/graphson/GraphsonWriterTest.java
deleted file mode 100644 (file)
index 8a08894..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.graph.graphson;
-
-import com.tinkerpop.blueprints.Graph;
-import com.tinkerpop.blueprints.impls.tg.TinkerGraphFactory;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
-import org.junit.Test;
-
-import java.io.StringWriter;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class GraphsonWriterTest {
-
-  @Test
-  public void outputGraphNoEmbeddedTypes() throws Exception {
-    Graph g = TinkerGraphFactory.createTinkerGraph();
-
-    StringWriter stream = new StringWriter();
-
-    GraphsonWriter writer = new GraphsonWriter();
-    writer.write(g, stream, GraphsonMode.NORMAL);
-
-    stream.flush();
-    stream.close();
-
-    String jsonString = stream.toString();
-
-    JSONObject rootNode = (JSONObject) JSONValue.parse(jsonString);
-
-    // ensure that the JSON conforms to basic structure and that the right
-    // number of graph elements are present.  other tests already cover element formatting
-    assertThat(rootNode).isNotNull();
-    assertThat(rootNode.containsKey(GraphsonTokens.MODE)).isTrue();
-    assertThat(rootNode.get(GraphsonTokens.MODE)).isEqualTo("NORMAL");
-
-    assertThat(rootNode.containsKey(GraphsonTokens.VERTICES)).isTrue();
-
-    JSONArray vertices = (JSONArray) rootNode.get(GraphsonTokens.VERTICES);
-    assertThat(vertices).hasSize(6);
-
-    assertThat(rootNode.containsKey(GraphsonTokens.EDGES)).isTrue();
-
-    JSONArray edges = (JSONArray) rootNode.get(GraphsonTokens.EDGES);
-    assertThat(edges).hasSize(6);
-  }
-
-  @Test
-  public void outputGraphWithEmbeddedTypes() throws Exception {
-    Graph g = TinkerGraphFactory.createTinkerGraph();
-
-    StringWriter stream = new StringWriter();
-
-    GraphsonWriter writer = new GraphsonWriter();
-    writer.write(g, stream, GraphsonMode.EXTENDED);
-
-    stream.flush();
-    stream.close();
-
-    String jsonString = stream.toString();
-
-    JSONObject rootNode = (JSONObject) JSONValue.parse(jsonString);
-
-    // ensure that the JSON conforms to basic structure and that the right
-    // number of graph elements are present.  other tests already cover element formatting
-    assertThat(rootNode).isNotNull();
-    assertThat(rootNode.containsKey(GraphsonTokens.MODE)).isTrue();
-    assertThat(rootNode.get(GraphsonTokens.MODE)).isEqualTo("EXTENDED");
-
-    assertThat(rootNode.containsKey(GraphsonTokens.VERTICES)).isTrue();
-
-    JSONArray vertices = (JSONArray) rootNode.get(GraphsonTokens.VERTICES);
-    assertThat(vertices).hasSize(6);
-
-    assertThat(rootNode.containsKey(GraphsonTokens.EDGES)).isTrue();
-
-    JSONArray edges = (JSONArray) rootNode.get(GraphsonTokens.EDGES);
-    assertThat(edges).hasSize(6);
-  }
-
-  @Test
-  public void outputGraphWithCompact() throws Exception {
-    Graph g = TinkerGraphFactory.createTinkerGraph();
-
-    StringWriter stream = new StringWriter();
-
-    GraphsonWriter writer = new GraphsonWriter();
-    writer.write(g, stream, GraphsonMode.COMPACT);
-
-    stream.flush();
-    stream.close();
-
-    String jsonString = stream.toString();
-
-    JSONObject rootNode = (JSONObject) JSONValue.parse(jsonString);
-
-    // ensure that the JSON conforms to basic structure and that the right
-    // number of graph elements are present.  other tests already cover element formatting
-    assertThat(rootNode).isNotNull();
-    assertThat(rootNode.containsKey(GraphsonTokens.MODE)).isTrue();
-    assertThat(rootNode.get(GraphsonTokens.MODE)).isEqualTo("COMPACT");
-
-    assertThat(rootNode.containsKey(GraphsonTokens.VERTICES)).isTrue();
-
-    JSONArray vertices = (JSONArray) rootNode.get(GraphsonTokens.VERTICES);
-    assertThat(vertices).hasSize(6);
-
-    assertThat(rootNode.containsKey(GraphsonTokens.EDGES)).isTrue();
-
-    JSONArray edges = (JSONArray) rootNode.get(GraphsonTokens.EDGES);
-    assertThat(edges).hasSize(6);
-  }
-}
diff --git a/sonar-core/src/test/java/org/sonar/core/test/DefaultTestCaseTest.java b/sonar-core/src/test/java/org/sonar/core/test/DefaultTestCaseTest.java
deleted file mode 100644 (file)
index 6834606..0000000
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.test;
-
-import com.google.common.collect.Iterables;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.sonar.api.component.mock.MockSourceFile;
-import org.sonar.api.test.CoverageBlock;
-import org.sonar.api.test.TestCase;
-import org.sonar.api.test.exception.CoverageAlreadyExistsException;
-import org.sonar.api.test.exception.IllegalDurationException;
-import org.sonar.core.component.ComponentVertex;
-import org.sonar.core.component.ScanGraph;
-import org.sonar.core.graph.BeanGraph;
-
-import java.util.Arrays;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class DefaultTestCaseTest {
-
-  @Rule
-  public ExpectedException thrown = ExpectedException.none();
-
-  @Test
-  public void no_coverage_blocks() {
-    BeanGraph beanGraph = BeanGraph.createInMemory();
-    DefaultTestCase testCase = beanGraph.createVertex(DefaultTestCase.class);
-
-    assertThat(testCase.doesCover()).isFalse();
-    assertThat(testCase.countCoveredLines()).isEqualTo(0);
-    assertThat(testCase.coverageBlocks()).isEmpty();
-  }
-
-  @Test
-  public void should_cover_testable() {
-    BeanGraph beanGraph = BeanGraph.createInMemory();
-    DefaultTestable testable = beanGraph.createVertex(DefaultTestable.class);
-    DefaultTestCase testCase = beanGraph.createVertex(DefaultTestCase.class);
-    testCase.setCoverageBlock(testable, Arrays.asList(10, 11, 12));
-
-    assertThat(testCase.doesCover()).isTrue();
-    assertThat(testCase.countCoveredLines()).isEqualTo(3);
-    assertThat(testCase.coverageBlocks()).hasSize(1);
-
-    CoverageBlock cover = Iterables.getFirst(testCase.coverageBlocks(), null);
-    assertThat(cover.testCase()).isEqualTo(testCase);
-    assertThat(cover.testable()).isSameAs(testable);
-    assertThat(cover.lines()).containsExactly(10, 11, 12);
-  }
-
-  @Test
-  public void should_cover_multiple_testables() {
-    ScanGraph graph = ScanGraph.create();
-    ComponentVertex file1 = graph.addComponent(MockSourceFile.createMain("org.foo.Bar"));
-    DefaultTestable testable1 = graph.createAdjacentVertex(file1, DefaultTestable.class, "testable");
-    ComponentVertex file2 = graph.addComponent(MockSourceFile.createMain("org.foo.File"));
-    DefaultTestable testable2 = graph.createAdjacentVertex(file2, DefaultTestable.class, "testable");
-    DefaultTestCase testCase = graph.createVertex(DefaultTestCase.class);
-
-    testCase.setCoverageBlock(testable1, Arrays.asList(10, 11, 12));
-    testCase.setCoverageBlock(testable2, Arrays.asList(12, 13, 14));
-
-    assertThat(testCase.doesCover()).isTrue();
-    assertThat(testCase.countCoveredLines()).isEqualTo(6);
-    assertThat(testCase.coverageBlocks()).hasSize(2);
-  }
-
-  @Test
-  public void should_return_cover_of_testable() {
-    BeanGraph beanGraph = BeanGraph.createInMemory();
-
-    ScanGraph graph = ScanGraph.create();
-    ComponentVertex file1 = graph.addComponent(MockSourceFile.createMain("org.foo.Bar"));
-    DefaultTestable testable1 = beanGraph.createAdjacentVertex(file1, DefaultTestable.class, "testable");
-
-    ComponentVertex file2 = graph.addComponent(MockSourceFile.createMain("org.foo.File"));
-    DefaultTestable testable2 = beanGraph.createAdjacentVertex(file2, DefaultTestable.class, "testable");
-
-    DefaultTestCase testCase = beanGraph.createVertex(DefaultTestCase.class);
-    testCase.setCoverageBlock(testable1, Arrays.asList(10, 11, 12));
-
-    assertThat(testCase.coverageBlock(testable1).testable()).isEqualTo(testable1);
-    assertThat(testCase.coverageBlock(testable1).testCase()).isEqualTo(testCase);
-    assertThat(testCase.coverageBlock(testable2)).isNull();
-  }
-
-  @Test
-  public void should_set_metadata() {
-    BeanGraph beanGraph = BeanGraph.createInMemory();
-    DefaultTestCase testCase = beanGraph.createVertex(DefaultTestCase.class);
-
-    testCase.setName("T1")
-      .setDurationInMs(1234L)
-      .setMessage("Error msg")
-      .setStackTrace("xxx")
-      .setType(TestCase.TYPE_UNIT)
-      .setStatus(TestCase.Status.ERROR);
-
-    assertThat(testCase.name()).isEqualTo("T1");
-    assertThat(testCase.message()).isEqualTo("Error msg");
-    assertThat(testCase.stackTrace()).isEqualTo("xxx");
-    assertThat(testCase.durationInMs()).isEqualTo(1234L);
-    assertThat(testCase.status()).isEqualTo(TestCase.Status.ERROR);
-    assertThat(testCase.type()).isEqualTo(TestCase.TYPE_UNIT);
-  }
-
-  @Test
-  public void duration_should_be_positive() {
-    thrown.expect(IllegalDurationException.class);
-    thrown.expectMessage("Test duration must be positive (got: -1234)");
-
-    BeanGraph beanGraph = BeanGraph.createInMemory();
-    DefaultTestCase testCase = beanGraph.createVertex(DefaultTestCase.class);
-
-    testCase.setDurationInMs(-1234L);
-  }
-
-  @Test
-  public void should_fail_if_coverage_block_already_exits() {
-    thrown.expect(CoverageAlreadyExistsException.class);
-
-    ScanGraph graph = ScanGraph.create();
-
-    ComponentVertex file = graph.addComponent(MockSourceFile.createMain("org.foo.Bar"));
-    DefaultTestable testable = graph.createAdjacentVertex(file, DefaultTestable.class, "testable");
-
-    DefaultTestCase testCase = graph.createVertex(DefaultTestCase.class);
-    testCase.setCoverageBlock(testable, Arrays.asList(10, 11, 12));
-
-    // error
-    testCase.setCoverageBlock(testable, Arrays.asList(20));
-  }
-}
diff --git a/sonar-core/src/test/java/org/sonar/core/test/DefaultTestPlanTest.java b/sonar-core/src/test/java/org/sonar/core/test/DefaultTestPlanTest.java
deleted file mode 100644 (file)
index 27d3946..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.test;
-
-import com.google.common.collect.Iterables;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.sonar.api.test.MutableTestCase;
-import org.sonar.core.graph.BeanGraph;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class DefaultTestPlanTest {
-  @Rule
-  public ExpectedException thrown = ExpectedException.none();
-
-  @Test
-  public void should_not_have_test_cases() {
-    BeanGraph beanGraph = BeanGraph.createInMemory();
-
-    DefaultTestPlan plan = beanGraph.createVertex(DefaultTestPlan.class);
-    assertThat(plan.testCases()).isEmpty();
-  }
-
-  @Test
-  public void should_add_test_cases() {
-    BeanGraph beanGraph = BeanGraph.createInMemory();
-
-    DefaultTestPlan plan = beanGraph.createVertex(DefaultTestPlan.class);
-    plan.addTestCase("T1");
-    plan.addTestCase("T2");
-
-    assertThat(plan.testCases()).hasSize(2);
-    MutableTestCase firstTestCase = Iterables.get(plan.testCases(), 0);
-    assertThat(firstTestCase.name()).isEqualTo("T1");
-    assertThat(firstTestCase.testPlan()).isSameAs(plan);
-
-    MutableTestCase secondTestCase = Iterables.get(plan.testCases(), 1);
-    assertThat(secondTestCase.name()).isEqualTo("T2");
-    assertThat(secondTestCase.testPlan()).isSameAs(plan);
-  }
-
-  @Test
-  public void should_find_test_case_by_name() {
-    BeanGraph beanGraph = BeanGraph.createInMemory();
-
-    DefaultTestPlan plan = beanGraph.createVertex(DefaultTestPlan.class);
-    plan.addTestCase("T1");
-    plan.addTestCase("T2");
-
-    assertThat(plan.testCasesByName("T1")).hasSize(1);
-    assertThat(Iterables.get(plan.testCasesByName("T1"), 0).name()).isEqualTo("T1");
-    assertThat(plan.testCasesByName("T3")).isEmpty();
-  }
-
-  @Test
-  public void should_find_multiple_test_cases_by_name() {
-    BeanGraph beanGraph = BeanGraph.createInMemory();
-
-    DefaultTestPlan plan = beanGraph.createVertex(DefaultTestPlan.class);
-    plan.addTestCase("T1");
-    plan.addTestCase("T1");
-
-    assertThat(plan.testCasesByName("T1")).hasSize(2);
-  }
-}
diff --git a/sonar-core/src/test/java/org/sonar/core/test/DefaultTestableTest.java b/sonar-core/src/test/java/org/sonar/core/test/DefaultTestableTest.java
deleted file mode 100644 (file)
index 23e92bb..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.test;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Iterables;
-import org.junit.Test;
-import org.sonar.api.component.mock.MockSourceFile;
-import org.sonar.api.test.MutableTestCase;
-import org.sonar.core.component.ComponentVertex;
-import org.sonar.core.component.ScanGraph;
-import org.sonar.core.graph.BeanGraph;
-
-import java.util.Arrays;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class DefaultTestableTest {
-
-  @Test
-  public void not_have_tested_lines() {
-    BeanGraph beanGraph = BeanGraph.createInMemory();
-
-    DefaultTestable testable = beanGraph.createVertex(DefaultTestable.class);
-    assertThat(testable.testedLines()).isEmpty();
-  }
-
-  @Test
-  public void tested_lines() {
-    BeanGraph beanGraph = BeanGraph.createInMemory();
-
-    DefaultTestable testable = beanGraph.createVertex(DefaultTestable.class);
-    DefaultTestCase testCase1 = beanGraph.createVertex(DefaultTestCase.class);
-    testCase1.setCoverageBlock(testable, Arrays.asList(10, 11, 12));
-    DefaultTestCase testCase2 = beanGraph.createVertex(DefaultTestCase.class);
-    testCase2.setCoverageBlock(testable, Arrays.asList(12, 48, 49));
-
-    assertThat(testable.testedLines()).containsOnly(10, 11, 12, 48, 49);
-    assertThat(testable.countTestCasesOfLine(2)).isEqualTo(0);
-    assertThat(testable.countTestCasesOfLine(10)).isEqualTo(1);
-    assertThat(testable.countTestCasesOfLine(12)).isEqualTo(2);
-  }
-
-  @Test
-  public void get_test_cases() {
-    BeanGraph beanGraph = BeanGraph.createInMemory();
-
-    DefaultTestable testable = beanGraph.createVertex(DefaultTestable.class);
-    DefaultTestCase testCase1 = beanGraph.createVertex(DefaultTestCase.class);
-    testCase1.setCoverageBlock(testable, Arrays.asList(10, 11, 12));
-    DefaultTestCase testCase2 = beanGraph.createVertex(DefaultTestCase.class);
-    testCase2.setCoverageBlock(testable, Arrays.asList(12, 48, 49));
-
-    assertThat(testable.testCases()).containsOnly(testCase1, testCase2);
-    assertThat(testable.testCasesOfLine(5)).isEmpty();
-    assertThat(testable.testCasesOfLine(10)).containsExactly(testCase1);
-    assertThat(testable.testCasesOfLine(12)).contains(testCase1, testCase2);
-  }
-
-  @Test
-  public void get_test_case_by_key() {
-    BeanGraph beanGraph = BeanGraph.createInMemory();
-
-    DefaultTestPlan plan = beanGraph.createVertex(DefaultTestPlan.class);
-    plan.addTestCase("T1");
-    plan.addTestCase("T2");
-
-    DefaultTestable testable = beanGraph.createVertex(DefaultTestable.class);
-    MutableTestCase testCase1 = Iterables.get(plan.testCases(), 0);
-    testCase1.setCoverageBlock(testable, Arrays.asList(10, 11, 12));
-    MutableTestCase testCase2 = Iterables.get(plan.testCases(), 1);
-    testCase2.setCoverageBlock(testable, Arrays.asList(12, 48, 49));
-
-    assertThat(testable.testCaseByName("T1")).isEqualTo(testCase1);
-    assertThat(testable.testCaseByName("T2")).isEqualTo(testCase2);
-    assertThat(testable.testCaseByName("Unknown")).isNull();
-  }
-
-  @Test
-  public void return_cover_of_testCase(){
-    BeanGraph beanGraph = BeanGraph.createInMemory();
-
-    ScanGraph graph = ScanGraph.create();
-    ComponentVertex file1 = graph.addComponent(MockSourceFile.createMain("org.foo.Bar"));
-    DefaultTestable testable1 = beanGraph.createAdjacentVertex(file1, DefaultTestable.class, "testable");
-
-    ComponentVertex file2 = graph.addComponent(MockSourceFile.createMain("org.foo.File"));
-    DefaultTestable testable2 = beanGraph.createAdjacentVertex(file2, DefaultTestable.class, "testable");
-
-    DefaultTestPlan plan = beanGraph.createVertex(DefaultTestPlan.class);
-    plan.addTestCase("T1");
-
-    MutableTestCase testCase = Iterables.get(plan.testCases(), 0);
-    testCase.setCoverageBlock(testable1, Arrays.asList(10, 11, 12));
-
-    assertThat(testable1.coverageBlock(testCase).testCase()).isEqualTo(testCase);
-    assertThat(testable1.coverageBlock(testCase).testable()).isEqualTo(testable1);
-    assertThat(testable2.coverageBlock(testCase)).isNull();
-  }
-
-  @Test
-  public void test_cases_by_lines() {
-    BeanGraph beanGraph = BeanGraph.createInMemory();
-
-    DefaultTestable testable = beanGraph.createVertex(DefaultTestable.class);
-    DefaultTestCase testCase1 = beanGraph.createVertex(DefaultTestCase.class);
-    testCase1.setCoverageBlock(testable, Arrays.asList(10, 11, 12));
-    DefaultTestCase testCase2 = beanGraph.createVertex(DefaultTestCase.class);
-    testCase2.setCoverageBlock(testable, Arrays.asList(12, 48, 49));
-
-    assertThat(testable.testCasesByLines()).isEqualTo(ImmutableMap.of(49, 1, 48, 1, 10, 1, 11, 1, 12, 2));
-  }
-}
diff --git a/sonar-core/src/test/java/org/sonar/core/test/TestPlanBuilderTest.java b/sonar-core/src/test/java/org/sonar/core/test/TestPlanBuilderTest.java
deleted file mode 100644 (file)
index 0b455e5..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.test;
-
-import org.junit.Test;
-import org.sonar.api.component.mock.MockSourceFile;
-import org.sonar.api.test.MutableTestPlan;
-import org.sonar.core.component.ComponentVertex;
-import org.sonar.core.component.ScanGraph;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class TestPlanBuilderTest {
-  @Test
-  public void test_path() {
-
-    ScanGraph graph = ScanGraph.create();
-    TestPlanPerspectiveLoader loader = new TestPlanPerspectiveLoader();
-    TestPlanBuilder builder = new TestPlanBuilder(graph, loader);
-
-    assertThat(builder.path().getElements()).isNotEmpty();
-  }
-
-  @Test
-  public void should_not_load_missing_perspective() {
-    ScanGraph graph = ScanGraph.create();
-    TestPlanPerspectiveLoader loader = new TestPlanPerspectiveLoader();
-    TestPlanBuilder builder = new TestPlanBuilder(graph, loader);
-    ComponentVertex file = graph.addComponent(MockSourceFile.createMain("org.foo.Bar"));
-
-    assertThat(builder.getPerspectiveLoader().load(file)).isNull();
-  }
-
-  @Test
-  public void should_create_perspective() {
-    ScanGraph graph = ScanGraph.create();
-    TestPlanPerspectiveLoader loader = new TestPlanPerspectiveLoader();
-    TestPlanBuilder builder = new TestPlanBuilder(graph, loader);
-    ComponentVertex file = graph.addComponent(MockSourceFile.createMain("org.foo.Bar"));
-
-    MutableTestPlan plan = builder.create(file);
-    assertThat(plan).isNotNull();
-    assertThat(plan.component()).isSameAs(file);
-    assertThat(builder.getPerspectiveLoader().load(file)).isSameAs(plan);
-  }
-}
diff --git a/sonar-core/src/test/java/org/sonar/core/test/TestableBuilderTest.java b/sonar-core/src/test/java/org/sonar/core/test/TestableBuilderTest.java
deleted file mode 100644 (file)
index e9a962f..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.test;
-
-import org.junit.Test;
-import org.sonar.api.component.mock.MockSourceFile;
-import org.sonar.api.test.MutableTestable;
-import org.sonar.core.component.ComponentVertex;
-import org.sonar.core.component.ScanGraph;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class TestableBuilderTest {
-  @Test
-  public void test_path() {
-    ScanGraph graph = ScanGraph.create();
-    TestablePerspectiveLoader loader = new TestablePerspectiveLoader();
-    TestableBuilder builder = new TestableBuilder(graph, loader);
-
-    assertThat(builder.path().getElements()).isNotEmpty();
-  }
-
-  @Test
-  public void should_not_load_missing_perspective() {
-    ScanGraph graph = ScanGraph.create();
-    TestablePerspectiveLoader loader = new TestablePerspectiveLoader();
-    TestableBuilder builder = new TestableBuilder(graph, loader);
-    ComponentVertex file = graph.addComponent(MockSourceFile.createMain("org.foo.Bar"));
-
-    assertThat(builder.getPerspectiveLoader().load(file)).isNull();
-  }
-
-  @Test
-  public void should_create_perspective() {
-    ScanGraph graph = ScanGraph.create();
-    TestablePerspectiveLoader loader = new TestablePerspectiveLoader();
-    TestableBuilder builder = new TestableBuilder(graph, loader);
-    ComponentVertex file = graph.addComponent(MockSourceFile.createMain("org.foo.Bar"));
-
-    MutableTestable testable = builder.create(file);
-    assertThat(testable).isNotNull();
-    assertThat(testable.component()).isSameAs(file);
-    assertThat(builder.getPerspectiveLoader().load(file)).isSameAs(testable);
-  }
-}
index 098b469a172fe77d6bac7913f2040af3a0a8f9e9..9ae9872d603777900b0ca9ca1513a4e464e11fb5 100644 (file)
@@ -21,6 +21,10 @@ package org.sonar.api.component;
 
 import javax.annotation.CheckForNull;
 
+/**
+ * @deprecated since 5.2
+ */
+@Deprecated
 public interface Component {
   String key();
 
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/component/MutablePerspective.java b/sonar-plugin-api/src/main/java/org/sonar/api/component/MutablePerspective.java
deleted file mode 100644 (file)
index 8395148..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.api.component;
-
-public interface MutablePerspective extends Perspective {
-}
index 9f5395c0a02b49d1077866fbb57c5b3f45caa6ee..10bbed9a754f3d493fbe8eb587e552b80d088706 100644 (file)
@@ -19,6 +19,9 @@
  */
 package org.sonar.api.component;
 
+/**
+ * @deprecated since 5.2
+ */
+@Deprecated
 public interface Perspective<C extends Component> {
-  C component();
 }
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/component/Perspectives.java b/sonar-plugin-api/src/main/java/org/sonar/api/component/Perspectives.java
deleted file mode 100644 (file)
index 58eff62..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.api.component;
-
-import org.sonar.api.batch.BatchSide;
-import org.sonar.api.server.ServerSide;
-
-/**
- * @deprecated since 5.2 unused
- */
-@Deprecated
-@BatchSide
-@ServerSide
-public interface Perspectives {
-
-  <P extends Perspective> P as(Class<P> perspectiveClass, Component component);
-
-}
index 18bce8f9e36c9e3161ff6dfcb36fa6cc56581068..c14cf64d622f7d7b20f8f8f265ab9c6548b7d118 100644 (file)
  */
 package org.sonar.api.component;
 
+import javax.annotation.CheckForNull;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.fs.InputPath;
+import org.sonar.api.batch.sensor.SensorContext;
 import org.sonar.api.issue.Issuable;
 import org.sonar.api.resources.Resource;
 import org.sonar.api.source.Highlightable;
@@ -28,8 +30,6 @@ import org.sonar.api.source.Symbolizable;
 import org.sonar.api.test.TestPlan;
 import org.sonar.api.test.Testable;
 
-import javax.annotation.CheckForNull;
-
 /**
  * Use this component to create perspective from resources or {@link InputPath}
  * Only on batch-side.
@@ -57,8 +57,10 @@ import javax.annotation.CheckForNull;
  * @see Testable
  * @see TestPlan
  * @since 3.5
+ * @deprecated since 5.2. Use appropriate methods on {@link SensorContext}.
  */
-public interface ResourcePerspectives extends Perspectives {
+@Deprecated
+public interface ResourcePerspectives {
 
   @CheckForNull
   <P extends Perspective> P as(Class<P> perspectiveClass, Resource resource);
index 50a5e0c21ff01dff53a02406aa289c5214e62d37..05e528885ba1acc8affffa9f6fc5e5c554dabe09 100644 (file)
@@ -19,9 +19,9 @@
  */
 package org.sonar.api.test;
 
-import javax.annotation.Nullable;
-
 import java.util.List;
+import javax.annotation.Nullable;
+import org.sonar.api.batch.fs.InputFile;
 
 public interface MutableTestCase extends TestCase {
   MutableTestCase setStatus(@Nullable Status s);
@@ -38,5 +38,11 @@ public interface MutableTestCase extends TestCase {
   @Deprecated
   MutableTestCase setType(@Nullable String s);
 
+  /**
+   * @deprecated since 5.2. Use {@link #setCoverageBlock(InputFile, List)}
+   */
+  @Deprecated
   MutableTestCase setCoverageBlock(Testable testable, List<Integer> lines);
+
+  MutableTestCase setCoverageBlock(InputFile mainFile, List<Integer> lines);
 }
index 4659917f0eef2ea973b95eb197fc1f22b736522f..020606d412b0b7a0fca835b8d6f2c11d976d9b8f 100644 (file)
  */
 package org.sonar.api.test;
 
-import org.sonar.api.component.MutablePerspective;
-
-public interface MutableTestPlan extends TestPlan<MutableTestCase>, MutablePerspective {
+public interface MutableTestPlan extends TestPlan<MutableTestCase> {
 
   /**
    * Add a {@link TestCase} to this test file.
    * Note that a same physical test (for example in Java a single method annotated with @Test)
    * can be executed several times (parameterized tests, different test suites, ...). As a result it is perfectly valid to register several
-   * tests with the same name. Anyway in this situation the coverage per test.
+   * tests with the same name. Anyway in this situation the coverage per test will be merged for all tests with the same name.
    * @param name
    * @return
    */
index be9c30892b1278e2e78ec57469217e728bba6bc7..c1812cef41ed81b0dc988468f973c804b039cb3c 100644 (file)
@@ -19,8 +19,6 @@
  */
 package org.sonar.api.test;
 
-import org.sonar.api.component.MutablePerspective;
-
-public interface MutableTestable extends Testable, MutablePerspective {
+public interface MutableTestable extends Testable {
 
 }
index 301d347f9afd7de80a0361e9bffb7df4c8c38a1a..f7296c4cf6c735f840075517fbff814fe72166fc 100644 (file)
@@ -23,8 +23,9 @@ import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
 
 /**
- * Represents a simple test execution result.
+ * @deprecated since 5.2 not used
  */
+@Deprecated
 public interface TestCase {
   enum Status {
     OK, FAILURE, ERROR, SKIPPED;
@@ -75,5 +76,6 @@ public interface TestCase {
 
   Iterable<CoverageBlock> coverageBlocks();
 
+  @CheckForNull
   CoverageBlock coverageBlock(Testable testable);
 }
index 74b4291598e7c7bb945eb1f92cd4d415336dc5db..ac1655c1522caa666cde0c91190dbf1d63b06163 100644 (file)
@@ -22,8 +22,9 @@ package org.sonar.api.test;
 import org.sonar.api.component.Perspective;
 
 /**
- * A {@link TestPlan} is 
+ * @deprecated since 5.2 not used
  */
+@Deprecated
 public interface TestPlan<T extends TestCase> extends Perspective {
   Iterable<T> testCases();
 
index 7091b6bee8666abbb2f62ad8c20dcd55cdf23a23..7b1c0c35a68a6bc4b0dc31677979a16858f104e6 100644 (file)
  */
 package org.sonar.api.test;
 
-import org.sonar.api.component.Perspective;
-
 import java.util.List;
 import java.util.Map;
 import java.util.SortedSet;
+import org.sonar.api.component.Perspective;
 
+/**
+ * @deprecated since 5.2
+ */
+@Deprecated
 public interface Testable extends Perspective {
 
   List<TestCase> testCases();