Skip to content

Commit

Permalink
Merge pull request #816 from robstoll/change-deprecation-to-0.17.0
Browse files Browse the repository at this point in the history
Change deprecation removal to 0.17.0
  • Loading branch information
robstoll authored Feb 18, 2021
2 parents 3a1025c + a93f992 commit fc31761
Show file tree
Hide file tree
Showing 19 changed files with 184 additions and 29 deletions.
4 changes: 2 additions & 2 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ coverage:

codecov:
notify:
after_n_builds: 4
after_n_builds: 5
comment:
after_n_builds: 4
after_n_builds: 5
3 changes: 3 additions & 0 deletions apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
]
Expand Down
4 changes: 4 additions & 0 deletions apis/infix-en_GB/atrium-api-infix-en_GB-jvm/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Int>.isEven() = createAndAddAssertion(IS, Text("an even number")) { it % 2 == 0 }

fun Expect<Int>.isMultipleOf(base: Int): Expect<Int> = _logicAppend { isMultipleOf(base) }
Expand Down
14 changes: 14 additions & 0 deletions bundles/fluent-en_GB/atrium-fluent-en_GB-jvm/build.gradle
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Int>.tobe(@Suppress("UNUSED_PARAMETER") even: even) =
createAndAddAssertion(IS, Text("an even number")) { it % 2 == 0 }

Expand Down
15 changes: 15 additions & 0 deletions bundles/infix-en_GB/atrium-infix-en_GB-jvm/build.gradle
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ fun <R> FeatureExpectOptions(configuration: FeatureExpectOptionsChooser<R>.() ->
*
* 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<R> {
Expand All @@ -62,13 +63,15 @@ interface FeatureExpectOptionsChooser<R> {
* 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))
}

/**
* 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)

/**
Expand All @@ -77,6 +80,7 @@ interface FeatureExpectOptionsChooser<R> {
*
* 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) }

Expand All @@ -92,6 +96,7 @@ interface FeatureExpectOptionsChooser<R> {
*
* 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?) {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
*/
Expand All @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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}."
}
}
Expand All @@ -69,14 +69,14 @@ data class TranslatableWithArgs constructor(val translatable: Translatable, val

companion object {

private fun createList(arg: Any): List<Any> = ArrayList<Any>(1).apply {
add(arg)
}
private fun createList(arg: Any): List<Any> =
ArrayList<Any>(1).apply { add(arg) }

private fun createList(arg1: Any, arg2: Any): List<Any> = ArrayList<Any>(2).apply {
add(arg1)
add(arg2)
}
private fun createList(arg1: Any, arg2: Any): List<Any> =
ArrayList<Any>(2).apply {
add(arg1)
add(arg2)
}

private fun createList(arg1: Any, arg2: Any, otherArgs: Array<out Any>): List<Any> =
ArrayList<Any>(2 + otherArgs.size).apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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<IllegalArgumentException> {
messageContains("use Text.Empty instead")
}
}

it("blank string; does not throw") {
Text(" ")
}
}
})
Original file line number Diff line number Diff line change
@@ -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<IllegalArgumentException> {
its messageContains values(
"No arguments specified"
)
}
}
it("one argument given; throws") {
expect {
TranslatableWithArgs(HELLO, "one")
}.toThrow<IllegalArgumentException> {
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<IllegalArgumentException> {
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<IllegalArgumentException> {
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<IllegalArgumentException> {
its messageContains values(
"No arguments specified"
)
}
}
it("one argument given; throws") {
expect {
TranslatableWithArgs(WITH_2_ARGS, "one")
}.toThrow<IllegalArgumentException> {
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"),

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fun <T> assert(subject: T, assertionCreator: Expect<T>.() -> Unit): Expect<T> =
"`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"
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fun <T> assertThat(subject: T, assertionCreator: Expect<T>.() -> Unit): Expect<T
"`assertThat` 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"
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fun <T> expect(subject: T, assertionCreator: Expect<T>.() -> Unit): Expect<T> =
"`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"
)
)
Expand Down

0 comments on commit fc31761

Please sign in to comment.