trait ResultMatchers extends AnyRef
Extends a test suite with a set of matchers over validation com.wix.accord.Results.
- Self Type
- ResultMatchers with Suite
- Alphabetic
- By Inheritance
- ResultMatchers
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
case class
GroupViolationMatcher
(value: Any = null, constraint: String = null, legacyDescription: String = null, path: Path = null, violations: Set[(ResultMatchers.this)#ViolationMatcher] = null) extends (ResultMatchers.this)#ViolationMatcher with Product with Serializable
A matcher over com.wix.accord.GroupViolations.
A matcher over com.wix.accord.GroupViolations. To generate a violation rule "pattern", call the constructor with the required predicates, for example:
val firstNameNotEmpty = RuleViolationMatcher( path = Path( Generic( "firstName" ) ), constraint = "must not be empty" ) val lastNameNotEmpty = RuleViolationMatcher( path = Path( Generic( "lastName" ) ), constraint = "must not be empty" ) val orPredicateFailed = GroupViolationMatcher( constraint = "doesn't meet any of the requirements", violations = firstNameNotEmpty :: lastNameNotEmpty :: Nil ) val validationResult: Result = ... validationResult must failWith( orPredicateFailed )
- value
A predicate specifying the object under validation.
- constraint
A predicate specifying the constraint being violated.
- legacyDescription
Retained for backwards compatibility; matches against the rendered description of the object being validated. See com.wix.accord.Descriptions.render for details of how descriptions are rendered into strings.
- path
A predicate specifying the path of the object being validated.
- violations
The set of violations that comprise the group being validated.
- See also
com.wix.accord.GroupViolation
-
case class
ResultMatcher
(expectedViolations: Set[(ResultMatchers.this)#ViolationMatcher]) extends Matcher[Result] with Product with Serializable
A matcher over validation com.wix.accord.Results.
A matcher over validation com.wix.accord.Results. Takes a set of expected violations and return a suitable match result in case of failure.
- expectedViolations
The set of expected violations for this matcher.
-
case class
RuleViolationMatcher
(value: Any = null, constraint: String = null, legacyDescription: String = null, path: Path = null) extends (ResultMatchers.this)#ViolationMatcher with Product with Serializable
A matcher over com.wix.accord.RuleViolations.
A matcher over com.wix.accord.RuleViolations. To generate a violation rule "pattern", call the constructor with the required predicates, for example:
val firstNameNotEmpty = RuleViolationMatcher( description = Path( Generic( "firstName" ) ), constraint = "must not be empty" ) val validationResult: Result = ... validationResult must failWith( firstNameNotEmpty )
- value
A predicate specifying the object under validation.
- constraint
A predicate specifying the constraint being violated.
- legacyDescription
Retained for backwards compatibility; matches against the rendered description of the object being validated. See com.wix.accord.Descriptions.render for details of how descriptions are rendered into strings.
- path
A predicate specifying the path to the object being validated.
- See also
com.wix.accord.RuleViolation
-
sealed
trait
ViolationMatcher
extends Matcher[Violation]
Abstracts over validators for the various violation type.
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
val
aFailure: BeMatcher[Result]
Enables syntax like
someResult should be( aFailure )
-
val
aSuccess: BeMatcher[Result]
Enables syntax like
someResult should be( aSuccess )
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
failWith(expectedViolations: (ResultMatchers.this)#ViolationMatcher*): Matcher[Result]
A convenience method for matching failures.
A convenience method for matching failures. Enables syntax like:
val result: Result = ... result should failWith( Path( Generic( "firstName" ) ) -> "must not be empty", Path( Generic( "lastName" ) ) -> "must not be empty" )
- expectedViolations
The set of expected violations.
- returns
A matcher over validation com.wix.accord.Results.
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
group[T](path: Path, constraint: String, expectedViolations: T*)(implicit ev: (T) ⇒ (ResultMatchers.this)#RuleViolationMatcher): (ResultMatchers.this)#GroupViolationMatcher
A convenience method for matching violation groups.
A convenience method for matching violation groups. Enables syntax like:
val result: Result = ... result should failWith( group( Path( Generic( "teacher" ) ), "is invalid", // The group context Path( Generic( "firstName ) ) -> "must not be empty" ) ) // The rule violations
- path
A predicate specifying the path to the object being validated.
- constraint
A textual description of the constraint being violated (for example, "must not be empty").
- expectedViolations
The set of expected violations that comprise the group.
- returns
A matcher over com.wix.accord.GroupViolations.
-
def
group(path: Path, constraint: String, expectedViolations: (Path, String)*): (ResultMatchers.this)#GroupViolationMatcher
A convenience method for matching violation groups.
A convenience method for matching violation groups. Enables syntax like:
val result: Result = ... result should failWith( group( Path( Generic( "teacher" ) ), "is invalid", // The group context Path( Generic( "firstName ) ) -> "must not be empty" ) ) // The rule violations
- path
A predicate specifying the path to the object being validated.
- constraint
A textual description of the constraint being violated (for example, "must not be empty").
- expectedViolations
The set of expected violations that comprise the group.
- returns
A matcher over com.wix.accord.GroupViolations.
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
implicit
def
path2RuleViolationMatcher(path: Path): (ResultMatchers.this)#RuleViolationMatcher
A convenience implicit to simplify test code.
A convenience implicit to simplify test code. Enables syntax like:
val rule: RuleViolationMatcher = Path( Generic( "firstName" ) ) // ... which is equivalent to val rule = RuleViolationMatcher( path = Path( Generic( "firstName" ) ) )
-
implicit
def
pathAndConstraintTuple2RuleMatcher(v: (Path, String)): (ResultMatchers.this)#RuleViolationMatcher
A convenience implicit to simplify test code.
A convenience implicit to simplify test code. Enables syntax like:
val rule: RuleViolationMatcher = Path( Generic( "firstName" ) ) -> "must not be empty" // ... which is equivalent to val rule = RuleViolationMatcher( path = Path( Generic( "firstName" ) ), constraint = "must not be empty" )
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
Deprecated Value Members
-
implicit
def
description2RuleViolationMatcher(desc: Description): (ResultMatchers.this)#RuleViolationMatcher
A convenience implicit to simplify test code.
A convenience implicit to simplify test code. Enables syntax like:
val rule: RuleViolationMatcher = Generic( "firstName" ) // ... which is equivalent to val rule = RuleViolationMatcher( path = Path( Generic( "firstName" ) ) )
- Annotations
- @deprecated
- Deprecated
(Since version 0.7)
-
implicit
def
descriptionAndConstraintTuple2RuleMatcher(v: (Description, String)): (ResultMatchers.this)#RuleViolationMatcher
A convenience implicit to simplify test code.
A convenience implicit to simplify test code. Enables syntax like:
val rule: RuleViolationMatcher = Generic( "firstName" ) -> "must not be empty" // ... which is equivalent to val rule = RuleViolationMatcher( path = Path( Generic( "firstName" ) ), constraint = "must not be empty" )
- Annotations
- @deprecated
- Deprecated
(Since version 0.7)
-
def
group[T](legacyDescription: String, constraint: String, expectedViolations: T*)(implicit ev: (T) ⇒ (ResultMatchers.this)#RuleViolationMatcher): (ResultMatchers.this)#GroupViolationMatcher
A convenience method for matching violation groups.
A convenience method for matching violation groups. Enables syntax like:
val result: Result = ... result should failWith( group( "teacher", "is invalid", // The group context "firstName" -> "must not be empty" ) ) // The rule violations
- legacyDescription
Retained for backwards compatibility; matches against the rendered description of the object being validated. See com.wix.accord.Descriptions.render for details of how descriptions are rendered into strings.
- constraint
A textual description of the constraint being violated (for example, "must not be empty").
- expectedViolations
The set of expected violations that comprise the group.
- returns
A matcher over com.wix.accord.GroupViolations.
- Annotations
- @deprecated
- Deprecated
(Since version 0.6) Intended for backwards compatibility. It is recommended to match against paths instead.
-
def
group(legacyDescription: String, constraint: String, expectedViolations: (String, String)*): (ResultMatchers.this)#GroupViolationMatcher
A convenience method for matching violation groups.
A convenience method for matching violation groups. Enables syntax like:
val result: Result = ... result should failWith( group( "teacher", "is invalid", // The group context "firstName" -> "must not be empty" ) ) // The rule violations
- legacyDescription
Retained for backwards compatibility; matches against the rendered description of the object being validated. See com.wix.accord.Descriptions.render for details of how descriptions are rendered into strings.
- constraint
A textual description of the constraint being violated (for example, "must not be empty").
- expectedViolations
The set of expected violations that comprise the group.
- returns
A matcher over com.wix.accord.GroupViolations.
- Annotations
- @deprecated
- Deprecated
(Since version 0.6) Intended for backwards compatibility. It is recommended to match against paths instead.
-
implicit
def
stringTuple2RuleMatcher(v: (String, String)): (ResultMatchers.this)#RuleViolationMatcher
A convenience implicit to simplify test code.
A convenience implicit to simplify test code. Enables syntax like:
val rule: RuleViolationMatcher = "firstName" -> "must not be empty" // ... which is equivalent to val rule = RuleViolationMatcher( legacyDescription = "firstName", constraint = "must not be empty" )
- Annotations
- @deprecated
- Deprecated
(Since version 0.6)