My brethren, count it all joy when you fall into various trials, knowing that the testing of your faith produces patience. But let patience have its perfect work, that you may be perfect and complete, lacking nothing. (James 1:2-4)
When bad things happen to us, we are to look upon that as opportunities for growth. This is the way of the gospel. Any other perspective is not biblical.
When bad things happen we still may feel pain. No where in scripture does it say we will not feel pain. This means that we may be feelings two conflicting or opposite emotions. We may feel joy knowing that a growth opportunity has come while at the same time feeling pain that we are in an uncomfortable situation.
Personal optimism is required in all situations. We are to believe that greater endurance will lead to greater results.