### Question:
PersistenceExceptionSubclassFilterRetryPredicate extends DatabaseRetryPredicate { @Override public boolean test(final Throwable throwable) { LOG.trace("Retry predicate investigation started. [throwable.class={0}]", throwable.getClass().getName()); boolean applies = true; if ((throwable.getCause() == null) && BLACKLIST_WITHOUT_CAUSE.contains(throwable.getClass())) { applies = false; } else { for (final Class<?> classDownTheStackTrace : getAllExceptions(throwable)) { for (final Class<? extends PersistenceException> blacklistElement : BLACKLIST_WITH_CAUSE) { if (blacklistElement.isAssignableFrom(classDownTheStackTrace)) { applies = false; } } } } LOG.trace("Retry predicate investigation finished. [applies={0}]", applies); return applies; }  @Override boolean test(final Throwable throwable);  }### Answer:
@Test public void testFilteredJPAExceptions() { assertFalse(predicate.test(new EntityExistsException())); assertFalse(predicate.test(new EntityNotFoundException())); assertFalse(predicate.test(new LockTimeoutException())); assertFalse(predicate.test(new NoResultException())); assertFalse(predicate.test(new NonUniqueResultException())); assertFalse(predicate.test(new OptimisticLockException())); assertFalse(predicate.test(new PessimisticLockException())); assertFalse(predicate.test(new QueryTimeoutException())); assertFalse(predicate.test(new TransactionRequiredException())); }
@Test public void testNotFilteredJPAExceptions() { assertTrue(predicate.test(new RollbackException())); assertTrue(predicate.test(new PersistenceException())); }
@Test public void testNonJPAExceptions() { assertTrue(predicate.test(new IllegalStateException())); assertTrue(predicate.test(new Exception())); }
@Test public void testNestedFilteredJPAExceptions() { assertFalse(predicate.test(wrapCause(new EntityExistsException()))); assertFalse(predicate.test(wrapCause(new EntityNotFoundException()))); assertFalse(predicate.test(wrapCause(new LockTimeoutException()))); assertFalse(predicate.test(wrapCause(new NoResultException()))); assertFalse(predicate.test(wrapCause(new NonUniqueResultException()))); assertFalse(predicate.test(wrapCause(new OptimisticLockException()))); assertFalse(predicate.test(wrapCause(new PessimisticLockException()))); assertFalse(predicate.test(wrapCause(new QueryTimeoutException()))); assertFalse(predicate.test(wrapCause(new TransactionRequiredException()))); }
@Test public void testNestedNotFilteredJPAExceptions() { assertTrue(predicate.test(wrapCause(new RollbackException()))); assertTrue(predicate.test(wrapCause(new PersistenceException()))); }
@Test public void testNestedNonJPAExceptions() { assertTrue(predicate.test(wrapCause(new RuntimeException()))); assertTrue(predicate.test(wrapCause(new Exception()))); }
@Test public void testPlainJPAExecutorExceptionWithMessage() { assertFalse(predicate.test(wrapMessage("No WorkflowJobBean found in database"))); assertFalse(predicate.test(wrapMessage("Some other message"))); assertFalse(predicate.test(wrapMessageRuntime("Some runtime problem"))); }