Browse files

test cases around auto-typing introduced into Element.getProperty() a…

…nd Element.removeProperty(). Removed some old commented out test cases in KeyIndexableGraph. Added more test cases to QueryTestSuite.
  • Loading branch information...
1 parent 8762d9d commit f0db8e4e67de50574a97a507a8ff498fb3703826 @okram okram committed Mar 10, 2013
View
41 blueprints-test/src/main/java/com/tinkerpop/blueprints/GraphTestSuite.java
@@ -697,4 +697,45 @@ public void testGraphDataPersists() {
}
graph.shutdown();
}
+
+ public void testAutotypingOfProperties() {
+ final Graph graph = graphTest.generateGraph();
+ if (graph.getFeatures().supportsVertexProperties) {
+ Vertex v = graph.addVertex(null);
+ v.setProperty(convertId(graph,"string"), "marko");
+ v.setProperty(convertId(graph,"integer"), 33);
+ v.setProperty(convertId(graph,"boolean"), true);
+
+ String name = v.getProperty(convertId(graph,"string"));
+ assertEquals(name, "marko");
+ Integer age = v.getProperty(convertId(graph,"integer"));
+ assertEquals(age, Integer.valueOf(33));
+ Boolean best = v.getProperty(convertId(graph,"boolean"));
+ assertTrue(best);
+
+ name = v.removeProperty(convertId(graph,"string"));
+ assertEquals(name, "marko");
+ age = v.removeProperty(convertId(graph,"integer"));
+ assertEquals(age, Integer.valueOf(33));
+ best = v.removeProperty(convertId(graph,"boolean"));
+ assertTrue(best);
+ }
+
+ if (graph.getFeatures().supportsEdgeProperties) {
+ Edge e = graph.addEdge(null, graph.addVertex(null), graph.addVertex(null), "knows");
+ e.setProperty(convertId(graph,"string"), "friend");
+ e.setProperty(convertId(graph,"double"), 1.0d);
+
+ String type = e.getProperty(convertId(graph,"string"));
+ assertEquals(type, "friend");
+ Double weight = e.getProperty(convertId(graph,"double"));
+ assertEquals(weight, 1.0d);
+
+ type = e.removeProperty(convertId(graph,"string"));
+ assertEquals(type, "friend");
+ weight = e.removeProperty(convertId(graph,"double"));
+ assertEquals(weight, 1.0d);
+ }
+ graph.shutdown();
+ }
}
View
26 blueprints-test/src/main/java/com/tinkerpop/blueprints/KeyIndexableGraphTestSuite.java
@@ -108,19 +108,6 @@ public void testGettingVerticesAndEdgesWithKeyValue() {
assertEquals(count(graph.getVertices("name", "stephen")), 1);
assertEquals(graph.getVertices("name", "marko").iterator().next(), v1);
assertEquals(graph.getVertices("name", "stephen").iterator().next(), v2);
-
- /*if (!graph.getFeatures().isWrapper) {
- assertTrue(graph.getVertices("location", "everywhere") instanceof PropertyFilteredIterable);
- assertTrue(graph.getVertices("location", "united states") instanceof PropertyFilteredIterable);
- assertTrue(graph.getVertices("location", 10) instanceof PropertyFilteredIterable);
- assertTrue(graph.getVertices("blah", "gnar") instanceof PropertyFilteredIterable);
- assertTrue(graph.getVertices("bloop", "ulapor states") instanceof PropertyFilteredIterable);
- assertTrue(graph.getVertices("bleep", 50) instanceof PropertyFilteredIterable);
- }
-
- assertFalse(graph.getVertices("name", "marko") instanceof PropertyFilteredIterable);
- assertFalse(graph.getVertices("name", "rodriguez") instanceof PropertyFilteredIterable);
- assertFalse(graph.getVertices("name", 768) instanceof PropertyFilteredIterable);*/
}
if (graph.getFeatures().supportsEdgeIteration && graph.getFeatures().supportsEdgeKeyIndex) {
@@ -140,19 +127,6 @@ public void testGettingVerticesAndEdgesWithKeyValue() {
assertEquals(count(graph.getEdges("name", "stephen")), 1);
assertEquals(graph.getEdges("name", "marko").iterator().next(), e1);
assertEquals(graph.getEdges("name", "stephen").iterator().next(), e2);
-
- /*assertFalse(graph.getEdges("place", "everywhere") instanceof PropertyFilteredIterable);
- assertFalse(graph.getEdges("place", "united states") instanceof PropertyFilteredIterable);
- assertFalse(graph.getEdges("place", 10) instanceof PropertyFilteredIterable);
-
- if (!graph.getFeatures().isWrapper) {
- assertTrue(graph.getEdges("blah", "gnar") instanceof PropertyFilteredIterable);
- assertTrue(graph.getEdges("bloop", "ulapor states") instanceof PropertyFilteredIterable);
- assertTrue(graph.getEdges("bleep", 50) instanceof PropertyFilteredIterable);
- assertTrue(graph.getEdges("name", "marko") instanceof PropertyFilteredIterable);
- assertTrue(graph.getEdges("name", "rodriguez") instanceof PropertyFilteredIterable);
- assertTrue(graph.getEdges("name", 768) instanceof PropertyFilteredIterable);
- }*/
}
graph.shutdown();
}
View
2 blueprints-test/src/main/java/com/tinkerpop/blueprints/QueryTestSuite.java
@@ -281,7 +281,9 @@ public void testGraphQueryForEdges() {
assertEquals(count(graph.query().limit(3).edges()), 2);
assertEquals(count(graph.query().has("type", "tinkerpop").has("type", "tinkerpop").edges()), 1);
+ assertEquals(graph.query().has("type", "tinkerpop").edges().iterator().next().getProperty("weight"), 1.0);
assertEquals(count(graph.query().has("type", "aurelius").edges()), 1);
+ assertEquals(graph.query().has("type", "aurelius").edges().iterator().next().getPropertyKeys().size(), 1);
assertEquals(count(graph.query().has("weight", null).edges()), 1);
assertEquals(graph.query().has("weight", null).edges().iterator().next().getProperty("type"), "aurelius");

0 comments on commit f0db8e4

Please sign in to comment.