Skip to content
This repository has been archived by the owner on Apr 12, 2019. It is now read-only.

Commit

Permalink
Merge pull request #190 from open-prevo/demoInterationTestsXlsxAssert…
Browse files Browse the repository at this point in the history
…ions

assert sheet line count
  • Loading branch information
mikaelkalt authored Jul 27, 2018
2 parents a13a6c4 + 73bfce3 commit 0fe3969
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -188,22 +188,34 @@ dockerCompose {

composeUp.dependsOn { tasks.docker }

def assertSheetRowCounts(File xlsxFile, def rowCounts) {
def xlsx = new java.util.zip.ZipFile(xlsxFile)
[rowCounts.terminations, rowCounts.commencements].eachWithIndex { rowCount, index ->
def sheetNr = index+1
def sheet = new XmlSlurper().parse(xlsx.getInputStream(xlsx.getEntry("xl/worksheets/sheet${sheetNr}.xml")))
def actual = sheet.sheetData.row.size()
assert rowCount == actual : "${xlsxFile}.sheet${sheetNr}.rowCount expected to be $rowCount but was $actual"
}
}

task integrationTest {
dependsOn composeUp
doLast {
// wait till the matching runs through
sleep(30000)
sleep(40000)

//assert that all nodes are notified with the expected amount of matches
assert 1 == new File("${buildDir}/demo/NodeBaloiseExcel").listFiles().findAll {
it.name.startsWith("retirement-fund-out-data")
}.size()
assert 1 == new File("${buildDir}/demo/NodeHelvetiaExcel").listFiles().findAll {
it.name.startsWith("retirement-fund-out-data")
}.size()
assert 1 == new File("${buildDir}/demo/NodeZurichExcel").listFiles().findAll {
it.name.startsWith("retirement-fund-out-data")
}.size()
def expectedMatchesPerNode = [
NodeBaloiseExcel : [terminations: 7, commencements: 5],
NodeHelvetiaExcel : [terminations: 9, commencements: 11],
NodeZurichExcel : [terminations: 5, commencements: 5]
]

expectedMatchesPerNode.each { folder , counts ->
FileFilter matchingOutputFile = { f -> f.name.startsWith("retirement-fund-out-data") }
File outputFile = new File("${buildDir}/demo/$folder").listFiles(matchingOutputFile).find()
assertSheetRowCounts(outputFile, counts)
}
}
}

Expand Down

0 comments on commit 0fe3969

Please sign in to comment.