]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6418 delete table GRAPHS
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 19 May 2015 17:22:32 +0000 (19:22 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 20 May 2015 09:02:53 +0000 (11:02 +0200)
25 files changed:
server/sonar-server/src/main/java/org/sonar/server/platform/BackendCleanup.java
server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java
server/sonar-server/src/main/java/org/sonar/server/test/CoverageService.java
server/sonar-server/src/test/java/org/sonar/server/test/CoverageServiceTest.java
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/915_drop_table_graphs.rb [new file with mode: 0644]
sonar-batch/src/main/java/org/sonar/batch/phases/GraphPersister.java [deleted file]
sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java
sonar-core/src/main/java/org/sonar/core/component/SnapshotPerspectives.java [deleted file]
sonar-core/src/main/java/org/sonar/core/graph/SubGraph.java [deleted file]
sonar-core/src/main/java/org/sonar/core/graph/jdbc/GraphDao.java [deleted file]
sonar-core/src/main/java/org/sonar/core/graph/jdbc/GraphDto.java [deleted file]
sonar-core/src/main/java/org/sonar/core/graph/jdbc/GraphDtoMapper.java [deleted file]
sonar-core/src/main/java/org/sonar/core/graph/jdbc/package-info.java [deleted file]
sonar-core/src/main/java/org/sonar/core/persistence/DaoUtils.java
sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java
sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java
sonar-core/src/main/java/org/sonar/core/purge/PurgeCommands.java
sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java
sonar-core/src/main/resources/org/sonar/core/graph/jdbc/GraphDtoMapper.xml [deleted file]
sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql
sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl
sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml
sonar-core/src/test/java/org/sonar/core/graph/SubGraphTest.java [deleted file]
sonar-core/src/test/java/org/sonar/core/graph/jdbc/GraphDaoTest.java [deleted file]
sonar-core/src/test/resources/org/sonar/core/graph/jdbc/GraphDaoTest/shared.xml [deleted file]

index 3a4d87a78c00cb0c4f2f621fffb8e03d4ca44536..22e7c803569b50caed581f4b0462f86e79630628 100644 (file)
@@ -39,7 +39,7 @@ import java.sql.SQLException;
 public class BackendCleanup {
 
   private static final String[] INSPECTION_TABLES = {
-    "action_plans", "authors", "dependencies", "duplications_index", "events", "graphs", "issues", "issue_changes", "manual_measures",
+    "action_plans", "authors", "dependencies", "duplications_index", "events", "issues", "issue_changes", "manual_measures",
     "notifications", "project_links", "project_measures", "projects", "resource_index",
     "semaphores", "snapshots", "file_sources"
   };
index c20b51777826841c9c2db6a9ae5f6bf2f02abfe4..0f08118e17b775625654a454aa63abccb9cb1b94 100644 (file)
@@ -31,7 +31,6 @@ import org.sonar.api.resources.ResourceTypes;
 import org.sonar.api.rules.AnnotationRuleParser;
 import org.sonar.api.rules.XMLRuleParser;
 import org.sonar.api.server.rule.RulesDefinitionXmlLoader;
-import org.sonar.core.component.SnapshotPerspectives;
 import org.sonar.core.computation.dbcleaner.DefaultPurgeTask;
 import org.sonar.core.computation.dbcleaner.IndexPurgeListener;
 import org.sonar.core.computation.dbcleaner.ProjectCleaner;
@@ -637,7 +636,6 @@ public class PlatformLevel4 extends PlatformLevel {
       // graphs and perspective related classes
       TestablePerspectiveLoader.class,
       TestPlanPerspectiveLoader.class,
-      SnapshotPerspectives.class,
 
       // Type validation
       TypeValidations.class,
index b56a58b7f5a2d71072ad03db5d28e54f902a881d..d52a4bfc1002dbec05fb2c94875129b43f254e50 100644 (file)
 
 package org.sonar.server.test;
 
+import com.google.common.collect.Maps;
 import java.util.Map;
-
 import javax.annotation.CheckForNull;
-
 import org.sonar.api.ServerSide;
 import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.test.MutableTestable;
-import org.sonar.api.test.Testable;
 import org.sonar.api.utils.KeyValueFormat;
 import org.sonar.api.web.UserRole;
-import org.sonar.core.component.SnapshotPerspectives;
 import org.sonar.core.measure.db.MeasureDto;
 import org.sonar.core.persistence.DbSession;
 import org.sonar.core.persistence.MyBatis;
 import org.sonar.server.measure.persistence.MeasureDao;
 import org.sonar.server.user.UserSession;
 
-import com.google.common.collect.Maps;
-
 @ServerSide
 public class CoverageService {
 
@@ -48,13 +42,11 @@ public class CoverageService {
 
   private final MyBatis myBatis;
   private final MeasureDao measureDao;
-  private final SnapshotPerspectives snapshotPerspectives;
   private final UserSession userSession;
 
-  public CoverageService(MyBatis myBatis, MeasureDao measureDao, SnapshotPerspectives snapshotPerspectives, UserSession userSession) {
+  public CoverageService(MyBatis myBatis, MeasureDao measureDao, UserSession userSession) {
     this.myBatis = myBatis;
     this.measureDao = measureDao;
-    this.snapshotPerspectives = snapshotPerspectives;
     this.userSession = userSession;
   }
 
@@ -95,19 +87,6 @@ public class CoverageService {
     }
   }
 
-  /**
-   * Test cases is only return for unit tests
-   */
-  public Map<Integer, Integer> getTestCases(String fileKey, CoverageService.TYPE type) {
-    if (TYPE.UT.equals(type)) {
-      Testable testable = snapshotPerspectives.as(MutableTestable.class, fileKey);
-      if (testable != null) {
-        return testable.testCasesByLines();
-      }
-    }
-    return Maps.newHashMap();
-  }
-
   @CheckForNull
   private Map<Integer, Integer> findDataFromComponent(String fileKey, String metricKey) {
     DbSession session = myBatis.openSession(false);
index f018335a00ea382a34875ea3b7afad96ad62d8a3..5f71cb5ffa5d70d33e3f0f74d6ad5993a672e22f 100644 (file)
@@ -29,9 +29,7 @@ import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.runners.MockitoJUnitRunner;
 import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.test.MutableTestable;
 import org.sonar.api.web.UserRole;
-import org.sonar.core.component.SnapshotPerspectives;
 import org.sonar.core.persistence.DbSession;
 import org.sonar.core.persistence.MyBatis;
 import org.sonar.server.measure.persistence.MeasureDao;
@@ -57,15 +55,13 @@ public class CoverageServiceTest {
   DbSession session;
   @Mock
   MeasureDao measureDao;
-  @Mock
-  SnapshotPerspectives snapshotPerspectives;
   CoverageService service;
 
   @Before
   public void setUp() {
     MyBatis myBatis = mock(MyBatis.class);
     when(myBatis.openSession(false)).thenReturn(session);
-    service = new CoverageService(myBatis, measureDao, snapshotPerspectives, userSessionRule);
+    service = new CoverageService(myBatis, measureDao, userSessionRule);
   }
 
   @Test
@@ -117,23 +113,4 @@ public class CoverageServiceTest {
     service.getCoveredConditions(COMPONENT_KEY, CoverageService.TYPE.OVERALL);
     verify(measureDao).findByComponentKeyAndMetricKey(session, COMPONENT_KEY, CoreMetrics.OVERALL_COVERED_CONDITIONS_BY_LINE_KEY);
   }
-
-  @Test
-  public void get_test_cases_by_lines() {
-    MutableTestable testable = mock(MutableTestable.class);
-    when(snapshotPerspectives.as(MutableTestable.class, COMPONENT_KEY)).thenReturn(testable);
-
-    service.getTestCases(COMPONENT_KEY, CoverageService.TYPE.UT);
-    verify(testable).testCasesByLines();
-
-    assertThat(service.getTestCases(COMPONENT_KEY, CoverageService.TYPE.IT)).isEmpty();
-  }
-
-  @Test
-  public void not_get_test_cases_by_lines_if_no_testable() {
-    when(snapshotPerspectives.as(MutableTestable.class, COMPONENT_KEY)).thenReturn(null);
-
-    assertThat(service.getTestCases(COMPONENT_KEY, CoverageService.TYPE.UT)).isEqualTo(Collections.emptyMap());
-  }
-
 }
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/915_drop_table_graphs.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/915_drop_table_graphs.rb
new file mode 100644 (file)
index 0000000..0b5f273
--- /dev/null
@@ -0,0 +1,31 @@
+#
+# 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.
+#
+
+#
+# SonarQube 5.1
+#
+class DropTableGraphs < ActiveRecord::Migration
+
+  def self.up
+    remove_index 'graphs', :name => 'graphs_perspectives'
+    drop_table 'graphs'
+  end
+
+end
diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/GraphPersister.java b/sonar-batch/src/main/java/org/sonar/batch/phases/GraphPersister.java
deleted file mode 100644 (file)
index 1cc8b4b..0000000
+++ /dev/null
@@ -1,101 +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.phases;
-
-import com.tinkerpop.blueprints.Graph;
-import org.sonar.api.component.Perspective;
-import org.sonar.batch.index.ScanPersister;
-import org.sonar.core.component.ComponentVertex;
-import org.sonar.core.component.GraphPerspectiveBuilder;
-import org.sonar.core.component.PerspectiveBuilder;
-import org.sonar.core.component.ScanGraph;
-import org.sonar.core.graph.SubGraph;
-import org.sonar.core.graph.graphson.GraphsonMode;
-import org.sonar.core.graph.graphson.GraphsonWriter;
-import org.sonar.core.graph.jdbc.GraphDto;
-import org.sonar.core.graph.jdbc.GraphDtoMapper;
-import org.sonar.core.persistence.DbSession;
-import org.sonar.core.persistence.MyBatis;
-
-import java.io.IOException;
-import java.io.StringWriter;
-
-public class GraphPersister implements ScanPersister {
-  private final MyBatis myBatis;
-  private final ScanGraph projectGraph;
-  private final GraphPerspectiveBuilder[] builders;
-
-  public GraphPersister(MyBatis myBatis, ScanGraph projectGraph, GraphPerspectiveBuilder[] builders) {
-    this.myBatis = myBatis;
-    this.projectGraph = projectGraph;
-    this.builders = builders;
-  }
-
-  @Override
-  public void persist() {
-    DbSession session = myBatis.openSession(true);
-    GraphDtoMapper mapper = session.getMapper(GraphDtoMapper.class);
-    try {
-      for (ComponentVertex component : projectGraph.getComponents()) {
-        persistComponentGraph(mapper, component);
-      }
-      session.commit();
-    } finally {
-      session.close();
-    }
-  }
-
-  private void persistComponentGraph(GraphDtoMapper mapper, ComponentVertex component) {
-    Long snapshotId = (Long) component.element().getProperty("sid");
-    if (snapshotId != null) {
-      for (PerspectiveBuilder builder : builders) {
-        GraphPerspectiveBuilder graphPerspectiveBuilder = (GraphPerspectiveBuilder) builder;
-        Perspective perspective = graphPerspectiveBuilder.getPerspectiveLoader().load(component);
-        if (perspective != null) {
-          serializePerspectiveData(mapper, component, snapshotId, graphPerspectiveBuilder);
-        }
-      }
-    }
-  }
-
-  private void serializePerspectiveData(GraphDtoMapper mapper, ComponentVertex component, Long snapshotId,
-    GraphPerspectiveBuilder builder) {
-    Graph subGraph = SubGraph.extract(component.element(), builder.path());
-    String data = write(subGraph);
-    mapper.insert(new GraphDto()
-      .setData(data)
-      .setFormat("graphson")
-      .setPerspective(builder.getPerspectiveLoader().getPerspectiveKey())
-      .setVersion(1)
-      .setResourceId((Long) component.element().getProperty("rid"))
-      .setSnapshotId(snapshotId)
-      .setRootVertexId(component.element().getId().toString())
-      );
-  }
-
-  private String write(Graph graph) {
-    try (StringWriter output = new StringWriter()) {
-      new GraphsonWriter().write(graph, output, GraphsonMode.EXTENDED);
-      return output.toString();
-    } catch (IOException e) {
-      throw new IllegalStateException("Unable to write graph", e);
-    }
-  }
-}
index 08b4ba777197548802015f60d2cd614a0d6277ff..a1c3bbb82025563867b1c5003efb3b41159cd11d 100644 (file)
@@ -54,7 +54,6 @@ import org.sonar.batch.issue.tracking.InitialOpenIssuesStack;
 import org.sonar.batch.issue.tracking.LocalIssueTracking;
 import org.sonar.batch.issue.tracking.ServerIssueRepository;
 import org.sonar.batch.mediumtest.ScanTaskObservers;
-import org.sonar.batch.phases.GraphPersister;
 import org.sonar.batch.phases.PhasesTimeProfiler;
 import org.sonar.batch.profiling.PhasesSumUpTimeProfiler;
 import org.sonar.batch.qualitygate.QualityGateProvider;
@@ -222,7 +221,6 @@ public class ProjectScanContainer extends ComponentContainer {
     add(
       PastMeasuresLoader.class,
       ResourcePersister.class,
-      GraphPersister.class,
 
       // Users
       DefaultUserFinder.class,
diff --git a/sonar-core/src/main/java/org/sonar/core/component/SnapshotPerspectives.java b/sonar-core/src/main/java/org/sonar/core/component/SnapshotPerspectives.java
deleted file mode 100644 (file)
index 03a1e2c..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.component;
-
-import com.google.common.collect.Maps;
-import com.tinkerpop.blueprints.impls.tg.TinkerGraph;
-import org.sonar.api.ServerSide;
-import org.sonar.api.component.Perspective;
-import org.sonar.core.graph.graphson.GraphsonReader;
-import org.sonar.core.graph.jdbc.GraphDao;
-import org.sonar.core.graph.jdbc.GraphDto;
-
-import javax.annotation.CheckForNull;
-
-import java.io.StringReader;
-import java.util.Map;
-
-@ServerSide
-public class SnapshotPerspectives {
-
-  private final GraphDao dao;
-  private final Map<Class<?>, GraphPerspectiveLoader<?>> loaders = Maps.newHashMap();
-
-  public SnapshotPerspectives(GraphDao dao, GraphPerspectiveLoader[] loaders) {
-    this.dao = dao;
-    for (GraphPerspectiveLoader loader : loaders) {
-      // TODO check duplications
-      this.loaders.put(loader.getPerspectiveClass(), loader);
-    }
-  }
-
-  @CheckForNull
-  public <T extends Perspective> T as(Class<T> perspectiveClass, String componentKey) {
-    GraphPerspectiveLoader<T> builder = (GraphPerspectiveLoader<T>) loaders.get(perspectiveClass);
-    if (builder == null) {
-      throw new IllegalStateException();
-    }
-    GraphDto graphDto = dao.selectByComponent(builder.getPerspectiveKey(), componentKey);
-    return doAs(builder, graphDto);
-  }
-
-  @CheckForNull
-  public <T extends Perspective> T as(Class<T> perspectiveClass, long snapshotId) {
-    GraphPerspectiveLoader<T> builder = (GraphPerspectiveLoader<T>) loaders.get(perspectiveClass);
-    if (builder == null) {
-      throw new IllegalStateException();
-    }
-    GraphDto graphDto = dao.selectBySnapshot(builder.getPerspectiveKey(), snapshotId);
-    return doAs(builder, graphDto);
-  }
-
-  private <T extends Perspective> T doAs(GraphPerspectiveLoader<T> loader, GraphDto graphDto) {
-    T result = null;
-    if (graphDto != null) {
-      SnapshotGraph graph = read(graphDto.getData(), graphDto.getRootVertexId());
-      result = loader.load(graph.wrap(graph.getComponentRoot(), ComponentVertex.class));
-    }
-    return result;
-  }
-
-  private SnapshotGraph read(String data, String rootVertexId) {
-    StringReader input = new StringReader(data);
-    try {
-      TinkerGraph graph = new TinkerGraph();
-      new GraphsonReader().read(input, graph);
-      return new SnapshotGraph(graph, rootVertexId);
-    } catch (Exception e) {
-      throw new IllegalStateException(e);
-    }
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/SubGraph.java b/sonar-core/src/main/java/org/sonar/core/graph/SubGraph.java
deleted file mode 100644 (file)
index 34bb34b..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.graph;
-
-import com.google.common.collect.Sets;
-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.ElementHelper;
-
-import java.util.List;
-import java.util.Set;
-
-/**
- * Not thread-safe
- */
-public class SubGraph {
-
-  private TinkerGraph sub = new TinkerGraph();
-  private Set<Edge> edgesToCopy = Sets.newHashSet();
-
-  private SubGraph() {
-  }
-
-  public static Graph extract(Vertex start, EdgePath edgePath) {
-    return new SubGraph().process(start, edgePath);
-  }
-
-  private Graph process(Vertex start, EdgePath edgePath) {
-    copy(start);
-    browse(start, 0, edgePath.getElements());
-    for (Edge edge : edgesToCopy) {
-      Vertex from = edge.getVertex(Direction.OUT);
-      Vertex to = edge.getVertex(Direction.IN);
-      Edge copyEdge = sub.addEdge(edge.getId(), sub.getVertex(from.getId()), sub.getVertex(to.getId()), edge.getLabel());
-      ElementHelper.copyProperties(edge, copyEdge);
-    }
-    return sub;
-  }
-
-  private void browse(Vertex from, int cursor, List<Object> edgePath) {
-    if (from != null && cursor < edgePath.size()) {
-      Direction edgeDirection = (Direction) edgePath.get(cursor);
-      String edgeLabel = (String) edgePath.get(cursor + 1);
-      Iterable<Edge> edges = from.getEdges(edgeDirection, edgeLabel);
-      for (Edge edge : edges) {
-        edgesToCopy.add(edge);
-        Vertex tail = edge.getVertex(edgeDirection.opposite());
-        copy(tail);
-        browse(tail, cursor + 2, edgePath);
-      }
-    }
-  }
-
-  private Vertex copy(Vertex v) {
-    Vertex to = sub.getVertex(v.getId());
-    if (to == null) {
-      to = sub.addVertex(v.getId());
-      ElementHelper.copyProperties(v, to);
-    }
-    return to;
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/jdbc/GraphDao.java b/sonar-core/src/main/java/org/sonar/core/graph/jdbc/GraphDao.java
deleted file mode 100644 (file)
index 40b1740..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.core.graph.jdbc;
-
-import org.sonar.core.persistence.DbSession;
-import org.sonar.core.persistence.MyBatis;
-
-public class GraphDao {
-  private final MyBatis mybatis;
-
-  public GraphDao(MyBatis mybatis) {
-    this.mybatis = mybatis;
-  }
-
-  public GraphDto selectBySnapshot(String perspectiveKey, long snapshotId) {
-    DbSession session = mybatis.openSession(true);
-    try {
-      GraphDtoMapper mapper = session.getMapper(GraphDtoMapper.class);
-      return mapper.selectBySnapshot(perspectiveKey, snapshotId);
-
-    } finally {
-      MyBatis.closeQuietly(session);
-    }
-  }
-
-  public GraphDto selectByComponent(String perspectiveKey, String componentKey) {
-    DbSession session = mybatis.openSession(true);
-    try {
-      GraphDtoMapper mapper = session.getMapper(GraphDtoMapper.class);
-      return mapper.selectByComponent(perspectiveKey, componentKey);
-
-    } finally {
-      MyBatis.closeQuietly(session);
-    }
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/jdbc/GraphDto.java b/sonar-core/src/main/java/org/sonar/core/graph/jdbc/GraphDto.java
deleted file mode 100644 (file)
index 7e36c78..0000000
+++ /dev/null
@@ -1,103 +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.jdbc;
-
-public class GraphDto {
-  private long id;
-  private long resourceId;
-  private long snapshotId;
-  private String format;
-  private String perspective;
-  private int version;
-  private String rootVertexId;
-  private String data;
-
-  public long getId() {
-    return id;
-  }
-
-  public GraphDto setId(long id) {
-    this.id = id;
-    return this;
-  }
-
-  public long getResourceId() {
-    return resourceId;
-  }
-
-  public GraphDto setResourceId(long resourceId) {
-    this.resourceId = resourceId;
-    return this;
-  }
-
-  public long getSnapshotId() {
-    return snapshotId;
-  }
-
-  public GraphDto setSnapshotId(long snapshotId) {
-    this.snapshotId = snapshotId;
-    return this;
-  }
-
-  public String getPerspective() {
-    return perspective;
-  }
-
-  public GraphDto setPerspective(String perspective) {
-    this.perspective = perspective;
-    return this;
-  }
-
-  public String getFormat() {
-    return format;
-  }
-
-  public GraphDto setFormat(String format) {
-    this.format = format;
-    return this;
-  }
-
-  public int getVersion() {
-    return version;
-  }
-
-  public GraphDto setVersion(int version) {
-    this.version = version;
-    return this;
-  }
-
-  public String getRootVertexId() {
-    return rootVertexId;
-  }
-
-  public GraphDto setRootVertexId(String rootVertexId) {
-    this.rootVertexId = rootVertexId;
-    return this;
-  }
-
-  public String getData() {
-    return data;
-  }
-
-  public GraphDto setData(String data) {
-    this.data = data;
-    return this;
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/jdbc/GraphDtoMapper.java b/sonar-core/src/main/java/org/sonar/core/graph/jdbc/GraphDtoMapper.java
deleted file mode 100644 (file)
index 23bb643..0000000
+++ /dev/null
@@ -1,30 +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.jdbc;
-
-import org.apache.ibatis.annotations.Param;
-
-public interface GraphDtoMapper {
-  void insert(GraphDto graph);
-
-  GraphDto selectBySnapshot(@Param("perspective") String perspectiveKey, @Param("sid") long snapshotId);
-
-  GraphDto selectByComponent(@Param("perspective") String perspectiveKey, @Param("key") String componentKey);
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/jdbc/package-info.java b/sonar-core/src/main/java/org/sonar/core/graph/jdbc/package-info.java
deleted file mode 100644 (file)
index 148e4e9..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.jdbc;
-
-import javax.annotation.ParametersAreNonnullByDefault;
index 052120c913b93fa0b73536dbc176dc6cd8b2c2f7..935bc122b29701c2f38b966818523e822d2f853d 100644 (file)
@@ -22,11 +22,18 @@ package org.sonar.core.persistence;
 import com.google.common.base.Function;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Lists;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
 import org.sonar.core.dashboard.ActiveDashboardDao;
 import org.sonar.core.dashboard.DashboardDao;
 import org.sonar.core.duplication.DuplicationDao;
-import org.sonar.core.graph.jdbc.GraphDao;
-import org.sonar.core.issue.db.*;
+import org.sonar.core.issue.db.ActionPlanDao;
+import org.sonar.core.issue.db.ActionPlanStatsDao;
+import org.sonar.core.issue.db.IssueChangeDao;
+import org.sonar.core.issue.db.IssueDao;
+import org.sonar.core.issue.db.IssueFilterDao;
+import org.sonar.core.issue.db.IssueFilterFavouriteDao;
 import org.sonar.core.notification.db.NotificationQueueDao;
 import org.sonar.core.permission.PermissionDao;
 import org.sonar.core.permission.PermissionTemplateDao;
@@ -40,11 +47,11 @@ import org.sonar.core.resource.ResourceKeyUpdaterDao;
 import org.sonar.core.rule.RuleDao;
 import org.sonar.core.technicaldebt.db.CharacteristicDao;
 import org.sonar.core.template.LoadedTemplateDao;
-import org.sonar.core.user.*;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
+import org.sonar.core.user.AuthorDao;
+import org.sonar.core.user.AuthorizationDao;
+import org.sonar.core.user.GroupMembershipDao;
+import org.sonar.core.user.RoleDao;
+import org.sonar.core.user.UserDao;
 
 import static com.google.common.collect.Lists.newArrayList;
 
@@ -67,7 +74,6 @@ public final class DaoUtils {
       AuthorizationDao.class,
       DashboardDao.class,
       DuplicationDao.class,
-      GraphDao.class,
       GroupMembershipDao.class,
       IssueDao.class,
       IssueChangeDao.class,
index 334245aa769cde9ef3bfaff8a8a0a79870295d4a..17fa55201f7dda5d920417fb25d650e4ae463418 100644 (file)
@@ -35,7 +35,7 @@ import java.util.List;
 @ServerSide
 public class DatabaseVersion {
 
-  public static final int LAST_VERSION = 914;
+  public static final int LAST_VERSION = 915;
 
   /**
    * List of all the tables.n
@@ -56,7 +56,6 @@ public class DatabaseVersion {
     "duplications_index",
     "events",
     "file_sources",
-    "graphs",
     "groups",
     "groups_users",
     "group_roles",
index 35d49d5a0d4b1d7879d0dfefb633a49f2f992442..7480d60edbefecad8ca6f6e1c7a1d83ce3a48a9b 100644 (file)
@@ -66,8 +66,6 @@ import org.sonar.core.duplication.DuplicationMapper;
 import org.sonar.core.duplication.DuplicationUnitDto;
 import org.sonar.core.event.EventDto;
 import org.sonar.core.event.db.EventMapper;
-import org.sonar.core.graph.jdbc.GraphDto;
-import org.sonar.core.graph.jdbc.GraphDtoMapper;
 import org.sonar.core.issue.db.ActionPlanDto;
 import org.sonar.core.issue.db.ActionPlanMapper;
 import org.sonar.core.issue.db.ActionPlanStatsDto;
@@ -197,7 +195,6 @@ public class MyBatis {
     loadAlias(conf, "ComponentLink", ComponentLinkDto.class);
     loadAlias(conf, "Dashboard", DashboardDto.class);
     loadAlias(conf, "DuplicationUnit", DuplicationUnitDto.class);
-    loadAlias(conf, "Graph", GraphDto.class);
     loadAlias(conf, "Group", GroupDto.class);
     loadAlias(conf, "GroupRole", GroupRoleDto.class);
     loadAlias(conf, "GroupMembership", GroupMembershipDto.class);
@@ -253,7 +250,7 @@ public class MyBatis {
 
     loadMapper(conf, "org.sonar.core.permission.PermissionMapper");
     Class<?>[] mappers = {ActivityMapper.class, ActiveDashboardMapper.class, AuthorMapper.class, DashboardMapper.class,
-      FileDependencyMapper.class, DuplicationMapper.class, GraphDtoMapper.class,
+      FileDependencyMapper.class, DuplicationMapper.class,
       IssueMapper.class, IssueChangeMapper.class, IssueFilterMapper.class, IssueFilterFavouriteMapper.class,
       IsAliveMapper.class,
       LoadedTemplateMapper.class, MeasureFilterMapper.class, Migration44Mapper.class, PermissionTemplateMapper.class, PropertiesMapper.class, PurgeMapper.class,
index 438f416177c38d326218658c1fd72ee8016d4e86..b8c9c49edd5f1aedd2db4bea6cf32ea3ac06287d 100644 (file)
@@ -132,13 +132,6 @@ class PurgeCommands {
     session.commit();
     profiler.stop();
 
-    profiler.start("deleteResourceGraphs (graphs)");
-    for (List<Long> partResourceIds : componentIdPartitions) {
-      purgeMapper.deleteResourceGraphs(partResourceIds);
-    }
-    session.commit();
-    profiler.stop();
-
     profiler.start("deleteResource (projects)");
     for (List<Long> partResourceIds : componentIdPartitions) {
       purgeMapper.deleteResource(partResourceIds);
@@ -181,8 +174,6 @@ class PurgeCommands {
     session.commit();
     profiler.stop();
 
-    deleteSnapshotGraphs(snapshotIdsPartition);
-
     profiler.start("deleteSnapshot (snapshots)");
     for (List<Long> partSnapshotIds : snapshotIdsPartition) {
       purgeMapper.deleteSnapshot(partSnapshotIds);
@@ -204,8 +195,6 @@ class PurgeCommands {
 
     deleteSnapshotDuplications(snapshotIdsPartition);
 
-    deleteSnapshotGraphs(snapshotIdsPartition);
-
     profiler.start("deleteSnapshotWastedMeasures (project_measures)");
     List<Long> metricIdsWithoutHistoricalData = purgeMapper.selectMetricIdsWithoutHistoricalData();
     for (List<Long> partSnapshotIds : snapshotIdsPartition) {
@@ -222,15 +211,6 @@ class PurgeCommands {
     profiler.stop();
   }
 
-  private void deleteSnapshotGraphs(final List<List<Long>> snapshotIdsPartition) {
-    profiler.start("deleteSnapshotGraphs (graphs)");
-    for (List<Long> partSnapshotIds : snapshotIdsPartition) {
-      purgeMapper.deleteSnapshotGraphs(partSnapshotIds);
-    }
-    session.commit();
-    profiler.stop();
-  }
-
   private void deleteSnapshotDuplications(final List<List<Long>> snapshotIdsPartition) {
     profiler.start("deleteSnapshotDuplications (duplications_index)");
     for (List<Long> partSnapshotIds : snapshotIdsPartition) {
index 2dda5e5283778f77832f91147c74db96fb568b4e..3c5e71314630fabba49a4f4df41c479d89b437dc 100644 (file)
@@ -49,8 +49,6 @@ public interface PurgeMapper {
 
   void deleteSnapshotMeasures(@Param("snapshotIds") List<Long> snapshotIds);
 
-  void deleteSnapshotGraphs(@Param("snapshotIds") List<Long> snapshotIds);
-
   List<Long> selectMetricIdsWithoutHistoricalData();
 
   void deleteSnapshotWastedMeasures(@Param("snapshotIds") List<Long> snapshotIds, @Param("mids") List<Long> metricIds);
@@ -83,8 +81,6 @@ public interface PurgeMapper {
 
   void deleteResourceActionPlans(@Param("resourceIds") List<Long> resourceIds);
 
-  void deleteResourceGraphs(@Param("resourceIds") List<Long> resourceIds);
-
   void deleteAuthors(@Param("resourceIds") List<Long> resourceIds);
 
   List<PurgeableSnapshotDto> selectPurgeableSnapshotsWithEvents(long resourceId);
diff --git a/sonar-core/src/main/resources/org/sonar/core/graph/jdbc/GraphDtoMapper.xml b/sonar-core/src/main/resources/org/sonar/core/graph/jdbc/GraphDtoMapper.xml
deleted file mode 100644 (file)
index 7040902..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-
-<mapper namespace="org.sonar.core.graph.jdbc.GraphDtoMapper">
-
-  <select id="selectBySnapshot" parameterType="map" resultType="Graph" >
-    SELECT id, resource_id as resourceId, snapshot_id as snapshotId, format, version, perspective, root_vertex_id as rootVertexId, data
-    FROM graphs
-    WHERE snapshot_id = #{sid} AND perspective = #{perspective}
-  </select>
-
-  <select id="selectByComponent" parameterType="map" resultType="Graph" >
-    SELECT g.id, g.resource_id as resourceId, g.snapshot_id as snapshotId, g.format, g.version, g.perspective, g.root_vertex_id as rootVertexId, g.data
-    FROM graphs g, snapshots s
-    WHERE g.perspective = #{perspective} AND g.snapshot_id=s.id AND s.islast=${_true} and s.project_id=(
-    select id from projects where enabled=${_true} and kee=#{key} and person_id is null and copy_resource_id is null
-    )
-  </select>
-
-  <insert id="insert" parameterType="Graph" useGeneratedKeys="false" >
-    insert into graphs
-    (resource_id, snapshot_id, format, version, perspective, root_vertex_id, data, created_at, updated_at)
-    values (
-    #{resourceId}, #{snapshotId}, #{format}, #{version}, #{perspective}, #{rootVertexId},
-    #{data}, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)
-  </insert>
-
-</mapper>
-
index 92a6baa5be69e16e04b47cb7c15497c65fe2a604..a985006dde761c9f3b74a9040d4daec96253b9dc 100644 (file)
@@ -338,6 +338,7 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('911');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('912');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('913');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('914');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('915');
 
 INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '1418215735482', '1418215735482', null, null);
 ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2;
index ff932e6131e4dc8fbaccd4b821dc135bdc9bf6db..f1b4b16c6c4c520fed53f32af098e7b38a2d8f53 100644 (file)
@@ -437,19 +437,6 @@ CREATE TABLE "MEASURE_FILTER_FAVOURITES" (
   "CREATED_AT" TIMESTAMP
 );
 
-CREATE TABLE "GRAPHS" (
-  "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
-  "RESOURCE_ID" INTEGER NOT NULL,
-  "SNAPSHOT_ID" INTEGER NOT NULL,
-  "FORMAT" VARCHAR(20),
-  "PERSPECTIVE" VARCHAR(30),
-  "VERSION" VARCHAR(20),
-  "ROOT_VERTEX_ID" VARCHAR(30),
-  "DATA" CLOB(2147483647),
-  "CREATED_AT" TIMESTAMP,
-  "UPDATED_AT" TIMESTAMP
-);
-
 CREATE TABLE "ISSUES" (
   "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
   "KEE" VARCHAR(50) UNIQUE NOT NULL,
@@ -665,8 +652,6 @@ CREATE INDEX "MEASURE_FILTERS_NAME" ON "MEASURE_FILTERS" ("NAME");
 
 CREATE INDEX "MEASURE_FILTER_FAVS_USERID" ON "MEASURE_FILTER_FAVOURITES" ("USER_ID");
 
-CREATE UNIQUE INDEX "GRAPHS_PERSPECTIVES" ON "GRAPHS" ("SNAPSHOT_ID", "PERSPECTIVE");
-
 CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES" ("KEE");
 
 CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES" ("COMPONENT_UUID");
index 6ba17308f50ff48963b6be8163659779ed0ef678..454cebefd32d05e043b4e39695481030b5920498 100644 (file)
     </foreach>
   </delete>
 
-  <delete id="deleteSnapshotGraphs" parameterType="map">
-    delete from graphs where snapshot_id in
-    <foreach collection="snapshotIds" open="(" close=")" item="snapshotId" separator=",">
-      #{snapshotId}
-    </foreach>
-  </delete>
-
   <delete id="deleteSnapshotDependenciesFromSnapshotId" parameterType="map">
     delete from dependencies where from_snapshot_id in
     <foreach collection="snapshotIds" open="(" close=")" item="snapshotId" separator=",">
     </foreach>
   </delete>
 
-  <delete id="deleteResourceGraphs" parameterType="map">
-    delete from graphs where resource_id in
-    <foreach collection="resourceIds" open="(" close=")" item="resourceId" separator=",">
-      #{resourceId}
-    </foreach>
-  </delete>
-
   <delete id="deleteAuthors" parameterType="map">
     delete from authors where person_id in
     <foreach collection="resourceIds" open="(" close=")" item="resourceId" separator=",">
diff --git a/sonar-core/src/test/java/org/sonar/core/graph/SubGraphTest.java b/sonar-core/src/test/java/org/sonar/core/graph/SubGraphTest.java
deleted file mode 100644 (file)
index 9323c28..0000000
+++ /dev/null
@@ -1,118 +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;
-import com.tinkerpop.blueprints.Graph;
-import com.tinkerpop.blueprints.Vertex;
-import com.tinkerpop.blueprints.impls.tg.TinkerGraph;
-import com.tinkerpop.blueprints.util.GraphHelper;
-import org.junit.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class SubGraphTest {
-
-  @Test
-  public void should_extract_graph() {
-    TinkerGraph graph = new TinkerGraph();
-    Vertex a = GraphHelper.addVertex(graph, null, "key", "a");
-    Vertex b = GraphHelper.addVertex(graph, null, "key", "b");
-    Vertex c = GraphHelper.addVertex(graph, null, "key", "c");
-    Vertex d = GraphHelper.addVertex(graph, null, "key", "d");
-    Vertex e = GraphHelper.addVertex(graph, null, "key", "e");
-
-    Edge ab = GraphHelper.addEdge(graph, null, a, b, "uses");
-    Edge bc = GraphHelper.addEdge(graph, null, b, c, "inherits");
-    Edge ad = GraphHelper.addEdge(graph, null, a, d, "uses");
-    Edge de = GraphHelper.addEdge(graph, null, d, e, "implements");
-
-    // a -uses-> b -inherits -> c
-    // a -uses-> d -implements-> e
-
-    Graph sub = SubGraph.extract(a, EdgePath.create(Direction.OUT, "uses", Direction.OUT, "implements"));
-
-    // a -uses-> b
-    // a -uses-> d -implements-> e
-    assertThat(sub.getVertices()).hasSize(4);
-    assertThat(sub.getVertex(a.getId()).getProperty("key")).isEqualTo("a");
-    assertThat(sub.getVertex(b.getId()).getProperty("key")).isEqualTo("b");
-    assertThat(sub.getVertex(c.getId())).isNull();
-    assertThat(sub.getVertex(d.getId()).getProperty("key")).isEqualTo("d");
-    assertThat(sub.getVertex(e.getId()).getProperty("key")).isEqualTo("e");
-
-    assertThat(sub.getEdges()).hasSize(3);
-    assertThat(sub.getEdge(ab.getId()).getLabel()).isEqualTo("uses");
-    assertThat(sub.getEdge(ab.getId()).toString()).isEqualTo(ab.toString());
-    assertThat(sub.getEdge(bc.getId())).isNull();
-    assertThat(sub.getEdge(ad.getId()).toString()).isEqualTo(ad.toString());
-    assertThat(sub.getEdge(de.getId()).toString()).isEqualTo(de.toString());
-  }
-
-  @Test
-  public void should_extract_cyclic_graph() {
-    TinkerGraph graph = new TinkerGraph();
-    Vertex a = GraphHelper.addVertex(graph, null, "key", "a");
-    Vertex b = GraphHelper.addVertex(graph, null, "key", "b");
-    Vertex c = GraphHelper.addVertex(graph, null, "key", "c");
-    Vertex d = GraphHelper.addVertex(graph, null, "key", "d");
-    Vertex e = GraphHelper.addVertex(graph, null, "key", "e");
-
-    Edge ab = GraphHelper.addEdge(graph, null, a, b, "uses");
-    Edge bc = GraphHelper.addEdge(graph, null, b, c, "implements");
-    Edge ce = GraphHelper.addEdge(graph, null, c, e, "package");
-    Edge ad = GraphHelper.addEdge(graph, null, a, d, "uses");
-    Edge dc = GraphHelper.addEdge(graph, null, d, c, "implements");
-
-    // a -uses-> b -implements-> c -package-> e
-    // a -uses-> d -implements-> c -package-> e
-
-    Graph sub = SubGraph.extract(a, EdgePath.create(Direction.OUT, "uses", Direction.OUT, "implements", Direction.OUT, "package"));
-
-    // same graph
-    assertThat(sub.getVertices()).hasSize(5);
-    assertThat(sub.getEdges()).hasSize(5);
-  }
-
-  @Test
-  public void should_check_edge_direction() {
-    TinkerGraph graph = new TinkerGraph();
-    Vertex a = GraphHelper.addVertex(graph, null, "key", "a");
-    Vertex b = GraphHelper.addVertex(graph, null, "key", "b");
-    Vertex c = GraphHelper.addVertex(graph, null, "key", "c");
-    Vertex d = GraphHelper.addVertex(graph, null, "key", "d");
-    Vertex e = GraphHelper.addVertex(graph, null, "key", "e");
-
-    Edge ab = GraphHelper.addEdge(graph, null, a, b, "uses");
-    Edge bc = GraphHelper.addEdge(graph, null, b, c, "inherits");
-    Edge ad = GraphHelper.addEdge(graph, null, a, d, "uses");
-    Edge de = GraphHelper.addEdge(graph, null, d, e, "implements");
-
-    // a -uses-> b -inherits -> c
-    // a -uses-> d -implements-> e
-
-    Graph sub = SubGraph.extract(a, EdgePath.create(Direction.IN /* instead of out */, "uses", Direction.OUT, "implements"));
-
-    assertThat(sub.getVertices()).hasSize(1);
-    assertThat(sub.getVertex(a.getId())).isNotNull();
-    assertThat(sub.getEdges()).isEmpty();
-  }
-}
diff --git a/sonar-core/src/test/java/org/sonar/core/graph/jdbc/GraphDaoTest.java b/sonar-core/src/test/java/org/sonar/core/graph/jdbc/GraphDaoTest.java
deleted file mode 100644 (file)
index 4b84ef0..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.graph.jdbc;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.core.persistence.AbstractDaoTestCase;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class GraphDaoTest extends AbstractDaoTestCase {
-  private GraphDao dao;
-
-  @Before
-  public void createDao() {
-    dao = new GraphDao(getMyBatis());
-    setupData("shared");
-  }
-
-  @Test
-  public void select_graph_by_snapshot() {
-    GraphDto testPlan = dao.selectBySnapshot("testplan", 11L);
-
-    assertThat(testPlan.getId()).isEqualTo(101L);
-    assertThat(testPlan.getResourceId()).isEqualTo(1L);
-    assertThat(testPlan.getSnapshotId()).isEqualTo(11L);
-    assertThat(testPlan.getFormat()).isEqualTo("graphson");
-    assertThat(testPlan.getVersion()).isEqualTo(1);
-    assertThat(testPlan.getPerspective()).isEqualTo("testplan");
-    assertThat(testPlan.getRootVertexId()).isEqualTo("3456");
-    assertThat(testPlan.getData()).isEqualTo("{testplan of snapshot 123}");
-  }
-
-  @Test
-  public void select_by_snapshot_and_missing_perspective() {
-    assertThat(dao.selectBySnapshot("duplicable", 123L)).isNull();
-  }
-
-  @Test
-  public void select_by_missing_snapshot() {
-    assertThat(dao.selectBySnapshot("duplicable", 7777L)).isNull();
-  }
-
-  @Test
-  public void select_by_component() {
-    GraphDto testPlan = dao.selectByComponent("testplan", "org.apache.struts:struts");
-
-    assertThat(testPlan.getId()).isEqualTo(101L);
-    assertThat(testPlan.getResourceId()).isEqualTo(1L);
-    assertThat(testPlan.getSnapshotId()).isEqualTo(11L);
-    assertThat(testPlan.getFormat()).isEqualTo("graphson");
-    assertThat(testPlan.getVersion()).isEqualTo(1);
-    assertThat(testPlan.getPerspective()).isEqualTo("testplan");
-    assertThat(testPlan.getRootVertexId()).isEqualTo("3456");
-    assertThat(testPlan.getData()).isEqualTo("{testplan of snapshot 123}");
-  }
-
-  @Test
-  public void select_by_missing_component() {
-    assertThat(dao.selectByComponent("testplan", "org.other:unknown")).isNull();
-  }
-}
diff --git a/sonar-core/src/test/resources/org/sonar/core/graph/jdbc/GraphDaoTest/shared.xml b/sonar-core/src/test/resources/org/sonar/core/graph/jdbc/GraphDaoTest/shared.xml
deleted file mode 100644 (file)
index 9345cfc..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<dataset>
-  <projects id="1" kee="org.apache.struts:struts" enabled="[true]"/>
-
-  <snapshots id="10" project_id="1" islast="[false]" />
-  <snapshots id="11" project_id="1" islast="[true]" />
-
-  <graphs id="100" resource_id="1" snapshot_id="11" format="graphson" version="1" perspective="testable" root_vertex_id="7890" data="{testable of snapshot 123}"/>
-  <graphs id="101" resource_id="1" snapshot_id="11" format="graphson" version="1" perspective="testplan" root_vertex_id="3456" data="{testplan of snapshot 123}"/>
-</dataset>
\ No newline at end of file