[GitHub] [kafka] wycccccc commented on a change in pull request #10835: KAFKA-12905: Replace EasyMock and PowerMock with Mockito for NamedCacheMetricsTest
wycc commented on a change in pull request #10835:
URL: https://github.com/apache/kafka/pull/10835#discussion_r648148202
##
File path:
streams/src/test/java/org/apache/kafka/streams/state/internals/metrics/NamedCacheMetricsTest.java
##
@@ -49,37 +41,28 @@
private static final String HIT_RATIO_MIN_DESCRIPTION = "The minimum cache
hit ratio";
private static final String HIT_RATIO_MAX_DESCRIPTION = "The maximum cache
hit ratio";
-private final StreamsMetricsImpl streamsMetrics =
createMock(StreamsMetricsImpl.class);
-private final Sensor expectedSensor = mock(Sensor.class);
+private Sensor expectedSensor = Mockito.mock(Sensor.class);
private final Map tagMap = mkMap(mkEntry("key", "value"));
@Test
public void shouldGetHitRatioSensorWithBuiltInMetricsVersionCurrent() {
final String hitRatio = "hit-ratio";
-mockStatic(StreamsMetricsImpl.class);
-expect(streamsMetrics.version()).andStubReturn(Version.LATEST);
-expect(streamsMetrics.cacheLevelSensor(THREAD_ID, TASK_ID, STORE_NAME,
hitRatio, RecordingLevel.DEBUG))
-.andReturn(expectedSensor);
-expect(streamsMetrics.cacheLevelTagMap(THREAD_ID, TASK_ID,
STORE_NAME)).andReturn(tagMap);
+final StreamsMetricsImpl streamsMetrics =
Mockito.mock(StreamsMetricsImpl.class);
+Mockito.when(streamsMetrics.cacheLevelSensor(THREAD_ID, TASK_ID,
STORE_NAME, hitRatio, RecordingLevel.DEBUG)).thenReturn(expectedSensor);
+Mockito.when(streamsMetrics.cacheLevelTagMap(THREAD_ID, TASK_ID,
STORE_NAME)).thenReturn(tagMap);
StreamsMetricsImpl.addAvgAndMinAndMaxToSensor(
-expectedSensor,
-StreamsMetricsImpl.CACHE_LEVEL_GROUP,
-tagMap,
-hitRatio,
-HIT_RATIO_AVG_DESCRIPTION,
-HIT_RATIO_MIN_DESCRIPTION,
-HIT_RATIO_MAX_DESCRIPTION);
-replay(streamsMetrics);
-replay(StreamsMetricsImpl.class);
+expectedSensor,
+StreamsMetricsImpl.CACHE_LEVEL_GROUP,
+tagMap,
+hitRatio,
+HIT_RATIO_AVG_DESCRIPTION,
+HIT_RATIO_MIN_DESCRIPTION,
+HIT_RATIO_MAX_DESCRIPTION);
Review comment:
Thank you for the review. @ijuma @chia7712 @cadonna
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
[GitHub] [kafka] wycccccc commented on a change in pull request #10835: KAFKA-12905: Replace EasyMock and PowerMock with Mockito for NamedCacheMetricsTest
wycc commented on a change in pull request #10835: URL: https://github.com/apache/kafka/pull/10835#discussion_r648145898 ## File path: streams/src/test/java/org/apache/kafka/streams/state/internals/metrics/NamedCacheMetricsTest.java ## @@ -49,37 +41,28 @@ private static final String HIT_RATIO_MIN_DESCRIPTION = "The minimum cache hit ratio"; private static final String HIT_RATIO_MAX_DESCRIPTION = "The maximum cache hit ratio"; -private final StreamsMetricsImpl streamsMetrics = createMock(StreamsMetricsImpl.class); -private final Sensor expectedSensor = mock(Sensor.class); +private Sensor expectedSensor = Mockito.mock(Sensor.class); Review comment: OK,I have changed.Thanks your suggestion. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
[GitHub] [kafka] wycccccc commented on a change in pull request #10835: KAFKA-12905: Replace EasyMock and PowerMock with Mockito for NamedCacheMetricsTest
wycc commented on a change in pull request #10835:
URL: https://github.com/apache/kafka/pull/10835#discussion_r646848688
##
File path: build.gradle
##
@@ -1710,6 +1711,8 @@ project(':streams') {
testImplementation libs.powermockEasymock
testImplementation libs.bcpkix
testImplementation libs.hamcrest
+testImplementation libs.mockitoCore
Review comment:
Yes,It's extra.I have removed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
[GitHub] [kafka] wycccccc commented on a change in pull request #10835: KAFKA-12905: Replace EasyMock and PowerMock with Mockito for NamedCacheMetricsTest
wycc commented on a change in pull request #10835:
URL: https://github.com/apache/kafka/pull/10835#discussion_r646847971
##
File path: build.gradle
##
@@ -1484,6 +1484,7 @@ project(':storage') {
testImplementation project(':clients').sourceSets.test.output
testImplementation libs.junitJupiter
testImplementation libs.mockitoCore
+testImplementation libs.mockitoInline // supports mocking static methods,
final classes, etc.
Review comment:
sor,my mis.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
[GitHub] [kafka] wycccccc commented on a change in pull request #10835: KAFKA-12905: Replace EasyMock and PowerMock with Mockito for NamedCacheMetricsTest
wycc commented on a change in pull request #10835: URL: https://github.com/apache/kafka/pull/10835#discussion_r646802528 ## File path: streams/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker ## @@ -0,0 +1,2 @@ +mock-maker-inline Review comment: Thanks suggestion, I have modified. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
[GitHub] [kafka] wycccccc commented on a change in pull request #10835: KAFKA-12905: Replace EasyMock and PowerMock with Mockito for NamedCacheMetricsTest
wycc commented on a change in pull request #10835:
URL: https://github.com/apache/kafka/pull/10835#discussion_r646780507
##
File path: build.gradle
##
@@ -1710,6 +1710,7 @@ project(':streams') {
testImplementation libs.powermockEasymock
Review comment:
There are other dependencies that have not been modified, so this cannot
be removed .
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
