Injecting a RandomBase into a DoFn

2 views
Skip to first unread message

Christopher Tignor

unread,
Mar 14, 2016, 8:21:37 PM3/14/16
to flume-user
Hello,

I'd like to inject a RandomBase into my DoFn class in order to be able to provide mocks during testing.

I've written my own constructor to take the RandomBase* as an arg.
When the arg is null it builds its own MTRandom  - this is the production path.

i also updated DecodeState() to call this constructor with the nullptr arg (I encode another string value in this stateful function).

In my test however I provide the DoFn with a non-null mock but because of the deferred evaluation it chooses to discard (encode) this object and decode it later without my RandomBase, essentially taking the prod path.

Is there a way I can solve this or at least make Flume not defer the use of my initial DoFn object that has my mock?

thanks,

C>T>
Reply all
Reply to author
Forward
0 new messages