I have an external team's package and I want to use one of the functions inside it.
//External package
class A (serviceExternalClient){
methodB {
value = serviceExternalClient.callExternalService()
otherProcesses(value)
}
}
class A2 (serviceExternalClient){
methodB {
value = serviceExternalClient.callExternalService2()
otherProcesses(value)
}
}
...
class AN (serviceExternalClient){
methodB {
value = serviceExternalClient.callExternalServiceN()
otherProcesses(value)
}
}
class A is public and I want to use methodB in all A classes but I don't have access to serviceExternal service so I want to intercept or stub callExternalService to return default values so that otherProcesses works and I can receive its results.
serviceExternalClient is injected using Dependency Injection.
I heard about using Reflection but couldn't figure out how to abstract it.
I ultimately want to do,
A.methodB()
but the external call is blocking the subsequent operation since I don't have access to it. The data provided by external call is irrelavant to me.