diff --git a/README.md b/README.md index 163f18e4a..a222816ce 100644 --- a/README.md +++ b/README.md @@ -458,6 +458,7 @@ dependencies { ### 5.3.0 + Implemented message routers used th2 transport protocol for interaction ++ Pin filters behaviour changed: conditions inside the message and metadata now combined as "and" ### 5.2.1 diff --git a/src/main/java/com/exactpro/th2/common/schema/filter/strategy/impl/AbstractFilterStrategy.java b/src/main/java/com/exactpro/th2/common/schema/filter/strategy/impl/AbstractFilterStrategy.java index fee14236e..7523d6208 100644 --- a/src/main/java/com/exactpro/th2/common/schema/filter/strategy/impl/AbstractFilterStrategy.java +++ b/src/main/java/com/exactpro/th2/common/schema/filter/strategy/impl/AbstractFilterStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2022 Exactpro (Exactpro Systems Limited) + * Copyright 2020-2023 Exactpro (Exactpro Systems Limited) * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -52,7 +52,7 @@ public boolean verify(T message, List routerFilters) { protected abstract Map getFields(T message); private boolean checkValues(Map messageFields, MultiValuedMap fieldFilters) { - return fieldFilters.isEmpty() || fieldFilters.keys().stream().anyMatch(fieldName -> { + return fieldFilters.isEmpty() || fieldFilters.keys().stream().allMatch(fieldName -> { String messageValue = messageFields.get(fieldName); Collection filters = fieldFilters.get(fieldName); return !filters.isEmpty() && filters.stream().allMatch(filter -> FieldValueChecker.checkFieldValue(filter, messageValue)); diff --git a/src/main/java/com/exactpro/th2/common/schema/filter/strategy/impl/AbstractTh2MsgFilterStrategy.java b/src/main/java/com/exactpro/th2/common/schema/filter/strategy/impl/AbstractTh2MsgFilterStrategy.java index 01a9f8302..1fb4a7578 100644 --- a/src/main/java/com/exactpro/th2/common/schema/filter/strategy/impl/AbstractTh2MsgFilterStrategy.java +++ b/src/main/java/com/exactpro/th2/common/schema/filter/strategy/impl/AbstractTh2MsgFilterStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2021 Exactpro (Exactpro Systems Limited) + * Copyright 2020-2023 Exactpro (Exactpro Systems Limited) * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -15,7 +15,6 @@ package com.exactpro.th2.common.schema.filter.strategy.impl; - import com.exactpro.th2.common.grpc.Message; import com.exactpro.th2.common.grpc.MessageID; import com.exactpro.th2.common.grpc.MessageMetadata; @@ -23,7 +22,6 @@ import java.util.Map; import java.util.stream.Collectors; - public abstract class AbstractTh2MsgFilterStrategy extends AbstractFilterStrategy { public static final String BOOK_KEY = "book"; @@ -31,6 +29,7 @@ public abstract class AbstractTh2MsgFilterStrategy extends AbstractFilterStrateg public static final String SESSION_ALIAS_KEY = "session_alias"; public static final String MESSAGE_TYPE_KEY = "message_type"; public static final String DIRECTION_KEY = "direction"; + public static final String PROTOCOL_KEY = "protocol"; @Override public Map getFields(com.google.protobuf.Message message) { @@ -50,7 +49,8 @@ public Map getFields(com.google.protobuf.Message message) { SESSION_GROUP_KEY, sessionGroup.isEmpty() ? sessionAlias : sessionGroup, SESSION_ALIAS_KEY, sessionAlias, MESSAGE_TYPE_KEY, metadata.getMessageType(), - DIRECTION_KEY, messageID.getDirection().name() + DIRECTION_KEY, messageID.getDirection().name(), + PROTOCOL_KEY, metadata.getProtocol() ); messageFields.putAll(metadataMsgFields); @@ -59,5 +59,4 @@ public Map getFields(com.google.protobuf.Message message) { } public abstract Message parseMessage(com.google.protobuf.Message message); - } diff --git a/src/main/kotlin/com/exactpro/th2/common/schema/filter/strategy/impl/AnyMessageFilterStrategy.kt b/src/main/kotlin/com/exactpro/th2/common/schema/filter/strategy/impl/AnyMessageFilterStrategy.kt index 5d76c600e..44abeac2f 100644 --- a/src/main/kotlin/com/exactpro/th2/common/schema/filter/strategy/impl/AnyMessageFilterStrategy.kt +++ b/src/main/kotlin/com/exactpro/th2/common/schema/filter/strategy/impl/AnyMessageFilterStrategy.kt @@ -34,20 +34,24 @@ object AnyMessageFilterStrategy : AbstractFilterStrategy() { val metadata = message.message.metadata val sessionAlias = metadata.id.connectionId.sessionAlias val sessionGroup = metadata.id.connectionId.sessionGroup + result.putAll(metadata.propertiesMap) result[AbstractTh2MsgFilterStrategy.BOOK_KEY] = metadata.id.bookName result[AbstractTh2MsgFilterStrategy.SESSION_GROUP_KEY] = sessionGroup.ifEmpty { sessionAlias } result[AbstractTh2MsgFilterStrategy.SESSION_ALIAS_KEY] = sessionAlias result[AbstractTh2MsgFilterStrategy.MESSAGE_TYPE_KEY] = metadata.messageType result[AbstractTh2MsgFilterStrategy.DIRECTION_KEY] = metadata.id.direction.name + result[AbstractTh2MsgFilterStrategy.PROTOCOL_KEY] = metadata.protocol } message.hasRawMessage() -> { val metadata = message.rawMessage.metadata val sessionAlias = metadata.id.connectionId.sessionAlias val sessionGroup = metadata.id.connectionId.sessionGroup + result.putAll(metadata.propertiesMap) result[AbstractTh2MsgFilterStrategy.BOOK_KEY] = metadata.id.bookName result[AbstractTh2MsgFilterStrategy.SESSION_GROUP_KEY] = sessionGroup.ifEmpty { sessionAlias } result[AbstractTh2MsgFilterStrategy.SESSION_ALIAS_KEY] = metadata.id.connectionId.sessionAlias result[AbstractTh2MsgFilterStrategy.DIRECTION_KEY] = metadata.id.direction.name + result[AbstractTh2MsgFilterStrategy.PROTOCOL_KEY] = metadata.protocol } else -> throw IllegalStateException("Message has not messages: ${message.toJson()}") } diff --git a/src/test/kotlin/com/exactpro/th2/common/schema/filter/strategy/impl/TestAnyMessageFilterStrategy.kt b/src/test/kotlin/com/exactpro/th2/common/schema/filter/strategy/impl/TestAnyMessageFilterStrategy.kt index bd59f34bc..55b2eaa1f 100644 --- a/src/test/kotlin/com/exactpro/th2/common/schema/filter/strategy/impl/TestAnyMessageFilterStrategy.kt +++ b/src/test/kotlin/com/exactpro/th2/common/schema/filter/strategy/impl/TestAnyMessageFilterStrategy.kt @@ -1,5 +1,5 @@ /* - * Copyright 2021 Exactpro (Exactpro Systems Limited) + * Copyright 2021-2023 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import com.exactpro.th2.common.event.bean.BaseTest.BOOK_NAME import com.exactpro.th2.common.grpc.AnyMessage import com.exactpro.th2.common.grpc.Direction import com.exactpro.th2.common.grpc.RawMessage +import com.exactpro.th2.common.message.addField import com.exactpro.th2.common.message.message import com.exactpro.th2.common.message.toJson import com.exactpro.th2.common.schema.message.configuration.FieldFilterConfiguration @@ -33,6 +34,158 @@ import org.junit.jupiter.params.provider.Arguments.arguments import org.junit.jupiter.params.provider.MethodSource class TestAnyMessageFilterStrategy { + + @ParameterizedTest + @MethodSource("multipleFiltersMatch") + fun `matches any filter`(anyMessage: AnyMessage, expectMatch: Boolean) { + val match = AnyMessageFilterStrategy.verify( + anyMessage, + listOf( + MqRouterFilterConfiguration( + metadata = MultiMapUtils.newListValuedHashMap().apply { + put("message_type", FieldFilterConfiguration( + fieldName = "message_type", + operation = FieldFilterOperation.EQUAL, + expectedValue = "test" + )) + } + ), + MqRouterFilterConfiguration( + metadata = MultiMapUtils.newListValuedHashMap().apply { + put("direction", FieldFilterConfiguration( + fieldName = "direction", + operation = FieldFilterOperation.EQUAL, + expectedValue = "FIRST" + )) + } + ) + ) + ) + assertEquals(expectMatch, match) { "The message ${anyMessage.toJson()} was${if (expectMatch) "" else " not"} matched" } + } + + @ParameterizedTest + @MethodSource("rawMessagesBothFilters") + fun `matches with multiple metadata filters`(anyMessage: AnyMessage, expectMatch: Boolean) { + val match = AnyMessageFilterStrategy.verify( + anyMessage, + MqRouterFilterConfiguration( + metadata = MultiMapUtils.newListValuedHashMap().apply { + put("session_alias", FieldFilterConfiguration( + fieldName = "session_alias", + operation = FieldFilterOperation.EQUAL, + expectedValue = "test-alias" + )) + put("direction", FieldFilterConfiguration( + fieldName = "direction", + operation = FieldFilterOperation.EQUAL, + expectedValue = "FIRST" + )) + } + ) + ) + assertEquals(expectMatch, match) { "The message ${anyMessage.toJson()} was${if (expectMatch) "" else " not"} matched" } + } + + @ParameterizedTest + @MethodSource("parsedMessagesBothFilters") + fun `matches with multiple message filters`(anyMessage: AnyMessage, expectMatch: Boolean) { + val match = AnyMessageFilterStrategy.verify( + anyMessage, + MqRouterFilterConfiguration( + message = MultiMapUtils.newListValuedHashMap().apply { + put("test-field1", FieldFilterConfiguration( + fieldName = "test-field1", + operation = FieldFilterOperation.EQUAL, + expectedValue = "test-value1" + )) + put("test-field2", FieldFilterConfiguration( + fieldName = "test-field2", + operation = FieldFilterOperation.EQUAL, + expectedValue = "test-value2" + )) + } + ) + ) + assertEquals(expectMatch, match) { "The message ${anyMessage.toJson()} was${if (expectMatch) "" else " not"} matched" } + } + + @ParameterizedTest + @MethodSource("messagesWithProperties") + fun `matches with multiple properties filters`(anyMessage: AnyMessage, expectMatch: Boolean) { + val match = AnyMessageFilterStrategy.verify( + anyMessage, + MqRouterFilterConfiguration( + metadata = MultiMapUtils.newListValuedHashMap().apply { + put("prop-field1", FieldFilterConfiguration( + fieldName = "prop-field1", + operation = FieldFilterOperation.EQUAL, + expectedValue = "prop-value1" + )) + put("prop-field2", FieldFilterConfiguration( + fieldName = "prop-field2", + operation = FieldFilterOperation.EQUAL, + expectedValue = "prop-value2" + )) + } + ) + ) + assertEquals(expectMatch, match) { "The message ${anyMessage.toJson()} was${if (expectMatch) "" else " not"} matched" } + } + + @ParameterizedTest + @MethodSource("messagesWithMessageAndMetadataFilters") + fun `matches with multiple message and metadata filters`(anyMessage: AnyMessage, expectMatch: Boolean) { + val match = AnyMessageFilterStrategy.verify( + anyMessage, + MqRouterFilterConfiguration( + message = MultiMapUtils.newListValuedHashMap().apply { + put("test-field1", FieldFilterConfiguration( + fieldName = "test-field1", + operation = FieldFilterOperation.EQUAL, + expectedValue = "test-value1" + )) + put("test-field2", FieldFilterConfiguration( + fieldName = "test-field2", + operation = FieldFilterOperation.EQUAL, + expectedValue = "test-value2" + )) + }, + metadata = MultiMapUtils.newListValuedHashMap().apply { + put("message_type", FieldFilterConfiguration( + fieldName = "message_type", + operation = FieldFilterOperation.EQUAL, + expectedValue = "test" + )) + put("direction", FieldFilterConfiguration( + fieldName = "direction", + operation = FieldFilterOperation.EQUAL, + expectedValue = "FIRST" + )) + } + ) + ) + assertEquals(expectMatch, match) { "The message ${anyMessage.toJson()} was${if (expectMatch) "" else " not"} matched" } + } + + @ParameterizedTest + @MethodSource("messageWithProtocol") + fun `matches protocol metadata filter`(anyMessage: AnyMessage, expectMatch: Boolean) { + val match = AnyMessageFilterStrategy.verify( + anyMessage, + MqRouterFilterConfiguration( + metadata = MultiMapUtils.newListValuedHashMap().apply { + put("protocol", FieldFilterConfiguration( + fieldName = "protocol", + operation = FieldFilterOperation.EQUAL, + expectedValue = "HTTP" + )) + } + ) + ) + assertEquals(expectMatch, match) { "The message ${anyMessage.toJson()} was${if (expectMatch) "" else " not"} matched" } + } + @ParameterizedTest @MethodSource("parsedMessages") fun `matches the parsed message by message type with single filter`(anyMessage: AnyMessage, expectMatch: Boolean) { @@ -82,48 +235,319 @@ class TestAnyMessageFilterStrategy { expectedValue = "test-alias" )) } - )) + ) + ) + + assertEquals(expectMatch, match) { "The message ${message.toJson()} was${if (expectMatch) "" else " not"} matched" } + } + + @ParameterizedTest + @MethodSource("messagesWithSameFilterFields") + fun `miss matches with the same filter fields`(message: AnyMessage, expectMatch: Boolean) { + val match = AnyMessageFilterStrategy.verify( + message, + MqRouterFilterConfiguration( + message = MultiMapUtils.newListValuedHashMap().apply { + put( + "test-field", FieldFilterConfiguration( + fieldName = "test-field", + operation = FieldFilterOperation.EQUAL, + expectedValue = "test-value1" + ) + ) + put( + "test-field", FieldFilterConfiguration( + fieldName = "test-field", + operation = FieldFilterOperation.EQUAL, + expectedValue = "test-value2" + ) + ) + } + ) + ) + + assertEquals(expectMatch, match) { "The message ${message.toJson()} was${if (expectMatch) "" else " not"} matched" } + } + + @ParameterizedTest + @MethodSource("messagesWithMultipleFiltersWithSameFilterField") + fun `matches with multiple filters with the same filter fields`(message: AnyMessage, expectMatch: Boolean) { + val match = AnyMessageFilterStrategy.verify( + message, + listOf( + MqRouterFilterConfiguration( + message = MultiMapUtils.newListValuedHashMap().apply { + put( + "test-field", FieldFilterConfiguration( + fieldName = "test-field", + operation = FieldFilterOperation.EQUAL, + expectedValue = "test-value1" + ) + ) + } + ), + MqRouterFilterConfiguration( + message = MultiMapUtils.newListValuedHashMap().apply { + put( + "test-field", FieldFilterConfiguration( + fieldName = "test-field", + operation = FieldFilterOperation.EQUAL, + expectedValue = "test-value2" + ) + ) + } + ) + ) + ) + + assertEquals(expectMatch, match) { "The message ${message.toJson()} was${if (expectMatch) "" else " not"} matched" } + } + + @ParameterizedTest + @MethodSource("messagesWithMultipleSameFields") + fun `matches message with multiple fields with same name`(message: AnyMessage, expectMatch: Boolean) { + val match = AnyMessageFilterStrategy.verify( + message, + MqRouterFilterConfiguration( + message = MultiMapUtils.newListValuedHashMap().apply { + put( + "test-field", FieldFilterConfiguration( + fieldName = "test-field", + operation = FieldFilterOperation.NOT_EQUAL, + expectedValue = "test-value1" + ) + ) + put( + "test-field", FieldFilterConfiguration( + fieldName = "test-field", + operation = FieldFilterOperation.EQUAL, + expectedValue = "test-value2" + ) + ) + } + ) + ) + + assertEquals(expectMatch, match) { "The message ${message.toJson()} was${if (expectMatch) "" else " not"} matched" } + } + + @ParameterizedTest + @MethodSource("messagesWithOneProperty") + fun `matches message with properties`(message: AnyMessage, expectMatch: Boolean) { + val match = AnyMessageFilterStrategy.verify( + message, + MqRouterFilterConfiguration( + metadata = MultiMapUtils.newListValuedHashMap().apply { + put( + "test-property", FieldFilterConfiguration( + fieldName = "test-property", + operation = FieldFilterOperation.EQUAL, + expectedValue = "property-value" + ) + ) + } + ) + ) + + assertEquals(expectMatch, match) { "The message ${message.toJson()} was${if (expectMatch) "" else " not"} matched" } + } + + @ParameterizedTest + @MethodSource("messagesWithPropertiesAndMetadata") + fun `matches message with properties and metadata`(message: AnyMessage, expectMatch: Boolean) { + val match = AnyMessageFilterStrategy.verify( + message, + MqRouterFilterConfiguration( + metadata = MultiMapUtils.newListValuedHashMap().apply { + put( + "test-property", FieldFilterConfiguration( + fieldName = "test-property", + operation = FieldFilterOperation.EQUAL, + expectedValue = "property-value" + ) + ) + + put("message_type", FieldFilterConfiguration( + fieldName = "message_type", + operation = FieldFilterOperation.EQUAL, + expectedValue = "test" + )) + } + ) + ) assertEquals(expectMatch, match) { "The message ${message.toJson()} was${if (expectMatch) "" else " not"} matched" } } companion object { - private val PARSED_MESSAGE_MATCH = AnyMessage.newBuilder().setMessage( - message(BOOK_NAME, "test", Direction.FIRST, "test-alias") - ).build() + private fun simpleMessageBuilder(messageType: String, direction: Direction, sessionAlias: String): AnyMessage { + return AnyMessage.newBuilder().setMessage( + message(BOOK_NAME, messageType, direction, sessionAlias) + ).build() + } + + private fun simpleRawMessageBuilder(sessionAlias: String, directionValue: Direction): AnyMessage { + return AnyMessage.newBuilder().setRawMessage( + RawMessage.newBuilder().apply { + metadataBuilder.idBuilder.apply { + connectionIdBuilder.sessionAlias = sessionAlias + direction = directionValue + } + } + ).build() + } - private val RAW_MESSAGE_MATCH = AnyMessage.newBuilder().setRawMessage( - RawMessage.newBuilder().apply { - metadataBuilder.idBuilder.apply { - connectionIdBuilder.sessionAlias = "test-alias" - direction = Direction.FIRST + private fun messageWithFieldsBuilder(messageType: String, direction: Direction, fields: List>): AnyMessage { + return AnyMessage.newBuilder().setMessage( + message(BOOK_NAME, messageType, direction, "test-alias").apply { + fields.forEach { addField(it.first, it.second) } } - } - ).build() + ).build() + } - private val PARSED_MESSAGE_MISS_MATCH = AnyMessage.newBuilder().setMessage( - message(BOOK_NAME, "test1", Direction.SECOND, "test-alias1") - ).build() + private fun messageWithPropertiesBuilder(messageType: String, direction: Direction, properties: List>): AnyMessage { + return AnyMessage.newBuilder().setMessage( + message(BOOK_NAME, messageType, direction, "test-alias").apply { + properties.forEach { metadataBuilder.putProperties(it.first, it.second) } + } + ).build() + } + + private fun rawMessageWithOnePropertyBuilder(propertyKey: String, propertyValue: String): AnyMessage { + return AnyMessage.newBuilder().setRawMessage( + RawMessage.newBuilder().apply { + metadataBuilder.putProperties(propertyKey, propertyValue) + } + ).build() + } - private val RAW_MESSAGE_MISS_MATCH = AnyMessage.newBuilder().setRawMessage( - RawMessage.newBuilder().apply { - metadataBuilder.idBuilder.apply { - connectionIdBuilder.sessionAlias = "test-alias1" - direction = Direction.SECOND + private fun messageWithOnePropertyBuilder(messageType: String, propertyKey: String, propertyValue: String): AnyMessage { + return messageWithPropertiesBuilder(messageType, Direction.FIRST, listOf(Pair(propertyKey, propertyValue))) + } + + private fun messageWithProtocolBuilder(protocol: String): AnyMessage { + return AnyMessage.newBuilder().setMessage( + message(BOOK_NAME, "test", Direction.FIRST, "test-alias").apply { + metadataBuilder.protocol = protocol } - } - ).build() + ).build() + } @JvmStatic - fun parsedMessages(): List = listOf( - arguments(PARSED_MESSAGE_MATCH, true), - arguments(PARSED_MESSAGE_MISS_MATCH, false) + fun messageWithProtocol(): List = listOf( + arguments(messageWithProtocolBuilder("HTTP"), true), + arguments(messageWithProtocolBuilder("FTP"), false), ) @JvmStatic fun messages(): List = listOf( - arguments(RAW_MESSAGE_MATCH, true), - arguments(RAW_MESSAGE_MISS_MATCH, false) + arguments(simpleRawMessageBuilder("test-alias", Direction.FIRST), true), + arguments(simpleRawMessageBuilder("test-alias1", Direction.SECOND), false) ) + parsedMessages() + + @JvmStatic + fun parsedMessages(): List = listOf( + arguments(simpleMessageBuilder("test", Direction.FIRST, "test-alias"), true), + arguments(simpleMessageBuilder("test1", Direction.SECOND, "test-alias1"), false) + ) + + @JvmStatic + fun messagesWithProperties(): List = listOf( + arguments(messageWithPropertiesBuilder("test", Direction.FIRST, listOf( + Pair("prop-field1", "prop-value1"), Pair("prop-field2", "prop-value2"))), true), + arguments(messageWithPropertiesBuilder("test", Direction.FIRST, listOf( + Pair("prop-field1", "prop-value-wrong"), Pair("prop-field2", "prop-value2"))), false), + arguments(messageWithPropertiesBuilder("test", Direction.FIRST, listOf( + Pair("prop-field1", "prop-value1"), Pair("prop-field2", "prop-value-wrong"))), false), + arguments(messageWithPropertiesBuilder("test", Direction.FIRST, listOf( + Pair("prop-field1", "prop-value-wrong"), Pair("prop-field2", "prop-value-wrong"))), false) + ) + + @JvmStatic + fun messagesWithMultipleSameFields(): List = listOf( + arguments(messageWithFieldsBuilder("test", Direction.FIRST, + listOf(Pair("test-field", "test-value1"), Pair("test-field", "test-value2"))), true) + ) + + @JvmStatic + fun messagesWithSameFilterFields(): List = listOf( + arguments(messageWithFieldsBuilder("test", Direction.FIRST, listOf(Pair("test-field", "test-value1"))), false), + arguments(messageWithFieldsBuilder("test", Direction.FIRST, listOf(Pair("test-field", "test-value2"))), false) + ) + + @JvmStatic + fun messagesWithMultipleFiltersWithSameFilterField(): List = listOf( + arguments(messageWithFieldsBuilder("test", Direction.FIRST, listOf(Pair("test-field", "test-value1"))), true), + arguments(messageWithFieldsBuilder("test", Direction.FIRST, listOf(Pair("test-field", "test-value2"))), true) + ) + + @JvmStatic + fun multipleFiltersMatch(): List = listOf( + arguments(simpleMessageBuilder("test", Direction.FIRST, "test-alias"), true), + arguments(simpleMessageBuilder("test", Direction.SECOND, "test-alias"), true), + arguments(simpleMessageBuilder("test-wrong", Direction.FIRST, "test-alias"), true), + arguments(simpleMessageBuilder("test-wrong", Direction.SECOND, "test-alias"), false) + ) + + @JvmStatic + fun messagesWithMessageAndMetadataFilters() : List = listOf( + // fields full match + arguments(messageWithFieldsBuilder("test", Direction.FIRST, + listOf(Pair("test-field1", "test-value1"), Pair("test-field2", "test-value2"))), true), + + // metadata mismatch + arguments(messageWithFieldsBuilder("test", Direction.SECOND, + listOf(Pair("test-field1", "test-value1"), Pair("test-field2", "test-value2"))), false), + arguments(messageWithFieldsBuilder("test-wrong", Direction.FIRST, + listOf(Pair("test-field1", "test-value1"), Pair("test-field2", "test-value2"))), false), + + // fields mismatch + arguments(messageWithFieldsBuilder("test", Direction.FIRST, + listOf(Pair("test-field1", "test-value-wrong"), Pair("test-field2", "test-value2"))), false), + arguments(messageWithFieldsBuilder("test", Direction.FIRST, + listOf(Pair("test-field1", "test-value1"), Pair("test-field2", "test-value-wrong"))), false), + arguments(messageWithFieldsBuilder("test", Direction.FIRST, + listOf(Pair("test-field1", "test-value-wrong"), Pair("test-field2", "test-value-wrong"))), false), + + // one field and one metadata mismatch + arguments(messageWithFieldsBuilder("test", Direction.SECOND, + listOf(Pair("test-field1", "test-value-wrong"), Pair("test-field2", "test-value2"))), false), + arguments(messageWithFieldsBuilder("test-wrong", Direction.FIRST, + listOf(Pair("test-field1", "test-value1"), Pair("test-field2", "test-value-wrong"))), false) + ) + + @JvmStatic + fun parsedMessagesBothFilters() : List = listOf( + arguments(messageWithFieldsBuilder("test", Direction.FIRST, + listOf(Pair("test-field1", "test-value1"), Pair("test-field2", "test-value2"))), true), + arguments(messageWithFieldsBuilder("test", Direction.FIRST, + listOf(Pair("test-field1", "test-value-wrong"), Pair("test-field2", "test-value2"))), false), + arguments(messageWithFieldsBuilder("test", Direction.FIRST, + listOf(Pair("test-field1", "test-value1"), Pair("test-field2", "test-value-wrong"))), false), + arguments(messageWithFieldsBuilder("test", Direction.FIRST, + listOf(Pair("test-field1", "test-value-wrong"), Pair("test-field2", "test-value-wrong"))), false) + ) + + @JvmStatic + fun messagesWithOneProperty() : List = listOf( + arguments(messageWithOnePropertyBuilder("test", "test-property", "property-value"), true), + arguments(messageWithOnePropertyBuilder("test", "test-property", "property-value-wrong"), false), + arguments(rawMessageWithOnePropertyBuilder("test-property", "property-value"), true), + arguments(rawMessageWithOnePropertyBuilder("test-property", "property-value-wrong"), false) + ) + + @JvmStatic + fun messagesWithPropertiesAndMetadata() : List = listOf( + arguments(messageWithOnePropertyBuilder("test", "test-property", "property-value"), true), + arguments(messageWithOnePropertyBuilder("test", "test-property", "property-value-wrong"), false), + arguments(messageWithOnePropertyBuilder("test-wrong", "test-property", "property-value"), false) + ) + + @JvmStatic + fun rawMessagesBothFilters() : List = listOf( + arguments(simpleRawMessageBuilder("test-alias", Direction.FIRST), true), + arguments(simpleRawMessageBuilder("test-alias", Direction.SECOND), false), + arguments(simpleRawMessageBuilder("test-alias-wrong-value", Direction.SECOND), false) + ) } } \ No newline at end of file