I am implementing a circuit breaker solution to my code using the Spring-Breaker project and was writing the test cases for the same.
Consider the following example:
@CircuitBreaker
methodA() {
//some code
gatewayServiceCall()
//some code
}
I need to test methodA and make it fail using CircuitBreaker timeout so I wrote a test class that mocks this.
setup() {
gatewayService = mock(GatewayService.class);
when(gatewayService.methodName().thenReturn(something);
}
@Test
testMethodA() {
methodA();
}
How do I make sure I call the methodA() but also mock the gatewayServiceCall.
I hope the question was clear. Please let me know if it wasn't. I'll try to elaborate further.
Thanks.