Skip to content

Commit a3f63ad

Browse files
[GH-251] Added MORE, NOT_MORE, LESS, NOT_LESS
1 parent 10eac8a commit a3f63ad

File tree

3 files changed

+54
-31
lines changed

3 files changed

+54
-31
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ The `th2_check1_active_tasks_number` metric separate rules with label `rule_type
353353

354354
### 4.9.0
355355

356-
+ [[GH-251] Filter with either IN, NOT_IN, LIKE, NOT_LIKE, WILDCARD, NOT_WILDCARD operation adds the operation name before expected value into event](https://github.com/th2-net/th2-check1/issues/251)
356+
+ [[GH-251] Filter with either IN, NOT_IN, LIKE, NOT_LIKE, WILDCARD, NOT_WILDCARD, MORE, NOT_MORE, LESS, NOT_LESS operation adds the operation name before expected value into event](https://github.com/th2-net/th2-check1/issues/251)
357357
+ Added [hide-operation-in-expected](#hide-operation-in-expected)
358358
+ Update:
359359
+ th2-plugin: `0.3.11` (bom: `4.14.3`)

src/main/java/com/exactpro/th2/check1/event/VerificationEntryUtils.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.exactpro.th2.common.event.bean.VerificationEntry;
2525
import com.exactpro.th2.common.event.bean.VerificationStatus;
2626
import com.exactpro.th2.common.grpc.FilterOperation;
27+
import com.exactpro.th2.sailfish.utils.filter.CompareFilter;
2728
import com.exactpro.th2.sailfish.utils.filter.IOperationFilter;
2829
import com.exactpro.th2.sailfish.utils.filter.ListContainFilter;
2930
import com.exactpro.th2.sailfish.utils.filter.RegExFilter;
@@ -124,12 +125,14 @@ private static String convertExpectedResult(ComparisonResult result, boolean hid
124125
Object expected = result.getExpected();
125126

126127
if (expected instanceof IComparisonFilter) {
127-
if (expected instanceof RegExFilter) {
128-
return ((Pattern)((RegExFilter) expected).getValue()).pattern();
129-
} else if (expected instanceof ListContainFilter) {
128+
if (expected.getClass().equals(RegExFilter.class)) {
129+
return ((Pattern) ((RegExFilter) expected).getValue()).pattern();
130+
} else if (expected.getClass().equals(ListContainFilter.class)) {
130131
return ((ListContainFilter) expected).getValue().toString();
131-
} else if (expected instanceof WildcardFilter) {
132+
} else if (expected.getClass().equals(WildcardFilter.class)) {
132133
return ((WildcardFilter) expected).getValue().toString();
134+
} else if (expected.getClass().equals(CompareFilter.class)) {
135+
return ((CompareFilter) expected).getValue().toString();
133136
}
134137
return ((IComparisonFilter) expected).getCondition(result.getActual());
135138
}

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

Lines changed: 46 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,6 @@ class TestVerificationEntryUtils {
8989
simpleFilter("simple-not_equal", "test-not_equal", NOT_EQUAL, isKey)
9090
emptyFilter("simple-empty", isKey)
9191
notEmptyFilter("simple-not_empty", 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)
9692
simpleFilter("simple-eq_time_precision", "2025-12-22T12:36:27.123456789", EQ_TIME_PRECISION, isKey)
9793
simpleFilter("simple-eq_decimal_precision", "10.123456789", EQ_DECIMAL_PRECISION, isKey)
9894
}
@@ -102,10 +98,6 @@ class TestVerificationEntryUtils {
10298
.putFields("simple-not_equal", "test-equal".toValue())
10399
// .putFields("simple-empty", nullValue())
104100
.putFields("simple-not_empty", "test-not_empty".toValue())
105-
.putFields("simple-more", "11".toValue())
106-
.putFields("simple-not_more", "10".toValue())
107-
.putFields("simple-less", "9".toValue())
108-
.putFields("simple-not_less", "10".toValue())
109101
.putFields("simple-eq_time_precision", "2025-12-22T12:36:27.123".toValue())
110102
.putFields("simple-eq_decimal_precision", "10.123".toValue())
111103
.build()
@@ -126,8 +118,8 @@ class TestVerificationEntryUtils {
126118

127119
val entry = VerificationEntryUtils.createVerificationEntry(result, hideOperationInExpected)
128120
expectThat(entry) {
129-
expectCollection("10", "9") {
130-
hasSize(10)
121+
expectCollection("6", "5") {
122+
hasSize(6)
131123
get { get("simple-equal") }.isNotNull() and {
132124
expectField("test-equal", "test-equal", isKey = isKey)
133125
}
@@ -140,18 +132,6 @@ class TestVerificationEntryUtils {
140132
get { get("simple-not_empty") }.isNotNull() and {
141133
expectField("*", "test-not_empty", operation = NOT_EMPTY, isKey = isKey)
142134
}
143-
get { get("simple-more") }.isNotNull() and {
144-
expectField(">10", "11", operation = MORE, isKey = isKey)
145-
}
146-
get { get("simple-not_more") }.isNotNull() and {
147-
expectField("<=10", "10", operation = NOT_MORE, isKey = isKey)
148-
}
149-
get { get("simple-less") }.isNotNull() and {
150-
expectField("<10", "9", operation = LESS, isKey = isKey)
151-
}
152-
get { get("simple-not_less") }.isNotNull() and {
153-
expectField(">=10", "10", operation = NOT_LESS, isKey = isKey)
154-
}
155135
get { get("simple-eq_time_precision") }.isNotNull() and {
156136
expectField("2025-12-22T12:36:27.123456789 ± 0.001s", "2025-12-22T12:36:27.123", operation = EQ_TIME_PRECISION, isKey = isKey)
157137
}
@@ -171,6 +151,10 @@ class TestVerificationEntryUtils {
171151
simpleFilter("simple-not_like", ".*-not_like", NOT_LIKE)
172152
simpleFilter("simple-wildcard", "t?*-wildcard", WILDCARD)
173153
simpleFilter("simple-not_wildcard", "t?*-not_wildcard", NOT_WILDCARD)
154+
simpleFilter("simple-more", "10", MORE)
155+
simpleFilter("simple-not_more", "10", NOT_MORE)
156+
simpleFilter("simple-less", "10", LESS)
157+
simpleFilter("simple-not_less", "10", NOT_LESS)
174158
}
175159

176160
val message = message("test")
@@ -180,6 +164,10 @@ class TestVerificationEntryUtils {
180164
.putFields("simple-not_like", "test-like".toValue())
181165
.putFields("simple-wildcard", "test-wildcard".toValue())
182166
.putFields("simple-not_wildcard", "test-wildcard".toValue())
167+
.putFields("simple-more", "11".toValue())
168+
.putFields("simple-not_more", "10".toValue())
169+
.putFields("simple-less", "9".toValue())
170+
.putFields("simple-not_less", "10".toValue())
183171
.build()
184172

185173
val expected = converter.fromProtoFilter(
@@ -194,8 +182,8 @@ class TestVerificationEntryUtils {
194182

195183
val entry = VerificationEntryUtils.createVerificationEntry(result, false)
196184
expectThat(entry) {
197-
expectCollection("6", "6") {
198-
hasSize(6)
185+
expectCollection("10", "10") {
186+
hasSize(10)
199187
get { get("simple-in") }.isNotNull() and {
200188
expectField("IN [test-1, test-2, test-3]", "test-2", operation = IN)
201189
}
@@ -214,6 +202,18 @@ class TestVerificationEntryUtils {
214202
get { get("simple-not_wildcard") }.isNotNull() and {
215203
expectField("NOT_WILDCARD t?*-not_wildcard", "test-wildcard", operation = NOT_WILDCARD)
216204
}
205+
get { get("simple-more") }.isNotNull() and {
206+
expectField(">10", "11", operation = MORE)
207+
}
208+
get { get("simple-not_more") }.isNotNull() and {
209+
expectField("<=10", "10", operation = NOT_MORE)
210+
}
211+
get { get("simple-less") }.isNotNull() and {
212+
expectField("<10", "9", operation = LESS)
213+
}
214+
get { get("simple-not_less") }.isNotNull() and {
215+
expectField(">=10", "10", operation = NOT_LESS)
216+
}
217217
}
218218
}
219219
}
@@ -227,6 +227,10 @@ class TestVerificationEntryUtils {
227227
simpleFilter("simple-not_like", ".*-not_like", NOT_LIKE)
228228
simpleFilter("simple-wildcard", "t?*-wildcard", WILDCARD)
229229
simpleFilter("simple-not_wildcard", "t?*-not_wildcard", NOT_WILDCARD)
230+
simpleFilter("simple-more", "10", MORE)
231+
simpleFilter("simple-not_more", "10", NOT_MORE)
232+
simpleFilter("simple-less", "10", LESS)
233+
simpleFilter("simple-not_less", "10", NOT_LESS)
230234
}
231235

232236
val message = message("test")
@@ -236,6 +240,10 @@ class TestVerificationEntryUtils {
236240
.putFields("simple-not_like", "test-like".toValue())
237241
.putFields("simple-wildcard", "test-wildcard".toValue())
238242
.putFields("simple-not_wildcard", "test-wildcard".toValue())
243+
.putFields("simple-more", "11".toValue())
244+
.putFields("simple-not_more", "10".toValue())
245+
.putFields("simple-less", "9".toValue())
246+
.putFields("simple-not_less", "10".toValue())
239247
.build()
240248

241249
val expected = converter.fromProtoFilter(
@@ -250,8 +258,8 @@ class TestVerificationEntryUtils {
250258

251259
val entry = VerificationEntryUtils.createVerificationEntry(result, true)
252260
expectThat(entry) {
253-
expectCollection("6", "6") {
254-
hasSize(6)
261+
expectCollection("10", "10") {
262+
hasSize(10)
255263
get { get("simple-in") }.isNotNull() and {
256264
expectField("[test-1, test-2, test-3]", "test-2", operation = IN)
257265
}
@@ -270,6 +278,18 @@ class TestVerificationEntryUtils {
270278
get { get("simple-not_wildcard") }.isNotNull() and {
271279
expectField("t?*-not_wildcard", "test-wildcard", operation = NOT_WILDCARD)
272280
}
281+
get { get("simple-more") }.isNotNull() and {
282+
expectField("10", "11", operation = MORE)
283+
}
284+
get { get("simple-not_more") }.isNotNull() and {
285+
expectField("10", "10", operation = NOT_MORE)
286+
}
287+
get { get("simple-less") }.isNotNull() and {
288+
expectField("10", "9", operation = LESS)
289+
}
290+
get { get("simple-not_less") }.isNotNull() and {
291+
expectField("10", "10", operation = NOT_LESS)
292+
}
273293
}
274294
}
275295
}

0 commit comments

Comments
 (0)