Skip to content

Commit

Permalink
Fixed StateConfiguration.groupByIdAndRemoveRedundantHandlers to not l…
Browse files Browse the repository at this point in the history
…ist handlers with guards after handlers without guards.
  • Loading branch information
clnhlzmn committed Apr 5, 2021
1 parent d45e540 commit bfbb885
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 3 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ data class StateConfiguration(val states: Set<State>) {
fun List<Pair<State, Handler.Event>>.groupByIdAndRemoveRedundantHandlers(): Map<String, List<Pair<State, Handler.Event>>> {
return groupBy { it.second.id }.mapValues { entry ->
val guards = HashSet<String?>()
entry.value.filter { guards.add(it.second.guard) }
entry.value.filter { !guards.contains(null) && guards.add(it.second.guard) }
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ internal class StateConfigurationTest {
Pair(s11, Handler.Event("foo")),
Pair(s1, Handler.Event("foo", guard = "bar"))
)
expected = mapOf(Pair("foo", listOf(Pair(s111, Handler.Event("foo")),
Pair(s1, Handler.Event("foo", guard = "bar")))))
expected = mapOf(Pair("foo", listOf(Pair(s111, Handler.Event("foo")))))
assertEquals(expected, handlers.groupByIdAndRemoveRedundantHandlers())


Expand Down

0 comments on commit bfbb885

Please sign in to comment.