/// <exception cref="System.Exception"/>
        private void VerifySubmitApp(MockRM rm, RMApp app, ApplicationId expectedAppId)
        {
            int maxWaittingTimes = 20;
            int count            = 0;

            while (true)
            {
                YarnApplicationState state = rm.GetApplicationReport(app.GetApplicationId()).GetYarnApplicationState
                                                 ();
                if (!state.Equals(YarnApplicationState.New) && !state.Equals(YarnApplicationState
                                                                             .NewSaving))
                {
                    break;
                }
                if (count > maxWaittingTimes)
                {
                    break;
                }
                Sharpen.Thread.Sleep(200);
                count++;
            }
            // Verify submittion is successful
            YarnApplicationState state_1 = rm.GetApplicationReport(app.GetApplicationId()).GetYarnApplicationState
                                               ();

            NUnit.Framework.Assert.IsTrue(state_1 == YarnApplicationState.Accepted || state_1
                                          == YarnApplicationState.Submitted);
            NUnit.Framework.Assert.AreEqual(expectedAppId, app.GetApplicationId());
        }