In package strikt.api

class strikt.api.Assertion.Builder

Used to construct assertions.

Methods

open fun assert(description: String, assert: AtomicAssertion.(T)->Unit): Builder

Evaluates a condition that may pass or fail.

While this method can be used directly in a test but is typically used inside an extension method on Assertion.Builder such as those provided in the strikt.assertions package.

Parameters:
  • description: String

    a description for the condition the assertion evaluates.

  • assert: AtomicAssertion.(T)->Unit

    the assertion implementation that should result in a call to Assertion.pass or Assertion.fail.

abstract fun assert(description: String, expected: Any?, assert: AtomicAssertion.(T)->Unit): Builder

Evaluates a condition that may pass or fail.

While this method can be used directly in a test but is typically used inside an extension method on Assertion.Builder such as those provided in the strikt.assertions package.

Parameters:
  • description: String

    a description for the condition the assertion evaluates. The description may contain a String.format style placeholder for the expected value.

  • expected: Any?

    the expected value of a comparison.

  • assert: AtomicAssertion.(T)->Unit

    the assertion implementation that should result in a call to Assertion.pass or Assertion.fail.

abstract fun compose(description: String, expected: Any?, assertions: Builder.(T)->Unit): CompoundAssertions

Allows an assertion to be composed of multiple sub-assertions such as on fields of an object or elements of a collection.

The results of assertions made inside the assertions block are included under the overall assertion result.

Parameters:
  • description: String

    a description for the condition the assertion evaluates.

  • expected: Any?

    the expected value of a comparison.

  • assertions: Builder.(T)->Unit

    a group of assertions that will be evaluated against the subject.

open fun compose(description: String, assertions: Builder.(T)->Unit): CompoundAssertions

Allows an assertion to be composed of multiple sub-assertions such as on fields of an object or elements of a collection.

The results of assertions made inside the assertions block are included under the overall assertion result.

Parameters:
  • description: String

    a description for the condition the assertion evaluates.

  • assertions: Builder.(T)->Unit

    a group of assertions that will be evaluated against the subject.

open fun passesIf(description: String, assert: (T)->Boolean): Builder

Evaluates a boolean condition. This is useful for implementing the simplest types of assertion function.

Parameters:
  • description: String

    a description for the condition the assertion evaluates.

  • assert: (T)->Boolean

    a function that returns true (the assertion passes) or false (the assertion fails).

open fun passesIf(description: String, expected: Any?, assert: (T)->Boolean): Builder

Evaluates a boolean condition. This is useful for implementing the simplest types of assertion function.

Parameters:
  • description: String

    a description for the condition the assertion evaluates.

  • expected: Any?

    the expected value of a comparison.

  • assert: (T)->Boolean

    a function that returns true (the assertion passes) or false (the assertion fails).

open fun assertThat(description: String, assert: (T)->Boolean): Builder

Evaluates a boolean condition. This is useful for implementing the simplest types of assertion function.

Parameters:
  • description: String

    a description for the condition the assertion evaluates.

  • assert: (T)->Boolean

    a function that returns true (the assertion passes) or false (the assertion fails).

open fun assertThat(description: String, expected: Any?, assert: (T)->Boolean): Builder

Evaluates a boolean condition. This is useful for implementing the simplest types of assertion function.

Parameters:
  • description: String

    a description for the condition the assertion evaluates.

  • expected: Any?

    the expected value of a comparison.

  • assert: (T)->Boolean

    a function that returns true (the assertion passes) or false (the assertion fails).

open fun <R> get(function: T.()->R): DescribeableBuilder

Maps the assertion subject to the result of function. This is useful for chaining to property values or method call results on the subject.

If function is a callable reference, (for example a getter or property reference) the subject description will be automatically determined for the returned assertion builder.

If function is a lambda, Strikt will make a best-effort attempt to determine an appropriate function / property name.

Parameters:
  • function: T.()->R

    a lambda whose receiver is the current assertion subject.

abstract fun <R> get(description: String, function: T.()->R): DescribeableBuilder

Maps the assertion subject to the result of function. This is useful for chaining to property values or method call results on the subject.

Parameters:
  • description: String

    a description of the mapped result.

  • function: T.()->R

    a lambda whose receiver is the current assertion subject.

open fun <R> chain(function: (T)->R): DescribeableBuilder

Deprecated form of get((T) -> R).

Parameters:
  • function: (T)->R
open fun <R> chain(description: String, function: (T)->R): DescribeableBuilder

Deprecated form of get(String, (T) -> R).

Parameters:
  • description: String
  • function: (T)->R
abstract fun not(): Builder

Reverses any assertions chained after this method.

Parameters:
  • No parameters
abstract fun not(assertions: Builder.()->Unit): Builder

Evaluates a block of assertions on the current subject by executing them in reverse.

Parameters:
  • assertions: Builder.()->Unit

    the assertions to evaluate in reverse

abstract infix fun and(assertions: Builder.()->Unit): Builder

Evaluates a block of assertions on the current subject.

The main use for this method is after strikt.assertions.isNotNull or strikt.assertions.isA in order that a group of assertions can more conveniently be performed on the narrowed subject type.

This method may be used as an infix function which tends to enhance readability when it directly follows a lambda.

Parameters:

Extensions

fun <T> Builder.isNull(): Builder

Asserts that the subject is null.

Parameters:
  • No parameters
fun <T> Builder.isNotNull(): Builder

Asserts that the subject is not null.

Parameters:
  • No parameters
inline fun <T> Builder.isA(): Builder

Asserts that the subject is an instance of T.

Parameters:
  • No parameters
fun <T> Builder.isEqualTo(expected: T?): Builder

Asserts that the subject is equal to expected according to the standard Kotlin == operator.

Parameters:
  • expected: T?

    the expected value.

fun Builder.isEqualTo(expected: Double, tolerance: Double): Builder

Asserts that the subject is within tolerance of expected.

Parameters:
  • expected: Double
  • tolerance: Double
fun Builder.isEqualTo(expected: Float, tolerance: Double): Builder

Asserts that the subject is within tolerance of expected.

Parameters:
  • expected: Float
  • tolerance: Double
fun <T> Builder.isNotEqualTo(expected: T?): Builder

Asserts that the subject is not equal to expected according to the standard Kotlin == operator.

Parameters:
  • expected: T?

    the expected value.

fun <T> Builder.isSameInstanceAs(expected: Any?): Builder

Asserts that the subject is the same instance as expected according to the standard Kotlin === operator.

Parameters:
  • expected: Any?

    the expected instance.

fun <T> Builder.isNotSameInstanceAs(expected: Any?): Builder

Asserts that the subject is not the same instance as expected according to the standard Kotlin === operator.

Parameters:
  • expected: Any?

    the expected instance.

fun <T : Any> Builder.propertiesAreEqualTo(other: T): Builder

Asserts that all properties of the subject match those of other according to either contentEquals in the case of array properties or isEqualTo in other cases.

Properties are identified using Java beans conventions.

Parameters:
  • other: T
fun <T> Builder.contentEquals(other: Array): Builder

Asserts that the subject's content is equal to that of other according to Array.contentEquals.

Parameters:
  • other: Array
fun Builder.contentEquals(other: BooleanArray): Builder

Asserts that the subject's content is equal to that of other according to BooleanArray.contentEquals.

Parameters:
  • other: BooleanArray
fun Builder.contentEquals(other: ByteArray): Builder

Asserts that the subject's content is equal to that of other according to ByteArray.contentEquals.

Parameters:
  • other: ByteArray
fun Builder.contentEquals(other: ShortArray): Builder

Asserts that the subject's content is equal to that of other according to ShortArray.contentEquals.

Parameters:
  • other: ShortArray
fun Builder.contentEquals(other: IntArray): Builder

Asserts that the subject's content is equal to that of other according to IntArray.contentEquals.

Parameters:
  • other: IntArray
fun Builder.contentEquals(other: LongArray): Builder

Asserts that the subject's content is equal to that of other according to LongArray.contentEquals.

Parameters:
  • other: LongArray
fun Builder.contentEquals(other: FloatArray): Builder

Asserts that the subject's content is equal to that of other according to FloatArray.contentEquals.

Parameters:
  • other: FloatArray
fun Builder.contentEquals(other: DoubleArray): Builder

Asserts that the subject's content is equal to that of other according to DoubleArray.contentEquals.

Parameters:
  • other: DoubleArray
fun Builder.contentEquals(other: CharArray): Builder

Asserts that the subject's content is equal to that of other according to CharArray.contentEquals.

Parameters:
  • other: CharArray
fun <T> Builder.isEmpty(): Builder

Asserts that the subject's content is empty.

Parameters:
  • No parameters
fun Builder.isEmpty(): Builder

Asserts that the subject's content is empty.

Parameters:
  • No parameters
fun Builder.isEmpty(): Builder

Asserts that the subject's content is empty.

Parameters:
  • No parameters
fun Builder.isEmpty(): Builder

Asserts that the subject's content is empty.

Parameters:
  • No parameters
fun Builder.isEmpty(): Builder

Asserts that the subject's content is empty.

Parameters:
  • No parameters
fun Builder.isEmpty(): Builder

Asserts that the subject's content is empty.

Parameters:
  • No parameters
fun Builder.isEmpty(): Builder

Asserts that the subject's content is empty.

Parameters:
  • No parameters
fun Builder.isEmpty(): Builder

Asserts that the subject's content is empty.

Parameters:
  • No parameters
fun Builder.isEmpty(): Builder

Asserts that the subject's content is empty.

Parameters:
  • No parameters
fun <T : CharSequence> Builder.isEmpty(): Builder

Asserts that the subject is the empty string.

Parameters:
  • No parameters
fun <T> Builder.toList(): Builder

Maps an array to a list to make it possible to use the iterable matchers

Parameters:
  • No parameters
fun <T : Boolean?> Builder.isTrue(): Builder

Asserts that the subject is not null and is the boolean value true.

Parameters:
  • No parameters
fun <T : Boolean?> Builder.isFalse(): Builder

Asserts that the subject is not null and is the boolean value false.

Parameters:
  • No parameters
fun <T : CharSequence> Builder.hasLength(expected: Int): Builder

Asserts that the subject has a CharSequence.length of exactly expected.

Parameters:
  • expected: Int
fun <T : CharSequence> Builder.isLowerCase(): Builder

Asserts that the subject is composed of all lower-case characters.

Parameters:
  • No parameters
fun <T : CharSequence> Builder.isUpperCase(): Builder

Asserts that the subject is composed of all upper-case characters.

Parameters:
  • No parameters
fun <T : CharSequence> Builder.startsWith(expected: Char): Builder

Asserts that the subject starts with the expected character.

Parameters:
  • expected: Char
fun <T : CharSequence> Builder.startsWith(expected: CharSequence): Builder

Asserts that the subject starts with the expected string.

Parameters:
  • expected: CharSequence
fun <T : Path> Builder.startsWith(other: Path): Builder

Asserts that the subject starts with the provided path.

Parameters:
  • other: Path

    the given path

fun <T : Path> Builder.startsWith(other: String): Builder

Asserts that the subject starts with the provided path.

Parameters:
  • other: String

    the given path string

fun <T : CharSequence> Builder.endsWith(expected: Char): Builder

Asserts that the subject ends with the expected character.

Parameters:
  • expected: Char
fun <T : CharSequence> Builder.endsWith(expected: CharSequence): Builder

Asserts that the subject ends with the expected string.

Parameters:
  • expected: CharSequence
fun <T : Path> Builder.endsWith(other: Path): Builder

Asserts that the subject end with the provided path.

Parameters:
  • other: Path

    the given path

fun <T : Path> Builder.endsWith(other: String): Builder

Asserts that the subject end with the provided path string.

Parameters:
  • other: String

    the given path string

fun <T : CharSequence> Builder.matches(expected: Regex): Builder

Asserts that the subject is a full match for the expected regular expression.

Parameters:
  • expected: Regex
fun <T : CharSequence> Builder.matchesIgnoringCase(expected: Regex): Builder

Asserts that the subject is a full match for the expected regular expression regardless of case.

Parameters:
  • expected: Regex
fun <T : CharSequence> Builder.contains(expected: Regex): Builder

Asserts that the subject contains a match for the expected regular expression.

Parameters:
  • expected: Regex
fun <T : CharSequence> Builder.contains(expected: CharSequence): Builder

Asserts that the subject contains the expected substring.

Parameters:
  • expected: CharSequence
fun <T : E, E> Builder.contains(element: E): Builder

Asserts that the subject range contains the provided element.

Parameters:
  • element: E
fun <T : E, E> Builder.contains(elements: E): Builder

Asserts that all elements are present in the subject. The elements may exist in any order any number of times and the subject may contain further elements that were not specified. If either the subject or elements are empty the assertion always fails.

Parameters:
  • elements: E
fun <T : E, E> Builder.contains(elements: Collection): Builder

Asserts that all elements are present in the subject. The elements may exist in any order any number of times and the subject may contain further elements that were not specified. If either the subject or elements are empty the assertion always fails.

Parameters:
  • elements: Collection
fun <T : CharSequence> Builder.containsIgnoringCase(expected: Regex): Builder

Asserts that the subject contains a match for the expected regular expression regardless of case.

Parameters:
  • expected: Regex
fun <T : CharSequence> Builder.containsIgnoringCase(expected: CharSequence): Builder

Asserts that the subject contains the expected substring regardless of case.

Parameters:
  • expected: CharSequence
fun <T : CharSequence?> Builder.isNullOrEmpty(): Builder

Asserts that the subject is null or the empty string.

Parameters:
  • No parameters
fun <T : CharSequence?> Builder.isNullOrBlank(): Builder

Asserts that the subject is null, empty, or contains only whitespace characters.

Parameters:
  • No parameters
fun <T : CharSequence> Builder.isBlank(): Builder

Asserts that the subject is empty, or contains only whitespace characters.

Parameters:
  • No parameters
fun <T : CharSequence> Builder.isNotEmpty(): Builder

Asserts that the subject is not the empty string (contains at least one character).

Parameters:
  • No parameters
fun <T : CharSequence> Builder.isNotBlank(): Builder

Asserts that the subject is not blank (contains at least one non-whitespace character).

Parameters:
  • No parameters
fun <T : CharSequence> Builder.trim(): Builder

Trims the subject CharSequence.

Parameters:
  • No parameters
fun Builder.trim(): Builder

Trims the subject string.

Parameters:
  • No parameters
fun <T : E, E> Builder.hasSize(expected: Int): Builder

Asserts that the subject has a Collection.size of exactly expected.

Parameters:
  • expected: Int
fun <T : E, E> Builder.isSorted(comparator: Comparator): Builder

Asserts that the subject collection is sorted according to the Comparator. Empty collections are considered sorted.

Parameters:
  • comparator: Comparator
fun <T : T> Builder.isGreaterThan(expected: T): Builder

Asserts that the subject compares greater than expected according to Kotlin's standard > operator.

Parameters:
  • expected: T
fun <T : T> Builder.isLessThan(expected: T): Builder

Asserts that the subject compares less than expected according to Kotlin's standard < operator.

Parameters:
  • expected: T
fun <T : T> Builder.isGreaterThanOrEqualTo(expected: T): Builder

Asserts that the subject compares greater than or equal to expected according to Kotlin's standard >= operator.

Parameters:
  • expected: T
fun <T : T> Builder.isLessThanOrEqualTo(expected: T): Builder

Asserts that the subject compares less than or equal to expected according to Kotlin's standard <= operator.

Parameters:
  • expected: T
fun <T : T> Builder.isIn(expected: ClosedRange): Builder

Asserts that the subject is in the expected range.

Parameters:
  • expected: ClosedRange
fun <T : File> Builder.toPath(): Builder

Maps this assertion to an assertion on a path object representing this subject.

Parameters:
  • No parameters
fun <T : File> Builder.lines(charset: Charset): Builder

Maps this assertion to an assertion on the lines of the subject decoded using the provided charset.

Parameters:
  • charset: Charset

    the charset used to decode the content

fun <T : File> Builder.text(charset: Charset): Builder

Maps this assertion to an assertion on the complete text of the subject decoded using the provided charset.

Parameters:
  • charset: Charset

    the charset used to decode the content

fun <T : E, E, R> Builder.map(function: (E)->R): Builder

Applies Iterable.map with function to the subject and returns an assertion builder wrapping the result.

Parameters:
  • function: (E)->R
fun <T : E, E> Builder.first(): Builder

Maps this assertion to an assertion over the first element in the subject iterable.

Parameters:
  • No parameters
fun <T : E, E> Builder.first(predicate: (E)->Boolean): Builder

Maps this assertion to an assertion over the first element in the subject iterable that matches predicate.

Parameters:
  • predicate: (E)->Boolean
fun <T : E, E> Builder.single(): Builder

Maps this assertion to an assertion over the single element in the subject iterable.

Parameters:
  • No parameters
fun <T : E, E> Builder.last(): Builder

Maps this assertion to an assertion over the last element in the subject iterable.

Parameters:
  • No parameters
fun <T : E, E, R> Builder.flatMap(transform: (E)->Iterable): Builder

Maps this assertion to an assertion over a flattened list of the results of transform for each element in the subject iterable.

Parameters:
  • transform: (E)->Iterable
fun <T : E, E> Builder.filter(predicate: (E)->Boolean): Builder

Maps this assertion to an assertion over a list of all elements of the subject that match predicate.

Parameters:
  • predicate: (E)->Boolean
fun <T : E, E> Builder.filterNot(predicate: (E)->Boolean): Builder

Maps this assertion to an assertion over a list of all elements of the subject that do not match predicate.

Parameters:
  • predicate: (E)->Boolean
inline fun <R> Builder.filterIsInstance(): Builder

Maps this assertion to an assertion over a list of all elements of the subject that are instances of R.

Parameters:
  • No parameters
fun <T : E, E> Builder.all(predicate: Builder.()->Unit): Builder

Asserts that all elements of the subject pass the assertions in predicate.

Parameters:
fun <T : E, E> Builder.any(predicate: Builder.()->Unit): Builder

Asserts that at least one element of the subject pass the assertions in predicate.

Parameters:
fun <T : E, E> Builder.none(predicate: Builder.()->Unit): Builder

Asserts that no elements of the subject pass the assertions in predicate.

Parameters:
fun <T : E, E> Builder.atLeast(count: Int, predicate: Builder.()->Unit): Builder

Asserts that at least count elements of the subject pass the assertions in predicate.

Parameters:
  • count: Int
  • predicate: Builder.()->Unit
fun <T : E, E> Builder.atMost(count: Int, predicate: Builder.()->Unit): Builder

Asserts that at most count elements of the subject pass the assertions in predicate.

Parameters:
  • count: Int
  • predicate: Builder.()->Unit
fun <T : E, E> Builder.exactly(count: Int, predicate: Builder.()->Unit): Builder

Asserts that exactly count elements of the subject pass the assertions in predicate.

Parameters:
  • count: Int
  • predicate: Builder.()->Unit
fun <T : E, E> Builder.doesNotContain(elements: E): Builder

Asserts that none of elements are present in the subject.

If elements is empty the assertion always fails. If the subject is empty the assertion always passe.

Parameters:
  • elements: E
fun <T : E, E> Builder.doesNotContain(elements: Collection): Builder

Asserts that none of elements are present in the subject.

If elements is empty the assertion always fails. If the subject is empty the assertion always passe.

Parameters:
  • elements: Collection
fun <T : E, E> Builder.containsExactly(elements: E): Builder

Asserts that all elements and no others are present in the subject in the specified order.

If the subject has no guaranteed iteration order (for example a Set) this assertion is probably not appropriate and you should use containsExactlyInAnyOrder instead.

Parameters:
  • elements: E
fun <T : E, E> Builder.containsExactly(elements: Collection): Builder

Asserts that all elements and no others are present in the subject in the specified order.

If the subject has no guaranteed iteration order (for example a Set) this assertion is probably not appropriate and you should use containsExactlyInAnyOrder instead.

Parameters:
  • elements: Collection
fun <T : E, E> Builder.containsExactlyInAnyOrder(elements: E): Builder

Asserts that all elements and no others are present in the subject. Order is not evaluated, so an assertion on a List will pass so long as it contains all the same elements with the same cardinality as elements regardless of what order they appear in.

Parameters:
  • elements: E
fun <T : E, E> Builder.containsExactlyInAnyOrder(elements: Collection): Builder

Asserts that all elements and no others are present in the subject. Order is not evaluated, so an assertion on a List will pass so long as it contains all the same elements with the same cardinality as elements regardless of what order they appear in.

Parameters:
  • elements: Collection
operator fun <T : E, E> Builder.get(i: Int): Builder

Maps this assertion to an assertion on the element at index i in the subject list.

Parameters:
  • i: Int
operator fun <T : E, E> Builder.get(range: IntRange): Builder

Maps this assertion to an assertion on the elements at the sub-list represented by range in the subject list.

Parameters:
  • range: IntRange
operator fun <T : Map, K, V> Builder.get(key: K): Builder

Maps this assertion to an assertion on the value indexed by key in the subject list.

Parameters:
  • key: K
fun <T : Map, K, V> Builder.getValue(key: K): Builder

Asserts that key exists in the subject map and then maps this assertion to an assertion on the associated value.

Parameters:
  • key: K
fun <T : Map, K, V> Builder.containsKey(key: K): Builder

Asserts that the subject map contains an entry indexed by key. Depending on the map implementation the value associated with key may be null. This assertion just tests for the existence of the key.

Parameters:
  • key: K
fun <T : Map, K, V> Builder.containsKeys(keys: K): Builder

Asserts that the subject map contains entries for all keys.

Parameters:
  • keys: K
fun <T : Map, K, V> Builder.hasEntry(key: K, value: V): Builder

Asserts that the subject map contains an entry indexed by key with a value equal to value.

Parameters:
  • key: K
  • value: V
fun <T> Builder.isPresent(): Builder

Asserts that an Optional contains a value (is not empty) and returns an assertion builder whose subject is the value.

Parameters:
  • No parameters
fun <T> Builder.isAbsent(): Builder

Asserts that an Optional does not contain a value.

Parameters:
  • No parameters
fun <T> Builder.toNullable(): Builder

Maps an assertion on a Java Optional to a Kotlin nullable type.

Parameters:
  • No parameters
fun <T : Path> Builder.isAbsolute(): Builder

Asserts that the subject is an absolute path.

Parameters:
  • No parameters
fun <T : Path> Builder.resolve(other: Path): Builder

Maps this assertion to an assertion of this subject resolved with the provided path.

Parameters:
  • other: Path

    the path to resolve against this subject's path

fun <T : Path> Builder.resolve(other: String): Builder

Maps this assertion to an assertion of this subject resolved with the provided path.

Parameters:
  • other: String

    the path string to resolve against this subject's path

fun <T : Path> Builder.toFile(): Builder

Maps this assertion to an assertion on the file object representing this subject.

Parameters:
  • No parameters
fun <T : Path> Builder.exists(options: LinkOption): Builder

Asserts that the subject exists, handling symbolic links according to the provided options

Parameters:
  • options: LinkOption

    the options indicating how symbolic links are handled

fun <T : Path> Builder.isDirectory(options: LinkOption): Builder

Asserts that the subject is a directory, handling symbolic links according to the provided options.

Parameters:
  • options: LinkOption

    the options indicating how symbolic links are handled

fun <T : Path> Builder.isExecutable(): Builder

Asserts that the subject is executable link.

Parameters:
  • No parameters
fun <T : Path> Builder.isReadable(): Builder

Asserts that the subject is readable.

Parameters:
  • No parameters
fun <T : Path> Builder.isRegularFile(options: LinkOption): Builder

Asserts that the subject is a regular file, handling symbolic links according to the provided options.

Parameters:
  • options: LinkOption

    the options indicating how symbolic links are handled

Asserts that the subject is a symbolic link.

Parameters:
  • No parameters
fun <T : Path> Builder.allBytes(): Builder

Maps this assertion to an assertion over all bytes of this subject path .

Parameters:
  • No parameters
fun <T : Path> Builder.allLines(): Builder

Maps this assertion to an assertion over all lines of this subject path decoded using the UTF-8 charset.

Parameters:
  • No parameters
fun <T : Path> Builder.allLines(charset: Charset): Builder

Maps this assertion to an assertion over all lines of this subject path decoded using the provided charset.

Parameters:
  • charset: Charset

    the charset to use in decoding

fun <T> Builder.succeeded(): Builder

Asserts that the subject is a successful result and maps this assertion to an assertion over the result value.

Parameters:
  • No parameters
fun <T> Builder.failed(): Builder

Asserts that the subject is a failed result and maps this assertion to an assertion over the exception that was thrown

Parameters:
  • No parameters
inline fun <E : Throwable> Builder.failedWith(): Builder

Asserts that the subject is a isFailure result that threw an exception assignable to E and maps this assertion to an assertion over that exception.

Parameters:
  • No parameters
fun Builder.isEqualToIgnoringCase(expected: String): Builder

Asserts that the subject is equal to the expected value regardless of case.

Parameters:
  • expected: String
fun <R : Any> Builder.doesNotThrow(): Builder

Asserts that the result of an action did not throw any exception and maps to an assertion on the result value. The assertion fails if the subject's Result.isFailure returns true.

Parameters:
  • No parameters
fun <T : BuildResult> Builder.task(taskPath: String): Builder

Maps this assertion to the task at the provided taskPath.

Parameters:
  • taskPath: String
fun <T : BuildResult> Builder.taskPaths(outcome: TaskOutcome): Builder

Maps this assertion to the task paths of the build with the provided outcome.

Parameters:
  • outcome: TaskOutcome
fun <T : BuildResult> Builder.tasks(outcome: TaskOutcome): Builder

Maps this assertion to the tasks of the build with the provided outcome.

Parameters:
  • outcome: TaskOutcome
fun <T : BuildTask> Builder.hasOutcome(outcome: TaskOutcome): Builder

Asserts that the outcome is equal to outcome.

Parameters:
  • outcome: TaskOutcome
fun <T : BuildTask> Builder.isSuccess(): Builder

Asserts that the outcome is TaskOutcome.SUCCESS.

Parameters:
  • No parameters
fun <T : BuildTask> Builder.isFailed(): Builder

Asserts that the outcome is TaskOutcome.FAILED.

Parameters:
  • No parameters
fun <T : BuildTask> Builder.isUpToDate(): Builder

Asserts that the outcome is TaskOutcome.UP_TO_DATE.

Parameters:
  • No parameters
fun <T : BuildTask> Builder.isSkipped(): Builder

Asserts that the outcome is TaskOutcome.SKIPPED.

Parameters:
  • No parameters
fun <T : BuildTask> Builder.isFromCache(): Builder

Asserts that the outcome is TaskOutcome.FROM_CACHE.

Parameters:
  • No parameters
fun <T : BuildTask> Builder.isNoSource(): Builder

Asserts that the outcome is TaskOutcome.NO_SOURCE.

Parameters:
  • No parameters
fun <T : JsonNode> Builder.has(fieldName: String): Builder

Asserts that the subject node has a field named fieldName.

Parameters:
  • fieldName: String
fun <T : JsonNode> Builder.path(fieldName: String): Builder

Maps the subject node of the assertion builder to the node accessed by fieldName.

Parameters:
  • fieldName: String
fun <T : JsonNode> Builder.isObject(): Builder

Asserts that the subject node is a JSON object.

Parameters:
  • No parameters
fun <T : JsonNode> Builder.isArray(): Builder

Asserts that the subject node is a JSON array.

Parameters:
  • No parameters
fun <T : JsonNode> Builder.isTextual(): Builder

Asserts that the subject node is a JSON text node.

Parameters:
  • No parameters
fun <T : JsonNode> Builder.isNumber(): Builder

Asserts that the subject node is a JSON numeric node.

Parameters:
  • No parameters
fun <T : JsonNode> Builder.isBoolean(): Builder

Asserts that the subject node is a JSON boolean node.

Parameters:
  • No parameters
fun <T : JsonNode> Builder.isMissing(): Builder

Asserts that the subject node is a JSON missing node.

Parameters:
  • No parameters
fun <T : JsonNode> Builder.textValue(): Builder

Maps the assertion to an assertion on the subject node's text value.

Be aware that if the node is not a text node this will map to an assertion on null.

Parameters:
  • No parameters
fun <T : JsonNode> Builder.numberValue(): Builder

Maps the assertion to an assertion on the subject node's number value.

Be aware that if the node is not a numeric node this will map to an assertion on null.

Parameters:
  • No parameters
fun <T : JsonNode> Builder.booleanValue(): Builder

Maps the assertion to an assertion on the subject node's boolean value.

Be aware that if the node is not a boolean node this will map to an assertion on false.

Parameters:
  • No parameters
fun <T : JsonNode> Builder.hasNodeType(nodeType: JsonNodeType): Builder

Asserts that the subject node's JsonNode.getNodeType method returns nodeType.

Convenient aliases for this assertion exist for common node types that also narrow the subject type of the resulting assertion builder.

Parameters:
  • nodeType: JsonNodeType
fun Builder.hasSize(expected: Int): Builder

Asserts that a JSON array's size is equal to expected.

Parameters:
  • expected: Int
fun Builder.size(): Builder

Maps an assertion on a JSON array to an assertion on its size.

Parameters:
  • No parameters
fun <T : TemporalAccessor> Builder.isBefore(expected: TemporalAccessor): Builder

Asserts that the subject is before expected.

Parameters:
  • expected: TemporalAccessor
fun <T : TemporalAccessor> Builder.isAfter(expected: TemporalAccessor): Builder

Asserts that the subject is after expected.

Parameters:
  • expected: TemporalAccessor
fun <T : TemporalAccessor> Builder.get(field: TemporalField): Builder

Maps an assertion on the subject to an assertion on the value of the specified temporal field.

Parameters:
  • field: TemporalField
fun <T : TemporalAccessor> Builder.getLong(field: TemporalField): Builder

Maps an assertion on the subject to an assertion on the value of the specified temporal field.

Parameters:
  • field: TemporalField
fun Builder.isEmpty()

Asserts that a com.google.protobuf.Any is empty and does not contain an object of any kind.

Parameters:
  • No parameters
inline fun <T : Message> Builder.unpacksTo(): Builder

Asserts that the subject is a message of type T.

Parameters:
  • No parameters
inline fun <T : Message> Builder.unpack(): Builder

Maps an assertion on com.google.protobuf.Any to an assertion on an unpacked message of type T.

Parameters:
  • No parameters
fun <T : MediaType?> Builder.isCompatibleWith(expected: MediaType): Builder

Asserts that the subject is compatible with expected.

For example, a subject of application/json;charset=UTF-8 is compatiblewith the media type application/json, but not with the media type application/x-yaml.

Parameters:
  • expected: MediaType
fun <T> Builder.statusCodeIs1xxInformational(): Builder

Asserts that the status code is a 1xx Information response.

Parameters:
  • No parameters
fun <T> Builder.statusCodeIs2xxSuccess(): Builder

Asserts that the status code is a 2xx Success response.

Parameters:
  • No parameters
fun <T> Builder.statusCodeIs3xxRedirection(): Builder

Asserts that the status code is a 3xx Redirect response.

Parameters:
  • No parameters
fun <T> Builder.statusCodeIs4xxClientError(): Builder

Asserts that the status code is a 4xx Client Error response.

Parameters:
  • No parameters
fun <T> Builder.statusCodeIs5xxServerError(): Builder

Asserts that the status code is a 5xx Server Error response.

Parameters:
  • No parameters
fun <T> Builder.statusCodeIs(expected: Int): Builder

Asserts that the status code is equal to expected.

Parameters:
  • expected: Int
fun <T> Builder.statusCodeIs(expected: HttpStatus): Builder

Asserts that the status code is equal to expected.

Parameters:
  • expected: HttpStatus
fun <T : ServletResponse> Builder.contentTypeIsCompatibleWith(expected: MediaType): Builder

Asserts that the content type of the subject is compatible with expected.

Parameters:
  • expected: MediaType