-
Notifications
You must be signed in to change notification settings - Fork 1
/
AllOfNestedExample.kt
33 lines (30 loc) · 989 Bytes
/
AllOfNestedExample.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package org.kollektions.examples.dispatchers
import org.kollektions.consumers.consume
import org.kollektions.consumers.max
import org.kollektions.consumers.min
import org.kollektions.dispatchers.allOf
import org.kollektions.transformations.filterOn
import org.kollektions.transformations.mapTo
import java.util.*
import kotlin.test.assertEquals
import kotlin.test.Test
class AllOfNestedExample {
@Test
fun decorateConsumers() {
val actual = (1..10).asSequence()
.consume(
filterOn<Int> { it > 2 }
.allOf(
mapTo<Int, Int> { it * 2 }
.allOf(min(), max()),
mapTo<Int, Int> { it * 3 }
.allOf(min(), max())
))
assertEquals(
listOf(
listOf(Optional.of(6), Optional.of(20)),
listOf(Optional.of(9), Optional.of(30))
),
actual[0])
}
}