lundi 23 février 2015

Spring boot integration test injecting mock object via autowire

I am using spring boot with java based configurations. I have following classes structure



@Service
public class Service implements IService{
@autowire
private IProcessor processor;

public void perform(Parameter param){
processor.process(param);
}
}

@Service
public class Processor implements IProcessor {
@autowire
private ProxyFactory factory;

public void process(Parameter param){
final ExternalSysProxy proxy = factory.get(param.getValue(), param.getId());
proxy.call();
}
}

@Repository
public class ProxyFactory {
public Proxy get(String value, String id){
final ExternalSysProxy proxy = new proxy(value, id);
return proxy;
}
}


The proxy object here makes call to external system. I want to write integration test by mocking proxy object. Can you please give me some guidance how I can inject mock proxy object in this structure.


Aucun commentaire:

Enregistrer un commentaire