Skip to content
This repository was archived by the owner on May 16, 2019. It is now read-only.

Commit e3a02a2

Browse files
committed
Fixed extracting from arrays higher than one digit
1 parent 42fef4a commit e3a02a2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/test/kotlin/com/github/pgutkowski/kgraphql/TestUtils.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ fun getMap(map : Map<*,*>, key : String) : Map<*,*>{
2525
fun <T> Map<*, *>.extract(path: String) : T {
2626
val tokens = path.trim().split('/').filter(String::isNotBlank)
2727
try {
28-
return tokens.fold(this as Any?, { workingMap, token ->
28+
return tokens.fold(this as Any?) { workingMap, token ->
2929
if(token.contains('[')){
3030
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()
3232
(list as List<*>)[index]
3333
} else {
3434
(workingMap as Map<*,*>)[token]
3535
}
36-
}) as T
36+
} as T
3737
} catch (e : Exception){
3838
throw IllegalArgumentException("Path: $path does not exist in map: ${this}", e)
3939
}
@@ -61,8 +61,8 @@ fun assertError(map : Map<*,*>, vararg messageElements : String) {
6161
MatcherAssert.assertThat(errorMessage, CoreMatchers.notNullValue())
6262

6363
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") }
6666
}
6767

6868
inline fun <reified T: Exception> expect(message: String? = null, block: () -> Unit){

0 commit comments

Comments
 (0)