Package org.approvej
Class ApprovalBuilder<T>
java.lang.Object
org.approvej.ApprovalBuilder<T>
- Type Parameters:
T
- the type of the value to approve
A builder to configure an approval for a given value.
Optionally the value can be "scrubbed" of dynamic data (like timestamps or ID's).
The value will be printed (converted to String
) using a Printer
. By default,
the ObjectPrinter
will be applied, which can be changed with the
printWith(Function)
.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> ApprovalBuilder
<T> approve
(T originalValue) Creates a new builder for the given value.scrubbedOf
(UnaryOperator<T> scrubber) Applies the given scrubber to the currentvalue
.void
verify()
Uses the DEFAULT_VERIFIER to approve the printedvalue
.void
Verifies that the given previouslyApproved value equals thevalue
using anInplaceVerifier
.void
-
Field Details
-
DEFAULT_PRINTER
The defaultPrinter
used to print the value.
-
-
Method Details
-
approve
Creates a new builder for the given value.- Type Parameters:
T
- the type of the value to approve- Parameters:
originalValue
- the value to approve- Returns:
- a new
ApprovalBuilder
for the given value
-
printWith
-
printWith
- Parameters:
printer
- the printer used to convert the value to aString
- Returns:
- this
-
scrubbedOf
Applies the given scrubber to the currentvalue
.- Parameters:
scrubber
- theUnaryOperator
orScrubber
- Returns:
- this
-
verify
- Parameters:
verifier
- theConsumer
orVerifier
- Throws:
ApprovalError
- if the verification fails
-
verify
Verifies that the given previouslyApproved value equals thevalue
using anInplaceVerifier
.- Parameters:
previouslyApproved
- the approved value
-
verify
public void verify()Uses the DEFAULT_VERIFIER to approve the printedvalue
.- Throws:
ApprovalError
- if the verification fails
-