mirror of
https://github.com/jlengrand/atrium.git
synced 2026-03-10 08:01:19 +00:00
deprecate ExpectImpl.collector
This commit is contained in:
@@ -3,17 +3,10 @@ package ch.tutteli.atrium.logic.impl
|
||||
import ch.tutteli.atrium.assertions.Assertion
|
||||
import ch.tutteli.atrium.creating.AssertionContainer
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.domain.builders.ExpectImpl
|
||||
import ch.tutteli.atrium.domain.creating.changers.ChangedSubjectPostStep
|
||||
import ch.tutteli.atrium.domain.creating.changers.ExtractedFeaturePostStep
|
||||
import ch.tutteli.atrium.logic.*
|
||||
import ch.tutteli.atrium.reporting.Text
|
||||
import ch.tutteli.atrium.translations.DescriptionAnyAssertion
|
||||
import ch.tutteli.atrium.translations.DescriptionAnyAssertion.*
|
||||
import ch.tutteli.atrium.translations.DescriptionBasic.IS
|
||||
import ch.tutteli.atrium.translations.DescriptionBasic.IS_NOT
|
||||
import ch.tutteli.atrium.translations.DescriptionCollectionAssertion.EMPTY
|
||||
import ch.tutteli.atrium.translations.DescriptionCollectionAssertion.SIZE
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
class DefaultAnyAssertions : AnyAssertions {
|
||||
@@ -55,8 +48,8 @@ class DefaultAnyAssertions : AnyAssertions {
|
||||
override fun <T, TSub : Any> isA(
|
||||
container: AssertionContainer<T>,
|
||||
subType: KClass<TSub>
|
||||
): ChangedSubjectPostStep<T, TSub> = container.changeSubject.reportBuilder()
|
||||
): ChangedSubjectPostStep<T, TSub> =
|
||||
container.changeSubject.reportBuilder()
|
||||
.downCastTo(subType)
|
||||
.build()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import ch.tutteli.atrium.core.trueProvider
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
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.Text
|
||||
import ch.tutteli.atrium.translations.DescriptionBasic
|
||||
import ch.tutteli.atrium.translations.DescriptionIterableAssertion
|
||||
@@ -27,7 +28,7 @@ internal fun <E : Any> allCreatedAssertionsHold(
|
||||
assertionCreator: (Expect<E>.() -> Unit)?
|
||||
): Boolean = when (subject) {
|
||||
null -> assertionCreator == null
|
||||
else -> assertionCreator != null && ExpectImpl.collector.collect(Some(subject), assertionCreator).holds()
|
||||
else -> assertionCreator != null && assertionCollector.collect(Some(subject), assertionCreator).holds()
|
||||
}
|
||||
|
||||
|
||||
@@ -56,4 +57,4 @@ internal inline fun <E : Any> createExplanatoryAssertionGroup(
|
||||
}
|
||||
}
|
||||
.build()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import ch.tutteli.atrium.reporting.Text
|
||||
import ch.tutteli.atrium.reporting.translating.Translatable
|
||||
import ch.tutteli.atrium.translations.DescriptionThrowableAssertion.*
|
||||
|
||||
class ThrowableThrownFailureHandler<T : Throwable?, R>() : SubjectChanger.FailureHandler<T, R> {
|
||||
class ThrowableThrownFailureHandler<T : Throwable?, R> : SubjectChanger.FailureHandler<T, R> {
|
||||
|
||||
override fun createAssertion(
|
||||
originalAssertionContainer: Expect<T>,
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user