mirror of
https://github.com/jlengrand/atrium.git
synced 2026-03-10 08:01:19 +00:00
deprecate mapEntryAssertions, use new ...Expectations in api-fluent
This commit is contained in:
@@ -1501,7 +1501,7 @@ then it will come in handy:
|
||||
|
||||
```kotlin
|
||||
expect(linkedMapOf("a" to 1, "b" to 2)).asEntries().toContain.inOrder.only.entries(
|
||||
{ isKeyValue("a", 1) },
|
||||
{ toEqualKeyValue("a", 1) },
|
||||
{
|
||||
key.toStartWith("a")
|
||||
value.toBeGreaterThan(2)
|
||||
@@ -1526,7 +1526,7 @@ expected that subject: {a=1, b=2} (java.util.LinkedHashMap <1234789>)
|
||||
```
|
||||
</ex-map-5>
|
||||
|
||||
`isKeyValue` as well as `key` and `value` are assertion functions defined for `Map.Entry<K, V>`.
|
||||
`toEqualKeyValue` as well as `key` and `value` are assertion functions defined for `Map.Entry<K, V>`.
|
||||
|
||||
There are more assertion functions, a full list can be found in
|
||||
[KDoc of atrium-api-fluent-en_GB](https://docs.atriumlib.org/latest#/doc/ch.tutteli.atrium.api.fluent.en_-g-b/index.html).
|
||||
|
||||
@@ -15,6 +15,7 @@ import ch.tutteli.atrium.logic.*
|
||||
*
|
||||
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.deprecated.MapEntryAssertionSamples.isKeyValue
|
||||
*/
|
||||
@Deprecated("Use toEqualKeyValue; will be removed with 1.0.0 at the latest", ReplaceWith("toEqualKeyValue(key, value)"))
|
||||
fun <K, V, T : Map.Entry<K, V>> Expect<T>.isKeyValue(key: K, value: V): Expect<T> =
|
||||
_logicAppend { isKeyValue(key, value) }
|
||||
|
||||
|
||||
@@ -24,16 +24,16 @@ object MapEntryExpectationsSpec : ch.tutteli.atrium.specs.integration.MapEntryEx
|
||||
|
||||
var star: Expect<Map.Entry<*, *>> = notImplemented()
|
||||
|
||||
a1.isKeyValue("a", 1)
|
||||
a2.isKeyValue("a", 1)
|
||||
a3.isKeyValue("a", 1)
|
||||
a4.isKeyValue("a", 1)
|
||||
star.isKeyValue("a", 1)
|
||||
a1.toEqualKeyValue("a", 1)
|
||||
a2.toEqualKeyValue("a", 1)
|
||||
a3.toEqualKeyValue("a", 1)
|
||||
a4.toEqualKeyValue("a", 1)
|
||||
star.toEqualKeyValue("a", 1)
|
||||
|
||||
a2.isKeyValue(null, 1)
|
||||
a3.isKeyValue("a", null)
|
||||
a4.isKeyValue(null, null)
|
||||
star.isKeyValue(null, null)
|
||||
a2.toEqualKeyValue(null, 1)
|
||||
a3.toEqualKeyValue("a", null)
|
||||
a4.toEqualKeyValue(null, null)
|
||||
star.toEqualKeyValue(null, null)
|
||||
|
||||
a1.key
|
||||
a2.key
|
||||
|
||||
@@ -12,10 +12,10 @@ class MapEntryAssertionSamples {
|
||||
|
||||
@Test
|
||||
fun isKeyValue() {
|
||||
expect(mapOf(1 to "a").entries.first()).isKeyValue(1, "a")
|
||||
expect(mapOf(1 to "a").entries.first()).toEqualKeyValue(1, "a")
|
||||
|
||||
fails {
|
||||
expect(mapOf(1 to "a").entries.first()).isKeyValue(1, "b")
|
||||
expect(mapOf(1 to "a").entries.first()).toEqualKeyValue(1, "b")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ class JsNameAmbiguityTest {
|
||||
@Test
|
||||
fun isKeyValueNullable() {
|
||||
expect(mapOf(1 to null as Int?)).asEntries().toContainExactly {
|
||||
isKeyValue(1, null)
|
||||
toEqualKeyValue(1, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ abstract class MapAsEntriesExpectationsSpec(
|
||||
it("$name - transformation can be applied and an assertion made") {
|
||||
expect(mapOf("a" to 1, "b" to 2)).asEntriesFun {
|
||||
toContain.inAnyOrder.only.entries(
|
||||
{ isKeyValue("b", 2) },
|
||||
{ toEqualKeyValue("b", 2) },
|
||||
{
|
||||
key.toStartWith("a")
|
||||
value.toBeGreaterThanOrEqualTo(1)
|
||||
|
||||
@@ -219,7 +219,7 @@ class MostExamplesSpec : Spek({
|
||||
}
|
||||
test("ex-map-5") {
|
||||
expect(linkedMapOf("a" to 1, "b" to 2)).asEntries().toContain.inOrder.only.entries(
|
||||
{ isKeyValue("a", 1) },
|
||||
{ toEqualKeyValue("a", 1) },
|
||||
{
|
||||
key.toStartWith("a")
|
||||
value.toBeGreaterThan(2)
|
||||
|
||||
Reference in New Issue
Block a user