deprecate ExpectImpl.collector

This commit is contained in:
Robert Stoll
2020-07-10 22:59:36 +02:00
parent 4988d942b6
commit 771b5ccf1c
8 changed files with 39 additions and 29 deletions

View File

@@ -62,7 +62,7 @@ interface AssertionCollector {
* [None] in case a previous subject change was not successful - used as subject for the given [assertionCreator].
* @param assertionCreator A lambda which defines the assertions for the feature.
*
* @return The collected assertions as an [AssertionGroup] with an [InvisibleAssertionGroupType].
* @return The collected assertions as a `List<[Assertion]>`.
*
* @throws IllegalArgumentException in case the given [assertionCreator] did not create a single
* assertion.

View File

@@ -1,5 +1,6 @@
//TODO remove file with 1.0.0
@file:Suppress("DEPRECATION", "DeprecatedCallableAddReplaceWith")
package ch.tutteli.atrium.domain.builders
import ch.tutteli.atrium.assertions.Assertion
@@ -50,7 +51,9 @@ object ExpectImpl {
* In detail, its an `inline` property which returns [AssertionCollectorBuilder]
* which inter alia delegates to the implementation of [AssertionCollector].
*/
inline val collector get() = AssertionCollectorBuilder
@Deprecated("Use _logic.collect instead; will be removed with 1.0.0")
inline val collector
get() = AssertionCollectorBuilder
//--- assertions ---------------------------------------------------------------------------
@@ -59,7 +62,8 @@ object ExpectImpl {
* which inter alia delegates to the implementation of [AnyAssertions].
*/
@Deprecated("Use _logic from ch.tutteli.atrium.logic instead; will be removed with 1.0.0")
inline val any get() = AnyAssertionsBuilder
inline val any
get() = AnyAssertionsBuilder
/**
* Returns [CharSequenceAssertionsBuilder]
@@ -72,35 +76,40 @@ object ExpectImpl {
* which inter alia delegates to the implementation of [CollectionAssertions].
*/
@Deprecated("Use _logic from ch.tutteli.atrium.logic instead; will be removed with 1.0.0")
inline val collection get() = CollectionAssertionsBuilder
inline val collection
get() = CollectionAssertionsBuilder
/**
* Returns [ComparableAssertionsBuilder]
* which inter alia delegates to the implementation of [ComparableAssertions].
*/
@Deprecated("Use _logic from ch.tutteli.atrium.logic instead; will be removed with 1.0.0")
inline val comparable get() = ComparableAssertionsBuilder
inline val comparable
get() = ComparableAssertionsBuilder
/**
* Returns [NewFeatureAssertionsBuilder]
* which inter alia delegates to the implementation of [FeatureAssertions].
*/
@Deprecated("Use _logic from ch.tutteli.atrium.logic instead; will be removed with 1.0.0")
inline val feature get() = NewFeatureAssertionsBuilder
inline val feature
get() = NewFeatureAssertionsBuilder
/**
* Returns [FloatingPointAssertionsBuilder] - [Assertion]s applicable to [Float], [Double]
* and maybe more - which inter alia delegates to the implementation of [FloatingPointAssertions].
*/
@Deprecated("Use _logic from ch.tutteli.atrium.logic instead; will be removed with 1.0.0")
inline val floatingPoint get() = FloatingPointAssertionsBuilder
inline val floatingPoint
get() = FloatingPointAssertionsBuilder
/**
* Returns [Fun0AssertionsBuilder] - [Assertion]s applicable to lambdas with arity 0
* which inter alia delegates to the implementation of [FloatingPointAssertions].
*/
@Deprecated("Use _logic from ch.tutteli.atrium.logic instead; will be removed with 1.0.0")
inline val fun0 get() = Fun0AssertionsBuilder
inline val fun0
get() = Fun0AssertionsBuilder
/**
* Returns [IterableAssertionsBuilder].
@@ -113,33 +122,38 @@ object ExpectImpl {
* which inter alia delegates to the implementation of [ListAssertions].
*/
@Deprecated("Use _logic from ch.tutteli.atrium.logic instead; will be removed with 1.0.0")
val list get() = ListAssertionsBuilder
val list
get() = ListAssertionsBuilder
/**
* Returns [MapAssertionsBuilder]
* which inter alia delegates to the implementation of [MapAssertions].
*/
@Deprecated("Use _logic from ch.tutteli.atrium.logic instead; will be removed with 1.0.0")
inline val map get() = MapAssertionsBuilder
inline val map
get() = MapAssertionsBuilder
/**
* Returns [PairAssertionsBuilder]
* which inter alia delegates to the implementation of [PairAssertions].
*/
@Deprecated("Use _logic from ch.tutteli.atrium.logic instead; will be removed with 1.0.0")
inline val pair get() = PairAssertionsBuilder
inline val pair
get() = PairAssertionsBuilder
/**
* Returns [ThrowableAssertionsBuilder]
* which inter alia delegates to the implementation of [ThrowableAssertions].
*/
@Deprecated("Use _logic from ch.tutteli.atrium.logic instead; will be removed with 1.0.0")
inline val throwable get() = ThrowableAssertionsBuilder
inline val throwable
get() = ThrowableAssertionsBuilder
/**
* Returns [IteratorAssertionsBuilder]
* which inter alia delegates to the implementation of [IteratorAssertions].
*/
@Deprecated("Use _logic from ch.tutteli.atrium.logic instead; will be removed with 1.0.0")
inline val iterator get() = IteratorAssertionsBuilder
inline val iterator
get() = IteratorAssertionsBuilder
}

View File

@@ -15,6 +15,7 @@ import ch.tutteli.atrium.reporting.translating.Translatable
* In detail, it implements [AssertionCollector] by delegating to [assertionCollector]
* which in turn delegates to the implementation via [loadSingleService].
*/
@Deprecated("Use _logic.collect instead, will be removed with 1.0.0")
object AssertionCollectorBuilder : AssertionCollector {
override inline fun <T> collect(

View File

@@ -5,7 +5,7 @@ import ch.tutteli.atrium.assertions.ExplanatoryAssertionGroupType
import ch.tutteli.atrium.assertions.builders.AssertionsOption
import ch.tutteli.atrium.core.Option
import ch.tutteli.atrium.creating.Expect
import ch.tutteli.atrium.domain.builders.ExpectImpl
import ch.tutteli.atrium.domain.creating.collectors.assertionCollector
/**
* Collects the assertions [assertionCreator] creates and uses them as [AssertionGroup.assertions].
@@ -21,4 +21,4 @@ fun <T, G : ExplanatoryAssertionGroupType, R> AssertionsOption<G, R>.collectAsse
fun <T, G : ExplanatoryAssertionGroupType, R> AssertionsOption<G, R>.collectAssertions(
maybeSubject: Option<T>,
assertionCreator: Expect<T>.() -> Unit
): R = withAssertions(ExpectImpl.collector.collectForComposition(maybeSubject, assertionCreator))
): R = withAssertions(assertionCollector.collectForComposition(maybeSubject, assertionCreator))

View File

@@ -8,6 +8,7 @@ import ch.tutteli.atrium.creating.FeatureExpect
import ch.tutteli.atrium.creating.FeatureExpectOptions
import ch.tutteli.atrium.domain.builders.ExpectImpl
import ch.tutteli.atrium.domain.builders.creating.collectors.collectAssertions
import ch.tutteli.atrium.domain.creating.collectors.assertionCollector
import ch.tutteli.atrium.reporting.translating.Translatable
@Suppress("DEPRECATION" /* OptIn is only available since 1.3.70 which we cannot use if we want to support 1.2 */)
@@ -56,7 +57,7 @@ fun <T, R> _extractFeature(
maybeSubAssertions.fold({
listOf<Assertion>()
}) { assertionCreator ->
ExpectImpl.collector.collectForComposition(Some(subject), assertionCreator)
assertionCollector.collectForComposition(Some(subject), assertionCreator)
},
FeatureExpectOptions(
representationInsteadOfFeature = representationInsteadOfFeature