Search in sources :

Example 96 with Date

use of java.sql.Date in project head by mifos.

the class LoanOfferingBOIntegrationTest method testUpdateloanOfferingWithoutName.

@Test
public void testUpdateloanOfferingWithoutName() throws SystemException, ApplicationException {
    createIntitalObjects();
    product = createLoanOfferingBO("Loan Product", "LOAP");
    try {
        product.update((short) 1, null, "S", productCategory, prdApplicableMaster, new Date(System.currentTimeMillis()), null, "Loan Product updated", PrdStatus.LOAN_ACTIVE, null, interestTypes, (short) 0, new Money(getCurrency(), "3000"), new Money(getCurrency(), "1000"), new Money(getCurrency(), "2000"), 12.0, 2.0, 3.0, (short) 20, (short) 1, (short) 12, false, false, false, null, null, null, (short) 2, RecurrenceType.WEEKLY, waiverInterest);
        Assert.fail();
    } catch (ProductDefinitionException e) {
    }
}
Also used : Money(org.mifos.framework.util.helpers.Money) ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) Date(java.sql.Date) Test(org.junit.Test)

Example 97 with Date

use of java.sql.Date in project head by mifos.

the class LoanOfferingBOIntegrationTest method testLoanOfferingWithDecliningInterestDeductionAtDisbursement.

@Test
public void testLoanOfferingWithDecliningInterestDeductionAtDisbursement() {
    try {
        createIntitalObjects();
        interestTypes = new InterestTypesEntity(InterestType.DECLINING);
        Date startDate = offSetCurrentDate(0);
        Date endDate = offSetCurrentDate(2);
        new LoanOfferingBO(TestObjectFactory.getContext(), "Loan Offering", "LOAP", productCategory, prdApplicableMaster, startDate, endDate, null, null, null, interestTypes, new Money(getCurrency(), "1000"), new Money(getCurrency(), "3000"), new Money(getCurrency(), "2000.0"), 12.0, 2.0, 3.0, (short) 20, (short) 11, (short) 17, false, true, false, null, null, null, frequency, principalglCodeEntity, intglCodeEntity, waiverInterest);
        Assert.fail();
    } catch (ProductDefinitionException e) {
        Assert.assertEquals("exceptions.declineinterestdisbursementdeduction", e.getKey());
    }
}
Also used : InterestTypesEntity(org.mifos.application.master.business.InterestTypesEntity) Money(org.mifos.framework.util.helpers.Money) ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) Date(java.sql.Date) Test(org.junit.Test)

Example 98 with Date

use of java.sql.Date in project head by mifos.

the class LoanOfferingBOIntegrationTest method testUpdateLoanOfferingForLogging.

@Test
public void testUpdateLoanOfferingForLogging() throws ProductDefinitionException, FeeException {
    createIntitalObjects();
    Date startDate = offSetCurrentDate(0);
    Date endDate = offSetCurrentDate(2);
    periodicFee = TestObjectFactory.createPeriodicAmountFee("Loan Periodic", FeeCategory.LOAN, "100", RecurrenceType.MONTHLY, (short) 1);
    oneTimeFee = TestObjectFactory.createOneTimeAmountFee("Loan One time", FeeCategory.LOAN, "100", FeePayment.UPFRONT);
    List<FeeBO> fees = new ArrayList<FeeBO>();
    fees.add(periodicFee);
    fees.add(oneTimeFee);
    product = createLoanOfferingBO("Loan Product", "LOAP");
    ((AuditInterceptor) StaticHibernateUtil.getInterceptor()).createInitialValueMap(product);
    product.update((short) 1, "Loan Product", "LOAN", productCategory, prdApplicableMaster, startDate, endDate, "Loan Product updated", PrdStatus.LOAN_ACTIVE, null, interestTypes, (short) 0, 12.0, 2.0, 12.0, false, true, true, null, fees, null, (short) 2, RecurrenceType.MONTHLY, populateLoanPrdActionForm("1", "1", new Double("3000"), new Double("1000"), new Double("1000"), "12", "1", "2"), waiverInterest, null);
    StaticHibernateUtil.flushAndClearSession();
    StaticHibernateUtil.getInterceptor().afterTransactionCompletion(new AuditTransactionForTests());
    product = (LoanOfferingBO) TestObjectFactory.getObject(LoanOfferingBO.class, product.getPrdOfferingId());
    List<AuditLog> auditLogList = TestObjectFactory.getChangeLog(EntityType.LOANPRODUCT, new Integer(product.getPrdOfferingId().toString()));
    Assert.assertEquals(1, auditLogList.size());
    Assert.assertEquals(EntityType.LOANPRODUCT.getValue(), auditLogList.get(0).getEntityType());
    Assert.assertEquals(15, auditLogList.get(0).getAuditLogRecords().size());
    for (AuditLogRecord auditLogRecord : auditLogList.get(0).getAuditLogRecords()) {
        if (auditLogRecord.getFieldName().equalsIgnoreCase("Min Loan Amount")) {
            Assert.assertEquals("300.0", auditLogRecord.getOldValue());
            Assert.assertEquals("1000.0", auditLogRecord.getNewValue());
        } else if (auditLogRecord.getFieldName().equalsIgnoreCase("Description")) {
            Assert.assertEquals("-", auditLogRecord.getOldValue());
            Assert.assertEquals("Loan Product updated", auditLogRecord.getNewValue());
        } else if (auditLogRecord.getFieldName().equalsIgnoreCase("Applicable For")) {
            Assert.assertEquals("Groups", auditLogRecord.getOldValue());
            Assert.assertEquals("Clients", auditLogRecord.getNewValue());
        } else if (auditLogRecord.getFieldName().equalsIgnoreCase("Frequency Of Installments")) {
            Assert.assertEquals("Week(s)", auditLogRecord.getOldValue());
            Assert.assertEquals("Month(s)", auditLogRecord.getNewValue());
        }
    }
}
Also used : AuditLogRecord(org.mifos.framework.components.audit.business.AuditLogRecord) AuditInterceptor(org.mifos.framework.components.audit.util.helpers.AuditInterceptor) ArrayList(java.util.ArrayList) FeeBO(org.mifos.accounts.fees.business.FeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) AuditTransactionForTests(org.mifos.framework.hibernate.helper.AuditTransactionForTests) Date(java.sql.Date) AuditLog(org.mifos.framework.components.audit.business.AuditLog) Test(org.junit.Test)

Example 99 with Date

use of java.sql.Date in project head by mifos.

the class LoanOfferingBOIntegrationTest method testBuildloanOfferingWithShortNameGreaterThanFourDig.

@Test
public void testBuildloanOfferingWithShortNameGreaterThanFourDig() throws SystemException, ApplicationException {
    createIntitalObjects();
    try {
        new LoanOfferingBO(TestObjectFactory.getContext(), "Loan Offering", "LOANOFF", productCategory, prdApplicableMaster, new Date(System.currentTimeMillis()), interestTypes, new Money(getCurrency(), "1000"), new Money(getCurrency(), "3000"), 12.0, 2.0, 3.0, (short) 20, (short) 1, (short) 12, false, false, false, frequency, principalglCodeEntity, intglCodeEntity, waiverInterest);
        Assert.fail();
    } catch (ProductDefinitionException e) {
    }
}
Also used : Money(org.mifos.framework.util.helpers.Money) ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) Date(java.sql.Date) Test(org.junit.Test)

Example 100 with Date

use of java.sql.Date in project head by mifos.

the class LoanOfferingBOIntegrationTest method testGracePeriodForIntDedAtDisb.

@Test
public void testGracePeriodForIntDedAtDisb() throws ProductDefinitionException {
    createIntitalObjects();
    Date startDate = offSetCurrentDate(0);
    Date endDate = offSetCurrentDate(2);
    LoanOfferingBO loanOffering = new LoanOfferingBO(TestObjectFactory.getContext(), "Loan Offering", "LOAP", productCategory, prdApplicableMaster, startDate, endDate, null, null, null, interestTypes, new Money(getCurrency(), "1000"), new Money(getCurrency(), "3000"), new Money(getCurrency(), "2000.0"), 12.0, 2.0, 3.0, (short) 20, (short) 11, (short) 17, false, true, false, null, null, null, frequency, principalglCodeEntity, intglCodeEntity, waiverInterest);
    Assert.assertNotNull(loanOffering.getGracePeriodType());
    Assert.assertNotNull(loanOffering.getGracePeriodDuration());
    Assert.assertEquals(GraceType.NONE.getValue(), loanOffering.getGracePeriodType().getId());
    Assert.assertEquals(Short.valueOf("0"), loanOffering.getGracePeriodDuration());
}
Also used : Money(org.mifos.framework.util.helpers.Money) Date(java.sql.Date) Test(org.junit.Test)

Aggregations

Date (java.sql.Date)631 Test (org.junit.Test)271 PreparedStatement (java.sql.PreparedStatement)123 ResultSet (java.sql.ResultSet)117 Connection (java.sql.Connection)102 Timestamp (java.sql.Timestamp)89 Money (org.mifos.framework.util.helpers.Money)83 Properties (java.util.Properties)60 ArrayList (java.util.ArrayList)59 SQLException (java.sql.SQLException)55 PDate (org.apache.phoenix.schema.types.PDate)55 ProductDefinitionException (org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException)50 Time (java.sql.Time)42 LocalDate (java.time.LocalDate)39 MeetingBO (org.mifos.application.meeting.business.MeetingBO)39 Test (org.testng.annotations.Test)39 BigDecimal (java.math.BigDecimal)38 Calendar (java.util.Calendar)32 PhoenixConnection (org.apache.phoenix.jdbc.PhoenixConnection)30 BaseTest (util.BaseTest)28