Skip to content

Commit

Permalink
service: test: Move all sample test to one place
Browse files Browse the repository at this point in the history
Signed-off-by: Shashank Verma <[email protected]>
  • Loading branch information
shank03 committed Sep 18, 2023
1 parent 2490f27 commit 8c15fd7
Showing 1 changed file with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.mnnit.moticlubs

import com.mnnit.moticlubs.utils.ResponseStamp
import org.junit.jupiter.api.Test

class PathMatcherTest {
class SampleTests {

@Test
fun validateMatching() {
Expand All @@ -27,4 +28,24 @@ class PathMatcherTest {
assert(!testPathAdminWrong.matches(matcherRegex))
assert(!testPathRandom.matches(matcherRegex))
}
}

@Test
fun validateStampFilter() {
val map = HashMap<String, Boolean>().apply {
this[ResponseStamp.USER.getKey()] = false
this[ResponseStamp.ADMIN.getKey()] = false
this[ResponseStamp.MEMBER.withKey("23").withKey("69").getKey()] = false
this[ResponseStamp.MEMBER.withKey("23").withKey("6").getKey()] = false
this[ResponseStamp.MEMBER.withKey("23").getKey()] = false
this[ResponseStamp.MEMBER.withKey("69").getKey()] = false
this[ResponseStamp.MEMBER.getKey()] = false
}

val keys = map.keys.filter { it.contains(ResponseStamp.MEMBER.withKey("23").getKey()) }
keys.forEach { map[it] = true }

assert(map["MEMBER:23:69"] ?: false)
assert(map["MEMBER:23:6"] ?: false)
assert(map["MEMBER:23"] ?: false)
}
}

0 comments on commit 8c15fd7

Please sign in to comment.