Skip to content

Commit

Permalink
fixed issue for BrokenCrossReferencesChecker
Browse files Browse the repository at this point in the history
  • Loading branch information
gernotstarke committed Dec 26, 2014
1 parent a75ad54 commit 4a797d9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,15 @@ class BrokenCrossReferencesChecker extends Checker {
if (!listOfIds.contains( linkTarget )) {

// we found a broken link!
String findingText = "link target \"$linkTarget\" missing"

// now count occurrences - how often is it referenced
int nrOfReferences = hrefList.findAll{ it == href }.size()
if (nrOfReferences > 1) {
findingText += ", reference count: $nrOfReferences"
}

String findingText = "link target \"$linkTarget\" missing (reference count $nrOfReferences)"

checkingResults.newFinding(findingText)
checkingResults.newFinding(findingText, nrOfReferences)
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class BrokenCrossReferencesCheckerTest extends GroovyTestCase {
assertEquals( "expected two checks", 2, collector.nrOfItemsChecked)

String actual = collector.findings.first()
String expected = "link target \"nonexisting\" missing (reference count 1)"
String expected = "link target \"nonexisting\" missing"
String message = "expected $expected"

assertEquals(message, expected, actual)
Expand Down Expand Up @@ -122,14 +122,14 @@ class BrokenCrossReferencesCheckerTest extends GroovyTestCase {

// first finding: aim42 link missing
String actual = collector.findings.first()
String expected = "link target \"arc42\" missing (reference count 1)"
String expected = "link target \"arc42\" missing"
String message = "expected $expected"

assertEquals(message, expected, actual)

// second finding: arc42 link missing
actual = collector.findings[1]
expected = "link target \"aim42\" missing (reference count 1)"
expected = "link target \"aim42\" missing"
assertEquals(message, expected, actual)
}

Expand All @@ -152,12 +152,12 @@ class BrokenCrossReferencesCheckerTest extends GroovyTestCase {

collector = undefinedInternalLinksChecker.performCheck()

assertEquals( "expected one finding", 1, collector.nrOfProblems())
assertEquals( "expected five findings", 5, collector.nrOfProblems())
assertEquals( "expected one check", 1, collector.nrOfItemsChecked)

// finding: aim42 link missing, reference count 5
String actual = collector.findings.first()
String expected = "link target \"aim42\" missing (reference count 5)"
String expected = "link target \"aim42\" missing, reference count: 5"
String message = "expected $expected"

assertEquals(message, expected, actual)
Expand Down

0 comments on commit 4a797d9

Please sign in to comment.