From 593cd80053b5ba4779c1f066505bdca7d9bbfae5 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Thu, 18 Feb 2021 16:27:28 +0100 Subject: [PATCH 1/4] adjust deprecations regarding removal and remove unused constant --- .../ch/tutteli/atrium/creating/FeatureExpectOptions.kt | 5 +++++ .../ch/tutteli/atrium/reporting/LazyRepresentation.kt | 1 + .../main/kotlin/ch/tutteli/atrium/reporting/RawString.kt | 8 ++++---- .../ch/tutteli/atrium/reporting/StringBasedRawString.kt | 2 +- .../main/kotlin/ch/tutteli/atrium/reporting/constants.kt | 7 ------- .../atrium/reporting/translating/Untranslatable.kt | 4 ++-- 6 files changed, 13 insertions(+), 14 deletions(-) diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/FeatureExpectOptions.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/FeatureExpectOptions.kt index 2bda8f73db..f92c72d256 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/FeatureExpectOptions.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/creating/FeatureExpectOptions.kt @@ -52,6 +52,7 @@ fun FeatureExpectOptions(configuration: FeatureExpectOptionsChooser.() -> * * Calling multiple times the same method overrides the previously defined value. */ +@Suppress("DeprecatedCallableAddReplaceWith", "DEPRECATION") @ExperimentalNewExpectTypes @Deprecated("Use FeatureExpectOptionsChooser from atrium-logic; will be removed with 0.17.0") interface FeatureExpectOptionsChooser { @@ -62,6 +63,7 @@ interface FeatureExpectOptionsChooser { * instead of the previously defined description. * */ + @Deprecated("Use FeatureExpectOptionsChooser from atrium-logic; will be removed with 0.17.0") fun withDescription(description: String) { withDescription(Untranslatable(description)) } @@ -69,6 +71,7 @@ interface FeatureExpectOptionsChooser { /** * Uses the given [description] as custom description instead of the previously defined description. */ + @Deprecated("Use FeatureExpectOptionsChooser from atrium-logic; will be removed with 0.17.0") fun withDescription(description: Translatable) /** @@ -77,6 +80,7 @@ interface FeatureExpectOptionsChooser { * * In case [AssertionContainer.maybeSubject] is not defined i.e. [None], then the previous representation is used. */ + @Deprecated("Use FeatureExpectOptionsChooser from atrium-logic; will be removed with 0.17.0") fun withRepresentation(textRepresentation: String): Unit = withRepresentation { Text(textRepresentation) } @@ -92,6 +96,7 @@ interface FeatureExpectOptionsChooser { * * In case [AssertionContainer.maybeSubject] is not defined i.e. [None], then the previous representation is used. */ + @Deprecated("Use FeatureExpectOptionsChooser from atrium-logic; will be removed with 0.17.0") fun withRepresentation(representationProvider: (R) -> Any) companion object { diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/reporting/LazyRepresentation.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/reporting/LazyRepresentation.kt index f44c12cb21..48ce2b9b8c 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/reporting/LazyRepresentation.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/reporting/LazyRepresentation.kt @@ -9,6 +9,7 @@ import ch.tutteli.atrium.assertions.FeatureAssertionGroupType * For instance, an [AssertionGroup] with a [FeatureAssertionGroupType] has typically a * [AssertionGroup.representation] with a [LazyRepresentation]. */ +//TODO 1.0.0 still required? class LazyRepresentation(private val provider: () -> Any?) { /** diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/reporting/RawString.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/reporting/RawString.kt index a95842631c..3624908590 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/reporting/RawString.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/reporting/RawString.kt @@ -9,14 +9,14 @@ import ch.tutteli.atrium.reporting.translating.TranslatableBasedRawString * Marker interface for types which provide a raw string functionality * and should be treated accordingly in reporting (e.g., in [ObjectFormatter]). */ -@Deprecated("Use Text instead; will be removed latest with 1.0.0", ReplaceWith("Text")) +@Deprecated("Use Text instead; will be removed with 0.17.0", ReplaceWith("Text")) interface RawString { companion object { /** * The representation for `null` as [StringBasedRawString]. */ @Deprecated( - "use Text.NULL instead; will be removed latest with 1.0.0", + "use Text.NULL instead; will be removed with 0.17.0", ReplaceWith("Text.NULL", "ch.tutteli.atrium.reporting.Text") ) val NULL = StringBasedRawString("null") @@ -25,13 +25,13 @@ interface RawString { * An empty string as [RawString]. */ @Deprecated( - "use Text.EMPTY instead; will be removed latest with 1.0.0", + "use Text.EMPTY instead; will be removed with 0.17.0", ReplaceWith("Text.EMPTY", "ch.tutteli.atrium.reporting.Text") ) val EMPTY = StringBasedRawString("") @Deprecated( - "Use Text.create instead; will be removed latest with 1.0.0", + "Use Text.create instead; will be removed with 0.17.0", ReplaceWith("Text(string)", "ch.tutteli.atrium.reporting.Text") ) fun create(string: String): RawString = StringBasedRawString(string) diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/reporting/StringBasedRawString.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/reporting/StringBasedRawString.kt index 6a043c5ef8..bb704866b2 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/reporting/StringBasedRawString.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/reporting/StringBasedRawString.kt @@ -12,7 +12,7 @@ package ch.tutteli.atrium.reporting * @constructor Use [RawString.create] to create a [String] based [RawString]. * @param string The string which should be treated as raw [String]. */ -@Deprecated("Switch from StringBasedRawString to Text; will be removed latest with 1.0.0", ReplaceWith("Text(string)")) +@Deprecated("Switch from StringBasedRawString to Text; will be removed with 0.17.0", ReplaceWith("Text(string)")) data class StringBasedRawString internal constructor(val string: String) : RawString { /** diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/reporting/constants.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/reporting/constants.kt index 805a708dd7..dd80ac0776 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/reporting/constants.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/reporting/constants.kt @@ -1,8 +1,5 @@ package ch.tutteli.atrium.reporting -import ch.tutteli.atrium.reporting.translating.Translatable -import ch.tutteli.atrium.reporting.translating.Untranslatable - /** * Refers to the bug tracker of Atrium. */ @@ -14,7 +11,3 @@ const val BUG_REPORT_URL = "https://github.com/robstoll/atrium/issues/new" const val SHOULD_NOT_BE_SHOWN_TO_THE_USER_BUG = "Should not be shown to the user; if you see this, please file a bug report at $BUG_REPORT_URL" -/** - * Can be used in places where an argument of type [Translatable] is expected which should never be shown to the user. - */ -val SHOULD_NOT_BE_SHOWN_TO_THE_USER_BUG_TRANSLATABLE = Untranslatable(SHOULD_NOT_BE_SHOWN_TO_THE_USER_BUG) diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/reporting/translating/Untranslatable.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/reporting/translating/Untranslatable.kt index 71fa3629c6..ef7d65af3a 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/reporting/translating/Untranslatable.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/reporting/translating/Untranslatable.kt @@ -10,10 +10,10 @@ package ch.tutteli.atrium.reporting.translating class Untranslatable(representation: String) : Translatable { @Suppress("DEPRECATION") - @Deprecated("Use the overload which expects String; will be removed latest with 1.0.0") + @Deprecated("Use the overload which expects String; will be removed with 0.17.0") constructor(representation: CharSequence) : this({ representation.toString() }) - @Deprecated("Use the overload which expects String; will be removed latest with 1.0.0") + @Deprecated("Use the overload which expects String; will be removed with 0.17.0") constructor(representation: () -> String) : this(representation()) override val name: String = representation From 96e7587684672a231f282c39b33c4eab686f6dac Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Thu, 18 Feb 2021 16:27:47 +0100 Subject: [PATCH 2/4] fix wrong ReplaceWith imports for assertion verbs --- .../src/main/kotlin/ch/tutteli/atrium/api.verbs/assert.kt | 2 +- .../src/main/kotlin/ch/tutteli/atrium/api.verbs/assertThat.kt | 2 +- .../src/main/kotlin/ch/tutteli/atrium/api.verbs/expect.kt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/misc/verbs/atrium-verbs-common/src/main/kotlin/ch/tutteli/atrium/api.verbs/assert.kt b/misc/verbs/atrium-verbs-common/src/main/kotlin/ch/tutteli/atrium/api.verbs/assert.kt index 3277ff336e..24b2d2b6fa 100644 --- a/misc/verbs/atrium-verbs-common/src/main/kotlin/ch/tutteli/atrium/api.verbs/assert.kt +++ b/misc/verbs/atrium-verbs-common/src/main/kotlin/ch/tutteli/atrium/api.verbs/assert.kt @@ -39,7 +39,7 @@ fun assert(subject: T, assertionCreator: Expect.() -> Unit): Expect = "`assert` should not be nested, use `feature` instead.", ReplaceWith( "feature(\"name of the feature\") { newSubject /* see also other overloads which do not require `name of the feature` and provide the subject as parameter, e.g. feature { f(it::yourFeature) } */}", - "ch.tutteli.atrium.api.fluent.de_CH.feature", + "ch.tutteli.atrium.api.infix.en_GB.feature", "ch.tutteli.atrium.api.fluent.en_GB.feature" ) ) diff --git a/misc/verbs/atrium-verbs-common/src/main/kotlin/ch/tutteli/atrium/api.verbs/assertThat.kt b/misc/verbs/atrium-verbs-common/src/main/kotlin/ch/tutteli/atrium/api.verbs/assertThat.kt index df9c557f20..bca64770e4 100644 --- a/misc/verbs/atrium-verbs-common/src/main/kotlin/ch/tutteli/atrium/api.verbs/assertThat.kt +++ b/misc/verbs/atrium-verbs-common/src/main/kotlin/ch/tutteli/atrium/api.verbs/assertThat.kt @@ -39,7 +39,7 @@ fun assertThat(subject: T, assertionCreator: Expect.() -> Unit): Expect expect(subject: T, assertionCreator: Expect.() -> Unit): Expect = "`expect` should not be nested, use `feature` instead.", ReplaceWith( "feature(\"name of the feature\") { newSubject /* see also other overloads which do not require `name of the feature` and provide the subject as parameter, e.g. feature { f(it::yourFeature) } */}", - "ch.tutteli.atrium.api.fluent.de_CH.feature", + "ch.tutteli.atrium.api.infix.en_GB.feature", "ch.tutteli.atrium.api.fluent.en_GB.feature" ) ) From eeccac627c30153a4f2477a3d109b351c6053872 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Thu, 18 Feb 2021 16:29:59 +0100 Subject: [PATCH 3/4] improve error message for TranslatableWithArgs and cover with tests moreover: - also cover the behaviour of Text --- .../atrium-api-fluent-en_GB-jvm/build.gradle | 3 + .../atrium-api-infix-en_GB-jvm/build.gradle | 4 + .../src/test/kotlin/SmokeTest.kt | 2 +- .../atrium-fluent-en_GB-jvm/build.gradle | 14 +++ .../src/test/kotlin/SmokeTest.kt | 1 + .../atrium-infix-en_GB-jvm/build.gradle | 15 +++ .../translating/TranslatableWithArgs.kt | 18 ++-- .../ch/tutteli/atrium/reporting/TextSpec.kt | 23 +++++ .../translating/TranslatableWithArgsSpec.kt | 96 +++++++++++++++++++ 9 files changed, 166 insertions(+), 10 deletions(-) create mode 100644 core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/reporting/TextSpec.kt create mode 100644 core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/reporting/translating/TranslatableWithArgsSpec.kt diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/build.gradle b/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/build.gradle index 958cad7476..cf8a27e118 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/build.gradle +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/build.gradle @@ -3,9 +3,12 @@ description = 'A fluent assertion function API in en_GB with a focus on code com ext.jacoco_additional = [ prefixedProject('translations-en_GB-jvm'), prefixedProject('logic-jvm'), + prefixedProject('core-api-jvm'), + //TODO remove with 0.17.0 prefixedProject('domain-builders-jvm'), prefixedProject('domain-robstoll-jvm'), prefixedProject('domain-robstoll-lib-jvm'), + prefixedProject('domain-api-jvm'), prefixedProject('core-robstoll-jvm'), prefixedProject('core-robstoll-lib-jvm'), ] diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/build.gradle b/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/build.gradle index 40e13d9e5d..439f020cdd 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/build.gradle +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-jvm/build.gradle @@ -2,9 +2,13 @@ description = 'An infix API in en_GB with a focus on code completion for JVM.' ext.jacoco_additional = [ prefixedProject('translations-de_CH-jvm'), + prefixedProject('logic-jvm'), + prefixedProject('core-api-jvm'), + //TODO remove with 0.17.0 prefixedProject('domain-builders-jvm'), prefixedProject('domain-robstoll-jvm'), prefixedProject('domain-robstoll-lib-jvm'), + prefixedProject('domain-api-jvm'), prefixedProject('core-robstoll-jvm'), prefixedProject('core-robstoll-lib-jvm'), ] diff --git a/bundles/fluent-en_GB/atrium-fluent-en_GB-common/src/test/kotlin/SmokeTest.kt b/bundles/fluent-en_GB/atrium-fluent-en_GB-common/src/test/kotlin/SmokeTest.kt index 5de731885b..2806a53906 100644 --- a/bundles/fluent-en_GB/atrium-fluent-en_GB-common/src/test/kotlin/SmokeTest.kt +++ b/bundles/fluent-en_GB/atrium-fluent-en_GB-common/src/test/kotlin/SmokeTest.kt @@ -106,7 +106,7 @@ class SmokeTest { } } - +//TODO 0.17.0 also add test case for using the string overload once we have createAndAppend fun Expect.isEven() = createAndAddAssertion(IS, Text("an even number")) { it % 2 == 0 } fun Expect.isMultipleOf(base: Int): Expect = _logicAppend { isMultipleOf(base) } diff --git a/bundles/fluent-en_GB/atrium-fluent-en_GB-jvm/build.gradle b/bundles/fluent-en_GB/atrium-fluent-en_GB-jvm/build.gradle index d56d7f4c51..d5f7a6c338 100644 --- a/bundles/fluent-en_GB/atrium-fluent-en_GB-jvm/build.gradle +++ b/bundles/fluent-en_GB/atrium-fluent-en_GB-jvm/build.gradle @@ -1,5 +1,19 @@ description = 'Represents a convenience module which merely bundles dependencies for the JVM platform.' +ext.jacoco_additional = [ + prefixedProject('verbs-jvm'), + prefixedProject('translations-en_GB-jvm'), + prefixedProject('logic-jvm'), + prefixedProject('core-api-jvm'), + //TODO remove with 0.17.0 + prefixedProject('domain-builders-jvm'), + prefixedProject('domain-robstoll-jvm'), + prefixedProject('domain-robstoll-lib-jvm'), + prefixedProject('domain-api-jvm'), + prefixedProject('core-robstoll-jvm'), + prefixedProject('core-robstoll-lib-jvm'), +] + dependencies { api prefixedProject('verbs-jvm') api prefixedProject('api-fluent-en_GB-jvm') diff --git a/bundles/infix-en_GB/atrium-infix-en_GB-common/src/test/kotlin/SmokeTest.kt b/bundles/infix-en_GB/atrium-infix-en_GB-common/src/test/kotlin/SmokeTest.kt index 3d76772b02..772f6aedc7 100644 --- a/bundles/infix-en_GB/atrium-infix-en_GB-common/src/test/kotlin/SmokeTest.kt +++ b/bundles/infix-en_GB/atrium-infix-en_GB-common/src/test/kotlin/SmokeTest.kt @@ -54,6 +54,7 @@ class SmokeTest { @Suppress("ClassName") object even +//TODO 0.17.0 also add test case for using the string overload once we have createAndAppend infix fun Expect.tobe(@Suppress("UNUSED_PARAMETER") even: even) = createAndAddAssertion(IS, Text("an even number")) { it % 2 == 0 } diff --git a/bundles/infix-en_GB/atrium-infix-en_GB-jvm/build.gradle b/bundles/infix-en_GB/atrium-infix-en_GB-jvm/build.gradle index e422ce8f7c..497f17ad50 100644 --- a/bundles/infix-en_GB/atrium-infix-en_GB-jvm/build.gradle +++ b/bundles/infix-en_GB/atrium-infix-en_GB-jvm/build.gradle @@ -1,5 +1,20 @@ description = 'Represents a convenience module which merely bundles dependencies for the JVM platform.' +ext.jacoco_additional = [ + prefixedProject('verbs-jvm'), + prefixedProject('translations-en_GB-jvm'), + prefixedProject('logic-jvm'), + prefixedProject('core-api-jvm'), + //TODO remove with 0.17.0 + prefixedProject('domain-builders-jvm'), + prefixedProject('domain-robstoll-jvm'), + prefixedProject('domain-robstoll-lib-jvm'), + prefixedProject('domain-api-jvm'), + prefixedProject('core-robstoll-jvm'), + prefixedProject('core-robstoll-lib-jvm'), +] + + dependencies { api prefixedProject('verbs-jvm') api prefixedProject('api-infix-en_GB-jvm') diff --git a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/reporting/translating/TranslatableWithArgs.kt b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/reporting/translating/TranslatableWithArgs.kt index 257f189fb2..4626919fb6 100644 --- a/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/reporting/translating/TranslatableWithArgs.kt +++ b/core/api/atrium-core-api-common/src/main/kotlin/ch/tutteli/atrium/reporting/translating/TranslatableWithArgs.kt @@ -54,8 +54,8 @@ data class TranslatableWithArgs constructor(val translatable: Translatable, val "\nTranslatable: $translatable" } require(isArgumentsCountMatchedWithTranslatable()) { - "arguments count do not match number of placeholders in [${translatable.getDefault()}]." + - "\nexpected count = ${arguments.size}, actual count = ${getPlaceHoldersCount()}" + + "The number of given arguments does not match the number of placeholders in [${translatable.getDefault()}]." + + "\nnumber of arguments = ${arguments.size}, placeholders = ${getPlaceHoldersCount()}" + "\nspecify exact number of placeholders before wrapping translatable into an ${TranslatableWithArgs::class.simpleName}." } } @@ -69,14 +69,14 @@ data class TranslatableWithArgs constructor(val translatable: Translatable, val companion object { - private fun createList(arg: Any): List = ArrayList(1).apply { - add(arg) - } + private fun createList(arg: Any): List = + ArrayList(1).apply { add(arg) } - private fun createList(arg1: Any, arg2: Any): List = ArrayList(2).apply { - add(arg1) - add(arg2) - } + private fun createList(arg1: Any, arg2: Any): List = + ArrayList(2).apply { + add(arg1) + add(arg2) + } private fun createList(arg1: Any, arg2: Any, otherArgs: Array): List = ArrayList(2 + otherArgs.size).apply { diff --git a/core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/reporting/TextSpec.kt b/core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/reporting/TextSpec.kt new file mode 100644 index 0000000000..fe3421bc36 --- /dev/null +++ b/core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/reporting/TextSpec.kt @@ -0,0 +1,23 @@ +package ch.tutteli.atrium.reporting + +import ch.tutteli.atrium.api.infix.en_GB.* +import ch.tutteli.atrium.api.verbs.internal.expect +import ch.tutteli.atrium.reporting.erroradjusters.NoOpAtriumErrorAdjuster +import org.spekframework.spek2.Spek +import org.spekframework.spek2.style.specification.describe + +class TextSpec : Spek({ + describe("creating a Text") { + it("empty string; throws IllegalArgumentException") { + expect{ + Text("") + }.toThrow { + messageContains("use Text.Empty instead") + } + } + + it("blank string; does not throw") { + Text(" ") + } + } +}) diff --git a/core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/reporting/translating/TranslatableWithArgsSpec.kt b/core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/reporting/translating/TranslatableWithArgsSpec.kt new file mode 100644 index 0000000000..af1fcd6fbb --- /dev/null +++ b/core/api/atrium-core-api-common/src/test/kotlin/ch/tutteli/atrium/reporting/translating/TranslatableWithArgsSpec.kt @@ -0,0 +1,96 @@ +package ch.tutteli.atrium.reporting.translating + +import ch.tutteli.atrium.api.infix.en_GB.* +import ch.tutteli.atrium.api.verbs.internal.expect +import ch.tutteli.atrium.reporting.Text +import ch.tutteli.atrium.reporting.erroradjusters.NoOpAtriumErrorAdjuster +import ch.tutteli.atrium.reporting.translating.Translations.* +import org.spekframework.spek2.Spek +import org.spekframework.spek2.style.specification.describe + +class TranslatableWithArgsSpec : Spek({ + describe("creating a TranslatableWithArgs") { + context("for a translatable without args") { + it("no arguments given; throws") { + expect { + TranslatableWithArgs(HELLO, listOf()) + }.toThrow { + its messageContains values( + "No arguments specified" + ) + } + } + it("one argument given; throws") { + expect { + TranslatableWithArgs(HELLO, "one") + }.toThrow { + its messageContains values( + "The number of given arguments does not match the number of placeholders in", + "number of arguments = 1", + "placeholders = 0" + ) + } + } + } + context("for a translatable with 1 arg") { + it("no arguments given; throws") { + expect { + TranslatableWithArgs(WITH_1_ARG, listOf()) + }.toThrow { + its messageContains values( + "No arguments specified" + ) + } + } + it("one argument given; OK") { + expect(TranslatableWithArgs(WITH_1_ARG, "hello").getDefault()).toBe("a) hello") + expect(TranslatableWithArgs(WITH_1_ARG, listOf("hello")).getDefault()).toBe("a) hello") + } + it("two arguments given; throws") { + expect { + TranslatableWithArgs(WITH_1_ARG, "one", "two") + }.toThrow { + its messageContains values( + "The number of given arguments does not match the number of placeholders in", + "number of arguments = 2", + "placeholders = 1" + ) + } + } + } + context("for a translatable with 2 args") { + it("no arguments given; throws") { + expect { + TranslatableWithArgs(WITH_2_ARGS, listOf()) + }.toThrow { + its messageContains values( + "No arguments specified" + ) + } + } + it("one argument given; throws") { + expect { + TranslatableWithArgs(WITH_2_ARGS, "one") + }.toThrow { + its messageContains values( + "The number of given arguments does not match the number of placeholders in", + "number of arguments = 1", + "placeholders = 2" + ) + } + } + it("two arguments given; OK") { + expect(TranslatableWithArgs(WITH_2_ARGS, "hello", "world").getDefault()).toBe("a) hello b) world") + expect(TranslatableWithArgs(WITH_2_ARGS, listOf("hello", "world")).getDefault()) + .toBe("a) hello b) world") + } + } + } +}) + +private enum class Translations(override val value: String) : StringBasedTranslatable { + HELLO("hello"), + WITH_1_ARG("a) %s"), + WITH_2_ARGS("a) %s b) %s"), + +} From a93f992657804d18fa9b64ec4d627892cbe06cc1 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Thu, 18 Feb 2021 16:54:41 +0100 Subject: [PATCH 4/4] codecov after 5 builds --- .github/codecov.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/codecov.yml b/.github/codecov.yml index 5147a56946..ed2c31f1a2 100644 --- a/.github/codecov.yml +++ b/.github/codecov.yml @@ -15,6 +15,6 @@ coverage: codecov: notify: - after_n_builds: 4 + after_n_builds: 5 comment: - after_n_builds: 4 + after_n_builds: 5