SQLExceptionFactory extends AbstractExceptionFactory<SQLException> { @Override public boolean indicatesFailure(SQLException exception, Dialect dialect) { SQLException nextException = exception.getNextException(); return dialect.indicatesFailure(exception) || ((nextException != null) && this.indicatesFailure(nextException, dialect)); } SQLExceptionFactory(); @Override SQLException createException(String message); @Override boolean equals(SQLException exception1, SQLException exception2); @Override boolean indicatesFailure(SQLException exception, Dialect dialect); @Override ExceptionType getType();  }
@Test public void indicatesFailure() { Dialect dialect = mock(Dialect.class); SQLException exception = new SQLException(); SQLException nextException = new SQLException(); when(dialect.indicatesFailure(exception)).thenReturn(true); boolean result = this.factory.indicatesFailure(exception, dialect); assertTrue(result); reset(dialect); exception.setNextException(nextException); when(dialect.indicatesFailure(exception)).thenReturn(false); when(dialect.indicatesFailure(nextException)).thenReturn(true); result = this.factory.indicatesFailure(exception, dialect); assertTrue(result); }