#42 Add tests for OpinionVoter

This commit is contained in:
2020-03-17 14:08:14 +01:00
parent 86b569123c
commit 622deb0f7d
2 changed files with 145 additions and 13 deletions

View File

@@ -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
}
}