forked from apache/fineract
-
Notifications
You must be signed in to change notification settings - Fork 6
FINERACT-38: Adding 2 test cases to check RunningBalanceNotCalculated… #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6f1acd1
FINERACT-38: Adding 2 test cases to check RunningBalanceNotCalculated…
d4ac3ae
FINERACT-38 : Renaming and Updating test:
3b009bf
Fineract-38: Adding 4 test cases signifying the calculation of debits…
f76f1df
FINERACT-38: Making xmlOutput & htmlOutput true for RAT to determine …
66e9db6
FINERACT-38: Optimizing imports
f85b05c
FINERACT-38: Adding Lynx in travis yaml to debug.
c17512e
File License Header Added and Some CheckStyleAdded
9327504
Revert "FINERACT-38: Adding Lynx in travis yaml to debug."
0598c7f
Revert "FINERACT-38: Making xmlOutput & htmlOutput true for RAT to de…
6603e69
FINERACT-38: Adding Mockito imports.
b83e341
FINERACT-38: Fix in Checkstyle
a76c306
FINERACT-38: Correcting checkstyle.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
172 changes: 172 additions & 0 deletions
172
...org/apache/fineract/integrationtests/CalculateIncomeAndExpanseBookingIntegrationTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,172 @@ | ||
| /** | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you 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. | ||
| */ | ||
| package org.apache.fineract.integrationtests; | ||
| import java.math.BigDecimal; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import org.apache.fineract.accounting.closure.command.GLClosureCommand; | ||
| import org.apache.fineract.accounting.closure.data.IncomeAndExpenseBookingData; | ||
| import org.apache.fineract.accounting.closure.data.IncomeAndExpenseJournalEntryData; | ||
| import org.apache.fineract.accounting.closure.exception.RunningBalanceNotCalculatedException; | ||
| import org.apache.fineract.accounting.closure.service.CalculateIncomeAndExpenseBookingImpl; | ||
| import org.apache.fineract.accounting.closure.service.IncomeAndExpenseReadPlatformService; | ||
| import org.apache.fineract.accounting.glaccount.domain.GLAccount; | ||
| import org.apache.fineract.organisation.office.service.OfficeReadPlatformService; | ||
| import org.joda.time.LocalDate; | ||
| import org.junit.After; | ||
| import org.junit.Assert; | ||
| import org.junit.Before; | ||
| import org.junit.Test; | ||
| import org.junit.runner.RunWith; | ||
| import org.mockito.InjectMocks; | ||
| import org.mockito.Mock; | ||
| import org.mockito.runners.MockitoJUnitRunner; | ||
|
|
||
| @RunWith(MockitoJUnitRunner.class) | ||
| public class CalculateIncomeAndExpanseBookingIntegrationTest { | ||
| /* | ||
| Test class CalculateIncomeAndExpenseBookingImpl | ||
| */ | ||
| @Mock private JsonCommandWrapperTest jsonCommandWrapperTest; | ||
| @Mock private IncomeAndExpenseReadPlatformService incomeAndExpenseReadPlatformService; | ||
| @Mock private OfficeReadPlatformService officeReadPlatformService; | ||
|
|
||
| @InjectMocks | ||
| private CalculateIncomeAndExpenseBookingImpl calculateIncomeAndExpenseBooking; | ||
|
|
||
| @Before | ||
| public void setup() { | ||
| calculateIncomeAndExpenseBooking = new CalculateIncomeAndExpenseBookingImpl(null, null, null, null, incomeAndExpenseReadPlatformService,officeReadPlatformService); | ||
| } | ||
|
|
||
| @After | ||
| public void tearDown() { | ||
|
|
||
| } | ||
| /* | ||
| Case 1: All running balances has to be calculated before booking off income and expense account | ||
| If not running balances, then throw exception | ||
| */ | ||
| @Test(expected = RunningBalanceNotCalculatedException.class) | ||
| public void testBookOffIncomeAndExpenseCheckException() { | ||
| GLClosureCommand glClosureCommand = new GLClosureCommand((long)10,(long)10, new LocalDate(),"Closing comment", false, (long)10 , "CAD", false, false, "comment" ); | ||
| IncomeAndExpenseJournalEntryData incomeAndExpenseJournalEntryData= new IncomeAndExpenseJournalEntryData(null, null,null, null | ||
| , true, false, null,null,null,10,10,null,null); | ||
| List<IncomeAndExpenseJournalEntryData> incomeAndExpenseJournalEntryDataList = new ArrayList<IncomeAndExpenseJournalEntryData>(); | ||
| incomeAndExpenseJournalEntryDataList.add(incomeAndExpenseJournalEntryData); | ||
| calculateIncomeAndExpenseBooking.bookOffIncomeAndExpense(incomeAndExpenseJournalEntryDataList,glClosureCommand, false,null,null); | ||
| } | ||
|
|
||
| /* | ||
| Case 2: All running balances has to be calculated before booking off income and expense account | ||
| No exception is to be thrown since it is running for the input. | ||
| However, later a null pointer exception is thrown, since the object incomeAndExpense is not initialized. | ||
| */ | ||
| @Test | ||
| public void testBookOffIncomeAndExpense() { | ||
| GLClosureCommand glClosureCommand = new GLClosureCommand(10L, 10L, new LocalDate(), "Closing comment", false, 10L , "CAD", false, false, "comment" ); | ||
| IncomeAndExpenseJournalEntryData incomeAndExpenseJournalEntryData= new IncomeAndExpenseJournalEntryData(null, null,null, null | ||
| , true, true, null,null,null,10,10,null,null); | ||
| List<IncomeAndExpenseJournalEntryData> incomeAndExpenseJournalEntryDataList = new ArrayList<>(); | ||
| incomeAndExpenseJournalEntryDataList.add(incomeAndExpenseJournalEntryData); | ||
| Assert.assertNotNull(calculateIncomeAndExpenseBooking.bookOffIncomeAndExpense(incomeAndExpenseJournalEntryDataList, glClosureCommand, false,null,null)); | ||
| } | ||
|
|
||
| /* | ||
| Case 3: In the case of an income account type- if the OfficeRunningBalance is greater than 0, then add to debits | ||
| */ | ||
| @Test(expected = NoClassDefFoundError.class) | ||
| public void testIncomeAccountsRunningBalanceGreaterThanZero_Debit() { | ||
| GLClosureCommand glClosureCommand = new GLClosureCommand(10L, 10L, new LocalDate(), "Closing comment", false, 10L , "CAD", false, false, "comment" ); | ||
| IncomeAndExpenseJournalEntryData incomeAndExpenseJournalEntryData= new IncomeAndExpenseJournalEntryData(null, null,null, null, true, true, null,new BigDecimal(10),null,4,10,null,null); | ||
| IncomeAndExpenseJournalEntryData incomeAndExpenseJournalEntryData2= new IncomeAndExpenseJournalEntryData(null, null,null, null, true, true, null,new BigDecimal(20),null,4,10,null,null); | ||
| List<IncomeAndExpenseJournalEntryData> incomeAndExpenseJournalEntryDataList = new ArrayList<>(); | ||
| incomeAndExpenseJournalEntryDataList.add(incomeAndExpenseJournalEntryData); | ||
| incomeAndExpenseJournalEntryDataList.add(incomeAndExpenseJournalEntryData2); | ||
| GLAccount glAccount = GLAccount.fromJson(null, jsonCommandWrapperTest.getCommand(),null); | ||
| IncomeAndExpenseBookingData incomeAndExpenseBookingData = calculateIncomeAndExpenseBooking.bookOffIncomeAndExpense(incomeAndExpenseJournalEntryDataList, glClosureCommand, false, null, null); | ||
| incomeAndExpenseBookingData.getJournalEntries().forEach(entry->{ | ||
| Assert.assertEquals(entry.getDebits().get(0).getAmount(), new BigDecimal(30)); | ||
| }); | ||
| Assert.assertNotNull(calculateIncomeAndExpenseBooking.bookOffIncomeAndExpense(incomeAndExpenseJournalEntryDataList, glClosureCommand, false,null,null)); | ||
| } | ||
|
|
||
|
|
||
| /* | ||
| Case 4: In the case of an income account type- if the OfficeRunningBalance is less than 0, then add to credits | ||
| */ | ||
| @Test(expected = NoClassDefFoundError.class) | ||
| public void testIncomeAccountsRunningBalanceLessThanZero_Credit() { | ||
| GLClosureCommand glClosureCommand = new GLClosureCommand(10L, 10L, new LocalDate(), "Closing comment", false, 10L , "CAD", false, false, "comment" ); | ||
| IncomeAndExpenseJournalEntryData incomeAndExpenseJournalEntryData= new IncomeAndExpenseJournalEntryData(null, null,null, null, true, true, null,new BigDecimal(-10),null,4,10,null,null); | ||
| IncomeAndExpenseJournalEntryData incomeAndExpenseJournalEntryData2= new IncomeAndExpenseJournalEntryData(null, null,null, null, true, true, null,new BigDecimal(-20),null,4,10,null,null); | ||
| List<IncomeAndExpenseJournalEntryData> incomeAndExpenseJournalEntryDataList = new ArrayList<>(); | ||
| incomeAndExpenseJournalEntryDataList.add(incomeAndExpenseJournalEntryData); | ||
| incomeAndExpenseJournalEntryDataList.add(incomeAndExpenseJournalEntryData2); | ||
| GLAccount glAccount = GLAccount.fromJson(null, jsonCommandWrapperTest.getCommand(),null); | ||
| IncomeAndExpenseBookingData incomeAndExpenseBookingData = calculateIncomeAndExpenseBooking.bookOffIncomeAndExpense(incomeAndExpenseJournalEntryDataList, glClosureCommand, false, null, null); | ||
| incomeAndExpenseBookingData.getJournalEntries().forEach(entry->{ | ||
| Assert.assertEquals(entry.getCredits().get(0).getAmount(), new BigDecimal(30)); | ||
| }); | ||
| Assert.assertNotNull(calculateIncomeAndExpenseBooking.bookOffIncomeAndExpense(incomeAndExpenseJournalEntryDataList, glClosureCommand, false,null,null)); | ||
| } | ||
|
|
||
|
|
||
| /* | ||
| Case 5: In the case of an Expanse account type- if the OfficeRunningBalance is greater than 0, then add to credit | ||
| */ | ||
| @Test(expected = NoClassDefFoundError.class) | ||
| public void testIncomeAccountsRunningBalanceGreaterThanZero_Credit() { | ||
| GLClosureCommand glClosureCommand = new GLClosureCommand(10L, 10L, new LocalDate(), "Closing comment", false, 10L , "CAD", false, false, "comment" ); | ||
| IncomeAndExpenseJournalEntryData incomeAndExpenseJournalEntryData= new IncomeAndExpenseJournalEntryData(null, null,null, null, true, true, null,new BigDecimal(10),null,5,10,null,null); | ||
| IncomeAndExpenseJournalEntryData incomeAndExpenseJournalEntryData2= new IncomeAndExpenseJournalEntryData(null, null,null, null, true, true, null,new BigDecimal(20),null,5,10,null,null); | ||
| List<IncomeAndExpenseJournalEntryData> incomeAndExpenseJournalEntryDataList = new ArrayList<>(); | ||
| incomeAndExpenseJournalEntryDataList.add(incomeAndExpenseJournalEntryData); | ||
| incomeAndExpenseJournalEntryDataList.add(incomeAndExpenseJournalEntryData2); | ||
| GLAccount glAccount = GLAccount.fromJson(null, jsonCommandWrapperTest.getCommand(),null); | ||
| IncomeAndExpenseBookingData incomeAndExpenseBookingData = calculateIncomeAndExpenseBooking.bookOffIncomeAndExpense(incomeAndExpenseJournalEntryDataList, glClosureCommand, false, null, null); | ||
| incomeAndExpenseBookingData.getJournalEntries().forEach(entry->{ | ||
| Assert.assertEquals(entry.getDebits().get(0).getAmount(), new BigDecimal(30)); | ||
| }); | ||
| Assert.assertNotNull(calculateIncomeAndExpenseBooking.bookOffIncomeAndExpense(incomeAndExpenseJournalEntryDataList, glClosureCommand, false,null,null)); | ||
| } | ||
|
|
||
|
|
||
| /* | ||
| Case 6: In the case of an Expanse account type- if the OfficeRunningBalance is less than 0, then add to debits | ||
| */ | ||
| @Test(expected = NoClassDefFoundError.class) | ||
| public void testIncomeAccountsRunningBalanceLessThanZero_Debit() { | ||
| GLClosureCommand glClosureCommand = new GLClosureCommand(10L, 10L, new LocalDate(), "Closing comment", false, 10L , "CAD", false, false, "comment" ); | ||
| IncomeAndExpenseJournalEntryData incomeAndExpenseJournalEntryData= new IncomeAndExpenseJournalEntryData(null, null,null, null, true, true, null,new BigDecimal(-10),null,5,10,null,null); | ||
| IncomeAndExpenseJournalEntryData incomeAndExpenseJournalEntryData2= new IncomeAndExpenseJournalEntryData(null, null,null, null, true, true, null,new BigDecimal(-20),null,5,10,null,null); | ||
| List<IncomeAndExpenseJournalEntryData> incomeAndExpenseJournalEntryDataList = new ArrayList<>(); | ||
| incomeAndExpenseJournalEntryDataList.add(incomeAndExpenseJournalEntryData); | ||
| incomeAndExpenseJournalEntryDataList.add(incomeAndExpenseJournalEntryData2); | ||
| GLAccount glAccount = GLAccount.fromJson(null, jsonCommandWrapperTest.getCommand(),null); | ||
| IncomeAndExpenseBookingData incomeAndExpenseBookingData = calculateIncomeAndExpenseBooking.bookOffIncomeAndExpense(incomeAndExpenseJournalEntryDataList, glClosureCommand, false, null, null); | ||
| incomeAndExpenseBookingData.getJournalEntries().forEach(entry->{ | ||
| Assert.assertEquals(entry.getCredits().get(0).getAmount(), new BigDecimal(30)); | ||
| }); | ||
| Assert.assertNotNull(calculateIncomeAndExpenseBooking.bookOffIncomeAndExpense(incomeAndExpenseJournalEntryDataList, glClosureCommand, false,null,null)); | ||
| } | ||
|
|
||
|
|
||
|
|
||
| } |
33 changes: 33 additions & 0 deletions
33
...src/integrationTest/java/org/apache/fineract/integrationtests/JsonCommandWrapperTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /** | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you 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. | ||
| */ | ||
| package org.apache.fineract.integrationtests; | ||
|
|
||
| import org.apache.fineract.infrastructure.core.api.JsonCommand; | ||
|
|
||
| public class JsonCommandWrapperTest { | ||
| private JsonCommand command; | ||
|
|
||
| public JsonCommand getCommand() { | ||
| return command; | ||
| } | ||
|
|
||
| public void setCommand(JsonCommand command) { | ||
| this.command = command; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.