From 607308dd4e78b08d92ec6f217dc379b266f8728e Mon Sep 17 00:00:00 2001 From: fickludd Date: Mon, 6 Nov 2017 10:38:04 +0100 Subject: [PATCH] Add javadocs to various places. --- .../org/neo4j/internal/kernel/api/Write.java | 66 +++++++++++++++++++ .../kernel/api/KernelAPIReadTestBase.java | 18 +++-- .../kernel/api/KernelAPIReadTestSupport.java | 21 +++++- .../kernel/api/KernelAPIWriteTestBase.java | 19 ++++-- .../kernel/api/KernelAPIWriteTestSupport.java | 21 +++++- .../kernel/impl/newapi/ReadTestSupport.java | 5 -- 6 files changed, 134 insertions(+), 16 deletions(-) diff --git a/community/kernel-api/src/main/java/org/neo4j/internal/kernel/api/Write.java b/community/kernel-api/src/main/java/org/neo4j/internal/kernel/api/Write.java index 5f5deeebd2ca7..8c75c8609ce2e 100644 --- a/community/kernel-api/src/main/java/org/neo4j/internal/kernel/api/Write.java +++ b/community/kernel-api/src/main/java/org/neo4j/internal/kernel/api/Write.java @@ -26,27 +26,93 @@ */ public interface Write { + /** + * Create a node. + * @return The internal id of the created node + */ long nodeCreate(); + /** + * Delete a node. + * @param node the internal id of the node to delete + */ void nodeDelete( long node ); + /** + * Create a relationship between two nodes. + * @param sourceNode the source internal node id + * @param relationshipLabel the label of the relationship to create + * @param targetNode the target internal node id + * @return the internal id of the created relationship + */ long relationshipCreate( long sourceNode, int relationshipLabel, long targetNode ); + /** + * Delete a relationship + * @param relationship the internal id of the relationship to delete + */ void relationshipDelete( long relationship ); + /** + * Add a label to a node + * @param node the internal node id + * @param nodeLabel the internal id of the label to add + */ void nodeAddLabel( long node, int nodeLabel ); + /** + * Remove a label from a node + * @param node the internal node id + * @param nodeLabel the internal id of the label to remove + */ void nodeRemoveLabel( long node, int nodeLabel ); + /** + * Set a property on a node + * @param node the internal node id + * @param propertyKey the property key id + * @param value the value to set + * @return The replaced value, or Values.NO_VALUE if the node did not have the property before + */ Value nodeSetProperty( long node, int propertyKey, Value value ); + /** + * Remove a property from a node + * @param node the internal node id + * @param propertyKey the property key id + * @return The removed value, or Values.NO_VALUE if the node did not have the property before + */ Value nodeRemoveProperty( long node, int propertyKey ); + /** + * Set a property on a relationship + * @param relationship the internal relationship id + * @param propertyKey the property key id + * @param value the value to set + * @return The replaced value, or Values.NO_VALUE if the relationship did not have the property before + */ Value relationshipSetProperty( long relationship, int propertyKey, Value value ); + /** + * Remove a property from a relationship + * @param node the internal relationship id + * @param propertyKey the property key id + * @return The removed value, or Values.NO_VALUE if the relationship did not have the property before + */ Value relationshipRemoveProperty( long node, int propertyKey ); + /** + * Set a property on the graph + * @param propertyKey the property key id + * @param value the value to set + * @return The replaced value, or Values.NO_VALUE if the graph did not have the property before + */ Value graphSetProperty( int propertyKey, Value value ); + /** + * Remove a property from the graph + * @param propertyKey the property key id + * @return The removed value, or Values.NO_VALUE if the graph did not have the property before + */ Value graphRemoveProperty( int propertyKey ); } diff --git a/community/kernel-api/src/test/java/org/neo4j/internal/kernel/api/KernelAPIReadTestBase.java b/community/kernel-api/src/test/java/org/neo4j/internal/kernel/api/KernelAPIReadTestBase.java index 1ded1d188571a..739e5d1bd2df9 100644 --- a/community/kernel-api/src/test/java/org/neo4j/internal/kernel/api/KernelAPIReadTestBase.java +++ b/community/kernel-api/src/test/java/org/neo4j/internal/kernel/api/KernelAPIReadTestBase.java @@ -28,8 +28,19 @@ import org.neo4j.graphdb.GraphDatabaseService; +/** + * KernelAPIReadTestBase is the basis of read tests targeting the Kernel API. + * + * As tests are packaged together with the API, they cannot provide all the functionality needed to construct the + * test graph, or provide the concrete Kernel to test. These things are abstracted behind the + * KernelAPIReadTestSupport interface, which needs to be implemented to test reading Kernel implementations. + * + * As read tests do not modify the graph, the test graph is created lazily on the first test run. + * + * @param The test support for the current test. + */ @SuppressWarnings( "WeakerAccess" ) -public abstract class KernelAPIReadTestBase +public abstract class KernelAPIReadTestBase { protected static final TemporaryFolder folder = new TemporaryFolder(); protected static KernelAPIReadTestSupport testSupport; @@ -42,9 +53,9 @@ public abstract class KernelAPIReadTestBase protected Token token; /** - * Creates a new instance of KernelAPITestSupport, which will be used to execute the concrete test + * Creates a new instance of KernelAPIReadTestSupport, which will be used to execute the concrete test */ - public abstract G newTestSupport(); + public abstract ReadSupport newTestSupport(); /** * Create the graph which all test in the class will be executed against. The graph is only built once, @@ -65,7 +76,6 @@ public void setupGraph() throws IOException } Kernel kernel = testSupport.kernelToTest(); session = kernel.beginSession( PermissionsFixture.allPermissions() ); - testSupport.beforeEachTest(); cursors = kernel.cursors(); tx = session.beginTransaction(); token = session.token(); diff --git a/community/kernel-api/src/test/java/org/neo4j/internal/kernel/api/KernelAPIReadTestSupport.java b/community/kernel-api/src/test/java/org/neo4j/internal/kernel/api/KernelAPIReadTestSupport.java index 517190dd85cff..b0fa7f0481be7 100644 --- a/community/kernel-api/src/test/java/org/neo4j/internal/kernel/api/KernelAPIReadTestSupport.java +++ b/community/kernel-api/src/test/java/org/neo4j/internal/kernel/api/KernelAPIReadTestSupport.java @@ -25,13 +25,30 @@ import org.neo4j.graphdb.GraphDatabaseService; +/** + * This interface defines the functionality that's needed to run Kernel API Read tests (tests that extends + * KernelAPIReadTestBase) on a Kernel. + */ public interface KernelAPIReadTestSupport { + /** + * Setup the test. Called once. Starts a Kernel in the provided store directory, and populates the graph using + * the provided create method. + * + * @param storeDir The directory in which to create the database. + * @param create Method which populates the database. + * @throws IOException If database creation failed due to IO problems. + */ void setup( File storeDir, Consumer create ) throws IOException; - void beforeEachTest(); - + /** + * The Kernel to test. Called before every test. + * @return The Kernel. + */ Kernel kernelToTest(); + /** + * Teardown the Kernel and any other resources once all tests have completed. + */ void tearDown(); } diff --git a/community/kernel-api/src/test/java/org/neo4j/internal/kernel/api/KernelAPIWriteTestBase.java b/community/kernel-api/src/test/java/org/neo4j/internal/kernel/api/KernelAPIWriteTestBase.java index a1778fa3c58fd..9f26564737e7a 100644 --- a/community/kernel-api/src/test/java/org/neo4j/internal/kernel/api/KernelAPIWriteTestBase.java +++ b/community/kernel-api/src/test/java/org/neo4j/internal/kernel/api/KernelAPIWriteTestBase.java @@ -28,8 +28,19 @@ import org.neo4j.graphdb.GraphDatabaseService; +/** + * KernelAPIWriteTestBase is the basis of write tests targeting the Kernel API. + * + * Just as with KernelAPIReadTestBase, write tests cannot provide all the functionality needed to construct the + * test kernel, and also do not know how to assert the effects of the writes. These things are abstracted behind the + * KernelAPIWriteTestSupport interface, which needs to be implemented to test Kernel write implementations. + * + * Since write tests modify the graph, the test graph is recreated on every test run. + * + * @param The test support for the current test. + */ @SuppressWarnings( "WeakerAccess" ) -public abstract class KernelAPIWriteTestBase +public abstract class KernelAPIWriteTestBase { protected static final TemporaryFolder folder = new TemporaryFolder(); protected static KernelAPIWriteTestSupport testSupport; @@ -38,9 +49,9 @@ public abstract class KernelAPIWriteTestBase create ) throws create.accept( db ); } - @Override - public void beforeEachTest() - { - } - @Override public Kernel kernelToTest() {