Add tes cases for role mapper.
Fix NPE on db connection.