@@ -3,12 +3,9 @@ package overflowdb.traversal
3
3
import org .scalatest .matchers .should .Matchers ._
4
4
import org .scalatest .wordspec .AnyWordSpec
5
5
import overflowdb ._
6
- import overflowdb .traversal .filter .P
7
6
import overflowdb .traversal .testdomains .simple .Thing .Properties .Name
8
7
import overflowdb .traversal .testdomains .simple .{Connection , ExampleGraphSetup , SimpleDomain , Thing , ThingTraversal }
9
-
10
8
import scala .collection .mutable
11
- import scala .jdk .CollectionConverters ._
12
9
13
10
class RepeatTraversalTests extends AnyWordSpec {
14
11
import ExampleGraphSetup ._
@@ -68,8 +65,8 @@ class RepeatTraversalTests extends AnyWordSpec {
68
65
69
66
" emit nodes that meet given condition" in {
70
67
val expectedResults = Set (" L1" , " L2" , " L3" )
71
- centerTrav.repeat(_.followedBy)(_.emit(_.name.filter(_.startsWith( " L" ) ))).name.toSetMutable shouldBe expectedResults
72
- centerTrav.repeat(_.followedBy)(_.emit(_.name.filter(_.startsWith( " L" ) )).breadthFirstSearch).name.toSetMutable shouldBe expectedResults
68
+ centerTrav.repeat(_.followedBy)(_.emit(_.nameStartsWith( " L" ))).name.toSetMutable shouldBe expectedResults
69
+ centerTrav.repeat(_.followedBy)(_.emit(_.nameStartsWith( " L" )).breadthFirstSearch).name.toSetMutable shouldBe expectedResults
73
70
centerTrav.repeat(_.out)(_.emit(_.has(Name .where(_.startsWith(" L" ))))).property(Name ).toSetMutable shouldBe expectedResults
74
71
centerTrav.repeat(_.out)(_.emit(_.has(Name .where(_.startsWith(" L" )))).breadthFirstSearch).property(Name ).toSetMutable shouldBe expectedResults
75
72
}
@@ -86,8 +83,8 @@ class RepeatTraversalTests extends AnyWordSpec {
86
83
" support arbitrary `until` condition" should {
87
84
" work without emit" in {
88
85
val expectedResults = Set (" L2" , " R2" )
89
- centerTrav.repeat(_.followedBy)(_.until(_.name.filter(_.endsWith( " 2" ) ))).name.toSetMutable shouldBe expectedResults
90
- centerTrav.repeat(_.followedBy)(_.until(_.name.filter(_.endsWith( " 2" ) )).breadthFirstSearch).name.toSetMutable shouldBe expectedResults
86
+ centerTrav.repeat(_.followedBy)(_.until(_.nameEndsWith( " 2" ))).name.toSetMutable shouldBe expectedResults
87
+ centerTrav.repeat(_.followedBy)(_.until(_.nameEndsWith( " 2" )).breadthFirstSearch).name.toSetMutable shouldBe expectedResults
91
88
92
89
centerTrav.repeat(_.out)(
93
90
_.until(_.has(Name .where(_.matches(" .*2" )))))
@@ -100,16 +97,16 @@ class RepeatTraversalTests extends AnyWordSpec {
100
97
101
98
" work in combination with emit" in {
102
99
val expectedResults = Set (" Center" , " L1" , " L2" , " R1" , " R2" )
103
- centerTrav.repeat(_.followedBy)(_.until(_.name.filter(_.endsWith( " 2" ) )).emit).name.toSetMutable shouldBe expectedResults
104
- centerTrav.repeat(_.followedBy)(_.until(_.name.filter(_.endsWith( " 2" ) )).emit.breadthFirstSearch).name.toSetMutable shouldBe expectedResults
100
+ centerTrav.repeat(_.followedBy)(_.until(_.nameEndsWith( " 2" )).emit).name.toSetMutable shouldBe expectedResults
101
+ centerTrav.repeat(_.followedBy)(_.until(_.nameEndsWith( " 2" )).emit.breadthFirstSearch).name.toSetMutable shouldBe expectedResults
105
102
centerTrav.repeat(_.out)(_.until(_.has(Name .where(_.matches(" .*2" )))).emit).property(Name ).toSetMutable shouldBe expectedResults
106
103
centerTrav.repeat(_.out)(_.until(_.has(Name .where(_.matches(" .*2" )))).emit.breadthFirstSearch).property(Name ).toSetMutable shouldBe expectedResults
107
104
}
108
105
109
106
" result in 'repeat/until' behaviour, i.e. `until` condition is only evaluated after one iteration" in {
110
107
val expectedResults = Set (" L1" , " R1" )
111
- centerTrav.repeat(_.followedBy)(_.until(_.filter(_. label == Thing .Label ))).name.toSetMutable shouldBe expectedResults
112
- centerTrav.repeat(_.followedBy)(_.until(_.filter(_. label == Thing .Label )).breadthFirstSearch).name.toSetMutable shouldBe expectedResults
108
+ centerTrav.repeat(_.followedBy)(_.until(_.label( Thing .Label ))).name.toSetMutable shouldBe expectedResults
109
+ centerTrav.repeat(_.followedBy)(_.until(_.label( Thing .Label )).breadthFirstSearch).name.toSetMutable shouldBe expectedResults
113
110
centerTrav.repeat(_.out)(_.until(_.hasLabel(Thing .Label ))).property(Name ).toSetMutable shouldBe expectedResults
114
111
centerTrav.repeat(_.out)(_.until(_.hasLabel(Thing .Label )).breadthFirstSearch).property(Name ).toSetMutable shouldBe expectedResults
115
112
}
0 commit comments