Skip to content

Commit b205ebc

Browse files
[GH-251] Refactored
1 parent 58274ec commit b205ebc

File tree

1 file changed

+38
-34
lines changed

1 file changed

+38
-34
lines changed

src/test/kotlin/com/exactpro/th2/check1/event/TestVerificationEntryUtils.kt

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ import org.junit.jupiter.params.ParameterizedTest
6464
import org.junit.jupiter.params.provider.Arguments
6565
import org.junit.jupiter.params.provider.Arguments.arguments
6666
import org.junit.jupiter.params.provider.MethodSource
67+
import org.junit.jupiter.params.provider.ValueSource
6768
import strikt.api.Assertion
6869
import strikt.api.expectThat
6970
import strikt.assertions.hasSize
@@ -76,25 +77,26 @@ import java.util.stream.Stream
7677
class TestVerificationEntryUtils {
7778
private val converter = AbstractCheckTask.PROTO_CONVERTER
7879

79-
@Test
80-
fun `simple not key fields test`() {
80+
@ParameterizedTest
81+
@ValueSource(booleans = [true, false])
82+
fun `simple not key fields test`(isKey: Boolean) {
8183
val filter = rootFilter(timePrecision = Duration.ofMillis(1), decimalPrecision = 0.001) {
82-
simpleFilter("simple-equal", "test-equal", EQUAL, false)
83-
simpleFilter("simple-not_equal", "test-not_equal", NOT_EQUAL, false)
84-
emptyFilter("simple-empty", false)
85-
notEmptyFilter("simple-not_empty", false)
86-
inFilter("simple-in", listOf("test-1", "test-2", "test-3"), false)
87-
notInFilter("simple-not_in", listOf("test-1", "test-2", "test-3"), false)
88-
simpleFilter("simple-like", ".*-like", LIKE, false)
89-
simpleFilter("simple-not_like", ".*-not_like", NOT_LIKE, false)
90-
simpleFilter("simple-more", "10", MORE, false)
91-
simpleFilter("simple-not_more", "10", NOT_MORE, false)
92-
simpleFilter("simple-less", "10", LESS, false)
93-
simpleFilter("simple-not_less", "10", NOT_LESS, false)
94-
simpleFilter("simple-wildcard", "t?*-wildcard", WILDCARD, false)
95-
simpleFilter("simple-not_wildcard", "t?*-not_wildcard", NOT_WILDCARD, false)
96-
simpleFilter("simple-eq_time_precision", "2025-12-22T12:36:27.123456789", EQ_TIME_PRECISION, false)
97-
simpleFilter("simple-eq_decimal_precision", "10.123456789", EQ_DECIMAL_PRECISION, false)
84+
simpleFilter("simple-equal", "test-equal", EQUAL, isKey)
85+
simpleFilter("simple-not_equal", "test-not_equal", NOT_EQUAL, isKey)
86+
emptyFilter("simple-empty", isKey)
87+
notEmptyFilter("simple-not_empty", isKey)
88+
inFilter("simple-in", listOf("test-1", "test-2", "test-3"), isKey)
89+
notInFilter("simple-not_in", listOf("test-1", "test-2", "test-3"), isKey)
90+
simpleFilter("simple-like", ".*-like", LIKE, isKey)
91+
simpleFilter("simple-not_like", ".*-not_like", NOT_LIKE, isKey)
92+
simpleFilter("simple-more", "10", MORE, isKey)
93+
simpleFilter("simple-not_more", "10", NOT_MORE, isKey)
94+
simpleFilter("simple-less", "10", LESS, isKey)
95+
simpleFilter("simple-not_less", "10", NOT_LESS, isKey)
96+
simpleFilter("simple-wildcard", "t?*-wildcard", WILDCARD, isKey)
97+
simpleFilter("simple-not_wildcard", "t?*-not_wildcard", NOT_WILDCARD, isKey)
98+
simpleFilter("simple-eq_time_precision", "2025-12-22T12:36:27.123456789", EQ_TIME_PRECISION, isKey)
99+
simpleFilter("simple-eq_decimal_precision", "10.123456789", EQ_DECIMAL_PRECISION, isKey)
98100
}
99101

100102
val message = message("test")
@@ -122,8 +124,10 @@ class TestVerificationEntryUtils {
122124
filter.messageType,
123125
)
124126
val actual = converter.fromProtoMessage(message, false)
127+
val container = VerificationUtil.toMetaContainer(filter.messageFilter, false)
125128
val settings = ComparatorSettings().apply {
126129
isKeepResultGroupOrder = true
130+
metaContainer = container
127131
}
128132
val result = MessageComparator.compare(actual, expected, settings)
129133
.assertNotNull { "Result must not be null" }
@@ -133,52 +137,52 @@ class TestVerificationEntryUtils {
133137
expectCollection("16", "15") {
134138
hasSize(16)
135139
get { get("simple-equal") }.isNotNull() and {
136-
expectField("test-equal", "test-equal")
140+
expectField("test-equal", "test-equal", isKey = isKey)
137141
}
138142
get { get("simple-not_equal") }.isNotNull() and {
139-
expectField("test-not_equal", "test-equal", operation = NOT_EQUAL)
143+
expectField("test-not_equal", "test-equal", operation = NOT_EQUAL, isKey = isKey)
140144
}
141145
get { get("simple-empty") }.isNotNull() and {
142-
expectField("#", null, operation = EMPTY)
146+
expectField("#", null, operation = EMPTY, isKey = isKey)
143147
}
144148
get { get("simple-not_empty") }.isNotNull() and {
145-
expectField("*", "test-not_empty", operation = NOT_EMPTY)
149+
expectField("*", "test-not_empty", operation = NOT_EMPTY, isKey = isKey)
146150
}
147151
get { get("simple-in") }.isNotNull() and {
148-
expectField("IN [test-1, test-2, test-3]", "test-2", operation = IN)
152+
expectField("IN [test-1, test-2, test-3]", "test-2", operation = IN, isKey = isKey)
149153
}
150154
get { get("simple-not_in") }.isNotNull() and {
151-
expectField("NOT_IN [test-1, test-2, test-3]", "test-4", operation = NOT_IN)
155+
expectField("NOT_IN [test-1, test-2, test-3]", "test-4", operation = NOT_IN, isKey = isKey)
152156
}
153157
get { get("simple-like") }.isNotNull() and {
154-
expectField("LIKE .*-like", "test-like", operation = LIKE)
158+
expectField("LIKE .*-like", "test-like", operation = LIKE, isKey = isKey)
155159
}
156160
get { get("simple-not_like") }.isNotNull() and {
157-
expectField("NOT_LIKE .*-not_like", "test-like", operation = NOT_LIKE)
161+
expectField("NOT_LIKE .*-not_like", "test-like", operation = NOT_LIKE, isKey = isKey)
158162
}
159163
get { get("simple-more") }.isNotNull() and {
160-
expectField(">10", "11", operation = MORE)
164+
expectField(">10", "11", operation = MORE, isKey = isKey)
161165
}
162166
get { get("simple-not_more") }.isNotNull() and {
163-
expectField("<=10", "10", operation = NOT_MORE)
167+
expectField("<=10", "10", operation = NOT_MORE, isKey = isKey)
164168
}
165169
get { get("simple-less") }.isNotNull() and {
166-
expectField("<10", "9", operation = LESS)
170+
expectField("<10", "9", operation = LESS, isKey = isKey)
167171
}
168172
get { get("simple-not_less") }.isNotNull() and {
169-
expectField(">=10", "10", operation = NOT_LESS)
173+
expectField(">=10", "10", operation = NOT_LESS, isKey = isKey)
170174
}
171175
get { get("simple-wildcard") }.isNotNull() and {
172-
expectField("WILDCARD t?*-wildcard", "test-wildcard", operation = WILDCARD)
176+
expectField("WILDCARD t?*-wildcard", "test-wildcard", operation = WILDCARD, isKey = isKey)
173177
}
174178
get { get("simple-not_wildcard") }.isNotNull() and {
175-
expectField("NOT_WILDCARD t?*-not_wildcard", "test-wildcard", operation = NOT_WILDCARD)
179+
expectField("NOT_WILDCARD t?*-not_wildcard", "test-wildcard", operation = NOT_WILDCARD, isKey = isKey)
176180
}
177181
get { get("simple-eq_time_precision") }.isNotNull() and {
178-
expectField("2025-12-22T12:36:27.123456789 ± 0.001s", "2025-12-22T12:36:27.123", operation = EQ_TIME_PRECISION)
182+
expectField("2025-12-22T12:36:27.123456789 ± 0.001s", "2025-12-22T12:36:27.123", operation = EQ_TIME_PRECISION, isKey = isKey)
179183
}
180184
get { get("simple-eq_decimal_precision") }.isNotNull() and {
181-
expectField("10.123456789 ± 0.001", "10.123", operation = EQ_DECIMAL_PRECISION)
185+
expectField("10.123456789 ± 0.001", "10.123", operation = EQ_DECIMAL_PRECISION, isKey = isKey)
182186
}
183187
}
184188
}

0 commit comments

Comments
 (0)