From 8c15fd7ecd359422f9748c21508781aae3eaa41f Mon Sep 17 00:00:00 2001 From: Shashank Verma Date: Mon, 18 Sep 2023 12:29:47 +0530 Subject: [PATCH] service: test: Move all sample test to one place Signed-off-by: Shashank Verma --- .../{PathMatcherTest.kt => SampleTests.kt} | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) rename src/test/kotlin/com/mnnit/moticlubs/{PathMatcherTest.kt => SampleTests.kt} (50%) diff --git a/src/test/kotlin/com/mnnit/moticlubs/PathMatcherTest.kt b/src/test/kotlin/com/mnnit/moticlubs/SampleTests.kt similarity index 50% rename from src/test/kotlin/com/mnnit/moticlubs/PathMatcherTest.kt rename to src/test/kotlin/com/mnnit/moticlubs/SampleTests.kt index aaee59f..d178b9d 100644 --- a/src/test/kotlin/com/mnnit/moticlubs/PathMatcherTest.kt +++ b/src/test/kotlin/com/mnnit/moticlubs/SampleTests.kt @@ -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() { @@ -27,4 +28,24 @@ class PathMatcherTest { assert(!testPathAdminWrong.matches(matcherRegex)) assert(!testPathRandom.matches(matcherRegex)) } -} \ No newline at end of file + + @Test + fun validateStampFilter() { + val map = HashMap().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) + } +}