diff --git a/librisworks/build.gradle b/librisworks/build.gradle index 19e68e2b54..f2e49e9cf1 100644 --- a/librisworks/build.gradle +++ b/librisworks/build.gradle @@ -5,6 +5,9 @@ sourceSets { scripts { groovy { srcDir 'scripts' } } + test { + groovy { srcDir 'src/test/groovy/' } + } } repositories { @@ -13,10 +16,16 @@ repositories { dependencies { implementation project(':whelktool') + testImplementation project(':whelk-core') compileOnly "org.codehaus.groovy:groovy:${groovyVersion}" compileOnly project(':whelk-core') scriptsCompileOnly sourceSets.main.output scriptsCompileOnly project(':whelk-core') + testImplementation "org.spockframework:spock-core:${spockVersion}" +} + +test { + useJUnitPlatform() } jar { diff --git a/librisworks/src/test/groovy/se/kb/libris/mergeworks/compare/ClassificationSpec.groovy b/librisworks/src/test/groovy/se/kb/libris/mergeworks/compare/ClassificationSpec.groovy new file mode 100644 index 0000000000..8bf21f3cfe --- /dev/null +++ b/librisworks/src/test/groovy/se/kb/libris/mergeworks/compare/ClassificationSpec.groovy @@ -0,0 +1,22 @@ +package se.kb.libris.mergeworks.compare + +import spock.lang.Specification + +class ClassificationSpec extends Specification { + def "merge SAB codes"() { + expect: + Classification.tryMergeSabCodes(a, b) == result + + where: + a || b || result + 'H' || 'H' || 'H' + 'Haaa' || 'H' || 'Haaa' + 'Hcqaa' || 'Hcbqbbb' || 'Hcqaa' + 'Hcb' || 'Hc' || null + 'Hci' || 'Hci,u' || 'Hci,u' + 'Hcd.016' || 'Hcd.01' || 'Hcd.016' + 'Hc.01' || 'Hcd.01' || 'Hcd.01' + 'Hda.017=c' || 'Hda.018' || 'Hda.017=c' + 'He' || 'Hc' || null + } +}