|
6 | 6 | import org.junit.Test;
|
7 | 7 | import org.neo4j.graphdb.GraphDatabaseService;
|
8 | 8 | import org.neo4j.graphdb.Node;
|
| 9 | +import org.neo4j.graphdb.QueryExecutionException; |
9 | 10 | import org.neo4j.test.TestGraphDatabaseFactory;
|
10 | 11 |
|
11 | 12 | import java.util.*;
|
@@ -318,6 +319,21 @@ public void testFlattenWithDelimiter() {
|
318 | 319 | });
|
319 | 320 | }
|
320 | 321 |
|
| 322 | + @SuppressWarnings("unchecked") |
| 323 | + public void testUnflatten() { |
| 324 | + Map<String, Object> flatMap = map( "string", "value", "int", 10, "nested.anotherkey", "anotherValue", "nested.nested.somekey", "someValue", "nested.nested.somenumeric", 123 ); |
| 325 | + TestUtil.testCall( db, "RETURN apoc.map.unflatten($map) AS value", map( "map", flatMap ), (r) -> { |
| 326 | + Map<String, Object> resultMap = (Map<String, Object>)r.get( "value" ); |
| 327 | + assertEquals( map( "string", "value", "int", 10, "nested", map( "anotherkey", "anotherValue", "nested", map( "somekey", "someValue", "somenumeric", 123 ) ) ), resultMap ); |
| 328 | + } ); |
| 329 | + } |
| 330 | + |
| 331 | + @Test (expected = QueryExecutionException.class) |
| 332 | + public void testUnflattenConflictingKeys() { |
| 333 | + Map<String, Object> flatMap = map( "key", "value", "key.nested", "anotherValue" ); |
| 334 | + TestUtil.testCall( db, "RETURN apoc.map.unflatten($map) AS value", map( "map", flatMap ), (r) -> {} ); |
| 335 | + } |
| 336 | + |
321 | 337 | @Test
|
322 | 338 | public void testSortedProperties() {
|
323 | 339 | TestUtil.testCall(db, "WITH {b:8, d:3, a:2, E: 12, C:9} as map RETURN apoc.map.sortedProperties(map, false) AS sortedProperties", (r) -> {
|
|
0 commit comments