/* * 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.loan; import org.joda.time.DateTime; import org.mifos.test.acceptance.admin.FeeTestHelper; import org.mifos.test.acceptance.framework.MifosPage; import org.mifos.test.acceptance.framework.UiTestCaseBase; import org.mifos.test.acceptance.framework.admin.FeesCreatePage; import org.mifos.test.acceptance.framework.loan.CreateLoanAccountSearchParameters; import org.mifos.test.acceptance.framework.testhelpers.LoanTestHelper; import org.mifos.test.acceptance.framework.testhelpers.NavigationHelper; import org.mifos.test.acceptance.util.ApplicationDatabaseOperation; import org.mifos.test.acceptance.util.TestDataSetup; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @ContextConfiguration(locations = {"classpath:ui-test-context.xml"}) @Test(singleThreaded = true, groups = {"loanproduct", "acceptance", "ui", "no_db_unit"}) public class VariableInstalmentLoanTest extends UiTestCaseBase { @Autowired private ApplicationDatabaseOperation applicationDatabaseOperation; private static final String clientName = "Client WeeklyTue"; private static final String loanProductName = "WeeklyClientVariableInstallmentsLoan"; private LoanTestHelper loanTestHelper; private DateTime systemDateTime; private NavigationHelper navigationHelper; private FeeTestHelper feeTestHelper; @SuppressWarnings("PMD.SignatureDeclareThrowsException") // one of the dependent methods throws Exception @AfterMethod public void logOut() throws Exception{ applicationDatabaseOperation.updateLSIM(0); (new MifosPage(selenium)).logout(); } @Override @SuppressWarnings("PMD.SignatureDeclareThrowsException") // one of the dependent methods throws Exception @BeforeMethod public void setUp() throws Exception { super.setUp(); navigationHelper = new NavigationHelper(selenium); systemDateTime = new DateTime(2010, 10, 11, 10, 0, 0, 0); loanTestHelper = new LoanTestHelper(selenium); loanTestHelper.setApplicationTime(systemDateTime); TestDataSetup dataSetup = new TestDataSetup(selenium, applicationDatabaseOperation); feeTestHelper = new FeeTestHelper(dataSetup, new NavigationHelper(selenium)); applicationDatabaseOperation.updateLSIM(1); } @SuppressWarnings("PMD.SignatureDeclareThrowsException") // one of the dependent methods throws Exception @Test(enabled = true) public void verifyRepaymentScheduleField() throws Exception { int noOfInstallments = 5; int maxGap = 10; int minGap = 1; int minInstalmentAmount = 100; DateTime disbursalDate = systemDateTime.plusDays(1); navigationHelper.navigateToHomePage(); loanTestHelper. navigateToCreateLoanAccountEntryPageWithoutLogout(setLoanSearchParameters()). setDisbursalDate(disbursalDate). clickContinue(). validateRepaymentScheduleFieldDefault(noOfInstallments). validateDateFieldValidations(disbursalDate, minGap, maxGap, noOfInstallments). verifyInstallmentTotalValidations(noOfInstallments, minInstalmentAmount, disbursalDate, minGap). verifyValidData(noOfInstallments, minGap, minInstalmentAmount, disbursalDate, maxGap). clickPreviewAndGoToReviewLoanAccountPage(). verifyEditSchedule(). verifySchedulePersistOnEdit(noOfInstallments, minGap, minInstalmentAmount, disbursalDate, maxGap); } @SuppressWarnings("PMD.SignatureDeclareThrowsException") // one of the dependent methods throws Exception @Test(enabled = true) public void verifyInvalidFees() throws Exception { DateTime disbursalDate = systemDateTime.plusDays(1); String periodicFees = feeTestHelper.createPeriodicFee("loanWeeklyFee", FeesCreatePage.SubmitFormParameters.LOAN, FeesCreatePage.SubmitFormParameters.WEEKLY_FEE_RECURRENCE, 1, 100); String fixedFeePerAmountAndInterest = feeTestHelper.createFixedFee("fixedFeePerAmountAndInterest", FeesCreatePage.SubmitFormParameters.LOAN, "Upfront", 100, "Loan Amount+Interest"); String fixedFeePerInterest = feeTestHelper.createFixedFee("fixedFeePerInterest", FeesCreatePage.SubmitFormParameters.LOAN, "Upfront", 20, "Interest"); String[] blockedInterest = {periodicFees, fixedFeePerAmountAndInterest, fixedFeePerInterest}; navigationHelper.navigateToHomePage(); loanTestHelper. navigateToCreateLoanAccountEntryPageWithoutLogout(setLoanSearchParameters()). setDisbursalDate(disbursalDate). verifyInvalidFeeBlocked(blockedInterest); } private CreateLoanAccountSearchParameters setLoanSearchParameters() { CreateLoanAccountSearchParameters accountSearchParameters = new CreateLoanAccountSearchParameters(); accountSearchParameters.setSearchString(clientName); accountSearchParameters.setLoanProduct(loanProductName); return accountSearchParameters; } }