You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "clolov (via GitHub)" <gi...@apache.org> on 2023/08/16 12:17:03 UTC
[GitHub] [kafka] clolov opened a new pull request, #14223: KAFKA-14133: Move AbstractStreamTest and RocksDBMetricsRecordingTriggerTest to Mockito
clolov opened a new pull request, #14223:
URL: https://github.com/apache/kafka/pull/14223
This pull requests migrates mocks from AbstractStreamTest and RocksDBMetricsRecordingTriggerTest to Mockito.
--
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] divijvaidya merged pull request #14223: KAFKA-14133: Move AbstractStreamTest and RocksDBMetricsRecordingTriggerTest to Mockito
Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya merged PR #14223:
URL: https://github.com/apache/kafka/pull/14223
--
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] clolov commented on a diff in pull request #14223: KAFKA-14133: Move AbstractStreamTest and RocksDBMetricsRecordingTriggerTest to Mockito
Posted by "clolov (via GitHub)" <gi...@apache.org>.
clolov commented on code in PR #14223:
URL: https://github.com/apache/kafka/pull/14223#discussion_r1301586778
##########
streams/src/test/java/org/apache/kafka/streams/kstream/internals/AbstractStreamTest.java:
##########
@@ -36,40 +36,39 @@
import org.apache.kafka.streams.kstream.internals.graph.ProcessorGraphNode;
import org.apache.kafka.streams.kstream.internals.graph.ProcessorParameters;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.junit.MockitoJUnitRunner;
import java.util.Random;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+@RunWith(MockitoJUnitRunner.StrictStubs.class)
public class AbstractStreamTest {
@Test
public void testToInternalValueTransformerSupplierSuppliesNewTransformers() {
- final ValueTransformerSupplier<?, ?> valueTransformerSupplier = createMock(ValueTransformerSupplier.class);
- expect(valueTransformerSupplier.get()).andAnswer(NoopValueTransformer::new).atLeastOnce();
- replay(valueTransformerSupplier);
+ final ValueTransformerSupplier<?, ?> valueTransformerSupplier = mock(ValueTransformerSupplier.class);
+ when(valueTransformerSupplier.get())
+ .thenReturn(new NoopValueTransformer<>())
+ .thenReturn(new NoopValueTransformer<>());
Review Comment:
These two separate objects are needed because otherwise I get:
```
org.apache.kafka.streams.kstream.ValueTransformerSupplier$MockitoMock$ktegTSa6 generates single reference. org.apache.kafka.streams.kstream.ValueTransformerSupplier$MockitoMock$ktegTSa6#get() must return a new object each time it is called.
java.lang.IllegalArgumentException: org.apache.kafka.streams.kstream.ValueTransformerSupplier$MockitoMock$ktegTSa6 generates single reference. org.apache.kafka.streams.kstream.ValueTransformerSupplier$MockitoMock$ktegTSa6#get() must return a new object each time it is called.
at org.apache.kafka.streams.internals.ApiUtils.checkSupplier(ApiUtils.java:99)
at org.apache.kafka.streams.kstream.internals.AbstractStream.toValueTransformerWithKeySupplier(AbstractStream.java:117)
at org.apache.kafka.streams.kstream.internals.AbstractStreamTest.testToInternalValueTransformerSupplierSuppliesNewTransformers(AbstractStreamTest.java:57)
```
since the `get` method is called twice in
```
public static <VR, V> void checkSupplier(final ValueTransformerSupplier<V, VR> supplier) {
if (supplier.get() == supplier.get()) { // <-- TWO INVOCATIONS HERE
final String supplierClass = supplier.getClass().getName();
throw new IllegalArgumentException(String.format("%s generates single reference." +
" %s#get() must return a new object each time it is called.", supplierClass, supplierClass));
}
}
```
--
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