KAFKA-20965: Remove hamcrest from org.apache.kafka.streams.state.internals.metrics package - #23201
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates Kafka Streams state-store metrics unit tests in org.apache.kafka.streams.state.internals.metrics to eliminate Hamcrest usage by switching assertions to JUnit Jupiter.
Changes:
- Replaced
assertThat(..., is(...))withAssertions.assertEquals(...)for object and message comparisons. - Replaced
notNullValue()checks withAssertions.assertNotNull(...)where applicable. - Removed Hamcrest static imports from the affected test classes.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| streams/src/test/java/org/apache/kafka/streams/state/internals/metrics/StateStoreMetricsTest.java | Switches Hamcrest assertThat/is to JUnit assertEquals for sensor verification. |
| streams/src/test/java/org/apache/kafka/streams/state/internals/metrics/RocksDBMetricsTest.java | Replaces Hamcrest equality assertion with JUnit assertEquals. |
| streams/src/test/java/org/apache/kafka/streams/state/internals/metrics/RocksDBMetricsRecorderTest.java | Converts multiple Hamcrest assertions (including exception message checks) to JUnit assertEquals. |
| streams/src/test/java/org/apache/kafka/streams/state/internals/metrics/RocksDBMetricsRecorderGaugesTest.java | Replaces Hamcrest null/equality assertions with assertNotNull and assertEquals. |
| streams/src/test/java/org/apache/kafka/streams/state/internals/metrics/NamedCacheMetricsTest.java | Updates Hamcrest sensor equality assertion to JUnit assertEquals. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
uros-b
approved these changes
Aug 21, 2026
Member
|
LGTM |
chia7712
pushed a commit
that referenced
this pull request
Aug 26, 2026
…nternals.metrics package (#23278) JIRA: https://issues.apache.org/jira/browse/KAFKA-20987 Parent: https://issues.apache.org/jira/browse/KAFKA-20948 Migrate hamcrest `assertThat` usage in `org.apache.kafka.streams.processor.internals.metrics` tests to JUnit 5. This package is not covered by the existing subtasks: - KAFKA-20963 / PR #23200 covers only `org.apache.kafka.streams.processor` (top-level) - KAFKA-20965 / PR #23201 covers `org.apache.kafka.streams.state.internals.metrics` Files changed: - `ProcessorNodeMetricsTest.java` - `StreamsMetricsImplTest.java` - `TaskMetricsTest.java` - `ThreadMetricsTest.java` - `TopicMetricsTest.java` No production code changes. This contribution is original work and is licensed to the project under the Apache License, Version 2.0. ### Tests ``` ./gradlew :streams:test \ --tests org.apache.kafka.streams.processor.internals.metrics.ProcessorNodeMetricsTest \ --tests org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImplTest \ --tests org.apache.kafka.streams.processor.internals.metrics.TaskMetricsTest \ --tests org.apache.kafka.streams.processor.internals.metrics.ThreadMetricsTest \ --tests org.apache.kafka.streams.processor.internals.metrics.TopicMetricsTest \ :streams:checkstyleTest :streams:spotlessCheck ``` BUILD SUCCESSFUL. Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
Contributor
|
Thanks @korih for this patch! Could you merge the latest trunk and retrigger the CI? |
…rnals.metrics package
korih
force-pushed
the
KAFKA-20965-hamcrest-state-metrics
branch
from
August 27, 2026 14:05
cd54510 to
4d134b1
Compare
Contributor
Author
done! |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Migrated hamcrest to junit
Reviewers: Uros (github:uros-b), Ken Huang s7133700@gmail.com