Josh Adams scored twice as Wales survived a nervy finish to outlast Japan 28-21 at the Principality Stadium.