Mock all transformers in ETL chain to a single Mock

Im working on an ETL app where the ETL chain is maintained in Spring beans. Something like:

<bean id="extractor" children="t1" /> <bean id="t1" children="t2" /> <bean id="t2" children="t3" /> <bean id="t3" children=null /> 

And the classes look like:

class Transformer {     Transformer [] children = [Transformer with secret S2]     String secret = "S1";     public doSomething() {              } }  Class Transformer {     Transformer [] children = [Transformer with secret S3]     String secret = "S2";     public doSomething() {      } }  Class Transformer {     Transformer [] children = null;     String secret = "S3";     public doSomething() {              } } 

And the extractor looks like:

class Extractor  {     public transform(Transformer n) {         n.doSomething();         for(Transformer c: n.children) {             extractor(c);         }     } } 

Transformers have database related data and hence would like to mock them. One option is the duplicate the Spring bean etl chain with mocked transformers but I dont like duplication. Plus it would hard to maintain. I also dont want a separate mock for each Transformer.

I have access to the real instance of Extractor but once extractor() starts, I would like to mock doSomething() of all instances of Transformer.

Is this possible?

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.