Skip to content

Commit

Permalink
Fixes neo4j#355 - Collections in collections are still Scala collecti…
Browse files Browse the repository at this point in the history
…ons instead of Java collections
  • Loading branch information
systay committed Jan 11, 2013
1 parent 3f14201 commit a224ba9
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 8 deletions.
1 change: 1 addition & 0 deletions community/cypher/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ o Fixes #394 - Identifiers inside of FOREACH get the wrong type
o Fixes #390 - IN/ANY/NONE/ANY/SINGLE causes RuntimeException for some patterns
o Fixes #387 - Some patterns produced "Unexpected traversal state" in Cypher
o Upgraded the Scala version to 2.10
o Fixes #355 - Collections in collections are still Scala collections instead of Java collections

1.9.M03
-------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class PipeExecutionResult(result: Iterator[Map[String, Any]], val columns: List[
}

private def makeValueJavaCompatible(value: Any): Any = value match {
case iter: Seq[_] => iter.asJava
case iter: Seq[_] => iter.map(makeValueJavaCompatible).asJava
case x => x
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package org.neo4j.cypher.javacompat;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import org.junit.Before;
import org.junit.Test;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Transaction;
import org.neo4j.test.TestGraphDatabaseFactory;

public class JavaCompatibilityTest
{
private GraphDatabaseService db;
private ExecutionEngine engine;

@Before
public void setUp() throws IOException
{
db = new TestGraphDatabaseFactory().newImpermanentDatabaseBuilder().newGraphDatabase();
engine = new ExecutionEngine( db );
Transaction tx = db.beginTx();

tx.success();
tx.finish();
}

@Test
public void collections_in_collections_look_aiight() throws Exception
{
ExecutionResult execute = engine.execute( "START n=node(0) RETURN [[ [1,2],[3,4] ],[[5,6]]] as x" );
Map<String, Object> next = execute.iterator().next();
List<List<Object>> x = (List<List<Object>>)next.get( "x" );
Object objects = x.get( 0 );

assertThat(objects, is(Iterable.class));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
*/
package org.neo4j.cypher.pycompat;

import java.util.Collection;
import java.util.Map;

import org.neo4j.graphdb.Path;
import scala.collection.JavaConversions;

/**
* Used to wrap gnarly scala classes into something that JPype understands.
Expand All @@ -41,11 +39,6 @@ else if(obj instanceof Map)
{
return new WrappedMap( (Map<String, Object>) obj );
}
else if(obj instanceof JavaConversions.SeqWrapper)
{
return new WrappedCollection<Object>( (Collection)obj );
}

return obj;
}

Expand Down

0 comments on commit a224ba9

Please sign in to comment.