public final class BasicChecks extends Object
| Modifier and Type | Method and Description |
|---|---|
static Check<Object> |
a(Class<?> expectedClass)
Alias of `instanceOf` which may be more readable in some context.
|
static <D> Check<D> |
allOf(Check<? super D>... operands)
General AND operator of multiple checks.
|
static <D> Check<D> |
allOf(Iterable<Check<? super D>> operands)
General AND operator of multiple checks.
|
static Check<Object> |
an(Class<?> expectedClass)
Alias of `instanceOf` which may be more readable in some context.
|
static <D> Check<D> |
anyOf(Check<? super D>... operands)
General OR operator of multiple checks.
|
static <D> Check<D> |
anyOf(Iterable<Check<? super D>> operands)
General OR operator of multiple checks.
|
static Check<Object> |
anything()
Check, that doesn't care of the tested value, and always returns true.
|
static <V> TransformationBuilder<V,Check<V>> |
as(Class<V> type)
Fluent builder of a check, that will assure, that provided object is instance of required class, and if yes,
it will cast it to that class, and apply provided check on the required type.
|
static <D,V> Check<D> |
compose(String name,
Transformation<? super D,V> transformation,
Check<? super V> check)
Convenient composition using transformation of the original object, and check on the result.
|
static <D,V> Check<D> |
compose(Transformation<? super D,V> transformation,
Check<? super V> check)
Simplified composition using transformation of the original object, and check on the result.
|
static <D> Check<D> |
createBuilder() |
static <D> Check<D> |
createBuilderWith(Check<D> check) |
static <D> Check<D> |
customResultFactory(Check<D> check,
ResultFactory customResultFactory) |
static <D> CheckBuilder<D> |
dsl() |
static <D> Check<D> |
equalTo(D expectedValue)
Create a check, that checks if the tested value is equal to expected value.
|
static <D,V> TransformationBuilder<V,Check<D>> |
has(String name,
Transformation<? super D,V> transformation) |
static <D,V> TransformationBuilder<V,Check<D>> |
has(Transformation<? super D,V> transformation) |
static <D> Check<D> |
check(Predicate<D> predicate,
String expectationDescription)
Build a custom check using it's description and pure Java predicate.
|
static Check<Object> |
instanceOf(Class<?> expectedClass)
Check, that tested data is instance of provided class (either the class itself or any subclass).
|
static <D> Check<D> |
is(D expectedValue)
Alias for `equalTo`, which may be more readable in some constructions.
|
static Check<Object> |
isA(Class<?> expectedClass)
Alias of `instanceOf` which may be more readable in some context.
|
static Check<Object> |
isAn(Class<?> expectedClass)
Alias of `instanceOf` which may be more readable in some context.
|
static Check<Object> |
isNotNull()
Check, if tested data is not null.
|
static Check<Object> |
isNull()
Check, if tested data is null.
|
static Check<Throwable> |
message(Check<? super String> check)
Check of exception (throwable) message.
|
static <D> Check<D> |
not(D positiveValue)
Check, that provided positive value isn't equal to checked data.
|
static <D> Check<D> |
not(Check<D> positiveCheck)
Check, that provided positive check doesn't match checked data.
|
static <D,V> TransformationBuilder<V,Check<D>> |
nullableHas(String name,
Transformation<? super D,V> transformation) |
static <D,V> TransformationBuilder<V,Check<D>> |
nullableHas(Transformation<? super D,V> transformation) |
static <D> Check<D> |
nullableCheck(Predicate<D> predicate,
String expectationDescription)
Define a transparent check using provided predicate and string expectation description.
|
static <D> Check<D> |
oneOf(Collection<D> alternatives)
Create matcher, that matches, if tested object meets one of provided alternatives (or).
|
static <D> Check<D> |
oneOf(D... alternatives)
Create matcher, that matches, if tested object meets one of provided alternatives (or).
|
static <D> Check<D> |
require(Check<? super D> requirement,
Check<? super D> check)
Require, that tested data meet provided requirement before application of a check.
|
static <D> Check<D> |
requireNotNull(Check<D> check)
Require, that tested value is not null, before application of the provided check on it.
|
static Check<Object> |
sameClass(Class<?> expectedClass)
Check, that tested data is exactly of the provided type, but not any subcalss of it.
|
static <D> Check<D> |
sameInstance(D expectedInstance)
Create a check, that checks if the tested value is exactly the same instance as expected.
|
static <D> Check<D> |
softCheck(Check<D> check) |
static ThrowingCheck |
throwing(Class<? extends Throwable> expectedType)
Check of a code, which should throw an exception (throwable) of expected type.
|
static ThrowingCheck |
throwing(Check<? super Throwable> check)
Check of a code, which should throw an exception (throwable).
|
static <D,V> Check<D> |
transform(Transformation<? super D,V> transformation,
Check<? super V> check)
Lowest level transformation.
|
static <D> Value<D> |
value() |
static <D> Check<D> |
which(Check<D> check) |
public static <D> Check<D> nullableCheck(Predicate<D> predicate, String expectationDescription)
D - Type of the data to be tested by the created expectation.predicate - Predicate used to test the supplied data.expectationDescription - Function, that provides description of the expectation.public static <D> Check<D> require(Check<? super D> requirement, Check<? super D> check)
D - Type of the data to be tested by the created check.requirement - Check, that must return true in order to evaluate the "actual" one.check - "Actual" check to be evaluated on tested data, if requirement is met.public static <D> Check<D> requireNotNull(Check<D> check)
D - Type of the data to be tested by the created check.check - Check to apply on the value, if it's not null.public static <D> Check<D> check(Predicate<D> predicate, String expectationDescription)
D - Type of the data to be checked.predicate - Implementation of the check logic.expectationDescription - Description of the expectation represented by this check.public static <D> Check<D> sameInstance(D expectedInstance)
D - Type of the tested data.expectedInstance - Expected instance.public static <D> Check<D> equalTo(D expectedValue)
D - Type of the tested data.expectedValue - Expected value.public static <D> Check<D> is(D expectedValue)
D - Type of the tested data.expectedValue - Expected value.equalTo(Object)public static Check<Object> isNotNull()
public static Check<Object> anything()
public static Check<Object> instanceOf(Class<?> expectedClass)
expectedClass - Expected class.public static Check<Object> isA(Class<?> expectedClass)
expectedClass - Expected class.public static Check<Object> isAn(Class<?> expectedClass)
expectedClass - Expected class.public static Check<Object> a(Class<?> expectedClass)
expectedClass - Expected class.public static Check<Object> an(Class<?> expectedClass)
expectedClass - Expected class.public static Check<Object> sameClass(Class<?> expectedClass)
expectedClass - Expected class.public static <D> Check<D> not(Check<D> positiveCheck)
D - Type of the data to be tested by the created check.positiveCheck - Positive check to evaluate, what shouldn't match.public static <D> Check<D> not(D positiveValue)
D - Type of the data to be tested by the created check.positiveValue - Positive value, which shouldn't be equal to checked data.public static <D> Check<D> oneOf(Collection<D> alternatives)
D - Type of the data to test using this expectation.alternatives - Expected alternatives.@SafeVarargs public static <D> Check<D> oneOf(D... alternatives)
D - Type of the data to test using this expectation.alternatives - Expected alternatives.public static <D> Check<D> anyOf(Iterable<Check<? super D>> operands)
D - Type of the tested data.operands - Individual checks to evaluate and apply logical or on their results.@SafeVarargs public static <D> Check<D> anyOf(Check<? super D>... operands)
D - Type of the tested data.operands - Individual checks to evaluate and apply logical or on their results.public static <D> Check<D> allOf(Iterable<Check<? super D>> operands)
D - Type of the tested data.operands - Individual checks to evaluate and apply logical and on their results.@SafeVarargs public static <D> Check<D> allOf(Check<? super D>... operands)
D - Type of the tested data.operands - Individual checks to evaluate and apply logical and on their results.public static <D,V> Check<D> transform(Transformation<? super D,V> transformation, Check<? super V> check)
D - Type of the original tested object.V - Type of the transformation result.transformation - Function transforming the original object.check - Check to apply on the result of the transformation.public static <D,V> Check<D> compose(String name, Transformation<? super D,V> transformation, Check<? super V> check)
D - Type of the original tested object.V - Type of the transformation result.name - Name (description) of the transformation.transformation - Function transforming the original object.check - Check to apply on the result of the transformation.public static <D,V> Check<D> compose(Transformation<? super D,V> transformation, Check<? super V> check)
D - Type of the original tested object.V - Type of the transformation result.transformation - Function transforming the original object.check - Check to apply on the result of the transformation.public static <D,V> TransformationBuilder<V,Check<D>> has(String name, Transformation<? super D,V> transformation)
public static <D,V> TransformationBuilder<V,Check<D>> has(Transformation<? super D,V> transformation)
public static <D,V> TransformationBuilder<V,Check<D>> nullableHas(String name, Transformation<? super D,V> transformation)
public static <D,V> TransformationBuilder<V,Check<D>> nullableHas(Transformation<? super D,V> transformation)
public static <V> TransformationBuilder<V,Check<V>> as(Class<V> type)
V - Type to check, and cast to.type - Required Java class / typepublic static Check<Throwable> message(Check<? super String> check)
check - String check of the message content.public static ThrowingCheck throwing(Check<? super Throwable> check)
check - Check on the throwable.public static ThrowingCheck throwing(Class<? extends Throwable> expectedType)
expectedType - Expected type of the thrown exception.public static <D> Check<D> createBuilder()
public static <D> CheckBuilder<D> dsl()
public static <D> Value<D> value()
public static <D> Check<D> customResultFactory(Check<D> check, ResultFactory customResultFactory)
Copyright © 2021. All rights reserved.