List of usage examples for junit.framework Assert assertNull
static public void assertNull(Object object)
From source file:org.mifos.accounts.loan.business.LoanBOIntegrationTest.java
/** * TODO: Re-enable this test when rounding code correctly handles mid-stream * changes to the loan schedule.//from ww w . j a v a 2 s . c o m */ public void testRemoveFeeForPartiallyPaidFeesAccount() throws Exception { Date startDate = new Date(System.currentTimeMillis()); MeetingBO meeting = TestObjectFactory.createMeeting( TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_SECOND_WEEK, CUSTOMER_MEETING)); center = TestObjectFactory.createWeeklyFeeCenter(this.getClass().getSimpleName() + " Center", meeting); group = TestObjectFactory.createWeeklyFeeGroupUnderCenter(this.getClass().getSimpleName() + " Group", CustomerStatus.GROUP_ACTIVE, center); LoanOfferingBO loanOffering = createOfferingNoPrincipalInLastInstallment(startDate, center.getCustomerMeeting().getMeeting()); List<FeeView> feeViewList = new ArrayList<FeeView>(); FeeBO periodicFee = TestObjectFactory.createPeriodicAmountFee("Periodic Fee", FeeCategory.LOAN, "100", RecurrenceType.WEEKLY, Short.valueOf("1")); feeViewList.add(new FeeView(TestObjectFactory.getContext(), periodicFee)); accountBO = loanDao.createLoan(TestUtils.makeUser(), loanOffering, group, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, new Money(getCurrency(), "300.0"), Short.valueOf("6"), startDate, false, 1.2, (short) 0, null, feeViewList, null, DOUBLE_ZERO, DOUBLE_ZERO, SHORT_ZERO, SHORT_ZERO, false); new TestObjectPersistence().persist(accountBO); Assert.assertEquals(6, accountBO.getAccountActionDates().size()); StaticHibernateUtil.closeSession(); accountBO = (AccountBO) StaticHibernateUtil.getSessionTL().get(AccountBO.class, accountBO.getAccountId()); accountBO.applyPaymentWithPersist(TestObjectFactory.getLoanAccountPaymentData(null, new Money(getCurrency(), "60"), accountBO.getCustomer(), accountBO.getPersonnel(), "432423", (short) 1, startDate, startDate)); StaticHibernateUtil.commitTransaction(); for (AccountFeesEntity accountFeesEntity : accountBO.getAccountFees()) { accountBO.removeFees(accountFeesEntity.getFees().getFeeId(), Short.valueOf("1")); } StaticHibernateUtil.commitTransaction(); Map<String, String> fees0 = new HashMap<String, String>(); Map<String, String> fees1 = new HashMap<String, String>(); fees1.put("Periodic Fee", "60"); Set<AccountActionDateEntity> actionDateEntities = ((LoanBO) accountBO).getAccountActionDates(); Assert.assertEquals(6, actionDateEntities.size()); LoanScheduleEntity[] paymentsArray = LoanBOTestUtils.getSortedAccountActionDateEntity(actionDateEntities); checkFees(fees1, paymentsArray[0], false); checkFees(fees0, paymentsArray[1], false); checkFees(fees0, paymentsArray[2], false); checkFees(fees0, paymentsArray[3], false); checkFees(fees0, paymentsArray[4], false); checkFees(fees0, paymentsArray[5], false); for (AccountFeesEntity accountFeesEntity : accountBO.getAccountFees()) { Assert.assertEquals(FeeStatus.INACTIVE, accountFeesEntity.getFeeStatusAsEnum()); Assert.assertNull(accountFeesEntity.getLastAppliedDate()); } LoanSummaryEntity loanSummaryEntity = ((LoanBO) accountBO).getLoanSummary(); Assert.assertEquals(new Money(getCurrency(), "60"), loanSummaryEntity.getFeesPaid()); Assert.assertEquals(new Money(getCurrency(), "60"), loanSummaryEntity.getOriginalFees()); Assert.assertEquals(new Money(getCurrency()), loanSummaryEntity.getFeesDue()); for (LoanActivityEntity loanActivityEntity : ((LoanBO) accountBO).getLoanActivityDetails()) { if (loanActivityEntity.getComments().equalsIgnoreCase("Periodic Fee removed")) { Assert.assertEquals(loanSummaryEntity.getFeesDue(), loanActivityEntity.getFeeOutstanding()); Assert.assertEquals(new Money(getCurrency(), "1040"), loanActivityEntity.getFee()); break; } } }
From source file:org.mifos.accounts.loan.business.LoanBOIntegrationTest.java
/** * TODO: Re-enable this test when rounding code correctly handles mid-stream * changes to the loan schedule.//from w ww. ja v a 2 s . co m */ public void testApplyChargeForPartiallyPaidFeesAccount() throws Exception { Date startDate = new Date(System.currentTimeMillis()); MeetingBO meeting = TestObjectFactory.createMeeting( TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_SECOND_WEEK, CUSTOMER_MEETING)); center = TestObjectFactory.createWeeklyFeeCenter(this.getClass().getSimpleName() + " Center", meeting); group = TestObjectFactory.createWeeklyFeeGroupUnderCenter(this.getClass().getSimpleName() + " Group", CustomerStatus.GROUP_ACTIVE, center); LoanOfferingBO loanOffering = TestObjectFactory.createLoanOffering("Loan", ApplicableTo.GROUPS, startDate, PrdStatus.LOAN_ACTIVE, 300.0, 1.2, 3, InterestType.FLAT, center.getCustomerMeeting().getMeeting()); List<FeeView> feeViewList = new ArrayList<FeeView>(); FeeBO periodicFee = TestObjectFactory.createPeriodicAmountFee("Periodic Fee", FeeCategory.LOAN, "100", RecurrenceType.WEEKLY, Short.valueOf("1")); feeViewList.add(new FeeView(TestObjectFactory.getContext(), periodicFee)); accountBO = loanDao.createLoan(TestUtils.makeUser(), loanOffering, group, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, new Money(getCurrency(), "300.0"), Short.valueOf("6"), startDate, false, 1.2, (short) 0, null, feeViewList, null, DOUBLE_ZERO, DOUBLE_ZERO, SHORT_ZERO, SHORT_ZERO, false); new TestObjectPersistence().persist(accountBO); Assert.assertEquals(6, accountBO.getAccountActionDates().size()); StaticHibernateUtil.closeSession(); accountBO = (AccountBO) StaticHibernateUtil.getSessionTL().get(AccountBO.class, accountBO.getAccountId()); accountBO.applyPaymentWithPersist(TestObjectFactory.getLoanAccountPaymentData(null, new Money(getCurrency(), "60"), accountBO.getCustomer(), accountBO.getPersonnel(), "432423", (short) 1, startDate, startDate)); StaticHibernateUtil.commitTransaction(); for (AccountFeesEntity accountFeesEntity : accountBO.getAccountFees()) { accountBO.removeFees(accountFeesEntity.getFees().getFeeId(), Short.valueOf("1")); } StaticHibernateUtil.commitTransaction(); Map<String, String> fees0 = new HashMap<String, String>(0); Map<String, String> fees1 = new HashMap<String, String>(); fees1.put("Periodic Fee", "60"); Map<String, String> feesPaid1 = new HashMap<String, String>(); feesPaid1.put("Periodic Fee", "60"); LoanScheduleEntity[] paymentsArray = LoanBOTestUtils .getSortedAccountActionDateEntity(((LoanBO) accountBO).getAccountActionDates()); Assert.assertEquals(6, paymentsArray.length); checkLoanScheduleEntity(null, null, null, null, null, null, fees1, feesPaid1, null, null, paymentsArray[0]); checkLoanScheduleEntity(null, null, null, null, null, null, fees0, null, null, null, paymentsArray[1]); checkLoanScheduleEntity(null, null, null, null, null, null, fees0, null, null, null, paymentsArray[2]); checkLoanScheduleEntity(null, null, null, null, null, null, fees0, null, null, null, paymentsArray[3]); checkLoanScheduleEntity(null, null, null, null, null, null, fees0, null, null, null, paymentsArray[4]); checkLoanScheduleEntity(null, null, null, null, null, null, fees0, null, null, null, paymentsArray[5]); for (AccountFeesEntity accountFeesEntity : accountBO.getAccountFees()) { Assert.assertEquals(FeeStatus.INACTIVE, accountFeesEntity.getFeeStatusAsEnum()); Assert.assertNull(accountFeesEntity.getLastAppliedDate()); } LoanSummaryEntity loanSummaryEntity = ((LoanBO) accountBO).getLoanSummary(); Assert.assertEquals(new Money(getCurrency(), "60"), loanSummaryEntity.getFeesPaid()); Assert.assertEquals(new Money(getCurrency(), "60"), loanSummaryEntity.getOriginalFees()); Assert.assertEquals(new Money(getCurrency()), loanSummaryEntity.getFeesDue()); for (LoanActivityEntity loanActivityEntity : ((LoanBO) accountBO).getLoanActivityDetails()) { if (loanActivityEntity.getComments().equalsIgnoreCase("Periodic Fee removed")) { Assert.assertEquals(loanSummaryEntity.getFeesDue(), loanActivityEntity.getFeeOutstanding()); Assert.assertEquals(new Money(getCurrency(), "1040"), loanActivityEntity.getFee()); break; } } accountBO.setUserContext(TestUtils.makeUser()); for (AccountFeesEntity accountFeesEntity : accountBO.getAccountFees()) { accountBO.applyCharge(accountFeesEntity.getFees().getFeeId(), Double.valueOf("200")); } StaticHibernateUtil.commitTransaction(); Map<String, String> fee260 = new HashMap<String, String>(); fee260.put("Periodic Fee", "260"); Map<String, String> fee400 = new HashMap<String, String>(); fee400.put("Periodic Fee", "400"); Set<AccountActionDateEntity> actionDateEntities1 = ((LoanBO) accountBO).getAccountActionDates(); Assert.assertEquals(6, actionDateEntities1.size()); LoanScheduleEntity[] paymentsArray1 = LoanBOTestUtils.getSortedAccountActionDateEntity(actionDateEntities1); checkLoanScheduleEntity(null, null, null, null, null, null, fee260, null, null, null, paymentsArray1[0]); checkLoanScheduleEntity(null, null, null, null, null, null, fee400, null, null, null, paymentsArray1[1]); checkLoanScheduleEntity(null, null, null, null, null, null, fee400, null, null, null, paymentsArray1[2]); checkLoanScheduleEntity(null, null, null, null, null, null, fee400, null, null, null, paymentsArray1[3]); checkLoanScheduleEntity(null, null, null, null, null, null, fee400, null, null, null, paymentsArray1[4]); checkLoanScheduleEntity(null, null, null, null, null, null, fee400, null, null, null, paymentsArray1[5]); // not sure if the remaining is being handled by validatePayments for (AccountActionDateEntity accountActionDateEntity : accountBO.getAccountActionDates()) { LoanScheduleEntity loanScheduleEntity = (LoanScheduleEntity) accountActionDateEntity; if (!loanScheduleEntity.getInstallmentId().equals(Short.valueOf("1"))) { Assert.assertEquals(1, loanScheduleEntity.getAccountFeesActionDetails().size()); for (AccountFeesActionDetailEntity accountFeesActionDetailEntity : loanScheduleEntity .getAccountFeesActionDetails()) { LoanFeeScheduleEntity loanFeeScheduleEntity = (LoanFeeScheduleEntity) accountFeesActionDetailEntity; Assert.assertEquals(TestUtils.createMoney(), loanFeeScheduleEntity.getFeeAmountPaid()); } } } for (AccountFeesEntity accountFeesEntity : accountBO.getAccountFees()) { Assert.assertEquals(FeeStatus.ACTIVE, accountFeesEntity.getFeeStatusAsEnum()); Assert.assertNotNull(accountFeesEntity.getLastAppliedDate()); } loanSummaryEntity = ((LoanBO) accountBO).getLoanSummary(); Assert.assertEquals(new Money(getCurrency(), "60"), loanSummaryEntity.getFeesPaid()); Assert.assertEquals(new Money(getCurrency(), "2260"), loanSummaryEntity.getOriginalFees()); Assert.assertEquals(new Money(getCurrency(), "2200"), loanSummaryEntity.getFeesDue()); for (LoanActivityEntity loanActivityEntity : ((LoanBO) accountBO).getLoanActivityDetails()) { if (loanActivityEntity.getComments().equalsIgnoreCase("Periodic Fee applied")) { Assert.assertEquals(loanSummaryEntity.getFeesDue(), loanActivityEntity.getFeeOutstanding()); Assert.assertEquals(new Money(getCurrency(), "2200"), loanActivityEntity.getFee()); break; } } }
From source file:org.mifos.accounts.loan.business.LoanCalculationIntegrationTest.java
private void verifyReversedLoanSchedules(LoanScheduleEntity[] schedules, Results expectedResults) { List<PaymentDetail> list = expectedResults.getPayments(); Assert.assertEquals(list.size(), schedules.length); for (int i = 0; i < schedules.length; i++) { Money zeroAmount = new Money(getCurrency(), "0"); Assert.assertEquals(schedules[i].getPrincipalPaid(), zeroAmount); if (i == 0) { Assert.assertNotNull(schedules[i].getPaymentDate()); } else {//from w w w . j av a2 s . c o m Assert.assertNull(schedules[i].getPaymentDate()); } Assert.assertEquals(schedules[i].isPaid(), false); verifyScheduleAndPaymentDetail(schedules[i], list.get(i)); } }
From source file:org.mifos.reports.branchreport.persistence.BranchReportPersistenceIntegrationTest.java
@Test public void testPopulateCustomersFormedBySetsTotalClientsEnrolledBy() throws Exception { Map<Short, BranchReportStaffSummaryBO> staffSummaries = createStaffSummariesMap(); branchReportPersistence.populateTotalClientsEnrolledByPersonnel(staffSummaries); Assert.assertNull( org.apache.commons.collections.CollectionUtils.find(staffSummaries.values(), new Predicate() { @Override/*from w w w . ja v a2s . c om*/ public boolean evaluate(Object object) { return !Integer.valueOf(0) .equals(((BranchReportStaffSummaryBO) object).getTotalClientsEnrolled()); } })); }
From source file:org.mifos.reports.branchreport.persistence.BranchReportPersistenceIntegrationTest.java
@Test public void testPopulateLoanArrearsAmountSetsLoanArrearsAmount() throws Exception { Map<Short, BranchReportStaffSummaryBO> staffSummaries = createStaffSummariesMap(); branchReportPersistence.populateLoanArrearsAmountForPersonnel(staffSummaries, DEFAULT_CURRENCY); Assert.assertNull( org.apache.commons.collections.CollectionUtils.find(staffSummaries.values(), new Predicate() { @Override//from w w w . java 2 s . c om public boolean evaluate(Object object) { return !BigDecimal.ZERO.setScale(AccountingRules.getDigitsAfterDecimal()) .equals(((BranchReportStaffSummaryBO) object).getLoanArrearsAmount()); } })); }
From source file:org.mule.streaming.ListableObjectStoreProducerTestCase.java
@Test public void happyPath() throws Exception { Set<Serializable> returnedValues = new HashSet<Serializable>(); Serializable item = this.producer.produce(); while (item != null) { returnedValues.add(item);/* www.j a v a 2 s.c o m*/ item = this.producer.produce(); } Assert.assertEquals(returnedValues.size(), this.values.size()); for (String value : this.values.values()) { Assert.assertTrue(returnedValues.contains(value)); } Assert.assertNull(this.producer.produce()); }
From source file:org.opencastproject.capture.impl.RecordingImplTest.java
@Test public void testEdgeRecording() throws IllegalArgumentException, ConfigurationException, IOException, MediaPackageException { // Let's test some edge-casey recordings rec = new RecordingImpl(MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder().createNew(), null);//from ww w . j a v a 2 s . c om Assert.assertNotNull(rec); Assert.assertEquals(System.getProperty("java.io.tmpdir"), rec.getProperty(CaptureParameters.CAPTURE_FILESYSTEM_CAPTURE_CACHE_URL)); Assert.assertNull(rec.setProperty("test", "foo")); Assert.assertEquals("foo", rec.setProperty("test", "bar")); FileUtils.deleteQuietly(rec.getBaseDir()); }
From source file:org.opencastproject.capture.impl.StateServiceImplTest.java
@Test public void testUnpreparedImpl() { Assert.assertNull(service.getAgentState()); Assert.assertNull(service.getAgentName()); service.setAgentState("TEST"); Assert.assertEquals("TEST", service.getAgentState()); service.setRecordingState(null, "won't work"); service.setRecordingState("somethign", null); service.setRecordingState("works", "working"); Assert.assertNotNull(service.getKnownRecordings()); Assert.assertEquals(1, service.getKnownRecordings().size()); Assert.assertEquals("working", service.getRecordingState("works").getState()); service.activate(null);/*from w w w .j a v a 2s .c o m*/ Assert.assertEquals(AgentState.IDLE, service.getAgentState()); service.setAgentState(AgentState.CAPTURING); Assert.assertEquals(AgentState.CAPTURING, service.getAgentState()); deleteDir("works"); }
From source file:org.opencastproject.capture.impl.StateServiceImplTest.java
@Test public void testRecordings() { Assert.assertNotNull(service.getKnownRecordings()); Assert.assertEquals(0, service.getKnownRecordings().size()); service.activate(null);/*from ww w . ja va 2s .c o m*/ Assert.assertNotNull(service.getKnownRecordings()); Assert.assertEquals(0, service.getKnownRecordings().size()); Assert.assertNull(service.getRecordingState("abc")); Assert.assertNull(service.getRecordingState("123")); Assert.assertNull(service.getRecordingState("doesnotexist")); service.setRecordingState("abc", RecordingState.CAPTURING); service.setRecordingState("123", RecordingState.UPLOADING); Assert.assertEquals(2, service.getKnownRecordings().size()); verifyRecording(service.getRecordingState("abc"), "abc", RecordingState.CAPTURING); verifyRecording(service.getRecordingState("123"), "123", RecordingState.UPLOADING); Assert.assertNull(service.getRecordingState("doesnotexist")); deleteDir("abc"); deleteDir("123"); }
From source file:org.opencastproject.distribution.youtube.YoutubeDistributionServiceTest.java
License:asdf
@Test public void testDistributeNotTrack() throws Exception { Job job = service.distribute(mp, "catalog-1"); Assert.assertNull(job); job = service.distribute(mp, "notes"); Assert.assertNull(job);//from ww w . j ava 2s.co m }