The Prophet ﷺ said, "The believer is like a fresh stalk of grain. Whichever direction the wind blows, it bends it, and when the wind subsides, it straightens up again, bending with each trial. The wicked person, however, is like a cedar tree, solid and rigid, standing firm until Allah breaks it whenever He wills."
أن النبي ﷺ قال: مثل المؤمن كمثل الخامة من الزرع، من حيث أتتها الريح كفأتها، فإذا اعتدلت تكفا بالبلاء والفاجر كالأرزة صماء معتدلة، حتى يقصمها الله إذا شاء.
Bukhari related it in the Book of the Sick (5644) and Muslim in the Characteristics of the Hypocrites (2809), both from two different routes, from Abu Hurairah, and the wording given here is Bukhari's.Muslim's wording is, "The believer is like a crop, the wind keeps bending it, and the believer keeps being afflicted by trials. And the hypocrite is like the cedar tree, it does not sway until it is uprooted all at once."In another version, instead of "bending it," it says "swaying it."