Search in sources :

Example 21 with MifosPage

use of org.mifos.test.acceptance.framework.MifosPage in project head by mifos.

the class BatchJobHelper method checkBatchJobsHaveFinished.

@SuppressWarnings("PMD")
private boolean checkBatchJobsHaveFinished(Map<String, String> previousRuns) {
    (new MifosPage(selenium)).logout();
    UiTestUtils.sleep(WAITING_TIME);
    LoginPage loginPage = appLauncher.launchMifos();
    loginPage.tryLoginUsingDefaultCredentials();
    if (!selenium.isElementPresent("//span[@id='page.id']") || "Login".equals(selenium.getAttribute("page.id@title"))) {
        return false;
    } else {
        Assert.assertEquals(selenium.getAttribute("page.id@title"), "Home");
    }
    HomePage homePage = new HomePage(selenium);
    homePage.tryNavigateToAdminPage();
    if ("Login".equals(selenium.getAttribute("page.id@title"))) {
        return false;
    } else {
        Assert.assertEquals(selenium.getAttribute("page.id@title"), AdminPage.PAGE_ID);
    }
    adminPage.tryNavigateToBatchJobsPage();
    if (selenium.isElementPresent("//span[@id='page.id']")) {
        // TODO Batch Jobs page do not have page.id!
        if ("Login".equals(selenium.getAttribute("page.id@title"))) {
            return false;
        } else {
            Assert.assertTrue(false, "Expected Batch Jobs page, but was: " + selenium.getAttribute("page.id@title"));
        }
    }
    List<String> completedJobs = new ArrayList<String>();
    for (Map.Entry<String, String> entry : previousRuns.entrySet()) {
        if (entry.getValue().equals(batchJobsPage.getPreviousRunStart(entry.getKey()))) {
            for (String job : completedJobs) {
                previousRuns.remove(job);
            }
            return false;
        }
        Assert.assertEquals(batchJobsPage.getPreviousRunStatus(entry.getKey()), "Previous run status:  Completed");
        completedJobs.add(entry.getKey());
    }
    return true;
}
Also used : HomePage(org.mifos.test.acceptance.framework.HomePage) ArrayList(java.util.ArrayList) MifosPage(org.mifos.test.acceptance.framework.MifosPage) HashMap(java.util.HashMap) Map(java.util.Map) LoginPage(org.mifos.test.acceptance.framework.login.LoginPage)

Aggregations

MifosPage (org.mifos.test.acceptance.framework.MifosPage)21 AfterMethod (org.testng.annotations.AfterMethod)10 DateTimeUpdaterRemoteTestingService (org.mifos.test.acceptance.remote.DateTimeUpdaterRemoteTestingService)8 HomePage (org.mifos.test.acceptance.framework.HomePage)4 LoginPage (org.mifos.test.acceptance.framework.login.LoginPage)4 QuestionnairePage (org.mifos.test.acceptance.framework.questionnaire.QuestionnairePage)3 AppLauncher (org.mifos.test.acceptance.framework.AppLauncher)2 AdminPage (org.mifos.test.acceptance.framework.admin.AdminPage)2 ClientViewDetailsPage (org.mifos.test.acceptance.framework.client.ClientViewDetailsPage)2 NavigationHelper (org.mifos.test.acceptance.framework.testhelpers.NavigationHelper)2 Test (org.testng.annotations.Test)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 DateTimeService (org.mifos.framework.util.DateTimeService)1 EditPenaltyPreviewPage (org.mifos.test.acceptance.framework.admin.EditPenaltyPreviewPage)1 ImportTransactionsPage (org.mifos.test.acceptance.framework.admin.ImportTransactionsPage)1 NewPenaltyPreviewPage (org.mifos.test.acceptance.framework.admin.NewPenaltyPreviewPage)1 ClientSearchResultsPage (org.mifos.test.acceptance.framework.client.ClientSearchResultsPage)1 ChangePasswordPage (org.mifos.test.acceptance.framework.login.ChangePasswordPage)1