If you make a proper redirect, with a 301 return code from the old urls to the new urls, the ranking should not be affected.
https://support.google.com/webmasters/answer/83105?hl=en
However, this is every SEO'ers nightmare, because what if... :) I think you just have to trust Google's promise that ranking will be kept when you create proper, working redirects.