pacer 2.0.10.pre-java → 2.0.12-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +5 -13
  2. data/.autotest +0 -4
  3. data/.gitignore +1 -0
  4. data/.travis.yml +2 -2
  5. data/Rakefile +25 -0
  6. data/blog/detach_benchmarks.txt +56 -0
  7. data/ext/.classpath +26 -0
  8. data/ext/.gitignore +44 -0
  9. data/ext/.project +23 -0
  10. data/ext/pom.xml +76 -0
  11. data/ext/src/main/java/com/xnlogic/pacer/pipes/BlackboxPipeline.java +56 -0
  12. data/ext/src/main/java/com/xnlogic/pacer/pipes/CollectionFilterPipe.java +18 -0
  13. data/ext/src/main/java/com/xnlogic/pacer/pipes/EdgesPipe.java +26 -0
  14. data/ext/src/main/java/com/xnlogic/pacer/pipes/ExpandablePipe.java +93 -0
  15. data/ext/src/main/java/com/xnlogic/pacer/pipes/IdCollectionFilterPipe.java +50 -0
  16. data/ext/src/main/java/com/xnlogic/pacer/pipes/IsEmptyPipe.java +35 -0
  17. data/ext/src/main/java/com/xnlogic/pacer/pipes/IsUniquePipe.java +58 -0
  18. data/ext/src/main/java/com/xnlogic/pacer/pipes/LabelCollectionFilterPipe.java +32 -0
  19. data/ext/src/main/java/com/xnlogic/pacer/pipes/LabelPrefixPipe.java +23 -0
  20. data/ext/src/main/java/com/xnlogic/pacer/pipes/NeverPipe.java +10 -0
  21. data/ext/src/main/java/com/xnlogic/pacer/pipes/VerticesPipe.java +26 -0
  22. data/ext/src/test/java/com/xnlogic/pacer/pipes/BlackboxPipelineTest.java +33 -0
  23. data/ext/src/test/java/com/xnlogic/pacer/pipes/CollectionFilterPipeTest.java +50 -0
  24. data/ext/src/test/java/com/xnlogic/pacer/pipes/EdgesPipeTest.java +103 -0
  25. data/ext/src/test/java/com/xnlogic/pacer/pipes/ExpandablePipeTest.java +66 -0
  26. data/ext/src/test/java/com/xnlogic/pacer/pipes/IdCollectionFilterPipeTest.java +85 -0
  27. data/ext/src/test/java/com/xnlogic/pacer/pipes/IsUniquePipeTest.java +62 -0
  28. data/ext/src/test/java/com/xnlogic/pacer/pipes/LabelCollectionFilterPipeTest.java +97 -0
  29. data/ext/src/test/java/com/xnlogic/pacer/pipes/LabelPrefixPipeTest.java +69 -0
  30. data/ext/src/test/java/com/xnlogic/pacer/pipes/NeverPipeTest.java +17 -0
  31. data/ext/src/test/java/com/xnlogic/pacer/pipes/VerticesPipeTest.java +97 -0
  32. data/lib/pacer/core/graph/element_route.rb +2 -2
  33. data/lib/pacer/core/graph/path_route.rb +2 -2
  34. data/lib/pacer/core/route.rb +77 -1
  35. data/lib/pacer/filter/property_filter/edge_filters.rb +5 -1
  36. data/lib/pacer/filter/property_filter/filters.rb +23 -7
  37. data/lib/pacer/pipe/path_wrapping_pipe.rb +14 -3
  38. data/lib/pacer/pipe/wrapping_pipe.rb +15 -4
  39. data/lib/pacer/pipes.rb +15 -13
  40. data/lib/pacer/route.rb +1 -0
  41. data/lib/pacer/side_effect/as_var.rb +1 -1
  42. data/lib/pacer/side_effect/is_unique.rb +2 -2
  43. data/lib/pacer/transform/branch.rb +1 -1
  44. data/lib/pacer/transform/lookup_ids.rb +1 -1
  45. data/lib/pacer/transform/path_tree.rb +1 -1
  46. data/lib/pacer/transform/reduce.rb +1 -1
  47. data/lib/pacer/transform/sort_section.rb +17 -9
  48. data/lib/pacer/transform/stream_sort.rb +1 -0
  49. data/lib/pacer/transform/stream_uniq.rb +1 -0
  50. data/lib/pacer/transform/wrapped_path.rb +1 -1
  51. data/lib/pacer/version.rb +1 -1
  52. data/lib/pacer/visitors/section.rb +10 -3
  53. data/lib/pacer/visitors/visits_section.rb +4 -4
  54. data/lib/pacer-ext.jar +0 -0
  55. data/lib/pacer.rb +1 -0
  56. data/pacer.gemspec +2 -1
  57. data/spec/pacer/filter/property_filter_spec.rb +17 -0
  58. data/spec/pacer/transform/path_spec.rb +10 -0
  59. data/spec/pacer/transform/sort_section_spec.rb +8 -1
  60. metadata +59 -30
  61. data/lib/pacer/pipe/blackbox_pipeline.rb +0 -55
  62. data/lib/pacer/pipe/collection_filter_pipe.rb +0 -12
  63. data/lib/pacer/pipe/edges_pipe.rb +0 -22
  64. data/lib/pacer/pipe/expandable_pipe.rb +0 -51
  65. data/lib/pacer/pipe/id_collection_filter_pipe.rb +0 -37
  66. data/lib/pacer/pipe/is_empty_pipe.rb +0 -23
  67. data/lib/pacer/pipe/is_unique_pipe.rb +0 -51
  68. data/lib/pacer/pipe/label_collection_filter_pipe.rb +0 -15
  69. data/lib/pacer/pipe/label_prefix_pipe.rb +0 -15
  70. data/lib/pacer/pipe/never_pipe.rb +0 -9
  71. data/lib/pacer/pipe/vertices_pipe.rb +0 -22
@@ -0,0 +1,32 @@
1
+ package com.xnlogic.pacer.pipes;
2
+
3
+ import java.util.Collection;
4
+ import java.util.HashSet;
5
+ import java.util.Set;
6
+
7
+ import com.tinkerpop.blueprints.Edge;
8
+ import com.tinkerpop.pipes.AbstractPipe;
9
+
10
+ public class LabelCollectionFilterPipe extends AbstractPipe<Edge, Edge> {
11
+ private Set<String> labels;
12
+
13
+ public LabelCollectionFilterPipe(final Collection<String> labels) {
14
+ if (labels instanceof Set) {
15
+ this.labels = (Set<String>)labels;
16
+ } else {
17
+ this.labels = new HashSet<String>();
18
+ if(labels != null){
19
+ this.labels.addAll(labels);
20
+ }
21
+ }
22
+ }
23
+
24
+ protected Edge processNextStart() {
25
+ while (true) {
26
+ Edge edge = this.starts.next();
27
+ if (edge != null && this.labels.contains(edge.getLabel())) {
28
+ return edge;
29
+ }
30
+ }
31
+ }
32
+ }
@@ -0,0 +1,23 @@
1
+ package com.xnlogic.pacer.pipes;
2
+
3
+ import com.tinkerpop.blueprints.Edge;
4
+ import com.tinkerpop.pipes.AbstractPipe;
5
+ import java.util.regex.Pattern;
6
+
7
+ public class LabelPrefixPipe extends AbstractPipe<Edge, Edge> {
8
+ private Pattern pattern;
9
+
10
+ public LabelPrefixPipe(final String pattern) {
11
+ super();
12
+ this.pattern = Pattern.compile("^" + pattern);
13
+ }
14
+
15
+ protected Edge processNextStart() {
16
+ while (true) {
17
+ Edge e = this.starts.next();
18
+ if (this.pattern.matcher(e.getLabel()).matches()) {
19
+ return e;
20
+ }
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,10 @@
1
+ package com.xnlogic.pacer.pipes;
2
+
3
+ import com.tinkerpop.pipes.AbstractPipe;
4
+ import com.tinkerpop.pipes.util.FastNoSuchElementException;
5
+
6
+ public class NeverPipe extends AbstractPipe<Object, Object> {
7
+ protected Object processNextStart() {
8
+ throw FastNoSuchElementException.instance();
9
+ }
10
+ }
@@ -0,0 +1,26 @@
1
+ package com.xnlogic.pacer.pipes;
2
+
3
+ import java.util.Iterator;
4
+
5
+ import com.tinkerpop.blueprints.Graph;
6
+ import com.tinkerpop.blueprints.Vertex;
7
+ import com.tinkerpop.pipes.AbstractPipe;
8
+
9
+ public class VerticesPipe extends AbstractPipe<Graph, Vertex> {
10
+ private Iterator<Vertex> iter;
11
+ private Graph starts;
12
+
13
+ public void setStarts(Iterator<Graph> starts) {
14
+ // TODO: Error checking?
15
+ this.starts = (Graph)starts.next();
16
+ this.iter = this.starts.getVertices().iterator();
17
+ }
18
+
19
+ protected Vertex processNextStart() {
20
+ return this.iter.next();
21
+ }
22
+
23
+ public void reset() {
24
+ this.iter = this.starts.getVertices().iterator();
25
+ }
26
+ }
@@ -0,0 +1,33 @@
1
+ package com.xnlogic.pacer.pipes;
2
+
3
+ import static org.junit.Assert.*;
4
+ import org.junit.Test;
5
+ import com.tinkerpop.pipes.Pipe;
6
+ import com.tinkerpop.pipes.IdentityPipe;
7
+ import java.util.Arrays;
8
+ import java.util.List;
9
+ import com.xnlogic.pacer.pipes.BlackboxPipeline;
10
+
11
+ public class BlackboxPipelineTest {
12
+ @Test
13
+ public void resetTest() {
14
+ List<String> data = Arrays.asList("Pacer", "Pipes", "Test");
15
+ Pipe<String, String> pipe1 = new IdentityPipe<String>();
16
+ Pipe<String, String> pipe2 = new IdentityPipe<String>();
17
+ BlackboxPipeline<String, String> blackboxPipeline = new BlackboxPipeline<String, String>(pipe1, pipe2);
18
+
19
+ blackboxPipeline.setStarts(data);
20
+ pipe2.setStarts(data);
21
+
22
+ int count = 0;
23
+
24
+ while (blackboxPipeline.hasNext()) {
25
+ assertEquals(blackboxPipeline.next(), data.get(count));
26
+ blackboxPipeline.reset();
27
+ count++;
28
+ }
29
+
30
+ assertEquals(count, data.size());
31
+ assertFalse(blackboxPipeline.hasNext());
32
+ }
33
+ }
@@ -0,0 +1,50 @@
1
+ package com.xnlogic.pacer.pipes;
2
+
3
+ import static org.junit.Assert.*;
4
+ import org.junit.Test;
5
+ import com.tinkerpop.blueprints.Contains;
6
+ import java.util.Collection;
7
+ import java.util.Arrays;
8
+ import java.util.ArrayList;
9
+ import com.xnlogic.pacer.pipes.CollectionFilterPipe;
10
+
11
+ public class CollectionFilterPipeTest {
12
+ @Test
13
+ public void filterInTest() {
14
+ Collection<String> collection = Arrays.asList("Pacer", "Pipes", "XNLogic");
15
+ Collection<String> starts = Arrays.asList("Pacer", "XNLogic");
16
+ Collection<String> result = new ArrayList<String>();
17
+ CollectionFilterPipe<String> collectionFilterPipe = new CollectionFilterPipe<String>(collection, Contains.IN);
18
+
19
+ collectionFilterPipe.setStarts(starts);
20
+
21
+ while (collectionFilterPipe.hasNext()) {
22
+ result.add(collectionFilterPipe.next());
23
+ }
24
+
25
+ assertEquals(2, result.size());
26
+ assertTrue(result.contains("Pacer"));
27
+ assertTrue(result.contains("XNLogic"));
28
+ assertFalse(result.contains("Pipes"));
29
+ }
30
+
31
+ @Test
32
+ public void filterNotInTest() {
33
+ Collection<String> collection = Arrays.asList("Pacer", "Pipes", "XNLogic");
34
+ Collection<String> starts = Arrays.asList("Pacer", "Java");
35
+ Collection<String> result = new ArrayList<String>();
36
+ CollectionFilterPipe<String> collectionFilterPipe = new CollectionFilterPipe<String>(collection, Contains.NOT_IN);
37
+
38
+ collectionFilterPipe.setStarts(starts);
39
+
40
+ while (collectionFilterPipe.hasNext()) {
41
+ result.add(collectionFilterPipe.next());
42
+ }
43
+
44
+ assertEquals(1, result.size());
45
+ assertFalse(result.contains("Pacer"));
46
+ assertTrue(result.contains("Java"));
47
+ }
48
+
49
+ // TODO: Test other constructor version.
50
+ }
@@ -0,0 +1,103 @@
1
+ package com.xnlogic.pacer.pipes;
2
+
3
+ import static org.junit.Assert.*;
4
+ import org.junit.Test;
5
+ import org.junit.Before;
6
+ import org.junit.After;
7
+ import com.tinkerpop.blueprints.impls.tg.TinkerGraph;
8
+ import com.tinkerpop.blueprints.Graph;
9
+ import com.tinkerpop.blueprints.Vertex;
10
+ import com.tinkerpop.blueprints.Edge;
11
+ import java.util.Collection;
12
+ import java.util.Arrays;
13
+ import java.util.ArrayList;
14
+ import com.xnlogic.pacer.pipes.EdgesPipe;
15
+
16
+ public class EdgesPipeTest {
17
+ private TinkerGraph graph = null;
18
+ private Collection<Graph> graphs;
19
+ private Collection<Edge> edgesThatCount;
20
+
21
+ @Before
22
+ public void setup() throws Exception {
23
+ this.graph = new TinkerGraph();
24
+ this.graphs = Arrays.asList((Graph)this.graph);
25
+ }
26
+
27
+ private void createEdges() {
28
+ Vertex v1 = this.graph.addVertex(1);
29
+ Vertex v2 = this.graph.addVertex(2);
30
+ Vertex v3 = this.graph.addVertex(3);
31
+
32
+ Edge e1 = this.graph.addEdge("E1", v1, v2, "edge_label");
33
+ Edge e2 = this.graph.addEdge("E2", v2, v1, "edge_label2");
34
+ Edge e3 = this.graph.addEdge("E3", v1, v2, "edge_label3");
35
+ this.graph.addEdge("E4", v2, v3, "edge_label4");
36
+
37
+ this.edgesThatCount = Arrays.asList(e1, e2, e3);
38
+ }
39
+
40
+ @After
41
+ public void teardown() throws Exception {
42
+ this.graph.shutdown();
43
+ this.graph = null;
44
+ }
45
+
46
+ @Test
47
+ public void getEdgesFromGraphTest() {
48
+ this.createEdges();
49
+
50
+ EdgesPipe edgesPipe = new EdgesPipe();
51
+ edgesPipe.setStarts(this.graphs);
52
+
53
+ Collection<Edge> edges = new ArrayList<Edge>();
54
+
55
+ while (edgesPipe.hasNext()) {
56
+ edges.add(edgesPipe.next());
57
+ }
58
+
59
+ assertEquals(4, edges.size());
60
+ assertTrue(edges.containsAll(this.edgesThatCount));
61
+ }
62
+
63
+ @Test
64
+ public void getEdgesFromGraphAfterResetTest() {
65
+ this.createEdges();
66
+
67
+ EdgesPipe edgesPipe = new EdgesPipe();
68
+ edgesPipe.setStarts(this.graphs);
69
+
70
+ Collection<Edge> edges = new ArrayList<Edge>();
71
+
72
+ while (edgesPipe.hasNext()) {
73
+ edges.add(edgesPipe.next());
74
+ }
75
+
76
+ assertEquals(4, edges.size());
77
+ assertTrue(edges.containsAll(this.edgesThatCount));
78
+
79
+ edgesPipe.reset();
80
+ edges.clear();
81
+
82
+ while (edgesPipe.hasNext()) {
83
+ edges.add(edgesPipe.next());
84
+ }
85
+
86
+ assertEquals(4, edges.size());
87
+ assertTrue(edges.containsAll(this.edgesThatCount));
88
+ }
89
+
90
+ @Test
91
+ public void getNoEdgesFromGraphTest() {
92
+ EdgesPipe edgesPipe = new EdgesPipe();
93
+ edgesPipe.setStarts(this.graphs);
94
+
95
+ Collection<Edge> edges = new ArrayList<Edge>();
96
+
97
+ while (edgesPipe.hasNext()) {
98
+ edges.add(edgesPipe.next());
99
+ }
100
+
101
+ assertEquals(0, edges.size());
102
+ }
103
+ }
@@ -0,0 +1,66 @@
1
+ package com.xnlogic.pacer.pipes;
2
+
3
+ import static org.junit.Assert.*;
4
+ import org.junit.Test;
5
+ import java.util.Arrays;
6
+ import java.util.ArrayList;
7
+ import com.tinkerpop.pipes.Pipe;
8
+ import com.tinkerpop.pipes.IdentityPipe;
9
+ import com.tinkerpop.pipes.AbstractPipe;
10
+ import java.util.Iterator;
11
+ import com.xnlogic.pacer.pipes.ExpandablePipe;
12
+
13
+ public class ExpandablePipeTest {
14
+
15
+ @Test
16
+ public void queueWithElementsTest() {
17
+ ExpandablePipe expandablePipe = new ExpandablePipe();
18
+
19
+ ArrayList input = new ArrayList();
20
+ input.add("X");
21
+
22
+ expandablePipe.setStarts(input.iterator());
23
+
24
+ expandablePipe.add("a", 1, new ArrayList());
25
+ expandablePipe.add("b", 2, new ArrayList());
26
+ expandablePipe.add("c", 3, new ArrayList());
27
+
28
+ Object result = expandablePipe.next();
29
+ assertTrue(result.equals("a"));
30
+ assertTrue(expandablePipe.getMetadata().equals(1));
31
+
32
+ result = expandablePipe.next();
33
+ assertTrue(result.equals("b"));
34
+ assertTrue(expandablePipe.getMetadata().equals(2));
35
+
36
+ result = expandablePipe.next();
37
+ assertTrue(result.equals("c"));
38
+ assertTrue(expandablePipe.getMetadata().equals(3));
39
+
40
+ result = expandablePipe.next();
41
+ assertTrue(result.equals("X"));
42
+ assertNull(expandablePipe.getMetadata());
43
+ }
44
+
45
+ @Test
46
+ public void emptyQueueTest() {
47
+ // TODO: fix this test
48
+
49
+ //ExpandablePipe expandablePipe = new ExpandablePipe();
50
+
51
+ //IdentityPipe<Pipe> pipe1 = new IdentityPipe<Pipe>();
52
+ //DeadPipe pipe2 = new DeadPipe();
53
+
54
+ //pipe1.enablePath(true);
55
+
56
+ //pipe1.setStarts(pipe2);
57
+ //expandablePipe.setStarts(pipe1);
58
+ //
59
+ //Pipe p = expandablePipe.next();
60
+ //assertTrue(pipe2.equals(p));
61
+ //assertNull(expandablePipe.getMetadata());
62
+ }
63
+
64
+ // TODO: Test getPathToHere()
65
+
66
+ }
@@ -0,0 +1,85 @@
1
+ package com.xnlogic.pacer.pipes;
2
+
3
+ import static org.junit.Assert.*;
4
+ import org.junit.Test;
5
+ import org.junit.Before;
6
+ import org.junit.After;
7
+ import com.tinkerpop.blueprints.Contains;
8
+ import com.tinkerpop.blueprints.Vertex;
9
+ import com.tinkerpop.blueprints.impls.tg.TinkerGraph;
10
+ import java.util.Arrays;
11
+ import java.util.NoSuchElementException;
12
+ import com.xnlogic.pacer.pipes.IdCollectionFilterPipe;
13
+
14
+ public class IdCollectionFilterPipeTest {
15
+ private TinkerGraph graph = null;
16
+
17
+ @Before
18
+ public void setup() throws Exception {
19
+ this.graph = new TinkerGraph();
20
+ }
21
+
22
+ @After
23
+ public void teardown() throws Exception {
24
+ this.graph.shutdown();
25
+ this.graph = null;
26
+ }
27
+
28
+ @Test
29
+ public void containsInTest() {
30
+ IdCollectionFilterPipe<Vertex> idCollectionFilterPipe =
31
+ new IdCollectionFilterPipe<Vertex>(Arrays.asList("1", "2", "3", "4"), Contains.IN);
32
+
33
+ Vertex v1 = this.graph.addVertex("1");
34
+ Vertex v2 = this.graph.addVertex("2");
35
+ Vertex v3 = this.graph.addVertex("5");
36
+
37
+ idCollectionFilterPipe.setStarts(Arrays.asList(v1, v2, v3));
38
+
39
+ Vertex v = idCollectionFilterPipe.next();
40
+ assertTrue(v.getId().equals("1"));
41
+
42
+ v = idCollectionFilterPipe.next();
43
+ assertTrue(v.getId().equals("2"));
44
+
45
+ boolean hasEx = false;
46
+
47
+ try {
48
+ v = idCollectionFilterPipe.next();
49
+ } catch (NoSuchElementException nsee) {
50
+ hasEx = true;
51
+ }
52
+
53
+ assertTrue(hasEx);
54
+ }
55
+
56
+ @Test
57
+ public void containsNotInTest() {
58
+ IdCollectionFilterPipe<Vertex> idCollectionFilterPipe =
59
+ new IdCollectionFilterPipe<Vertex>(Arrays.asList("1", "2", "3", "4"), Contains.NOT_IN);
60
+
61
+ Vertex v1 = this.graph.addVertex("7");
62
+ Vertex v2 = this.graph.addVertex("8");
63
+ Vertex v3 = this.graph.addVertex("1");
64
+
65
+ idCollectionFilterPipe.setStarts(Arrays.asList(v1, v2, v3));
66
+
67
+ Vertex v = idCollectionFilterPipe.next();
68
+ assertTrue(v.getId().equals("7"));
69
+
70
+ v = idCollectionFilterPipe.next();
71
+ assertTrue(v.getId().equals("8"));
72
+
73
+ boolean hasEx = false;
74
+
75
+ try {
76
+ v = idCollectionFilterPipe.next();
77
+ } catch (NoSuchElementException nsee) {
78
+ hasEx = true;
79
+ }
80
+
81
+ assertTrue(hasEx);
82
+ }
83
+
84
+ // TODO: Lookup "Contains" and see if there are more than just the two values in the enum.
85
+ }
@@ -0,0 +1,62 @@
1
+ package com.xnlogic.pacer.pipes;
2
+
3
+ import static org.junit.Assert.*;
4
+ import org.junit.Test;
5
+ import java.util.Collection;
6
+ import java.util.Arrays;
7
+ import com.xnlogic.pacer.pipes.IsUniquePipe;
8
+
9
+ public class IsUniquePipeTest {
10
+
11
+ @Test
12
+ public void allUniqueTest() {
13
+ Collection<String> collection = Arrays.asList("These", "are", "all", "unique");
14
+ IsUniquePipe<String> isUniquePipe = new IsUniquePipe<String>();
15
+
16
+ isUniquePipe.setStarts(collection);
17
+
18
+ String s = isUniquePipe.next();
19
+ assertTrue(s.equals("These"));
20
+ assertTrue(isUniquePipe.isUnique());
21
+
22
+ s = isUniquePipe.next();
23
+ assertTrue(s.equals("are"));
24
+ assertTrue(isUniquePipe.isUnique());
25
+
26
+ s = isUniquePipe.next();
27
+ assertTrue(s.equals("all"));
28
+ assertTrue(isUniquePipe.isUnique());
29
+
30
+ s = isUniquePipe.next();
31
+ assertTrue(s.equals("unique"));
32
+ assertTrue(isUniquePipe.isUnique());
33
+ }
34
+
35
+ @Test
36
+ public void notAllUniqueTest() {
37
+ Collection<String> collection = Arrays.asList("Not", "all", "all", "all", "unique");
38
+ IsUniquePipe<String> isUniquePipe = new IsUniquePipe<String>();
39
+
40
+ isUniquePipe.setStarts(collection);
41
+
42
+ String s = isUniquePipe.next();
43
+ assertTrue(s.equals("Not"));
44
+ assertTrue(isUniquePipe.isUnique());
45
+
46
+ s = isUniquePipe.next();
47
+ assertTrue(s.equals("all"));
48
+ assertTrue(isUniquePipe.isUnique());
49
+
50
+ s = isUniquePipe.next();
51
+ assertTrue(s.equals("all"));
52
+ assertFalse(isUniquePipe.isUnique());
53
+
54
+ s = isUniquePipe.next();
55
+ assertTrue(s.equals("all"));
56
+ assertFalse(isUniquePipe.isUnique());
57
+
58
+ s = isUniquePipe.next();
59
+ assertTrue(s.equals("unique"));
60
+ assertFalse(isUniquePipe.isUnique());
61
+ }
62
+ }
@@ -0,0 +1,97 @@
1
+ package com.xnlogic.pacer.pipes;
2
+
3
+ import static org.junit.Assert.*;
4
+ import org.junit.Test;
5
+ import org.junit.Before;
6
+ import org.junit.After;
7
+ import com.tinkerpop.blueprints.impls.tg.TinkerGraph;
8
+ import com.tinkerpop.blueprints.Vertex;
9
+ import com.tinkerpop.blueprints.Edge;
10
+ import java.util.Collection;
11
+ import java.util.Arrays;
12
+ import java.util.HashSet;
13
+ import java.util.NoSuchElementException;
14
+ import com.xnlogic.pacer.pipes.LabelCollectionFilterPipe;
15
+
16
+ public class LabelCollectionFilterPipeTest {
17
+ private TinkerGraph graph;
18
+ private Collection<Edge> edges;
19
+
20
+ @Before
21
+ public void setup() throws Exception {
22
+ this.graph = new TinkerGraph();
23
+ }
24
+
25
+ @After
26
+ public void teardown() throws Exception {
27
+ this.graph.shutdown();
28
+ this.graph = null;
29
+ }
30
+
31
+ private void createEdges() {
32
+ Vertex v1 = this.graph.addVertex(1);
33
+ Vertex v2 = this.graph.addVertex(2);
34
+ Vertex v3 = this.graph.addVertex(3);
35
+ Vertex v4 = this.graph.addVertex(4);
36
+
37
+ Edge e1 = this.graph.addEdge("E1", v1, v2, "edge1");
38
+ Edge e2 = this.graph.addEdge("E2", v2, v1, "edge2");
39
+ Edge e3 = this.graph.addEdge("E3", v2, v3, "edge3");
40
+ Edge e4 = this.graph.addEdge("E4", v3, v4, "edge4");
41
+
42
+ this.edges = Arrays.asList(e1, e2, e3, e4);
43
+ }
44
+
45
+ @Test(expected=NoSuchElementException.class)
46
+ public void hasSomeMatchingEdgesTest() {
47
+ this.createEdges();
48
+ Collection<String> edgeLabels = Arrays.asList("edge2", "edge3");
49
+ LabelCollectionFilterPipe labelCollectionFilterPipe = new LabelCollectionFilterPipe(edgeLabels);
50
+
51
+ labelCollectionFilterPipe.setStarts(this.edges);
52
+ Edge e = labelCollectionFilterPipe.next();
53
+ assertEquals("E2", e.getId());
54
+
55
+ e = labelCollectionFilterPipe.next();
56
+ assertEquals("E3", e.getId());
57
+
58
+ labelCollectionFilterPipe.next();
59
+ }
60
+
61
+
62
+ @Test(expected=NoSuchElementException.class)
63
+ public void hasSomeMatchingEdgesWithSetTest() {
64
+ this.createEdges();
65
+ HashSet<String> edgeLabels = new HashSet<String>(Arrays.asList("edge2", "edge3"));
66
+ LabelCollectionFilterPipe labelCollectionFilterPipe = new LabelCollectionFilterPipe(edgeLabels);
67
+
68
+ labelCollectionFilterPipe.setStarts(this.edges);
69
+ Edge e = labelCollectionFilterPipe.next();
70
+ assertEquals("E2", e.getId());
71
+
72
+ e = labelCollectionFilterPipe.next();
73
+ assertEquals("E3", e.getId());
74
+
75
+ labelCollectionFilterPipe.next();
76
+ }
77
+
78
+ @Test(expected=NoSuchElementException.class)
79
+ public void hasNoMatchingEdgesTest() {
80
+ this.createEdges();
81
+ Collection<String> edgeLabels = Arrays.asList("edge5", "edge6");
82
+ LabelCollectionFilterPipe labelCollectionFilterPipe = new LabelCollectionFilterPipe(edgeLabels);
83
+
84
+ labelCollectionFilterPipe.setStarts(this.edges);
85
+ labelCollectionFilterPipe.next();
86
+ }
87
+
88
+
89
+ @Test(expected=NoSuchElementException.class)
90
+ public void noEdgesToMatchTest() {
91
+ this.createEdges();
92
+ LabelCollectionFilterPipe labelCollectionFilterPipe = new LabelCollectionFilterPipe(null);
93
+
94
+ labelCollectionFilterPipe.setStarts(this.edges);
95
+ labelCollectionFilterPipe.next();
96
+ }
97
+ }
@@ -0,0 +1,69 @@
1
+ package com.xnlogic.pacer.pipes;
2
+
3
+ import static org.junit.Assert.assertEquals;
4
+ import static org.junit.Assert.assertTrue;
5
+
6
+ import java.util.Arrays;
7
+ import java.util.Collection;
8
+ import java.util.NoSuchElementException;
9
+
10
+ import org.junit.After;
11
+ import org.junit.Before;
12
+ import org.junit.Test;
13
+
14
+ import com.tinkerpop.blueprints.Edge;
15
+ import com.tinkerpop.blueprints.Vertex;
16
+ import com.tinkerpop.blueprints.impls.tg.TinkerGraph;
17
+
18
+ public class LabelPrefixPipeTest {
19
+ private TinkerGraph graph;
20
+ private Collection<Edge> edges;
21
+
22
+ @Before
23
+ public void setup() throws Exception {
24
+ this.graph = new TinkerGraph();
25
+ }
26
+
27
+ @After
28
+ public void teardown() throws Exception {
29
+ this.graph.shutdown();
30
+ this.graph = null;
31
+ }
32
+
33
+ private void createEdges() {
34
+ Vertex v1 = this.graph.addVertex(1);
35
+ Vertex v2 = this.graph.addVertex(2);
36
+ Vertex v3 = this.graph.addVertex(3);
37
+ Vertex v4 = this.graph.addVertex(4);
38
+
39
+ Edge e1 = this.graph.addEdge("E1", v1, v2, "edge1");
40
+ Edge e2 = this.graph.addEdge("E2", v2, v1, "edge2");
41
+ Edge e3 = this.graph.addEdge("E3", v2, v3, "edge3");
42
+ Edge e4 = this.graph.addEdge("E4", v3, v4, "edge4");
43
+
44
+ this.edges = Arrays.asList(e1, e2, e3, e4);
45
+ }
46
+
47
+ @Test
48
+ public void hasLabelPrefixesTest() {
49
+ this.createEdges();
50
+ LabelPrefixPipe labelPrefixPipe = new LabelPrefixPipe("edge[2-3]");
51
+
52
+ labelPrefixPipe.setStarts(this.edges);
53
+ Edge e = labelPrefixPipe.next();
54
+ assertEquals("E2", e.getId());
55
+
56
+ e = labelPrefixPipe.next();
57
+ assertEquals("E3", e.getId());
58
+
59
+ boolean hasEx = false;
60
+
61
+ try {
62
+ e = labelPrefixPipe.next();
63
+ } catch (NoSuchElementException nsee) {
64
+ hasEx = true;
65
+ }
66
+
67
+ assertTrue(hasEx);
68
+ }
69
+ }
@@ -0,0 +1,17 @@
1
+ package com.xnlogic.pacer.pipes;
2
+
3
+ import java.util.ArrayList;
4
+ import java.util.NoSuchElementException;
5
+
6
+ import org.junit.Test;
7
+
8
+ public class NeverPipeTest {
9
+ @Test(expected=NoSuchElementException.class)
10
+ public void ensureExceptionTest() {
11
+ NeverPipe neverPipe = new NeverPipe();
12
+ ArrayList<Object> starts = new ArrayList<Object>();
13
+ starts.add(new Object());
14
+ neverPipe.setStarts(starts.iterator());
15
+ neverPipe.next();
16
+ }
17
+ }