@@ -25,15 +25,15 @@ fun getMap(map : Map<*,*>, key : String) : Map<*,*>{
25
25
fun <T > Map <* , * >.extract (path : String ) : T {
26
26
val tokens = path.trim().split(' /' ).filter(String ::isNotBlank)
27
27
try {
28
- return tokens.fold(this as Any? , { workingMap, token ->
28
+ return tokens.fold(this as Any? ) { workingMap, token ->
29
29
if (token.contains(' [' )){
30
30
val list = (workingMap as Map <* ,* >)[token.substringBefore(' [' )]
31
- val index = token[ token.indexOf(' [' )+ 1 ].toString( ).toInt()
31
+ val index = token.substring( token.indexOf(' [' )+ 1 , token.length - 1 ).toInt()
32
32
(list as List <* >)[index]
33
33
} else {
34
34
(workingMap as Map <* ,* >)[token]
35
35
}
36
- }) as T
36
+ } as T
37
37
} catch (e : Exception ){
38
38
throw IllegalArgumentException (" Path: $path does not exist in map: ${this } " , e)
39
39
}
@@ -61,8 +61,8 @@ fun assertError(map : Map<*,*>, vararg messageElements : String) {
61
61
MatcherAssert .assertThat(errorMessage, CoreMatchers .notNullValue())
62
62
63
63
messageElements
64
- .filterNot { errorMessage.contains(it) }
65
- .forEach { throw AssertionError (" Expected error message to contain $it , but was: $errorMessage " ) }
64
+ .filterNot { errorMessage.contains(it) }
65
+ .forEach { throw AssertionError (" Expected error message to contain $it , but was: $errorMessage " ) }
66
66
}
67
67
68
68
inline fun <reified T : Exception > expect (message : String? = null, block : () -> Unit ){
0 commit comments