@Test(expected = MessagePersistException.class) public void test_should_convert_unknown_data_integrity_exception_to_domain_exception() { final String message = "ERROR: duplicate key value violates unique constraint \"foo\""; final DataIntegrityViolationException exception = new DataIntegrityViolationException(message); new DataIntegrityViolationExceptionTransformer(exception).transform(); }
public void transform() { if (exception.getMessage().contains(UNIQUE_CONSTRAINT_NAME)) { throw new DuplicateMessageIdentityException(exception); } throw new MessagePersistException(exception); }
DataIntegrityViolationExceptionTransformer { public void transform() { if (exception.getMessage().contains(UNIQUE_CONSTRAINT_NAME)) { throw new DuplicateMessageIdentityException(exception); } throw new MessagePersistException(exception); } }
DataIntegrityViolationExceptionTransformer { public void transform() { if (exception.getMessage().contains(UNIQUE_CONSTRAINT_NAME)) { throw new DuplicateMessageIdentityException(exception); } throw new MessagePersistException(exception); } DataIntegrityViolationExceptionTransformer(DataIntegrityViolationException exception); }
DataIntegrityViolationExceptionTransformer { public void transform() { if (exception.getMessage().contains(UNIQUE_CONSTRAINT_NAME)) { throw new DuplicateMessageIdentityException(exception); } throw new MessagePersistException(exception); } DataIntegrityViolationExceptionTransformer(DataIntegrityViolationException exception); void transform(); }
DataIntegrityViolationExceptionTransformer { public void transform() { if (exception.getMessage().contains(UNIQUE_CONSTRAINT_NAME)) { throw new DuplicateMessageIdentityException(exception); } throw new MessagePersistException(exception); } DataIntegrityViolationExceptionTransformer(DataIntegrityViolationException exception); void transform();  }