Permalink
Browse files

couple of tests on entity sets

  • Loading branch information...
1 parent 840248a commit 4808a864387550a7c455539f6100a9d38626cde0 @nigelsmall nigelsmall committed Jan 17, 2012
View
16 geoff-core/src/test/java/org/neo4j/geoff/test/CreateOrUpdateNodeTest.java
@@ -133,4 +133,20 @@ public void canCreateMultipleAnonymousNodes() throws Exception {
db.assertNodeCount(4);
}
+ @Test
+ public void canCreateAndUpdateNodeSet() throws Exception {
+ TestGeoffBuilder geoff = new TestGeoffBuilder();
+ geoff.append("(N.1) {\"name\": \"Alice Allison\"}");
+ geoff.append("(N.2) {\"name\": \"Bob Robertson\"}");
+ geoff.append("(N.3) {\"name\": \"Carol Carlson\"}");
+ geoff.append("(N) {\"name\": \"Bob Robertson\"}");
+ Map<String, PropertyContainer> out = Geoff.loadIntoNeo4j(geoff.getReader(), db, null);
+ assertNotNull(out);
+ //dumpParams(out);
+ assertBob((Node) out.get("(N.1)"));
+ assertBob((Node) out.get("(N.2)"));
+ assertBob((Node) out.get("(N.3)"));
+ db.assertNodeCount(4);
+ }
+
}
View
25 geoff-core/src/test/java/org/neo4j/geoff/test/CreateOrUpdateRelationshipTest.java
@@ -39,7 +39,7 @@
import static org.junit.Assert.assertTrue;
import static org.neo4j.geoff.test.TestDatabase.*;
-public class CreateOrUpdateRelationshipTest {
+public class CreateOrUpdateRelationshipTest extends TestBase {
@Test
public void canParseShortCreateOrUpdateRelationshipRule() throws Exception {
@@ -400,7 +400,6 @@ public void ignoresShortNamedIncorrectlyTypedRelationship() throws Exception {
@Test
public void ignoresNamedIncorrectlyTypedRelationship() throws Exception {
- TestDatabase db = new TestDatabase();
Map<String, PropertyContainer> params = new HashMap<String, PropertyContainer>();
params.put("[R]", db.createAliceKnowsBob());
TestGeoffBuilder geoff = new TestGeoffBuilder("()-[R:HATES]->() {\"foo\": \"bar\"}");
@@ -414,7 +413,6 @@ public void ignoresNamedIncorrectlyTypedRelationship() throws Exception {
@Test
public void ignoresNamedIncorrectlyTypedRelationshipA() throws Exception {
- TestDatabase db = new TestDatabase();
Map<String, PropertyContainer> params = new HashMap<String, PropertyContainer>();
params.put("[R]", db.createAliceKnowsBob());
TestGeoffBuilder geoff = new TestGeoffBuilder("(A)-[R:HATES]->() {\"foo\": \"bar\"}");
@@ -428,7 +426,6 @@ public void ignoresNamedIncorrectlyTypedRelationshipA() throws Exception {
@Test
public void ignoresNamedIncorrectlyTypedRelationshipAB() throws Exception {
- TestDatabase db = new TestDatabase();
Map<String, PropertyContainer> params = new HashMap<String, PropertyContainer>();
params.put("[R]", db.createAliceKnowsBob());
TestGeoffBuilder geoff = new TestGeoffBuilder("(A)-[R:HATES]->(B) {\"foo\": \"bar\"}");
@@ -442,7 +439,6 @@ public void ignoresNamedIncorrectlyTypedRelationshipAB() throws Exception {
@Test
public void ignoresNamedIncorrectlyTypedRelationshipB() throws Exception {
- TestDatabase db = new TestDatabase();
Map<String, PropertyContainer> params = new HashMap<String, PropertyContainer>();
params.put("[R]", db.createAliceKnowsBob());
TestGeoffBuilder geoff = new TestGeoffBuilder("()-[R:HATES]->(B) {\"foo\": \"bar\"}");
@@ -458,7 +454,6 @@ public void ignoresNamedIncorrectlyTypedRelationshipB() throws Exception {
@Test
public void canCreateMultipleRelationshipsWithImplicitNodeCreation() throws Exception {
- TestDatabase db = new TestDatabase();
TestGeoffBuilder geoff = new TestGeoffBuilder();
geoff.append("(A)-[R_AB:LOVES]->(B)");
geoff.append("(B)-[R_BC:LOVES]->(C)");
@@ -471,7 +466,6 @@ public void canCreateMultipleRelationshipsWithImplicitNodeCreation() throws Exce
@Test
public void canCreateMultipleRelationshipsWithExplicitNodeCreation() throws Exception {
- TestDatabase db = new TestDatabase();
TestGeoffBuilder geoff = new TestGeoffBuilder();
geoff.appendAlice();
geoff.appendBob();
@@ -485,4 +479,21 @@ public void canCreateMultipleRelationshipsWithExplicitNodeCreation() throws Exce
db.assertCounts(4, 3);
}
+ @Test
+ public void canCreateRelationshipsFromNodeSets() throws Exception {
+ TestGeoffBuilder geoff = new TestGeoffBuilder();
+ geoff.append("(A.1) {\"name\": \"Alice Allison\"}");
+ geoff.append("(A.2) {\"name\": \"Amanda Allison\"}");
+ geoff.append("(B.1) {\"name\": \"Bob Robertson\"}");
+ geoff.append("(B.2) {\"name\": \"Bert Robertson\"}");
+ geoff.append("(B.3) {\"name\": \"Bill Robertson\"}");
+ geoff.append("(C) {\"name\": \"Carol Carlson\"}");
+ geoff.append("(A)-[R_AB:KNOWS]->(B) {\"status\": \"friends\"}");
+ geoff.append("(B)-[R_BC:KNOWS]->(C) {\"status\": \"colleagues\"}");
+ Map<String, PropertyContainer> out = Geoff.loadIntoNeo4j(geoff.getReader(), db, null);
+ assertNotNull(out);
+ //dumpParams(out);
+ db.assertCounts(7, 9);
+ }
+
}
View
19 geoff-core/src/test/java/org/neo4j/geoff/test/TestBase.java
@@ -21,6 +21,9 @@
import org.junit.After;
import org.junit.Before;
+import org.neo4j.graphdb.PropertyContainer;
+
+import java.util.Map;
public class TestBase
{
@@ -36,4 +39,20 @@ public void setUp() throws Exception {
public void tearDown() throws Exception {
db.shutdown();
}
+
+ public void dumpParams(Map<String, PropertyContainer> params) {
+ for (Map.Entry<String, PropertyContainer> entry : params.entrySet()) {
+ StringBuilder str = new StringBuilder(entry.getKey());
+ PropertyContainer entity = entry.getValue();
+ str.append(": ");
+ for (String key : entity.getPropertyKeys()) {
+ str.append(' ');
+ str.append(key);
+ str.append('=');
+ str.append(entity.getProperty(key));
+ }
+ System.out.println(str.toString());
+ }
+ }
+
}

0 comments on commit 4808a86

Please sign in to comment.