Skip to content

Commit

Permalink
Add unit tests for And.collectRulingTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
kwahlin committed Dec 19, 2024
1 parent 950d595 commit 0329c0c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package whelk.search2.querytree

import spock.lang.Specification

import static DummyNodes.and
import static DummyNodes.or

Expand All @@ -13,6 +12,8 @@ import static DummyNodes.pathV5
import static DummyNodes.orXY
import static DummyNodes.andXY
import static DummyNodes.andXYZ
import static DummyNodes.type1
import static DummyNodes.type2

class AndSpec extends Specification {
def "contains"() {
Expand Down Expand Up @@ -74,4 +75,17 @@ class AndSpec extends Specification {
and([orXY, pathV3]) | orXY | andXY | and([pathV3, pathV1, pathV2])
and([orXY, pathV4, pathV5, pathV3]) | pathV4 | and([pathV1, pathV3]) | and([orXY, pathV5, pathV3, pathV1])
}

def "collect ruling types"() {
expect:
and.collectRulingTypes() == result

where:
and | result
and([type1, pathV1]) | ["T1"]
and([type1, type2, pathV1]) | ["T1", "T2"]
and([pathV1, pathV2]) | []
and([or([type1, type2]), pathV1]) | ["T1", "T2"]
and([or([type1, pathV1]), or([type2, pathV2])]) | []
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class DummyNodes {

static def ft1 = new FreeText(Operator.EQUALS, 'ft1')

static def type1 = new PropertyValue(new Property("rdf:type"), Operator.EQUALS, new VocabTerm("T1"))
static def type2 = new PropertyValue(new Property("rdf:type"), Operator.EQUALS, new VocabTerm("T2"))

static def ft(String s) {
return new FreeText(eq, s)
}
Expand Down

0 comments on commit 0329c0c

Please sign in to comment.