atrium v0.14.0 Release Notes
Release Date: 2020-11-14 // almost 4 years ago-
Table of Content
- New Features
- ๐ Fixes
- Improvements
- Breaking Changes
- ๐ Deprecation
- ๐ Migrating deprecated functionality
- Sponsors
๐ New Features
All APIs
- #461 Sequence.asList => thanks to @Valefant for the implementation
- #462 Iterable.asList => thanks to @Valefant for the implementation
- #172 Iterable.containsNoDuplicates => thanks to @frikit for the implementation
- #480 accept date as string in ISO 8601 format for ChronoLocalDate => thanks to @Valefant for implementation
- #482 accept date and time as string in ISO 8601 for ChronoZonedDateTime => thanks to @Valefant for implementation
- #591 Path.isExecutable => thanks to @jGleitz for the implementation
- #629 Path.isAbsolute => thanks to @jakubriegel for the implementation
- #630 Path.isRelative => thanks to @jakubriegel for the implementation
- #590 Path.hasDirectoryEntry => thanks to @jgrgt for the first implementation (api-fluent) and @jGleitz for the completion (generalise to logic and add to infix)
api-fluent-en_GB
- no fluent only additions this time
api-infx-en_GB
- no infix only additions this time
Domain / Core
- ๐ we transition away from atrium-domain-... to atrium-logic, getting rid of ServiceLoader and other changes. Some parts of domain were already deprecated (see below)
๐ Fixes
- #631 Atrium stops working for JS with Kotlin 1.4 => thanks to @chadmarchand for the fix
๐ Improvements
- #628 Report Evaluation Result After notToThrow(), catch exceptions in feature extraction
- #329 fuse FeatureAssertionSpec with AssertionSpec => thanks to @tarczynskitomek for the first few adjustments
- โก๏ธ #349 configure dependabot to update samples => thanks to @uzilan for the implementation
- ๐ #400 check if Js isIntance bug is really fixed in Kotlin => thanks to @Valefant for the time and simplification
- #409 limit representation to 10'000 chars => thanks to @Valefant for the implementation
- #600 make generateLogic more readable with named matches => thanks to @jgrgt for the suggestion and implementation
- โก๏ธ #637 update gradle wrapper => thanks to @fejd
- โก๏ธ #473 update js samples to use the new org.jetbrains.kotlin.js gradle plugin => thanks to @chadmarchand for most of the work
- #643 add samples for anyAssertions => thanks to @jdornieden
- #644 add samples for arrayAssertions => thanks to @jdornieden
- #646 add samples for collectionAssertions => thanks to @Gosunet
- #647 add samples for comparableAssertions => thanks to @Gosunet
- #649 add samples for floatingPointAssertions => thanks to @BimuratMukhtar
- #652 add samples for iteratorAssertions => thanks to @Gosunet
- #653 add samples for listAssertions => thanks to @BimuratMukhtar
- #656 add samples for pairAssertions => thanks to @BimuratMukhtar
๐ฅ Breaking Changes
Planned (previously deprecated or announced)
- ๐ we are no longer using the builders defined in the API for CharSequence/Iterable.contains but the new ones from atrium-logic. This constitutes a binary backward compatibility break. Please re-compile, it is still source compatible.
Unplanned
- ๐ we are no longer using the builders defined in atrium-domain-builders for a subject change and feature extraction but the once from atrium-logic. This constitutes a binary backward compatibility break. Please re-compile, it is still source compatible.
๐ Deprecation
- ๐ฑ the helper function
asExpect
to turn anAssert<T>
into anExpect<T>
=> time to move on ๐ - ๐ most of the module atrium-domain-builders -> use atrium-logic instead, see migration hints further down below. Inter alia:
- SubjectChanger and SubjectChangerBuilder
- FeatureExtractor and FeatureExtractorBuilder
- toVarArg, iterableLikeToIterable
- nullable, nullableContainer, nullableKeyMap etc.
- mapArguments
๐ฅ Breaking Changes with 0.15.0
- ๐ might be we have to break compatibility when we deprecate core-robstoll and core-robstoll-lib
- ๐ might also be, that we have to break compatibility when we move ExpectBuilder and ExpectOptions from domain-builders to atrium-logic
- ๐ we will break binary compatibility when we move Group from atrium-domain-builders to atrium-logic (or to the individual APIs)
- ๐ we will break binary compatibility when we move VarArgHelper from atrium-domain-builders to atrium-logic
๐ฅ Breaking Changes with 1.0.0
๐ See atrium-roadmap -> Milestone 1.0.0
๐ Migrating deprecated functionality
We don't provide
ReplaceWith
to transition from atrium-domain-robstoll/-robstoll-lib to atrium-logic in all cases. We don't expect that there are enough users using types of those modules directly. Let us know if you do and have troubles migrating.In case you should use:
- ๐
mapArguments
, then search forimport ch.tutteli.atrium.domain.builders.utils.mapArguments
and replace it withimport ch.tutteli.atrium.logic.utils.mapArguments
- ๐
nullable
, then search forimport ch.tutteli.atrium.domain.builders.utils.nullable
and replace withimport ch.tutteli.atrium.logic.utils.nullable
- ๐
subExpect
, then search forsubExpect
and replace withexpectLambda
and search forimport ch.tutteli.atrium.domain.builders.utils.subExpect
and replace withimport ch.tutteli.atrium.logic.utils.expectLambda
Some further search&replace patterns for assertion writers, in case you use:
CharSequenceOrNumberOrChar
orCharSequenceOrNumberOrChar
, search forimport ch.tutteli.atrium.domain.creating.typeutils
and replace withimport ch.tutteli.atrium.logic.creating.typeutils
In case you already started using the experimental atrium-logic module, then you might run into the problem that:
getExpectOfFeature()
does not exist => replace with transform()addToInitial
does not exist => replace withcollectAndAppend
- ๐ we removed
genericSubjectBasedFeature
andgenericFeature
from FeatureAssertions -> use either manualFeature or FeatureExtractor/FeatureExtractorBuilder instead
๐ Please have a look at the older release-notes in case you don't migrate from 0.12.0 or 0.13.0
Sponsors
๐ We would like to thank Tegonal GmbH for sponsoring Support and PR-Review time.
Are you are using Atrium at work?
๐ Please consider to support the project as well by:
- sponsoring robstoll (Author and main contributor)
- share your assertion functions with others
- report bugs
- provide feedback in case you miss a feature
Previous changes from v0.12.0
-
API Maturity: Stable
Implementation Maturity: Almost Stable๐ There won't be any breaking changes in the API (assertion functions/builders) until v1.0.0 besides parameter name renaming and experimental features. But we want to progress as well and deprecate functionality in each version (e.g quite a lot with 0.7.0; please replace deprecated functionality until v1.0.0 where we will remove it).
โ However, we do not provide yet a stable API for the domain and core modules of Atrium -- it is almost stable, but there might be slight breaking changes which we want to introduce before v1.0.0. That is also the reason why we do not have yet established backward compatibility tests for domain/core. This might affect you if you write your own assertion functions. And it also affects you if you provide your own implementation for parts of Atrium.Table of Content
- New Features
- ๐ Fixes
- Improvments
- Breaking Changes
- ๐ Deprecation
- ๐ Migrating deprecated functionality
๐ New Features
api-fluent-en_GB
๐ new api-infix-en_GB
Thanks to the following contributors to support the migration from cc-infix-en_GB to infix-en_GB:
- #227 collectionAssertions => thanks to @ratkayandras
- #231 pairAssertions => thanks to @dexpota
- #228 listAssertions => thanks to @sanatik
- #232 sequenceAssertions => thanks to @ivanmiklec
- #229 mapAssertions => thanks to @jlundhol
- #230 mapEntryAssertions => thanks to @johnGachihi
- #226 arrayAssertions => thanks to @isfedorov
- #233 bigDecimalAssertions => thanks to @isfedorov
- #236 create bundles for the new infix API => thanks to @isfedorov
- #316 fileAssertions => thanks to @jGleitz
- #317 localDateAssertions => thanks to @jGleitz
- #318 localDateTimeAssertions => thanks to @jGleitz
- #319 zonedDateTimeAssertions=> thanks to @tfesenko
- #313 chronoLocalDateAssertions => thanks to @ivanmiklec
- #314 chronoLocalDateTimeAssertions => thanks to @isfedorov
- #315 chronoZonedDateTimeAssertions => thanks to @tfesenko
- #388 optionalAssertions => thanks to @isfedorov
kotlin 1.3 extensions
- #389 resultAssertions => thanks to @ivanmiklec
Domain / Core
- none this time
๐ Fixes
- none this time
๐ Improvements
- ๐ #235 setup code coverage for windows=> thanks to @ivanmiklec
- ๐ #245 Build samples as composite build => thanks to @assaflei
#/167 compile android class files into dex bytecode => thanks to @assaflei - ๐ #493 merge jdk8 extension into jvm module => thanks to @assaflei
- #470 create maven sample project => thanks to @binkley
- #466 fail if a TranslatableWithArgs has not exact arguments => thanks to @tkech17
- #495 cache gradle and dependencies in github actions => thanks to @assaflei
- ๐ #506 remove android jars -> they are no longer required => thanks to @ultraon for checking if the module-info.class bug was really resolved in d8
๐ฅ Breaking Changes
Planned (previously deprecated or announced)
- none this time (yet we no longer publish a dedicated
-android
jar you can use the regular jvm artifact instead)
Unplanned
- none this time
๐ Deprecation
๐ The following was deprecated and will be removed with 1.0.0:
- API cc-infix-en_GB => use infix-en_GB, fluent-en_GB respectively => a big thank you to @Miftahunajat for the many ReplaceWith he placed all over api-cc-infix to ease the migration ๐
- the jdk8 extension was merged into the normal module => search
import ch.tutteli.atrium.api.fluent.en_GB.jdk8
replace withimport ch.tutteli.atrium.api.fluent.en_GB
๐ฅ Breaking Changes with 1.0.0
๐ See atrium-roadmap -> Milestone 1.0.0
๐ Migrating deprecated functionality
API fluent
โก๏ธ There aren't any deprecations in api-fluent-en_GB in this version and thus also no migration required if you update from 0.9.x, 0.10.0 or 0.11.0
๐ In case you used the jdk8 extension: it was merged into the main artifact:
- perform a search for
import ch.tutteli.atrium.api.fluent.en_GB.jdk8
and replace withimport ch.tutteli.atrium.api.fluent.en_GB
- โ remove the corresponding dependency
API infix
You should migrate from api-cc-infix-en_GB to the new api-infix-en_GB (api-cc-infix-en_GB will be removed with 1.0.0)
๐ In case you migrate from a version < 0.7.0 to this version, then please have a look at the migration guide given in the Release notes of v0.7.0 and v0.8.0 first.Otherwise you can use the suggested replacements (ALT + Enter -> Replace with ...) or the search/replace patterns shown below (recommended, since faster).
Notice, that you don't have to migrate everything at once where
asExpect
andasAssert
allow to switch between the oldAssert
and the newExpect
world.
Ping us in the Atrium slack channel if you need help.The following command is carrying out the points 1 to 14 as described below. The script for 15a or 15b follows afterwards (don't forget to do the manual points 16, 17, ...), run it from the root of your project, no guarantees that your system is capable of carrying it out. If not, you can use the manual steps described below.
find ./ -path "*/test/*" -name "*.kt" | xargs perl -0777 -i \ -pe 's/AssertImpl([\n\r\s]*)\.changeSubject\(([^\)\n]+)\)[\n\r\s]*\{[\n\r\s]*subject/ExpectImpl$1.changeSubject\($2\)$1.unreported \{ it/g;' \ -pe 's/AssertImpl([\n\r\s]*)\.changeSubject\(([^\)]+)\)/ExpectImpl$1.changeSubject\($2\).unreported/g;' \ -pe 's/AssertImpl([\n\r\s]*)\.builder([\n\r\s]*)\.createDescriptive\(([^,\n]+,[^\)]+\)[\n\r\s]*\{[\n\r\s]*)plant.subject/AssertImpl([\n\r\s]*)\.builder([\n\r\s]*)\.createDescriptive\(([^,\n]+,[^\)]+\)[\n\r\s]*\{[\n\r\s]*)plant.subject/g;' \ -pe 's/AssertImpl([\n\r\s]*)\.builder([\n\r\s]*)\.descriptive([\n\r\s]*).withTest(\(?[\n\r\s]*)\{([\n\r\s]*)plant.subject/AssertImpl$1.builder$2.descriptive$3.withTest\(plant\)$4\{$5it/g;' \ -pe 's/AssertImpl([\n\r\s]*)\.builder([\n\r\s]*)\.descriptive([\n\r\s]*).withTest(\(?[\n\r\s]*)\{([\n\r\s]*)subject/AssertImpl$1.builder$2.descriptive$3.withTest\(this\)$4\{$5it/g;' \ -pe 's/(\.| )((?:toThrow|isA)<.*>)\s*\{\s*\}/$1$2()/g;' \ -pe 's/notToBeNull\s*\{\s*\}/notToBe null/g;' \ -pe 's/fun <T\s*:\s*Any> ([^\(]+)\(subject:\s*T\)[\n\r\s]*=[\n\r\s]*AssertImpl[\n\r\s]*\.coreFactory[\n\r\s]*\.newReportingPlant\(([^,]+),[\n\r\s]*\{\s*subject\s*\}[\n\r\s]*,[\n\r\s]*reporter\)/fun <T> $1\(subject: T\): Expect<T> = \n ExpectBuilder.forSubject\(subject\)\n .withVerb\($2\)\n .withoutOptions\(\)\n .build\(\)/g;' \ -pe 's/fun <T\s*:\s*Any> ([^\(]+)\(subject:\s*T\s*,[\n\r\s]*assertionCreator: Assert<T>.\(\)\s*->\s*Unit\)[\n\r\s]*=[\n\r\s]*AssertImpl[\n\r\s]*\.coreFactory[\n\r\s]*\.newReportingPlantAndAddAssertionsCreatedBy\(([^,]+),[\n\r\s]*\{\s*subject\s*\}[\n\r\s]*,[\n\r\s]*reporter,[\n\r\s]*assertionCreator\)/fun <T> $1\(subject: T, assertionCreator: Expect<T>.\(\) -> Unit\): Expect<T> = \n $1(subject).addAssertionsCreatedBy(assertionCreator)/g;' \ -pe 's/(?:internal )?fun <T(?:\s*:\s*Any\?)?> ([^\(]+)\(subject:\s*T\)[\n\r\s]*=[\n\r\s]*AssertImpl[\n\r\s]*\.coreFactory[\n\r\s]*\.newReportingPlantNullable\(([^,]+),[\n\r\s]*\{\s*subject\s*\}[\n\r\s]*,[^\)]+\)//g;' \ -pe 's/import ch.tutteli.atrium.verbs\.(expect|assert|assertThat)/import ch.tutteli.atrium.api.verbs.$1/g;' \ -pe 's/AssertImpl/ExpectImpl/g;' \ -pe 's/fun Assert(?:ionPlant(?:Nullable)?)?<(.*)>\./fun <T: $1> Expect<T>\./g;' \ -pe 's/Assert(ionPlant(Nullable)?)?</Expect</g;' \ -pe 's/import ch\.tutteli\.atrium\.creating\.Assert(ionPlant(Nullable)?)?/import ch.tutteli.atrium.creating.Expect/g;' \ -pe 's/import ch.tutteli\.atrium\.api\.cc\.infix\.en_GB/import ch.tutteli.atrium.api.infix.en_GB/g;' \ -pe 's/is(Less|Greater)OrEquals/is$1ThanOrEqual/g;' \ -pe 's/\.asIterable\(\)/ asList o/g;' \ -pe 's/asIterable(\s*\{)/asList$1/g;' \ -pe 's/\.asEntries\(\)/ asEntries o/g;' \ -pe 's/ o / it /g;' \ -pe 's/get\s*Index\(([^\)]+)\)\s*assertIt\s*\{([^\}]+)\}/get index($1) {$2}/g;' \ -pe 's/import ch.tutteli.atrium.api.infix.en_GB.Index/import ch.tutteli.atrium.api.infix.en_GB.index/g;' \ -pe 's/getExisting\s*Key\(([^\)]+)\)\s*assertIt\s*\{([^\}]+)\}/getExisting key($1) {$2}/g;' \ -pe 's/import ch.tutteli.atrium.api.infix.en_GB.Key/import ch.tutteli.atrium.api.infix.en_GB.key/g;'
In case you use Kotlin 1.4 or have enabled the new type inference, then you can use the following script to carry out point 13a:
find ./ -path "*/test/*" -name "*.kt" | xargs perl -0777 -i \ -pe 's/((?:[\n\r]+|\{)\s*)(?:property|returnValueOf|rueckgabewertVon)\((?:[\n\r\s]*)subject::([^\)]+)\)(\s*\{)/$1its feature of(\{ f(it::$2) \})$3/g;' \ -pe 's/(?:property|returnValueOf|rueckgabewertVon)\((?:[\n\r\s]*)subject::([^\)]+)\)(\s*\{)/feature of(\{ f(it::$1) \})$2/g;' \ -pe 's/((?:[\n\r]+|\{)\s*)(?:property|returnValueOf|rueckgabewertVon)\((?:[\n\r\s]*)subject::([^\)]+)\)/$1its feature \{ f(it::$2) \}/g;' \ -pe 's/(?:property|returnValueOf|rueckgabewertVon)\((?:[\n\r\s]*)subject::([^\)]+)\)/feature \{ f(it::$1) \}/g;' \ -pe 's/((?:[\n\r]+|\{)\s*)(?:property|returnValueOf|rueckgabewertVon)\(([A-Z][^:]+)::([^\)]+)\)(\s*\{)/$1its feature of($2::$3)$4/g;' \ -pe 's/(?:property|returnValueOf|rueckgabewertVon)\(([A-Z][^:]+)::([^\)]+)\)(\s*\{)/feature of($1::$2)$3/g;' \ -pe 's/((?:[\n\r]+|\{)\s*)(?:property|returnValueOf|rueckgabewertVon)\(([A-Z][^:]+)::([^\),]+)\)/$1 its feature($2::$3)/g;' \ -pe 's/(?:property|returnValueOf|rueckgabewertVon)\(([A-Z][^:]+)::([^\),]+)\)/feature($1::$2)/g;' \ -pe 's/((?:[\n\r]+|\{)\s*)(?:property|returnValueOf|rueckgabewertVon)\(([A-Z][^:]+)::([^\)]+)\)/$1its feature of($2::$3)/g;' \ -pe 's/(?:property|returnValueOf|rueckgabewertVon)\(([A-Z][^:]+)::([^\)]+)\)/feature of($1::$2)/g;' \ -pe 's/((?:[\n\r]+|\{)\s*)(?:property|returnValueOf|rueckgabewertVon)\(([^:]+)::([^\)]+)\)/$1its feature of("$2.$3") { $2.$3 }/g;' \ -pe 's/(?:property|returnValueOf|rueckgabewertVon)\(([^:]+)::([^\)]+)\)/feature("$1.$2", { $1.$2 })/g;' \ -pe 's/(import ch\.tutteli\.atrium\.api\.cc\.(?:\.infix)?(?:en_GB|de_CH))\.(property|returnValueOf)/$1.feature/g;' \
Otherwise you need to carry out the point 13b which can be done with the following script`
find ./ -path "*/test/*" -name "*.kt" | xargs perl -0777 -i \ -pe 's/((?:[\n\r]+|\{)\s*)(?:property|returnValueOf|rueckgabewertVon)\((?:[\n\r\s]*)subject::([^\)]+)\)(\s*\{)/$1its feature \{ f(it::$2) \} it$3/g;' \ -pe 's/(?:property|returnValueOf|rueckgabewertVon)\((?:[\n\r\s]*)subject::([^\)]+)\)(\s*\{)/feature \{ f(it::$1) \} it$2/g;' \ -pe 's/((?:[\n\r]+|\{)\s*)(?:property|returnValueOf|rueckgabewertVon)\((?:[\n\r\s]*)subject::([^\)]+)\)/$1its feature \{ f(it::$2) \}/g;' \ -pe 's/(?:property|returnValueOf|rueckgabewertVon)\((?:[\n\r\s]*)subject::([^\)]+)\)/feature \{ f(it::$1) \}/g;' \ -pe 's/((?:[\n\r]+|\{)\s*)(?:property|returnValueOf|rueckgabewertVon)\(([A-Z][^:]+)::([^\)]+)\)(\s*\{)/$1its feature of($2::$3)$4/g;' \ -pe 's/(?:property|returnValueOf|rueckgabewertVon)\(([A-Z][^:]+)::([^\)]+)\)(\s*\{)/feature of($1::$2)$3/g;' \ -pe 's/((?:[\n\r]+|\{)\s*)(?:property|returnValueOf|rueckgabewertVon)\(([A-Z][^:]+)::([^\),]+)\)/$1 its feature($2::$3)/g;' \ -pe 's/(?:property|returnValueOf|rueckgabewertVon)\(([A-Z][^:]+)::([^\),]+)\)/feature($1::$2)/g;' \ -pe 's/((?:[\n\r]+|\{)\s*)(?:property|returnValueOf|rueckgabewertVon)\(([A-Z][^:]+)::([^\)]+)\)/$1its feature of($2::$3)/g;' \ -pe 's/(?:property|returnValueOf|rueckgabewertVon)\(([A-Z][^:]+)::([^\)]+)\)/feature of($1::$2)/g;' \ -pe 's/((?:[\n\r]+|\{)\s*)(?:property|returnValueOf|rueckgabewertVon)\(([^:]+)::([^\)]+)\)/$1its feature of("$2.$3") { $2.$3 }/g;' \ -pe 's/(?:property|returnValueOf|rueckgabewertVon)\(([^:]+)::([^\)]+)\)/feature("$1.$2", { $1.$2 })/g;' \ -pe 's/(import ch\.tutteli\.atrium\.api\.cc\.(?:\.infix)?(?:en_GB|de_CH))\.(property|returnValueOf)/$1.feature/g;'
โช But you still need to add manually
import ch.tutteli.atrium.api.infix.en_GB.workaround.it
whereit
is not known
In case you cannot carry out the commands above, then read on to perform the manual steps:
The following list helps you to migrate faster by using a few regex search replace commands (in Intellij). Make sure you have checked
Regex
as well asMatch Case
in the search options. Notice, that the code will certainly not compile after a single replace, you need to carry out all search&replace commands.
It is not perfect, maybe you need to do a few adjustments in addition, let us now and we improve the search/replace commands here.Switch to ExpectImpl.changeSubject instead of using AssertImpl.changeSubject:
Search:AssertImpl([\n\r\s]*)\.changeSubject\(([^\)\n]+)\)[\n\r\s]*\{[\n\r\s]*subject
Replace:ExpectImpl$1.changeSubject\($2\)$1.unreported { it
Search:
AssertImpl([\n\r\s]*)\.changeSubject\(([^\)]+)\)
Replace:ExpectImpl$1.changeSubject\($2\).unreported
๐ builder.descriptive, safe withTest
๐ Search:
AssertImpl([\n\r\s]*)\.builder([\n\r\s]*)\.createDescriptive\(([^,\n]+,[^\)]+\)[\n\r\s]*\{[\n\r\s]*)plant.subject
๐ Replace:AssertImpl$1.builder$2.createDescriptive\(plant, $3it
๐ Search:
AssertImpl([\n\r\s]*)\.builder([\n\r\s]*)\.descriptive([\n\r\s]*).withTest(\(?[\n\r\s]*)\{([\n\r\s]*)plant.subject
๐ Replace:AssertImpl$1.builder$2.descriptive$3.withTest\(plant\)$4{$5it
๐ Search:
AssertImpl([\n\r\s]*)\.builder([\n\r\s]*)\.descriptive([\n\r\s]*).withTest(\(?[\n\r\s]*)\{([\n\r\s]*)subject
๐ Replace:AssertImpl$1.builder$2.descriptive$3.withTest\(this\)$4{$5it
toThrow and isA with empty assertionCreator lambda
Search:(\.| )((?:toThrow|wirft|isA|istEin)<.*>)\s*\{\s*\}
Replace$1$2()
notToBeNull with empty assertionCreator lambda
Search:notToBeNull\s*\{\s*\}
Replace:notToBe null
migrate custom assertion verbs:
Search:
fun <T\s*:\s*Any> ([^\(]+)\(subject:\s*T\)[\n\r\s]*=[\n\r\s]*AssertImpl[\n\r\s]*\.coreFactory[\n\r\s]*\.newReportingPlant\(([^,]+),[\n\r\s]*\{\s*subject\s*\}[\n\r\s]*,[\n\r\s]*reporter\)
Replace:
๐fun <T> $1\(subject: T\): Expect<T> = \n ExpectBuilder.forSubject\(subject\)\n .withVerb\($2\)\n .withoutOptions\(\)\n .build\(\)
Search:
fun <T\s*:\s*Any> ([^\(]+)\(subject:\s*T\s*,[\n\r\s]*assertionCreator: Assert<T>.\(\)\s*->\s*Unit\)[\n\r\s]*=[\n\r\s]*AssertImpl[\n\r\s]*\.coreFactory[\n\r\s]*\.newReportingPlantAndAddAssertionsCreatedBy\(([^,]+),[\n\r\s]*\{\s*subject\s*\}[\n\r\s]*,[\n\r\s]*reporter,[\n\r\s]*assertionCreator\)
Replace:
fun <T> $1\(subject: T, assertionCreator: Expect<T>.\(\) -> Unit\): Expect<T> = \n $1(subject).addAssertionsCreatedBy(assertionCreator)
Search:
(?:internal )?fun <T(?:\s*:\s*Any\?)?> ([^\(]+)\(subject:\s*T\)[\n\r\s]*=[\n\r\s]*AssertImpl[\n\r\s]*\.coreFactory[\n\r\s]*\.newReportingPlantNullable\(([^,]+),[\n\r\s]*\{\s*subject\s*\}[\n\r\s]*,[^\)]+\)
Replace:(empty string)
In case the above search&replace did not find anything (because your code is different):
๐จ Switch fromAssertImpl.coreFactory.newReportingPlant
toExpectBuilder
๐ => see atriumVerbs.kt for an example of how own assertion verbs are defined now; or use the suggested replacements but please addimport ch.tutteli.atrium.domain.builders.reporting.ExpectBuilder
first as it will not work correctly otherwise due to an Intellij bug
=> Note that you don't need a verb for nullable types any more. Thus:- remove the upper bound
T: Any
- remove the verb which uses `newReportingPlantNullable
- remove the verb which expected
act: () -> Unit
Switch to new built-in assertion verbs which use Expect
Search: import ch.tutteli.atrium.verbs.(expect|assert|assertThat)
Replace: import ch.tutteli.atrium.api.verbs.$1Switch from AssertImpl to ExpectImpl
Search:
AssertImpl
Replace:ExpectImpl
Switch all your assertion functions to use Expect and no longer Assert:
Search:
import ch\.tutteli\.atrium\.creating\.Assert(ionPlant(Nullable)?)?
Replace:import ch.tutteli.atrium.creating.Expect
Search:
fun Assert(?:ionPlant(?:Nullable)?)?<(.*)>\.
Replace:fun <T: $1> Expect<T>\.
Search:
Assert(ionPlant(Nullable)?)?<
Replace:Expect<
Switch the API
Search:
import ch.tutteli\.atrium\.api\.cc\.infix\.en_GB Replace:
import ch.tutteli.atrium.api.infix`isLessOr/isGreaterOrEquals
Search:
is(Less|Greater)OrEquals
Replace:is$1ThanOrEqual
11 use asList instead of asIterable and replace
asEntries()
Search:
\.asIterable\(\)
Replace:asList o
Search:
asIterable(\s*\{)
Replace:asList$1
Search:
asEntries\(\)
Replace:asEntries o
12 List get Index assertIt
This one has to be done with care as there could be nested assertion group blocksSearch:
get\s*Index\(([^\)]+)\)\s*assertIt\s*\{([^\}]+)\}
Replace:get index($1) {$2}
Search:
import ch.tutteli.atrium.api.infix.en_GB.Index
Replace:import ch.tutteli.atrium.api.infix.en_GB.index
13 Map getExisting Key assertIt
This one has to be done with care as there could be nested assertion group blocksSearch:
getExisting\s*Key\(([^\)]+)\)\s*assertIt\s*\{([^\}]+)\}
Replace:getExisting key($1) {$2}
Search:
import ch.tutteli.atrium.api.infix.en_GB.Key
Replace:import ch.tutteli.atrium.api.infix.en_GB.key
14 use
it
instead ofo
inside assertion groups:
Search:o
Replace:it
(you can also replace byits
)15a. use new feature mechanism - replacements for Kotlin 1.4 or the new inference (skip to 13b in case you use Kotlin < 1.4)
This one needs extra care as arguments could be function calls. Verify the replacements
Search:
((?:[\n\r]+|\{)\s*)(?:property|returnValueOf|rueckgabewertVon)\((?:[\n\r\s]*)subject::([^\)]+)\)(\s*\{)
Replace:$1its feature of(\{ f(it::$2) \})$3
Search:
(?:property|returnValueOf|rueckgabewertVon)\((?:[\n\r\s]*)subject::([^\)]+)\)(\s*\{)
Replace:feature of(\{ f(it::$1) \})$2
Search:
((?:[\n\r]+|\{)\s*)(?:property|returnValueOf|rueckgabewertVon)\((?:[\n\r\s]*)subject::([^\)]+)\)
Replace:$1its feature \{ f(it::$2) \}
Search:
(?:property|returnValueOf|rueckgabewertVon)\((?:[\n\r\s]*)subject::([^\)]+)\)
Replace:feature \{ f(it::$1) \}
Search:
((?:[\n\r]+|\{)\s*)(?:property|returnValueOf|rueckgabewertVon)\(([A-Z][^:]+)::([^\)]+)\)(\s*\{)
Replace:$1its feature of($2::$3)$4
Search:
(?:property|returnValueOf|rueckgabewertVon)\(([A-Z][^:]+)::([^\)]+)\)(\s*\{)
Replace:feature of($1::$2)$3
Search:
((?:[\n\r]+|\{)\s*)(?:property|returnValueOf|rueckgabewertVon)\(([A-Z][^:]+)::([^\),]+)\)
Replace:$1 its feature($2::$3)
Search:
(?:property|returnValueOf|rueckgabewertVon)\(([A-Z][^:]+)::([^\),]+)\)
Replace:feature($1::$2)
Search:
((?:[\n\r]+|\{)\s*)(?:property|returnValueOf|rueckgabewertVon)\(([A-Z][^:]+)::([^\)]+)\)
Replace:$1its feature of($2::$3)
Search:
(?:property|returnValueOf|rueckgabewertVon)\(([A-Z][^:]+)::([^\)]+)\)
Replace:feature of($1::$2)
Search:
((?:[\n\r]+|\{)\s*)(?:property|returnValueOf|rueckgabewertVon)\(([^:]+)::([^\)]+)\)
Replace:$1its feature of("$2.$3") { $2.$3 }
Search:
(?:property|returnValueOf|rueckgabewertVon)\(([^:]+)::([^\)]+)\)
Replace:feature("$1.$2", { $1.$2 })
Search:
(import ch\.tutteli\.atrium\.api\.cc\.(?:\.infix)?(?:en_GB|de_CH))\.(property|returnValueOf)
Replace:$1.feature
15b use new feature mechanism - replacements for Kotlin < 1.4 (skip if you already applied 11a)
This one needs extra care as arguments could be function calls. Verify the replacements
Search:
((?:[\n\r]+|\{)\s*)(?:property|returnValueOf|rueckgabewertVon)\((?:[\n\r\s]*)subject::([^\)]+)\)(\s*\{)
โ addimport ch.tutteli.atrium.api.infix.en_GB.workaround.it
to those filesSearch again for:
((?:[\n\r]+|\{)\s*)(?:property|returnValueOf|rueckgabewertVon)\((?:[\n\r\s]*)subject::([^\)]+)\)(\s*\{)
Replace:$1its feature \{ f(it::$2) \} it$3
Search:
(?:property|returnValueOf|rueckgabewertVon)\((?:[\n\r\s]*)subject::([^\)]+)\)(\s*\{)
Replace:feature \{ f(it::$1) \} it$2
Search:
((?:[\n\r]+|\{)\s*)(?:property|returnValueOf|rueckgabewertVon)\((?:[\n\r\s]*)subject::([^\)]+)\)
Replace:$1its feature \{ f(it::$2) \}
Search:
(?:property|returnValueOf|rueckgabewertVon)\((?:[\n\r\s]*)subject::([^\)]+)\)
Replace:feature \{ f(it::$1) \}
Search:
((?:[\n\r]+|\{)\s*)(?:property|returnValueOf|rueckgabewertVon)\(([A-Z][^:]+)::([^\)]+)\)(\s*\{)
Replace:$1its feature of($2::$3)$4
Search:
(?:property|returnValueOf|rueckgabewertVon)\(([A-Z][^:]+)::([^\)]+)\)(\s*\{)
Replace:feature of($1::$2)$3
Search:
((?:[\n\r]+|\{)\s*)(?:property|returnValueOf|rueckgabewertVon)\(([A-Z][^:]+)::([^\),]+)\)
Replace:$1 its feature($2::$3)
Search:
(?:property|returnValueOf|rueckgabewertVon)\(([A-Z][^:]+)::([^\),]+)\)
Replace:feature($1::$2)
Search:
((?:[\n\r]+|\{)\s*)(?:property|returnValueOf|rueckgabewertVon)\(([A-Z][^:]+)::([^\)]+)\)
Replace:$1its feature of($2::$3)
Search:
(?:property|returnValueOf|rueckgabewertVon)\(([A-Z][^:]+)::([^\)]+)\)
Replace:feature of($1::$2)
Search:
((?:[\n\r]+|\{)\s*)(?:property|returnValueOf|rueckgabewertVon)\(([^:]+)::([^\)]+)\)
Replace:$1its feature of("$2.$3") { $2.$3 }
Search:
(?:property|returnValueOf|rueckgabewertVon)\(([^:]+)::([^\)]+)\)
Replace:feature("$1.$2", { $1.$2 })
Search:
(import ch\.tutteli\.atrium\.api\.cc\.(?:\.infix)?(?:en_GB|de_CH))\.(property|returnValueOf)
Replace:$1.feature
โช But you still need to add manually
import ch.tutteli.atrium.api.infix.en_GB.workaround.it
whereit
is not known16 In case you have custom assertion verbs
Dealing with thrown exceptions is now handled byExpect
as well.
๐ป However, in case you have named the assertion verb differently for expecting an Exception then you have to decide:- ๐ use the same name => rename the corresponding function which expects
act: () -> Unit
to the same name and remove it afterwards - ๐ use a different name => delegate the function which expects
act: () -> Unit
to the other verb
๐ Check if you need to add
import ch.tutteli.atrium.domain.builders.reporting.ExpectBuilder
Try to reduce duplicated Expect imports
Repeat until you don't have duplicate imports any more
Search:import ch\.tutteli\.atrium\.creating\.Expect\n\s*import ch\.tutteli\.atrium\.creating\.Expect
Replace:import ch.tutteli.atrium.creating.Expect
โ Try to compile your project and watch out for the following warnings:
'MyClass' is a final type, and thus a value of the type parameter is predetermined
=> you can suppress this warning by adding@file:Suppress("FINAL_UPPER_BOUND")
to your file, this is actually a Kotlin bug (https://youtrack.jetbrains.com/issue/KT-34257)