Skip to content

Commit

Permalink
Add CXZ testing framework.
Browse files Browse the repository at this point in the history
  • Loading branch information
jannistsiroyannis committed Nov 20, 2023
1 parent d60ebb8 commit 6650512
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 2 deletions.
12 changes: 12 additions & 0 deletions housekeeping/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,20 @@ dependencies {
// Cron
implementation group: 'it.sauronsoftware.cron4j', name: 'cron4j', version: '2.2.5'

// Testing
testImplementation "org.spockframework:spock-core:${spockVersion}"
}

test {
useJUnitPlatform()
}

test.testLogging {
showStandardStreams = true
exceptionFormat = "full"
}


gretty {
jvmArgs = ['-XX:+UseParallelGC']
systemProperties = ['xl.secret.properties': System.getProperty("xl.secret.properties")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class InquirySender extends HouseKeeper {
connection = whelk.getStorage().getOuterConnection()
connection.setAutoCommit(false)
try {
String sql = "SELECT modified, data FROM lddb WHERE data#>>'{@graph,1,@type}' IN ('InquiryAction', 'ChangeNotice') AND modified > ?;"
String sql = "SELECT modified, data FROM lddb WHERE deleted = false AND data#>>'{@graph,1,@type}' IN ('InquiryAction', 'ChangeNotice') AND modified > ?;"
connection.setAutoCommit(false)
statement = connection.prepareStatement(sql)
statement.setTimestamp(1, from)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class NotificationGenerator extends HouseKeeper {
connection.setAutoCommit(false)
try {
// Fetch all changed IDs within the interval
String sql = "SELECT id, ARRAY_AGG(data#>>'{@graph,0,hasChangeNote}') as changeNotes FROM lddb__versions WHERE collection IN ('bib', 'auth') AND ( modified > ? AND modified <= ? ) group by id;"
String sql = "SELECT id, ARRAY_AGG(data#>>'{@graph,0,hasChangeNote}') as changeNotes FROM lddb__versions WHERE collection IN ('bib', 'auth') AND deleted = false AND ( modified > ? AND modified <= ? ) group by id;"
connection.setAutoCommit(false)
statement = connection.prepareStatement(sql)
statement.setTimestamp(1, from)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package whelk.housekeeping

import spock.lang.Specification
import whelk.Document

class NotificationRulesSpec extends Specification {

def "Change PrimaryContribution familyName"() {
given:
Document framedBefore = new Document([
"mainEntity" : [
"instanceOf" : [
"contribution" : [
[
"@type" : "PrimaryContribution",
"agent" : [
"familyName": "aaa",
"givenName": "bbb",
"lifeSpan": "2022-2023"
]
]
]
]
]
])
Document framedAfter = new Document([
"mainEntity" : [
"instanceOf" : [
"contribution" : [
[
"@type" : "PrimaryContribution",
"agent" : [
"familyName": "aab",
"givenName": "bbb",
"lifeSpan": "2022-2023"
]
]
]
]
]
])
Tuple result = NotificationRules.primaryContributionChanged(framedBefore, framedAfter)

expect:
result[0] == true
}

def "Change PrimaryContribution givenName"() {
given:
Document framedBefore = new Document([
"mainEntity" : [
"instanceOf" : [
"contribution" : [
[
"@type" : "PrimaryContribution",
"agent" : [
"familyName": "aaa",
"givenName": "bbb",
"lifeSpan": "2022-2023"
]
]
]
]
]
])
Document framedAfter = new Document([
"mainEntity" : [
"instanceOf" : [
"contribution" : [
[
"@type" : "PrimaryContribution",
"agent" : [
"familyName": "aaa",
"givenName": "bbc",
"lifeSpan": "2022-2023"
]
]
]
]
]
])
Tuple result = NotificationRules.primaryContributionChanged(framedBefore, framedAfter)

expect:
result[0] == true
}
}

0 comments on commit 6650512

Please sign in to comment.