Skip to content

Commit

Permalink
Merge pull request #256 from kkaczmarczyk/branch
Browse files Browse the repository at this point in the history
MIFOS-5958: Create acceptance test for adjusting amount with comma on Ne...
  • Loading branch information
wojtek-szarmacher committed Feb 13, 2013
2 parents bdd679f + cd0d3de commit ae4bd8f
Show file tree
Hide file tree
Showing 7 changed files with 199 additions and 0 deletions.
Expand Up @@ -50,6 +50,12 @@ public LoanAccountPage fillAdjustmentFieldsWithoutRevertingAndSubmit(String adju
applyAdjustmentWithoutReverting(adjustmentAmount);
return submitAdjustment();
}
public ApplyAdjustmentPage fillAdjustmentFieldsWithoutRevertingAndSubmitGroupLoan(String adjustmentAmount) {
applyAdjustmentWithoutReverting(adjustmentAmount);
selenium.click("applyadjustment.button.submit");
waitForPageToLoad();
return new ApplyAdjustmentPage(selenium);
}

public LoanAccountPage submitAdjustment() {
selenium.click("applyadjustment.button.submit");
Expand Down
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2005-2011 Grameen Foundation USA
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* See also http://www.apache.org/licenses/LICENSE-2.0.html for an
* explanation of the license and how it is applied.
*/

package org.mifos.test.acceptance.framework.loan;

import org.mifos.test.acceptance.framework.AbstractPage;

import com.thoughtworks.selenium.Selenium;

public class ApplyGroupPaymentConfirmationPage extends AbstractPage {

public ApplyGroupPaymentConfirmationPage(Selenium selenium) {
super(selenium);
this.verifyPage("ReviewApplyGroupPayment");
}

public LoanAccountPage submitAndNavigateToLoanAccountDetailsPage() {
selenium.click("reviewapplypayment.button.submit");
waitForPageToLoad();
return new LoanAccountPage(selenium);
}

}
@@ -0,0 +1,42 @@
package org.mifos.test.acceptance.framework.loan;

import org.mifos.test.acceptance.framework.MifosPage;

import com.thoughtworks.selenium.Selenium;

public class ApplyGroupPaymentPage extends MifosPage {

public ApplyGroupPaymentPage(Selenium selenium) {
super(selenium);
verifyPage("ApplyGroupPayment");
}

public ApplyGroupPaymentConfirmationPage submitAndNavigateToApplyGroupPaymentConfirmationPage(PaymentParameters params)
{
enterPaymentData(params);
return new ApplyGroupPaymentConfirmationPage(selenium);
}

public void verifyPaymentPriorLastPaymentDate(PaymentParameters params) {
enterPaymentData(params);
selenium.isTextPresent("Date of transaction cannot be less than the last payment date");
}

private void enterPaymentData(PaymentParameters params) {
selenium.type("transactionDateDD", params.getTransactionDateDD());
selenium.type("transactionDateMM", params.getTransactionDateMM());
selenium.type("transactionDateYY", params.getTransactionDateYYYY());
selenium.select("applypayment.input.paymentType", "value=" + params.getPaymentTypeValue());
this.typeTextIfNotEmpty("applypayment.input.receiptId", params.getReceiptId());

this.typeTextIfNotEmpty("receiptDateDD", params.getReceiptDateDD());
this.typeTextIfNotEmpty("receiptDateMM", params.getReceiptDateMM());
this.typeTextIfNotEmpty("receiptDateYY", params.getReceiptDateYYYY());

selenium.type("applypayment.input.amount", params.getAmount());
waitForPageToLoad();
selenium.click("applypayment.button.reviewTransaction");
waitForPageToLoad();
}

}
Expand Up @@ -399,6 +399,12 @@ public ApplyPaymentPage navigateToApplyPayment() {
waitForPageToLoad();
return new ApplyPaymentPage(selenium);
}

public ApplyGroupPaymentPage navigateToApplyGroupPayment() {
selenium.click("loanaccountdetail.link.applyPayment");
waitForPageToLoad();
return new ApplyGroupPaymentPage(selenium);
}

public AccountAddNotesPage navigateToAddNotesPage() {
selenium.click("loanaccountdetail.link.addNote");
Expand Down
Expand Up @@ -176,6 +176,10 @@ public void setInitialRoundOffMultiple(String initialRoundOffMultiple) {
selenium.open(UPDATE_PAGE + "?AccountingRules.InitialRoundOffMultiple=" + initialRoundOffMultiple);
}

public void setNewGroupLoanWithMembers(boolean newGLIM) {
selenium.open(UPDATE_PAGE + "?AccountingRules.GroupLoanWithMembers=" + newGLIM);
}

public void setOverdueInterestPaidFirst(String overdueInterestPaidFirst) {
selenium.open(UPDATE_PAGE + "?OverdueInterestPaidFirst=" + overdueInterestPaidFirst);
}
Expand Down
Expand Up @@ -40,6 +40,8 @@
import org.mifos.test.acceptance.framework.loan.AccountActivityPage;
import org.mifos.test.acceptance.framework.loan.AccountChangeStatusPage;
import org.mifos.test.acceptance.framework.loan.ApplyChargePage;
import org.mifos.test.acceptance.framework.loan.ApplyGroupPaymentConfirmationPage;
import org.mifos.test.acceptance.framework.loan.ApplyGroupPaymentPage;
import org.mifos.test.acceptance.framework.loan.ApplyPaymentConfirmationPage;
import org.mifos.test.acceptance.framework.loan.ApplyPaymentPage;
import org.mifos.test.acceptance.framework.loan.ChargeParameters;
Expand Down Expand Up @@ -393,6 +395,19 @@ public LoanAccountPage applyPayment(String loanId, PaymentParameters paymentPara
return loanAccountPage;
}


public LoanAccountPage applyGroupPayment(String loanId, PaymentParameters paymentParams) {
LoanAccountPage loanAccountPage = navigationHelper.navigateToLoanAccountPage(loanId);

ApplyGroupPaymentPage applyGroupPaymentPage = loanAccountPage.navigateToApplyGroupPayment();

ApplyGroupPaymentConfirmationPage applyGroupPaymentConfirmationPage = applyGroupPaymentPage.submitAndNavigateToApplyGroupPaymentConfirmationPage(paymentParams);
loanAccountPage = applyGroupPaymentConfirmationPage.submitAndNavigateToLoanAccountDetailsPage();

return loanAccountPage;
}


/**
* Waive the fee associated with the loan account with id <tt>loanId</tt>.
* @param loanId The loan account id.
Expand Down
@@ -0,0 +1,86 @@
package org.mifos.test.acceptance.loan;

import org.joda.time.DateTime;
import org.junit.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.springframework.test.context.ContextConfiguration;
import org.mifos.test.acceptance.framework.MifosPage;
import org.mifos.test.acceptance.framework.UiTestCaseBase;
import org.mifos.test.acceptance.framework.testhelpers.LoanTestHelper;
import org.mifos.test.acceptance.remote.DateTimeUpdaterRemoteTestingService;
import org.mifos.test.acceptance.framework.loan.CreateLoanAccountConfirmationPage;
import org.mifos.test.acceptance.framework.loan.CreateLoanAccountEntryPage;
import org.mifos.test.acceptance.framework.loan.CreateLoanAccountPreviewPage;
import org.mifos.test.acceptance.framework.loan.CreateLoanAccountReviewInstallmentPage;
import org.mifos.test.acceptance.framework.loan.CreateLoanAccountSearchParameters;
import org.mifos.test.acceptance.framework.loan.DisburseLoanParameters;
import org.mifos.test.acceptance.framework.loan.EditLoanAccountStatusParameters;
import org.mifos.test.acceptance.framework.loan.LoanAccountPage;
import org.mifos.test.acceptance.framework.loan.PaymentParameters;
import org.mifos.test.acceptance.framework.testhelpers.CustomPropertiesHelper;


@ContextConfiguration(locations = {"classpath:ui-test-context.xml"})
@Test(singleThreaded = true, enabled = true,groups = {"acceptance", "loan", "no_db_unit"})

public class ApplyAdjustmentGroupLoanTest extends UiTestCaseBase {
private LoanTestHelper loanTestHelper;
private CustomPropertiesHelper customPropertiesHelper;

@Override
@BeforeMethod(alwaysRun=true)
public void setUp() throws Exception {
super.setUp();
loanTestHelper = new LoanTestHelper(selenium);
customPropertiesHelper = new CustomPropertiesHelper(selenium);
customPropertiesHelper.setNewGroupLoanWithMembers(true);
}
@AfterMethod
public void logOut(){
customPropertiesHelper.setNewGroupLoanWithMembers(false);
(new MifosPage(selenium)).logout();
}
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
public void adjustmentWithCommaTest() throws Exception{
DateTimeUpdaterRemoteTestingService dateTimeUpdaterRemoteTestingService = new DateTimeUpdaterRemoteTestingService(selenium);
DateTime targetTime = new DateTime(2013, 02, 8, 13, 0, 0, 0);
dateTimeUpdaterRemoteTestingService.setDateTime(targetTime);

CreateLoanAccountSearchParameters searchParameters = new CreateLoanAccountSearchParameters();
searchParameters.setSearchString("Default Group");
searchParameters.setLoanProduct("WeeklyGroupFlatLoanWithOnetimeFee");
CreateLoanAccountEntryPage loanAccountEntryPage = loanTestHelper.navigateToCreateLoanAccountEntryPage(searchParameters);

loanAccountEntryPage.setDisbursalDate(new DateTime(2013, 2, 8, 15, 0, 0, 0));
loanAccountEntryPage.selectGLIMClients(0, "Stu1233266299995 Client1233266299995 Client Id: 0002-000000012", "1500", null);
loanAccountEntryPage.selectGLIMClients(2, "Stu1233266319760 Client1233266319760 Client Id: 0002-000000014", "1500", null);
CreateLoanAccountReviewInstallmentPage createLoanAccountReviewInstallmentPage = loanAccountEntryPage.navigateToReviewInstallmentsPage();
CreateLoanAccountPreviewPage createLoanAccountPreviewPage = createLoanAccountReviewInstallmentPage.clickPreviewAndGoToReviewLoanAccountPage();
CreateLoanAccountConfirmationPage createLoanAccountConfirmationPage = createLoanAccountPreviewPage.submitForApprovalAndNavigateToConfirmationPage();

LoanAccountPage loanAccountPage = createLoanAccountConfirmationPage.navigateToLoanAccountDetailsPage();
String loanId = loanAccountPage.getAccountId();
EditLoanAccountStatusParameters statusParameters = new EditLoanAccountStatusParameters();
statusParameters.setStatus(EditLoanAccountStatusParameters.APPROVED);
statusParameters.setNote("Test new GLIM");
loanTestHelper.changeLoanAccountStatus(loanId, statusParameters);

DisburseLoanParameters params = new DisburseLoanParameters();
params.setPaymentType(DisburseLoanParameters.CASH);
loanTestHelper.disburseLoan(loanId, params);

PaymentParameters paymentParameters = new PaymentParameters();
paymentParameters.setAmount("2500.0");
paymentParameters.setPaymentType(PaymentParameters.CASH);
paymentParameters.setTransactionDateDD("08");
paymentParameters.setTransactionDateMM("2");
paymentParameters.setTransactionDateYYYY("2013");
loanTestHelper.applyGroupPayment(loanId,paymentParameters);
loanAccountPage.navigateToApplyAdjustment().fillAdjustmentFieldsWithoutRevertingAndSubmitGroupLoan("2500.0");
Assert.assertFalse(selenium.isTextPresent("stack trace"));
Assert.assertTrue(selenium.isTextPresent("2,500"));

}
}

0 comments on commit ae4bd8f

Please sign in to comment.