Search in sources :

Example 1 with NewPenaltyPreviewPage

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

the class MainPenaltyTest method fillFormAndGotoPreviewPage.

@SuppressWarnings("PMD.SignatureDeclareThrowsException")
private MifosPage fillFormAndGotoPreviewPage(final PenaltyFormPage penaltyFormPage, final PenaltyFormParameters parameters, final int i, final boolean isCreatePage) throws Exception {
    parameters.setFrequency(PenaltyFormParameters.FREQUENCY_DAILY);
    parameters.setGlCode("31102 - Penalty");
    parameters.setDuration("1");
    parameters.setMax("15");
    parameters.setMin("1");
    if (i == 0) {
        parameters.setName(AMOUNT_PENALTY_NAME);
        parameters.setApplies(PenaltyFormParameters.APPLIES_SAVINGS);
        parameters.setPeriod(PenaltyFormParameters.PERIOD_DAYS);
        parameters.setAmount("2200.5");
        parameters.setRate("");
    } else if (i == 1) {
        parameters.setName(RATE_PENALTY_NAME);
        parameters.setApplies(PenaltyFormParameters.APPLIES_LOANS);
        parameters.setPeriod(PenaltyFormParameters.PERIOD_INSTALLMENTS);
        parameters.setRate("7.5");
        parameters.setFormula(PenaltyFormParameters.FORMULA_OUTSTANDING_LOAN);
        parameters.setAmount("");
    }
    MifosPage previewPage = null;
    if (isCreatePage) {
        previewPage = penaltyFormPage.fillParameters(parameters).submitPageAndGotoPenaltyPreviewPage(NewPenaltyPreviewPage.class);
        ((NewPenaltyPreviewPage) previewPage).verifyData(parameters);
    } else {
        parameters.setStatus(PenaltyFormParameters.STATUS_INACTIVE);
        previewPage = penaltyFormPage.fillParameters(parameters).submitPageAndGotoPenaltyPreviewPage(EditPenaltyPreviewPage.class);
        ((EditPenaltyPreviewPage) previewPage).verifyData(parameters);
    }
    return previewPage;
}
Also used : NewPenaltyPreviewPage(org.mifos.test.acceptance.framework.admin.NewPenaltyPreviewPage) EditPenaltyPreviewPage(org.mifos.test.acceptance.framework.admin.EditPenaltyPreviewPage) MifosPage(org.mifos.test.acceptance.framework.MifosPage)

Example 2 with NewPenaltyPreviewPage

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

the class MainPenaltyTest method verifyCreateAndEditPenalty.

@Test(enabled = true)
public void verifyCreateAndEditPenalty() throws Exception {
    final PenaltyFormParameters param = new PenaltyFormParameters();
    ViewPenaltiesPage penaltiesPage = navigationHelper.navigateToAdminPage().navigateToViewPenaltiesPage();
    int startLoanPenaltyCount = penaltiesPage.getLoanPenaltiesCount();
    int startSavingsPenaltyCount = penaltiesPage.getSavingPenaltiesCount();
    for (int i = 0; i < 2; ++i) {
        category = "";
        penaltiesPage.verifyLoanPenaltiesCount(startLoanPenaltyCount);
        penaltiesPage.verifySavingPenaltiesCount(startSavingsPenaltyCount + i);
        PenaltyFormPage newPenaltyPage = penaltiesPage.navigateToDefineNewPenaltyPage();
        for (int j = 0; j < 2; ++j) {
            verifyErrorsWithEmptyForm(newPenaltyPage, param, CREATE_PAGE);
            verifyErrorsWithoutSelectFrequency(newPenaltyPage, param, CREATE_PAGE);
            verifyErrorsWithIncorrectValue(newPenaltyPage, param, CREATE_PAGE);
            verifyErrorsWithMinGreaterThanMax(newPenaltyPage, param, CREATE_PAGE);
            verifyErrorsForLoanPenaltyWithoutAmount(newPenaltyPage, param, CREATE_PAGE);
            verifyErrorsForLoanPenaltyWithIncorrectRate(newPenaltyPage, param);
            verifyErrorsForLoanPenaltyWithoutFormula(newPenaltyPage, param);
            final NewPenaltyPreviewPage newPreviewPage = (NewPenaltyPreviewPage) fillFormAndGotoPreviewPage(newPenaltyPage, param, i, CREATE_PAGE);
            if (j == 0) {
                newPenaltyPage = newPreviewPage.navigateToEditPenaltyInformationPage();
            } else if (j == 1) {
                penaltiesPage = newPreviewPage.submit().navigateToViewPenaltiesPage();
            }
        }
        ViewPenaltyPage penaltyPage = null;
        if (i == 0) {
            penaltiesPage.verifyLoanPenaltiesCount(startLoanPenaltyCount);
            penaltiesPage.verifySavingPenaltiesCount(startSavingsPenaltyCount + 1);
            penaltyPage = penaltiesPage.navigateToViewPenaltyPage(AMOUNT_PENALTY_NAME);
        } else if (i == 1) {
            penaltiesPage.verifyLoanPenaltiesCount(startLoanPenaltyCount + 1);
            penaltiesPage.verifySavingPenaltiesCount(startSavingsPenaltyCount + 1);
            penaltyPage = penaltiesPage.navigateToViewPenaltyPage(RATE_PENALTY_NAME);
        }
        penaltyPage.verifyData(createData(param, i));
        final PenaltyFormPage editPenaltyPage = penaltyPage.navigateToEditPenaltyPage();
        category = param.getApplies();
        for (int j = 0; j < 2; ++j) {
            verifyErrorsWithEmptyForm(editPenaltyPage, param, EDIT_PAGE);
            verifyErrorsWithoutSelectFrequency(editPenaltyPage, param, EDIT_PAGE);
            verifyErrorsWithIncorrectValue(editPenaltyPage, param, EDIT_PAGE);
            verifyErrorsWithMinGreaterThanMax(editPenaltyPage, param, EDIT_PAGE);
            if (i == 0) {
                verifyErrorsForLoanPenaltyWithoutAmount(newPenaltyPage, param, EDIT_PAGE);
            } else {
                verifyErrorsForLoanPenaltyWithIncorrectRate(editPenaltyPage, param);
                verifyErrorsForLoanPenaltyWithoutFormula(editPenaltyPage, param);
            }
            final EditPenaltyPreviewPage editPreviewPage = (EditPenaltyPreviewPage) fillFormAndGotoPreviewPage(editPenaltyPage, param, i, EDIT_PAGE);
            if (j == 0) {
                newPenaltyPage = editPreviewPage.navigateToEditPenaltyInformationPage();
            } else if (j == 1) {
                penaltyPage = editPreviewPage.submit();
            }
        }
        penaltyPage.verifyData(createData(param, i));
        penaltiesPage = navigationHelper.navigateToAdminPage().navigateToViewPenaltiesPage();
    }
    penaltiesPage = navigationHelper.navigateToAdminPage().navigateToViewPenaltiesPage();
    penaltiesPage.verifyLoanPenaltiesCount(startLoanPenaltyCount + 1);
    penaltiesPage.verifySavingPenaltiesCount(startSavingsPenaltyCount + 1);
    penaltiesPage.verifyInActivePenaltyLabel(2);
    penaltiesPage.verifyInActivePenaltyLabel(4);
}
Also used : PenaltyFormPage(org.mifos.test.acceptance.framework.admin.PenaltyFormPage) NewPenaltyPreviewPage(org.mifos.test.acceptance.framework.admin.NewPenaltyPreviewPage) PenaltyFormParameters(org.mifos.test.acceptance.framework.admin.PenaltyFormParameters) ViewPenaltyPage(org.mifos.test.acceptance.framework.admin.ViewPenaltyPage) ViewPenaltiesPage(org.mifos.test.acceptance.framework.admin.ViewPenaltiesPage) EditPenaltyPreviewPage(org.mifos.test.acceptance.framework.admin.EditPenaltyPreviewPage) Test(org.testng.annotations.Test)

Aggregations

EditPenaltyPreviewPage (org.mifos.test.acceptance.framework.admin.EditPenaltyPreviewPage)2 NewPenaltyPreviewPage (org.mifos.test.acceptance.framework.admin.NewPenaltyPreviewPage)2 MifosPage (org.mifos.test.acceptance.framework.MifosPage)1 PenaltyFormPage (org.mifos.test.acceptance.framework.admin.PenaltyFormPage)1 PenaltyFormParameters (org.mifos.test.acceptance.framework.admin.PenaltyFormParameters)1 ViewPenaltiesPage (org.mifos.test.acceptance.framework.admin.ViewPenaltiesPage)1 ViewPenaltyPage (org.mifos.test.acceptance.framework.admin.ViewPenaltyPage)1 Test (org.testng.annotations.Test)1