Wolfgang-Schuetzelhofer / jcypher

Java access to Neo4J graph databases at multiple levels of abstraction
Apache License 2.0
86 stars 15 forks source link

mailing list #12

Closed asomov closed 8 years ago

asomov commented 8 years ago

Hi, is there a mailing list to discuss general questions ? What is the best way to ask a question ?

Wolfgang-Schuetzelhofer commented 8 years ago

Hi, at the moment please post questions to this issue you opened (#12) I will open a discussion group (google groups) soon.

Best regards, Wolfgang

asomov commented 8 years ago

I am trying to create a unit test for my code which creates a Seq[APIObject with IClause] which is then given to jcypher. The challenge is: I cannot compare (in the unit test) the expected Seq with generated Seq. Basically I miss "getters" or another way to see the contents of APIObject.

Wolfgang-Schuetzelhofer commented 8 years ago

To unit test a sequence of IClause(s) you can do the following: (an example)

IClause[] clauses = new IClause[] { MATCH.node(n).label("SomeLabel"), RETURN.value(n) }; JcQuery query = new JcQuery(); query.setClauses(clauses); String cypher = iot.jcypher.util.Util.toCypher(query, Format.PRETTY_1); String json = iot.jcypher.util.Util.toJSON(query, Format.PRETTY_1);

this will give you a string representation of the CYPHER expressions or a string representation of the JSON (CYPHER + parameters) respectively, which is generated based on the sequence of clauses. You can then take these strings as expected results in a unit test. APIObject(s) on execution create a quite complex model in the background, which is then converted to the upper mentioned CYPHER or JSON. Accessing internals of APIObject is not encouraged.

Hope that helps, best regards, Wolfgang

asomov commented 8 years ago

Thank you very much. This is exactly what I was looking for.