@@ -34,7 +34,6 @@ import java.util.Locale
34
34
import kotlin.test.assertEquals
35
35
import kotlin.test.assertFalse
36
36
import kotlin.test.assertNotNull
37
- import kotlin.test.assertNull
38
37
import kotlin.test.assertTrue
39
38
40
39
/* *
@@ -44,12 +43,6 @@ class BotDefinitionTest {
44
43
45
44
private val botDef = BotDefinitionTest ()
46
45
47
- /* *
48
- * Finds a [StoryDefinition] from a story [id]
49
- */
50
- private fun BotDefinition.findStoryDefinitionById (id : String ): StoryDefinition ? =
51
- stories.find { it.id == id || (it as ? ConfiguredStoryDefinition )?.configuration?.storyId == id }
52
-
53
46
@Test
54
47
fun `i18nTranslator() returns an I18nTranslator that use BotDefinition#i18nKeyFromLabel` () {
55
48
val result = botDef.i18nTranslator(Locale .ENGLISH , ConnectorType .none).i18n(" test" )
@@ -82,27 +75,24 @@ class BotDefinitionTest {
82
75
@Test
83
76
fun `GIVEN stories containing configured story with specific id WHEN findStoryDefinitionById THEN story is found` () {
84
77
// Given
85
- val storyConfiguration = ConfiguredStoryDefinition (
86
- BotDefinitionWrapper (botDef),
87
- StoryDefinitionConfiguration (
88
- botDefinition = botDef,
89
- storyDefinition = SimpleStoryDefinition (
90
- id = " disable_bot" ,
91
- storyHandler = StoryHandlerTest ,
92
- starterIntents = setOf (Intent (" starter_intent" ))
93
- ),
94
- configurationName = " toto"
78
+ val wrap = BotDefinitionWrapper (botDef)
79
+
80
+ wrap.updateStories(
81
+ listOf (
82
+ StoryDefinitionConfiguration (
83
+ botDefinition = botDef,
84
+ storyDefinition = SimpleStoryDefinition (
85
+ id = " disable_bot" ,
86
+ storyHandler = StoryHandlerTest ,
87
+ starterIntents = setOf (Intent (" starter_intent" ))
88
+ ),
89
+ configurationName = " toto"
90
+ )
95
91
)
96
92
)
97
93
98
- val botDef = BotDefinitionBase (
99
- botId = " test" ,
100
- namespace = " namespace" ,
101
- stories = listOf (storyConfiguration)
102
- )
103
-
104
94
// When
105
- val result = botDef .findStoryDefinitionById(" disable_bot" )
95
+ val result = wrap .findStoryDefinitionById(" disable_bot" )
106
96
107
97
// Then
108
98
assertNotNull(result)
@@ -143,7 +133,7 @@ class BotDefinitionTest {
143
133
val result = botDef.findStoryDefinitionById(" disable_bot" )
144
134
145
135
// Then
146
- assertNull( result)
136
+ assertEquals(botDef.unknownStory, result)
147
137
}
148
138
149
139
@Test
@@ -178,7 +168,7 @@ class BotDefinitionTest {
178
168
val result = botDef.findStoryDefinitionById(" should_not_find_id" )
179
169
180
170
// Then
181
- assertNull( result)
171
+ assertEquals(botDef.unknownStory, result)
182
172
}
183
173
184
174
@Test
0 commit comments