I have a method that calls a method called "burn" inside that throws a data exception, and if so, then it is caught in a try/catch block and logs to a logger. The class is using the annotation @Slf4j however, and lombok.extern.slf4j:
@Slf4j
public class MyClass {
private void myMethod(Type parameter) throws Exception {
try {
dataGateway.burn(id);
}
catch {
log.error("Failed to burn({})",id);
}
}
I have already mocked the datagateway and have it throwing an exception when burn is called, I know the exception is caught but how do I use verify to assert the logger was called with .error?? DateGateway dBMock = mock(DateGateway.class);
when(dBMock.burn(anyString())).thenReturn(new DataException("exception"));