Skip to content

KAFKA-20965: Remove hamcrest from org.apache.kafka.streams.state.internals.metrics package - #23201

Merged
m1a2st merged 1 commit into
apache:trunkfrom
korih:KAFKA-20965-hamcrest-state-metrics
Aug 28, 2026
Merged

KAFKA-20965: Remove hamcrest from org.apache.kafka.streams.state.internals.metrics package#23201
m1a2st merged 1 commit into
apache:trunkfrom
korih:KAFKA-20965-hamcrest-state-metrics

Conversation

@korih

@korih korih commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Migrated hamcrest to junit

Reviewers: Uros (github:uros-b), Ken Huang s7133700@gmail.com

Copilot AI lite review requested due to automatic review settings August 19, 2026 23:10
@github-actions github-actions Bot added triage PRs from the community streams tests Test fixes (including flaky tests) small Small PRs labels Aug 19, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(...)) with Assertions.assertEquals(...) for object and message comparisons.
  • Replaced notNullValue() checks with Assertions.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.

@github-actions github-actions Bot removed the triage PRs from the community label Aug 20, 2026
@uros-b

uros-b commented Aug 21, 2026

Copy link
Copy Markdown
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>

@m1a2st m1a2st left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM

@m1a2st

m1a2st commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Thanks @korih for this patch! Could you merge the latest trunk and retrigger the CI?

@korih
korih force-pushed the KAFKA-20965-hamcrest-state-metrics branch from cd54510 to 4d134b1 Compare August 27, 2026 14:05
@korih

korih commented Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @korih for this patch! Could you merge the latest trunk and retrigger the CI?

done!

@m1a2st
m1a2st merged commit d688109 into apache:trunk Aug 28, 2026
20 checks passed
@korih
korih deleted the KAFKA-20965-hamcrest-state-metrics branch August 28, 2026 02:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-approved small Small PRs streams tests Test fixes (including flaky tests)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants