SkipUniqueKeyViolationPolicy implements SkipPolicy { @Override public boolean shouldSkip(Throwable t, int skipCount) throws SkipLimitExceededException { boolean result = false; if (skipCount < 0 || isExpectedViolation(t)) { result = true; } return result; }  @Override boolean shouldSkip(Throwable t, int skipCount); static final String[] CONSTRAINT_NAMES; }
@Test public void testSkipConstraintViolationException() throws Exception { Assert.assertTrue(skipPolicy.shouldSkip(new ConstraintViolationException("foo", new SQLException(), SkipUniqueKeyViolationPolicy.CONSTRAINT_NAMES[0] ), 0 ) ); }
@Test public void testSkipSQLIntegrityConstraintViolationException() throws Exception { Assert.assertTrue(skipPolicy.shouldSkip( new SQLIntegrityConstraintViolationException(SkipUniqueKeyViolationPolicy.CONSTRAINT_NAMES[0]), 0) ); }
@Test public void testSkipPersistenceExceptionWithSQLIntegrityConstraintViolationException() throws Exception { Assert.assertTrue(skipPolicy.shouldSkip(new PersistenceException("foo", new SQLIntegrityConstraintViolationException( SkipUniqueKeyViolationPolicy.CONSTRAINT_NAMES[0] ) ), 0 ) ); }
@Test public void testSkipPersistenceExceptionWithConstraintViolationException() throws Exception { Assert.assertTrue(skipPolicy.shouldSkip(new PersistenceException("", new ConstraintViolationException("foo", new SQLException(), SkipUniqueKeyViolationPolicy.CONSTRAINT_NAMES[0]) ), 0 ) ); }
@Test public void testNotSkipException() throws Exception { Assert.assertFalse(skipPolicy.shouldSkip(new Exception(), 0)); }
@Test public void testGracefulSkip() throws Exception { Assert.assertTrue(skipPolicy.shouldSkip(null, -1)); }