-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Th2 3673 common need to change the filter #201
Open
Xanclry
wants to merge
18
commits into
master
Choose a base branch
from
TH2-3673-common-need-to-change-the-filter
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
35f6fad
[TH2-3673] Fixed filters logic
Xanclry 952232b
[TH2-3673] Added tests for new filtering logic
Xanclry 997dbbb
[TH2-3673] Added tests for new filtering logic
Xanclry b3a2a18
[TH2-3673] Minor optimization for verifying against multiple filters
Xanclry abd9642
[TH2-3673] Tests for multiple same values
Xanclry ae7e315
[TH2-3673] minor test code style improvements
Xanclry a517c7c
Merge branch 'master' into TH2-3673-common-need-to-change-the-filter
Xanclry 76b908c
additional tests
Xanclry e3a5c0b
changed logic for filtering message batches
Xanclry c88af55
tests for filtering message batches
Xanclry b49399e
added properties field in filter; added related tests
Xanclry 11a848b
tests refactor
Xanclry 259e0de
added additional tests for properties filtering
Xanclry b6b2f2d
tests refactoring with util methods
Xanclry 8f44ca4
added protocol field to metadata, added according tests
Xanclry 04a6ff8
[TH2-3673] run ci
Xanclry 4d26cee
[TH2-3673] added aliases for message filter configuration
Xanclry 6e105ba
Merge branch 'master' into TH2-3673-common-need-to-change-the-filter
Xanclry File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,13 +35,7 @@ import org.junit.jupiter.api.Assertions | |
import org.junit.jupiter.api.Nested | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.function.Executable | ||
import org.mockito.kotlin.any | ||
import org.mockito.kotlin.anyOrNull | ||
import org.mockito.kotlin.argumentCaptor | ||
import org.mockito.kotlin.eq | ||
import org.mockito.kotlin.mock | ||
import org.mockito.kotlin.never | ||
import org.mockito.kotlin.verify | ||
import org.mockito.kotlin.* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please avoid multiple imports. You can configure idea for that |
||
|
||
class TestRabbitMessageGroupBatchRouter { | ||
private val connectionConfiguration = ConnectionManagerConfiguration() | ||
|
@@ -263,6 +257,75 @@ class TestRabbitMessageGroupBatchRouter { | |
} | ||
} | ||
|
||
@Nested | ||
inner class BatchPublishing { | ||
|
||
private val router = createRouter(mapOf( | ||
"test-pine" to QueueConfiguration( | ||
routingKey = "", | ||
queue = "subscribe", | ||
exchange = "test-exchange", | ||
attributes = listOf("subscribe") | ||
), | ||
"test-pin1" to QueueConfiguration( | ||
routingKey = "test", | ||
queue = "", | ||
exchange = "test-exchange", | ||
attributes = listOf("publish"), | ||
filters = listOf( | ||
MqRouterFilterConfiguration( | ||
metadata = listOf( | ||
FieldFilterConfiguration( | ||
fieldName = "message_type", | ||
expectedValue = "test-message", | ||
operation = FieldFilterOperation.EQUAL | ||
) | ||
) | ||
) | ||
) | ||
), | ||
)) | ||
|
||
@Test | ||
fun `publish batch if all messages passed`() { | ||
router.send( | ||
MessageGroupBatch.newBuilder() | ||
.addGroups(MessageGroup.newBuilder() | ||
.apply { this += message("test-message", Direction.FIRST, "test-alias1") } | ||
Nikita-Smirnov-Exactpro marked this conversation as resolved.
Show resolved
Hide resolved
|
||
.apply { this += message("test-message", Direction.FIRST, "test-alias2") } | ||
.apply { this += message("test-message", Direction.FIRST, "test-alias3") } | ||
).build() | ||
) | ||
verify(connectionManager, times(1)).basicPublish(any(), any(), anyOrNull(), any()) | ||
} | ||
|
||
@Test | ||
fun `dont publish batch if all messages not passed`() { | ||
router.send( | ||
MessageGroupBatch.newBuilder() | ||
.addGroups(MessageGroup.newBuilder() | ||
.apply { this += message("test-message1", Direction.FIRST, "test-alias1") } | ||
.apply { this += message("test-message2", Direction.FIRST, "test-alias2") } | ||
.apply { this += message("test-message3", Direction.FIRST, "test-alias3") } | ||
).build() | ||
) | ||
verify(connectionManager, never()).basicPublish(any(), any(), anyOrNull(), any()) | ||
} | ||
|
||
@Test | ||
fun `publish full batch if one message is passed`() { | ||
router.send( | ||
MessageGroupBatch.newBuilder() | ||
.addGroups(MessageGroup.newBuilder() | ||
.apply { this += message("test-message1", Direction.FIRST, "test-alias1") } | ||
.apply { this += message("test-message", Direction.FIRST, "test-alias2") } | ||
.apply { this += message("test-message3", Direction.FIRST, "test-alias3") } | ||
).build() | ||
) | ||
verify(connectionManager, times(1)).basicPublish(any(), any(), anyOrNull(), any()) | ||
} | ||
} | ||
|
||
private fun createRouter(pins: Map<String, QueueConfiguration>): MessageRouter<MessageGroupBatch> = | ||
RabbitMessageGroupBatchRouter().apply { | ||
init(DefaultMessageRouterContext( | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean this case, here we can see:
Could you please write others methods in a similar style