Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 45 additions & 64 deletions src/test/java/com/redislabs/redisgraph/RedisGraphAPITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,21 +181,15 @@ public void testHeader(){
Header header = queryResult.getHeader();

List<String> schemaNames = header.getSchemaNames();
List<Header.ResultSetColumnTypes> schemaTypes = header.getSchemaTypes();

Assert.assertNotNull(schemaNames);
Assert.assertNotNull(schemaTypes);

Assert.assertEquals(3, schemaNames.size());
Assert.assertEquals(3, schemaTypes.size());

Assert.assertEquals("a", schemaNames.get(0));
Assert.assertEquals("r", schemaNames.get(1));
Assert.assertEquals("a.age", schemaNames.get(2));

Assert.assertEquals(COLUMN_NODE, schemaTypes.get(0));
Assert.assertEquals(COLUMN_RELATION, schemaTypes.get(1));
Assert.assertEquals(COLUMN_SCALAR, schemaTypes.get(2));
Comment on lines -196 to -198
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove line 184
please annotate getSchemaTypes as @deprecated both in the interface and the implemented class, with explenation why it is deprecated


}

Expand Down Expand Up @@ -368,17 +362,11 @@ public void testMultiThread(){
Assert.assertNotNull(resultSet.getHeader());
Header header = resultSet.getHeader();
List<String> schemaNames = header.getSchemaNames();
List<Header.ResultSetColumnTypes> schemaTypes = header.getSchemaTypes();
Assert.assertNotNull(schemaNames);
Assert.assertNotNull(schemaTypes);
Assert.assertEquals(3, schemaNames.size());
Assert.assertEquals(3, schemaTypes.size());
Assert.assertEquals("a", schemaNames.get(0));
Assert.assertEquals("r", schemaNames.get(1));
Assert.assertEquals("a.age", schemaNames.get(2));
Assert.assertEquals(COLUMN_NODE, schemaTypes.get(0));
Assert.assertEquals(COLUMN_RELATION, schemaTypes.get(1));
Assert.assertEquals(COLUMN_SCALAR, schemaTypes.get(2));
Comment on lines -379 to -381
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove line 368 and all other lines using schemaTypes

Assert.assertEquals(1, resultSet.size());
Assert.assertTrue(resultSet.hasNext());
Record record = resultSet.next();
Expand Down Expand Up @@ -413,15 +401,10 @@ public void testMultiThread(){
Assert.assertNotNull(resultSet.getHeader());
Header header = resultSet.getHeader();
List<String> schemaNames = header.getSchemaNames();
List<Header.ResultSetColumnTypes> schemaTypes = header.getSchemaTypes();
Assert.assertNotNull(schemaNames);
Assert.assertNotNull(schemaTypes);
Assert.assertEquals(2, schemaNames.size());
Assert.assertEquals(2, schemaTypes.size());
Assert.assertEquals("a", schemaNames.get(0));
Assert.assertEquals("r", schemaNames.get(1));
Assert.assertEquals(COLUMN_NODE, schemaTypes.get(0));
Assert.assertEquals(COLUMN_RELATION, schemaTypes.get(1));
Comment on lines -423 to -424
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove line 410 and all the lines using schema types

Assert.assertEquals(1, resultSet.size());
Assert.assertTrue(resultSet.hasNext());
Record record = resultSet.next();
Expand Down Expand Up @@ -462,15 +445,10 @@ public void testAdditionToProcedures(){
Assert.assertNotNull(resultSet.getHeader());
Header header = resultSet.getHeader();
List<String> schemaNames = header.getSchemaNames();
List<Header.ResultSetColumnTypes> schemaTypes = header.getSchemaTypes();
Assert.assertNotNull(schemaNames);
Assert.assertNotNull(schemaTypes);
Assert.assertEquals(2, schemaNames.size());
Assert.assertEquals(2, schemaTypes.size());
Assert.assertEquals("a", schemaNames.get(0));
Assert.assertEquals("r", schemaNames.get(1));
Assert.assertEquals(COLUMN_NODE, schemaTypes.get(0));
Assert.assertEquals(COLUMN_RELATION, schemaTypes.get(1));
Comment on lines -472 to -473
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove line 457 and all line using schemaTypes

Assert.assertEquals(1, resultSet.size());
Assert.assertTrue(resultSet.hasNext());
Record record = resultSet.next();
Expand All @@ -497,15 +475,10 @@ public void testAdditionToProcedures(){
Assert.assertNotNull(resultSet.getHeader());
header = resultSet.getHeader();
schemaNames = header.getSchemaNames();
schemaTypes = header.getSchemaTypes();
Assert.assertNotNull(schemaNames);
Assert.assertNotNull(schemaTypes);
Assert.assertEquals(2, schemaNames.size());
Assert.assertEquals(2, schemaTypes.size());
Assert.assertEquals("a", schemaNames.get(0));
Assert.assertEquals("r", schemaNames.get(1));
Assert.assertEquals(COLUMN_NODE, schemaTypes.get(0));
Assert.assertEquals(COLUMN_RELATION, schemaTypes.get(1));
Comment on lines -507 to -508
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove line 490 and all lines using schemaTypes

Assert.assertEquals(1, resultSet.size());
Assert.assertTrue(resultSet.hasNext());
record = resultSet.next();
Expand Down Expand Up @@ -572,18 +545,10 @@ public void testMultiExec(){


List<String> schemaNames = header.getSchemaNames();
List<Header.ResultSetColumnTypes> schemaTypes = header.getSchemaTypes();

Assert.assertNotNull(schemaNames);
Assert.assertNotNull(schemaTypes);

Assert.assertEquals(1, schemaNames.size());
Assert.assertEquals(1, schemaTypes.size());

Assert.assertEquals("n", schemaNames.get(0));

Assert.assertEquals(COLUMN_NODE, schemaTypes.get(0));

Comment on lines -585 to -586
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove line 563 and all lines using schemaTypes

Property nameProperty = new Property("name", "a");

Node expectedNode = new Node();
Expand All @@ -606,18 +571,10 @@ public void testMultiExec(){


schemaNames = header.getSchemaNames();
schemaTypes = header.getSchemaTypes();

Assert.assertNotNull(schemaNames);
Assert.assertNotNull(schemaTypes);

Assert.assertEquals(1, schemaNames.size());
Assert.assertEquals(1, schemaTypes.size());

Assert.assertEquals("label", schemaNames.get(0));

Assert.assertEquals(COLUMN_SCALAR, schemaTypes.get(0));

Assert.assertEquals(1, resultSet.size());
Assert.assertTrue(resultSet.hasNext());
record = resultSet.next();
Expand Down Expand Up @@ -816,16 +773,9 @@ public void testArraySupport() {


List<String> schemaNames = header.getSchemaNames();
List<Header.ResultSetColumnTypes> schemaTypes = header.getSchemaTypes();

Assert.assertNotNull(schemaNames);
Assert.assertNotNull(schemaTypes);

Assert.assertEquals(1, schemaNames.size());
Assert.assertEquals(1, schemaTypes.size());

Assert.assertEquals("x", schemaNames.get(0));
Assert.assertEquals(COLUMN_SCALAR, schemaTypes.get(0));

// check record
Assert.assertEquals(1, resultSet.size());
Expand All @@ -846,16 +796,9 @@ public void testArraySupport() {


schemaNames = header.getSchemaNames();
schemaTypes = header.getSchemaTypes();

Assert.assertNotNull(schemaNames);
Assert.assertNotNull(schemaTypes);

Assert.assertEquals(1, schemaNames.size());
Assert.assertEquals(1, schemaTypes.size());

Assert.assertEquals("x", schemaNames.get(0));
Assert.assertEquals(COLUMN_SCALAR, schemaTypes.get(0));

// check record
Assert.assertEquals(1, resultSet.size());
Expand All @@ -875,16 +818,9 @@ record = resultSet.next();


schemaNames = header.getSchemaNames();
schemaTypes = header.getSchemaTypes();

Assert.assertNotNull(schemaNames);
Assert.assertNotNull(schemaTypes);

Assert.assertEquals(1, schemaNames.size());
Assert.assertEquals(1, schemaTypes.size());

Assert.assertEquals("x", schemaNames.get(0));
Assert.assertEquals(COLUMN_SCALAR, schemaTypes.get(0));

// check record
Assert.assertEquals(3, resultSet.size());
Expand Down Expand Up @@ -960,4 +896,49 @@ public void testParameters(){
}
}

@Test
public void testNullGraphEntities() {
// Create two nodes connected by a single outgoing edge.
Assert.assertNotNull(api.query("social", "CREATE (:L)-[:E]->(:L2)"));
// Test a query that produces 1 record with 3 null values.
ResultSet resultSet = api.query("social", "OPTIONAL MATCH (a:NONEXISTENT)-[e]->(b) RETURN a, e, b");
Assert.assertEquals(1, resultSet.size());
Assert.assertTrue(resultSet.hasNext());
Record record = resultSet.next();
Assert.assertFalse(resultSet.hasNext());
Assert.assertEquals(Arrays.asList(null, null, null), record.values());

// Test a query that produces 2 records, with 2 null values in the second.
resultSet = api.query("social", "MATCH (a) OPTIONAL MATCH (a)-[e]->(b) RETURN a, e, b ORDER BY ID(a)");
Assert.assertEquals(2, resultSet.size());
record = resultSet.next();
Assert.assertEquals(3, record.size());

Assert.assertNotNull(record.getValue(0));
Assert.assertNotNull(record.getValue(1));
Assert.assertNotNull(record.getValue(2));

record = resultSet.next();
Assert.assertEquals(3, record.size());

Assert.assertNotNull(record.getValue(0));
Assert.assertNull(record.getValue(1));
Assert.assertNull(record.getValue(2));

// Test a query that produces 2 records, the first containing a path and the second containing a null value.
resultSet = api.query("social", "MATCH (a) OPTIONAL MATCH p = (a)-[e]->(b) RETURN p");
Assert.assertEquals(2, resultSet.size());
record = resultSet.next();
Assert.assertEquals(1, record.size());

Object path = record.getValue(0);
Assert.assertNotNull(record.getValue(0));

record = resultSet.next();
Assert.assertEquals(1, record.size());

path = record.getValue(0);
Assert.assertNull(record.getValue(0));

}
}