I would like to be able to mock SomeService, however, because it's a maven plugin, I'm out of control how this class is created. I need to create SomeService manually, because I can't use it in constructor or in other place. In a test I can mock SomeService - but it will be replace by new instance created in execute() method. Is it possible to mock this service in other way than using PowerMockito ??
@Mojo(name = "hellomojo")
public class HelloMojo extends AbstractMojo {
private SomeService service;
@Override
public void execute() throws MojoExecutionException {
service = createService();
}
private SomeService createService() {
return new SomeService(parameter);
}
}