Repository: apache/kafka
File: trogdor/src/test/java/org/apache/kafka/trogdor/workload/PayloadGeneratorTest.java (Java)

Code before:
        byte[] val3 = generator.generate(200);
        byte[] val3End = new byte[100];
        System.arraycopy(val3, 900, val3End, 0, 100);
        assertArrayEquals(val1End, val2End);
        assertArrayEquals(val1End, val3End);
    }
    
    @Test
    public void testRandomComponentPayloadGenerator() {
        NullPayloadGenerator nullGenerator = new NullPayloadGenerator();
        RandomComponent nullConfig = new RandomComponent(50, nullGenerator);
        
        UniformRandomPayloadGenerator uniformGenerator =
            new UniformRandomPayloadGenerator(5, 123, 0);
        RandomComponent uniformConfig = new RandomComponent(50, uniformGenerator);
        
        SequentialPayloadGenerator sequentialGenerator =
            new SequentialPayloadGenerator(4, 10);
        RandomComponent sequentialConfig = new RandomComponent(75, sequentialGenerator);
        
        ConstantPayloadGenerator constantGenerator =
            new ConstantPayloadGenerator(4, new byte[0]);
        RandomComponent constantConfig = new RandomComponent(25, constantGenerator);
        
        List<RandomComponent> components1 = new ArrayList<>(List.of(nullConfig, uniformConfig));
        List<RandomComponent> components2 = new ArrayList<>(List.of(sequentialConfig, constantConfig));
        byte[] expected = new byte[4];

        PayloadIterator iter = new PayloadIterator(
            new RandomComponentPayloadGenerator(4, components1));
        int notNull = 0;
        int isNull = 0;
        while (notNull < 1000 || isNull < 1000) {
            byte[] cur = iter.next();
            if (cur == null) {
                isNull++;
            } else {
                notNull++;
            }
        }
        
        iter = new PayloadIterator(
            new RandomComponentPayloadGenerator(123, components2));
        int isZeroBytes = 0;
        int isNotZeroBytes = 0;
        while (isZeroBytes < 500 || isNotZeroBytes < 1500) {
            byte[] cur = iter.next();
            if (Arrays.equals(expected, cur)) {
                isZeroBytes++;
            } else {
                isNotZeroBytes++;

Review comment (suggestion):
```suggestion
        List<RandomComponent> components1 = List.of(nullConfig, uniformConfig);
        List<RandomComponent> components2 = List.of(sequentialConfig, constantConfig);
```

Code after:
        byte[] val3End = new byte[100];
        System.arraycopy(val3, 900, val3End, 0, 100);
        assertArrayEquals(val1End, val2End);
        assertArrayEquals(val1End, val3End);
    }
    
    @Test
    public void testRandomComponentPayloadGenerator() {
        NullPayloadGenerator nullGenerator = new NullPayloadGenerator();
        RandomComponent nullConfig = new RandomComponent(50, nullGenerator);
        
        UniformRandomPayloadGenerator uniformGenerator =
            new UniformRandomPayloadGenerator(5, 123, 0);
        RandomComponent uniformConfig = new RandomComponent(50, uniformGenerator);
        
        SequentialPayloadGenerator sequentialGenerator =
            new SequentialPayloadGenerator(4, 10);
        RandomComponent sequentialConfig = new RandomComponent(75, sequentialGenerator);
        
        ConstantPayloadGenerator constantGenerator =
            new ConstantPayloadGenerator(4, new byte[0]);
        RandomComponent constantConfig = new RandomComponent(25, constantGenerator);
        
        List<RandomComponent> components1 = List.of(nullConfig, uniformConfig);
        List<RandomComponent> components2 = List.of(sequentialConfig, constantConfig);
        byte[] expected = new byte[4];

        PayloadIterator iter = new PayloadIterator(
            new RandomComponentPayloadGenerator(4, components1));
        int notNull = 0;
        int isNull = 0;
        while (notNull < 1000 || isNull < 1000) {
            byte[] cur = iter.next();
            if (cur == null) {
                isNull++;
            } else {
                notNull++;
            }
        }
        
        iter = new PayloadIterator(
            new RandomComponentPayloadGenerator(123, components2));
        int isZeroBytes = 0;
        int isNotZeroBytes = 0;
        while (isZeroBytes < 500 || isNotZeroBytes < 1500) {
            byte[] cur = iter.next();
            if (Arrays.equals(expected, cur)) {
                isZeroBytes++;
            } else {
                isNotZeroBytes++;
            }