#42 Add tests for OpinionVoter

This commit is contained in:
flecomte committed 2020-03-17 14:08:14 +01:00
1 parent 86b569123c
commit 622deb0f7d
2 files changed
+145 -13

No files matched your search

@@ -12,7 +12,7 @@ class OpinionVoter : Voter {
override fun supports(action: ActionI, call: ApplicationCall, subject: Any?): Boolean {
return (action is Action)
.and(subject is Opinion<*>? || subject is List<*>)
.and(subject is Opinion<*>?)
}
override fun vote(action: ActionI, call: ApplicationCall, subject: Any?): Vote {
@@ -25,14 +25,6 @@ class OpinionVoter : Voter {
if (subject is Opinion<*>) {
return Vote.GRANTED
}
if (subject is List<*>) {
subject.forEach {
if (it !is Opinion<*>) {
return Vote.DENIED
}
}
return Vote.GRANTED
}
return Vote.DENIED
}
@@ -45,10 +37,6 @@ class OpinionVoter : Voter {
else Vote.DENIED
}
if (action is Action) {
return Vote.DENIED
}
return Vote.ABSTAIN
}
}