In package strikt.api

class strikt.api.DescribeableBuilder

Extension of Assertion.Builder that enables the description of the assertion subject.

Since it doesn't make sense to do this anywhere except directly after the initial expectThat or Assertion.Builder.get call those methods return an instance of this interface, while assertions themselves just return Assertion.Builder.

Methods

abstract fun describedAs(description: String): Builder

Adds a description to the assertion.

Parameters:
  • description: String

    a description of the subject of the assertion. The description may include a String.format style placeholder for the value itself.

abstract fun describedAs(descriptor: T.()->String): Builder

Adds a description to the assertion.

Parameters:
  • descriptor: T.()->String

    a function that returns a description for the subject of the assertion. The subject is the function's this so it's possible to use properties or method results of the subject in the description.

Extensions

fun <L, R> Builder.isRight(): Builder
Parameters:
  • No parameters
fun <L, R> Builder.isRight(value: R): Builder
Parameters:
  • value: R
fun <L, R> Builder.isLeft(): Builder
Parameters:
  • No parameters
fun <L, R> Builder.isLeft(value: L): Builder
Parameters:
  • value: L
fun <T> Builder.isNone(): Builder
Parameters:
  • No parameters
fun <T> Builder.isSome(): Builder
Parameters:
  • No parameters
fun <T> Builder.isSome(value: T): Builder
Parameters:
  • value: T
fun <T> Builder.isSuccess(value: T): Builder
Parameters:
  • value: T
fun <T> Builder.isFailure(): Builder
Parameters:
  • No parameters
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 <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 : 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.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 <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
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 : 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 <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.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 <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 <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 : ServletResponse> Builder.contentTypeIsCompatibleWith(expected: MediaType): Builder

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

Parameters:
  • expected: MediaType