From b913776218e0fe92809a0aaf0b980aefb87a241b Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Mon, 31 May 2021 12:15:23 +0200 Subject: [PATCH] link to sample of isKeyValue and other cleanup --- .../api/infix/en_GB/mapEntryAssertions.kt | 18 ++++---- .../samples/MapEntryExpectationSamples.kt | 44 ++++++------------ .../deprecated/MapEntryAssertionSamples.kt | 45 +++---------------- 3 files changed, 28 insertions(+), 79 deletions(-) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapEntryAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapEntryAssertions.kt index ebf36cbb2..f5ef6f7f0 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapEntryAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/mapEntryAssertions.kt @@ -12,6 +12,8 @@ import ch.tutteli.atrium.logic.* * reporting etc. * * @return an [Expect] for the subject of `this` expectation. + * + * @sample ch.tutteli.atrium.api.infix.en_GB.samples.deprecated.MapEntryAssertionSamples.isKeyValue */ @Deprecated("Use toEqualKeyValue; will be removed with 1.0.0 at the latest", ReplaceWith("this.toEqualKeyValue(keyValuePair)")) infix fun > Expect.isKeyValue(keyValuePair: Pair): Expect = @@ -22,9 +24,9 @@ infix fun > Expect.isKeyValue(keyValuePair: Pair> Expect.key: Expect get() = _logic.key().transform() @@ -35,9 +37,9 @@ val > Expect.key: Expect * holds all assertions the given [assertionCreator] creates for it and * returns an [Expect] for the current subject of `this` expectation. * - * @sample ch.tutteli.atrium.api.infix.en_GB.samples.MapEntryExpectationSamples.key - * * @return an [Expect] for the subject of `this` expectation. + * + * @sample ch.tutteli.atrium.api.infix.en_GB.samples.MapEntryExpectationSamples.key */ infix fun > Expect.key(assertionCreator: Expect.() -> Unit): Expect = _logic.key().collectAndAppend(assertionCreator) @@ -47,9 +49,9 @@ infix fun > Expect.key(assertionCreator: Expect. * Creates an [Expect] for the property [Map.Entry.value] of the subject of `this` expectation, * so that further fluent calls are assertions about it. * - * @sample ch.tutteli.atrium.api.infix.en_GB.samples.MapEntryExpectationSamples.valueFeature - * * @return The newly created [Expect] for the extracted feature. + * + * @sample ch.tutteli.atrium.api.infix.en_GB.samples.MapEntryExpectationSamples.valueFeature */ val > Expect.value: Expect get() = _logic.value().transform() @@ -60,9 +62,9 @@ val > Expect.value: Expect * holds all assertions the given [assertionCreator] creates for it and * returns an [Expect] for the current subject of `this` expectation. * - * @sample ch.tutteli.atrium.api.infix.en_GB.samples.MapEntryExpectationSamples.value - * * @return an [Expect] for the subject of `this` expectation. + * + * @sample ch.tutteli.atrium.api.infix.en_GB.samples.MapEntryExpectationSamples.value */ infix fun > Expect.value(assertionCreator: Expect.() -> Unit): Expect = _logic.value().collectAndAppend(assertionCreator) diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/MapEntryExpectationSamples.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/MapEntryExpectationSamples.kt index e7e6fadf5..366699eff 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/MapEntryExpectationSamples.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/MapEntryExpectationSamples.kt @@ -12,44 +12,32 @@ class MapEntryExpectationSamples { @Test fun toEqualKeyValue() { expect(mapOf(1 to "a").entries.first()) toEqualKeyValue (1 to "a") - // | | | subject here is type of Map.Entry (actually (1 to "a")) - // | | subject here is type of Set> - // | subject here is type of Map - fails { - // fails because (1 to "a") is not equal to (1 to "b") + fails { // because (1 to "a") is not equal to (1 to "b") expect(mapOf(1 to "a").entries.first()) toEqualKeyValue (1 to "b") - // | | | subject here is type of Map.Entry (actually (1 to "a")) - // | | subject here is type of Set> - // | subject here is type of Map } } @Test fun keyFeature() { expect(mapOf(1 to "a").entries.first()).key toEqual 1 - // | | subject here is type of Int (actually 1) - // | subject here is of type Map + // | | subject here is type of Int (actually 1) + // | subject here is of type Map.Entry - fails { - - // fails because 1 is not equal to 2 + fails { // because 1 is not equal to 2 expect(mapOf(1 to "a").entries.first()).key toEqual 2 - // | | subject here is type of Int (actually 1) - // | subject here is of type Map + // | | subject here is type of Int (actually 1) + // | subject here is of type Map.Entry } } @Test fun key() { - // | subject here is of type Map expect(mapOf(1 to "a").entries.first()).key { // subject inside this block is of type Int (actually 1) this toEqual 1 } - fails { - // fails because 1 is not equal to 2 - // | subject here is of type Map + fails { // because 1 is not equal to 2 expect(mapOf(1 to "a").entries.first()).key { // subject inside this block is of type Int (actually 1) this toEqual 2 } @@ -59,29 +47,23 @@ class MapEntryExpectationSamples { @Test fun valueFeature() { expect(mapOf(1 to "a").entries.first()).value toEqual "a" - // | | subject here is of type String (actually "a") - // | subject here is of type Map + // | | subject here is of type String (actually "a") + // | subject here is of type Map.Entry - fails { - - // fails because "a" is not equal to "b" + fails { // because "a" is not equal to "b" expect(mapOf(1 to "a").entries.first()).value toEqual "b" - // | | subject here is of type String (actually "a") - // | subject here is of type Map + // | | subject here is of type String (actually "a") + // | subject here is of type Map.Entry } } @Test fun value() { - // | subject here is of type Map expect(mapOf(1 to "a").entries.first()) value { // subject inside this block is of type String (actually "a") this toEqual "a" } - fails { - - // fails because "a" is not equal to "b" - // | subject here is of type Map + fails { // because "a" is not equal to "b" expect(mapOf(1 to "a").entries.first()) value { // subject inside this block is of type String (actually "a") this toEqual "b" } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/deprecated/MapEntryAssertionSamples.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/deprecated/MapEntryAssertionSamples.kt index 15fff4830..47c21aa5a 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/deprecated/MapEntryAssertionSamples.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/samples/deprecated/MapEntryAssertionSamples.kt @@ -1,3 +1,6 @@ +//TODO remove file with 1.0.0 +@file:Suppress("DEPRECATION") + package ch.tutteli.atrium.api.infix.en_GB.samples.deprecated import ch.tutteli.atrium.api.infix.en_GB.* @@ -9,48 +12,10 @@ class MapEntryAssertionSamples { @Test fun isKeyValue() { - expect(mapOf(1 to "a").entries.first()) toEqualKeyValue (1 to "a") + expect(mapOf(1 to "a").entries.first()) isKeyValue (1 to "a") fails { - expect(mapOf(1 to "a").entries.first()) toEqualKeyValue (1 to "b") + expect(mapOf(1 to "a").entries.first()) isKeyValue (1 to "b") } } - - @Test - fun keyFeature() { - expect(mapOf(1 to "a").entries.first()).key toEqual 1 - - fails { - expect(mapOf(1 to "a").entries.first()).key toEqual 2 - } - } - - @Test - fun key() { - expect(mapOf(1 to "a").entries.first()) key { it toEqual 1 } - - fails { - expect(mapOf(1 to "a").entries.first()) key { it toEqual 2 } - } - } - - @Test - fun valueFeature() { - expect(mapOf(1 to "a").entries.first()).value toEqual "a" - - fails { - expect(mapOf(1 to "a").entries.first()).value toEqual "b" - } - } - - @Test - fun value() { - expect(mapOf(1 to "a").entries.first()) value { it toEqual "a" } - - - fails { - expect(mapOf(1 to "a").entries.first()) value { it toEqual "b" } - } - } - }