27
27
package io.spine.validate
28
28
29
29
import io.kotest.matchers.collections.shouldBeEmpty
30
+ import io.kotest.matchers.shouldBe
30
31
import io.spine.validate.option.ValidatingOptionFactory
31
32
import java.util.function.Function
32
33
import org.junit.jupiter.api.BeforeEach
33
34
import org.junit.jupiter.api.DisplayName
34
35
import org.junit.jupiter.api.Test
35
36
import org.junit.jupiter.api.assertDoesNotThrow
36
37
37
- @DisplayName(" Interface `ValidatingOptionFactory` should" )
38
+ @DisplayName(" `ValidatingOptionFactory` should" )
38
39
internal class ValidatingOptionFactorySpec {
39
40
40
41
private lateinit var options: ValidatingOptionFactory
@@ -44,14 +45,19 @@ internal class ValidatingOptionFactorySpec {
44
45
options = object : ValidatingOptionFactory {}
45
46
}
46
47
48
+ /* *
49
+ * Verifies that [ValidatingOptionFactory] does not force the classes that
50
+ * implement this interface to provide implementations for the methods.
51
+ *
52
+ * The interface has all the methods declared as `default` providing the implementations.
53
+ *
54
+ * This test checks that the requirement is met by providing the simplest possible
55
+ * implementation via an anonymous object. If this test compiles, we're good to go.
56
+ */
47
57
@Test
48
58
fun `have no abstract methods` () {
49
- // We do not expect the code below to throw.
50
- // Here we test that the simplest derived class does not implement
51
- // any method and compiles.
52
- assertDoesNotThrow {
53
- object : ValidatingOptionFactory {}
54
- }
59
+ val factory = object : ValidatingOptionFactory {}
60
+ factory.forBoolean().size shouldBe 0
55
61
}
56
62
57
63
@Test
0 commit comments