Creating a backtype.storm.tuple.Tuple file for testing?

I am new to Storm and trying to figure out how to write a bolt test that tests a method execute(Tuple tuple)in a subclass BaseRichBolt.

The problem is that it is Tupleimmutable, and I do not see any methods or collectors for creating a new Tuple. How can I create my own Tupleor how can I test a bolt using test input?

I use Scala, not Java, but the answer should be easily translatable.

+5
source share
1 answer

Tuple Object Failure is a good storm launch project solution . It's simple:

package storm.starter.tools;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import backtype.storm.Constants;
import backtype.storm.tuple.Tuple;

public final class MockTupleHelpers {

    private MockTupleHelpers() {
    }

    public static Tuple mockTickTuple() {
        return mockTuple(Constants.SYSTEM_COMPONENT_ID, Constants.SYSTEM_TICK_STREAM_ID);
    }

    public static Tuple mockTuple(String componentId, String streamId) {
        Tuple tuple = mock(Tuple.class);
        when(tuple.getSourceComponent()).thenReturn(componentId);
        when(tuple.getSourceStreamId()).thenReturn(streamId);
        return tuple;
    }
}
+5
source

All Articles