Repository: apache/kafka
File: streams/src/test/java/org/apache/kafka/streams/kstream/internals/KStreamFlatTransformTest.java (Java)

Code before:
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentMatchers;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;

import java.util.Arrays;
import java.util.Collections;

import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@RunWith(MockitoJUnitRunner.StrictStubs.class)
public class KStreamFlatTransformTest {

    private Number inputKey;
    private Number inputValue;

    @Mock
    private Transformer<Number, Number, Iterable<KeyValue<Integer, Integer>>> transformer;
    @Mock
    private InternalProcessorContext<Integer, Integer> context;

    private KStreamFlatTransformProcessor<Number, Number, Integer, Integer> processor;

    @Before
    public void setUp() {
        inputKey = 1;
        inputValue = 10;
        processor = new KStreamFlatTransformProcessor<>(transformer);
    }

    @Test
    public void shouldInitialiseFlatTransformProcessor() {
        processor.init(context);

        verify(transformer).init(context);
    }

    @Test
    public void shouldTransformInputRecordToMultipleOutputRecords() {
        final Iterable<KeyValue<Integer, Integer>> outputRecords = Arrays.asList(
                KeyValue.pair(2, 20),
                KeyValue.pair(3, 30),
                KeyValue.pair(4, 40));

        processor.init(context);

Review comment (suggestion):
In EasyMock a strict mock verifies also the order of the calls. In Mockito that is done by using `InOrder` (https://javadoc.io/doc/org.mockito/mockito-core/latest/org/mockito/Mockito.html#in_order_verification). Currently, this PR does not check the order which softens up the test. 

Code after:
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentMatchers;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;

import java.util.Arrays;
import java.util.Collections;

import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@RunWith(MockitoJUnitRunner.StrictStubs.class)
public class KStreamFlatTransformTest {

    private Number inputKey;
    private Number inputValue;

    @Mock
    private Transformer<Number, Number, Iterable<KeyValue<Integer, Integer>>> transformer;
    @Mock
    private InternalProcessorContext<Integer, Integer> context;
    private InOrder inOrder;

    private KStreamFlatTransformProcessor<Number, Number, Integer, Integer> processor;

    @Before
    public void setUp() {
        inputKey = 1;
        inputValue = 10;
        inOrder = inOrder(context);
        processor = new KStreamFlatTransformProcessor<>(transformer);
    }

    @Test
    public void shouldInitialiseFlatTransformProcessor() {
        processor.init(context);

        verify(transformer).init(context);
    }

    @Test
    public void shouldTransformInputRecordToMultipleOutputRecords() {
        final Iterable<KeyValue<Integer, Integer>> outputRecords = Arrays.asList(
                KeyValue.pair(2, 20),