From aab063aa4f7ee04dc642326536180a20a0bc3d86 Mon Sep 17 00:00:00 2001 From: Pontus Melke Date: Fri, 12 Oct 2018 08:49:10 +0200 Subject: [PATCH] Fix failing tests - PointTypeIT wasn't cleaning up the database after tests - missing nullcheck before checking isArray --- .../server/rest/repr/PropertiesRepresentation.java | 3 --- .../server/rest/repr/RepresentationDispatcher.java | 2 +- .../server/rest/transactional/Neo4jJsonCodec.java | 2 +- .../rest/transactional/integration/PointTypeIT.java | 11 ++++++++++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/community/server/src/main/java/org/neo4j/server/rest/repr/PropertiesRepresentation.java b/community/server/src/main/java/org/neo4j/server/rest/repr/PropertiesRepresentation.java index 072519577090a..e3b30a8f1a90d 100644 --- a/community/server/src/main/java/org/neo4j/server/rest/repr/PropertiesRepresentation.java +++ b/community/server/src/main/java/org/neo4j/server/rest/repr/PropertiesRepresentation.java @@ -24,8 +24,6 @@ import org.neo4j.graphdb.PropertyContainer; import org.neo4j.graphdb.spatial.CRS; -import org.neo4j.graphdb.spatial.Coordinate; -import org.neo4j.graphdb.spatial.Geometry; import org.neo4j.graphdb.spatial.Point; import org.neo4j.server.helpers.PropertyTypeDispatcher; @@ -78,7 +76,6 @@ protected Void dispatchBooleanProperty( boolean property, String param ) protected Void dispatchPointProperty( Point property, String param ) { MappingWriter pointWriter = writer.newMapping( RepresentationType.POINT, param ); - writePoint( pointWriter, property ); pointWriter.done(); return null; diff --git a/community/server/src/main/java/org/neo4j/server/rest/repr/RepresentationDispatcher.java b/community/server/src/main/java/org/neo4j/server/rest/repr/RepresentationDispatcher.java index ccf2cb75130c6..36d72790ce027 100644 --- a/community/server/src/main/java/org/neo4j/server/rest/repr/RepresentationDispatcher.java +++ b/community/server/src/main/java/org/neo4j/server/rest/repr/RepresentationDispatcher.java @@ -180,7 +180,7 @@ protected Representation dispatchFloatArrayProperty( PropertyArray array, String parfam ) + protected Representation dispatchDoubleArrayProperty( PropertyArray array, String param ) { ArrayList values = new ArrayList<>(); for ( Double z : array ) diff --git a/community/server/src/main/java/org/neo4j/server/rest/transactional/Neo4jJsonCodec.java b/community/server/src/main/java/org/neo4j/server/rest/transactional/Neo4jJsonCodec.java index 05513f3c1bbbe..b9b53eee89a50 100644 --- a/community/server/src/main/java/org/neo4j/server/rest/transactional/Neo4jJsonCodec.java +++ b/community/server/src/main/java/org/neo4j/server/rest/transactional/Neo4jJsonCodec.java @@ -139,7 +139,7 @@ else if ( value instanceof Temporal || value instanceof TemporalAmount ) { super.writeValue( out, value.toString() ); } - else if ( value.getClass().isArray() && supportedArrayType( value.getClass().getComponentType() ) ) + else if ( value != null && value.getClass().isArray() && supportedArrayType( value.getClass().getComponentType() ) ) { writeReflectiveArray( out, value ); } diff --git a/community/server/src/test/java/org/neo4j/server/rest/transactional/integration/PointTypeIT.java b/community/server/src/test/java/org/neo4j/server/rest/transactional/integration/PointTypeIT.java index 0ccc2f9f48810..cd60d4d0603bb 100644 --- a/community/server/src/test/java/org/neo4j/server/rest/transactional/integration/PointTypeIT.java +++ b/community/server/src/test/java/org/neo4j/server/rest/transactional/integration/PointTypeIT.java @@ -20,6 +20,7 @@ package org.neo4j.server.rest.transactional.integration; import org.codehaus.jackson.JsonNode; +import org.junit.After; import org.junit.Test; import org.neo4j.graphdb.Node; @@ -44,10 +45,18 @@ public class PointTypeIT extends AbstractRestFunctionalTestBase { + @After + public void tearDown() + { + // empty the database + graphdb().execute( "MATCH (n) DETACH DELETE n" ); + } + @Test public void shouldWorkWithPoint2DArrays() throws Exception { - HTTP.Response response = runQuery( "create (:Node {points: [point({x:1, y:1}), point({x:2, y:2}), point({x: 3.0, y: 3.0})]})" ); + HTTP.Response response = + runQuery( "create (:Node {points: [point({x:1, y:1}), point({x:2, y:2}), point({x: 3.0, y: 3.0})]})" ); assertEquals( 200, response.status() ); assertNoErrors( response );