-
Notifications
You must be signed in to change notification settings - Fork 20
add getters/setters to all Resultset classes and dependencies - issue… #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pierrelambert
wants to merge
3
commits into
RedisGraph:StatisticsImpl_jackson
Choose a base branch
from
pierrelambert:StatisticsImpl_jackson
base: StatisticsImpl_jackson
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
8c718f6
add getters/setters to all Resultset classes and dependencies - issue…
pierrelambert ea50b32
add test cases for getters/setters to all Resultset classes and depen…
pierrelambert ed0a669
add test cases for getters/setters to all Resultset classes and depen…
pierrelambert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,16 @@ | |
import java.util.*; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.IntStream; | ||
|
||
import com.redislabs.redisgraph.graph_entities.Edge; | ||
import com.redislabs.redisgraph.graph_entities.Node; | ||
import com.redislabs.redisgraph.graph_entities.Path; | ||
import com.redislabs.redisgraph.graph_entities.Property; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.redislabs.redisgraph.graph_entities.*; | ||
import com.redislabs.redisgraph.impl.api.RedisGraph; | ||
import com.redislabs.redisgraph.impl.resultset.RecordImpl; | ||
import com.redislabs.redisgraph.impl.resultset.ResultSetImpl; | ||
import com.redislabs.redisgraph.impl.resultset.StatisticsImpl; | ||
import com.redislabs.redisgraph.test.utils.PathBuilder; | ||
import org.junit.*; | ||
|
||
|
@@ -223,13 +226,6 @@ public void testRecord(){ | |
expectedNode.addProperty(doubleProperty); | ||
expectedNode.addProperty(trueBooleanProperty); | ||
expectedNode.addProperty(nullProperty); | ||
Assert.assertEquals( | ||
"Node{labels=[person], id=0, " | ||
+ "propertyMap={name=Property{name='name', value=roi}, " | ||
+ "boolValue=Property{name='boolValue', value=true}, " | ||
+ "doubleValue=Property{name='doubleValue', value=3.14}, " | ||
+ "nullValue=Property{name='nullValue', value=null}, " | ||
+ "age=Property{name='age', value=32}}}", expectedNode.toString()); | ||
|
||
Edge expectedEdge = new Edge(); | ||
expectedEdge.setId(0); | ||
|
@@ -241,6 +237,11 @@ public void testRecord(){ | |
expectedEdge.addProperty(doubleProperty); | ||
expectedEdge.addProperty(falseBooleanProperty); | ||
expectedEdge.addProperty(nullProperty); | ||
Assert.assertEquals("{boolValue=Property{name='boolValue', value=false}, " | ||
+ "place=Property{name='place', value=TLV}, " | ||
+ "doubleValue=Property{name='doubleValue', value=3.14}, " | ||
+ "nullValue=Property{name='nullValue', value=null}, " | ||
+ "since=Property{name='since', value=2000}}",expectedEdge.getPropertyMap().toString()); | ||
Assert.assertEquals("Edge{relationshipType='knows', source=0, destination=1, id=0, " | ||
+ "propertyMap={boolValue=Property{name='boolValue', value=false}, " | ||
+ "place=Property{name='place', value=TLV}, " | ||
|
@@ -272,6 +273,8 @@ public void testRecord(){ | |
Assert.assertEquals(0, resultSet.getStatistics().relationshipsCreated()); | ||
Assert.assertEquals(0, resultSet.getStatistics().relationshipsDeleted()); | ||
Assert.assertNotNull(resultSet.getStatistics().getStringValue(Label.QUERY_INTERNAL_EXECUTION_TIME)); | ||
//Added the getQueryExecutionTime method | ||
Assert.assertNotNull(resultSet.getStatistics().queryExecutionTime()); | ||
|
||
|
||
Assert.assertEquals(1, resultSet.size()); | ||
|
@@ -615,6 +618,13 @@ public void testContextedAPI() { | |
expectedNode.addProperty(doubleProperty); | ||
expectedNode.addProperty(trueBooleanProperty); | ||
expectedNode.addProperty(nullProperty); | ||
Assert.assertEquals( | ||
"Node{labels=[person], id=0, " | ||
+ "propertyMap={name=Property{name='name', value=roi}, " | ||
+ "boolValue=Property{name='boolValue', value=true}, " | ||
+ "doubleValue=Property{name='doubleValue', value=3.14}, " | ||
+ "nullValue=Property{name='nullValue', value=null}, " | ||
+ "age=Property{name='age', value=32}}}", expectedNode.toString()); | ||
|
||
Edge expectedEdge = new Edge(); | ||
expectedEdge.setId(0); | ||
|
@@ -626,6 +636,12 @@ public void testContextedAPI() { | |
expectedEdge.addProperty(doubleProperty); | ||
expectedEdge.addProperty(falseBooleanProperty); | ||
expectedEdge.addProperty(nullProperty); | ||
Assert.assertEquals("Edge{relationshipType='knows', source=0, destination=1, id=0, " | ||
+ "propertyMap={boolValue=Property{name='boolValue', value=false}, " | ||
+ "place=Property{name='place', value=TLV}, " | ||
+ "doubleValue=Property{name='doubleValue', value=3.14}, " | ||
+ "nullValue=Property{name='nullValue', value=null}, " | ||
+ "since=Property{name='since', value=2000}}}", expectedEdge.toString()); | ||
|
||
Map<String, Object> params = new HashMap<>(); | ||
params.put("name", name); | ||
|
@@ -973,4 +989,127 @@ public void testCachedExecution() { | |
Assert.assertEquals(params.get("val"), r.getValue(0)); | ||
Assert.assertTrue(resultSet.getStatistics().cachedExecution()); | ||
} | ||
|
||
@Test | ||
public void testResultSetImplSerializable(){ | ||
|
||
|
||
String name = "roi"; | ||
int age = 32; | ||
double doubleValue = 3.14; | ||
boolean boolValue = true; | ||
|
||
String place = "TLV"; | ||
int since = 2000; | ||
|
||
Property<String> nameProperty = new Property<>("name", name); | ||
Property<Integer> ageProperty = new Property<>("age", age); | ||
Property<Double> doubleProperty = new Property<>("doubleValue", doubleValue); | ||
Property<Boolean> trueBooleanProperty = new Property<>("boolValue", true); | ||
Property<Boolean> falseBooleanProperty = new Property<>("boolValue", false); | ||
Property<?> nullProperty = new Property<>("nullValue", null); | ||
|
||
Property<String> placeProperty = new Property<>("place", place); | ||
Property<Integer> sinceProperty = new Property<>("since", since); | ||
|
||
Node expectedNode = new Node(); | ||
expectedNode.setId(0); | ||
expectedNode.addLabel("person"); | ||
expectedNode.addProperty(nameProperty); | ||
expectedNode.addProperty(ageProperty); | ||
expectedNode.addProperty(doubleProperty); | ||
expectedNode.addProperty(trueBooleanProperty); | ||
expectedNode.addProperty(nullProperty); | ||
|
||
Edge expectedEdge = new Edge(); | ||
expectedEdge.setId(0); | ||
expectedEdge.setSource(0); | ||
expectedEdge.setDestination(1); | ||
expectedEdge.setRelationshipType("knows"); | ||
expectedEdge.addProperty(placeProperty); | ||
expectedEdge.addProperty(sinceProperty); | ||
expectedEdge.addProperty(doubleProperty); | ||
expectedEdge.addProperty(falseBooleanProperty); | ||
expectedEdge.addProperty(nullProperty); | ||
// PropertyMap getter tests | ||
Assert.assertEquals("{name=Property{name='name', value=roi}, " | ||
+ "boolValue=Property{name='boolValue', value=true}, " | ||
+ "doubleValue=Property{name='doubleValue', value=3.14}, " | ||
+ "nullValue=Property{name='nullValue', value=null}, " | ||
+ "age=Property{name='age', value=32}}",expectedNode.getPropertyMap().toString()); | ||
|
||
Assert.assertEquals( | ||
"Node{labels=[person], id=0, " | ||
+ "propertyMap={name=Property{name='name', value=roi}, " | ||
+ "boolValue=Property{name='boolValue', value=true}, " | ||
+ "doubleValue=Property{name='doubleValue', value=3.14}, " | ||
+ "nullValue=Property{name='nullValue', value=null}, " | ||
+ "age=Property{name='age', value=32}}}", expectedNode.toString()); | ||
|
||
Map<String, Object> params = new HashMap<>(); | ||
params.put("name", name); | ||
params.put("age", age); | ||
params.put("boolValue", boolValue); | ||
params.put("doubleValue", doubleValue); | ||
|
||
Assert.assertNotNull(api.query("social", "CREATE (:person{name:$name,age:$age, doubleValue:$doubleValue, boolValue:$boolValue, nullValue:null})", params)); | ||
Assert.assertNotNull(api.query("social", "CREATE (:person{name:'amit',age:30})")); | ||
Assert.assertNotNull(api.query("social", "MATCH (a:person), (b:person) WHERE (a.name = 'roi' AND b.name='amit') " + | ||
"CREATE (a)-[:knows{place:'TLV', since:2000,doubleValue:3.14, boolValue:false, nullValue:null}]->(b)")); | ||
|
||
|
||
|
||
ResultSet resultSet = api.query("social", "MATCH (a:person)-[r:knows]->(b:person) RETURN a,r, " + | ||
"a.name, a.age, a.doubleValue, a.boolValue, a.nullValue, " + | ||
"r.place, r.since, r.doubleValue, r.boolValue, r.nullValue"); | ||
Assert.assertNotNull(resultSet); | ||
//New ResultSet.getResults() Method test | ||
Assert.assertNotNull(resultSet.getResults()); | ||
Assert.assertEquals(1,resultSet.getResults().size()); | ||
|
||
Assert.assertFalse(resultSet.getResults().isEmpty()); | ||
Record record = resultSet.next(); | ||
Assert.assertFalse(resultSet.hasNext()); | ||
|
||
|
||
|
||
Node node = record.getValue(0); | ||
Node node2 = resultSet.getResults().get(0).getValue(0); | ||
Assert.assertNotNull(node); | ||
Assert.assertNotNull(node2); | ||
Assert.assertEquals(node,node2); | ||
|
||
Assert.assertEquals(expectedNode, node2); | ||
|
||
node = resultSet.getResults().get(0).getValue("a"); | ||
Assert.assertEquals(expectedNode, node); | ||
|
||
Edge edge = resultSet.getResults().get(0).getValue(1); | ||
Assert.assertNotNull(edge); | ||
Assert.assertEquals(expectedEdge, edge); | ||
|
||
edge = resultSet.getResults().get(0).getValue("r"); | ||
Assert.assertEquals(expectedEdge, edge); | ||
|
||
Assert.assertEquals(Arrays.asList("a", "r", "a.name", "a.age", "a.doubleValue", "a.boolValue", "a.nullValue", | ||
"r.place", "r.since", "r.doubleValue", "r.boolValue", "r.nullValue"), resultSet.getResults().get(0).keys()); | ||
//Serialization tests | ||
ObjectMapper mapper = new ObjectMapper(); | ||
|
||
|
||
Assert.assertTrue((mapper.canSerialize(StatisticsImpl.class))); | ||
Assert.assertTrue((mapper.canSerialize(RecordImpl.class))); | ||
Assert.assertTrue((mapper.canSerialize(GraphEntity.class))); | ||
Assert.assertTrue((mapper.canSerialize(ResultSetImpl.class))); | ||
Assert.assertTrue((mapper.canSerialize(Property.class))); | ||
Assert.assertTrue((mapper.canSerialize(Node.class))); | ||
Assert.assertTrue((mapper.canSerialize(Edge.class))); | ||
Assert.assertTrue((mapper.canSerialize(Path.class))); | ||
Assert.assertTrue((mapper.canSerialize(ResultSet.class))); | ||
Comment on lines
+1100
to
+1108
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. align indentations, please |
||
// Assert.assertTrue((mapper.canSerialize(Statistics.class))); | ||
// Assert.assertTrue((mapper.canSerialize(Record.class))); | ||
Comment on lines
+1109
to
+1110
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove those |
||
|
||
|
||
|
||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a scenario of serialization and deserialization?
resultsSet->JSON->resultSet
compare the original resultSet to the generated resultSet