You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2022/06/21 13:33:56 UTC

[GitHub] [kafka] cadonna opened a new pull request, #12322: MINOR: Fix static mock usage in NamedCacheMetricsTest

cadonna opened a new pull request, #12322:
URL: https://github.com/apache/kafka/pull/12322

   Before this PR the call to `StreamsMetricsImpl.addAvgAndMinAndMaxToSensor()`
   was just a call and not a verification on the mock. This miss happened
   during the switch from EasyMock to Mockito.
   
   
   ### Committer Checklist (excluded from commit message)
   - [ ] Verify design and implementation 
   - [ ] Verify test coverage and CI build status
   - [ ] Verify documentation (including upgrade notes)
   


-- 
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.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] cadonna merged pull request #12322: MINOR: Fix static mock usage in NamedCacheMetricsTest

Posted by GitBox <gi...@apache.org>.
cadonna merged PR #12322:
URL: https://github.com/apache/kafka/pull/12322


-- 
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.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] cadonna commented on a diff in pull request #12322: MINOR: Fix static mock usage in NamedCacheMetricsTest

Posted by GitBox <gi...@apache.org>.
cadonna commented on code in PR #12322:
URL: https://github.com/apache/kafka/pull/12322#discussion_r902627716


##########
streams/src/test/java/org/apache/kafka/streams/state/internals/metrics/NamedCacheMetricsTest.java:
##########
@@ -19,16 +19,20 @@
 import org.apache.kafka.common.metrics.Sensor;
 import org.apache.kafka.common.metrics.Sensor.RecordingLevel;
 import org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl;
+
+import org.junit.AfterClass;
 import org.junit.Test;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
+import org.mockito.MockedStatic;
 
 import java.util.Map;
 
 import static org.apache.kafka.common.utils.Utils.mkEntry;
 import static org.apache.kafka.common.utils.Utils.mkMap;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.mockStatic;
+import static org.mockito.Mockito.when;

Review Comment:
   Just reordering of the imports.



-- 
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.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] cadonna commented on pull request #12322: MINOR: Fix static mock usage in NamedCacheMetricsTest

Posted by GitBox <gi...@apache.org>.
cadonna commented on PR #12322:
URL: https://github.com/apache/kafka/pull/12322#issuecomment-1162770981

   Good call!
   
   The mockito docs say:
   
   > When using the inline mock maker, it is possible to mock static method invocations within the current thread and a user-defined scope. This way, Mockito assures that concurrently and sequentially running tests do not interfere.
   
   Additionally, I put the static mock into try-with-resource statements to limit the scope of the mock.


-- 
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.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org