Skip to content

Commit

Permalink
Move factory methods to interface
Browse files Browse the repository at this point in the history
With Java 8 we can have static methods on interfaces, so there is no
need for DynamicLabel and DynamicRelationshipType. Instead we can move
the corresponding factory methods to the Label and RelationshipType
interfaces respectively.
  • Loading branch information
thobe committed Nov 26, 2015
1 parent 0f15fb3 commit 4512524
Show file tree
Hide file tree
Showing 261 changed files with 750 additions and 725 deletions.
Expand Up @@ -28,7 +28,6 @@


import org.neo4j.bolt.v1.messaging.BoltIOException; import org.neo4j.bolt.v1.messaging.BoltIOException;
import org.neo4j.graphdb.Direction; import org.neo4j.graphdb.Direction;
import org.neo4j.graphdb.DynamicLabel;
import org.neo4j.graphdb.GraphDatabaseService; import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Label; import org.neo4j.graphdb.Label;
import org.neo4j.graphdb.Node; import org.neo4j.graphdb.Node;
Expand Down Expand Up @@ -88,7 +87,7 @@ public static ValueNode unpackFields( Neo4jPack.Unpacker unpacker )
labels = new ArrayList<>( numLabels ); labels = new ArrayList<>( numLabels );
for ( int i = 0; i < numLabels; i++ ) for ( int i = 0; i < numLabels; i++ )
{ {
labels.add( DynamicLabel.label( unpacker.unpackString() ) ); labels.add( Label.label( unpacker.unpackString() ) );
} }
} }
else else
Expand Down
Expand Up @@ -24,7 +24,6 @@


import org.neo4j.bolt.v1.messaging.BoltIOException; import org.neo4j.bolt.v1.messaging.BoltIOException;
import org.neo4j.bolt.v1.messaging.Neo4jPack; import org.neo4j.bolt.v1.messaging.Neo4jPack;
import org.neo4j.graphdb.DynamicRelationshipType;
import org.neo4j.graphdb.GraphDatabaseService; import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node; import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship; import org.neo4j.graphdb.Relationship;
Expand Down Expand Up @@ -71,7 +70,7 @@ public static ValueRelationship unpackFields( Neo4jPack.Unpacker unpacker )


Map<String, Object> props = unpacker.unpackMap(); Map<String, Object> props = unpacker.unpackMap();


RelationshipType relType = DynamicRelationshipType.withName( relTypeName ); RelationshipType relType = RelationshipType.withName( relTypeName );


return new ValueRelationship( relId, startNodeId, endNodeId, relType, props ); return new ValueRelationship( relId, startNodeId, endNodeId, relType, props );
} }
Expand Down
Expand Up @@ -23,7 +23,6 @@
import java.util.Map; import java.util.Map;


import org.neo4j.bolt.v1.messaging.Neo4jPack; import org.neo4j.bolt.v1.messaging.Neo4jPack;
import org.neo4j.graphdb.DynamicRelationshipType;
import org.neo4j.graphdb.GraphDatabaseService; import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node; import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship; import org.neo4j.graphdb.Relationship;
Expand Down Expand Up @@ -60,7 +59,7 @@ public static ValueUnboundRelationship unpackFields( Neo4jPack.Unpacker unpacker


Map<String, Object> props = unpacker.unpackMap(); Map<String, Object> props = unpacker.unpackMap();


RelationshipType relType = DynamicRelationshipType.withName( relTypeName ); RelationshipType relType = RelationshipType.withName( relTypeName );


return new ValueUnboundRelationship( relId, relType, props ); return new ValueUnboundRelationship( relId, relType, props );
} }
Expand Down
Expand Up @@ -42,7 +42,7 @@
import org.neo4j.bolt.v1.packstream.BufferedChannelOutput; import org.neo4j.bolt.v1.packstream.BufferedChannelOutput;
import org.neo4j.bolt.v1.packstream.PackStream; import org.neo4j.bolt.v1.packstream.PackStream;
import org.neo4j.bolt.v1.packstream.PackType; import org.neo4j.bolt.v1.packstream.PackType;
import org.neo4j.graphdb.DynamicRelationshipType; import org.neo4j.graphdb.RelationshipType;


import static java.util.Arrays.asList; import static java.util.Arrays.asList;
import static junit.framework.TestCase.fail; import static junit.framework.TestCase.fail;
Expand All @@ -51,7 +51,7 @@
import static org.neo4j.bolt.v1.messaging.PackStreamMessageFormatV1.Writer.NO_OP; import static org.neo4j.bolt.v1.messaging.PackStreamMessageFormatV1.Writer.NO_OP;
import static org.neo4j.bolt.v1.messaging.example.Paths.PATH_WITH_LENGTH_TWO; import static org.neo4j.bolt.v1.messaging.example.Paths.PATH_WITH_LENGTH_TWO;
import static org.neo4j.bolt.v1.runtime.spi.Records.record; import static org.neo4j.bolt.v1.runtime.spi.Records.record;
import static org.neo4j.graphdb.DynamicLabel.label; import static org.neo4j.graphdb.Label.label;
import static org.neo4j.helpers.collection.MapUtil.map; import static org.neo4j.helpers.collection.MapUtil.map;


/** This tests that Neo4j value mappings described in the documentation work the way we say they do. */ /** This tests that Neo4j value mappings described in the documentation work the way we say they do. */
Expand Down Expand Up @@ -175,7 +175,7 @@ else if ( type.equalsIgnoreCase( "node" ) )
} }
else if ( type.equalsIgnoreCase( "relationship" ) ) else if ( type.equalsIgnoreCase( "relationship" ) )
{ {
return new ValueRelationship( 12, 1, 2, DynamicRelationshipType.withName( "KNOWS" ), map() ); return new ValueRelationship( 12, 1, 2, RelationshipType.withName( "KNOWS" ), map() );
} }
else if ( type.equalsIgnoreCase( "path" ) ) else if ( type.equalsIgnoreCase( "path" ) )
{ {
Expand Down
Expand Up @@ -26,8 +26,8 @@


import org.junit.Test; import org.junit.Test;


import org.neo4j.graphdb.DynamicRelationshipType;
import org.neo4j.graphdb.Path; import org.neo4j.graphdb.Path;
import org.neo4j.graphdb.RelationshipType;
import org.neo4j.kernel.api.exceptions.Status; import org.neo4j.kernel.api.exceptions.Status;
import org.neo4j.kernel.impl.util.HexPrinter; import org.neo4j.kernel.impl.util.HexPrinter;
import org.neo4j.bolt.v1.messaging.infrastructure.ValueNode; import org.neo4j.bolt.v1.messaging.infrastructure.ValueNode;
Expand All @@ -50,7 +50,7 @@
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;


import static org.neo4j.graphdb.DynamicLabel.label; import static org.neo4j.graphdb.Label.label;
import static org.neo4j.helpers.collection.MapUtil.map; import static org.neo4j.helpers.collection.MapUtil.map;
import static org.neo4j.bolt.v1.messaging.PackStreamMessageFormatV1.Writer.NO_OP; import static org.neo4j.bolt.v1.messaging.PackStreamMessageFormatV1.Writer.NO_OP;
import static org.neo4j.bolt.v1.messaging.example.Paths.ALL_PATHS; import static org.neo4j.bolt.v1.messaging.example.Paths.ALL_PATHS;
Expand Down Expand Up @@ -129,7 +129,7 @@ public void shouldSerializeNode() throws Throwable
@Test @Test
public void shouldSerializeRelationship() throws Throwable public void shouldSerializeRelationship() throws Throwable
{ {
assertSerializesNeoValue( new ValueRelationship( 12l, 1l, 2l, DynamicRelationshipType.withName( "KNOWS" ), assertSerializesNeoValue( new ValueRelationship( 12l, 1l, 2l, RelationshipType.withName( "KNOWS" ),
map( "name", "Bob", "age", 14 ) ) ); map( "name", "Bob", "age", 14 ) ) );
} }


Expand Down
Expand Up @@ -26,7 +26,7 @@


import static java.util.Arrays.asList; import static java.util.Arrays.asList;


import static org.neo4j.graphdb.DynamicLabel.label; import static org.neo4j.graphdb.Label.label;
import static org.neo4j.helpers.collection.MapUtil.map; import static org.neo4j.helpers.collection.MapUtil.map;
import static org.neo4j.bolt.v1.messaging.example.Support.NO_LABELS; import static org.neo4j.bolt.v1.messaging.example.Support.NO_LABELS;


Expand Down
Expand Up @@ -19,7 +19,6 @@
*/ */
package org.neo4j.bolt.v1.messaging.example; package org.neo4j.bolt.v1.messaging.example;


import org.neo4j.graphdb.DynamicRelationshipType;
import org.neo4j.graphdb.Relationship; import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.RelationshipType; import org.neo4j.graphdb.RelationshipType;
import org.neo4j.bolt.v1.messaging.infrastructure.ValueRelationship; import org.neo4j.bolt.v1.messaging.infrastructure.ValueRelationship;
Expand All @@ -34,13 +33,13 @@
public class Relationships public class Relationships
{ {
// Relationship types // Relationship types
public static final RelationshipType KNOWS = DynamicRelationshipType.withName( "KNOWS" ); public static final RelationshipType KNOWS = RelationshipType.withName( "KNOWS" );
public static final RelationshipType LIKES = DynamicRelationshipType.withName( "LIKES" ); public static final RelationshipType LIKES = RelationshipType.withName( "LIKES" );
public static final RelationshipType DISLIKES = DynamicRelationshipType.withName( "DISLIKES" ); public static final RelationshipType DISLIKES = RelationshipType.withName( "DISLIKES" );
public static final RelationshipType MARRIED_TO = public static final RelationshipType MARRIED_TO =
DynamicRelationshipType.withName( "MARRIED_TO" ); RelationshipType.withName( "MARRIED_TO" );
public static final RelationshipType WORKS_FOR = public static final RelationshipType WORKS_FOR =
DynamicRelationshipType.withName( "WORKS_FOR" ); RelationshipType.withName( "WORKS_FOR" );


// Relationships // Relationships
public static final Relationship ALICE_KNOWS_BOB = public static final Relationship ALICE_KNOWS_BOB =
Expand Down
Expand Up @@ -28,11 +28,10 @@
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;


import org.neo4j.graphdb.DynamicLabel;
import org.neo4j.graphdb.DynamicRelationshipType;
import org.neo4j.graphdb.GraphDatabaseService; import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Label; import org.neo4j.graphdb.Label;
import org.neo4j.graphdb.Node; import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.RelationshipType;
import org.neo4j.graphdb.Transaction; import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.factory.GraphDatabaseFactory; import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import org.neo4j.graphdb.factory.GraphDatabaseSettings; import org.neo4j.graphdb.factory.GraphDatabaseSettings;
Expand Down Expand Up @@ -129,7 +128,7 @@ public void shouldNotReportDuplicateForHugeLongValues() throws Exception
GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabase( testDirectory.graphDbDir() ); GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabase( testDirectory.graphDbDir() );


String propertyKey = "itemId"; String propertyKey = "itemId";
Label label = DynamicLabel.label( "Item" ); Label label = Label.label( "Item" );
try ( Transaction tx = db.beginTx() ) try ( Transaction tx = db.beginTx() )
{ {
db.schema().constraintFor( label ).assertPropertyIsUnique( propertyKey ).create(); db.schema().constraintFor( label ).assertPropertyIsUnique( propertyKey ).create();
Expand Down Expand Up @@ -207,7 +206,7 @@ protected void generateInitialData( GraphDatabaseService graphDb )
{ {
Node node1 = set( graphDb.createNode() ); Node node1 = set( graphDb.createNode() );
Node node2 = set( graphDb.createNode(), property( "key", "value" ) ); Node node2 = set( graphDb.createNode(), property( "key", "value" ) );
node1.createRelationshipTo( node2, DynamicRelationshipType.withName( "C" ) ); node1.createRelationshipTo( node2, RelationshipType.withName( "C" ) );
tx.success(); tx.success();
} }
} }
Expand Down
Expand Up @@ -61,7 +61,7 @@
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyZeroInteractions;


import static org.neo4j.graphdb.DynamicLabel.label; import static org.neo4j.graphdb.Label.label;
import static org.neo4j.test.EphemeralFileSystemRule.shutdownDbAction; import static org.neo4j.test.EphemeralFileSystemRule.shutdownDbAction;


public class ConsistencyCheckToolTest public class ConsistencyCheckToolTest
Expand Down
Expand Up @@ -30,9 +30,9 @@
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;


import org.neo4j.graphdb.DynamicRelationshipType;
import org.neo4j.graphdb.GraphDatabaseService; import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node; import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.RelationshipType;
import org.neo4j.graphdb.factory.GraphDatabaseSettings; import org.neo4j.graphdb.factory.GraphDatabaseSettings;
import org.neo4j.helpers.progress.ProgressMonitorFactory; import org.neo4j.helpers.progress.ProgressMonitorFactory;
import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.configuration.Config;
Expand Down Expand Up @@ -90,7 +90,7 @@ protected void generateInitialData( GraphDatabaseService graphDb )
{ {
Node node1 = set( graphDb.createNode() ); Node node1 = set( graphDb.createNode() );
Node node2 = set( graphDb.createNode(), property( "key", "value" ) ); Node node2 = set( graphDb.createNode(), property( "key", "value" ) );
node1.createRelationshipTo( node2, DynamicRelationshipType.withName( "C" ) ); node1.createRelationshipTo( node2, RelationshipType.withName( "C" ) );
tx.success(); tx.success();
} }
} }
Expand Down
Expand Up @@ -107,8 +107,8 @@
import static java.util.Arrays.asList; import static java.util.Arrays.asList;
import static java.util.Collections.singleton; import static java.util.Collections.singleton;


import static org.neo4j.graphdb.DynamicLabel.label; import static org.neo4j.graphdb.Label.label;
import static org.neo4j.graphdb.DynamicRelationshipType.withName; import static org.neo4j.graphdb.RelationshipType.withName;
import static org.neo4j.helpers.collection.IteratorUtil.asIterable; import static org.neo4j.helpers.collection.IteratorUtil.asIterable;
import static org.neo4j.helpers.collection.IteratorUtil.iterator; import static org.neo4j.helpers.collection.IteratorUtil.iterator;
import static org.neo4j.kernel.api.CountsRead.ANY_LABEL; import static org.neo4j.kernel.api.CountsRead.ANY_LABEL;
Expand Down
Expand Up @@ -31,11 +31,10 @@
import org.neo4j.consistency.ConsistencyCheckService.Result; import org.neo4j.consistency.ConsistencyCheckService.Result;
import org.neo4j.consistency.checking.GraphStoreFixture; import org.neo4j.consistency.checking.GraphStoreFixture;
import org.neo4j.consistency.checking.full.ConsistencyCheckIncompleteException; import org.neo4j.consistency.checking.full.ConsistencyCheckIncompleteException;
import org.neo4j.graphdb.DynamicLabel;
import org.neo4j.graphdb.DynamicRelationshipType;
import org.neo4j.graphdb.GraphDatabaseService; import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Label; import org.neo4j.graphdb.Label;
import org.neo4j.graphdb.Node; import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.RelationshipType;
import org.neo4j.graphdb.Transaction; import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.factory.GraphDatabaseFactory; import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import org.neo4j.graphdb.factory.GraphDatabaseSettings; import org.neo4j.graphdb.factory.GraphDatabaseSettings;
Expand Down Expand Up @@ -123,7 +122,7 @@ public void shouldNotReportDuplicateForHugeLongValues() throws Exception
GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabase( testDirectory.graphDbDir() ); GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabase( testDirectory.graphDbDir() );


String propertyKey = "itemId"; String propertyKey = "itemId";
Label label = DynamicLabel.label( "Item" ); Label label = Label.label( "Item" );
try ( Transaction tx = db.beginTx() ) try ( Transaction tx = db.beginTx() )
{ {
db.schema().constraintFor( label ).assertPropertyIsUnique( propertyKey ).create(); db.schema().constraintFor( label ).assertPropertyIsUnique( propertyKey ).create();
Expand Down Expand Up @@ -206,7 +205,7 @@ protected void generateInitialData( GraphDatabaseService graphDb )
{ {
Node node1 = set( graphDb.createNode() ); Node node1 = set( graphDb.createNode() );
Node node2 = set( graphDb.createNode(), property( "key", "value" ) ); Node node2 = set( graphDb.createNode(), property( "key", "value" ) );
node1.createRelationshipTo( node2, DynamicRelationshipType.withName( "C" ) ); node1.createRelationshipTo( node2, RelationshipType.withName( "C" ) );
tx.success(); tx.success();
} }
} }
Expand Down
Expand Up @@ -67,7 +67,7 @@
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyZeroInteractions;
import static org.neo4j.consistency.ConsistencyCheckTool.USE_LEGACY_CHECKER; import static org.neo4j.consistency.ConsistencyCheckTool.USE_LEGACY_CHECKER;
import static org.neo4j.graphdb.DynamicLabel.label; import static org.neo4j.graphdb.Label.label;
import static org.neo4j.helpers.ArrayUtil.concat; import static org.neo4j.helpers.ArrayUtil.concat;
import static org.neo4j.test.EphemeralFileSystemRule.shutdownDbAction; import static org.neo4j.test.EphemeralFileSystemRule.shutdownDbAction;


Expand Down
Expand Up @@ -49,9 +49,9 @@
import org.neo4j.consistency.statistics.Statistics; import org.neo4j.consistency.statistics.Statistics;
import org.neo4j.consistency.store.RecordAccess; import org.neo4j.consistency.store.RecordAccess;
import org.neo4j.consistency.store.RecordReference; import org.neo4j.consistency.store.RecordReference;
import org.neo4j.graphdb.DynamicRelationshipType;
import org.neo4j.graphdb.GraphDatabaseService; import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node; import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.RelationshipType;
import org.neo4j.graphdb.factory.GraphDatabaseSettings; import org.neo4j.graphdb.factory.GraphDatabaseSettings;
import org.neo4j.helpers.progress.ProgressMonitorFactory; import org.neo4j.helpers.progress.ProgressMonitorFactory;
import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.configuration.Config;
Expand Down Expand Up @@ -93,7 +93,7 @@ protected void generateInitialData( GraphDatabaseService graphDb )
{ {
Node node1 = set( graphDb.createNode() ); Node node1 = set( graphDb.createNode() );
Node node2 = set( graphDb.createNode(), property( "key", "value" ) ); Node node2 = set( graphDb.createNode(), property( "key", "value" ) );
node1.createRelationshipTo( node2, DynamicRelationshipType.withName( "C" ) ); node1.createRelationshipTo( node2, RelationshipType.withName( "C" ) );
tx.success(); tx.success();
} }
} }
Expand Down
Expand Up @@ -118,8 +118,8 @@
import static org.neo4j.consistency.checking.full.ExecutionOrderIntegrationTest.config; import static org.neo4j.consistency.checking.full.ExecutionOrderIntegrationTest.config;
import static org.neo4j.consistency.checking.full.FullCheckIntegrationTest.ConsistencySummaryVerifier.on; import static org.neo4j.consistency.checking.full.FullCheckIntegrationTest.ConsistencySummaryVerifier.on;
import static org.neo4j.consistency.checking.schema.IndexRules.loadAllIndexRules; import static org.neo4j.consistency.checking.schema.IndexRules.loadAllIndexRules;
import static org.neo4j.graphdb.DynamicLabel.label; import static org.neo4j.graphdb.Label.label;
import static org.neo4j.graphdb.DynamicRelationshipType.withName; import static org.neo4j.graphdb.RelationshipType.withName;
import static org.neo4j.helpers.collection.IteratorUtil.asIterable; import static org.neo4j.helpers.collection.IteratorUtil.asIterable;
import static org.neo4j.helpers.collection.IteratorUtil.iterator; import static org.neo4j.helpers.collection.IteratorUtil.iterator;
import static org.neo4j.kernel.api.CountsRead.ANY_LABEL; import static org.neo4j.kernel.api.CountsRead.ANY_LABEL;
Expand Down
Expand Up @@ -19,8 +19,8 @@
*/ */
package org.neo4j.internal.cypher.acceptance package org.neo4j.internal.cypher.acceptance


import org.neo4j.cypher.{NewPlannerTestSupport, ExecutionEngineFunSuite, QueryStatisticsTestSupport, SyntaxException} import org.neo4j.cypher.{ExecutionEngineFunSuite, NewPlannerTestSupport, QueryStatisticsTestSupport, SyntaxException}
import org.neo4j.graphdb.{DynamicRelationshipType, Direction, Node, Relationship} import org.neo4j.graphdb.{Direction, Relationship, RelationshipType}


class CreateAcceptanceTest extends ExecutionEngineFunSuite with QueryStatisticsTestSupport with NewPlannerTestSupport { class CreateAcceptanceTest extends ExecutionEngineFunSuite with QueryStatisticsTestSupport with NewPlannerTestSupport {


Expand Down Expand Up @@ -141,8 +141,8 @@ class CreateAcceptanceTest extends ExecutionEngineFunSuite with QueryStatisticsT


assertStats(result, relationshipsCreated = 1) assertStats(result, relationshipsCreated = 1)
graph.inTx { graph.inTx {
start.getRelationships(DynamicRelationshipType.withName(typ), Direction.OUTGOING).asScala should have size 1 start.getRelationships(RelationshipType.withName(typ), Direction.OUTGOING).asScala should have size 1
end.getRelationships(DynamicRelationshipType.withName(typ), Direction.INCOMING).asScala should have size 1 end.getRelationships(RelationshipType.withName(typ), Direction.INCOMING).asScala should have size 1
} }
} }


Expand All @@ -155,7 +155,7 @@ class CreateAcceptanceTest extends ExecutionEngineFunSuite with QueryStatisticsT


assertStats(result, nodesCreated = 1, labelsAdded = 1, relationshipsCreated = 1) assertStats(result, nodesCreated = 1, labelsAdded = 1, relationshipsCreated = 1)
graph.inTx { graph.inTx {
start.getRelationships(DynamicRelationshipType.withName(typ), Direction.OUTGOING).asScala should have size 1 start.getRelationships(RelationshipType.withName(typ), Direction.OUTGOING).asScala should have size 1
} }
} }


Expand Down
Expand Up @@ -1491,8 +1491,8 @@ return b
test("MATCH (a1:X:Y)-[r]->() WITH r, a1 LIMIT 1 MATCH (a1:Y)-[r]->(b2) RETURN a1, r, b2") { test("MATCH (a1:X:Y)-[r]->() WITH r, a1 LIMIT 1 MATCH (a1:Y)-[r]->(b2) RETURN a1, r, b2") {
val node1 = graph.inTx({ val node1 = graph.inTx({
val node = createNode() val node = createNode()
node.addLabel(DynamicLabel.label("X")) node.addLabel(Label.label("X"))
node.addLabel(DynamicLabel.label("Y")) node.addLabel(Label.label("Y"))
node node
}) })
val node2 = createNode() val node2 = createNode()
Expand Down
Expand Up @@ -31,6 +31,7 @@ import org.neo4j.cypher.internal.frontend.v3_0.helpers.NonEmptyList
import org.neo4j.cypher.internal.frontend.v3_0.symbols._ import org.neo4j.cypher.internal.frontend.v3_0.symbols._
import org.neo4j.graphalgo.GraphAlgoFactory import org.neo4j.graphalgo.GraphAlgoFactory
import org.neo4j.graphalgo.impl.path.ShortestPath.ShortestPathPredicate import org.neo4j.graphalgo.impl.path.ShortestPath.ShortestPathPredicate
import org.neo4j.graphdb.RelationshipType.withName
import org.neo4j.graphdb._ import org.neo4j.graphdb._
import org.neo4j.kernel.Traversal import org.neo4j.kernel.Traversal


Expand Down Expand Up @@ -136,7 +137,7 @@ case class ShortestPathExpression(shortestPathPattern: ShortestPath, predicates:
Traversal.expanderForAllTypes(toGraphDb(shortestPathPattern.dir)) Traversal.expanderForAllTypes(toGraphDb(shortestPathPattern.dir))
} else { } else {
shortestPathPattern.relTypes.foldLeft(Traversal.emptyExpander()) { shortestPathPattern.relTypes.foldLeft(Traversal.emptyExpander()) {
case (e, t) => e.add(DynamicRelationshipType.withName(t), toGraphDb(shortestPathPattern.dir)) case (e, t) => e.add(withName(t), toGraphDb(shortestPathPattern.dir))
} }
} }


Expand Down
Expand Up @@ -22,13 +22,13 @@ package org.neo4j.cypher.internal.compiler.v3_0.pipes.matching
import org.neo4j.cypher.internal.compiler.v3_0._ import org.neo4j.cypher.internal.compiler.v3_0._
import org.neo4j.cypher.internal.compiler.v3_0.ast.convert.commands.DirectionConverter._ import org.neo4j.cypher.internal.compiler.v3_0.ast.convert.commands.DirectionConverter._
import org.neo4j.cypher.internal.compiler.v3_0.commands.predicates.Predicate import org.neo4j.cypher.internal.compiler.v3_0.commands.predicates.Predicate
import org.neo4j.cypher.internal.compiler.v3_0.pipes.QueryState
import org.neo4j.cypher.internal.compiler.v3_0.symbols.SymbolTable import org.neo4j.cypher.internal.compiler.v3_0.symbols.SymbolTable
import pipes.QueryState import org.neo4j.graphdb.{Node, Relationship, RelationshipType}
import org.neo4j.graphdb.{Relationship, Node, DynamicRelationshipType} import org.neo4j.graphmatching.{PatternMatch, PatternMatcher => SimplePatternMatcher, PatternNode => SimplePatternNode, PatternRelationship => SimplePatternRelationship}
import org.neo4j.graphmatching.{PatternMatcher => SimplePatternMatcher, PatternNode => SimplePatternNode,
PatternRelationship => SimplePatternRelationship, PatternMatch} import scala.collection.JavaConverters._
import collection.{immutable, Map} import scala.collection.{Map, immutable}
import collection.JavaConverters._


class SimplePatternMatcherBuilder(pattern: PatternGraph, class SimplePatternMatcherBuilder(pattern: PatternGraph,
predicates: Seq[Predicate], predicates: Seq[Predicate],
Expand All @@ -53,7 +53,7 @@ class SimplePatternMatcherBuilder(pattern: PatternGraph,
else { else {
// The SimplePatternMatcher does not support multiple relationship types // The SimplePatternMatcher does not support multiple relationship types
// re-visit this if it ever does // re-visit this if it ever does
start.createRelationshipTo(end, DynamicRelationshipType.withName(pr.relTypes.head), toGraphDb(pr.dir)) start.createRelationshipTo(end, RelationshipType.withName(pr.relTypes.head), toGraphDb(pr.dir))
} }


patternRel.setLabel(pr.key) patternRel.setLabel(pr.key)
Expand Down
Expand Up @@ -31,7 +31,7 @@ import scala.collection.JavaConverters._


class PathImplTest extends CypherFunSuite { class PathImplTest extends CypherFunSuite {


val typ = DynamicRelationshipType.withName("a") val typ = RelationshipType.withName("a")


test("singleNodeTests") { test("singleNodeTests") {
val node = new FakeNode val node = new FakeNode
Expand Down
Expand Up @@ -21,7 +21,7 @@ package org.neo4j.cypher.internal.compiler.v3_0.commands.expressions


import org.mockito.Mockito import org.mockito.Mockito
import org.neo4j.cypher.internal.frontend.v3_0.test_helpers.CypherFunSuite import org.neo4j.cypher.internal.frontend.v3_0.test_helpers.CypherFunSuite
import org.neo4j.graphdb.{DynamicRelationshipType, Node, Relationship} import org.neo4j.graphdb.{Node, Relationship, RelationshipType}


class PathValueBuilderTest extends CypherFunSuite { class PathValueBuilderTest extends CypherFunSuite {


Expand Down Expand Up @@ -245,7 +245,7 @@ class PathValueBuilderTest extends CypherFunSuite {
Mockito.when(rel.getId).thenReturn(id) Mockito.when(rel.getId).thenReturn(id)
Mockito.when(rel.getStartNode).thenReturn(start) Mockito.when(rel.getStartNode).thenReturn(start)
Mockito.when(rel.getEndNode).thenReturn(end) Mockito.when(rel.getEndNode).thenReturn(end)
Mockito.when(rel.getType).thenReturn(DynamicRelationshipType.withName("X")) Mockito.when(rel.getType).thenReturn(RelationshipType.withName("X"))
Mockito.when(rel.getOtherNode(start)).thenReturn(end) Mockito.when(rel.getOtherNode(start)).thenReturn(end)
Mockito.when(rel.getOtherNode(end)).thenReturn(start) Mockito.when(rel.getOtherNode(end)).thenReturn(start)


Expand Down

0 comments on commit 4512524

Please sign in to comment.