deprecate CoreFactory and loadService

This commit is contained in:
Robert Stoll
2021-04-05 21:03:07 +02:00
parent 564ef9430f
commit 81216138ec
19 changed files with 53 additions and 55 deletions

View File

@@ -1,9 +1,7 @@
package ch.tutteli.atrium.assertions
import ch.tutteli.atrium.core.CoreFactory
/**
* A marker interface for types which can be used to identify bullet points in
* [CoreFactory.registerTextAssertionFormatterCapabilities].
* A marker interface for types which can be used to identify bullet points.
*/
interface BulletPointIdentifier

View File

@@ -1,6 +1,5 @@
package ch.tutteli.atrium.assertions
import ch.tutteli.atrium.core.CoreFactory
/**
* Represents the [AssertionGroupType] for [AssertionGroup]s which contain some kind of feature assertions.
@@ -8,7 +7,7 @@ import ch.tutteli.atrium.core.CoreFactory
interface FeatureAssertionGroupType : AssertionGroupType
/**
* This class is only used as identifier for [CoreFactory.registerTextAssertionFormatterCapabilities].
* This class is only used as [BulletPointIdentifier].
*/
class PrefixFeatureAssertionGroupHeader private constructor() : BulletPointIdentifier

View File

@@ -1,6 +1,5 @@
package ch.tutteli.atrium.assertions
import ch.tutteli.atrium.core.CoreFactory
import ch.tutteli.atrium.reporting.AssertionFormatter
import ch.tutteli.atrium.reporting.Reporter
@@ -20,16 +19,12 @@ interface SummaryAssertionGroupType : DoNotFilterAssertionGroupType
/**
* Represents the identifier for bullet points used to prefix [Assertion]s which hold, in context of an
* [AssertionGroup] with type [SummaryAssertionGroupType].
*
* See also [CoreFactory.registerTextAssertionFormatterCapabilities].
*/
class PrefixSuccessfulSummaryAssertion private constructor() : BulletPointIdentifier
/**
* Represents the identifier for bullet points used to prefix [Assertion]s which do not hold, in context of an
* [AssertionGroup] with type [SummaryAssertionGroupType].
*
* See also [CoreFactory.registerTextAssertionFormatterCapabilities].
*/
class PrefixFailingSummaryAssertion private constructor() : BulletPointIdentifier

View File

@@ -1,3 +1,6 @@
//TODO remove file with 0.18.0
@file:Suppress("DEPRECATION")
package ch.tutteli.atrium.core
import ch.tutteli.atrium.assertions.*
@@ -19,7 +22,7 @@ annotation class ExperimentalNewExpectTypes
*
* It loads the implementation lazily via [loadSingleService].
*/
//TODO 0.17.0 deprecate
@Deprecated("Retrieve components via ComponentFactoryContainer; will be removed with 0.18.0")
val coreFactory by lazy { loadSingleService(CoreFactory::class) }
/**
@@ -31,7 +34,7 @@ val coreFactory by lazy { loadSingleService(CoreFactory::class) }
* Notice, the platform specific types have to define the default methods for `newReportingPlantNullable`
* (otherwise we are not binary backward compatible) -> will be moved to CoreFactoryCommon with 1.0.0
*/
//TODO 0.17.0 deprecate
@Deprecated("Retrieve components via ComponentFactoryContainer; will be removed with 0.18.0")
expect interface CoreFactory : CoreFactoryCommon
/**
@@ -52,7 +55,7 @@ expect interface CoreFactory : CoreFactoryCommon
* - [Reporter]
* - [AtriumErrorAdjuster]
*/
//TODO 0.17.0 deprecate
@Deprecated("Retrieve components via ComponentFactoryContainer; will be removed with 0.18.0")
interface CoreFactoryCommon {
/**
@@ -64,7 +67,7 @@ interface CoreFactoryCommon {
*
* @return The newly created method call formatter.
*/
@Deprecated("Create a new MethodCallFormatter via the ComponentFactoryContainer, e.g. via _logic.components.build<MethodCallFormatter>(); will be removed with 0.17.0")
@Deprecated("Create a new MethodCallFormatter via the ComponentFactoryContainer, e.g. via _logic.components.build<MethodCallFormatter>(); will be removed with 0.18.0")
fun newMethodCallFormatter(): MethodCallFormatter
@@ -91,7 +94,7 @@ interface CoreFactoryCommon {
* @throws IllegalArgumentException in case [primaryLocale] or [fallbackLocales] have as language `no` or if they
* have: as language `zh`, country is not set and script is either `Hant` or `Hans`.
*/
@Deprecated("Create a new Translator via the ComponentFactoryContainer, e.g. via _logic.components.build<Translator>(); will be removed with 0.17.0")
@Deprecated("Create a new Translator via the ComponentFactoryContainer, e.g. via _logic.components.build<Translator>(); will be removed with 0.18.0")
fun newTranslator(
translationSupplier: TranslationSupplier,
localeOrderDecider: LocaleOrderDecider,
@@ -108,7 +111,7 @@ interface CoreFactoryCommon {
*
* @return The newly created [Locale] order decider.
*/
@Deprecated("Create a new LocaleOrderDecider via the ComponentFactoryContainer, e.g. via _logic.components.build<LocaleOrderDecider>(); will be removed with 0.17.0")
@Deprecated("Create a new LocaleOrderDecider via the ComponentFactoryContainer, e.g. via _logic.components.build<LocaleOrderDecider>(); will be removed with 0.18.0")
fun newLocaleOrderDecider(): LocaleOrderDecider
/**
@@ -117,7 +120,7 @@ interface CoreFactoryCommon {
*
* @return The newly created object formatter.
*/
@Deprecated("Create a new ObjectFormatter via the ComponentFactoryContainer, e.g. via _logic.components.build<ObjectFormatter>(); will be removed with 0.17.0")
@Deprecated("Create a new ObjectFormatter via the ComponentFactoryContainer, e.g. via _logic.components.build<ObjectFormatter>(); will be removed with 0.18.0")
fun newDetailedObjectFormatter(translator: Translator): ObjectFormatter
/**
@@ -125,7 +128,7 @@ interface CoreFactoryCommon {
*
* @return The newly created assertion formatter controller.
*/
@Deprecated("Open an issue in case you used this; Will be removed with 0.17.0")
@Deprecated("Open an issue in case you used this; will be removed with 0.18.0")
fun newAssertionFormatterController(): AssertionFormatterController
/**
@@ -135,7 +138,7 @@ interface CoreFactoryCommon {
*
* @return The newly created assertion formatter facade.
*/
@Deprecated("Open an issue in case you used this; Will be removed with 0.17.0")
@Deprecated("Open an issue in case you used this; will be removed with 0.18.0")
fun newAssertionFormatterFacade(assertionFormatterController: AssertionFormatterController): AssertionFormatterFacade
/**
@@ -154,7 +157,7 @@ interface CoreFactoryCommon {
*
* @return The newly created assertion formatter.
*/
@Deprecated("Create it via TextAssertionPairFormatter.newSameLine(...); will be removed with 0.17.0")
@Deprecated("Create it via TextAssertionPairFormatter.newSameLine(...); will be removed with 0.18.0")
fun newTextSameLineAssertionPairFormatter(
objectFormatter: ObjectFormatter,
translator: Translator
@@ -178,7 +181,7 @@ interface CoreFactoryCommon {
*
* @return The newly created assertion formatter.
*/
@Deprecated("Create it via TextAssertionPairFormatter.newNextLine(...); will be removed with 0.17.0")
@Deprecated("Create it via TextAssertionPairFormatter.newNextLine(...); will be removed with 0.18.0")
fun newTextNextLineAssertionPairFormatter(
objectFormatter: ObjectFormatter,
translator: Translator
@@ -199,7 +202,7 @@ interface CoreFactoryCommon {
*
* @return The newly created assertion formatter.
*/
@Deprecated("Open an issue in case you used this; Will be removed with 0.17.0")
@Deprecated("Open an issue in case you used this; will be removed with 0.18.0")
fun newTextFallbackAssertionFormatter(
bulletPoints: Map<KClass<out BulletPointIdentifier>, String>,
assertionFormatterController: AssertionFormatterController,
@@ -221,7 +224,7 @@ interface CoreFactoryCommon {
*
* @return The newly created assertion formatter.
*/
@Deprecated("Open an issue in case you used this; Will be removed with 0.17.0")
@Deprecated("Open an issue in case you used this; will be removed with 0.18.0")
fun newTextFeatureAssertionGroupFormatter(
bulletPoints: Map<KClass<out BulletPointIdentifier>, String>,
assertionFormatterController: AssertionFormatterController,
@@ -242,7 +245,7 @@ interface CoreFactoryCommon {
*
* @return The newly created assertion formatter.
*/
@Deprecated("Open an issue in case you used this; Will be removed with 0.17.0")
@Deprecated("Open an issue in case you used this; will be removed with 0.18.0")
fun newTextListAssertionGroupFormatter(
bulletPoints: Map<KClass<out BulletPointIdentifier>, String>,
assertionFormatterController: AssertionFormatterController,
@@ -264,7 +267,7 @@ interface CoreFactoryCommon {
*
* @return The newly created assertion formatter.
*/
@Deprecated("Open an issue in case you used this; Will be removed with 0.17.0")
@Deprecated("Open an issue in case you used this; will be removed with 0.18.0")
fun newTextSummaryAssertionGroupFormatter(
bulletPoints: Map<KClass<out BulletPointIdentifier>, String>,
assertionFormatterController: AssertionFormatterController,
@@ -284,7 +287,7 @@ interface CoreFactoryCommon {
*
* @return The newly created assertion formatter.
*/
@Deprecated("Open an issue in case you used this; Will be removed with 0.17.0")
@Deprecated("Open an issue in case you used this; will be removed with 0.18.0")
fun newTextExplanatoryAssertionGroupFormatter(
bulletPoints: Map<KClass<out BulletPointIdentifier>, String>,
assertionFormatterController: AssertionFormatterController
@@ -305,7 +308,7 @@ interface CoreFactoryCommon {
* @param objectFormatter The formatter which is used to format objects other than [Assertion]s.
* @param translator The translator which is used to translate [Translatable] such as [DescriptiveAssertion.description].
*/
@Deprecated("Open an issue in case you used this; Will be removed with 0.17.0")
@Deprecated("Open an issue in case you used this; will be removed with 0.18.0")
fun registerTextAssertionFormatterCapabilities(
bulletPoints: Map<KClass<out BulletPointIdentifier>, String>,
assertionFormatterFacade: AssertionFormatterFacade,
@@ -333,7 +336,7 @@ interface CoreFactoryCommon {
* @return The newly created adjuster.
*/
@Deprecated(
"Use NoOpAtriumErrorAdjuster instead; will be removed with 0.17.0",
"Use NoOpAtriumErrorAdjuster instead; will be removed with 0.18.0",
ReplaceWith("ch.tutteli.atrium.reporting.erroradjusters.NoOpAtriumErrorAdjuster")
)
fun newNoOpAtriumErrorAdjuster(): AtriumErrorAdjuster
@@ -343,7 +346,7 @@ interface CoreFactoryCommon {
*
* @return The newly created adjuster.
*/
@Deprecated("Create a new RemoveRunnerFromAtriumError via the ComponentFactoryContainer, e.g. via _logic.components.build<RemoveRunnerFromAtriumError>(); will be removed with 0.17.0")
@Deprecated("Create a new RemoveRunnerFromAtriumError via the ComponentFactoryContainer, e.g. via _logic.components.build<RemoveRunnerFromAtriumError>(); will be removed with 0.18.0")
fun newRemoveRunnerAtriumErrorAdjuster(): AtriumErrorAdjuster
/**
@@ -351,7 +354,7 @@ interface CoreFactoryCommon {
*
* @return The newly created adjuster.
*/
@Deprecated("Create a new RemoveAtriumFromAtriumError via the ComponentFactoryContainer, e.g. via _logic.components.build<RemoveAtriumFromAtriumError>(); will be removed with 0.17.0")
@Deprecated("Create a new RemoveAtriumFromAtriumError via the ComponentFactoryContainer, e.g. via _logic.components.build<RemoveAtriumFromAtriumError>(); will be removed with 0.18.0")
fun newRemoveAtriumFromAtriumErrorAdjuster(): AtriumErrorAdjuster
/**
@@ -365,7 +368,7 @@ interface CoreFactoryCommon {
* @return The newly created adjuster.
*/
@Deprecated(
"Use MultiAtriumErrorAdjuster instead; will be removed with 0.17.0",
"Use MultiAtriumErrorAdjuster instead; will be removed with 0.18.0",
ReplaceWith(
"MultiAtriumErrorAdjuster(firstAdjuster, secondAdjuster, otherAdjusters)",
"ch.tutteli.atrium.reporting.erroradjusters.MultiAtriumErrorAdjuster"

View File

@@ -1,3 +1,4 @@
//TODO remove file with 0.18.0
package ch.tutteli.atrium.core.polyfills
import ch.tutteli.kbox.forEachRemaining
@@ -11,7 +12,7 @@ import kotlin.reflect.KClass
* @throws NoSuchElementException in case there is no service found for [kClass].
* @throws IllegalStateException in case there is more than one service found for [kClass].
*/
//TODO 0.17.0 deprecate
@Deprecated("Retrieve components via ComponentFactoryContainer; will be removed with 0.18.0")
expect fun <T : Any> loadSingleService(kClass: KClass<T>): T
/**
@@ -19,7 +20,7 @@ expect fun <T : Any> loadSingleService(kClass: KClass<T>): T
*
* @return The loaded services as a [Sequence].
*/
//TODO 0.17.0 deprecate
@Deprecated("Retrieve components via ComponentFactoryContainer; will be removed with 0.18.0")
expect fun <T : Any> loadServices(kClass: KClass<T>): Sequence<T>
/**
@@ -28,7 +29,7 @@ expect fun <T : Any> loadServices(kClass: KClass<T>): Sequence<T>
* @throws NoSuchElementException in case there is no service found for [kClass].
* @throws IllegalStateException in case there is more than one service found for [kClass].
*/
//TODO 0.17.0 deprecate
@Deprecated("Retrieve components via ComponentFactoryContainer; will be removed with 0.18.0")
fun <T : Any> useSingleService(kClass: KClass<T>, itr: Iterator<T>): T {
if (!itr.hasNext()) throw NoSuchElementException("Could not find any implementation for ${kClass.fullName}")

View File

@@ -32,7 +32,7 @@ interface AssertionContainer<T> : @kotlin.Suppress("DEPRECATION") SubjectProvide
*
* Might be we completely remove it without prior notice.
*/
//TODO 0.17.0/0.18.0 maybe it would be better to have proofFactories as val like we have components?
//TODO 0.18.0/0.19.0 maybe it would be better to have proofFactories as val like we have components?
@ExperimentalNewExpectTypes
fun <I : Any> getImpl(kClass: KClass<I>, defaultFactory: () -> I): I

View File

@@ -10,7 +10,7 @@ import ch.tutteli.atrium.core.Some
* Provides the subject of an [Assertion].
*
* Notice, this interface had its mere purpose to facilitate the transition from `Assert` to [Expect] -- `Assert` was
* removed in 0.16.0 and thus this interface will be removed with 0.17.0.
* removed in 0.16.0 and thus this interface will be removed with 0.18.0.
*/
@Suppress("DEPRECATION")
@Deprecated("Will be removed with 0.18.0 without replacement, switch to Expect or AssertionContainer")

View File

@@ -4,7 +4,6 @@ import ch.tutteli.atrium.assertions.Assertion
import ch.tutteli.atrium.assertions.AssertionGroup
import ch.tutteli.atrium.assertions.ExplanatoryAssertionGroupType
import ch.tutteli.atrium.assertions.InvisibleAssertionGroupType
import ch.tutteli.atrium.core.CoreFactory
/**
* Responsible to control the flow of reporting using [register]ed [AssertionFormatter]s.
@@ -16,8 +15,7 @@ interface AssertionFormatterController {
* formats it.
*
* The [parameterObject] allows to define an [assertionFilter][AssertionFormatterParameterObject.assertionFilter]
* to filter out [Assertion]s (for instance, filter out messages which hold
* &rarr; see [CoreFactory.newOnlyFailureReporter]).
* to filter out [Assertion]s (for instance, filter out messages which hold.
* Moreover the controller should take into account whether the control flow
* [AssertionFormatterParameterObject.isNotInDoNotFilterGroup] or is in such a group,
* in which case the filtering should not apply.

View File

@@ -1,7 +1,6 @@
package ch.tutteli.atrium.reporting
import ch.tutteli.atrium.assertions.Assertion
import ch.tutteli.atrium.core.CoreFactory
/**
* Responsible to call an appropriate [AssertionFormatter] which supports [format]ing a given [Assertion].
@@ -11,8 +10,7 @@ interface AssertionFormatterFacade {
/**
* Formats the given [assertion] and appends the result to the given [sb].
*
* One can define an [assertionFilter] to filter out [Assertion]s
* (for instance, filter out assertions which hold &rarr; see [CoreFactory.newOnlyFailureReporter]).
* One can define an [assertionFilter] to filter out [Assertion]s.
*
* @param sb The [StringBuilder] to which the formatted [assertion] will be appended.
* @param assertion The assertion which should be formatted

View File

@@ -1,7 +1,6 @@
package ch.tutteli.atrium.reporting
import ch.tutteli.atrium.assertions.Assertion
import ch.tutteli.atrium.core.CoreFactory
/**
* Represents a reporter which reports about [Assertion]s.
@@ -12,8 +11,6 @@ interface Reporter {
* Reports about the given [assertion], using the given [sb] where the actual
* implementation will decide whether the given [assertion] is noteworthy to be reported.
*
* For instance, [CoreFactory.newOnlyFailureReporter] will only report failing [Assertion]s.
*
* @param sb The [StringBuilder] which can be used for reporting.
* @param assertion The assertion which should be considered for reporting.
*/

View File

@@ -1,3 +1,7 @@
//TODO remove file with 0.18.0
@file:Suppress("DEPRECATION")
package ch.tutteli.atrium.core
@Deprecated("Retrieve components via ComponentFactoryContainer; will be removed with 0.18.0")
actual interface CoreFactory : CoreFactoryCommon

View File

@@ -1,13 +1,17 @@
//TODO remove file with 0.18.0
@file:Suppress("DEPRECATION", "DeprecatedCallableAddReplaceWith")
package ch.tutteli.atrium.core.polyfills
import kotlin.reflect.KClass
private val serviceRegistry = mutableMapOf<KClass<*>, HashSet<Any>>()
@Deprecated("Retrieve components via ComponentFactoryContainer; will be removed with 0.18.0")
actual fun <T : Any> loadSingleService(kClass: KClass<T>): T =
useSingleService(kClass, loadServices(kClass).iterator())
@Deprecated("Retrieve components via ComponentFactoryContainer; will be removed with 0.18.0")
actual fun <T : Any> loadServices(kClass: KClass<T>): Sequence<T> {
@Suppress("UNCHECKED_CAST" /* we have a homogeneous map but make sure insertions are type safe, thus OK */)
val set = serviceRegistry[kClass] as Set<() -> T>?
@@ -17,11 +21,13 @@ actual fun <T : Any> loadServices(kClass: KClass<T>): Sequence<T> {
/**
* Registers the given [service] for the service of type [T].
*/
@Deprecated("Retrieve components via ComponentFactoryContainer; will be removed with 0.18.0")
inline fun <reified T : Any> registerService(noinline service: () -> T) = registerService(T::class, service)
/**
* Registers the given [service] for the given [serviceInterface].
*/
@Deprecated("Retrieve components via ComponentFactoryContainer; will be removed with 0.18.0")
fun <T : Any> registerService(serviceInterface: KClass<T>, service: () -> T) {
val services = serviceRegistry.getOrPut(serviceInterface) { hashSetOf() }
services.add(service)

View File

@@ -1,6 +1,7 @@
//TODO remove file with 0.18.0
@file:Suppress(
// TODO remove once https://youtrack.jetbrains.com/issue/KT-35343 is fixed
"JAVA_MODULE_DOES_NOT_READ_UNNAMED_MODULE"
"JAVA_MODULE_DOES_NOT_READ_UNNAMED_MODULE", "DEPRECATION"
)
package ch.tutteli.atrium.core
@@ -11,7 +12,7 @@ import ch.tutteli.atrium.reporting.translating.Locale
import ch.tutteli.atrium.reporting.translating.TranslationSupplier
import java.util.*
//TODO 0.17.0 deprecate
@Deprecated("Retrieve components via ComponentFactoryContainer; will be removed with 0.18.0")
actual interface CoreFactory : CoreFactoryCommon {
/**
@@ -27,7 +28,7 @@ actual interface CoreFactory : CoreFactoryCommon {
*
* @return The newly created translation supplier.
*/
@Deprecated("Open an issue in case you used this; Will be removed with 0.17.0")
@Deprecated("Open an issue in case you used this; Will be removed with 0.18.0")
fun newPropertiesBasedTranslationSupplier(): TranslationSupplier
@Deprecated(

View File

@@ -1,6 +1,7 @@
//TODO remove file with 0.18.0
@file:Suppress(
// TODO remove once https://youtrack.jetbrains.com/issue/KT-35343 is fixed
"JAVA_MODULE_DOES_NOT_READ_UNNAMED_MODULE"
"JAVA_MODULE_DOES_NOT_READ_UNNAMED_MODULE", "DEPRECATION", "DeprecatedCallableAddReplaceWith"
)
package ch.tutteli.atrium.core.polyfills
@@ -17,8 +18,10 @@ import kotlin.reflect.KClass
* @throws NoSuchElementException in case there is no service found for [kClass].
* @throws IllegalStateException in case there is more than one service found for [kClass].
*/
@Deprecated("Retrieve components via ComponentFactoryContainer; will be removed with 0.18.0")
actual fun <T : Any> loadSingleService(kClass: KClass<T>): T =
useSingleService(kClass, ServiceLoader.load(kClass.java).iterator())
@Deprecated("Retrieve components via ComponentFactoryContainer; will be removed with 0.18.0")
actual fun <T : Any> loadServices(kClass: KClass<T>): Sequence<T> =
ServiceLoader.load(kClass.java).asSequence()

View File

@@ -5,7 +5,6 @@ import ch.tutteli.atrium.assertions.builders.assertionBuilder
import ch.tutteli.atrium.assertions.builders.invisibleGroup
import ch.tutteli.atrium.core.Option
import ch.tutteli.atrium.core.Some
import ch.tutteli.atrium.core.coreFactory
import ch.tutteli.atrium.creating.Expect
import ch.tutteli.atrium.creating.ExperimentalComponentFactoryContainer
import ch.tutteli.atrium.creating.build

View File

@@ -2,7 +2,6 @@ package ch.tutteli.atrium.logic.impl
import ch.tutteli.atrium.core.ExperimentalNewExpectTypes
import ch.tutteli.atrium.core.Some
import ch.tutteli.atrium.core.coreFactory
import ch.tutteli.atrium.creating.AssertionContainer
import ch.tutteli.atrium.creating.ExperimentalComponentFactoryContainer
import ch.tutteli.atrium.creating.build

View File

@@ -1,7 +1,6 @@
package ch.tutteli.atrium.specs.reporting
import ch.tutteli.atrium.assertions.*
import ch.tutteli.atrium.core.coreFactory
import ch.tutteli.atrium.reporting.*
import ch.tutteli.atrium.reporting.impl.AssertionFormatterControllerBasedFacade
import ch.tutteli.atrium.reporting.impl.DefaultAssertionFormatterController

View File

@@ -6,7 +6,6 @@ import ch.tutteli.atrium.api.verbs.internal.expect
import ch.tutteli.atrium.assertions.AssertionGroup
import ch.tutteli.atrium.assertions.AssertionGroupType
import ch.tutteli.atrium.assertions.builders.assertionBuilder
import ch.tutteli.atrium.core.coreFactory
import ch.tutteli.atrium.reporting.AssertionFormatter
import ch.tutteli.atrium.reporting.AssertionFormatterController
import ch.tutteli.atrium.reporting.AssertionFormatterParameterObject

View File

@@ -10,7 +10,6 @@ import ch.tutteli.atrium.assertions.AssertionGroup
import ch.tutteli.atrium.assertions.AssertionGroupType
import ch.tutteli.atrium.assertions.BulletPointIdentifier
import ch.tutteli.atrium.assertions.builders.assertionBuilder
import ch.tutteli.atrium.core.coreFactory
import ch.tutteli.atrium.core.polyfills.fullName
import ch.tutteli.atrium.reporting.AssertionFormatter
import ch.tutteli.atrium.reporting.AssertionFormatterController