-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…ion and GroupViolation
- Loading branch information
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.wix.accord | ||
|
||
import com.wix.accord.Descriptions.Generic | ||
import org.scalatest.{FlatSpec, Matchers} | ||
|
||
/** | ||
* Created by grenville on 9/6/16. | ||
*/ | ||
class ViolationSpec extends FlatSpec with Matchers { | ||
|
||
val subSampleRule = RuleViolation("value", "is null", Generic("subSampleRule")) | ||
val subSampleGroup = GroupViolation("subgroup", "is not valid", | ||
children = Set(subSampleRule), Generic("request")) | ||
val sampleRule1 = RuleViolation("value", "is null", Generic("sampleRule1")) | ||
val sampleRule2 = RuleViolation("value", "is null", Generic("sampleRule2")) | ||
val sampleGroup = GroupViolation("group", "is not valid", | ||
children = Set(sampleRule1, sampleRule2, subSampleGroup), Generic("request")) | ||
|
||
"Violation" should "produce a string representation for a RuleViolation" in { | ||
sampleRule1.toString shouldEqual "sampleRule1 is null" | ||
} | ||
|
||
it should "produce a string representation for a GroupViolation" in { | ||
sampleGroup.toString shouldEqual "request is not valid: Set(sampleRule1 is null, sampleRule2 is null, " + | ||
"subgroup is not valid: Set(subSampleRule is null))" | ||
} | ||
} |