It has been authentically related from the Prophet (Sallahu alaihi wa salam) on the authority of Ibn ‘Abbas -May Allah be pleased with him – that when he was a small boy, the Prophet (Sallahu alaihi wa salam) advised him by saying,
Know Allah in times of ease and He will know you in times of adversities
Nnarrated by Ahmad and others.
Al Hafidh Ibn Rajab Al Hanbali – may Allah have mercy upon him- mentioned in his book, ‘Al Jaam’I Al ‘Uloom wal Hikm’, pg. 424,
In the general sense, whoever has dealt with Allah with taqwa and obedience while in a state of ease, then Allah will deal with him with compassion and assist him in the circumstance of his experiencing hardship.