Compare commits
504
Commits
aa9643429b
...
9f78554972
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f78554972 | ||
|
|
629508dcab | ||
|
|
c6a74a1d64 | ||
|
|
7105d688bc | ||
|
|
642b45def8 | ||
|
|
27b8761011 | ||
|
|
42ff4c1b1c | ||
|
|
6515d18b73 | ||
|
|
2212618256 | ||
|
|
8acb08c526 | ||
|
|
09e2d04a6e | ||
|
|
d69e2de0ac | ||
|
|
cea6436470 | ||
|
|
bae2a7088e | ||
|
|
65d9ca11bf | ||
|
|
34a9ec41c5 | ||
|
|
64c642656f | ||
|
|
8298a8f86a | ||
|
|
118f4904c6 | ||
|
|
f197fe572a | ||
|
|
d5ce6f2c98 | ||
|
|
2fc3c9c7ee | ||
|
|
4ec1173bc3 | ||
|
|
4f67c8bf7f | ||
|
|
77dbe27281 | ||
|
|
91fc23e92a | ||
|
|
8ef61f3275 | ||
|
|
4c6ea532e9 | ||
|
|
589b1c2dbb | ||
|
|
2f5dc2875f | ||
|
|
466a691e56 | ||
|
|
c80265124b | ||
|
|
8ad5324fb6 | ||
|
|
c4db5b811a | ||
|
|
4dcb979b78 | ||
|
|
aaf7025d79 | ||
|
|
eb8c7103ae | ||
|
|
ba04ea535e | ||
|
|
d0f214c834 | ||
|
|
a51390ae37 | ||
|
|
07052f983e | ||
|
|
f58fc1c116 | ||
|
|
9b826ea98e | ||
|
|
78b6f2a3e6 | ||
|
|
637f062ce3 | ||
|
|
8f13a96f61 | ||
|
|
a15ce5ce8b | ||
|
|
d644fa9123 | ||
|
|
0d85d4b9de | ||
|
|
06dfb9d732 | ||
|
|
e25ddfd18a | ||
|
|
f93bb4a7ba | ||
|
|
958fb33db2 | ||
|
|
6646ab57db | ||
|
|
cd76d1d543 | ||
|
|
1dee8c14ee | ||
|
|
c7a6d93bc4 | ||
|
|
cc487116bb | ||
|
|
9dadb669a4 | ||
|
|
ff8f116b96 | ||
|
|
555839df31 | ||
|
|
66c6ddc82e | ||
|
|
094c205018 | ||
|
|
e420a56986 | ||
|
|
5a21aa6bfd | ||
|
|
1c83f181ab | ||
|
|
99dfadf990 | ||
|
|
c11f3af180 | ||
|
|
180c49fce9 | ||
|
|
eb2741a0e2 | ||
|
|
e1313fd254 | ||
|
|
61a096f33c | ||
|
|
7db8147f9d | ||
|
|
77e08d11c8 | ||
|
|
95447d21b7 | ||
|
|
10f22ab3eb | ||
|
|
1573b5a6b3 | ||
|
|
c4ef820ad0 | ||
|
|
5f5f94d5f2 | ||
|
|
580eec5064 | ||
|
|
03898052a0 | ||
|
|
7218ac354e | ||
|
|
dc72c8c5f0 | ||
|
|
b8b45620b4 | ||
|
|
8758d6f669 | ||
|
|
b27e0a9581 | ||
|
|
0664aca901 | ||
|
|
ef3d19c387 | ||
|
|
131b07318e | ||
|
|
c3e66a6bff | ||
|
|
915f187bef | ||
|
|
2418c09701 | ||
|
|
99b3bf1b4d | ||
|
|
f1e9c2800b | ||
|
|
a8c733100b | ||
|
|
1c49096881 | ||
|
|
b2e9ab4a9c | ||
|
|
16d974ded7 | ||
|
|
c5c34138a7 | ||
|
|
2b93590c5c | ||
|
|
c8ccc96309 | ||
|
|
80dfd752d7 | ||
|
|
630694c133 | ||
|
|
db9278d1b2 | ||
|
|
34fb6acc44 | ||
|
|
702ecd480f | ||
|
|
7d0ac6bf29 | ||
|
|
642417166c | ||
|
|
9072556925 | ||
|
|
9174a9406c | ||
|
|
2aa18a32da | ||
|
|
f05b3585e1 | ||
|
|
d576c73dbb | ||
|
|
61db1cee89 | ||
|
|
48528bc75e | ||
|
|
ec51ca3007 | ||
|
|
77e9549a54 | ||
|
|
9a8bb71235 | ||
|
|
784c180154 | ||
|
|
c7cd28c340 | ||
|
|
3bba3b9192 | ||
|
|
1164bf40a3 | ||
|
|
8a9c05e212 | ||
|
|
2134dda13f | ||
|
|
cf085c6a8d | ||
|
|
b3424921d5 | ||
|
|
659ffa3e9a | ||
|
|
9863f8d6a3 | ||
|
|
1c5364ac7f | ||
|
|
e61abec3de | ||
|
|
5c76d3d377 | ||
|
|
ba4154d8df | ||
|
|
8067a288d0 | ||
|
|
a09da301c1 | ||
|
|
4cb8ca8c71 | ||
|
|
263a32a83a | ||
|
|
546981a514 | ||
|
|
c04cebc5b6 | ||
|
|
21c4cdf002 | ||
|
|
733656685d | ||
|
|
7c26fd7723 | ||
|
|
1646995525 | ||
|
|
84c321cfe8 | ||
|
|
e9d50e09db | ||
|
|
32746c0981 | ||
|
|
d4f8c632d5 | ||
|
|
3847186f2b | ||
|
|
a1cbaf7927 | ||
|
|
f9a78d8d28 | ||
|
|
76e1c819a4 | ||
|
|
07d054cbec | ||
|
|
59622daae4 | ||
|
|
8f96e18225 | ||
|
|
d5d53ea84b | ||
|
|
cc712e71a4 | ||
|
|
eb6af6a6a3 | ||
|
|
8b36f6f27e | ||
|
|
f5077ef2b9 | ||
|
|
511a0d89c0 | ||
|
|
30c73e32ab | ||
|
|
9f739ee476 | ||
|
|
0262d89727 | ||
|
|
780bdfb01d | ||
|
|
0bf2557cfa | ||
|
|
7c6485a968 | ||
|
|
e361c913ee | ||
|
|
b18a403314 | ||
|
|
7abec8a1c9 | ||
|
|
d1039c1929 | ||
|
|
872843a327 | ||
|
|
0553cda5e3 | ||
|
|
5841e8f957 | ||
|
|
8db27ccb0b | ||
|
|
ba8710fd51 | ||
|
|
f30ad4ca0b | ||
|
|
b796cae43c | ||
|
|
47afc0e8a4 | ||
|
|
9a817c0495 | ||
|
|
d7082eebfd | ||
|
|
b52ed04fec | ||
|
|
fce91a51d3 | ||
|
|
e458dd0a4e | ||
|
|
ab14373f35 | ||
|
|
856beec760 | ||
|
|
3a525ac671 | ||
|
|
4ddf99498e | ||
|
|
430977306b | ||
|
|
f7be3555c4 | ||
|
|
3e433a12c2 | ||
|
|
1cac15959c | ||
|
|
adc99d2dec | ||
|
|
0b501d1dcd | ||
|
|
00309de7e0 | ||
|
|
ccb5717bd6 | ||
|
|
b760624cd4 | ||
|
|
15a9804427 | ||
|
|
a4465fbc15 | ||
|
|
848797985a | ||
|
|
b9cfcce1f9 | ||
|
|
3a7c8d8ebb | ||
|
|
e7aadae9fa | ||
|
|
192d690240 | ||
|
|
7ed6705f74 | ||
|
|
71517d87c6 | ||
|
|
276e6b1864 | ||
|
|
68f6ecc60d | ||
|
|
bda10bbf78 | ||
|
|
a41f926dbe | ||
|
|
253c444a45 | ||
|
|
114f17e300 | ||
|
|
d19ab1c8e4 | ||
|
|
57f014a8b0 | ||
|
|
6d5830e232 | ||
|
|
4266e5d705 | ||
|
|
ad51032aec | ||
|
|
4a83cb3d17 | ||
|
|
0b22529bb9 | ||
|
|
598f0ba4b1 | ||
|
|
4b0658a685 | ||
|
|
0e2f0eb85c | ||
|
|
4eb2cf6e21 | ||
|
|
0d8bd285dc | ||
|
|
7e0742b576 | ||
|
|
9e1313226a | ||
|
|
2e4203614c | ||
|
|
5356f5b45f | ||
|
|
5b0dc5b77b | ||
|
|
68e0b873fe | ||
|
|
7da550fe7c | ||
|
|
91ea2f0e2e | ||
|
|
8535b14646 | ||
|
|
7889254e78 | ||
|
|
18fda5d5d7 | ||
|
|
e7abf6601f | ||
|
|
a4fae7efca | ||
|
|
d3b8b02425 | ||
|
|
66e9a570dd | ||
|
|
46c51f2ff5 | ||
|
|
39c628ddf2 | ||
|
|
1385588083 | ||
|
|
b098f53627 | ||
|
|
4b9f6f3042 | ||
|
|
3e5db84702 | ||
|
|
b66cce870a | ||
|
|
cb745a196d | ||
|
|
f6853f681a | ||
|
|
45cd2e7602 | ||
|
|
933ede2c06 | ||
|
|
ba1373acae | ||
|
|
ee3adc05ce | ||
|
|
a630d89549 | ||
|
|
5130fba303 | ||
|
|
74c36e810d | ||
|
|
80e3a24742 | ||
|
|
58a15a0382 | ||
|
|
84ec7cd7b9 | ||
|
|
e27613550f | ||
|
|
efdccfbb81 | ||
|
|
9c3b40b00a | ||
|
|
6247385227 | ||
|
|
527a0bea5f | ||
|
|
d846886508 | ||
|
|
821a879610 | ||
|
|
5fc958f2bc | ||
|
|
f324f9ee8a | ||
|
|
c96980c457 | ||
|
|
d55c3d4521 | ||
|
|
8aceac3860 | ||
|
|
e644d6f53d | ||
|
|
9730f9cc65 | ||
|
|
79097ca7b9 | ||
|
|
0caed4ac23 | ||
|
|
6c6362bf34 | ||
|
|
76f064503b | ||
|
|
8a9a57a0f4 | ||
|
|
e68cba5929 | ||
|
|
3103f20fdb | ||
|
|
2a8cbfdbf9 | ||
|
|
350f313411 | ||
|
|
87217fb29e | ||
|
|
e2645b6461 | ||
|
|
c62bd61222 | ||
|
|
debd298a13 | ||
|
|
df4a070123 | ||
|
|
9893563865 | ||
|
|
80e1d67862 | ||
|
|
f2e9aa7cb0 | ||
|
|
818e085d3a | ||
|
|
1d1217accf | ||
|
|
827c4c5a0d | ||
|
|
103a4a0ee1 | ||
|
|
0ef30f4124 | ||
|
|
6fc9a99945 | ||
|
|
15c4668583 | ||
|
|
fca9659de7 | ||
|
|
a90bfada78 | ||
|
|
34324ab1d6 | ||
|
|
21ce356d88 | ||
|
|
0af62967a7 | ||
|
|
4fd78b9f0e | ||
|
|
98cc90b696 | ||
|
|
482b7aa714 | ||
|
|
80146f9565 | ||
|
|
fd3a401821 | ||
|
|
817794b26b | ||
|
|
18f70dbc2e | ||
|
|
e3e5b0a97b | ||
|
|
54765a915f | ||
|
|
1a747ab1c0 | ||
|
|
4d73189a63 | ||
|
|
b2769ff21b | ||
|
|
4dc7581972 | ||
|
|
4d4f96567e | ||
|
|
ce4ec8d035 | ||
|
|
0ab49e72e0 | ||
|
|
c05022f692 | ||
|
|
fca0404019 | ||
|
|
4664220769 | ||
|
|
54ad317227 | ||
|
|
5ead31ae9b | ||
|
|
ffbff972be | ||
|
|
c26381d594 | ||
|
|
41b62af4db | ||
|
|
0cd593d145 | ||
|
|
b758e88a4e | ||
|
|
227dd05ff2 | ||
|
|
e237a3a70e | ||
|
|
72e8b11d57 | ||
|
|
a2aea2da22 | ||
|
|
cd3e26f817 | ||
|
|
f4483ab240 | ||
|
|
5db84b4470 | ||
|
|
c30398d84a | ||
|
|
1d3e1fd60b | ||
|
|
b8b5d91bc2 | ||
|
|
41bed0aace | ||
|
|
d45270c413 | ||
|
|
5b909305c2 | ||
|
|
f4547c26d8 | ||
|
|
3f35a3e4cf | ||
|
|
241a02bf0f | ||
|
|
e3d4f08a7f | ||
|
|
456e30bf41 | ||
|
|
747305cfc9 | ||
|
|
c77b4573b6 | ||
|
|
95afc0238d | ||
|
|
65fa4d33df | ||
|
|
348c850087 | ||
|
|
6cdd3322de | ||
|
|
40665f0b66 | ||
|
|
4051afd583 | ||
|
|
40b005cbfa | ||
|
|
bd6fd35a20 | ||
|
|
ec7b7c0fd6 | ||
|
|
1ff83bd7e8 | ||
|
|
c25805a804 | ||
|
|
b5f7cc5f22 | ||
|
|
af86c1727f | ||
|
|
d9e1ba8139 | ||
|
|
6df0c28df6 | ||
|
|
64b142f478 | ||
|
|
f0f2583959 | ||
|
|
a6c463d525 | ||
|
|
eac581c48b | ||
|
|
e3658a5a8f | ||
|
|
14989c0ccf | ||
|
|
8edcaf934e | ||
|
|
7ebabc10f6 | ||
|
|
cb4a249958 | ||
|
|
9599c1197a | ||
|
|
3c8a9c232d | ||
|
|
ae1cbf371e | ||
|
|
24fb2d489d | ||
|
|
21db526584 | ||
|
|
0389bde94e | ||
|
|
958c27c443 | ||
|
|
6745cf6280 | ||
|
|
38481b03cf | ||
|
|
530301cc59 | ||
|
|
5cfc7e85c5 | ||
|
|
ef7c7c15a3 | ||
|
|
a30f46f5d8 | ||
|
|
6a14031ac3 | ||
|
|
78284b8115 | ||
|
|
b385a95a30 | ||
|
|
7c76541a2d | ||
|
|
3c97fccee8 | ||
|
|
b4c3e8be64 | ||
|
|
83ae893088 | ||
|
|
b0df80e2a2 | ||
|
|
1b60601664 | ||
|
|
4975a59b7e | ||
|
|
342a0edc24 | ||
|
|
85207ae273 | ||
|
|
07c39d49af | ||
|
|
55ef6628c1 | ||
|
|
b2bf8cbe95 | ||
|
|
ffb5dc3715 | ||
|
|
3ac3a0ff5f | ||
|
|
5a06119811 | ||
|
|
f51cf6f4fe | ||
|
|
44a235d329 | ||
|
|
b852af14d3 | ||
|
|
1e89de1807 | ||
|
|
ef43647a10 | ||
|
|
16fc259540 | ||
|
|
45a372944c | ||
|
|
fc2d90db7b | ||
|
|
1eff0f138e | ||
|
|
b1cf0b5e59 | ||
|
|
722aceccc7 | ||
|
|
0e62a7de81 | ||
|
|
06448ccb54 | ||
|
|
5481d2033a | ||
|
|
cdd724f601 | ||
|
|
c0b92c97af | ||
|
|
2e9604c126 | ||
|
|
81e847aada | ||
|
|
5664ac3f98 | ||
|
|
b5ed7fecf7 | ||
|
|
5474e87227 | ||
|
|
2d7b1d9cf4 | ||
|
|
5ae0e0f62c | ||
|
|
fc0bb3897d | ||
|
|
cb52335e23 | ||
|
|
d67bf61d1c | ||
|
|
da20683715 | ||
|
|
0d2abd3b60 | ||
|
|
d1575d9cbb | ||
|
|
3aa3699eaa | ||
|
|
a152cb6698 | ||
|
|
0fd87bf951 | ||
|
|
a2ba251b83 | ||
|
|
199dbfd417 | ||
|
|
01c05abad6 | ||
|
|
f9dfd409db | ||
|
|
c2c2f65c13 | ||
|
|
43a3359ac2 | ||
|
|
e0e4b1db43 | ||
|
|
f23a0cb18b | ||
|
|
60e2af384b | ||
|
|
722e657ea9 | ||
|
|
4e84934110 | ||
|
|
f7204f3905 | ||
|
|
c26bac92d8 | ||
|
|
8a4fa86f03 | ||
|
|
9c9c91b44a | ||
|
|
9aa9473c8c | ||
|
|
9126e40ddc | ||
|
|
48baa127d4 | ||
|
|
1f07da18d4 | ||
|
|
b66e289df8 | ||
|
|
fcaad335f0 | ||
|
|
58d4458515 | ||
|
|
7ad0a6c71b | ||
|
|
17d96ae8a6 | ||
|
|
a01d243078 | ||
|
|
46b653e387 | ||
|
|
e0fd3d0fe7 | ||
|
|
ccb98baf5f | ||
|
|
f7254fc660 | ||
|
|
e8de3cbecc | ||
|
|
632855d896 | ||
|
|
fb5398e83b | ||
|
|
97a88e1d1e | ||
|
|
2a60b05bf6 | ||
|
|
c8fccc51ad | ||
|
|
67a7570412 | ||
|
|
f4e47cc013 | ||
|
|
3eb0b46a89 | ||
|
|
c6d39fa737 | ||
|
|
a031463930 | ||
|
|
5ef940627c | ||
|
|
469f871756 | ||
|
|
d04f2757e2 | ||
|
|
602f0bdb07 | ||
|
|
d7399cc6e5 | ||
|
|
80439d6e6d | ||
|
|
7f5ff5780f | ||
|
|
2aa8b89d65 | ||
|
|
317363de11 | ||
|
|
e820d4ae00 | ||
|
|
63173c0de0 | ||
|
|
9035063dc2 | ||
|
|
baeab1f7c8 | ||
|
|
71505edbc5 | ||
|
|
06efcb73c9 | ||
|
|
c2d94f2976 | ||
|
|
dbde081057 | ||
|
|
caad86ac65 | ||
|
|
e1a8c8a371 | ||
|
|
2885cc0864 | ||
|
|
e09162f5e2 | ||
|
|
c89699c9df | ||
|
|
6cc6d03785 | ||
|
|
54b60fdcd0 | ||
|
|
a450829b94 | ||
|
|
ece576e275 | ||
|
|
1db61882a8 | ||
|
|
37710750eb | ||
|
|
f194867c15 | ||
|
|
226439bef1 | ||
|
|
d33c16e594 | ||
|
|
e6ac1213f7 |
@@ -4,3 +4,8 @@ jdk:
|
||||
script: ./travis_build.sh
|
||||
notifications:
|
||||
email: true
|
||||
# This is so that the Gradle output is readable on the Travis web console
|
||||
# @see http://stackoverflow.com/questions/17942819/how-can-i-get-clean-gradle-output-on-travis-ci
|
||||
# @see http://gradle.1045684.n5.nabble.com/Plain-console-output-td5710237.html
|
||||
env:
|
||||
- TERM=dumb
|
||||
|
||||
+269
@@ -6,6 +6,11 @@ See VERSIONING (https://github.com/openMF/mifosx/blob/master/VERSIONING.md) for
|
||||
Releases
|
||||
===============
|
||||
|
||||
1. 1 Nov 2014 - 1.25.1.RELEASE
|
||||
1. 12 Oct 2014 - 1.25.0.RELEASE
|
||||
1. 10 Jul 2014 - 1.24.0.RELEASE
|
||||
1. 16 Jun 2014 - 1.23.1.RELEASE
|
||||
1. 15 Jun 2014 - 1.23.0.RELEASE
|
||||
1. 30 Apr 2014 - 1.22.0.RELEASE
|
||||
1. 30 Mar 2014 - 1.21.0.RELEASE
|
||||
1. 18 Mar 2014 - 1.20.1.RELEASE
|
||||
@@ -63,6 +68,270 @@ Releases
|
||||
1. 05 April 2013 - 0.11.1.beta
|
||||
1. 05 April 2013 - 0.11.0.beta
|
||||
|
||||
1.25.1.RELEASE
|
||||
=============
|
||||
Bug Release
|
||||
|
||||
Platform & API
|
||||
|
||||
New Features & Improvements
|
||||
- [MIFOSX-1466] - Savings interest posting - Should be flexible
|
||||
- [MIFOSX-1632] - Fine tuning of Accrual transactions with interest recalculation
|
||||
|
||||
Bugs
|
||||
- [MIFOSX-1586] - Applying overdue charge for a loan with interest recalculation causes the application to create multiple schedules for the same loan account
|
||||
- [MIFOSX-1589] - Support for Charge and interest waivers with Accrual accounting
|
||||
- [MIFOSX-1595] - Periodic accrual is posting wrong interest when run multiple times in a repayment period
|
||||
- [MIFOSX-1606] - Closing savings account throws null pointer exception
|
||||
- [MIFOSX-1608] - Rounding issue in periodic accrual for loan accounts with Decimal Place as Zero.
|
||||
- [MIFOSX-1612] - If a loan disbursal is undone, then the journal entries created for the accrued interest on that loan is not being reversed.
|
||||
- [MIFOSX-1631] - Not able to disburse loan with installment fees attached
|
||||
|
||||
Community App
|
||||
- [MIFOSX-1626] - Pagination Issue in Audit Trails Search
|
||||
- [MIFOSX-1604] - Community app always uploads signature to the "default" tenant, similar issues exists with loan documents
|
||||
|
||||
1.25.0.RELEASE
|
||||
=============
|
||||
This feature release ships various enhancements like interest recalculation for loans with configurable rest definitions and compounding options, point in time accruals, improved pre-payment functionality, batching API calls and support for Hooks along with a number of updates to the Community app and bug fixes.
|
||||
|
||||
New Features & Improvements
|
||||
|
||||
- [MIFOSX-580] - Add support for 'pure' declining balance
|
||||
- [MIFOSX-1442] - Support for Webhooks
|
||||
- [MIFOSX-1188] - GSOC Project: Batch API
|
||||
- [MIFOSX-1420] - Add pre-payment functionality
|
||||
- [MIFOSX-1537] - Add display of original Schedule for interest recalculation
|
||||
- [MIFOSX-1526] - Add future installments display for interest first repayment strategies
|
||||
- [MIFOSX-1416] - Add batch jobs to run accruals with specific periodicity
|
||||
- [MIFOSX-1417] - Add API to add accrual transactions till specified date
|
||||
- [MIFOSX-1418] - Recalculate and adjust accruals for back dated entries
|
||||
- [MIFOSX-1252] - Add API's for assigning and unassigning Staff for savings account (along with tracking assignment history similar to loans)
|
||||
- [MIFOSX-1265] - Ability to capture "External ID" for Savings account
|
||||
- [MIFOSX-1315] - Global search should search for saving account number and external id fields
|
||||
- [MIFOSX-1395] - Add Loan/Savings Product Short Name in ClientAccounts Response
|
||||
- [MIFOSX-1397] - Added Submitted date on loan transaction and saving transaction
|
||||
- [MIFOSX-1400] - User should be able to modify client submission date
|
||||
- [MIFOSX-1415] - Modify loan and Add Accrual Transactions batch job to capture last accrued date
|
||||
- [MIFOSX-1468] - Add a "joining date" field for staff
|
||||
- [MIFOSX-1522] - Add loan running balance to transactions
|
||||
- [MIFOSX-1470] - Increase column length to 200 for COA name field
|
||||
- [MIFOSX-1434] - Populate Submitted On date for Create Client with default date as current date
|
||||
|
||||
|
||||
Bugs
|
||||
|
||||
- [MIFOSX-1145] - Update data table throws "Data truncation: Invalid use of NULL value" SQL error
|
||||
- [MIFOSX-1424] - Opening and closing of Overdraft account
|
||||
- [MIFOSX-1184] - BeanCurrentlyInCreationException: Error creating bean with name 'schedulerStopListener': Requested bean is currently in creation: Is there an unresolvable circular reference?
|
||||
- [MIFOSX-1291] - Overdue Fees
|
||||
- [MIFOSX-1368] - In Loans excess repayment is not getting repaid properly if Repayment Strategy is RBI
|
||||
- [MIFOSX-1410] - Should not allow to close Client with -ve account balance (Overdraft account)
|
||||
- [MIFOSX-1411] - Withdraw of amount in RD account results in null point exception
|
||||
- [MIFOSX-1426] - Issues related to Loan Collaterals
|
||||
- [MIFOSX-1429] - Loans incorrectly classified as NPA
|
||||
- [MIFOSX-1452] - Active Client Loan not correct when there is a group loan
|
||||
- [MIFOSX-1453] - When transferring a client with a loan status as overpaid to another branch the loan status is changed to active instead of overpaid
|
||||
- [MIFOSX-1467] - Periodic accrual accounting is not working properly if the gap between loan approved and disbursement date is more
|
||||
- [MIFOSX-1483] - Not able to submit Recurring deposit account application if "Deposit Frequency" is defined as days
|
||||
- [MIFOSX-1500] - Some fields for loan in the client page loan section not populate/displayed.
|
||||
- [MIFOSX-1501] - Fixing Issues related to clean shutdown of Mifos Server: AbandonedCleanupThread and Quartz scheduler worker Threads.
|
||||
- [MIFOSX-1513] - If more than one repayment is done on today's date (i.e sysdate) loan got closed with overpaid status
|
||||
- [MIFOSX-1517] - For Tranche Loans interest is getting calculated with respect to the Approved amount than Disbursed amount
|
||||
- [MIFOSX-1528] - Missing Documentation: For Assign and Unassign Loan Officer
|
||||
- [MIFOSX-1531] - Not Appearing Loan Approval and Loan Disbursal in Checker Inbox & Tasks
|
||||
- [MIFOSX-1539] - In Loan account "First repayment on" is not working as expected
|
||||
- [MIFOSX-1547] - Interest is getting calculated for the non Disbursed amount in Tranche loan if one of the repayment date and 2nd Tranche disbursement date is today
|
||||
- [MIFOSX-1549] - For JLG Loans repayments are not syncing with the meeting dates if disbursement date is other than meeting date
|
||||
- [MIFOSX-1554] - Not able to withdraw amount from savings account having sufficient balance
|
||||
- [MIFOSX-1557] - No Journal entries are created if accounts are being mapped in 'Advance Accounting Rule" (Issue found only in Accrual Accounting)
|
||||
- [MIFOSX-1561] - In Tranche Loan should not allowed to repay second Tranche amount if only first Tranche is disbursed
|
||||
- [MIFOSX-1563] - For Loans, generated schedule is incorrect after the first repayment
|
||||
|
||||
|
||||
Community App
|
||||
|
||||
- [MIFOSX-1020] - Improvements in User profile page
|
||||
- [MIFOSX-1037] - Need thousands separator for amounts
|
||||
- [MIFOSX-1425] - Bulk JLG Loan Applications
|
||||
- [MIFOSX-1534] - Limited Date Formats
|
||||
- [MIFOSX-1497] - Loan Category under Loan purpose
|
||||
- [MIFOSX-1516] - High CPU Usage from "grunt serve"
|
||||
- [MIFOSX-1437] - Center Screen Layout Changes
|
||||
- [MIFOSX-1438] - Groups Screen Layout Changes
|
||||
- [MIFOSX-1374] - Improvements to Chart of Account UI
|
||||
- [MIFOSX-1308] - The labels for collateral attributes are inconsistent on different pages.
|
||||
- [MIFOSX-1031] - UI related Issues
|
||||
- [MIFOSX-1290] - Correctly spell Installment Fee under Charge time type
|
||||
- [MIFOSX-1432] - Minor layout fixes to Organization Admin screens
|
||||
- [MIFOSX-1446] - In "Client savings transaction" page ( transaction page -> Export) different client name is displaying
|
||||
- [MIFOSX-1465] - UI and Label related issues
|
||||
- [MIFOSX-1430] - Activities search bar on home page doesn't populate with available activities or actually search
|
||||
- [MIFOSX-1433] - Products Views layout changes.
|
||||
- [MIFOSX-1455] - In Centers -> View Centers -> Create Group page members added is not displaying properly in Group General page
|
||||
- [MIFOSX-1325] - Add ability to attach a group to a center
|
||||
- [MIFOSX-1482] - Improve work-flow for adding Clients to a Group during its Creation
|
||||
- [MIFOSX-1574] - Unable to search for GL Accounts by GL Codes in "Add Journal Entries"
|
||||
|
||||
|
||||
|
||||
1.24.0.RELEASE
|
||||
=============
|
||||
This feature release ships improvements to savings accounts including support for weekly fees and minimum balance for interest calculation along with a number of bug fixes and minor enhancements
|
||||
|
||||
Also note that issue https://mifosforge.jira.com/browse/MIFOSX-1364 introduces an API breaking change.
|
||||
|
||||
Platform & API
|
||||
|
||||
New Features & Improvements
|
||||
|
||||
- [MIFOSX-1392] - Add minimum balance support for interest calculation
|
||||
- [MIFOSX-1161] - Add minimum balance to savings product and accounts
|
||||
- [MIFOSX-1235] - Saving charges with weekly frequency
|
||||
- [MIFOSX-1275] - Improve logging for Standing Instructions
|
||||
- [MIFOSX-1398] - Add an option for balance withdrawal on closing of savings account
|
||||
- [MIFOSX-1324] - Support for server side Image resizing
|
||||
|
||||
Bugs
|
||||
|
||||
- [MIFOSX-1364] - Checker permissions should have _CHECKER appended to the Action name
|
||||
- [MIFOSX-1157] - API Document updates related to recurring deposit extensions
|
||||
- [MIFOSX-1200] - In Fixed deposit on premature closure withdrawal amount is calculating incorrectly
|
||||
- [MIFOSX-1204] - Missing documentation related to optional parameter "multiRow" while Creating Data tables
|
||||
- [MIFOSX-1272] - Percentage of Fee amount on Loan disbursement should calculated with respect to actual disbursed amount than approved amount
|
||||
- [MIFOSX-1302] - Organization currencies can be deleted even when they are associated with active loan/savings products or charges
|
||||
- [MIFOSX-1339] - Reinvest of Term deposits should not be allowed on premature closure
|
||||
- [MIFOSX-1340] - In Recurring deposits for Mandatory savings, activation of account and deposits not getting scheduled with meeting dates
|
||||
- [MIFOSX-1341] - Withdrawal is not possible in active recurring deposit if "Allow withdrawal" checkbox is selected while submitting the application
|
||||
- [MIFOSX-1351] - Charge on activation attached to a saving product is not creating journal entry while creating a client with active savings account
|
||||
- [MIFOSX-1353] - Monthly charges attached to an active savings account is not getting collected on due date
|
||||
- [MIFOSX-1357] - Repayment reschedule to next meeting date is falling on Non working day in Loan repayment schedule
|
||||
- [MIFOSX-1358] - If repayment reschedule date is defined as holiday, then also repayment falls on that date
|
||||
- [MIFOSX-1359] - Code Duplication in multiple classes: Re-factor and cleanup as necessary
|
||||
- [MIFOSX-1365] - Not able to disburse Loan with backdated (borrower loan counter included) for the client who already having active Loans ( borrower loan counter not included)
|
||||
- [MIFOSX-1366] - Incentive value defined for Gender in Fixed and Recurring deposit product is displaying improper value on submitting account for a client
|
||||
- [MIFOSX-1369] - Undo disbursal of Loan is not getting updated in "Amount Disbursed for Today" home page
|
||||
- [MIFOSX-1394] - For overdraft account interest is not posting properly for the +ve balance after repayment of dues
|
||||
- [MIFOSX-1399] - Creating new Guarantor for loan account crash if the loan already has existing guarantor
|
||||
- [MIFOSX-1401] - Allow value 0 for inArrearsTolerance when editing loanAccount
|
||||
- [MIFOSX-1349] - In Client savings account -> Chages page - Monthly charges is not updating properly
|
||||
- [MIFOSX-1403] - Closing of Fixed deposit creates double journal entries
|
||||
|
||||
Community App
|
||||
|
||||
- [MIFOSX-1142] - Ability to zoom-in client's photo in the community-app
|
||||
- [MIFOSX-1158] - Allow upload of a client's signature & preview of the same
|
||||
- [MIFOSX-1348] - Implementation of sorting options for transaction preview tables for Fixed deposits and Recurring deposit accounts
|
||||
- [MIFOSX-1333] - Usability related issue in Frequent posting and Add journal entry pages
|
||||
- [MIFOSX-1396] - Improper error message is displayed on trying to delete the used code values.
|
||||
- [MIFOSX-1404] - Not able to add Group to the Center
|
||||
- [MIFOSX-1367] - Merge Landing Page and Dashboard for the Community App
|
||||
- [MIFOSX-1371] - Improvements to Add Journal Entries screens
|
||||
- [MIFOSX-1373] - Improvements to Search Journal Entries screens
|
||||
- [MIFOSX-1375] - Improvements to Accounting Closure screens
|
||||
- [MIFOSX-1376] - Improvements to Accounting Rules screens
|
||||
- [MIFOSX-1414] - Add change password button in user profile screen
|
||||
- [MIFOSX-1413] - Populate date for collection sheet with default date as current date
|
||||
- [MIFOSX-1362] - After Loan disbursement for a client in Transaction page displaying "Accrual" in transaction type for interest
|
||||
- [MIFOSX-1388] - UI related issues due to bootstrap upgradation
|
||||
- [MIFOSX-1390] - Term deposits - UI related issues
|
||||
- [MIFOSX-1391] - Duplicate Client Creation Forms
|
||||
- [MIFOSX-1218] - Make view of action to be verified more readable for checker
|
||||
|
||||
1.23.1.RELEASE
|
||||
=============
|
||||
Bug Release
|
||||
|
||||
Bugs
|
||||
- [MIFOSX-1336] - Mifos X Generates Incorrect Repayment Schedules for Loans
|
||||
|
||||
|
||||
1.23.0.RELEASE
|
||||
=============
|
||||
This feature release contains works around adding support for opening fixed deposits from existing savings accounts, transferring interest from fixed deposits to savings Account, accounting improvements for account Transfers, ability to collect "recovery payments" for written off Loans, flexible interest rate charts with the ability to provide incentives based on customer attributes along with a number of bug fixes
|
||||
|
||||
Platform & API
|
||||
|
||||
New Features & Improvements
|
||||
|
||||
- [MIFOSX-1163] - Add support for opening fixed deposits from existing savings account
|
||||
- [MIFOSX-1182] - Add support to transfer interest from fixed deposit to linked savings account
|
||||
- [MIFOSX-695] - Clean up Account Transfers functionality implementation
|
||||
- [MIFOSX-281] - Add ability to enter a 'recovery repayment' on written off loan
|
||||
- [MIFOSX-1227] - Option to set staff as active/inactive
|
||||
- [MIFOSX-1024] - Add support to decline maker checker
|
||||
- [MIFOSX-709] - Ability of Not allow to Close Client with the Loan status "Overpaid"
|
||||
- [MIFOSX-982] - Add ability to associate a staff to user
|
||||
- [MIFOSX-1203] - Add batch job to update status from Active to Matured in Fixed deposits
|
||||
- [MIFOSX-1313] - Add support to use incentives for interest rate chart
|
||||
|
||||
Bugs
|
||||
|
||||
- [MIFOSX-1019] - transferring a client with a savings account not approved yet crashes
|
||||
- [MIFOSX-1099] - Added validation that compound period falls within posting period
|
||||
- [MIFOSX-1107] - Transaction balance end day calculated wrongly after interest posting in recurring deposit account
|
||||
- [MIFOSX-1115] - Withdrawal posted twice when closing matured recurring deposit account
|
||||
- [MIFOSX-1150] - Issue where null pointer exception was thrown after enabling cash based accounting for recurring deposit account
|
||||
- [MIFOSX-1151] - Issue where expected first deposit date was not updated when recurring deposit account was edited
|
||||
- [MIFOSX-1162] - Undo disbursal failing for loans which have overdue charges
|
||||
- [MIFOSX-1187] - Not able to submit Fixed deposit application if the Maximum deposit term is not defined in Product level
|
||||
- [MIFOSX-1183] - replaced fields in loans api transactions part (loanTransactionType.invalid)
|
||||
- [MIFOSX-960] - Lefthand navigation menu shouldn't collapse automatically
|
||||
- [MIFOSX-1300] - Should not allowed to transfer fund from Savings account to an active Fixed deposit account
|
||||
- [MIFOSX-1200] - In Fixed deposit on premature closure withdrawal amount is calculating incorrectly
|
||||
- [MIFOSX-1288] - For FD and RD transfer to savings account on premature closure is not working as expected
|
||||
- [MIFOSX-1242] - For update fixed deposit product - "View Audit entry" page displays other improper details along with the output
|
||||
- [MIFOSX-1243] - Not able to create Fixed deposit account for a client if Maker checker task is enabled.
|
||||
- [MIFOSX-1244] - Details displayed in "Waiting For Checker Approval" page after creating Recurring Deposit is not proper
|
||||
- [MIFOSX-1245] - Not able to create Recurring deposit account for a client if Maker checker task is enabled.
|
||||
- [MIFOSX-1260] - Not able to create a client with the savings account attached
|
||||
- [MIFOSX-1268] - In demo version Transactions created by activation of savings account while creating client is not proper
|
||||
- [MIFOSX-1270] - In Savings account Journal entries are not mapping properly because of the charges attached on activation.
|
||||
- [MIFOSX-1274] - Standing Instructions fail if the savings account had gone to negative balance during account creation
|
||||
- [MIFOSX-1318] - Not able to Generate collection sheet for the defined meeting date
|
||||
- [MIFOSX-1238] - Error while running Pentaho reports in MySQL 5.6+ with strict mode enabled
|
||||
- [MIFOSX-1208] - Issue on Retrieving Datatable entries for Office.
|
||||
- [MIFOSX-1215] - Not able to approve/delete maker checker tasks with checker user role
|
||||
- [MIFOSX-1237] - Able to login with Deleted user
|
||||
- [MIFOSX-1335] - Not able to close FD and RD accounts, displays "account is not active" error message
|
||||
|
||||
Community App
|
||||
|
||||
- [MIFOSX-1233] - When assigning staff to Centers, Groups, Client, Loan, Savings a/c: Only loan officers who belong to the branch should be displayed in dropdown
|
||||
- [MIFOSX-1154] - Usability issues while editing data tables
|
||||
- [MIFOSX-1164] - Clean up login page transition
|
||||
- [MIFOSX-1320] - Force logout on the community app on tab/window close
|
||||
- [MIFOSX-1263] - Client/Loan Account info table takes up too much space
|
||||
- [MIFOSX-1039] - Provide option for External ID to Loans
|
||||
- [MIFOSX-1069] - Implementation of sorting options for transaction preview tables for savings or loans.
|
||||
- [MIFOSX-1207] - Journal Entries - should have debits before credits
|
||||
- [MIFOSX-1209] - In Loan repayment schedule page "Waive" column should be introduced
|
||||
- [MIFOSX-1226] - UI improvements in Fixed deposits
|
||||
- [MIFOSX-1254] - The UI for defining/managing charges, refers to loan products only. Charges may be set up for other products.
|
||||
- [MIFOSX-1255] - Overdue charges do not appear in UI in loan product edit mode
|
||||
- [MIFOSX-1256] - Filter charge and overdue charges drop-down lists to display only valid charges (matching currency)
|
||||
- [MIFOSX-1257] - When creating charges, charges may be associated with either Loan or Saving, but Saving apply to Fixed and Recurring Deposits as well.
|
||||
- [MIFOSX-1259] - Need space between icons and text
|
||||
- [MIFOSX-1267] - Loan writeoff screen should display Writeoff amount
|
||||
- [MIFOSX-1294] - Ability to hide " Add Fee Frequency " field for Loan charges except for Overdue fees
|
||||
- [MIFOSX-1297] - In Saving product creation page settings is not working as expected
|
||||
- [MIFOSX-1299] - Not able to add cash based accounting in Edit Fixed deposit product
|
||||
- [MIFOSX-1196] - In fixed deposit product not able to "Edit Interest Rate Chart" displays improper error message
|
||||
- [MIFOSX-1198] - Mobile Number field in Community App should be Text instead of Numeric field
|
||||
- [MIFOSX-1282] - UI related issues in FD, RD, Loan and Savings products
|
||||
- [MIFOSX-1276] - Not able to save Edit loan product page with Accounting "None"
|
||||
- [MIFOSX-1279] - Deposit frequency is missed in Create and edit Recurring deposit product
|
||||
- [MIFOSX-1280] - "Locking period frequency" is displaying improper values after submitting the Fixed deposit application and Recurring deposit application for a client
|
||||
- [MIFOSX-1281] - In cash based accounting for loan products "Over payment liability" GL accounts are not displaying in dropdown
|
||||
- [MIFOSX-1314] - Transfer of overpaid Loan amount to Savings account navigates to a page displays without entries
|
||||
- [MIFOSX-1327] - Date format modified in settings is displaying "invalid date format" error while adding charge to savings account
|
||||
- [MIFOSX-1328] - UI related issues
|
||||
- [MIFOSX-1217] - Overdue charges added while creating the loan product is not displaying in Edit loan product page.
|
||||
- [MIFOSX-1219] - Unable to make datatable entries for manually registered datatables
|
||||
- [MIFOSX-1221] - External ID added while creating the center is not displaying in center general page
|
||||
- [MIFOSX-1240] - Gender drop down menu does not display when editing client information
|
||||
- [MIFOSX-1331] - For saving charges in Edit charge page Dropdown of "Charge calculation" is displaying Loan charge related inputs
|
||||
|
||||
|
||||
1.22.0.RELEASE
|
||||
=============
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# Getting started with Mifos X
|
||||
Instructions for getting started are located at https://mifosforge.jira.com/wiki/display/MIFOSX/Getting+started+-+Contributing+to+MifosX
|
||||
|
||||
# Pull Request Checklist
|
||||
Before sending out a pull request, please ensure that the following pre-requisites are taken care of
|
||||
|
||||
1. API documentation has been updated to reflect any changes made to the API (new API's, adding new Fields or Options to existing API etc)
|
||||
|
||||
1. An integration test is added/updated to test the new feature developed/bug-fix being made
|
||||
|
||||
1. The pull request has a Jira issue associated with it. Details for creating issues on Jira are located at https://mifosforge.jira.com/wiki/display/MIFOSX/Getting+started+-+Contributing+to+MifosX#Gettingstarted-ContributingtoMifosX-CreateIssues
|
||||
|
||||
1. The Relevant Jira number (Ex: MIFOSX-1454) is present as a part of the commit message. Refer http://comments.gmane.org/gmane.comp.finance.mifos.devel/14664 for details
|
||||
|
||||
1. Newly added code has been formatted and cleaned up as per our preferences at https://github.com/openMF/mifosx/wiki/Eclipse#apply-project-preferences-to-eclipse
|
||||
|
||||
1. Comments are added where relevant to ease peer review
|
||||
|
||||
1. Your work is present in a single commit rather than several broken up commits. This helps us maintain a cleaner commit history. https://github.com/openMF/mifosx/wiki/Github-&-Git#contributing-back-changes-to-original-repositoryauthors has instructions for squashing multiple commits or resetting head and recommiting your work as a single commit
|
||||
|
||||
1. Your work is rebased on top of the latest code from develop branch to make life easier for our Committers
|
||||
|
||||
1. "gradlew licenseFormatMain licenseFormatTest licenseFormatIntegrationTest" has been run to apply the Mozilla License on all newly added files (your pull requests are verified to ensure compliance with this since https://github.com/openMF/mifosx/pull/1053)
|
||||
+60
-24
@@ -32,7 +32,7 @@ The two ways to get up and running with mifos platform is:
|
||||
|
||||
## 1. Amazon Public AMI
|
||||
|
||||
Use AWS Wizard to launch instance by using this link: <a target="_blank" href="https://console.aws.amazon.com/ec2/home?region=eu-west-1#launchAmi=ami-948b6be3" title="Mifos Platform Public AMI 1.13.0.RELEASE">Mifos Platform AMI (ami-948b6be3)</a>
|
||||
Use AWS Wizard to launch instance by using this link: <a target="_blank" href="https://console.aws.amazon.com/ec2/home?region=ap-southeast-1#launchAmi=ami-a6035af4" title="Latest Mifos Platform Public AMI">Mifos Platform AMI (ami-a6035af4)</a>
|
||||
|
||||
*Note:* Read through the following as you step through the AWS Wizard
|
||||
|
||||
@@ -44,23 +44,21 @@ The two ways to get up and running with mifos platform is:
|
||||
- You will be asked to use a 'keypair' which you will need to SSH onto the new instance, if this is your first time create a new keypair, be srue to download it and store in place as you will need it later, otherwise use an existing keypair.
|
||||
- When the instance starts, the following should be available at:
|
||||
- Platform application should be available @ https://[public DNS]:8443/mifosng-provider/api/v1/offices?tenantIdentifier=default&pretty=true
|
||||
- Reference application should be available @ https://[public DNS]:8443/IndividualLendingGeneralJavaScript/IndivLendHome.html?baseApiUrl=https://[server ip address]:8443/mifosng-provider/api/v1/
|
||||
- Community app should be available @ https://[public DNS]:8443/community-app
|
||||
- API docs should be available @ https://[public DNS]:8443/api-docs/apiLive.htm
|
||||
|
||||
*Name:* Mifos Platform 1.13.0.RELEASE Public AMI
|
||||
*Name:* Mifos Platform 1.24.0.RELEASE Public AMI
|
||||
|
||||
- AMI ID: ami-948b6be3
|
||||
- Kernel ID: aki-71665e05
|
||||
- Name: Mifos Platform 1.13.0.RELEASE Public AMI
|
||||
- Owner: 476083131096
|
||||
- Source: 476083131096/Mifos Platform 1.13.0.RELEASE Public AMI
|
||||
- AMI ID: ami-a6035af4
|
||||
- Kernel ID: aki-503e7402
|
||||
- Name: Mifos Platform 1.24.0.RELEASE Public AMI
|
||||
- Owner: 540782944231
|
||||
- Source: 540782944231/Mifos X-1.24.0 release
|
||||
- Architecture: Ubuntu12.04 LTS x86_64
|
||||
- Built starting from Ubuntu AMI ami-35acbb41
|
||||
- Java 1.6_45 32 bit JVM
|
||||
- Java 1.7.0_51 64 bit JVM
|
||||
- Tomcat 7.0.39 (with SSL configured for self-signed certificate)
|
||||
- MySql 5.5.31
|
||||
- Mifos Platform 1.13.0.RELEASE
|
||||
- Mifos Reference App 1.13.0.RELEASE
|
||||
|
||||
## 2. Manual Installation
|
||||
|
||||
@@ -96,29 +94,67 @@ The two ways to get up and running with mifos platform is:
|
||||
exit
|
||||
```
|
||||
|
||||
Step two: populate mifosplatform-tenants database using ```database/mifospltaform-tenants-first-time-install.sql```
|
||||
```
|
||||
mysql -uroot -pmysql mifosplatform-tenants < database/mifospltaform-tenants-first-time-install.sql
|
||||
```
|
||||
|
||||
Step three: create mifostenant-default database
|
||||
Step two: create mifostenant-default database
|
||||
```
|
||||
mysql -uroot -pmysql
|
||||
create database `mifostenant-default`;
|
||||
exit
|
||||
```
|
||||
The tables and lookup data for both databases are created on application startup.
|
||||
|
||||
Step three (optional): to be followed only if your mysql credentials are other than root/mysql
|
||||
|
||||
Manually restore the contents of *mifosplatform-tenants* database
|
||||
|
||||
```
|
||||
mysql -uroot -pmysql mifosplatform-tenants < database/mifospltaform-tenants-first-time-install.sql
|
||||
```
|
||||
Next, update the default credentials for connecting to *mifoplatform-default* database stored in the *tenants* table of *mifosplatform-tenants* with your credentials
|
||||
|
||||
```
|
||||
UPDATE tenants SET schema_username = "your_username", schema_password = "your_password" WHERE identifier = "default";
|
||||
```
|
||||
|
||||
#### 2.2.2 Upgrade existing database(s)
|
||||
|
||||
Those updating an existing MifosX installation to version 1.21.* or higher would need to upgrade the *mifosplatform-tenants* database with patch ```database/migrations/list_db/V2__externalize-connection-properties.sql```
|
||||
```
|
||||
mysql -uroot -pmysql mifosplatform-tenants < database/migrations/list_db/V2__externalize-connection-properties.sql
|
||||
```
|
||||
|
||||
Any *tenant* databases will be upgraded automatically when the application starts if the *auto_update* field of the *tenants* database table is enabled(=1). This is the default setting.
|
||||
The list database *mifosplatform-tenants* is upgraded when the application starts. Any *tenant* databases will also be upgraded automatically when the application starts if the *auto_update* field of the *tenants* database table is enabled(=1). This is the default setting.
|
||||
|
||||
Upgrading your database in this way is the recommended way as it will upgrade any *tenants* setup in the *mifosplatform-tenants* database but can be disabled by setting the *auto_update* field of the tenant to zero.
|
||||
|
||||
##### 2.2.2.1 Special Instructions for those upgrading from version 1.24.* or lower
|
||||
|
||||
Starting from version 1.25.* , updates to *mifosplatform-tenants* database are managed by Flyway (http://flywaydb.org/). To ensure that flyway works correctly, verify that table *schema_version* is present along with two entries in *mifosplatform-tenants* database.
|
||||
|
||||
You can do so as follows
|
||||
|
||||
````
|
||||
mysql -uroot -pmysql
|
||||
|
||||
use `mifosplatform-tenants`;
|
||||
select * from schema_version;
|
||||
```
|
||||
|
||||
If the table does not exist, create the same using the script at https://gist.github.com/vishwasbabu/dc105b6a9450cff8ff1f
|
||||
|
||||
Next, check if the patch for "externalizing mysql connection properties" has been run (i.e if you are updating from 1.21 or a higher version of Mifos X)
|
||||
|
||||
````
|
||||
mysql -uroot -pmysql
|
||||
|
||||
use `mifosplatform-tenants`;
|
||||
select pool_initial_size from tenants;
|
||||
```
|
||||
|
||||
If the above query does **not** throw an error (Unknown column 'pool_initial_size'), *schema_version* needs to be updated with the details of this patch by executing the scripts below
|
||||
|
||||
```
|
||||
mysql -uroot -pmysql
|
||||
|
||||
use `mifosplatform-tenants`;
|
||||
INSERT INTO `schema_version` (`version_rank`, `installed_rank`, `version`, `description`, `type`, `script`, `checksum`, `installed_by`, `installed_on`, `execution_time`, `success`) VALUES
|
||||
(2, 2, '2', 'externalize-connection-properties', 'SQL', 'V2__externalize-connection-properties.sql', 210473669, 'root', '2014-10-12 22:13:51', 661, 1);
|
||||
```
|
||||
|
||||
#### 2.2.3 Load *mifostenant-default* schema with sample data (optional)
|
||||
Every release ships with sample data (offices, users, customers, loan products, savings products and a chart of accounts). The same can be restored by running the following command
|
||||
|
||||
@@ -134,7 +170,7 @@ The two ways to get up and running with mifos platform is:
|
||||
#### 2.3.1 Environment Variables Check
|
||||
|
||||
Check that the following environment variables exist:
|
||||
- JAVA_HOME ... should point to directory where a 1.6 JDK or JRE is on machine
|
||||
- JAVA_HOME ... should point to directory where a 1.7 JDK or JRE is on machine
|
||||
- CATALINA_HOME ... should point to a directory where a Tomcat 7 instance is installed
|
||||
|
||||
Check that the following is on your path:
|
||||
|
||||
+3658
-474
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -47,8 +47,9 @@ CREATE TABLE `schema_version` (
|
||||
|
||||
LOCK TABLES `schema_version` WRITE;
|
||||
/*!40000 ALTER TABLE `schema_version` DISABLE KEYS */;
|
||||
INSERT INTO `schema_version` VALUES (1,1,'1','mifos-platform-shared-tenants','SQL','/V1__mifos-platform-shared-tenants.sql',-486745552,'root','2013-04-05 09:33:11',50,1);
|
||||
/*!40000 ALTER TABLE `schema_version` ENABLE KEYS */;
|
||||
INSERT INTO `schema_version` (`version_rank`, `installed_rank`, `version`, `description`, `type`, `script`, `checksum`, `installed_by`, `installed_on`, `execution_time`, `success`) VALUES
|
||||
(1, 1, '1', 'mifos-platform-shared-tenants', 'SQL', 'V1__mifos-platform-shared-tenants.sql', -486745552, 'root', '2014-10-12 22:13:50', 896, 1),
|
||||
(2, 2, '2', 'externalize-connection-properties', 'SQL', 'V2__externalize-connection-properties.sql', 210473669, 'root', '2014-10-12 22:13:51', 661, 1);/*!40000 ALTER TABLE `schema_version` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
|
||||
@@ -346,6 +346,7 @@ CREATE TABLE `m_staff` (
|
||||
`firstname` varchar(50) DEFAULT NULL,
|
||||
`lastname` varchar(50) DEFAULT NULL,
|
||||
`display_name` varchar(100) NOT NULL,
|
||||
`joining_date` date,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `display_name` (`display_name`),
|
||||
KEY `FK_m_staff_m_office` (`office_id`),
|
||||
|
||||
@@ -10,29 +10,30 @@ buildscript {
|
||||
|
||||
dependencies {
|
||||
classpath 'org.gradle.api.plugins:gradle-tomcat-plugin:1.0',
|
||||
'nl.javadude.gradle.plugins:license-gradle-plugin:0.6.0',
|
||||
'org.zeroturnaround:gradle-jrebel-plugin:1.1.2'
|
||||
'nl.javadude.gradle.plugins:license-gradle-plugin:0.11.0',
|
||||
'org.zeroturnaround:gradle-jrebel-plugin:1.1.2',
|
||||
'org.springframework.boot:spring-boot-gradle-plugin:1.1.6.RELEASE' // also change springDataJpaVersion below
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'rebel'
|
||||
apply plugin: 'license'
|
||||
apply plugin: 'war'
|
||||
apply plugin: 'spring-boot'
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'idea'
|
||||
apply plugin: 'tomcat'
|
||||
apply plugin: 'project-report'
|
||||
|
||||
/* define the valid syntax level for source files */
|
||||
sourceCompatibility = JavaVersion.VERSION_1_6
|
||||
/* define binary compatiblity version */
|
||||
targetCompatibility = JavaVersion.VERSION_1_6
|
||||
sourceCompatibility = JavaVersion.VERSION_1_7
|
||||
/* define binary compatibility version */
|
||||
targetCompatibility = JavaVersion.VERSION_1_7
|
||||
|
||||
project.ext.springVersion = '3.2.5.RELEASE'
|
||||
project.ext.springSecurityVersion = '3.1.4.RELEASE'
|
||||
project.ext.hibernateCoreVersion = '4.1.9.Final'
|
||||
project.ext.springBootVersion = '1.1.6.RELEASE'
|
||||
project.ext.springVersion = '4.0.7.RELEASE'
|
||||
project.ext.jerseyVersion = '1.17'
|
||||
project.ext.springDataJpaVersion = '1.4.1.RELEASE'
|
||||
project.ext.springDataJpaVersion = '1.7.0.RELEASE' // also change spring-boot-gradle-plugin version above
|
||||
|
||||
project.ext.mysqlUser='root'
|
||||
project.ext.mysqlPassword='mysql'
|
||||
@@ -43,11 +44,13 @@ group = 'org.mifosplatform'
|
||||
repositories {
|
||||
jcenter()
|
||||
maven {
|
||||
url "http://repository.pentaho.org/artifactory/pentaho/"
|
||||
url "http://repository.pentaho.org/artifactory/pentaho/"
|
||||
}
|
||||
// mavenLocal() // useful for local dev using MariaDB4j SNAPSHOTs (not needed for real-world non-SNAPHOT builds)
|
||||
}
|
||||
|
||||
configurations {
|
||||
providedRuntime // needed for Spring Boot executable WAR
|
||||
providedCompile
|
||||
compile
|
||||
runtime
|
||||
@@ -55,31 +58,28 @@ configurations {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
def tomcatVersion = '7.0.47'
|
||||
def tomcatVersion = '7.0.54'
|
||||
tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
|
||||
"org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}"
|
||||
"org.apache.tomcat.embed:tomcat-embed-logging-log4j:${tomcatVersion}" // NOT tomcat-embed-logging-juli (http://stackoverflow.com/questions/23963049/classcircularityerror-java-util-logging-logrecord-running-gradle-webapp-with-ja)
|
||||
tomcat("org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}") {
|
||||
exclude group: 'org.eclipse.jdt.core.compiler', module: 'ecj'
|
||||
}
|
||||
tomcat "org.apache.tomcat:tomcat-dbcp:${tomcatVersion}"
|
||||
|
||||
providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
|
||||
|
||||
providedCompile(
|
||||
[group: 'javax.servlet', name: 'servlet-api', version: '2.5'],
|
||||
// [group: 'javax.servlet', name: 'servlet-api', version: '2.5'],
|
||||
)
|
||||
|
||||
compile(
|
||||
[group: 'org.springframework', name: 'spring-core', version: springVersion],
|
||||
[group: 'org.springframework', name: 'spring-aspects', version: springVersion],
|
||||
[group: 'org.springframework', name: 'spring-web', version: springVersion],
|
||||
[group: 'org.springframework', name: 'spring-test', version: springVersion],
|
||||
[group: 'org.springframework.security', name: 'spring-security-core', version: springSecurityVersion],
|
||||
[group: 'org.springframework.security', name: 'spring-security-web', version: springSecurityVersion],
|
||||
[group: 'org.springframework.security', name: 'spring-security-config', version: springSecurityVersion],
|
||||
[group: 'org.aspectj', name: 'aspectjrt', version: '1.7.0.RELEASE'],
|
||||
[group: 'ch.vorburger.mariaDB4j', name: 'mariaDB4j', version: '2.1.1'],
|
||||
|
||||
[group: 'org.hibernate', name: 'hibernate-core', version: hibernateCoreVersion],
|
||||
[group: 'org.hibernate', name: 'hibernate-entitymanager', version: hibernateCoreVersion],
|
||||
[group: 'org.hibernate.javax.persistence', name: 'hibernate-jpa-2.0-api', version: '1.0.1.Final'],
|
||||
[group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: springBootVersion],
|
||||
[group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: springBootVersion],
|
||||
[group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: springBootVersion],
|
||||
|
||||
[group: 'org.springframework', name: 'spring-context-support', version: springVersion],
|
||||
|
||||
[group: 'javax.ws.rs', name: 'jsr311-api', version: '1.1.1'],
|
||||
[group: 'com.sun.jersey', name: 'jersey-core', version: jerseyVersion],
|
||||
@@ -89,24 +89,23 @@ dependencies {
|
||||
[group: 'com.sun.jersey.contribs', name: 'jersey-spring', version: jerseyVersion],
|
||||
[group: 'com.sun.jersey.contribs', name: 'jersey-multipart', version: jerseyVersion],
|
||||
|
||||
[group: 'com.squareup.retrofit', name: 'retrofit', version: '1.6.1'],
|
||||
[group: 'com.squareup.okhttp', name: 'okhttp', version: '2.0.0'],
|
||||
[group: 'com.squareup.okhttp', name: 'okhttp-urlconnection', version: '2.0.0'],
|
||||
|
||||
|
||||
[group: 'com.google.code.gson', name: 'gson', version: '2.2.4'],
|
||||
[group: 'com.google.guava', name: 'guava', version: '15.0'],
|
||||
|
||||
[group: 'org.springframework.data', name: 'spring-data-jpa', version: springDataJpaVersion],
|
||||
|
||||
[group: 'joda-time', name: 'joda-time', version: '2.3'],
|
||||
[group: 'joda-time', name: 'joda-time', version: '2.4'],
|
||||
[group: 'net.sourceforge.javacsv', name: 'javacsv', version: '2.0'],
|
||||
[group: 'org.apache.commons', name: 'commons-email', version: '1.3.1'],
|
||||
[group: 'org.apache.commons', name: 'commons-lang3', version: '3.1'],
|
||||
[group: 'org.apache.commons', name: 'commons-email', version: '1.3.3'],
|
||||
[group: 'org.apache.commons', name: 'commons-lang3', version: '3.3.2'],
|
||||
|
||||
[group: 'org.slf4j', name: 'slf4j-api', version: '1.7.5'],
|
||||
[group: 'org.slf4j', name: 'jcl-over-slf4j', version: '1.7.5'],
|
||||
|
||||
[group: 'ch.qos.logback', name: 'logback-core', version: '1.0.13'],
|
||||
[group: 'ch.qos.logback', name: 'logback-classic', version: '1.0.13'],
|
||||
// no slf4j & logback here (anymore), as spring-boot-starter-logging already brings this now, better assembled (log4j-over-slf4j was originally forgotten here)
|
||||
|
||||
[group: 'mysql', name: 'mysql-connector-java', version: '5.1.27'],
|
||||
[group: 'org.apache.tomcat', name: 'tomcat-jdbc', version: '7.0.47'],
|
||||
[group: 'org.apache.tomcat', name: 'tomcat-jdbc', version: tomcatVersion],
|
||||
|
||||
[group: 'pentaho-reporting-engine', name: 'pentaho-reporting-engine-classic-core', version: '3.9.1.1'],
|
||||
[group: 'pentaho-reporting-engine', name: 'pentaho-reporting-engine-classic-extensions', version: '3.9.1-GA'],
|
||||
@@ -132,17 +131,22 @@ dependencies {
|
||||
[group: 'com.lowagie', name: 'itext', version: '2.1.7'],
|
||||
[group: 'com.lowagie', name: 'itext-rtf', version: '2.1.7'],
|
||||
[group: 'org.mnode.ical4j', name: 'ical4j', version: '1.0.4'],
|
||||
[group: 'com.googlecode.flyway', name: 'flyway-maven-plugin', version: '2.1.1'],
|
||||
[group: 'com.googlecode.flyway', name: 'flyway-core', version: '2.1.1'],
|
||||
[group: 'org.quartz-scheduler', name: 'quartz', version: '2.1.7'],
|
||||
[group: 'com.amazonaws', name: 'aws-java-sdk', version: '1.2.1'],
|
||||
[group: 'net.sf.ehcache', name: 'ehcache', version: '2.7.2'],
|
||||
[group: 'com.github.spullara.mustache.java', name: 'compiler', version: '0.8.12']
|
||||
)
|
||||
[group: 'com.github.spullara.mustache.java', name: 'compiler', version: '0.8.12'],
|
||||
[group: 'com.jayway.jsonpath', name: 'json-path', version: '0.9.1'],
|
||||
|
||||
testCompile 'junit:junit:4.10',
|
||||
'junit:junit-dep:4.10',
|
||||
'org.mockito:mockito-all:1.9.5',
|
||||
'com.jayway.restassured:rest-assured:1.7.2'
|
||||
// Although Mifos (at the time of writing) doesn't have any compile time dep. on this,
|
||||
// it's useful to have this for the Spring Boot TestRestTemplate http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-features-rest-templates-test-utility
|
||||
[group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.3.5']
|
||||
)
|
||||
testCompile 'junit:junit:4.11',
|
||||
'junit:junit-dep:4.11',
|
||||
'org.mockito:mockito-core:1.9.5',
|
||||
'com.jayway.restassured:rest-assured:2.3.3',
|
||||
[group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: springBootVersion]
|
||||
|
||||
}
|
||||
|
||||
@@ -173,7 +177,7 @@ task dist(type:Zip){
|
||||
include '*.sql'
|
||||
into('database')
|
||||
}
|
||||
from('../mifosng-db/migrations') {
|
||||
from('src/main/resources/sql/migrations') {
|
||||
fileMode = 0755
|
||||
include '**/*'
|
||||
into('database/migrations')
|
||||
@@ -197,13 +201,12 @@ task deployPentahoReports() {
|
||||
|
||||
war {
|
||||
it.dependsOn deployPentahoReports
|
||||
from ('../mifosng-db/migrations/core_db') {
|
||||
into "WEB-INF/classes/sql"
|
||||
}
|
||||
war.finalizedBy(bootRepackage)
|
||||
}
|
||||
|
||||
license {
|
||||
header rootProject.file('../LICENSE.md')
|
||||
excludes(["**/*.mustache", "**/*.sql", "**/package-info.java", "**/keystore.jks"])
|
||||
strictCheck true
|
||||
}
|
||||
|
||||
@@ -222,11 +225,14 @@ tomcatRunWar {
|
||||
stopPort = 8081
|
||||
stopKey= 'stopKey'
|
||||
enableSSL = true
|
||||
keystoreFile = file('../keystore.jks')
|
||||
keystoreFile = file('src/main/resources/keystore.jks')
|
||||
keystorePass = 'openmf'
|
||||
configFile = file('src/test/resources/META-INF/context.xml')
|
||||
}
|
||||
|
||||
/* http://stackoverflow.com/questions/19653311/jpa-repository-works-in-idea-and-production-but-not-in-gradle */
|
||||
sourceSets.main.output.resourcesDir = sourceSets.main.output.classesDir
|
||||
sourceSets.test.output.resourcesDir = sourceSets.test.output.classesDir
|
||||
|
||||
sourceSets {
|
||||
integrationTest {
|
||||
@@ -296,7 +302,7 @@ buildscript {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.github.ben-manes:gradle-flyway-plugin:0.2'
|
||||
classpath "org.flywaydb:flyway-gradle-plugin:3.0" // version upgraded during Spring Boot & MariaDB4j work, as prev. used v0.2 didn't work well after *.sql moved from mifosng-db to mifosng-provider/src/main/resources (new version also has clearer errors, e.g. in case of missing DB)
|
||||
classpath 'mysql:mysql-connector-java:5.1.22'
|
||||
}
|
||||
}
|
||||
@@ -306,15 +312,12 @@ flyway {
|
||||
url = "jdbc:mysql://localhost:3306/mifostenant-default"
|
||||
user = mysqlUser
|
||||
password = mysqlPassword
|
||||
|
||||
def filePath = "filesystem:$projectDir" + System.properties['file.separator'] + '..' + System.properties['file.separator'] + 'mifosng-db' + System.properties['file.separator'] + 'migrations'
|
||||
locations = [filePath]
|
||||
}
|
||||
|
||||
task migrateTenantDB<<{
|
||||
description="Migrates a Tenant DB. Optionally can pass dbName. Defaults to 'mifostenant-default' (Example: -PdbName=someTenantDBname)"
|
||||
|
||||
def filePath = "filesystem:$projectDir" + System.properties['file.separator'] + '..' + System.properties['file.separator'] + 'mifosng-db' + System.properties['file.separator'] + 'migrations/core_db'
|
||||
def filePath = "filesystem:$projectDir" + '/src/main/resources/sql/migrations/core_db'
|
||||
def tenantDbName = 'mifostenant-default';
|
||||
if (rootProject.hasProperty("dbName")) {
|
||||
tenantDbName = rootProject.getProperty("dbName")
|
||||
@@ -329,7 +332,7 @@ task migrateTenantDB<<{
|
||||
task showTenantDBInfo<<{
|
||||
description="Shows the migration info for a Tenant DB. Optionally can pass dbName. Defaults to 'mifostenant-default' (Example: -PdbName=someTenantDBname)"
|
||||
|
||||
def filePath = "filesystem:$projectDir" + System.properties['file.separator'] + '..' + System.properties['file.separator'] + 'mifosng-db' + System.properties['file.separator'] + 'migrations/core_db'
|
||||
def filePath = "filesystem:$projectDir" + '/src/main/resources/sql/migrations/core_db'
|
||||
def tenantDbName = 'mifostenant-default';
|
||||
if (rootProject.hasProperty("dbName")) {
|
||||
tenantDbName = rootProject.getProperty("dbName")
|
||||
@@ -344,7 +347,7 @@ task showTenantDBInfo<<{
|
||||
task migrateTenantListDB<<{
|
||||
description="Migrates a Tenant List DB. Optionally can pass dbName. Defaults to 'mifosplatform-tenants' (Example: -PdbName=someDBname)"
|
||||
|
||||
def filePath = "filesystem:$projectDir" + System.properties['file.separator'] + '..' + System.properties['file.separator'] + 'mifosng-db' + System.properties['file.separator'] + 'migrations/list_db'
|
||||
def filePath = "filesystem:$projectDir" + '/src/main/resources/sql/migrations/list_db'
|
||||
def tenantsDbName = 'mifosplatform-tenants';
|
||||
if (rootProject.hasProperty("dbName")) {
|
||||
tenantsDbName = rootProject.getProperty("dbName")
|
||||
@@ -359,7 +362,7 @@ task migrateTenantListDB<<{
|
||||
task showTenantListDBInfo<<{
|
||||
description="Shows the migration info for a List DB. Optionally can pass dbName. Defaults to 'mifosplatform-tenants' (Example: -PdbName=someDBname)"
|
||||
|
||||
def filePath = "filesystem:$projectDir" + System.properties['file.separator'] + '..' + System.properties['file.separator'] + 'mifosng-db' + System.properties['file.separator'] + 'migrations/list_db'
|
||||
def filePath = "filesystem:$projectDir" + '/src/main/resources/sql/migrations/list_db'
|
||||
def tenantsDbName = 'mifosplatform-tenants';
|
||||
if (rootProject.hasProperty("dbName")) {
|
||||
tenantsDbName = rootProject.getProperty("dbName")
|
||||
@@ -373,7 +376,7 @@ task showTenantListDBInfo<<{
|
||||
task repairTenantDB<<{
|
||||
description="repair migrate"
|
||||
|
||||
def filePath = "filesystem:$projectDir" + System.properties['file.separator'] + '..' + System.properties['file.separator'] + 'mifosng-db' + System.properties['file.separator'] + 'migrations/list_db'
|
||||
def filePath = "filesystem:$projectDir" + '/src/main/resources/sql/migrations/list_db'
|
||||
def tenantsDbName = 'mifosplatform-tenants';
|
||||
if (rootProject.hasProperty("dbName")) {
|
||||
tenantsDbName = rootProject.getProperty("dbName")
|
||||
@@ -401,3 +404,10 @@ def qualifyVersionIfNecessary(version) {
|
||||
}
|
||||
return version
|
||||
}
|
||||
|
||||
springBoot {
|
||||
mainClass = 'org.mifosplatform.ServerWithMariaDB4jApplication'
|
||||
}
|
||||
bootRepackage {
|
||||
mainClass = 'org.mifosplatform.ServerWithMariaDB4jApplication'
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
releaseVersion=1.22.0.RELEASE
|
||||
releaseVersion=1.25.1.RELEASE
|
||||
|
||||
|
||||
|
||||
|
||||
+60
-63
@@ -1,13 +1,16 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -17,10 +20,10 @@ import org.mifosplatform.integrationtests.common.OfficeHelper;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
import org.mifosplatform.integrationtests.common.accounting.Account;
|
||||
import org.mifosplatform.integrationtests.common.accounting.AccountHelper;
|
||||
import org.mifosplatform.integrationtests.common.accounting.FinancialActivityAccountHelper;
|
||||
import org.mifosplatform.integrationtests.common.accounting.JournalEntry;
|
||||
import org.mifosplatform.integrationtests.common.accounting.JournalEntryHelper;
|
||||
import org.mifosplatform.integrationtests.common.accounting.OfficeAccountMappingHelper;
|
||||
import org.mifosplatform.integrationtests.common.charges.ChargesHelper;
|
||||
import org.mifosplatform.integrationtests.common.accounting.Account.AccountType;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanApplicationTestBuilder;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanProductTestBuilder;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanStatusChecker;
|
||||
@@ -66,6 +69,10 @@ public class AccountTransferTest {
|
||||
Float TRANSFER_AMOUNT = new Float(ACCOUNT_TRANSFER_AMOUNT);
|
||||
Float TRANSFER_AMOUNT_ADJUST = new Float(ACCOUNT_TRANSFER_AMOUNT_ADJUST);
|
||||
|
||||
private FinancialActivityAccountHelper financialActivityAccountHelper;
|
||||
private Integer financialActivityAccountId;
|
||||
private Account liabilityTransferAccount;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
Utils.initializeRESTAssured();
|
||||
@@ -74,6 +81,42 @@ public class AccountTransferTest {
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec);
|
||||
this.journalEntryHelper = new JournalEntryHelper(this.requestSpec, this.responseSpec);
|
||||
this.financialActivityAccountHelper = new FinancialActivityAccountHelper(this.requestSpec);
|
||||
|
||||
List<HashMap> financialActivities = this.financialActivityAccountHelper.getAllFinancialActivityAccounts(this.responseSpec);
|
||||
if (financialActivities.isEmpty()) {
|
||||
/** Setup liability transfer account **/
|
||||
/** Create a Liability and an Asset Transfer Account **/
|
||||
liabilityTransferAccount = accountHelper.createLiabilityAccount();
|
||||
Assert.assertNotNull(liabilityTransferAccount);
|
||||
|
||||
/*** Create A Financial Activity to Account Mapping **/
|
||||
financialActivityAccountId = (Integer) financialActivityAccountHelper.createFinancialActivityAccount(
|
||||
FinancialActivityAccountsTest.liabilityTransferFinancialActivityId, liabilityTransferAccount.getAccountID(),
|
||||
responseSpec, CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
Assert.assertNotNull(financialActivityAccountId);
|
||||
} else {
|
||||
for (HashMap financialActivity : financialActivities) {
|
||||
HashMap financialActivityData = (HashMap) financialActivity.get("financialActivityData");
|
||||
if (financialActivityData.get("id").equals(FinancialActivityAccountsTest.liabilityTransferFinancialActivityId)) {
|
||||
HashMap glAccountData = (HashMap) financialActivity.get("glAccountData");
|
||||
liabilityTransferAccount = new Account((Integer) glAccountData.get("id"), AccountType.LIABILITY);
|
||||
financialActivityAccountId = (Integer) financialActivity.get("id");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the Liability transfer account
|
||||
*/
|
||||
@After
|
||||
public void tearDown() {
|
||||
Integer deletedFinancialActivityAccountId = financialActivityAccountHelper.deleteFinancialActivityAccount(
|
||||
financialActivityAccountId, responseSpec, CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
Assert.assertNotNull(deletedFinancialActivityAccountId);
|
||||
Assert.assertEquals(financialActivityAccountId, deletedFinancialActivityAccountId);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -95,15 +138,6 @@ public class AccountTransferTest {
|
||||
String.valueOf(toOfficeId));
|
||||
Assert.assertNotNull(toClientID);
|
||||
|
||||
Account toTransferAccount = accountHelper.createLiabilityAccount();
|
||||
Assert.assertNotNull(toTransferAccount);
|
||||
|
||||
OfficeAccountMappingHelper accountMappingHelper = new OfficeAccountMappingHelper(this.requestSpec,
|
||||
new ResponseSpecBuilder().build());
|
||||
Integer toTransferAccountMappingId = (Integer) accountMappingHelper.createOfficeAccountMapping(toOfficeId,
|
||||
toTransferAccount.getAccountID(), CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
Assert.assertNotNull(toTransferAccountMappingId);
|
||||
|
||||
final Integer toSavingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE, assetAccount,
|
||||
incomeAccount, expenseAccount, liabilityAccount);
|
||||
Assert.assertNotNull(toSavingsProductID);
|
||||
@@ -131,13 +165,6 @@ public class AccountTransferTest {
|
||||
String.valueOf(fromOfficeId));
|
||||
Assert.assertNotNull(fromClientID);
|
||||
|
||||
Account fromTransferAccount = accountHelper.createLiabilityAccount();
|
||||
Assert.assertNotNull(fromTransferAccount);
|
||||
|
||||
Integer fromTransferAccountMappingId = (Integer) accountMappingHelper.createOfficeAccountMapping(fromOfficeId,
|
||||
fromTransferAccount.getAccountID(), CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
Assert.assertNotNull(fromTransferAccountMappingId);
|
||||
|
||||
final Integer fromSavingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
|
||||
assetAccount, incomeAccount, expenseAccount, liabilityAccount);
|
||||
Assert.assertNotNull(fromSavingsProductID);
|
||||
@@ -178,10 +205,10 @@ public class AccountTransferTest {
|
||||
final JournalEntry[] office2LiabilityEntries = { new JournalEntry(new Float(ACCOUNT_TRANSFER_AMOUNT),
|
||||
JournalEntry.TransactionType.DEBIT) };
|
||||
|
||||
this.journalEntryHelper.checkJournalEntryForAssetAccount(fromTransferAccount, AccountTransferHelper.ACCOUNT_TRANSFER_DATE,
|
||||
office1LiabilityEntries);
|
||||
this.journalEntryHelper.checkJournalEntryForAssetAccount(toTransferAccount, AccountTransferHelper.ACCOUNT_TRANSFER_DATE,
|
||||
office2LiabilityEntries);
|
||||
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(fromOfficeId, liabilityTransferAccount,
|
||||
AccountTransferHelper.ACCOUNT_TRANSFER_DATE, office1LiabilityEntries);
|
||||
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(toOfficeId, liabilityTransferAccount,
|
||||
AccountTransferHelper.ACCOUNT_TRANSFER_DATE, office2LiabilityEntries);
|
||||
|
||||
}
|
||||
|
||||
@@ -213,12 +240,6 @@ public class AccountTransferTest {
|
||||
Account toTransferAccount = accountHelper.createLiabilityAccount();
|
||||
Assert.assertNotNull(toTransferAccount);
|
||||
|
||||
OfficeAccountMappingHelper accountMappingHelper = new OfficeAccountMappingHelper(this.requestSpec,
|
||||
new ResponseSpecBuilder().build());
|
||||
Integer toTransferAccountMappingId = (Integer) accountMappingHelper.createOfficeAccountMapping(toOfficeId,
|
||||
toTransferAccount.getAccountID(), CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
Assert.assertNotNull(toTransferAccountMappingId);
|
||||
|
||||
final Integer toLoanProductID = createLoanProduct(loanAssetAccount, loanIncomeAccount, loanExpenseAccount, overpaymentAccount);
|
||||
Assert.assertNotNull(toLoanProductID);
|
||||
|
||||
@@ -242,13 +263,6 @@ public class AccountTransferTest {
|
||||
String.valueOf(fromOfficeId));
|
||||
Assert.assertNotNull(fromClientID);
|
||||
|
||||
Account fromTransferAccount = accountHelper.createLiabilityAccount();
|
||||
Assert.assertNotNull(fromTransferAccount);
|
||||
|
||||
Integer fromTransferAccountMappingId = (Integer) accountMappingHelper.createOfficeAccountMapping(fromOfficeId,
|
||||
fromTransferAccount.getAccountID(), CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
Assert.assertNotNull(fromTransferAccountMappingId);
|
||||
|
||||
final Integer fromSavingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
|
||||
assetAccount, incomeAccount, expenseAccount, liabilityAccount);
|
||||
Assert.assertNotNull(fromSavingsProductID);
|
||||
@@ -288,10 +302,10 @@ public class AccountTransferTest {
|
||||
final JournalEntry[] office2LiabilityEntries = { new JournalEntry(new Float(ACCOUNT_TRANSFER_AMOUNT_ADJUST),
|
||||
JournalEntry.TransactionType.DEBIT) };
|
||||
|
||||
this.journalEntryHelper.checkJournalEntryForAssetAccount(fromTransferAccount, AccountTransferHelper.ACCOUNT_TRANSFER_DATE,
|
||||
office1LiabilityEntries);
|
||||
this.journalEntryHelper.checkJournalEntryForAssetAccount(toTransferAccount, AccountTransferHelper.ACCOUNT_TRANSFER_DATE,
|
||||
office2LiabilityEntries);
|
||||
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(fromOfficeId, liabilityTransferAccount,
|
||||
AccountTransferHelper.ACCOUNT_TRANSFER_DATE, office1LiabilityEntries);
|
||||
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(toOfficeId, liabilityTransferAccount,
|
||||
AccountTransferHelper.ACCOUNT_TRANSFER_DATE, office2LiabilityEntries);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -319,15 +333,6 @@ public class AccountTransferTest {
|
||||
String.valueOf(toOfficeId));
|
||||
Assert.assertNotNull(toClientID);
|
||||
|
||||
Account toTransferAccount = accountHelper.createLiabilityAccount();
|
||||
Assert.assertNotNull(toTransferAccount);
|
||||
|
||||
OfficeAccountMappingHelper accountMappingHelper = new OfficeAccountMappingHelper(this.requestSpec,
|
||||
new ResponseSpecBuilder().build());
|
||||
Integer toTransferAccountMappingId = (Integer) accountMappingHelper.createOfficeAccountMapping(toOfficeId,
|
||||
toTransferAccount.getAccountID(), CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
Assert.assertNotNull(toTransferAccountMappingId);
|
||||
|
||||
final Integer toSavingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE, assetAccount,
|
||||
incomeAccount, expenseAccount, liabilityAccount);
|
||||
Assert.assertNotNull(toSavingsProductID);
|
||||
@@ -353,13 +358,6 @@ public class AccountTransferTest {
|
||||
String.valueOf(fromOfficeId));
|
||||
Assert.assertNotNull(fromClientID);
|
||||
|
||||
Account fromTransferAccount = accountHelper.createLiabilityAccount();
|
||||
Assert.assertNotNull(fromTransferAccount);
|
||||
|
||||
Integer fromTransferAccountMappingId = (Integer) accountMappingHelper.createOfficeAccountMapping(fromOfficeId,
|
||||
fromTransferAccount.getAccountID(), CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
Assert.assertNotNull(fromTransferAccountMappingId);
|
||||
|
||||
final Integer loanProductID = createLoanProduct(loanAssetAccount, loanIncomeAccount, loanExpenseAccount, overpaymentAccount);
|
||||
Assert.assertNotNull(loanProductID);
|
||||
|
||||
@@ -375,7 +373,6 @@ public class AccountTransferTest {
|
||||
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSAL_DATE, loanID);
|
||||
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
|
||||
|
||||
|
||||
final Integer fromSavingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
|
||||
assetAccount, incomeAccount, expenseAccount, liabilityAccount);
|
||||
Assert.assertNotNull(fromSavingsProductID);
|
||||
@@ -426,10 +423,10 @@ public class AccountTransferTest {
|
||||
final JournalEntry[] office2LiabilityEntries = { new JournalEntry(new Float(ACCOUNT_TRANSFER_AMOUNT_ADJUST),
|
||||
JournalEntry.TransactionType.DEBIT) };
|
||||
|
||||
this.journalEntryHelper.checkJournalEntryForAssetAccount(fromTransferAccount, AccountTransferHelper.ACCOUNT_TRANSFER_DATE,
|
||||
office1LiabilityEntries);
|
||||
this.journalEntryHelper.checkJournalEntryForAssetAccount(toTransferAccount, AccountTransferHelper.ACCOUNT_TRANSFER_DATE,
|
||||
office2LiabilityEntries);
|
||||
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(fromOfficeId, liabilityTransferAccount,
|
||||
AccountTransferHelper.ACCOUNT_TRANSFER_DATE, office1LiabilityEntries);
|
||||
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(toOfficeId, liabilityTransferAccount,
|
||||
AccountTransferHelper.ACCOUNT_TRANSFER_DATE, office2LiabilityEntries);
|
||||
|
||||
}
|
||||
|
||||
|
||||
+274
-37
@@ -1,14 +1,24 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.joda.time.Days;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
@@ -21,6 +31,7 @@ import org.mifosplatform.integrationtests.common.accounting.Account;
|
||||
import org.mifosplatform.integrationtests.common.accounting.AccountHelper;
|
||||
import org.mifosplatform.integrationtests.common.accounting.JournalEntry;
|
||||
import org.mifosplatform.integrationtests.common.accounting.JournalEntryHelper;
|
||||
import org.mifosplatform.integrationtests.common.accounting.PeriodicAccrualAccountingHelper;
|
||||
import org.mifosplatform.integrationtests.common.charges.ChargesHelper;
|
||||
import org.mifosplatform.integrationtests.common.fixeddeposit.FixedDepositAccountHelper;
|
||||
import org.mifosplatform.integrationtests.common.fixeddeposit.FixedDepositAccountStatusChecker;
|
||||
@@ -83,6 +94,7 @@ public class AccountingScenarioIntegrationTest {
|
||||
private RecurringDepositProductHelper recurringDepositProductHelper;
|
||||
private RecurringDepositAccountHelper recurringDepositAccountHelper;
|
||||
private SchedulerJobHelper schedulerJobHelper;
|
||||
private PeriodicAccrualAccountingHelper periodicAccrualAccountingHelper;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
@@ -95,6 +107,7 @@ public class AccountingScenarioIntegrationTest {
|
||||
this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec);
|
||||
this.journalEntryHelper = new JournalEntryHelper(this.requestSpec, this.responseSpec);
|
||||
this.schedulerJobHelper = new SchedulerJobHelper(this.requestSpec, this.responseSpec);
|
||||
this.periodicAccrualAccountingHelper = new PeriodicAccrualAccountingHelper(this.requestSpec, this.responseSpec);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -325,7 +338,7 @@ public class AccountingScenarioIntegrationTest {
|
||||
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||
this.fixedDepositAccountHelper = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
|
||||
DateFormat currentDateFormat = new SimpleDateFormat("dd");
|
||||
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
@@ -407,7 +420,7 @@ public class AccountingScenarioIntegrationTest {
|
||||
final Account expenseAccount = this.accountHelper.createExpenseAccount();
|
||||
final Account liabilityAccount = this.accountHelper.createLiabilityAccount();
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
|
||||
DateFormat currentDateFormat = new SimpleDateFormat("dd");
|
||||
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
@@ -422,7 +435,7 @@ public class AccountingScenarioIntegrationTest {
|
||||
final String APPROVED_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String ACTIVATION_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String EXPECTED_FIRST_DEPOSIT_ON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
|
||||
|
||||
Integer currentDate = new Integer(currentDateFormat.format(todaysDate.getTime()));
|
||||
Integer daysInMonth = todaysDate.getActualMaximum(Calendar.DATE);
|
||||
Integer numberOfDaysLeft = (daysInMonth - currentDate) + 1;
|
||||
@@ -432,7 +445,8 @@ public class AccountingScenarioIntegrationTest {
|
||||
Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientId);
|
||||
|
||||
Integer recurringDepositProductId = createRecurringDepositProduct(VALID_FROM, VALID_TO, assetAccount, liabilityAccount, incomeAccount, expenseAccount);
|
||||
Integer recurringDepositProductId = createRecurringDepositProduct(VALID_FROM, VALID_TO, assetAccount, liabilityAccount,
|
||||
incomeAccount, expenseAccount);
|
||||
Assert.assertNotNull(recurringDepositProductId);
|
||||
|
||||
Integer recurringDepositAccountId = applyForRecurringDepositApplication(clientId.toString(), recurringDepositProductId.toString(),
|
||||
@@ -450,23 +464,26 @@ public class AccountingScenarioIntegrationTest {
|
||||
recurringDepositAccountStatusHashMap = this.recurringDepositAccountHelper.activateRecurringDeposit(recurringDepositAccountId,
|
||||
ACTIVATION_DATE);
|
||||
RecurringDepositAccountStatusChecker.verifyRecurringDepositIsActive(recurringDepositAccountStatusHashMap);
|
||||
|
||||
HashMap recurringDepositAccountData = this.recurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec, this.responseSpec, recurringDepositAccountId);
|
||||
|
||||
HashMap recurringDepositAccountData = this.recurringDepositAccountHelper.getRecurringDepositAccountById(this.requestSpec,
|
||||
this.responseSpec, recurringDepositAccountId);
|
||||
Float depositAmount = (Float) recurringDepositAccountData.get("mandatoryRecommendedDepositAmount");
|
||||
|
||||
Integer depositTransactionId = this.recurringDepositAccountHelper.depositToRecurringDepositAccount(recurringDepositAccountId, depositAmount, EXPECTED_FIRST_DEPOSIT_ON_DATE);
|
||||
|
||||
Integer depositTransactionId = this.recurringDepositAccountHelper.depositToRecurringDepositAccount(recurringDepositAccountId,
|
||||
depositAmount, EXPECTED_FIRST_DEPOSIT_ON_DATE);
|
||||
Assert.assertNotNull(depositTransactionId);
|
||||
|
||||
// Checking initial Journal entries after Activation.
|
||||
|
||||
// Checking initial Journal entries after Activation.
|
||||
final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(depositAmount, JournalEntry.TransactionType.DEBIT) };
|
||||
final JournalEntry[] liablilityAccountInitialEntry = { new JournalEntry(depositAmount, JournalEntry.TransactionType.CREDIT) };
|
||||
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, EXPECTED_FIRST_DEPOSIT_ON_DATE, assetAccountInitialEntry);
|
||||
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, EXPECTED_FIRST_DEPOSIT_ON_DATE, liablilityAccountInitialEntry);
|
||||
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(liabilityAccount, EXPECTED_FIRST_DEPOSIT_ON_DATE,
|
||||
liablilityAccountInitialEntry);
|
||||
|
||||
Integer interestPostingTransactionId = this.recurringDepositAccountHelper
|
||||
.postInterestForRecurringDeposit(recurringDepositAccountId);
|
||||
Assert.assertNotNull(interestPostingTransactionId);
|
||||
|
||||
|
||||
HashMap accountSummary = this.recurringDepositAccountHelper.getRecurringDepositSummary(recurringDepositAccountId);
|
||||
Float totalInterestPosted = (Float) accountSummary.get("totalInterestPosted");
|
||||
|
||||
@@ -508,8 +525,7 @@ public class AccountingScenarioIntegrationTest {
|
||||
System.out.println("------------------------------CREATING NEW RECURRING DEPOSIT PRODUCT ---------------------------------------");
|
||||
RecurringDepositProductHelper recurringDepositProductHelper = new RecurringDepositProductHelper(this.requestSpec, this.responseSpec);
|
||||
final String recurringDepositProductJSON = recurringDepositProductHelper //
|
||||
.withAccountingRuleAsCashBased(accounts)
|
||||
.build(validFrom, validTo);
|
||||
.withAccountingRuleAsCashBased(accounts).build(validFrom, validTo);
|
||||
return RecurringDepositProductHelper.createRecurringDepositProduct(recurringDepositProductJSON, requestSpec, responseSpec);
|
||||
}
|
||||
|
||||
@@ -557,7 +573,7 @@ public class AccountingScenarioIntegrationTest {
|
||||
|
||||
final String jobName = "Add Accrual Transactions";
|
||||
try {
|
||||
this.schedulerJobHelper.excuteJob(jobName);
|
||||
this.schedulerJobHelper.executeJob(jobName);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -568,7 +584,8 @@ public class AccountingScenarioIntegrationTest {
|
||||
final float FIRST_PRINCIPAL = 2000.0f;
|
||||
final float FEE_PORTION = 0.0f;
|
||||
final float PENALTY_PORTION = 0.0f;
|
||||
this.loanTransactionHelper.checkAccrualTransactionForRepayment(getDateAsLocalDate(this.REPAYMENT_DATE[1]), FIRST_INTEREST, FEE_PORTION, PENALTY_PORTION, loanID);
|
||||
this.loanTransactionHelper.checkAccrualTransactionForRepayment(getDateAsLocalDate(this.REPAYMENT_DATE[1]), FIRST_INTEREST,
|
||||
FEE_PORTION, PENALTY_PORTION, loanID);
|
||||
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[1], this.REPAYMENT_AMOUNT[1], loanID);
|
||||
float expected_value = this.LP_PRINCIPAL - PRINCIPAL_VALUE_FOR_EACH_PERIOD;
|
||||
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(1, expected_value, loanID);
|
||||
@@ -584,19 +601,23 @@ public class AccountingScenarioIntegrationTest {
|
||||
final float SECOND_AND_THIRD_INTEREST = 400.0f;
|
||||
final float SECOND_PRINCIPAL = this.REPAYMENT_AMOUNT[2] - SECOND_AND_THIRD_INTEREST;
|
||||
expected_value = expected_value - PRINCIPAL_VALUE_FOR_EACH_PERIOD;
|
||||
this.loanTransactionHelper.checkAccrualTransactionForRepayment(getDateAsLocalDate(this.REPAYMENT_DATE[2]), FIRST_INTEREST, FEE_PORTION, PENALTY_PORTION, loanID);
|
||||
this.loanTransactionHelper.checkAccrualTransactionForRepayment(getDateAsLocalDate(this.REPAYMENT_DATE[3]), FIRST_INTEREST, FEE_PORTION, PENALTY_PORTION, loanID);
|
||||
this.loanTransactionHelper.checkAccrualTransactionForRepayment(getDateAsLocalDate(this.REPAYMENT_DATE[2]), FIRST_INTEREST,
|
||||
FEE_PORTION, PENALTY_PORTION, loanID);
|
||||
this.loanTransactionHelper.checkAccrualTransactionForRepayment(getDateAsLocalDate(this.REPAYMENT_DATE[3]), FIRST_INTEREST,
|
||||
FEE_PORTION, PENALTY_PORTION, loanID);
|
||||
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(2, expected_value, loanID);
|
||||
final JournalEntry[] assetAccountSecondEntry = { new JournalEntry(this.REPAYMENT_AMOUNT[2], JournalEntry.TransactionType.DEBIT),
|
||||
new JournalEntry(SECOND_AND_THIRD_INTEREST, JournalEntry.TransactionType.CREDIT),
|
||||
new JournalEntry(SECOND_PRINCIPAL, JournalEntry.TransactionType.CREDIT), };
|
||||
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[2], assetAccountSecondEntry);
|
||||
System.out.println("Repayment 2 Done ......");
|
||||
|
||||
|
||||
// WAIVE INTEREST
|
||||
System.out.println("Waive Interest ......");
|
||||
this.loanTransactionHelper.checkAccrualTransactionForRepayment(getDateAsLocalDate(this.REPAYMENT_DATE[4]), FIRST_INTEREST, FEE_PORTION, PENALTY_PORTION, loanID);
|
||||
this.loanTransactionHelper.checkAccrualTransactionForRepayment(getDateAsLocalDate(this.REPAYMENT_DATE[5]), FIRST_INTEREST, FEE_PORTION, PENALTY_PORTION, loanID);
|
||||
this.loanTransactionHelper.checkAccrualTransactionForRepayment(getDateAsLocalDate(this.REPAYMENT_DATE[4]), FIRST_INTEREST,
|
||||
FEE_PORTION, PENALTY_PORTION, loanID);
|
||||
this.loanTransactionHelper.checkAccrualTransactionForRepayment(getDateAsLocalDate(this.REPAYMENT_DATE[5]), FIRST_INTEREST,
|
||||
FEE_PORTION, PENALTY_PORTION, loanID);
|
||||
this.loanTransactionHelper.waiveInterest(this.REPAYMENT_DATE[4], this.AMOUNT_TO_BE_WAIVE.toString(), loanID);
|
||||
|
||||
final JournalEntry waivedEntry = new JournalEntry(this.AMOUNT_TO_BE_WAIVE, JournalEntry.TransactionType.CREDIT);
|
||||
@@ -605,7 +626,7 @@ public class AccountingScenarioIntegrationTest {
|
||||
final JournalEntry expenseJournalEntry = new JournalEntry(this.AMOUNT_TO_BE_WAIVE, JournalEntry.TransactionType.DEBIT);
|
||||
this.journalEntryHelper.checkJournalEntryForExpenseAccount(expenseAccount, this.REPAYMENT_DATE[4], expenseJournalEntry);
|
||||
System.out.println("Waive Interest Done......");
|
||||
|
||||
|
||||
// REPAYMENT 3
|
||||
System.out.println("Repayment 3 ......");
|
||||
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[3], this.REPAYMENT_AMOUNT[3], loanID);
|
||||
@@ -637,16 +658,232 @@ public class AccountingScenarioIntegrationTest {
|
||||
System.out.println("Repayment 5 Done ......");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkPeriodicAccrualAccountingTillCurrentDateFlow() {
|
||||
final Account assetAccount = this.accountHelper.createAssetAccount();
|
||||
final Account incomeAccount = this.accountHelper.createIncomeAccount();
|
||||
final Account expenseAccount = this.accountHelper.createExpenseAccount();
|
||||
final Account overpaymentAccount = this.accountHelper.createLiabilityAccount();
|
||||
|
||||
final Integer loanProductID = createLoanProductWithPeriodicAccrualAccountingEnabled(assetAccount, incomeAccount, expenseAccount,
|
||||
overpaymentAccount);
|
||||
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, this.DATE_OF_JOINING);
|
||||
final Integer loanID = applyForLoanApplication(clientID, loanProductID);
|
||||
|
||||
final float FEE_PORTION = 50.0f;
|
||||
final float PENALTY_PORTION = 100.0f;
|
||||
Integer flat = ChargesHelper.createCharges(requestSpec, responseSpec,
|
||||
ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(FEE_PORTION), false));
|
||||
Integer flatSpecifiedDueDate = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getLoanSpecifiedDueDateJSON(
|
||||
ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(PENALTY_PORTION), true));
|
||||
|
||||
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
|
||||
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
|
||||
|
||||
loanStatusHashMap = this.loanTransactionHelper.approveLoan(this.EXPECTED_DISBURSAL_DATE, loanID);
|
||||
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
|
||||
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
|
||||
|
||||
Calendar todayDate = Calendar.getInstance();
|
||||
final String currentDate = dateFormat.format(todayDate.getTime());
|
||||
|
||||
todayDate.add(Calendar.DATE, -4);
|
||||
|
||||
final String LOAN_DISBURSEMENT_DATE = dateFormat.format(todayDate.getTime());
|
||||
|
||||
todayDate.add(Calendar.MONTH, 2);
|
||||
final String FIRST_REPAYMENT_DATE = dateFormat.format(todayDate.getTime());
|
||||
|
||||
todayDate = Calendar.getInstance();
|
||||
todayDate.add(Calendar.DATE, -2);
|
||||
|
||||
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID);
|
||||
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
|
||||
|
||||
this.loanTransactionHelper.addChargesForLoan(
|
||||
loanID,
|
||||
LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(flatSpecifiedDueDate),
|
||||
dateFormat.format(todayDate.getTime()), String.valueOf(PENALTY_PORTION)));
|
||||
todayDate.add(Calendar.DATE, 1);
|
||||
this.loanTransactionHelper.addChargesForLoan(loanID, LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(
|
||||
String.valueOf(flat), dateFormat.format(todayDate.getTime()), String.valueOf(FEE_PORTION)));
|
||||
|
||||
// CHECK ACCOUNT ENTRIES
|
||||
System.out.println("Entries ......");
|
||||
final float PRINCIPAL_VALUE_FOR_EACH_PERIOD = 2000.0f;
|
||||
final float TOTAL_INTEREST = 1000.0f;
|
||||
final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(this.LP_PRINCIPAL, JournalEntry.TransactionType.CREDIT),
|
||||
new JournalEntry(this.LP_PRINCIPAL, JournalEntry.TransactionType.DEBIT), };
|
||||
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, LOAN_DISBURSEMENT_DATE, assetAccountInitialEntry);
|
||||
|
||||
final String jobName = "Add Periodic Accrual Transactions";
|
||||
try {
|
||||
this.schedulerJobHelper.executeJob(jobName);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
final ArrayList<HashMap> loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec,
|
||||
loanID);
|
||||
// MAKE 1
|
||||
List fromDateList = (List) loanSchedule.get(1).get("fromDate");
|
||||
LocalDate fromDateLocal = LocalDate.now();
|
||||
fromDateLocal = fromDateLocal.withYear((int) fromDateList.get(0));
|
||||
fromDateLocal = fromDateLocal.withMonthOfYear((int) fromDateList.get(1));
|
||||
fromDateLocal = fromDateLocal.withDayOfMonth((int) fromDateList.get(2));
|
||||
|
||||
List dueDateList = (List) loanSchedule.get(1).get("dueDate");
|
||||
LocalDate dueDateLocal = LocalDate.now();
|
||||
dueDateLocal = dueDateLocal.withYear((int) dueDateList.get(0));
|
||||
dueDateLocal = dueDateLocal.withMonthOfYear((int) dueDateList.get(1));
|
||||
dueDateLocal = dueDateLocal.withDayOfMonth((int) dueDateList.get(2));
|
||||
|
||||
int totalDaysInPeriod = Days.daysBetween(fromDateLocal, dueDateLocal).getDays();
|
||||
|
||||
float totalInterest = (float) loanSchedule.get(1).get("interestOriginalDue");
|
||||
DecimalFormat numberFormat = new DecimalFormat("#.00", new DecimalFormatSymbols(Locale.US));
|
||||
float INTEREST_4_DAYS = totalInterest / totalDaysInPeriod * 4;
|
||||
INTEREST_4_DAYS = new Float(numberFormat.format(INTEREST_4_DAYS));
|
||||
|
||||
this.loanTransactionHelper.checkAccrualTransactionForRepayment(getDateAsLocalDate(currentDate), INTEREST_4_DAYS, FEE_PORTION,
|
||||
PENALTY_PORTION, loanID);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkPeriodicAccrualAccountingAPIFlow() {
|
||||
final Account assetAccount = this.accountHelper.createAssetAccount();
|
||||
final Account incomeAccount = this.accountHelper.createIncomeAccount();
|
||||
final Account expenseAccount = this.accountHelper.createExpenseAccount();
|
||||
final Account overpaymentAccount = this.accountHelper.createLiabilityAccount();
|
||||
|
||||
final Integer loanProductID = createLoanProductWithPeriodicAccrualAccountingEnabled(assetAccount, incomeAccount, expenseAccount,
|
||||
overpaymentAccount);
|
||||
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, this.DATE_OF_JOINING);
|
||||
final Integer loanID = applyForLoanApplication(clientID, loanProductID);
|
||||
|
||||
final float FEE_PORTION = 50.0f;
|
||||
final float PENALTY_PORTION = 100.0f;
|
||||
final float NEXT_FEE_PORTION = 55.0f;
|
||||
final float NEXT_PENALTY_PORTION = 105.0f;
|
||||
|
||||
Integer flat = ChargesHelper.createCharges(requestSpec, responseSpec,
|
||||
ChargesHelper.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(FEE_PORTION), false));
|
||||
Integer flatSpecifiedDueDate = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getLoanSpecifiedDueDateJSON(
|
||||
ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(PENALTY_PORTION), true));
|
||||
|
||||
Integer flatNext = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper.getLoanSpecifiedDueDateJSON(
|
||||
ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(NEXT_FEE_PORTION), false));
|
||||
Integer flatSpecifiedDueDateNext = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper
|
||||
.getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, String.valueOf(NEXT_PENALTY_PORTION), true));
|
||||
|
||||
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
|
||||
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
|
||||
|
||||
loanStatusHashMap = this.loanTransactionHelper.approveLoan(this.EXPECTED_DISBURSAL_DATE, loanID);
|
||||
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
|
||||
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
|
||||
|
||||
Calendar todayDate = Calendar.getInstance();
|
||||
final String currentDate = dateFormat.format(todayDate.getTime());
|
||||
|
||||
todayDate.add(Calendar.DATE, -4);
|
||||
|
||||
final String LOAN_DISBURSEMENT_DATE = dateFormat.format(todayDate.getTime());
|
||||
|
||||
todayDate.add(Calendar.MONTH, 2);
|
||||
final String FIRST_REPAYMENT_DATE = dateFormat.format(todayDate.getTime());
|
||||
|
||||
todayDate = Calendar.getInstance();
|
||||
todayDate.add(Calendar.DATE, -2);
|
||||
|
||||
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID);
|
||||
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
|
||||
|
||||
this.loanTransactionHelper.addChargesForLoan(
|
||||
loanID,
|
||||
LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(flatSpecifiedDueDate),
|
||||
dateFormat.format(todayDate.getTime()), String.valueOf(PENALTY_PORTION)));
|
||||
todayDate.add(Calendar.DATE, 1);
|
||||
String runOndate = dateFormat.format(todayDate.getTime());
|
||||
|
||||
this.loanTransactionHelper
|
||||
.addChargesForLoan(
|
||||
loanID,
|
||||
LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(flat), runOndate,
|
||||
String.valueOf(FEE_PORTION)));
|
||||
|
||||
todayDate.add(Calendar.DATE, 1);
|
||||
this.loanTransactionHelper.addChargesForLoan(
|
||||
loanID,
|
||||
LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(flatSpecifiedDueDateNext),
|
||||
dateFormat.format(todayDate.getTime()), String.valueOf(NEXT_PENALTY_PORTION)));
|
||||
|
||||
this.loanTransactionHelper.addChargesForLoan(
|
||||
loanID,
|
||||
LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(String.valueOf(flatNext),
|
||||
dateFormat.format(todayDate.getTime()), String.valueOf(NEXT_FEE_PORTION)));
|
||||
|
||||
// CHECK ACCOUNT ENTRIES
|
||||
System.out.println("Entries ......");
|
||||
final float PRINCIPAL_VALUE_FOR_EACH_PERIOD = 2000.0f;
|
||||
final float TOTAL_INTEREST = 1000.0f;
|
||||
final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(this.LP_PRINCIPAL, JournalEntry.TransactionType.CREDIT),
|
||||
new JournalEntry(this.LP_PRINCIPAL, JournalEntry.TransactionType.DEBIT), };
|
||||
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, LOAN_DISBURSEMENT_DATE, assetAccountInitialEntry);
|
||||
|
||||
this.periodicAccrualAccountingHelper.runPeriodicAccrualAccounting(runOndate);
|
||||
|
||||
final ArrayList<HashMap> loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec,
|
||||
loanID);
|
||||
// MAKE 1
|
||||
List fromDateList = (List) loanSchedule.get(1).get("fromDate");
|
||||
LocalDate fromDateLocal = LocalDate.now();
|
||||
fromDateLocal = fromDateLocal.withYear((int) fromDateList.get(0));
|
||||
fromDateLocal = fromDateLocal.withMonthOfYear((int) fromDateList.get(1));
|
||||
fromDateLocal = fromDateLocal.withDayOfMonth((int) fromDateList.get(2));
|
||||
|
||||
List dueDateList = (List) loanSchedule.get(1).get("dueDate");
|
||||
LocalDate dueDateLocal = LocalDate.now();
|
||||
dueDateLocal = dueDateLocal.withYear((int) dueDateList.get(0));
|
||||
dueDateLocal = dueDateLocal.withMonthOfYear((int) dueDateList.get(1));
|
||||
dueDateLocal = dueDateLocal.withDayOfMonth((int) dueDateList.get(2));
|
||||
|
||||
int totalDaysInPeriod = Days.daysBetween(fromDateLocal, dueDateLocal).getDays();
|
||||
|
||||
float totalInterest = (float) loanSchedule.get(1).get("interestOriginalDue");
|
||||
DecimalFormat numberFormat = new DecimalFormat("#.00", new DecimalFormatSymbols(Locale.US));
|
||||
float INTEREST_3_DAYS = totalInterest / totalDaysInPeriod * 3;
|
||||
INTEREST_3_DAYS = new Float(numberFormat.format(INTEREST_3_DAYS));
|
||||
this.loanTransactionHelper.checkAccrualTransactionForRepayment(getDateAsLocalDate(runOndate), INTEREST_3_DAYS, FEE_PORTION,
|
||||
PENALTY_PORTION, loanID);
|
||||
|
||||
runOndate = dateFormat.format(todayDate.getTime());
|
||||
|
||||
this.periodicAccrualAccountingHelper.runPeriodicAccrualAccounting(runOndate);
|
||||
float interestPerDay = (totalInterest / totalDaysInPeriod * 4) - INTEREST_3_DAYS;
|
||||
interestPerDay = new Float(numberFormat.format(interestPerDay));
|
||||
this.loanTransactionHelper.checkAccrualTransactionForRepayment(getDateAsLocalDate(runOndate), interestPerDay, NEXT_FEE_PORTION,
|
||||
NEXT_PENALTY_PORTION, loanID);
|
||||
|
||||
}
|
||||
|
||||
private Integer createLoanProductWithPeriodicAccrualAccountingEnabled(final Account... accounts) {
|
||||
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
|
||||
final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(this.LP_PRINCIPAL.toString()).withRepaymentTypeAsMonth()
|
||||
.withRepaymentAfterEvery(this.LP_REPAYMENT_PERIOD).withNumberOfRepayments(this.LP_REPAYMENTS).withRepaymentTypeAsMonth()
|
||||
.withinterestRatePerPeriod(this.LP_INTEREST_RATE).withInterestRateFrequencyTypeAsMonths()
|
||||
.withAmortizationTypeAsEqualPrincipalPayment().withInterestTypeAsFlat().withAccountingRulePeriodicAccrual(accounts)
|
||||
.build(null);
|
||||
.withDaysInMonth("30").withDaysInYear("365").build(null);
|
||||
return this.loanTransactionHelper.getLoanProductId(loanProductJSON);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void checkCashBasedAccountingFlow() {
|
||||
final Account assetAccount = this.accountHelper.createAssetAccount();
|
||||
@@ -677,7 +914,7 @@ public class AccountingScenarioIntegrationTest {
|
||||
final JournalEntry[] assetAccountInitialEntry = { new JournalEntry(this.LP_PRINCIPAL, JournalEntry.TransactionType.CREDIT),
|
||||
new JournalEntry(this.LP_PRINCIPAL, JournalEntry.TransactionType.DEBIT) };
|
||||
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.EXPECTED_DISBURSAL_DATE, assetAccountInitialEntry);
|
||||
|
||||
|
||||
// MAKE 1
|
||||
System.out.println("Repayment 1 ......");
|
||||
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[1], this.REPAYMENT_AMOUNT[1], loanID);
|
||||
@@ -707,15 +944,15 @@ public class AccountingScenarioIntegrationTest {
|
||||
this.journalEntryHelper.checkJournalEntryForIncomeAccount(incomeAccount, this.REPAYMENT_DATE[2], new JournalEntry(
|
||||
SECOND_AND_THIRD_INTEREST, JournalEntry.TransactionType.CREDIT));
|
||||
System.out.println("Repayment 2 Done ......");
|
||||
|
||||
|
||||
// WAIVE INTEREST
|
||||
System.out.println("Waive Interest ......");
|
||||
Integer transactionId = this.loanTransactionHelper.waiveInterestAndReturnTransactionId(this.REPAYMENT_DATE[4], this.AMOUNT_TO_BE_WAIVE.toString(), loanID);
|
||||
// waive of fees and interest are not considered in cash based accounting,
|
||||
this.journalEntryHelper.ensureNoAccountingTransactionsWithTransactionId("L"+transactionId);
|
||||
|
||||
|
||||
|
||||
Integer transactionId = this.loanTransactionHelper.waiveInterestAndReturnTransactionId(this.REPAYMENT_DATE[4],
|
||||
this.AMOUNT_TO_BE_WAIVE.toString(), loanID);
|
||||
// waive of fees and interest are not considered in cash based
|
||||
// accounting,
|
||||
this.journalEntryHelper.ensureNoAccountingTransactionsWithTransactionId("L" + transactionId);
|
||||
|
||||
// REPAYMENT 3
|
||||
System.out.println("Repayment 3 ......");
|
||||
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[3], this.REPAYMENT_AMOUNT[3], loanID);
|
||||
@@ -725,7 +962,7 @@ public class AccountingScenarioIntegrationTest {
|
||||
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(3, expected_value, loanID);
|
||||
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[3], assetAccountThirdEntry);
|
||||
System.out.println("Repayment 3 Done ......");
|
||||
|
||||
|
||||
// REPAYMENT 4
|
||||
System.out.println("Repayment 4 ......");
|
||||
this.loanTransactionHelper.makeRepayment(this.REPAYMENT_DATE[4], this.REPAYMENT_AMOUNT[4], loanID);
|
||||
@@ -746,25 +983,25 @@ public class AccountingScenarioIntegrationTest {
|
||||
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[5], assetAccountFifthEntry);
|
||||
System.out.println("Repayment 5 Done ......");
|
||||
}
|
||||
|
||||
|
||||
private Integer createLoanProductWithCashBasedAccountingEnabled(final Account... accounts) {
|
||||
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
|
||||
final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(this.LP_PRINCIPAL.toString()).withRepaymentTypeAsMonth()
|
||||
.withRepaymentAfterEvery(this.LP_REPAYMENT_PERIOD).withNumberOfRepayments(this.LP_REPAYMENTS).withRepaymentTypeAsMonth()
|
||||
.withinterestRatePerPeriod(this.LP_INTEREST_RATE).withInterestRateFrequencyTypeAsMonths()
|
||||
.withAmortizationTypeAsEqualPrincipalPayment().withInterestTypeAsFlat().withAccountingRuleAsCashBased(accounts)
|
||||
.build(null);
|
||||
.withAmortizationTypeAsEqualPrincipalPayment().withInterestTypeAsFlat().withAccountingRuleAsCashBased(accounts).build(null);
|
||||
return this.loanTransactionHelper.getLoanProductId(loanProductJSON);
|
||||
}
|
||||
|
||||
private LocalDate getDateAsLocalDate(String dateAsString) {
|
||||
LocalDate date = null;
|
||||
try {
|
||||
DateFormat df = new SimpleDateFormat("dd MMMM yyyy");
|
||||
DateFormat df = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
|
||||
date = new LocalDate(df.parse(dateAsString));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return date;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+412
@@ -0,0 +1,412 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mifosplatform.batch.domain.BatchRequest;
|
||||
import org.mifosplatform.batch.domain.BatchResponse;
|
||||
import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
|
||||
import org.mifosplatform.integrationtests.common.BatchHelper;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanProductTestBuilder;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanTransactionHelper;
|
||||
import org.mifosplatform.integrationtests.common.savings.SavingsProductHelper;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.jayway.restassured.builder.RequestSpecBuilder;
|
||||
import com.jayway.restassured.builder.ResponseSpecBuilder;
|
||||
import com.jayway.restassured.http.ContentType;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
/**
|
||||
* Test class for
|
||||
* {@link org.mifosplatform.batch.command.CommandStrategyProvider}. This tests
|
||||
* the response provided by commandStrategy by injecting it with a
|
||||
* {@code BatchRequest}.
|
||||
*
|
||||
* @author RishabhShukla
|
||||
*
|
||||
* @see org.mifosplatform.integrationtests.common.BatchHelper
|
||||
* @see org.mifosplatform.batch.domain.BatchRequest
|
||||
*/
|
||||
public class BatchApiTest {
|
||||
|
||||
private ResponseSpecification responseSpec;
|
||||
private RequestSpecification requestSpec;
|
||||
|
||||
public BatchApiTest() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the essential settings for the TEST like contentType,
|
||||
* expectedStatusCode. It uses the '@Before' annotation provided by jUnit.
|
||||
*/
|
||||
@Before
|
||||
public void setup() {
|
||||
|
||||
Utils.initializeRESTAssured();
|
||||
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests for the unimplemented command Strategies by returning 501 status
|
||||
* code. For a unknownRequest a statusCode 501 is returned back with
|
||||
* response.
|
||||
*
|
||||
* @see org.mifosplatform.batch.command.internal.UnknownCommandStrategy
|
||||
*/
|
||||
@Test
|
||||
public void shouldReturnStatusNotImplementedUnknownCommand() {
|
||||
|
||||
final BatchRequest br = new BatchRequest();
|
||||
br.setRequestId(4711L);
|
||||
br.setRelativeUrl("/nirvana");
|
||||
br.setMethod("POST");
|
||||
|
||||
final List<BatchResponse> response = BatchHelper.postWithSingleRequest(this.requestSpec, this.responseSpec, br);
|
||||
|
||||
// Verify that only 501 is returned as the status code
|
||||
for (BatchResponse resp : response) {
|
||||
Assert.assertEquals("Verify Status code 501", (long) 501, (long) resp.getStatusCode());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests for the successful response for a createClient request from
|
||||
* createClientCommand. A successful response with statusCode '200' is
|
||||
* returned back.
|
||||
*
|
||||
* @see org.mifosplatform.batch.command.internal.CreateClientCommandStrategy
|
||||
*/
|
||||
@Test
|
||||
public void shouldReturnOkStatusForCreateClientCommand() {
|
||||
|
||||
final BatchRequest br = BatchHelper.createClientRequest(4712L, "");
|
||||
|
||||
final List<BatchResponse> response = BatchHelper.postWithSingleRequest(this.requestSpec, this.responseSpec, br);
|
||||
|
||||
// Verify that a 200 response is returned as the status code
|
||||
for (BatchResponse resp : response) {
|
||||
Assert.assertEquals("Verify Status code 200", (long) 200, (long) resp.getStatusCode());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests for an erroneous response with statusCode '501' if transaction
|
||||
* fails. If Query Parameter 'enclosingTransaction' is set to 'true' and if
|
||||
* one of the request in BatchRequest fails then all transactions are rolled
|
||||
* back.
|
||||
*
|
||||
* @see org.mifosplatform.batch.command.internal.CreateClientCommandStrategy
|
||||
* @see org.mifosplatform.batch.api.BatchApiResource
|
||||
* @see org.mifosplatform.batch.service.BatchApiService
|
||||
*/
|
||||
@Test
|
||||
public void shouldRollBackAllTransactionsOnFailure() {
|
||||
|
||||
// Create first client request
|
||||
final BatchRequest br1 = BatchHelper.createClientRequest(4713L, "TestExtId11");
|
||||
|
||||
// Create second client request
|
||||
final BatchRequest br2 = BatchHelper.createClientRequest(4714L, "TestExtId12");
|
||||
|
||||
// Create third client request, having same externalID as second client,
|
||||
// hence cause of error
|
||||
final BatchRequest br3 = BatchHelper.createClientRequest(4715L, "TestExtId11");
|
||||
|
||||
final List<BatchRequest> batchRequests = new ArrayList<>();
|
||||
|
||||
batchRequests.add(br1);
|
||||
batchRequests.add(br2);
|
||||
batchRequests.add(br3);
|
||||
|
||||
final String jsonifiedRequest = BatchHelper.toJsonString(batchRequests);
|
||||
final List<BatchResponse> response = BatchHelper.postBatchRequestsWithEnclosingTransaction(this.requestSpec, this.responseSpec,
|
||||
jsonifiedRequest);
|
||||
|
||||
// Verifies that none of the client in BatchRequest is created on the
|
||||
// server
|
||||
BatchHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, "TestExtId11");
|
||||
BatchHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, "TestExtId12");
|
||||
|
||||
// Asserts that all the transactions have been successfully rolled back
|
||||
Assert.assertEquals(response.size(), 1);
|
||||
Assert.assertEquals("Verify Status code 400", (long) 400, (long) response.get(0).getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that a client information was successfully updated through
|
||||
* updateClientCommand. A 'changes' parameter is returned in the response
|
||||
* after successful update of client information.
|
||||
*
|
||||
* @see org.mifosplatform.batch.command.internal.UpdateClientCommandStrategy
|
||||
*/
|
||||
@Test
|
||||
public void shouldReflectChangesOnClientUpdate() {
|
||||
|
||||
// Create a createClient Request
|
||||
final BatchRequest br1 = BatchHelper.createClientRequest(4716L, "");
|
||||
|
||||
// Create a clientUpdate Request
|
||||
final BatchRequest br2 = BatchHelper.updateClientRequest(4717L, 4716L);
|
||||
|
||||
final List<BatchRequest> batchRequests = new ArrayList<>();
|
||||
|
||||
batchRequests.add(br1);
|
||||
batchRequests.add(br2);
|
||||
|
||||
final String jsonifiedRequest = BatchHelper.toJsonString(batchRequests);
|
||||
|
||||
final List<BatchResponse> response = BatchHelper.postBatchRequestsWithoutEnclosingTransaction(this.requestSpec, this.responseSpec,
|
||||
jsonifiedRequest);
|
||||
|
||||
// Get the changes parameter from updateClient Response
|
||||
final JsonObject changes = new FromJsonHelper().parse(response.get(1).getBody()).getAsJsonObject().get("changes").getAsJsonObject();
|
||||
|
||||
// Asserts the client information is successfully updated
|
||||
Assert.assertEquals("Verify Firstname", "TestFirstName", changes.get("firstname").getAsString());
|
||||
Assert.assertEquals("Verify Lastname", "TestLastName", changes.get("lastname").getAsString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that a ApplyLoanCommand was successfully executed and returned a
|
||||
* 200(OK) status. It creates a new client and apply a loan to that client.
|
||||
* This also verifies the successful resolution of dependencies among two
|
||||
* requests.
|
||||
*
|
||||
* @see org.mifosplatform.batch.command.internal.ApplyLoanCommandStrategy
|
||||
*/
|
||||
@Test
|
||||
public void shouldReturnOkStatusForApplyLoanCommand() {
|
||||
|
||||
final String loanProductJSON = new LoanProductTestBuilder() //
|
||||
.withPrincipal("10000000.00") //
|
||||
.withNumberOfRepayments("24") //
|
||||
.withRepaymentAfterEvery("1") //
|
||||
.withRepaymentTypeAsMonth() //
|
||||
.withinterestRatePerPeriod("2") //
|
||||
.withInterestRateFrequencyTypeAsMonths() //
|
||||
.withAmortizationTypeAsEqualPrincipalPayment() //
|
||||
.withInterestTypeAsDecliningBalance() //
|
||||
.currencyDetails("0", "100").build(null);
|
||||
|
||||
final Integer productId = new LoanTransactionHelper(this.requestSpec, this.responseSpec).getLoanProductId(loanProductJSON);
|
||||
|
||||
// Create a createClient Request
|
||||
final BatchRequest br1 = BatchHelper.createClientRequest(4718L, "");
|
||||
|
||||
// Create a activateClient Request
|
||||
final BatchRequest br2 = BatchHelper.activateClientRequest(4719L, 4718L);
|
||||
|
||||
// Create a ApplyLoan Request
|
||||
final BatchRequest br3 = BatchHelper.applyLoanRequest(4720L, 4719L, productId);
|
||||
|
||||
final List<BatchRequest> batchRequests = new ArrayList<>();
|
||||
|
||||
batchRequests.add(br1);
|
||||
batchRequests.add(br2);
|
||||
batchRequests.add(br3);
|
||||
|
||||
final String jsonifiedRequest = BatchHelper.toJsonString(batchRequests);
|
||||
|
||||
final List<BatchResponse> response = BatchHelper.postBatchRequestsWithoutEnclosingTransaction(this.requestSpec, this.responseSpec,
|
||||
jsonifiedRequest);
|
||||
|
||||
// Get the clientId parameter from createClient Response
|
||||
final JsonElement clientId = new FromJsonHelper().parse(response.get(0).getBody()).getAsJsonObject().get("clientId");
|
||||
|
||||
Assert.assertEquals("Verify Status Code 200" + clientId.getAsString(), 200L, (long) response.get(1).getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that a new savings accounts was applied to an existing client and a
|
||||
* 200(OK) status was returned. It first creates a new client and a savings
|
||||
* product, then uses the cliendId and ProductId to apply a savings account.
|
||||
*
|
||||
* @see org.mifosplatform.batch.command.internal.ApplySavingsCommandStrategy
|
||||
*/
|
||||
@Test
|
||||
public void shouldReturnOkStatusForApplySavingsCommand() {
|
||||
|
||||
final SavingsProductHelper savingsProductHelper = new SavingsProductHelper();
|
||||
final String savingsProductJSON = savingsProductHelper //
|
||||
.withInterestCompoundingPeriodTypeAsDaily() //
|
||||
.withInterestPostingPeriodTypeAsMonthly() //
|
||||
.withInterestCalculationPeriodTypeAsDailyBalance() //
|
||||
.withMinimumOpenningBalance("5000").build();
|
||||
|
||||
final Integer productId = SavingsProductHelper.createSavingsProduct(savingsProductJSON, this.requestSpec, this.responseSpec);
|
||||
|
||||
// Create a createClient Request
|
||||
final BatchRequest br1 = BatchHelper.createClientRequest(4720L, "");
|
||||
|
||||
// Create a activateClient Request
|
||||
final BatchRequest br2 = BatchHelper.activateClientRequest(4721L, 4720L);
|
||||
|
||||
// Create a applySavings Request
|
||||
final BatchRequest br3 = BatchHelper.applySavingsRequest(4722L, 4721L, productId);
|
||||
|
||||
final List<BatchRequest> batchRequests = new ArrayList<>();
|
||||
|
||||
batchRequests.add(br1);
|
||||
batchRequests.add(br2);
|
||||
batchRequests.add(br3);
|
||||
|
||||
final String jsonifiedRequest = BatchHelper.toJsonString(batchRequests);
|
||||
|
||||
final List<BatchResponse> response = BatchHelper.postBatchRequestsWithoutEnclosingTransaction(this.requestSpec, this.responseSpec,
|
||||
jsonifiedRequest);
|
||||
|
||||
Assert.assertEquals("Verify Status Code 200", 200L, (long) response.get(1).getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that a new charge was added to a newly created loan and charges are
|
||||
* Collected properly 200(OK) status was returned for successful responses.
|
||||
* It first creates a new client and apply a loan, then creates a new charge
|
||||
* for the create loan and then fetches all the applied charges
|
||||
*
|
||||
* @see org.mifosplatform.batch.command.internal.CollectChargesCommandStrategy
|
||||
* @see org.mifosplatform.batch.command.internal.CreateChargeCommandStrategy
|
||||
*/
|
||||
@Test
|
||||
public void shouldReturnOkStatusForCollectChargesCommand() {
|
||||
|
||||
final String loanProductJSON = new LoanProductTestBuilder() //
|
||||
.withPrincipal("10000000.00") //
|
||||
.withNumberOfRepayments("24") //
|
||||
.withRepaymentAfterEvery("1") //
|
||||
.withRepaymentTypeAsMonth() //
|
||||
.withinterestRatePerPeriod("2") //
|
||||
.withInterestRateFrequencyTypeAsMonths() //
|
||||
.withAmortizationTypeAsEqualPrincipalPayment() //
|
||||
.withInterestTypeAsDecliningBalance() //
|
||||
.currencyDetails("0", "100").build(null);
|
||||
|
||||
final Integer productId = new LoanTransactionHelper(this.requestSpec, this.responseSpec).getLoanProductId(loanProductJSON);
|
||||
|
||||
// Create a createClient Request
|
||||
final BatchRequest br1 = BatchHelper.createClientRequest(4722L, "");
|
||||
|
||||
// Create a activateClient Request
|
||||
final BatchRequest br2 = BatchHelper.activateClientRequest(4723L, 4722L);
|
||||
|
||||
// Create a ApplyLoan Request
|
||||
final BatchRequest br3 = BatchHelper.applyLoanRequest(4724L, 4723L, productId);
|
||||
|
||||
// Create a Collect Charges Request
|
||||
final BatchRequest br4 = BatchHelper.collectChargesRequest(4725L, 4724L);
|
||||
|
||||
final List<BatchRequest> batchRequests = new ArrayList<>();
|
||||
|
||||
batchRequests.add(br1);
|
||||
batchRequests.add(br2);
|
||||
batchRequests.add(br3);
|
||||
batchRequests.add(br4);
|
||||
|
||||
final String jsonifiedRequest = BatchHelper.toJsonString(batchRequests);
|
||||
|
||||
final List<BatchResponse> response = BatchHelper.postBatchRequestsWithoutEnclosingTransaction(this.requestSpec, this.responseSpec,
|
||||
jsonifiedRequest);
|
||||
|
||||
Assert.assertEquals("Verify Status Code 200 for Create Loan Charge", 200L, (long) response.get(3).getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for the successful activation of a pending client using
|
||||
* 'ActivateClientCommandStrategy'. A '200' status code is expected on
|
||||
* successful activation.
|
||||
*
|
||||
* @see org.mifosplatform.batch.command.internal.ActivateClientCommandStrategy
|
||||
*/
|
||||
@Test
|
||||
public void shouldReturnOkStatusOnSuccessfulClientActivation() {
|
||||
|
||||
// Create a createClient Request
|
||||
final BatchRequest br1 = BatchHelper.createClientRequest(4726L, "");
|
||||
|
||||
// Create a activateClient Request
|
||||
final BatchRequest br2 = BatchHelper.activateClientRequest(4727L, 4726L);
|
||||
|
||||
final List<BatchRequest> batchRequests = new ArrayList<>();
|
||||
|
||||
batchRequests.add(br1);
|
||||
batchRequests.add(br2);
|
||||
|
||||
final String jsonifiedRequest = BatchHelper.toJsonString(batchRequests);
|
||||
|
||||
final List<BatchResponse> response = BatchHelper.postBatchRequestsWithoutEnclosingTransaction(this.requestSpec, this.responseSpec,
|
||||
jsonifiedRequest);
|
||||
|
||||
Assert.assertEquals("Verify Status Code 200 for Create Client", 200L, (long) response.get(0).getStatusCode());
|
||||
Assert.assertEquals("Verify Status Code 200 for Activate Client", 200L, (long) response.get(1).getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for the successful approval and disbursal of a loan using
|
||||
* 'ApproveLoanCommandStrategy' and 'DisburseLoanCommandStrategy'. A '200'
|
||||
* status code is expected on successful activation.
|
||||
*
|
||||
* @see org.mifosplatform.batch.command.internal.ApproveLoanCommandStrategy
|
||||
* @see org.mifosplatform.batch.command.internal.DisburseLoanCommandStrategy
|
||||
*/
|
||||
@Test
|
||||
public void shouldReturnOkStatusOnSuccessfulLoanApprovalAndDisburse() {
|
||||
final String loanProductJSON = new LoanProductTestBuilder() //
|
||||
.withPrincipal("10000000.00") //
|
||||
.withNumberOfRepayments("24") //
|
||||
.withRepaymentAfterEvery("1") //
|
||||
.withRepaymentTypeAsMonth() //
|
||||
.withinterestRatePerPeriod("2") //
|
||||
.withInterestRateFrequencyTypeAsMonths() //
|
||||
.withAmortizationTypeAsEqualPrincipalPayment() //
|
||||
.withInterestTypeAsDecliningBalance() //
|
||||
.currencyDetails("0", "100").build(null);
|
||||
|
||||
final Integer productId = new LoanTransactionHelper(this.requestSpec, this.responseSpec).getLoanProductId(loanProductJSON);
|
||||
|
||||
// Create a createClient Request
|
||||
final BatchRequest br1 = BatchHelper.createClientRequest(4730L, "");
|
||||
|
||||
// Create a activateClient Request
|
||||
final BatchRequest br2 = BatchHelper.activateClientRequest(4731L, 4730L);
|
||||
|
||||
// Create a ApplyLoan Request
|
||||
final BatchRequest br3 = BatchHelper.applyLoanRequest(4732L, 4731L, productId);
|
||||
|
||||
// Create a approveLoan Request
|
||||
final BatchRequest br4 = BatchHelper.approveLoanRequest(4733L, 4732L);
|
||||
|
||||
// Create a disburseLoan Request
|
||||
final BatchRequest br5 = BatchHelper.disburseLoanRequest(4734L, 4733L);
|
||||
|
||||
final List<BatchRequest> batchRequests = new ArrayList<>();
|
||||
|
||||
batchRequests.add(br1);
|
||||
batchRequests.add(br2);
|
||||
batchRequests.add(br3);
|
||||
batchRequests.add(br4);
|
||||
batchRequests.add(br5);
|
||||
|
||||
final String jsonifiedRequest = BatchHelper.toJsonString(batchRequests);
|
||||
|
||||
final List<BatchResponse> response = BatchHelper.postBatchRequestsWithoutEnclosingTransaction(this.requestSpec, this.responseSpec,
|
||||
jsonifiedRequest);
|
||||
|
||||
Assert.assertEquals("Verify Status Code 200 for Approve Loan", 200L, (long) response.get(3).getStatusCode());
|
||||
Assert.assertEquals("Verify Status Code 200 for Disburse Loan", 200L, (long) response.get(4).getStatusCode());
|
||||
}
|
||||
}
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mifosplatform.batch.domain.BatchRequest;
|
||||
import org.mifosplatform.batch.domain.BatchResponse;
|
||||
import org.mifosplatform.integrationtests.common.BatchHelper;
|
||||
import org.mifosplatform.integrationtests.common.ClientHelper;
|
||||
import org.mifosplatform.integrationtests.common.GroupHelper;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanProductTestBuilder;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanTransactionHelper;
|
||||
|
||||
import com.jayway.restassured.builder.RequestSpecBuilder;
|
||||
import com.jayway.restassured.builder.ResponseSpecBuilder;
|
||||
import com.jayway.restassured.http.ContentType;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
/**
|
||||
* Test class for testing the integration of Batch API with custom batch
|
||||
* requests and various user defined workflow. Like in the case of mifos
|
||||
* community-app
|
||||
*
|
||||
* @author Rishabh Shukla
|
||||
*/
|
||||
public class BatchRequestsIntegrationTest {
|
||||
|
||||
private ResponseSpecification responseSpec;
|
||||
private RequestSpecification requestSpec;
|
||||
|
||||
public BatchRequestsIntegrationTest() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the essential settings for the TEST like contentType,
|
||||
* expectedStatusCode. It uses the '@Before' annotation provided by jUnit.
|
||||
*/
|
||||
@Before
|
||||
public void setup() {
|
||||
|
||||
Utils.initializeRESTAssured();
|
||||
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
/**
|
||||
* Tests that a loan is successfully applied to client members of a group.
|
||||
* Firstly, it'll create a few new clients and then will add those clients
|
||||
* to the group. Then a few loans will be created and one of those loans
|
||||
* will be chosen at random and similarily a few of the created clients will
|
||||
* be chosen on random. Now, the selected loan will be applied to these
|
||||
* clients through Batch - API ApplyLoanCommandStrategy.
|
||||
*/
|
||||
public void shouldReturnOkStatusForLoansAppliedToSelectedClients() {
|
||||
|
||||
// Generate a random count of number of clients to be created
|
||||
final Integer clientsCount = (int) Math.ceil(Math.random() * 7) + 3;
|
||||
final Integer[] clientIDs = new Integer[clientsCount];
|
||||
|
||||
// Create a new group and get its groupId
|
||||
Integer groupID = GroupHelper.createGroup(this.requestSpec, this.responseSpec, true);
|
||||
|
||||
// Create new clients and add those to this group
|
||||
for (Integer i = 0; i < clientsCount; i++) {
|
||||
clientIDs[i] = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientIDs[i].toString());
|
||||
System.out.println("client " + clientIDs[i] + " has been added to the group " + groupID);
|
||||
}
|
||||
|
||||
// Generate a random count of number of new loan products to be created
|
||||
final Integer loansCount = (int) Math.ceil(Math.random() * 4) + 1;
|
||||
final Integer[] loanProducts = new Integer[loansCount];
|
||||
|
||||
// Create new loan Products
|
||||
for (Integer i = 0; i < loansCount; i++) {
|
||||
final String loanProductJSON = new LoanProductTestBuilder() //
|
||||
.withPrincipal(String.valueOf(10000.00 + Math.ceil(Math.random() * 1000000.00))) //
|
||||
.withNumberOfRepayments(String.valueOf(2 + (int) Math.ceil(Math.random() * 36))) //
|
||||
.withRepaymentAfterEvery(String.valueOf(1 + (int) Math.ceil(Math.random() * 3))) //
|
||||
.withRepaymentTypeAsMonth() //
|
||||
.withinterestRatePerPeriod(String.valueOf(1 + (int) Math.ceil(Math.random() * 4))) //
|
||||
.withInterestRateFrequencyTypeAsMonths() //
|
||||
.withAmortizationTypeAsEqualPrincipalPayment() //
|
||||
.withInterestTypeAsDecliningBalance() //
|
||||
.currencyDetails("0", "100").build(null);
|
||||
|
||||
loanProducts[i] = new LoanTransactionHelper(this.requestSpec, this.responseSpec).getLoanProductId(loanProductJSON);
|
||||
}
|
||||
|
||||
// Select anyone of the loan products at random
|
||||
final Integer loanProductID = loanProducts[(int) Math.floor(Math.random() * (loansCount - 1))];
|
||||
|
||||
final List<BatchRequest> batchRequests = new ArrayList<>();
|
||||
|
||||
// Select a few clients from created group at random
|
||||
Integer selClientsCount = (int) Math.ceil(Math.random() * clientsCount) + 2;
|
||||
for (int i = 0; i < selClientsCount; i++) {
|
||||
BatchRequest br = BatchHelper.applyLoanRequest((long) selClientsCount, null, loanProductID);
|
||||
br.setBody(br.getBody().replace("$.clientId", String.valueOf(clientIDs[(int) Math.floor(Math.random() * (clientsCount - 1))])));
|
||||
batchRequests.add(br);
|
||||
}
|
||||
|
||||
// Send the request to Batch - API
|
||||
final String jsonifiedRequest = BatchHelper.toJsonString(batchRequests);
|
||||
|
||||
final List<BatchResponse> response = BatchHelper.postBatchRequestsWithoutEnclosingTransaction(this.requestSpec, this.responseSpec,
|
||||
jsonifiedRequest);
|
||||
|
||||
// Verify that each loan has been applied successfully
|
||||
for (BatchResponse res : response) {
|
||||
Assert.assertEquals("Verify Status Code 200", 200L, (long) res.getStatusCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
+1151
-54
File diff suppressed because it is too large
Load Diff
+410
-22
@@ -1,13 +1,24 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DateFormat;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -55,8 +66,12 @@ public class ClientSavingsIntegrationTest {
|
||||
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientID);
|
||||
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE);
|
||||
final String minBalanceForInterestCalculation = null;
|
||||
final String minRequiredBalance = null;
|
||||
final String enforceMinRequiredBalance = "false";
|
||||
final boolean allowOverdraft = false;
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
|
||||
minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance, allowOverdraft);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID, ACCOUNT_TYPE_INDIVIDUAL);
|
||||
@@ -90,13 +105,64 @@ public class ClientSavingsIntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSavingsAccount_CLOSE_APPLICATION() {
|
||||
public void testSavingsAccountWithMinBalanceForInterestCalculation() {
|
||||
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientID);
|
||||
final String minBalanceForInterestCalculation = "5000";
|
||||
final String minRequiredBalance = null;
|
||||
final String enforceMinRequiredBalance = "false";
|
||||
final boolean allowOverdraft = false;
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
|
||||
minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance, allowOverdraft);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, null);
|
||||
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID, ACCOUNT_TYPE_INDIVIDUAL);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
HashMap modifications = this.savingsAccountHelper.updateSavingsAccount(clientID, savingsProductID, savingsId,
|
||||
ACCOUNT_TYPE_INDIVIDUAL);
|
||||
Assert.assertTrue(modifications.containsKey("submittedOnDate"));
|
||||
|
||||
HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
|
||||
|
||||
savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
|
||||
|
||||
savingsStatusHashMap = this.savingsAccountHelper.activateSavings(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
|
||||
|
||||
final HashMap summaryBefore = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
this.savingsAccountHelper.calculateInterestForSavings(savingsId);
|
||||
HashMap summary = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
assertEquals(summaryBefore, summary);
|
||||
|
||||
this.savingsAccountHelper.postInterestForSavings(savingsId);
|
||||
summary = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
assertEquals(summaryBefore, summary);
|
||||
|
||||
final Object savingsInterest = this.savingsAccountHelper.getSavingsInterest(savingsId);
|
||||
Assert.assertNull(savingsInterest);
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testSavingsAccount_CLOSE_APPLICATION() {
|
||||
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||
final ResponseSpecification errorResponse = new ResponseSpecBuilder().expectStatusCode(400).build();
|
||||
final SavingsAccountHelper validationErrorHelper = new SavingsAccountHelper(this.requestSpec, errorResponse);
|
||||
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientID);
|
||||
final String minBalanceForInterestCalculation = null;
|
||||
final String minRequiredBalance = "1000.0";
|
||||
final String enforceMinRequiredBalance = "true";
|
||||
final boolean allowOverdraft = false;
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
|
||||
minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance, allowOverdraft);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID, ACCOUNT_TYPE_INDIVIDUAL);
|
||||
@@ -111,10 +177,86 @@ public class ClientSavingsIntegrationTest {
|
||||
savingsStatusHashMap = this.savingsAccountHelper.activateSavings(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
|
||||
|
||||
savingsStatusHashMap = this.savingsAccountHelper.closeSavingsAccount(savingsId);
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
final String CLOSEDON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
String withdrawBalance = "false";
|
||||
ArrayList<HashMap> savingsAccountErrorData = (ArrayList<HashMap>) validationErrorHelper.closeSavingsAccountAndGetBackRequiredField(
|
||||
savingsId, withdrawBalance, CommonConstants.RESPONSE_ERROR, CLOSEDON_DATE);
|
||||
assertEquals("validation.msg.savingsaccount.close.results.in.balance.not.zero",
|
||||
savingsAccountErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
withdrawBalance = "true";
|
||||
savingsStatusHashMap = this.savingsAccountHelper.closeSavingsAccount(savingsId, withdrawBalance);
|
||||
SavingsStatusChecker.verifySavingsAccountIsClosed(savingsStatusHashMap);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testSavingsAccount_WITH_ENFORCE_MIN_BALANCE() {
|
||||
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||
final ResponseSpecification errorResponse = new ResponseSpecBuilder().expectStatusCode(403).build();
|
||||
final SavingsAccountHelper validationErrorHelper = new SavingsAccountHelper(this.requestSpec, errorResponse);
|
||||
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientID);
|
||||
final String minBalanceForInterestCalculation = null;
|
||||
final String minRequiredBalance = "1500.0";
|
||||
final String openningBalance = "1600";
|
||||
final String enforceMinRequiredBalance = "true";
|
||||
final boolean allowOverdraft = false;
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, openningBalance ,
|
||||
minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance, allowOverdraft);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID, ACCOUNT_TYPE_INDIVIDUAL);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
|
||||
|
||||
final Integer savingsActivationChargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
|
||||
ChargesHelper.getSavingsActivationFeeJSON());
|
||||
Assert.assertNotNull(savingsActivationChargeId);
|
||||
|
||||
this.savingsAccountHelper.addChargesForSavings(savingsId, savingsActivationChargeId);
|
||||
|
||||
savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
|
||||
|
||||
savingsStatusHashMap = this.savingsAccountHelper.activateSavings(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
|
||||
|
||||
HashMap summary = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
Float balance = new Float(openningBalance);
|
||||
Float chargeAmt = 100f;
|
||||
balance -= chargeAmt;
|
||||
assertEquals("Verifying opening Balance", balance, summary.get("accountBalance"));
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
final String TRANSACTION_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String withdrawAmt = "800";
|
||||
ArrayList<HashMap> savingsAccountErrorData = (ArrayList<HashMap>) validationErrorHelper.withdrawalFromSavingsAccount(savingsId,
|
||||
withdrawAmt, TRANSACTION_DATE, CommonConstants.RESPONSE_ERROR);
|
||||
assertEquals("error.msg.savingsaccount.transaction.insufficient.account.balance",
|
||||
savingsAccountErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
Integer depositTransactionId = (Integer) this.savingsAccountHelper.depositToSavingsAccount(savingsId, DEPOSIT_AMOUNT,
|
||||
TRANSACTION_DATE, CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
HashMap depositTransaction = this.savingsAccountHelper.getSavingsTransaction(savingsId, depositTransactionId);
|
||||
balance += new Float(DEPOSIT_AMOUNT);
|
||||
assertEquals("Verifying Deposit Amount", new Float(DEPOSIT_AMOUNT), depositTransaction.get("amount"));
|
||||
assertEquals("Verifying Balance after Deposit", balance, depositTransaction.get("runningBalance"));
|
||||
|
||||
Integer withdrawTransactionId = (Integer) this.savingsAccountHelper.withdrawalFromSavingsAccount(savingsId, withdrawAmt,
|
||||
TRANSACTION_DATE, CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
HashMap withdrawTransaction = this.savingsAccountHelper.getSavingsTransaction(savingsId, withdrawTransactionId);
|
||||
balance -= new Float(withdrawAmt);
|
||||
assertEquals("Verifying Withdrawal Amount", new Float(withdrawAmt), withdrawTransaction.get("amount"));
|
||||
assertEquals("Verifying Balance after Withdrawal", balance, withdrawTransaction.get("runningBalance"));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testSavingsAccount_DELETE_APPLICATION() {
|
||||
@@ -125,8 +267,12 @@ public class ClientSavingsIntegrationTest {
|
||||
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientID);
|
||||
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, null);
|
||||
final String minBalanceForInterestCalculation = null;
|
||||
final String minRequiredBalance = null;
|
||||
final String enforceMinRequiredBalance = "false";
|
||||
final boolean allowOverdraft = false;
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
|
||||
minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance, allowOverdraft);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID, ACCOUNT_TYPE_INDIVIDUAL);
|
||||
@@ -164,8 +310,12 @@ public class ClientSavingsIntegrationTest {
|
||||
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientID);
|
||||
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE);
|
||||
final String minBalanceForInterestCalculation = null;
|
||||
final String minRequiredBalance = null;
|
||||
final String enforceMinRequiredBalance = "false";
|
||||
final boolean allowOverdraft = false;
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
|
||||
minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance, allowOverdraft);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID, ACCOUNT_TYPE_INDIVIDUAL);
|
||||
@@ -205,8 +355,12 @@ public class ClientSavingsIntegrationTest {
|
||||
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientID);
|
||||
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE);
|
||||
final String minBalanceForInterestCalculation = null;
|
||||
final String minRequiredBalance = null;
|
||||
final String enforceMinRequiredBalance = "false";
|
||||
final boolean allowOverdraft = false;
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
|
||||
minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance, allowOverdraft);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID, ACCOUNT_TYPE_INDIVIDUAL);
|
||||
@@ -229,8 +383,12 @@ public class ClientSavingsIntegrationTest {
|
||||
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientID);
|
||||
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE);
|
||||
final String minBalanceForInterestCalculation = null;
|
||||
final String minRequiredBalance = null;
|
||||
final String enforceMinRequiredBalance = "false";
|
||||
final boolean allowOverdraft = false;
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
|
||||
minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance, allowOverdraft);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID, ACCOUNT_TYPE_INDIVIDUAL);
|
||||
@@ -319,16 +477,23 @@ public class ClientSavingsIntegrationTest {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testSavingsAccountCharges() {
|
||||
|
||||
final ResponseSpecification erroResponseSpec = new ResponseSpecBuilder().build();
|
||||
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||
final SavingsAccountHelper validationErrorHelper = new SavingsAccountHelper(this.requestSpec, erroResponseSpec);
|
||||
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientID);
|
||||
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE);
|
||||
final String minBalanceForInterestCalculation = null;
|
||||
final String minRequiredBalance = null;
|
||||
final String enforceMinRequiredBalance = "false";
|
||||
final boolean allowOverdraft = false;
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
|
||||
minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance, allowOverdraft);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID, ACCOUNT_TYPE_INDIVIDUAL);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
|
||||
@@ -368,7 +533,14 @@ public class ClientSavingsIntegrationTest {
|
||||
Assert.assertEquals(1, charges.size());
|
||||
|
||||
HashMap savingsChargeForPay = charges.get(0);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(CommonConstants.dateFormat);
|
||||
Integer annualSavingsChargeId = (Integer) savingsChargeForPay.get("id");
|
||||
|
||||
ArrayList<HashMap> savingsAccountErrorData = (ArrayList<HashMap>) validationErrorHelper.inactivateCharge(annualSavingsChargeId,
|
||||
savingsId, CommonConstants.RESPONSE_ERROR);
|
||||
assertEquals("validation.msg.savingsaccountcharge.inactivation.of.charge.not.allowed.when.charge.is.due", savingsAccountErrorData
|
||||
.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(CommonConstants.dateFormat, Locale.US);
|
||||
Calendar cal = Calendar.getInstance();
|
||||
List dates = (List) savingsChargeForPay.get("dueDate");
|
||||
cal.set(Calendar.YEAR, (Integer) dates.get(0));
|
||||
@@ -380,6 +552,10 @@ public class ClientSavingsIntegrationTest {
|
||||
HashMap paidCharge = this.savingsAccountHelper.getSavingsCharge(savingsId, (Integer) savingsChargeForPay.get("id"));
|
||||
assertEquals(savingsChargeForPay.get("amount"), paidCharge.get("amountPaid"));
|
||||
|
||||
Integer inactivatedChargeId = (Integer) this.savingsAccountHelper.inactivateCharge(annualSavingsChargeId, savingsId,
|
||||
CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
assertEquals("Inactivated Savings Charges Id", annualSavingsChargeId, inactivatedChargeId);
|
||||
|
||||
final Integer monthlyFeechargeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
|
||||
ChargesHelper.getSavingsMonthlyFeeJSON());
|
||||
Assert.assertNotNull(monthlyFeechargeId);
|
||||
@@ -389,19 +565,231 @@ public class ClientSavingsIntegrationTest {
|
||||
Assert.assertEquals(2, charges.size());
|
||||
|
||||
HashMap savingsChargeForWaive = charges.get(1);
|
||||
final Integer monthlySavingsCharge = (Integer) savingsChargeForWaive.get("id");
|
||||
|
||||
savingsAccountErrorData = (ArrayList<HashMap>) validationErrorHelper.inactivateCharge(monthlySavingsCharge, savingsId,
|
||||
CommonConstants.RESPONSE_ERROR);
|
||||
assertEquals("validation.msg.savingsaccountcharge.inactivation.of.charge.not.allowed.when.charge.is.due", savingsAccountErrorData
|
||||
.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
this.savingsAccountHelper.waiveCharge((Integer) savingsChargeForWaive.get("id"), savingsId);
|
||||
HashMap waiveCharge = this.savingsAccountHelper.getSavingsCharge(savingsId, (Integer) savingsChargeForWaive.get("id"));
|
||||
assertEquals(savingsChargeForWaive.get("amount"), waiveCharge.get("amountWaived"));
|
||||
|
||||
this.savingsAccountHelper.waiveCharge((Integer) savingsChargeForWaive.get("id"), savingsId);
|
||||
waiveCharge = this.savingsAccountHelper.getSavingsCharge(savingsId, (Integer) savingsChargeForWaive.get("id"));
|
||||
BigDecimal totalWaiveAmount = BigDecimal.valueOf(Double.valueOf((Float) savingsChargeForWaive.get("amount")));
|
||||
totalWaiveAmount = totalWaiveAmount.add(totalWaiveAmount);
|
||||
assertEquals(totalWaiveAmount.floatValue(), waiveCharge.get("amountWaived"));
|
||||
|
||||
final Integer weeklyFeeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
|
||||
ChargesHelper.getSavingsWeeklyFeeJSON());
|
||||
Assert.assertNotNull(weeklyFeeId);
|
||||
|
||||
this.savingsAccountHelper.addChargesForSavings(savingsId, weeklyFeeId);
|
||||
charges = this.savingsAccountHelper.getSavingsCharges(savingsId);
|
||||
Assert.assertEquals(3, charges.size());
|
||||
|
||||
savingsChargeForPay = charges.get(2);
|
||||
final Integer weeklySavingsFeeId = (Integer) savingsChargeForPay.get("id");
|
||||
|
||||
savingsAccountErrorData = (ArrayList<HashMap>) validationErrorHelper.inactivateCharge(weeklySavingsFeeId, savingsId,
|
||||
CommonConstants.RESPONSE_ERROR);
|
||||
assertEquals("validation.msg.savingsaccountcharge.inactivation.of.charge.not.allowed.when.charge.is.due", savingsAccountErrorData
|
||||
.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
cal = Calendar.getInstance();
|
||||
dates = (List) savingsChargeForPay.get("dueDate");
|
||||
cal.set(Calendar.YEAR, (Integer) dates.get(0));
|
||||
cal.set(Calendar.MONTH, (Integer) dates.get(1) - 1);
|
||||
cal.set(Calendar.DAY_OF_MONTH, (Integer) dates.get(2));
|
||||
|
||||
// Depositing huge amount as scheduler job deducts the fee amount
|
||||
Integer depositTransactionId = (Integer) this.savingsAccountHelper.depositToSavingsAccount(savingsId, "100000",
|
||||
SavingsAccountHelper.TRANSACTION_DATE, CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
Assert.assertNotNull(depositTransactionId);
|
||||
|
||||
this.savingsAccountHelper.payCharge((Integer) savingsChargeForPay.get("id"), savingsId,
|
||||
((Float) savingsChargeForPay.get("amount")).toString(), sdf.format(cal.getTime()));
|
||||
paidCharge = this.savingsAccountHelper.getSavingsCharge(savingsId, (Integer) savingsChargeForPay.get("id"));
|
||||
assertEquals(savingsChargeForPay.get("amount"), paidCharge.get("amountPaid"));
|
||||
List nextDueDates = (List) paidCharge.get("dueDate");
|
||||
LocalDate nextDueDate = new LocalDate((Integer) nextDueDates.get(0), (Integer) nextDueDates.get(1), (Integer) nextDueDates.get(2));
|
||||
LocalDate expectedNextDueDate = new LocalDate((Integer) dates.get(0), (Integer) dates.get(1), (Integer) dates.get(2))
|
||||
.plusWeeks((Integer) paidCharge.get("feeInterval"));
|
||||
assertEquals(expectedNextDueDate, nextDueDate);
|
||||
}
|
||||
|
||||
/***
|
||||
* Test case for overdraft account functionality. Open account with zero
|
||||
* balance, perform transactions then post interest and verify posted
|
||||
* interest
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testSavingsAccountWithOverdraft() {
|
||||
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||
final ResponseSpecification errorResponse = new ResponseSpecBuilder().expectStatusCode(400).build();
|
||||
final SavingsAccountHelper validationErrorHelper = new SavingsAccountHelper(this.requestSpec, errorResponse);
|
||||
|
||||
/***
|
||||
* Create a client to apply for savings account (overdraft account).
|
||||
*/
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientID);
|
||||
final String minBalanceForInterestCalculation = null;
|
||||
|
||||
/***
|
||||
* Create savings product with zero opening balance and overdraft
|
||||
* enabled
|
||||
*/
|
||||
final String zeroOpeningBalance = "0.0";
|
||||
final String minRequiredBalance = null;
|
||||
final String enforceMinRequiredBalance = "false";
|
||||
final boolean allowOverdraft = true;
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, zeroOpeningBalance,
|
||||
minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance, allowOverdraft);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
/***
|
||||
* Apply for Savings account
|
||||
*/
|
||||
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(clientID, savingsProductID, ACCOUNT_TYPE_INDIVIDUAL);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
HashMap modifications = this.savingsAccountHelper.updateSavingsAccount(clientID, savingsProductID, savingsId,
|
||||
ACCOUNT_TYPE_INDIVIDUAL);
|
||||
Assert.assertTrue(modifications.containsKey("submittedOnDate"));
|
||||
|
||||
HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
|
||||
|
||||
/***
|
||||
* Approve the savings account
|
||||
*/
|
||||
savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -1);
|
||||
todaysDate.set(Calendar.DAY_OF_MONTH, 1);
|
||||
final String ACTIVATION_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final Integer lastDayOfMonth = todaysDate.getActualMaximum(Calendar.DAY_OF_MONTH);
|
||||
todaysDate.set(Calendar.DAY_OF_MONTH, lastDayOfMonth);
|
||||
final String TRANSACTION_DATE = dateFormat.format(todaysDate.getTime());
|
||||
|
||||
/***
|
||||
* Activate the application and verify account status
|
||||
*
|
||||
* @param activationDate
|
||||
* this value is every time first day of previous month
|
||||
*/
|
||||
savingsStatusHashMap = activateSavingsAccount(savingsId, ACTIVATION_DATE);
|
||||
SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
|
||||
|
||||
/***
|
||||
* Verify the account summary
|
||||
*/
|
||||
final HashMap summaryBefore = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
this.savingsAccountHelper.calculateInterestForSavings(savingsId);
|
||||
HashMap summary = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
assertEquals(summaryBefore, summary);
|
||||
|
||||
Float balance = Float.valueOf(zeroOpeningBalance);
|
||||
|
||||
/***
|
||||
* Perform withdraw transaction, verify account balance(account balance
|
||||
* will go to negative as no deposits are there prior to this
|
||||
* transaction)
|
||||
*/
|
||||
Integer withdrawTransactionId = (Integer) this.savingsAccountHelper.withdrawalFromSavingsAccount(savingsId, WITHDRAW_AMOUNT,
|
||||
ACTIVATION_DATE, CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
HashMap withdrawTransaction = this.savingsAccountHelper.getSavingsTransaction(savingsId, withdrawTransactionId);
|
||||
balance -= new Float(WITHDRAW_AMOUNT);
|
||||
assertEquals("Verifying Withdrawal Amount", new Float(WITHDRAW_AMOUNT), withdrawTransaction.get("amount"));
|
||||
assertEquals("Verifying Balance after Withdrawal", balance, withdrawTransaction.get("runningBalance"));
|
||||
|
||||
/***
|
||||
* Perform Deposit transaction on last day of month and verify account
|
||||
* balance.
|
||||
*
|
||||
* @param transactionDate
|
||||
* this value is every time last day of previous month
|
||||
*/
|
||||
Integer depositTransactionId = (Integer) this.savingsAccountHelper.depositToSavingsAccount(savingsId, DEPOSIT_AMOUNT,
|
||||
TRANSACTION_DATE, CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
HashMap depositTransaction = this.savingsAccountHelper.getSavingsTransaction(savingsId, depositTransactionId);
|
||||
balance += new Float(DEPOSIT_AMOUNT);
|
||||
assertEquals("Verifying Deposit Amount", new Float(DEPOSIT_AMOUNT), depositTransaction.get("amount"));
|
||||
assertEquals("Verifying Balance after Deposit", balance, depositTransaction.get("runningBalance"));
|
||||
|
||||
/***
|
||||
* Perform Post interest transaction and verify the posted amount
|
||||
*/
|
||||
this.savingsAccountHelper.postInterestForSavings(savingsId);
|
||||
HashMap accountDetails = this.savingsAccountHelper.getSavingsDetails(savingsId);
|
||||
summary = (HashMap) accountDetails.get("summary");
|
||||
Float actualInterestPosted = Float.valueOf(summary.get("totalInterestPosted").toString());
|
||||
|
||||
/***
|
||||
* Calculate expected interest to be posted, interest should be posted
|
||||
* for one day only because deposit transaction happened on last day of
|
||||
* month before this account balance is negative.
|
||||
*/
|
||||
final Float nominalAnnualInterest = Float.valueOf(accountDetails.get("nominalAnnualInterestRate").toString());
|
||||
final HashMap interestCalculationDaysInYearType = (HashMap) accountDetails.get("interestCalculationDaysInYearType");
|
||||
final Integer daysInYear = Integer.valueOf(interestCalculationDaysInYearType.get("id").toString());
|
||||
double interestRateInFraction = (nominalAnnualInterest / 100);
|
||||
double perDay = (double) 1 / (daysInYear);
|
||||
double interestPerDay = interestRateInFraction * perDay;
|
||||
Float interestPosted = (float) (interestPerDay * balance * 1);
|
||||
|
||||
/***
|
||||
* Apply rounding on interestPosted, actualInterestPosted and verify
|
||||
* both are same
|
||||
*/
|
||||
DecimalFormat decimalFormat = new DecimalFormat("", new DecimalFormatSymbols(Locale.US));
|
||||
decimalFormat.applyPattern("#.###");
|
||||
interestPosted = new Float(decimalFormat.format(interestPosted));
|
||||
actualInterestPosted = new Float(decimalFormat.format(actualInterestPosted));
|
||||
assertEquals("Verifying interest posted", interestPosted, actualInterestPosted);
|
||||
|
||||
todaysDate = Calendar.getInstance();
|
||||
final String CLOSEDON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
String withdrawBalance = "false";
|
||||
ArrayList<HashMap> savingsAccountErrorData = (ArrayList<HashMap>) validationErrorHelper.closeSavingsAccountAndGetBackRequiredField(
|
||||
savingsId, withdrawBalance, CommonConstants.RESPONSE_ERROR, CLOSEDON_DATE);
|
||||
assertEquals("validation.msg.savingsaccount.close.results.in.balance.not.zero",
|
||||
savingsAccountErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
}
|
||||
|
||||
private HashMap activateSavingsAccount(final Integer savingsId, final String activationDate) {
|
||||
final HashMap status = this.savingsAccountHelper.activateSavingsAccount(savingsId, activationDate);
|
||||
return status;
|
||||
}
|
||||
|
||||
private Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String minOpenningBalance) {
|
||||
final String minOpenningBalance, String minBalanceForInterestCalculation, String minRequiredBalance,
|
||||
String enforceMinRequiredBalance, final boolean allowOverdraft) {
|
||||
System.out.println("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------");
|
||||
SavingsProductHelper savingsProductHelper = new SavingsProductHelper();
|
||||
final String savingsProductJSON = savingsProductHelper //
|
||||
.withInterestCompoundingPeriodTypeAsDaily() //
|
||||
.withInterestPostingPeriodTypeAsMonthly() //
|
||||
.withInterestCalculationPeriodTypeAsDailyBalance() //
|
||||
if (allowOverdraft) {
|
||||
final String overDraftLimit = "2000.0";
|
||||
savingsProductHelper = savingsProductHelper.withOverDraft(overDraftLimit);
|
||||
}
|
||||
|
||||
final String savingsProductJSON = savingsProductHelper
|
||||
//
|
||||
.withInterestCompoundingPeriodTypeAsDaily()
|
||||
//
|
||||
.withInterestPostingPeriodTypeAsMonthly()
|
||||
//
|
||||
.withInterestCalculationPeriodTypeAsDailyBalance()
|
||||
//
|
||||
.withMinBalanceForInterestCalculation(minBalanceForInterestCalculation)
|
||||
//
|
||||
.withMinRequiredBalance(minRequiredBalance).withEnforceMinRequiredBalance(enforceMinRequiredBalance)
|
||||
.withMinimumOpenningBalance(minOpenningBalance).build();
|
||||
return SavingsProductHelper.createSavingsProduct(savingsProductJSON, requestSpec, responseSpec);
|
||||
}
|
||||
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class ClientStatusChecker {
|
||||
public static void verifyClientIsActive(final HashMap clientStatusHashMap) {
|
||||
assertEquals((int) clientStatusHashMap.get("id"), 300);
|
||||
}
|
||||
|
||||
|
||||
public static void verifyClientClosed(final HashMap clientStatusHashMap) {
|
||||
System.out.println("\n-------------------------------------- VERIFYING CLIENT IS CLOSED ------------------------------------");
|
||||
assertEquals((int) clientStatusHashMap.get("id"), 600);
|
||||
System.out.println("Client Status:" + clientStatusHashMap + "\n");
|
||||
}
|
||||
public static void verifyClientPending(final HashMap clientStatusHashMap) {
|
||||
System.out.println("\n-------------------------------------- VERIFYING CLIENT IS PENDING ------------------------------------");
|
||||
assertEquals((int) clientStatusHashMap.get("id"), 100);
|
||||
System.out.println("Client Status:" + clientStatusHashMap + "\n");
|
||||
}
|
||||
public static void verifyClientRejected(final HashMap clientStatusHashMap) {
|
||||
System.out.println("\n-------------------------------------- VERIFYING CLIENT IS REJECTED ------------------------------------");
|
||||
assertEquals((int) clientStatusHashMap.get("id"), 700);
|
||||
System.out.println("Client Status:" + clientStatusHashMap + "\n");
|
||||
}
|
||||
|
||||
public static void verifyClientActiavted(final HashMap clientStatusHashMap) {
|
||||
System.out.println("\n-------------------------------------- VERIFYING CLIENT IS ACTIVATED ------------------------------------");
|
||||
assertEquals((int) clientStatusHashMap.get("id"), 300);
|
||||
System.out.println("Client Status:" + clientStatusHashMap + "\n");
|
||||
}
|
||||
|
||||
public static void verifyClientWithdrawn(final HashMap clientStatusHashMap) {
|
||||
System.out.println("\n-------------------------------------- VERIFYING CLIENT IS WITHDRAWN ------------------------------------");
|
||||
assertEquals((int) clientStatusHashMap.get("id"), 800);
|
||||
System.out.println("Client Status:" + clientStatusHashMap + "\n");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mifosplatform.integrationtests.common.ClientHelper;
|
||||
import org.mifosplatform.integrationtests.common.SchedulerJobHelper;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
import org.mifosplatform.integrationtests.common.accounting.AccountHelper;
|
||||
import org.mifosplatform.integrationtests.common.accounting.JournalEntryHelper;
|
||||
import org.mifosplatform.integrationtests.common.accounting.PeriodicAccrualAccountingHelper;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanTransactionHelper;
|
||||
import org.mifosplatform.integrationtests.common.savings.SavingsAccountHelper;
|
||||
import org.mifosplatform.integrationtests.common.savings.SavingsStatusChecker;
|
||||
|
||||
import com.jayway.restassured.builder.RequestSpecBuilder;
|
||||
import com.jayway.restassured.builder.ResponseSpecBuilder;
|
||||
import com.jayway.restassured.http.ContentType;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
public class ClientTest {
|
||||
|
||||
private ResponseSpecification responseSpec;
|
||||
private RequestSpecification requestSpec;
|
||||
private ClientHelper clientHelper;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
Utils.initializeRESTAssured();
|
||||
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClientStatus() {
|
||||
this.clientHelper = new ClientHelper(this.requestSpec, this.responseSpec);
|
||||
final Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientId);
|
||||
|
||||
HashMap status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
|
||||
ClientStatusChecker.verifyClientIsActive(status);
|
||||
|
||||
HashMap clientStatusHashMap = this.clientHelper.closeClient(clientId);
|
||||
ClientStatusChecker.verifyClientClosed(clientStatusHashMap);
|
||||
|
||||
clientStatusHashMap = this.clientHelper.reactivateClient(clientId);
|
||||
ClientStatusChecker.verifyClientPending(clientStatusHashMap);
|
||||
|
||||
clientStatusHashMap = this.clientHelper.rejectClient(clientId);
|
||||
ClientStatusChecker.verifyClientRejected(clientStatusHashMap);
|
||||
|
||||
clientStatusHashMap = this.clientHelper.activateClient(clientId);
|
||||
ClientStatusChecker.verifyClientActiavted(clientStatusHashMap);
|
||||
|
||||
clientStatusHashMap = this.clientHelper.closeClient(clientId);
|
||||
ClientStatusChecker.verifyClientClosed(clientStatusHashMap);
|
||||
|
||||
clientStatusHashMap = this.clientHelper.reactivateClient(clientId);
|
||||
ClientStatusChecker.verifyClientPending(clientStatusHashMap);
|
||||
|
||||
clientStatusHashMap = this.clientHelper.withdrawClient(clientId);
|
||||
ClientStatusChecker.verifyClientWithdrawn(clientStatusHashMap);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mifosplatform.accounting.common.AccountingConstants.FINANCIAL_ACTIVITY;
|
||||
import org.mifosplatform.accounting.financialactivityaccount.exception.DuplicateFinancialActivityAccountFoundException;
|
||||
import org.mifosplatform.accounting.financialactivityaccount.exception.FinancialActivityAccountInvalidException;
|
||||
import org.mifosplatform.integrationtests.common.CommonConstants;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
import org.mifosplatform.integrationtests.common.accounting.Account;
|
||||
import org.mifosplatform.integrationtests.common.accounting.AccountHelper;
|
||||
import org.mifosplatform.integrationtests.common.accounting.FinancialActivityAccountHelper;
|
||||
|
||||
import com.jayway.restassured.builder.RequestSpecBuilder;
|
||||
import com.jayway.restassured.builder.ResponseSpecBuilder;
|
||||
import com.jayway.restassured.http.ContentType;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class FinancialActivityAccountsTest {
|
||||
|
||||
private ResponseSpecification responseSpec;
|
||||
private ResponseSpecification responseSpecForValidationError;
|
||||
private ResponseSpecification responseSpecForDomainRuleViolation;
|
||||
private ResponseSpecification responseSpecForResourceNotFoundError;
|
||||
private RequestSpecification requestSpec;
|
||||
private AccountHelper accountHelper;
|
||||
private FinancialActivityAccountHelper financialActivityAccountHelper;
|
||||
private final Integer assetTransferFinancialActivityId = FINANCIAL_ACTIVITY.ASSET_TRANSFER.getValue();
|
||||
public static final Integer liabilityTransferFinancialActivityId = FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue();
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
Utils.initializeRESTAssured();
|
||||
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
this.responseSpecForValidationError = new ResponseSpecBuilder().expectStatusCode(400).build();
|
||||
this.responseSpecForDomainRuleViolation = new ResponseSpecBuilder().expectStatusCode(403).build();
|
||||
this.responseSpecForResourceNotFoundError = new ResponseSpecBuilder().expectStatusCode(404).build();
|
||||
this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec);
|
||||
this.financialActivityAccountHelper = new FinancialActivityAccountHelper(this.requestSpec);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testFinancialActivityAccounts() {
|
||||
|
||||
/** Create a Liability and an Asset Transfer Account **/
|
||||
Account liabilityTransferAccount = accountHelper.createLiabilityAccount();
|
||||
Account assetTransferAccount = accountHelper.createAssetAccount();
|
||||
Assert.assertNotNull(assetTransferAccount);
|
||||
Assert.assertNotNull(liabilityTransferAccount);
|
||||
|
||||
/*** Create A Financial Activity to Account Mapping **/
|
||||
Integer financialActivityAccountId = (Integer) financialActivityAccountHelper.createFinancialActivityAccount(
|
||||
liabilityTransferFinancialActivityId, liabilityTransferAccount.getAccountID(), responseSpec,
|
||||
CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
Assert.assertNotNull(financialActivityAccountId);
|
||||
|
||||
/***
|
||||
* Fetch Created Financial Activity to Account Mapping and validate
|
||||
* created values
|
||||
**/
|
||||
assertFinancialActivityAccountCreation(financialActivityAccountId, liabilityTransferFinancialActivityId, liabilityTransferAccount);
|
||||
|
||||
/**
|
||||
* Update Existing Financial Activity to Account Mapping and assert
|
||||
* changes
|
||||
**/
|
||||
Account newLiabilityTransferAccount = accountHelper.createLiabilityAccount();
|
||||
Assert.assertNotNull(newLiabilityTransferAccount);
|
||||
|
||||
HashMap changes = (HashMap) financialActivityAccountHelper.updateFinancialActivityAccount(financialActivityAccountId,
|
||||
liabilityTransferFinancialActivityId, newLiabilityTransferAccount.getAccountID(), responseSpec,
|
||||
CommonConstants.RESPONSE_CHANGES);
|
||||
Assert.assertEquals(newLiabilityTransferAccount.getAccountID(), changes.get("glAccountId"));
|
||||
|
||||
/** Validate update works correctly **/
|
||||
assertFinancialActivityAccountCreation(financialActivityAccountId, liabilityTransferFinancialActivityId,
|
||||
newLiabilityTransferAccount);
|
||||
|
||||
/** Update with Invalid Financial Activity should fail **/
|
||||
List<HashMap> invalidFinancialActivityUpdateError = (List<HashMap>) financialActivityAccountHelper.updateFinancialActivityAccount(
|
||||
financialActivityAccountId, 232, newLiabilityTransferAccount.getAccountID(), responseSpecForValidationError,
|
||||
CommonConstants.RESPONSE_ERROR);
|
||||
assertEquals("validation.msg.financialactivityaccount.financialActivityId.is.not.one.of.expected.enumerations",
|
||||
invalidFinancialActivityUpdateError.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
/** Creating Duplicate Financial Activity should fail **/
|
||||
List<HashMap> duplicateFinancialActivityAccountError = (List<HashMap>) financialActivityAccountHelper
|
||||
.createFinancialActivityAccount(liabilityTransferFinancialActivityId, liabilityTransferAccount.getAccountID(),
|
||||
responseSpecForDomainRuleViolation, CommonConstants.RESPONSE_ERROR);
|
||||
assertEquals(DuplicateFinancialActivityAccountFoundException.getErrorcode(),
|
||||
duplicateFinancialActivityAccountError.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
/**
|
||||
* Associating incorrect GL account types with a financial activity
|
||||
* should fail
|
||||
**/
|
||||
List<HashMap> invalidFinancialActivityAccountError = (List<HashMap>) financialActivityAccountHelper.updateFinancialActivityAccount(
|
||||
financialActivityAccountId, assetTransferFinancialActivityId, newLiabilityTransferAccount.getAccountID(),
|
||||
responseSpecForDomainRuleViolation, CommonConstants.RESPONSE_ERROR);
|
||||
assertEquals(FinancialActivityAccountInvalidException.getErrorcode(),
|
||||
invalidFinancialActivityAccountError.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
/** Should be able to delete a Financial Activity to Account Mapping **/
|
||||
Integer deletedFinancialActivityAccountId = financialActivityAccountHelper.deleteFinancialActivityAccount(
|
||||
financialActivityAccountId, responseSpec, CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
Assert.assertNotNull(deletedFinancialActivityAccountId);
|
||||
Assert.assertEquals(financialActivityAccountId, deletedFinancialActivityAccountId);
|
||||
|
||||
/*** Trying to fetch a Deleted Account Mapping should give me a 404 **/
|
||||
financialActivityAccountHelper.getFinancialActivityAccount(deletedFinancialActivityAccountId, responseSpecForResourceNotFoundError);
|
||||
}
|
||||
|
||||
private void assertFinancialActivityAccountCreation(Integer financialActivityAccountId, Integer financialActivityId, Account glAccount) {
|
||||
HashMap mappingDetails = financialActivityAccountHelper.getFinancialActivityAccount(financialActivityAccountId, responseSpec);
|
||||
Assert.assertEquals(financialActivityId, ((HashMap) mappingDetails.get("financialActivityData")).get("id"));
|
||||
Assert.assertEquals(glAccount.getAccountID(), ((HashMap) mappingDetails.get("glAccountData")).get("id"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the Financial activities
|
||||
*/
|
||||
@After
|
||||
public void tearDown() {
|
||||
List<HashMap> financialActivities = this.financialActivityAccountHelper.getAllFinancialActivityAccounts(this.responseSpec);
|
||||
for (HashMap financialActivity : financialActivities) {
|
||||
Integer financialActivityAccountId = (Integer) financialActivity.get("id");
|
||||
Integer deletedFinancialActivityAccountId = this.financialActivityAccountHelper.deleteFinancialActivityAccount(
|
||||
financialActivityAccountId, this.responseSpec, CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
Assert.assertNotNull(deletedFinancialActivityAccountId);
|
||||
Assert.assertEquals(financialActivityAccountId, deletedFinancialActivityAccountId);
|
||||
}
|
||||
}
|
||||
}
|
||||
+423
-90
File diff suppressed because it is too large
Load Diff
+148
@@ -0,0 +1,148 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mifosplatform.integrationtests.common.ClientHelper;
|
||||
import org.mifosplatform.integrationtests.common.CommonConstants;
|
||||
import org.mifosplatform.integrationtests.common.GlobalConfigurationHelper;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
import org.mifosplatform.integrationtests.common.savings.SavingsAccountHelper;
|
||||
import org.mifosplatform.integrationtests.common.savings.SavingsProductHelper;
|
||||
import org.mifosplatform.integrationtests.common.savings.SavingsStatusChecker;
|
||||
|
||||
import com.jayway.restassured.builder.RequestSpecBuilder;
|
||||
import com.jayway.restassured.builder.ResponseSpecBuilder;
|
||||
import com.jayway.restassured.http.ContentType;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unused", "unchecked" })
|
||||
public class FlexibleSavingsInterestPostingIntegrationTest {
|
||||
|
||||
public static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL";
|
||||
|
||||
private ResponseSpecification responseSpec;
|
||||
private RequestSpecification requestSpec;
|
||||
private SavingsProductHelper savingsProductHelper;
|
||||
private SavingsAccountHelper savingsAccountHelper;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
Utils.initializeRESTAssured();
|
||||
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||
this.savingsProductHelper = new SavingsProductHelper();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSavingsInterestPostingAtPeriodEnd() {
|
||||
//client activation, savings activation and 1st transaction date
|
||||
final String startDate = "01 December 2013";
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, startDate);
|
||||
Assert.assertNotNull(clientID);
|
||||
|
||||
// Configuring global config flags
|
||||
configureInterestPosting(true, 4);
|
||||
|
||||
final Integer savingsId = createSavingsAccount(clientID, startDate);
|
||||
|
||||
Integer depositTransactionId = (Integer) this.savingsAccountHelper.depositToSavingsAccount(savingsId, "1000",
|
||||
startDate, CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
|
||||
/***
|
||||
* Perform Post interest transaction and verify the posted transaction date
|
||||
*/
|
||||
this.savingsAccountHelper.postInterestForSavings(savingsId);
|
||||
HashMap accountDetails = this.savingsAccountHelper.getSavingsDetails(savingsId);
|
||||
ArrayList<HashMap<String, Object>> transactions = (ArrayList<HashMap<String, Object>>)
|
||||
accountDetails.get("transactions");
|
||||
HashMap<String, Object> interestPostingTransaction = transactions.get(0);
|
||||
for(Entry<String, Object> entry : interestPostingTransaction.entrySet())
|
||||
System.out.println(entry.getKey() + "-" + entry.getValue().toString());
|
||||
//1st Dec 13 to 31st March 14 - 365 days, daily compounding using daily balance
|
||||
//33.7016 obtained from formula in excel provided by Subramanya
|
||||
assertEquals("Equality check for interest posted amount",
|
||||
"33.7016", interestPostingTransaction.get("amount").toString());
|
||||
assertEquals("Date check for Interest Posting transaction",
|
||||
"[2014, 3, 31]", interestPostingTransaction.get("date").toString());
|
||||
|
||||
}
|
||||
|
||||
private Integer createSavingsAccount(final Integer clientID, final String startDate) {
|
||||
final Integer savingsProductID = createSavingsProduct();
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplicationOnDate(clientID,
|
||||
savingsProductID, ACCOUNT_TYPE_INDIVIDUAL, startDate);
|
||||
Assert.assertNotNull(savingsId);
|
||||
HashMap savingsStatusHashMap = this.savingsAccountHelper.approveSavingsOnDate(savingsId, startDate);
|
||||
SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
|
||||
savingsStatusHashMap = this.savingsAccountHelper.activateSavingsAccount(savingsId, startDate);
|
||||
SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
|
||||
return savingsId;
|
||||
}
|
||||
|
||||
private void configureInterestPosting(final Boolean periodEndEnable,
|
||||
final Integer financialYearBeginningMonth) {
|
||||
final ArrayList<HashMap> globalConfig = GlobalConfigurationHelper.getAllGlobalConfigurations(this.requestSpec,
|
||||
this.responseSpec);
|
||||
Assert.assertNotNull(globalConfig);
|
||||
|
||||
// Updating flag for interest posting at period end
|
||||
Integer periodEndConfigId = (Integer) globalConfig.get(10).get("id");
|
||||
Assert.assertNotNull(periodEndConfigId);
|
||||
|
||||
HashMap periodEndConfigData = GlobalConfigurationHelper.getGlobalConfigurationById(this.requestSpec, this.responseSpec,
|
||||
periodEndConfigId.toString());
|
||||
Assert.assertNotNull(periodEndConfigData);
|
||||
|
||||
Boolean enabled = (Boolean) globalConfig.get(10).get("enabled");
|
||||
|
||||
if (enabled != periodEndEnable)
|
||||
periodEndConfigId = GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec,
|
||||
periodEndConfigId.toString(), periodEndEnable);
|
||||
|
||||
|
||||
//Updating value for financial year beginning month
|
||||
Integer financialYearBeginningConfigId = (Integer) globalConfig.get(11).get("id");
|
||||
Assert.assertNotNull(financialYearBeginningConfigId);
|
||||
|
||||
HashMap financialYearBeginningConfigData = GlobalConfigurationHelper.getGlobalConfigurationById(this.requestSpec, this.responseSpec,
|
||||
financialYearBeginningConfigId.toString());
|
||||
Assert.assertNotNull(financialYearBeginningConfigData);
|
||||
|
||||
financialYearBeginningConfigId = GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec,
|
||||
financialYearBeginningConfigId.toString(), financialYearBeginningMonth.toString());
|
||||
Assert.assertNotNull(financialYearBeginningConfigId);
|
||||
}
|
||||
|
||||
private Integer createSavingsProduct() {
|
||||
final String savingsProductJSON = this.savingsProductHelper
|
||||
.withInterestCompoundingPeriodTypeAsDaily()
|
||||
.withInterestPostingPeriodTypeAsAnnual()
|
||||
.withInterestCalculationPeriodTypeAsDailyBalance()
|
||||
.build();
|
||||
return SavingsProductHelper.createSavingsProduct(savingsProductJSON, requestSpec, responseSpec);
|
||||
}
|
||||
|
||||
//Reset configuration fields
|
||||
@After
|
||||
public void tearDown() {
|
||||
configureInterestPosting(false, 1);
|
||||
}
|
||||
|
||||
}
|
||||
+333
@@ -0,0 +1,333 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
import org.mifosplatform.integrationtests.common.funds.FundsHelper;
|
||||
import org.mifosplatform.integrationtests.common.funds.FundsResourceHandler;
|
||||
|
||||
import com.jayway.restassured.builder.RequestSpecBuilder;
|
||||
import com.jayway.restassured.builder.ResponseSpecBuilder;
|
||||
import com.jayway.restassured.http.ContentType;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Funds Integration Test for checking Funds Application.
|
||||
*/
|
||||
public class FundsIntegrationTest {
|
||||
|
||||
private ResponseSpecification statusOkResponseSpec;
|
||||
private RequestSpecification requestSpec;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
Utils.initializeRESTAssured();
|
||||
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
this.statusOkResponseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateFund() {
|
||||
FundsHelper fh = FundsHelper
|
||||
.create(Utils.randomNameGenerator("", 10))
|
||||
.externalId(Utils.randomNameGenerator("fund-", 5))
|
||||
.build();
|
||||
String jsonData = fh.toJSON();
|
||||
|
||||
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
|
||||
Assert.assertNotNull(fundID);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateFundWithEmptyName() {
|
||||
FundsHelper fh = FundsHelper
|
||||
.create(null)
|
||||
.externalId(Utils.randomNameGenerator("fund-", 5))
|
||||
.build();
|
||||
String jsonData = fh.toJSON();
|
||||
|
||||
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build();
|
||||
final Long fundID = createFund(jsonData, this.requestSpec, responseSpec);
|
||||
Assert.assertNull(fundID);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateFundWithEmptyExternalId() {
|
||||
FundsHelper fh = FundsHelper
|
||||
.create(Utils.randomNameGenerator("", 10))
|
||||
.externalId(null)
|
||||
.build();
|
||||
String jsonData = fh.toJSON();
|
||||
|
||||
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
|
||||
Assert.assertNotNull(fundID);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateFundWithDuplicateName() {
|
||||
FundsHelper fh = FundsHelper
|
||||
.create(Utils.randomNameGenerator("", 10))
|
||||
.externalId(Utils.randomNameGenerator("fund-", 5))
|
||||
.build();
|
||||
String jsonData = fh.toJSON();
|
||||
|
||||
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
|
||||
Assert.assertNotNull(fundID);
|
||||
|
||||
FundsHelper fh2 = FundsHelper
|
||||
.create(fh.getName())
|
||||
.externalId(Utils.randomNameGenerator("fund-", 5))
|
||||
.build();
|
||||
jsonData = fh2.toJSON();
|
||||
|
||||
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(403).build();
|
||||
final Long fundID2 = createFund(jsonData, this.requestSpec, responseSpec);
|
||||
Assert.assertNull(fundID2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateFundWithDuplicateExternalId() {
|
||||
FundsHelper fh = FundsHelper
|
||||
.create(Utils.randomNameGenerator("", 10))
|
||||
.externalId(Utils.randomNameGenerator("fund-", 5))
|
||||
.build();
|
||||
String jsonData = fh.toJSON();
|
||||
|
||||
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
|
||||
Assert.assertNotNull(fundID);
|
||||
|
||||
FundsHelper fh2 = FundsHelper
|
||||
.create(Utils.randomNameGenerator("", 10))
|
||||
.externalId(fh.getExternalId())
|
||||
.build();
|
||||
jsonData = fh2.toJSON();
|
||||
|
||||
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(403).build();
|
||||
final Long fundID2 = createFund(jsonData, this.requestSpec, responseSpec);
|
||||
Assert.assertNull(fundID2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateFundWithInvalidName() {
|
||||
FundsHelper fh = FundsHelper
|
||||
.create(Utils.randomNameGenerator("", 120))
|
||||
.externalId(Utils.randomNameGenerator("fund-", 5))
|
||||
.build();
|
||||
String jsonData = fh.toJSON();
|
||||
|
||||
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build();
|
||||
final Long fundID = createFund(jsonData, this.requestSpec, responseSpec);
|
||||
Assert.assertNull(fundID);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateFundWithInvalidExternalId() {
|
||||
FundsHelper fh = FundsHelper
|
||||
.create(Utils.randomNameGenerator("", 10))
|
||||
.externalId(Utils.randomNameGenerator("fund-", 120))
|
||||
.build();
|
||||
String jsonData = fh.toJSON();
|
||||
|
||||
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build();
|
||||
final Long fundID = createFund(jsonData, this.requestSpec, responseSpec);
|
||||
Assert.assertNull(fundID);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRetrieveFund() {
|
||||
FundsHelper fh = FundsHelper
|
||||
.create(Utils.randomNameGenerator("", 10))
|
||||
.externalId(Utils.randomNameGenerator("fund-", 5))
|
||||
.build();
|
||||
String jsonData = fh.toJSON();
|
||||
|
||||
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
|
||||
Assert.assertNotNull(fundID);
|
||||
|
||||
jsonData = FundsResourceHandler.retrieveFund(fundID, this.requestSpec, this.statusOkResponseSpec);
|
||||
FundsHelper fh2 = FundsHelper.fromJSON(jsonData);
|
||||
|
||||
assertEquals(fh.getName(), fh2.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRetrieveAllFunds() {
|
||||
FundsHelper fh = FundsHelper
|
||||
.create(Utils.randomNameGenerator("", 10))
|
||||
.externalId(Utils.randomNameGenerator("fund-", 5))
|
||||
.build();
|
||||
String jsonData = fh.toJSON();
|
||||
|
||||
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
|
||||
Assert.assertNotNull(fundID);
|
||||
|
||||
List<FundsHelper> fhList = FundsResourceHandler.retrieveAllFunds(this.requestSpec, this.statusOkResponseSpec);
|
||||
|
||||
Assert.assertNotNull(fhList);
|
||||
Assert.assertThat(fhList.size(), greaterThanOrEqualTo(1));
|
||||
Assert.assertThat(fhList, hasItem(fh));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRetrieveUnknownFund() {
|
||||
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(404).build();
|
||||
String jsonData = FundsResourceHandler.retrieveFund(Long.MAX_VALUE, this.requestSpec, responseSpec);
|
||||
HashMap<String, String> map = new Gson().fromJson(jsonData, HashMap.class);
|
||||
assertEquals(map.get("userMessageGlobalisationCode"), "error.msg.resource.not.found");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateFund() {
|
||||
FundsHelper fh = FundsHelper
|
||||
.create(Utils.randomNameGenerator("", 10))
|
||||
.externalId(Utils.randomNameGenerator("fund-", 5))
|
||||
.build();
|
||||
String jsonData = fh.toJSON();
|
||||
|
||||
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
|
||||
Assert.assertNotNull(fundID);
|
||||
|
||||
String newName = Utils.randomNameGenerator("", 10);
|
||||
String newExternalId = Utils.randomNameGenerator("fund-", 5);
|
||||
FundsHelper fh2 = FundsResourceHandler.updateFund(fundID, newName, newExternalId, this.requestSpec, this.statusOkResponseSpec);
|
||||
|
||||
Assert.assertEquals(newName, fh2.getName());
|
||||
Assert.assertEquals(newExternalId, fh2.getExternalId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateUnknownFund() {
|
||||
String newName = Utils.randomNameGenerator("", 10);
|
||||
String newExternalId = Utils.randomNameGenerator("fund-", 5);
|
||||
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(404).build();
|
||||
FundsHelper fh = FundsResourceHandler.updateFund(Long.MAX_VALUE, newName, newExternalId, this.requestSpec,
|
||||
responseSpec);
|
||||
Assert.assertNull(fh);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateFundWithInvalidNewName() {
|
||||
FundsHelper fh = FundsHelper
|
||||
.create(Utils.randomNameGenerator("", 10))
|
||||
.externalId(Utils.randomNameGenerator("fund-", 5))
|
||||
.build();
|
||||
String jsonData = fh.toJSON();
|
||||
|
||||
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
|
||||
Assert.assertNotNull(fundID);
|
||||
|
||||
String newName = Utils.randomNameGenerator("", 120);
|
||||
String newExternalId = Utils.randomNameGenerator("fund-", 5);
|
||||
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build();
|
||||
FundsHelper fh2 = FundsResourceHandler.updateFund(fundID, newName, newExternalId, this.requestSpec,
|
||||
responseSpec);
|
||||
|
||||
Assert.assertNull(fh2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateFundWithNewExternalId() {
|
||||
FundsHelper fh = FundsHelper
|
||||
.create(Utils.randomNameGenerator("", 10))
|
||||
.externalId(Utils.randomNameGenerator("fund-", 5))
|
||||
.build();
|
||||
String jsonData = fh.toJSON();
|
||||
|
||||
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
|
||||
Assert.assertNotNull(fundID);
|
||||
|
||||
String newExternalId = Utils.randomNameGenerator("fund-", 5);
|
||||
FundsHelper fh2 = FundsResourceHandler.updateFund(fundID, null, newExternalId, this.requestSpec, this.statusOkResponseSpec);
|
||||
|
||||
Assert.assertEquals(newExternalId, fh2.getExternalId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateFundWithInvalidNewExternalId() {
|
||||
FundsHelper fh = FundsHelper
|
||||
.create(Utils.randomNameGenerator("", 10))
|
||||
.externalId(Utils.randomNameGenerator("fund-", 5))
|
||||
.build();
|
||||
String jsonData = fh.toJSON();
|
||||
|
||||
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
|
||||
Assert.assertNotNull(fundID);
|
||||
|
||||
String newName = Utils.randomNameGenerator("", 10);
|
||||
String newExternalId = Utils.randomNameGenerator("fund-", 120);
|
||||
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(400).build();
|
||||
FundsHelper fh2 = FundsResourceHandler.updateFund(fundID, newName, newExternalId, this.requestSpec,
|
||||
responseSpec);
|
||||
|
||||
Assert.assertNull(fh2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateFundWithNewName() {
|
||||
FundsHelper fh = FundsHelper
|
||||
.create(Utils.randomNameGenerator("", 10))
|
||||
.externalId(Utils.randomNameGenerator("fund-", 5))
|
||||
.build();
|
||||
String jsonData = fh.toJSON();
|
||||
|
||||
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
|
||||
Assert.assertNotNull(fundID);
|
||||
|
||||
String newName = Utils.randomNameGenerator("", 10);
|
||||
FundsHelper fh2 = FundsResourceHandler.updateFund(fundID, newName, null, this.requestSpec, this.statusOkResponseSpec);
|
||||
|
||||
Assert.assertEquals(newName, fh2.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateFundWithEmptyParams() {
|
||||
FundsHelper fh = FundsHelper
|
||||
.create(Utils.randomNameGenerator("", 10))
|
||||
.externalId(Utils.randomNameGenerator("fund-", 5))
|
||||
.build();
|
||||
String jsonData = fh.toJSON();
|
||||
|
||||
final Long fundID = createFund(jsonData, this.requestSpec, this.statusOkResponseSpec);
|
||||
Assert.assertNotNull(fundID);
|
||||
|
||||
FundsHelper fh2 = FundsResourceHandler.updateFund(fundID, null, null, this.requestSpec, this.statusOkResponseSpec);
|
||||
|
||||
Assert.assertNull(fh2.getName());
|
||||
Assert.assertNull(fh2.getExternalId());
|
||||
|
||||
// assert that there was no change in
|
||||
// the name and external ID of the fund
|
||||
jsonData = FundsResourceHandler.retrieveFund(fundID, this.requestSpec, this.statusOkResponseSpec);
|
||||
FundsHelper fh3 = new Gson().fromJson(jsonData, FundsHelper.class);
|
||||
|
||||
Assert.assertEquals(fh.getName(), fh3.getName());
|
||||
Assert.assertEquals(fh.getExternalId(), fh3.getExternalId());
|
||||
}
|
||||
|
||||
private Long createFund(final String fundJSON,
|
||||
final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec) {
|
||||
String fundId = String.valueOf(FundsResourceHandler.createFund(fundJSON, requestSpec, responseSpec));
|
||||
if (fundId.equals("null")) {
|
||||
// Invalid JSON data parameters
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Long(fundId);
|
||||
}
|
||||
|
||||
}
|
||||
+5
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
+9
-4
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -93,22 +98,22 @@ public class GroupLoanIntegrationTest {
|
||||
private void verifyLoanRepaymentSchedule(final ArrayList<HashMap> loanSchedule) {
|
||||
System.out.println("--------------------VERIFYING THE PRINCIPAL DUES,INTEREST DUE AND DUE DATE--------------------------");
|
||||
|
||||
assertEquals("Checking for Due Date for 1st Month", new ArrayList<Integer>(Arrays.asList(2011, 10, 20)),
|
||||
assertEquals("Checking for Due Date for 1st Month", new ArrayList<>(Arrays.asList(2011, 10, 20)),
|
||||
loanSchedule.get(1).get("dueDate"));
|
||||
assertEquals("Checking for Principal Due for 1st Month", new Float("2911.49"), loanSchedule.get(1).get("principalOriginalDue"));
|
||||
assertEquals("Checking for Interest Due for 1st Month", new Float("240.00"), loanSchedule.get(1).get("interestOriginalDue"));
|
||||
|
||||
assertEquals("Checking for Due Date for 2nd Month", new ArrayList<Integer>(Arrays.asList(2011, 11, 20)),
|
||||
assertEquals("Checking for Due Date for 2nd Month", new ArrayList<>(Arrays.asList(2011, 11, 20)),
|
||||
loanSchedule.get(2).get("dueDate"));
|
||||
assertEquals("Checking for Principal Due for 2nd Month", new Float("2969.71"), loanSchedule.get(2).get("principalDue"));
|
||||
assertEquals("Checking for Interest Due for 2nd Month", new Float("181.77"), loanSchedule.get(2).get("interestOriginalDue"));
|
||||
|
||||
assertEquals("Checking for Due Date for 3rd Month", new ArrayList<Integer>(Arrays.asList(2011, 12, 20)),
|
||||
assertEquals("Checking for Due Date for 3rd Month", new ArrayList<>(Arrays.asList(2011, 12, 20)),
|
||||
loanSchedule.get(3).get("dueDate"));
|
||||
assertEquals("Checking for Principal Due for 3rd Month", new Float("3029.1"), loanSchedule.get(3).get("principalDue"));
|
||||
assertEquals("Checking for Interest Due for 3rd Month", new Float("122.38"), loanSchedule.get(3).get("interestOriginalDue"));
|
||||
|
||||
assertEquals("Checking for Due Date for 4th Month", new ArrayList<Integer>(Arrays.asList(2012, 1, 20)),
|
||||
assertEquals("Checking for Due Date for 4th Month", new ArrayList<>(Arrays.asList(2012, 1, 20)),
|
||||
loanSchedule.get(4).get("dueDate"));
|
||||
assertEquals("Checking for Principal Due for 4th Month", new Float("3089.7"), loanSchedule.get(4).get("principalDue"));
|
||||
assertEquals("Checking for Interest Due for 4th Month", new Float("61.79"), loanSchedule.get(4).get("interestOriginalDue"));
|
||||
|
||||
+99
-10
@@ -1,13 +1,22 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -63,7 +72,11 @@ public class GroupSavingsIntegrationTest {
|
||||
groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientID.toString());
|
||||
Assert.assertNotNull(groupID);
|
||||
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE);
|
||||
final String minBalanceForInterestCalculation = null;
|
||||
final String minRequiredBalance = null;
|
||||
final String enforceMinRequiredBalance = "false";
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
|
||||
minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(groupID, savingsProductID, ACCOUNT_TYPE_GROUP);
|
||||
@@ -93,9 +106,12 @@ public class GroupSavingsIntegrationTest {
|
||||
final Object savingsInterest = this.savingsAccountHelper.getSavingsInterest(savingsId);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testSavingsAccount_CLOSE_APPLICATION() {
|
||||
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||
final ResponseSpecification errorResponse = new ResponseSpecBuilder().expectStatusCode(400).build();
|
||||
final SavingsAccountHelper validationErrorHelper = new SavingsAccountHelper(this.requestSpec, errorResponse);
|
||||
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientID);
|
||||
@@ -106,7 +122,11 @@ public class GroupSavingsIntegrationTest {
|
||||
groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientID.toString());
|
||||
Assert.assertNotNull(groupID);
|
||||
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, null);
|
||||
final String minBalanceForInterestCalculation = null;
|
||||
final String minRequiredBalance = "1000.0";
|
||||
final String enforceMinRequiredBalance = "true";
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
|
||||
minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(groupID, savingsProductID, ACCOUNT_TYPE_GROUP);
|
||||
@@ -121,7 +141,17 @@ public class GroupSavingsIntegrationTest {
|
||||
savingsStatusHashMap = this.savingsAccountHelper.activateSavings(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
|
||||
|
||||
savingsStatusHashMap = this.savingsAccountHelper.closeSavingsAccount(savingsId);
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
final String CLOSEDON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
String withdrawBalance = "false";
|
||||
ArrayList<HashMap> savingsAccountErrorData = (ArrayList<HashMap>) validationErrorHelper.closeSavingsAccountAndGetBackRequiredField(
|
||||
savingsId, withdrawBalance, CommonConstants.RESPONSE_ERROR, CLOSEDON_DATE);
|
||||
assertEquals("validation.msg.savingsaccount.close.results.in.balance.not.zero",
|
||||
savingsAccountErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
withdrawBalance = "true";
|
||||
savingsStatusHashMap = this.savingsAccountHelper.closeSavingsAccount(savingsId, withdrawBalance);
|
||||
SavingsStatusChecker.verifySavingsAccountIsClosed(savingsStatusHashMap);
|
||||
}
|
||||
|
||||
@@ -142,7 +172,11 @@ public class GroupSavingsIntegrationTest {
|
||||
groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientID.toString());
|
||||
Assert.assertNotNull(groupID);
|
||||
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, null);
|
||||
final String minBalanceForInterestCalculation = null;
|
||||
final String minRequiredBalance = null;
|
||||
final String enforceMinRequiredBalance = "false";
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
|
||||
minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(groupID, savingsProductID, ACCOUNT_TYPE_GROUP);
|
||||
@@ -187,7 +221,11 @@ public class GroupSavingsIntegrationTest {
|
||||
groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientID.toString());
|
||||
Assert.assertNotNull(groupID);
|
||||
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE);
|
||||
final String minBalanceForInterestCalculation = null;
|
||||
final String minRequiredBalance = null;
|
||||
final String enforceMinRequiredBalance = "false";
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
|
||||
minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(groupID, savingsProductID, ACCOUNT_TYPE_GROUP);
|
||||
@@ -233,7 +271,11 @@ public class GroupSavingsIntegrationTest {
|
||||
groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientID.toString());
|
||||
Assert.assertNotNull(groupID);
|
||||
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE);
|
||||
final String minBalanceForInterestCalculation = null;
|
||||
final String minRequiredBalance = null;
|
||||
final String enforceMinRequiredBalance = "false";
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
|
||||
minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(groupID, savingsProductID, ACCOUNT_TYPE_GROUP);
|
||||
@@ -263,7 +305,11 @@ public class GroupSavingsIntegrationTest {
|
||||
groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientID.toString());
|
||||
Assert.assertNotNull(groupID);
|
||||
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE);
|
||||
final String minBalanceForInterestCalculation = null;
|
||||
final String minRequiredBalance = null;
|
||||
final String enforceMinRequiredBalance = "false";
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
|
||||
minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(groupID, savingsProductID, ACCOUNT_TYPE_GROUP);
|
||||
@@ -363,7 +409,11 @@ public class GroupSavingsIntegrationTest {
|
||||
groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientID.toString());
|
||||
Assert.assertNotNull(groupID);
|
||||
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE);
|
||||
final String minBalanceForInterestCalculation = null;
|
||||
final String minRequiredBalance = null;
|
||||
final String enforceMinRequiredBalance = "false";
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
|
||||
minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(groupID, savingsProductID, ACCOUNT_TYPE_GROUP);
|
||||
@@ -407,7 +457,7 @@ public class GroupSavingsIntegrationTest {
|
||||
Assert.assertEquals(1, charges.size());
|
||||
|
||||
HashMap savingsChargeForPay = charges.get(0);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(CommonConstants.dateFormat);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(CommonConstants.dateFormat, Locale.US);
|
||||
Calendar cal = Calendar.getInstance();
|
||||
List dates = (List) savingsChargeForPay.get("dueDate");
|
||||
cal.set(Calendar.YEAR, (Integer) dates.get(0));
|
||||
@@ -431,16 +481,55 @@ public class GroupSavingsIntegrationTest {
|
||||
this.savingsAccountHelper.waiveCharge((Integer) savingsChargeForWaive.get("id"), savingsId);
|
||||
HashMap waiveCharge = this.savingsAccountHelper.getSavingsCharge(savingsId, (Integer) savingsChargeForWaive.get("id"));
|
||||
assertEquals(savingsChargeForWaive.get("amount"), waiveCharge.get("amountWaived"));
|
||||
|
||||
this.savingsAccountHelper.waiveCharge((Integer) savingsChargeForWaive.get("id"), savingsId);
|
||||
waiveCharge = this.savingsAccountHelper.getSavingsCharge(savingsId, (Integer) savingsChargeForWaive.get("id"));
|
||||
BigDecimal totalWaiveAmount = BigDecimal.valueOf(Double.valueOf((Float) savingsChargeForWaive.get("amount")));
|
||||
totalWaiveAmount = totalWaiveAmount.add(totalWaiveAmount);
|
||||
assertEquals(totalWaiveAmount.floatValue(), waiveCharge.get("amountWaived"));
|
||||
|
||||
final Integer weeklyFeeId = ChargesHelper.createCharges(this.requestSpec, this.responseSpec, ChargesHelper.getSavingsWeeklyFeeJSON());
|
||||
Assert.assertNotNull(weeklyFeeId);
|
||||
|
||||
this.savingsAccountHelper.addChargesForSavings(savingsId, weeklyFeeId);
|
||||
charges = this.savingsAccountHelper.getSavingsCharges(savingsId);
|
||||
Assert.assertEquals(3, charges.size());
|
||||
|
||||
savingsChargeForPay = charges.get(2);
|
||||
cal = Calendar.getInstance();
|
||||
dates = (List) savingsChargeForPay.get("dueDate");
|
||||
cal.set(Calendar.YEAR, (Integer) dates.get(0));
|
||||
cal.set(Calendar.MONTH, (Integer) dates.get(1) - 1);
|
||||
cal.set(Calendar.DAY_OF_MONTH, (Integer) dates.get(2));
|
||||
|
||||
// Depositing huge amount as scheduler job deducts the fee amount
|
||||
Integer depositTransactionId = (Integer) this.savingsAccountHelper.depositToSavingsAccount(savingsId, "100000",
|
||||
SavingsAccountHelper.TRANSACTION_DATE, CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
Assert.assertNotNull(depositTransactionId);
|
||||
|
||||
this.savingsAccountHelper.payCharge((Integer) savingsChargeForPay.get("id"), savingsId,
|
||||
((Float) savingsChargeForPay.get("amount")).toString(), sdf.format(cal.getTime()));
|
||||
paidCharge = this.savingsAccountHelper.getSavingsCharge(savingsId, (Integer) savingsChargeForPay.get("id"));
|
||||
assertEquals(savingsChargeForPay.get("amount"), paidCharge.get("amountPaid"));
|
||||
List nextDueDates = (List) paidCharge.get("dueDate");
|
||||
LocalDate nextDueDate = new LocalDate((Integer) nextDueDates.get(0), (Integer) nextDueDates.get(1), (Integer) nextDueDates.get(2));
|
||||
LocalDate expectedNextDueDate = new LocalDate((Integer) dates.get(0), (Integer) dates.get(1), (Integer) dates.get(2))
|
||||
.plusWeeks((Integer) paidCharge.get("feeInterval"));
|
||||
assertEquals(expectedNextDueDate, nextDueDate);
|
||||
}
|
||||
|
||||
public static Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String minOpenningBalance) {
|
||||
final String minOpenningBalance, final String minBalanceForInterestCalculation, final String minRequiredBalance,
|
||||
final String enforceMinRequiredBalance) {
|
||||
System.out.println("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------");
|
||||
SavingsProductHelper savingsProductHelper = new SavingsProductHelper();
|
||||
final String savingsProductJSON = savingsProductHelper //
|
||||
.withInterestCompoundingPeriodTypeAsDaily() //
|
||||
.withInterestPostingPeriodTypeAsMonthly() //
|
||||
.withInterestCalculationPeriodTypeAsDailyBalance() //
|
||||
.withMinBalanceForInterestCalculation(minBalanceForInterestCalculation) //
|
||||
.withMinRequiredBalance(minRequiredBalance) //
|
||||
.withEnforceMinRequiredBalance(enforceMinRequiredBalance) //
|
||||
.withMinimumOpenningBalance(minOpenningBalance).build();
|
||||
return SavingsProductHelper.createSavingsProduct(savingsProductJSON, requestSpec, responseSpec);
|
||||
}
|
||||
|
||||
Regular → Executable
+111
@@ -1,9 +1,16 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mifosplatform.integrationtests.common.ClientHelper;
|
||||
import org.mifosplatform.integrationtests.common.GroupHelper;
|
||||
import org.mifosplatform.integrationtests.common.StaffHelper;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
|
||||
import com.jayway.restassured.builder.RequestSpecBuilder;
|
||||
@@ -11,6 +18,16 @@ import com.jayway.restassured.builder.ResponseSpecBuilder;
|
||||
import com.jayway.restassured.http.ContentType;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
import org.mifosplatform.integrationtests.common.accounting.Account;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanApplicationTestBuilder;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanProductTestBuilder;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanTransactionHelper;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
|
||||
/**
|
||||
* Group Test for checking Group: Creation, Activation, Client Association,
|
||||
@@ -20,6 +37,12 @@ public class GroupTest {
|
||||
|
||||
private ResponseSpecification responseSpec;
|
||||
private RequestSpecification requestSpec;
|
||||
private LoanTransactionHelper loanTransactionHelper;
|
||||
private String principal = "10000.00";
|
||||
private String accountingRule = "1";
|
||||
private String numberOfRepayments = "5";
|
||||
private String interestRatePerPeriod = "18";
|
||||
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
@@ -27,6 +50,8 @@ public class GroupTest {
|
||||
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -53,4 +78,90 @@ public class GroupTest {
|
||||
// GroupHelper.deleteGroup(this.requestSpec, this.responseSpec, groupID.toString());
|
||||
// GroupHelper.verifyGroupDeleted(this.requestSpec, this.responseSpec, groupID);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void assignStaffToGroup(){
|
||||
Integer groupID = GroupHelper.createGroup(this.requestSpec, this.responseSpec);
|
||||
GroupHelper.verifyGroupCreatedOnServer(this.requestSpec, this.responseSpec, groupID);
|
||||
|
||||
final String updateGroupName = Utils.randomNameGenerator("Savings Group Help_",5);
|
||||
groupID = GroupHelper.activateGroup(this.requestSpec, this.responseSpec, groupID.toString());
|
||||
Integer updateGroupId = GroupHelper.updateGroup(this.requestSpec,this.responseSpec,updateGroupName,groupID.toString());
|
||||
|
||||
//create client and add client to group
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientID.toString());
|
||||
GroupHelper.verifyGroupMembers(this.requestSpec, this.responseSpec, groupID, clientID);
|
||||
|
||||
|
||||
//create staff
|
||||
Integer createStaffId1 = StaffHelper.createStaff(this.requestSpec, this.responseSpec) ;
|
||||
System.out.println("--------------creating first staff with id-------------" + createStaffId1);
|
||||
Assert.assertNotNull(createStaffId1);
|
||||
|
||||
Integer createStaffId2 = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
|
||||
System.out.println("--------------creating second staff with id-------------" + createStaffId2);
|
||||
Assert.assertNotNull(createStaffId2);
|
||||
|
||||
//assign staff "createStaffId1" to group
|
||||
HashMap assignStaffGroupId = (HashMap)GroupHelper.assignStaff(this.requestSpec,this.responseSpec,groupID.toString(),createStaffId1.longValue());
|
||||
assertEquals("Verify assigned staff id is the same as id sent",assignStaffGroupId.get("staffId"),createStaffId1);
|
||||
|
||||
|
||||
|
||||
//assign staff "createStaffId2" to client
|
||||
final HashMap assignStaffToClientChanges = (HashMap)ClientHelper.assignStaffToClient(this.requestSpec,this.responseSpec,clientID.toString(),createStaffId2.toString());
|
||||
assertEquals("Verify assigned staff id is the same as id sent", assignStaffToClientChanges.get("staffId"),createStaffId2);
|
||||
|
||||
|
||||
final Integer loanProductId = this.createLoanProduct();
|
||||
|
||||
final Integer loanId = this.applyForLoanApplication(clientID,loanProductId,this.principal);
|
||||
|
||||
this.loanTransactionHelper.approveLoan("20 September 2014",loanId);
|
||||
this.loanTransactionHelper.disburseLoan("20 September 2014",loanId);
|
||||
|
||||
final HashMap assignStaffAndInheritStaffForClientAccounts = (HashMap)GroupHelper.assignStaffInheritStaffForClientAccounts(this.requestSpec,this.responseSpec,groupID.toString(),createStaffId1.toString());
|
||||
final Integer getClientStaffId = ClientHelper.getClient(this.requestSpec,this.responseSpec,clientID.toString());
|
||||
|
||||
//assert if client staff officer has change Note client was assigned staff with createStaffId2
|
||||
assertNotEquals("Verify if client stuff has changed", assignStaffAndInheritStaffForClientAccounts.get("staffId"), createStaffId2);
|
||||
assertEquals("Verify if client inherited staff assigned above", assignStaffAndInheritStaffForClientAccounts.get("staffId"), getClientStaffId);
|
||||
|
||||
//assert if clients loan officer has changed
|
||||
final Integer loanOfficerId = this.loanTransactionHelper.getLoanOfficerId(loanId.toString());
|
||||
assertEquals("Verify if client loan inherited staff", assignStaffAndInheritStaffForClientAccounts.get("staffId"), loanOfficerId);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private Integer createLoanProduct() {
|
||||
final String loanProductJSON = new LoanProductTestBuilder()
|
||||
.withPrincipal(this.principal)
|
||||
.withNumberOfRepayments(this.numberOfRepayments)
|
||||
.withinterestRatePerPeriod(this.interestRatePerPeriod)
|
||||
.withInterestRateFrequencyTypeAsYear()
|
||||
.build(null);
|
||||
return this.loanTransactionHelper.getLoanProductId(loanProductJSON);
|
||||
}
|
||||
|
||||
private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID, String principal) {
|
||||
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
|
||||
final String loanApplicationJSON = new LoanApplicationTestBuilder() //
|
||||
.withPrincipal(principal) //
|
||||
.withLoanTermFrequency("4") //
|
||||
.withLoanTermFrequencyAsMonths() //
|
||||
.withNumberOfRepayments("4") //
|
||||
.withRepaymentEveryAfter("1") //
|
||||
.withRepaymentFrequencyTypeAsMonths() //
|
||||
.withInterestRatePerPeriod("2") //
|
||||
.withAmortizationTypeAsEqualInstallments() //
|
||||
.withInterestTypeAsDecliningBalance() //
|
||||
.withInterestCalculationPeriodTypeSameAsRepaymentPeriod() //
|
||||
.withExpectedDisbursementDate("20 September 2014") //
|
||||
.withSubmittedOnDate("20 September 2014") //
|
||||
.build(clientID.toString(), loanProductID.toString(), null);
|
||||
return this.loanTransactionHelper.getLoanId(loanApplicationJSON);
|
||||
}
|
||||
|
||||
}
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.http.conn.HttpHostConnectException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mifosplatform.integrationtests.common.HookHelper;
|
||||
import org.mifosplatform.integrationtests.common.OfficeHelper;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
|
||||
import com.jayway.restassured.RestAssured;
|
||||
import com.jayway.restassured.builder.RequestSpecBuilder;
|
||||
import com.jayway.restassured.builder.ResponseSpecBuilder;
|
||||
import com.jayway.restassured.http.ContentType;
|
||||
import com.jayway.restassured.path.json.JsonPath;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
public class HookIntegrationTest {
|
||||
|
||||
private RequestSpecification requestSpec;
|
||||
private ResponseSpecification responseSpec;
|
||||
|
||||
private HookHelper hookHelper;
|
||||
private OfficeHelper officeHelper;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
Utils.initializeRESTAssured();
|
||||
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
this.hookHelper = new HookHelper(this.requestSpec, this.responseSpec);
|
||||
this.officeHelper = new OfficeHelper(this.requestSpec, this.responseSpec);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldSendOfficeCreationNotification() {
|
||||
// Subject to https://echo-webhook.herokuapp.com being up
|
||||
// See
|
||||
// http://www.jamesward.com/2014/06/11/testing-webhooks-was-a-pain-so-i-fixed-the-glitch
|
||||
final String payloadURL = "http://echo-webhook.herokuapp.com:80/Z7RXoCBdLSFMDrpn?";
|
||||
this.hookHelper.createHook(payloadURL);
|
||||
final Integer createdOfficeID = this.officeHelper.createOffice("01 January 2012");
|
||||
try {
|
||||
|
||||
/**
|
||||
* sleep for a three seconds after each failure to increase the
|
||||
* likelihood of the previous request for creating office completing
|
||||
**/
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
try {
|
||||
final String json = RestAssured.get(payloadURL.replace("?", "")).asString();
|
||||
final Integer notificationOfficeId = JsonPath.with(json).get("officeId");
|
||||
assertEquals("Equality check for created officeId and hook received payload officeId", createdOfficeID,
|
||||
notificationOfficeId);
|
||||
System.out.println("Notification Office Id - " + notificationOfficeId);
|
||||
i = 6;
|
||||
} catch (Exception e) {
|
||||
TimeUnit.SECONDS.sleep(3);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (final Exception e) {
|
||||
if (e instanceof HttpHostConnectException) {
|
||||
fail("Failed to connect to https://echo-webhook.herokuapp.com platform");
|
||||
}
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.jayway.restassured.builder.RequestSpecBuilder;
|
||||
import com.jayway.restassured.builder.ResponseSpecBuilder;
|
||||
import com.jayway.restassured.http.ContentType;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
import org.mifosplatform.integrationtests.common.ClientHelper;
|
||||
import org.mifosplatform.integrationtests.common.CommonConstants;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanApplicationTestBuilder;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanProductTestBuilder;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanStatusChecker;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanTransactionHelper;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class LoanApplicationApprovalTest {
|
||||
|
||||
private ResponseSpecification responseSpec;
|
||||
private ResponseSpecification responseSpecForStatusCode403;
|
||||
private RequestSpecification requestSpec;
|
||||
private LoanTransactionHelper loanTransactionHelper;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
Utils.initializeRESTAssured();
|
||||
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
this.responseSpecForStatusCode403 = new ResponseSpecBuilder().expectStatusCode(403).build();
|
||||
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||
}
|
||||
|
||||
/*
|
||||
* Positive test case: Approved amount non zero is less than proposed amount
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void loanApplicationApprovedAmountLessThanProposedAmount() {
|
||||
|
||||
final String proposedAmount = "8000";
|
||||
final String approvalAmount = "5000";
|
||||
final String approveDate = "20 September 2012";
|
||||
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2012");
|
||||
final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder().build(null));
|
||||
final Integer loanID = applyForLoanApplication(clientID, loanProductID, proposedAmount);
|
||||
|
||||
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
|
||||
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
|
||||
|
||||
loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount(approveDate, approvalAmount, loanID);
|
||||
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Negative test case: Approved amount non zero is greater than proposed amount
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void loanApplicationApprovedAmountGreaterThanProposedAmount() {
|
||||
|
||||
final String proposedAmount = "5000";
|
||||
final String approvalAmount = "9000";
|
||||
final String approveDate = "20 September 2011";
|
||||
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2012");
|
||||
final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder().build(null));
|
||||
final Integer loanID = applyForLoanApplication(clientID, loanProductID, proposedAmount);
|
||||
|
||||
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
|
||||
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
|
||||
|
||||
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpecForStatusCode403);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<HashMap> error = (List<HashMap>) this.loanTransactionHelper.approveLoanWithApproveAmount(approveDate, approvalAmount, loanID,
|
||||
CommonConstants.RESPONSE_ERROR);
|
||||
|
||||
assertEquals("error.msg.loan.approval.amount.can't.be.greater.than.loan.amount.demanded", error
|
||||
.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
}
|
||||
|
||||
private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID, final String proposedAmount) {
|
||||
final String loanApplication = new LoanApplicationTestBuilder().withPrincipal(proposedAmount).withLoanTermFrequency("5")
|
||||
.withLoanTermFrequencyAsMonths().withNumberOfRepayments("5").withRepaymentEveryAfter("1")
|
||||
.withRepaymentFrequencyTypeAsMonths().withInterestRatePerPeriod("2").withExpectedDisbursementDate("04 April 2012")
|
||||
.withSubmittedOnDate("02 April 2012").build(clientID.toString(), loanProductID.toString(), null);
|
||||
return this.loanTransactionHelper.getLoanId(loanApplication);
|
||||
}
|
||||
}
|
||||
+206
@@ -0,0 +1,206 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mifosplatform.integrationtests.common.ClientHelper;
|
||||
import org.mifosplatform.integrationtests.common.LoanRescheduleRequestHelper;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanApplicationTestBuilder;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanProductTestBuilder;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanRescheduleRequestTestBuilder;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanTransactionHelper;
|
||||
|
||||
import com.jayway.restassured.builder.RequestSpecBuilder;
|
||||
import com.jayway.restassured.builder.ResponseSpecBuilder;
|
||||
import com.jayway.restassured.http.ContentType;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
/**
|
||||
* Test the creation, approval and rejection of a loan reschedule request
|
||||
**/
|
||||
@SuppressWarnings({ "rawtypes" })
|
||||
public class LoanRescheduleRequestTest {
|
||||
private ResponseSpecification responseSpec;
|
||||
private ResponseSpecification generalResponseSpec;
|
||||
private RequestSpecification requestSpec;
|
||||
private LoanTransactionHelper loanTransactionHelper;
|
||||
private LoanRescheduleRequestHelper loanRescheduleRequestHelper;
|
||||
private Integer clientId;
|
||||
private Integer loanProductId;
|
||||
private Integer loanId;
|
||||
private Integer loanRescheduleRequestId;
|
||||
private String loanPrincipalAmount = "100000.00";
|
||||
private String numberOfRepayments = "12";
|
||||
private String interestRatePerPeriod = "18";
|
||||
private String dateString = "4 September 2014";
|
||||
|
||||
@Before
|
||||
public void initialize() {
|
||||
Utils.initializeRESTAssured();
|
||||
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||
this.loanRescheduleRequestHelper = new LoanRescheduleRequestHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
this.generalResponseSpec = new ResponseSpecBuilder().build();
|
||||
|
||||
// create all required entities
|
||||
this.createRequiredEntities();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the client, loan product, and loan entities
|
||||
**/
|
||||
private void createRequiredEntities() {
|
||||
this.createClientEntity();
|
||||
this.createLoanProductEntity();
|
||||
this.createLoanEntity();
|
||||
}
|
||||
|
||||
/**
|
||||
* create a new client
|
||||
**/
|
||||
private void createClientEntity() {
|
||||
this.clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
|
||||
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, this.clientId);
|
||||
}
|
||||
|
||||
/**
|
||||
* create a new loan product
|
||||
**/
|
||||
private void createLoanProductEntity() {
|
||||
System.out.println("---------------------------------CREATING LOAN PRODUCT------------------------------------------");
|
||||
|
||||
final String loanProductJSON = new LoanProductTestBuilder()
|
||||
.withPrincipal(loanPrincipalAmount)
|
||||
.withNumberOfRepayments(numberOfRepayments)
|
||||
.withinterestRatePerPeriod(interestRatePerPeriod)
|
||||
.withInterestRateFrequencyTypeAsYear()
|
||||
.build(null);
|
||||
|
||||
this.loanProductId = this.loanTransactionHelper.getLoanProductId(loanProductJSON);
|
||||
System.out.println("Successfully created loan product (ID: " + this.loanProductId + ")");
|
||||
}
|
||||
|
||||
/**
|
||||
* submit a new loan application, approve and disburse the loan
|
||||
**/
|
||||
private void createLoanEntity() {
|
||||
System.out.println("---------------------------------NEW LOAN APPLICATION------------------------------------------");
|
||||
|
||||
final String loanApplicationJSON = new LoanApplicationTestBuilder()
|
||||
.withPrincipal(loanPrincipalAmount)
|
||||
.withLoanTermFrequency(numberOfRepayments)
|
||||
.withLoanTermFrequencyAsMonths()
|
||||
.withNumberOfRepayments(numberOfRepayments)
|
||||
.withRepaymentEveryAfter("1")
|
||||
.withRepaymentFrequencyTypeAsMonths()
|
||||
.withAmortizationTypeAsEqualInstallments()
|
||||
.withInterestCalculationPeriodTypeAsDays()
|
||||
.withInterestRatePerPeriod(interestRatePerPeriod)
|
||||
.withLoanTermFrequencyAsMonths()
|
||||
.withSubmittedOnDate(dateString)
|
||||
.withExpectedDisbursementDate(dateString)
|
||||
.withPrincipalGrace("2")
|
||||
.withInterestGrace("2")
|
||||
.build(this.clientId.toString(), this.loanProductId.toString(), null);
|
||||
|
||||
this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON);
|
||||
|
||||
System.out.println("Sucessfully created loan (ID: " + this.loanId + ")");
|
||||
|
||||
this.approveLoanApplication();
|
||||
this.disburseLoan();
|
||||
}
|
||||
|
||||
/**
|
||||
* approve the loan application
|
||||
**/
|
||||
private void approveLoanApplication() {
|
||||
|
||||
if(this.loanId != null) {
|
||||
this.loanTransactionHelper.approveLoan(this.dateString, this.loanId);
|
||||
System.out.println("Successfully approved loan (ID: " + this.loanId + ")");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* disburse the newly created loan
|
||||
**/
|
||||
private void disburseLoan() {
|
||||
|
||||
if(this.loanId != null) {
|
||||
this.loanTransactionHelper.disburseLoan(this.dateString, this.loanId);
|
||||
System.out.println("Successfully disbursed loan (ID: " + this.loanId + ")");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* create new loan reschedule request
|
||||
**/
|
||||
private void createLoanRescheduleRequest() {
|
||||
System.out.println("---------------------------------CREATING LOAN RESCHEDULE REQUEST------------------------------------------");
|
||||
|
||||
final String requestJSON = new LoanRescheduleRequestTestBuilder().build(this.loanId.toString());
|
||||
|
||||
this.loanRescheduleRequestId = this.loanRescheduleRequestHelper.createLoanRescheduleRequest(requestJSON);
|
||||
this.loanRescheduleRequestHelper.verifyCreationOfLoanRescheduleRequest(this.loanRescheduleRequestId);
|
||||
|
||||
System.out.println("Successfully created loan reschedule request (ID: " + this.loanRescheduleRequestId + ")");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateLoanRescheduleRequest() {
|
||||
this.createLoanRescheduleRequest();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRejectLoanRescheduleRequest() {
|
||||
this.createLoanRescheduleRequest();
|
||||
|
||||
System.out.println("-----------------------------REJECTING LOAN RESCHEDULE REQUEST--------------------------");
|
||||
|
||||
final String requestJSON = new LoanRescheduleRequestTestBuilder().getRejectLoanRescheduleRequestJSON();
|
||||
this.loanRescheduleRequestHelper.rejectLoanRescheduleRequest(this.loanRescheduleRequestId, requestJSON);
|
||||
|
||||
final HashMap response = (HashMap) this.loanRescheduleRequestHelper.getLoanRescheduleRequest(loanRescheduleRequestId, "statusEnum");
|
||||
assertTrue((Boolean)response.get("rejected"));
|
||||
|
||||
System.out.println("Successfully rejected loan reschedule request (ID: " + this.loanRescheduleRequestId + ")");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testApproveLoanRescheduleRequest() {
|
||||
this.createLoanRescheduleRequest();
|
||||
|
||||
System.out.println("-----------------------------APPROVING LOAN RESCHEDULE REQUEST--------------------------");
|
||||
|
||||
final String requestJSON = new LoanRescheduleRequestTestBuilder().getApproveLoanRescheduleRequestJSON();
|
||||
this.loanRescheduleRequestHelper.approveLoanRescheduleRequest(this.loanRescheduleRequestId, requestJSON);
|
||||
|
||||
final HashMap response = (HashMap) this.loanRescheduleRequestHelper.getLoanRescheduleRequest(loanRescheduleRequestId, "statusEnum");
|
||||
assertTrue((Boolean)response.get("approved"));
|
||||
|
||||
final Integer numberOfRepayments = (Integer) this.loanTransactionHelper.getLoanDetail(requestSpec, generalResponseSpec, loanId, "numberOfRepayments");
|
||||
final HashMap loanSummary = this.loanTransactionHelper.getLoanSummary(requestSpec, generalResponseSpec, loanId);
|
||||
final Float totalExpectedRepayment = (Float) loanSummary.get("totalExpectedRepayment");
|
||||
|
||||
assertEquals("NUMBER OF REPAYMENTS SHOULD BE 16, NOT 12", "16", numberOfRepayments.toString());
|
||||
assertEquals("TOTAL EXPECTED REPAYMENT MUST BE EQUAL TO 118000.0", "118000.0", totalExpectedRepayment.toString());
|
||||
|
||||
System.out.println("Successfully approved loan reschedule request (ID: " + this.loanRescheduleRequestId + ")");
|
||||
}
|
||||
}
|
||||
+5
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
+5
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
+207
@@ -0,0 +1,207 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mifosplatform.integrationtests.common.CalendarHelper;
|
||||
import org.mifosplatform.integrationtests.common.ClientHelper;
|
||||
import org.mifosplatform.integrationtests.common.CommonConstants;
|
||||
import org.mifosplatform.integrationtests.common.GroupHelper;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanApplicationTestBuilder;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanProductTestBuilder;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanStatusChecker;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanTransactionHelper;
|
||||
|
||||
import com.jayway.restassured.builder.RequestSpecBuilder;
|
||||
import com.jayway.restassured.builder.ResponseSpecBuilder;
|
||||
import com.jayway.restassured.http.ContentType;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
/**
|
||||
* Test the creation, approval and rejection of a loan reschedule request
|
||||
**/
|
||||
@SuppressWarnings({ "rawtypes" })
|
||||
public class MinimumDaysBetweenDisbursalAndFirstRepaymentTest {
|
||||
|
||||
private ResponseSpecification responseSpec;
|
||||
private ResponseSpecification responseSpecForStatusCode403;
|
||||
private RequestSpecification requestSpec;
|
||||
private LoanTransactionHelper loanTransactionHelper;
|
||||
private Integer clientId;
|
||||
private Integer groupId;
|
||||
private Integer groupCalendarId;
|
||||
private Integer loanProductId;
|
||||
private Integer loanId;
|
||||
private final String loanPrincipalAmount = "100000.00";
|
||||
private final String numberOfRepayments = "12";
|
||||
private final String interestRatePerPeriod = "18";
|
||||
private final String groupActivationDate = "1 August 2014";
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
Utils.initializeRESTAssured();
|
||||
}
|
||||
|
||||
/*
|
||||
* MinimumDaysBetweenDisbursalAndFirstRepayment is set to 7 days and days
|
||||
* between disbursal date and first repayment is set as 7. system should
|
||||
* allow to create this loan and allow to disburse
|
||||
*/
|
||||
@Test
|
||||
public void createLoanEntity_WITH_DAY_BETWEEN_DISB_DATE_AND_REPAY_START_DATE_GREATER_THAN_MIN_DAY_CRITERIA() {
|
||||
|
||||
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
// create all required entities
|
||||
this.createRequiredEntities();
|
||||
|
||||
final String disbursalDate = "4 September 2014";
|
||||
final String firstRepaymentDate = "11 September 2014";
|
||||
|
||||
final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(loanPrincipalAmount)
|
||||
.withLoanTermFrequency(numberOfRepayments).withLoanTermFrequencyAsWeeks().withNumberOfRepayments(numberOfRepayments)
|
||||
.withRepaymentEveryAfter("1").withRepaymentFrequencyTypeAsMonths().withAmortizationTypeAsEqualInstallments()
|
||||
.withInterestCalculationPeriodTypeAsDays().withInterestRatePerPeriod(interestRatePerPeriod)
|
||||
.withRepaymentFrequencyTypeAsWeeks().withSubmittedOnDate(disbursalDate).withExpectedDisbursementDate(disbursalDate)
|
||||
.withPrincipalGrace("2").withInterestGrace("2").withFirstRepaymentDate(firstRepaymentDate)
|
||||
.build(this.clientId.toString(), this.loanProductId.toString(), null);
|
||||
|
||||
this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON);
|
||||
|
||||
// Test for loan account is created
|
||||
Assert.assertNotNull(this.loanId);
|
||||
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId);
|
||||
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
|
||||
|
||||
// Test for loan account is created, can be approved
|
||||
this.loanTransactionHelper.approveLoan(disbursalDate, this.loanId);
|
||||
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId);
|
||||
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
|
||||
|
||||
// Test for loan account approved can be disbursed
|
||||
this.loanTransactionHelper.disburseLoan(disbursalDate, this.loanId);
|
||||
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId);
|
||||
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* MinimumDaysBetweenDisbursalAndFirstRepayment is set to 7 days and days
|
||||
* between disbursal date and first repayment is set as 7. system should
|
||||
* allow to create this loan and allow to disburse
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void createLoanEntity_WITH_DAY_BETWEEN_DISB_DATE_AND_REPAY_START_DATE_LESS_THAN_MIN_DAY_CRITERIA() {
|
||||
|
||||
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
this.responseSpecForStatusCode403 = new ResponseSpecBuilder().expectStatusCode(403).build();
|
||||
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||
// create all required entities
|
||||
this.createRequiredEntities();
|
||||
|
||||
// loanTransactionHelper is reassigned to accept 403 status code from
|
||||
// server
|
||||
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpecForStatusCode403);
|
||||
|
||||
final String disbursalDate = "4 September 2014";
|
||||
final String firstRepaymentDate = "5 September 2014";
|
||||
|
||||
final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(loanPrincipalAmount)
|
||||
.withLoanTermFrequency(numberOfRepayments).withLoanTermFrequencyAsWeeks().withNumberOfRepayments(numberOfRepayments)
|
||||
.withRepaymentEveryAfter("1").withRepaymentFrequencyTypeAsMonths().withAmortizationTypeAsEqualInstallments()
|
||||
.withInterestCalculationPeriodTypeAsDays().withInterestRatePerPeriod(interestRatePerPeriod)
|
||||
.withRepaymentFrequencyTypeAsWeeks().withSubmittedOnDate(disbursalDate).withExpectedDisbursementDate(disbursalDate)
|
||||
.withPrincipalGrace("2").withInterestGrace("2").withFirstRepaymentDate(firstRepaymentDate)
|
||||
.build(this.clientId.toString(), this.loanProductId.toString(), null);
|
||||
|
||||
List<HashMap> error = (List<HashMap>) this.loanTransactionHelper.createLoanAccount(loanApplicationJSON,
|
||||
CommonConstants.RESPONSE_ERROR);
|
||||
assertEquals("error.msg.loan.days.between.first.repayment.and.disbursal.are.less.than.minimum.allowed",
|
||||
error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the client, loan product, and loan entities
|
||||
**/
|
||||
private void createRequiredEntities() {
|
||||
final String minimumDaysBetweenDisbursalAndFirstRepayment = "7"; // &
|
||||
// days
|
||||
this.createGroupEntityWithCalendar();
|
||||
this.createClientEntity();
|
||||
this.associateClientToGroup(this.groupId, this.clientId);
|
||||
this.createLoanProductEntity(minimumDaysBetweenDisbursalAndFirstRepayment);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Associate client to the group
|
||||
*/
|
||||
|
||||
private void associateClientToGroup(final Integer groupId, final Integer clientId) {
|
||||
GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupId.toString(), clientId.toString());
|
||||
GroupHelper.verifyGroupMembers(this.requestSpec, this.responseSpec, groupId, clientId);
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a new group
|
||||
*/
|
||||
|
||||
private void createGroupEntityWithCalendar() {
|
||||
this.groupId = GroupHelper.createGroup(this.requestSpec, this.responseSpec, this.groupActivationDate);
|
||||
GroupHelper.verifyGroupCreatedOnServer(this.requestSpec, this.responseSpec, this.groupId);
|
||||
|
||||
final String startDate = this.groupActivationDate;
|
||||
final String frequency = "2"; // 2:Weekly
|
||||
final String interval = "1"; // Every one week
|
||||
final String repeatsOnDay = "1"; // 1:Monday
|
||||
|
||||
this.setGroupCalendarId(CalendarHelper.createMeetingCalendarForGroup(this.requestSpec, this.responseSpec, this.groupId, startDate,
|
||||
frequency, interval, repeatsOnDay));
|
||||
}
|
||||
|
||||
/**
|
||||
* create a new client
|
||||
**/
|
||||
private void createClientEntity() {
|
||||
this.clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, this.clientId);
|
||||
}
|
||||
|
||||
/**
|
||||
* create a new loan product
|
||||
**/
|
||||
private void createLoanProductEntity(final String minimumDaysBetweenDisbursalAndFirstRepayment) {
|
||||
final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(loanPrincipalAmount)
|
||||
.withNumberOfRepayments(numberOfRepayments).withinterestRatePerPeriod(interestRatePerPeriod)
|
||||
.withInterestRateFrequencyTypeAsYear()
|
||||
.withMinimumDaysBetweenDisbursalAndFirstRepayment(minimumDaysBetweenDisbursalAndFirstRepayment).build(null);
|
||||
this.loanProductId = this.loanTransactionHelper.getLoanProductId(loanProductJSON);
|
||||
}
|
||||
|
||||
public Integer getGroupCalendarId() {
|
||||
return groupCalendarId;
|
||||
}
|
||||
|
||||
public void setGroupCalendarId(Integer groupCalendarId) {
|
||||
this.groupCalendarId = groupCalendarId;
|
||||
}
|
||||
}
|
||||
-93
@@ -1,93 +0,0 @@
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mifosplatform.integrationtests.common.CommonConstants;
|
||||
import org.mifosplatform.integrationtests.common.OfficeHelper;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
import org.mifosplatform.integrationtests.common.accounting.Account;
|
||||
import org.mifosplatform.integrationtests.common.accounting.AccountHelper;
|
||||
import org.mifosplatform.integrationtests.common.accounting.OfficeAccountMappingHelper;
|
||||
|
||||
import com.jayway.restassured.builder.RequestSpecBuilder;
|
||||
import com.jayway.restassured.builder.ResponseSpecBuilder;
|
||||
import com.jayway.restassured.http.ContentType;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class OfficeAccountingMappingsTest {
|
||||
|
||||
private ResponseSpecification responseSpec;
|
||||
private RequestSpecification requestSpec;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
Utils.initializeRESTAssured();
|
||||
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testOfficeAccountingMappings() {
|
||||
|
||||
OfficeHelper officeHelper = new OfficeHelper(this.requestSpec, this.responseSpec);
|
||||
Integer officeId = officeHelper.createOffice("01 January 2014");
|
||||
Assert.assertNotNull(officeId);
|
||||
|
||||
Integer officeId2 = officeHelper.createOffice("01 January 2014");
|
||||
Assert.assertNotNull(officeId2);
|
||||
|
||||
AccountHelper accountHelper = new AccountHelper(this.requestSpec, this.responseSpec);
|
||||
Account transferAccount = accountHelper.createLiabilityAccount();
|
||||
Assert.assertNotNull(transferAccount);
|
||||
|
||||
OfficeAccountMappingHelper accountMappingHelper = new OfficeAccountMappingHelper(this.requestSpec,
|
||||
new ResponseSpecBuilder().build());
|
||||
Integer transferAccountMappingId = (Integer) accountMappingHelper.createOfficeAccountMapping(officeId,
|
||||
transferAccount.getAccountID(), CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
Assert.assertNotNull(transferAccountMappingId);
|
||||
|
||||
HashMap mappingDetails = accountMappingHelper.getOfficeAccountMapping(transferAccountMappingId);
|
||||
Assert.assertEquals(officeId, ((HashMap) mappingDetails.get("officeData")).get("id"));
|
||||
Assert.assertEquals(transferAccount.getAccountID(), ((HashMap) mappingDetails.get("glAccountData")).get("id"));
|
||||
|
||||
Account transferAccount2 = accountHelper.createLiabilityAccount();
|
||||
Assert.assertNotNull(transferAccount2);
|
||||
|
||||
HashMap changes = (HashMap) accountMappingHelper.updateOfficeAccountMapping(transferAccountMappingId, officeId,
|
||||
transferAccount2.getAccountID(), CommonConstants.RESPONSE_CHANGES);
|
||||
Assert.assertEquals(transferAccount2.getAccountID(), changes.get("liabilityTransferInSuspenseAccountId"));
|
||||
|
||||
mappingDetails = accountMappingHelper.getOfficeAccountMapping(transferAccountMappingId);
|
||||
Assert.assertEquals(officeId, ((HashMap) mappingDetails.get("officeData")).get("id"));
|
||||
Assert.assertEquals(transferAccount2.getAccountID(), ((HashMap) mappingDetails.get("glAccountData")).get("id"));
|
||||
|
||||
List<HashMap> error1 = (List<HashMap>) accountMappingHelper.updateOfficeAccountMapping(transferAccountMappingId, officeId2,
|
||||
transferAccount2.getAccountID(), CommonConstants.RESPONSE_ERROR);
|
||||
assertEquals("error.msg.officeToAccountMapping.update.of.officeId.is.not.supported",
|
||||
error1.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
List<HashMap> error2 = (List<HashMap>) accountMappingHelper.createOfficeAccountMapping(officeId, transferAccount.getAccountID(),
|
||||
CommonConstants.RESPONSE_ERROR);
|
||||
assertEquals("error.msg.officeToAccountMapping.exists.for.office", error2.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
Account fundAccount = accountHelper.createAssetAccount();
|
||||
Assert.assertNotNull(fundAccount);
|
||||
|
||||
List<HashMap> error3 = (List<HashMap>) accountMappingHelper.createOfficeAccountMapping(officeId2, fundAccount.getAccountID(),
|
||||
CommonConstants.RESPONSE_ERROR);
|
||||
assertEquals("error.msg.liabilityTransferInSuspenseAccountId.invalid.account.type", error3.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+594
-104
File diff suppressed because it is too large
Load Diff
+5
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
+42
-22
@@ -1,13 +1,21 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
@@ -33,6 +41,8 @@ import org.mifosplatform.integrationtests.common.loans.LoanTransactionHelper;
|
||||
import org.mifosplatform.integrationtests.common.savings.SavingsAccountHelper;
|
||||
import org.mifosplatform.integrationtests.common.savings.SavingsProductHelper;
|
||||
import org.mifosplatform.integrationtests.common.savings.SavingsStatusChecker;
|
||||
import org.mifosplatform.portfolio.account.PortfolioAccountType;
|
||||
import org.mifosplatform.portfolio.account.domain.AccountTransferType;
|
||||
|
||||
import com.jayway.restassured.builder.RequestSpecBuilder;
|
||||
import com.jayway.restassured.builder.ResponseSpecBuilder;
|
||||
@@ -115,7 +125,7 @@ public class SchedulerJobsTestResults {
|
||||
HashMap summaryBefore = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
String JobName = "Apply Annual Fee For Savings";
|
||||
|
||||
this.schedulerJobHelper.excuteJob(JobName);
|
||||
this.schedulerJobHelper.executeJob(JobName);
|
||||
final HashMap chargeData = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, annualFeeChargeId);
|
||||
|
||||
Float chargeAmount = (Float) chargeData.get("amount");
|
||||
@@ -155,7 +165,7 @@ public class SchedulerJobsTestResults {
|
||||
|
||||
String JobName = "Post Interest For Savings";
|
||||
|
||||
this.schedulerJobHelper.excuteJob(JobName);
|
||||
this.schedulerJobHelper.executeJob(JobName);
|
||||
final HashMap summaryAfter = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
|
||||
Assert.assertNotSame("Verifying the Balance after running Post Interest for Savings Job", summaryBefore.get("accountBalance"),
|
||||
@@ -206,7 +216,7 @@ public class SchedulerJobsTestResults {
|
||||
Assert.assertNotNull(specifiedDueDateChargeId);
|
||||
|
||||
this.loanTransactionHelper.addChargesForLoan(loanID,
|
||||
LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(specifiedDueDateChargeId.toString()));
|
||||
LoanTransactionHelper.getSpecifiedDueDateChargesForLoanAsJSON(specifiedDueDateChargeId.toString(), "12 March 2013", "100"));
|
||||
ArrayList<HashMap> chargesPendingState = this.loanTransactionHelper.getLoanCharges(loanID);
|
||||
Assert.assertEquals(1, chargesPendingState.size());
|
||||
|
||||
@@ -215,7 +225,7 @@ public class SchedulerJobsTestResults {
|
||||
final HashMap summaryBefore = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
|
||||
String JobName = "Transfer Fee For Loans From Savings";
|
||||
this.schedulerJobHelper.excuteJob(JobName);
|
||||
this.schedulerJobHelper.executeJob(JobName);
|
||||
final HashMap summaryAfter = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
|
||||
final HashMap chargeData = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, specifiedDueDateChargeId);
|
||||
@@ -286,7 +296,7 @@ public class SchedulerJobsTestResults {
|
||||
|
||||
String JobName = "Apply Holidays To Loans";
|
||||
|
||||
this.schedulerJobHelper.excuteJob(JobName);
|
||||
this.schedulerJobHelper.executeJob(JobName);
|
||||
final ArrayList<HashMap> repaymentScheduleDataAfterJob = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec,
|
||||
this.responseSpec, loanID);
|
||||
|
||||
@@ -337,7 +347,7 @@ public class SchedulerJobsTestResults {
|
||||
|
||||
String JobName = "Pay Due Savings Charges";
|
||||
|
||||
this.schedulerJobHelper.excuteJob(JobName);
|
||||
this.schedulerJobHelper.executeJob(JobName);
|
||||
HashMap summaryAfter = this.savingsAccountHelper.getSavingsSummary(savingsId);
|
||||
|
||||
final HashMap chargeData = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, specifiedDueDateChargeId);
|
||||
@@ -387,7 +397,7 @@ public class SchedulerJobsTestResults {
|
||||
|
||||
String JobName = "Update Accounting Running Balances";
|
||||
|
||||
this.schedulerJobHelper.excuteJob(JobName);
|
||||
this.schedulerJobHelper.executeJob(JobName);
|
||||
final HashMap runningBalanceAfter = this.accountHelper.getAccountingWithRunningBalanceById(accountID.toString());
|
||||
|
||||
final Integer INT_BALANCE = new Integer(MINIMUM_OPENING_BALANCE);
|
||||
@@ -422,7 +432,7 @@ public class SchedulerJobsTestResults {
|
||||
|
||||
String JobName = "Update Loan Arrears Ageing";
|
||||
|
||||
this.schedulerJobHelper.excuteJob(JobName);
|
||||
this.schedulerJobHelper.executeJob(JobName);
|
||||
HashMap loanSummaryData = this.loanTransactionHelper.getLoanSummary(this.requestSpec, this.responseSpec, loanID);
|
||||
|
||||
Float totalLoanArrearsAging = (Float) loanSummaryData.get("principalOverdue") + (Float) loanSummaryData.get("interestOverdue");
|
||||
@@ -437,7 +447,7 @@ public class SchedulerJobsTestResults {
|
||||
this.schedulerJobHelper = new SchedulerJobHelper(this.requestSpec, this.responseSpec);
|
||||
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
|
||||
|
||||
Calendar todayDate = Calendar.getInstance();
|
||||
final String currentDate = dateFormat.format(todayDate.getTime());
|
||||
@@ -477,7 +487,7 @@ public class SchedulerJobsTestResults {
|
||||
HashMap loanSummary = this.loanTransactionHelper.getLoanSummary(this.requestSpec, this.responseSpec, loanID);
|
||||
|
||||
String JobName = "Update Loan Paid In Advance";
|
||||
this.schedulerJobHelper.excuteJob(JobName);
|
||||
this.schedulerJobHelper.executeJob(JobName);
|
||||
// Retrieving Loan Repayment Schedule after the successful
|
||||
// completion of
|
||||
// Update Loan Paid in Advance Scheduler Job
|
||||
@@ -498,7 +508,7 @@ public class SchedulerJobsTestResults {
|
||||
this.schedulerJobHelper = new SchedulerJobHelper(this.requestSpec, this.responseSpec);
|
||||
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
|
||||
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
final String currentDate = dateFormat.format(todaysDate.getTime());
|
||||
@@ -540,7 +550,7 @@ public class SchedulerJobsTestResults {
|
||||
HashMap loanSummaryBefore = this.loanTransactionHelper.getLoanSummary(this.requestSpec, this.responseSpec, loanID);
|
||||
|
||||
String JobName = "Update loan Summary";
|
||||
this.schedulerJobHelper.excuteJob(JobName);
|
||||
this.schedulerJobHelper.executeJob(JobName);
|
||||
Float expectedSummaryAfterJob = (Float) loanSummaryBefore.get("totalExpectedRepayment")
|
||||
- (Float) loanSummaryBefore.get("feeChargesPaid");
|
||||
HashMap loanSummaryAfter = this.loanTransactionHelper.getLoanSummary(this.requestSpec, this.responseSpec, loanID);
|
||||
@@ -555,11 +565,11 @@ public class SchedulerJobsTestResults {
|
||||
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||
this.standingInstructionsHelper = new StandingInstructionsHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
|
||||
DateFormat monthDayFormat = new SimpleDateFormat("dd MMMM");
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
|
||||
DateFormat monthDayFormat = new SimpleDateFormat("dd MMMM", Locale.US);
|
||||
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -1);
|
||||
todaysDate.add(Calendar.WEEK_OF_YEAR, -1);
|
||||
final String VALID_FROM = dateFormat.format(todaysDate.getTime());
|
||||
|
||||
final String MONTH_DAY = monthDayFormat.format(todaysDate.getTime());
|
||||
@@ -612,7 +622,7 @@ public class SchedulerJobsTestResults {
|
||||
Assert.assertNotNull(standingInstructionId);
|
||||
|
||||
String JobName = "Execute Standing Instruction";
|
||||
this.schedulerJobHelper.excuteJob(JobName);
|
||||
this.schedulerJobHelper.executeJob(JobName);
|
||||
HashMap fromSavingsSummaryAfter = this.savingsAccountHelper.getSavingsSummary(fromSavingsId);
|
||||
Float fromSavingsBalanceAfter = (Float) fromSavingsSummaryAfter.get("accountBalance");
|
||||
|
||||
@@ -628,6 +638,16 @@ public class SchedulerJobsTestResults {
|
||||
fromSavingsBalanceAfter);
|
||||
Assert.assertEquals("Verifying To Savings Balance after Successful completion of Scheduler Job", expectedToSavingsBalance,
|
||||
toSavingsBalanceAfter);
|
||||
Integer fromAccountType = PortfolioAccountType.SAVINGS.getValue();
|
||||
Integer transferType = AccountTransferType.ACCOUNT_TRANSFER.getValue();
|
||||
List<HashMap> standinInstructionHistoryData = this.standingInstructionsHelper.getStandingInstructionHistory(fromSavingsId,
|
||||
fromAccountType, clientID, transferType);
|
||||
Assert.assertEquals("Verifying the no of stainding instruction transactions logged for the client", 1,
|
||||
standinInstructionHistoryData.size());
|
||||
HashMap loggedTransaction = standinInstructionHistoryData.get(0);
|
||||
|
||||
Assert.assertEquals("Verifying transferred amount and logged transaction amounts", (Float) standingInstructionData.get("amount"),
|
||||
(Float) loggedTransaction.get("amount"));
|
||||
|
||||
}
|
||||
|
||||
@@ -663,7 +683,7 @@ public class SchedulerJobsTestResults {
|
||||
this.responseSpec, loanID);
|
||||
|
||||
String JobName = "Apply penalty to overdue loans";
|
||||
this.schedulerJobHelper.excuteJob(JobName);
|
||||
this.schedulerJobHelper.executeJob(JobName);
|
||||
|
||||
final HashMap chargeData = ChargesHelper.getChargeById(this.requestSpec, this.responseSpec, overdueFeeChargeId);
|
||||
|
||||
@@ -708,7 +728,7 @@ public class SchedulerJobsTestResults {
|
||||
Assert.assertFalse(isNPABefore);
|
||||
// Integer jobId = (Integer) allSchedulerJobsData.get(1).get("jobId");
|
||||
String JobName = "Update Non Performing Assets";
|
||||
this.schedulerJobHelper.excuteJob(JobName);
|
||||
this.schedulerJobHelper.executeJob(JobName);
|
||||
final Boolean isNPAAfter = (Boolean) this.loanTransactionHelper.getLoanDetail(requestSpec, responseSpec, loanID, "isNPA");
|
||||
Assert.assertTrue(isNPAAfter);
|
||||
}
|
||||
@@ -721,8 +741,8 @@ public class SchedulerJobsTestResults {
|
||||
AccountHelper accountHelper = new AccountHelper(this.requestSpec, this.responseSpec);
|
||||
FixedDepositAccountHelper fixedDepositAccountHelper = new FixedDepositAccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
|
||||
DateFormat monthDayFormat = new SimpleDateFormat("dd MMM");
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
|
||||
DateFormat monthDayFormat = new SimpleDateFormat("dd MMM", Locale.US);
|
||||
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -3);
|
||||
@@ -785,7 +805,7 @@ public class SchedulerJobsTestResults {
|
||||
Float interestPosted = (Float) fixedDepositSummary.get("accountBalance") - new Float(FixedDepositAccountHelper.depositAmount);
|
||||
|
||||
String JobName = "Transfer Interest To Savings";
|
||||
this.schedulerJobHelper.excuteJob(JobName);
|
||||
this.schedulerJobHelper.executeJob(JobName);
|
||||
fixedDepositSummary = savingsAccountHelper.getSavingsSummary(fixedDepositAccountId);
|
||||
assertEquals("Verifying opening Balance", new Float(FixedDepositAccountHelper.depositAmount),
|
||||
fixedDepositSummary.get("accountBalance"));
|
||||
@@ -872,7 +892,7 @@ public class SchedulerJobsTestResults {
|
||||
}
|
||||
|
||||
public void validateNumberForEqualExcludePrecission(String val, String val2) {
|
||||
DecimalFormat twoDForm = new DecimalFormat("#");
|
||||
DecimalFormat twoDForm = new DecimalFormat("#", new DecimalFormatSymbols(Locale.US));
|
||||
Assert.assertTrue(new Float(twoDForm.format(new Float(val))).compareTo(new Float(twoDForm.format(new Float(val2)))) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import org.junit.Before;
|
||||
|
||||
+229
-318
@@ -1,8 +1,14 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@@ -24,336 +30,241 @@ import com.jayway.restassured.specification.ResponseSpecification;
|
||||
* Test for creating, updating, deleting codes and code values
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public class SystemCodeTest {
|
||||
|
||||
private ResponseSpecification responseSpec;
|
||||
private ResponseSpecification generalResponseSpec;
|
||||
private RequestSpecification requestSpec;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
Utils.initializeRESTAssured();
|
||||
this.requestSpec = new RequestSpecBuilder().setContentType(
|
||||
ContentType.JSON).build();
|
||||
this.requestSpec
|
||||
.header("Authorization",
|
||||
"Basic "
|
||||
+ Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200)
|
||||
.build();
|
||||
|
||||
this.generalResponseSpec = new ResponseSpecBuilder().build();
|
||||
|
||||
}
|
||||
|
||||
// @Ignore()
|
||||
@Test
|
||||
// scenario 57, 58, 59, 60
|
||||
public void testCreateCode() {
|
||||
final String codeName = "Client Marital Status";
|
||||
|
||||
final Integer createResponseId = (Integer) CodeHelper.createCode(
|
||||
this.requestSpec, this.responseSpec, codeName,
|
||||
CodeHelper.RESPONSE_ID_ATTRIBUTE_NAME);
|
||||
|
||||
// verify code created
|
||||
final HashMap newCodeAttributes = (HashMap) CodeHelper.getCodeById(
|
||||
this.requestSpec, this.responseSpec, createResponseId, "");
|
||||
|
||||
Assert.assertNotNull(newCodeAttributes);
|
||||
assertEquals("Verify value of codeId", createResponseId,
|
||||
newCodeAttributes.get(CodeHelper.CODE_ID_ATTRIBUTE_NAME));
|
||||
|
||||
assertEquals("Verify code name", codeName,
|
||||
newCodeAttributes.get(CodeHelper.CODE_NAME_ATTRIBUTE_NAME));
|
||||
assertEquals("Verify system defined is false", false,
|
||||
newCodeAttributes
|
||||
.get(CodeHelper.CODE_SYSTEM_DEFINED_ATTRIBUTE_NAME));
|
||||
|
||||
// update code
|
||||
final HashMap updateChangeResponse = (HashMap) CodeHelper.updateCode(
|
||||
this.requestSpec, this.responseSpec, createResponseId, codeName
|
||||
+ "(CHANGE)", "changes");
|
||||
|
||||
assertEquals("Verify code name updated", codeName + "(CHANGE)",
|
||||
updateChangeResponse.get(CodeHelper.CODE_NAME_ATTRIBUTE_NAME));
|
||||
|
||||
// delete code
|
||||
final Integer deleteResponseId = (Integer) CodeHelper.deleteCodeById(
|
||||
this.requestSpec, this.responseSpec, createResponseId,
|
||||
CodeHelper.RESPONSE_ID_ATTRIBUTE_NAME);
|
||||
assertEquals("Verify code deleted", createResponseId, deleteResponseId);
|
||||
|
||||
// verify code deleted
|
||||
final HashMap deletedCodeValues = (HashMap) CodeHelper.getCodeById(
|
||||
this.requestSpec, this.generalResponseSpec, deleteResponseId,
|
||||
"");
|
||||
|
||||
Assert.assertNotNull(deletedCodeValues);
|
||||
assertNull("Verify value of codeId",
|
||||
deletedCodeValues.get(CodeHelper.CODE_ID_ATTRIBUTE_NAME));
|
||||
|
||||
assertNull("Verify code name",
|
||||
deletedCodeValues.get(CodeHelper.CODE_NAME_ATTRIBUTE_NAME));
|
||||
assertNull("Verify system defined is false",
|
||||
deletedCodeValues
|
||||
.get(CodeHelper.CODE_SYSTEM_DEFINED_ATTRIBUTE_NAME));
|
||||
}
|
||||
|
||||
// @Ignore()
|
||||
@Test
|
||||
// scenario 57, 60
|
||||
public void testPreventCreateDuplicateCode() {
|
||||
final String codeName = "Client Marital Status";
|
||||
|
||||
// create code
|
||||
final Integer createResponseId = (Integer) CodeHelper.createCode(
|
||||
this.requestSpec, this.responseSpec, codeName,
|
||||
CodeHelper.RESPONSE_ID_ATTRIBUTE_NAME);
|
||||
|
||||
// verify code created
|
||||
final HashMap newCodeAttributes = (HashMap) CodeHelper.getCodeById(
|
||||
this.requestSpec, this.responseSpec, createResponseId, "");
|
||||
|
||||
Assert.assertNotNull(newCodeAttributes);
|
||||
assertEquals("Verify value of codeId", createResponseId,
|
||||
newCodeAttributes.get(CodeHelper.CODE_ID_ATTRIBUTE_NAME));
|
||||
|
||||
assertEquals("Verify code name", codeName,
|
||||
newCodeAttributes.get(CodeHelper.CODE_NAME_ATTRIBUTE_NAME));
|
||||
assertEquals("Verify system defined is false", false,
|
||||
newCodeAttributes
|
||||
.get(CodeHelper.CODE_SYSTEM_DEFINED_ATTRIBUTE_NAME));
|
||||
|
||||
// try to create duplicate-- should fail
|
||||
final List<HashMap> error = (List) CodeHelper.createCode(
|
||||
this.requestSpec, this.generalResponseSpec, codeName,
|
||||
CommonConstants.RESPONSE_ERROR);
|
||||
|
||||
assertEquals("Verify duplication error",
|
||||
"error.msg.code.duplicate.name",
|
||||
error.get(0).get("userMessageGlobalisationCode"));
|
||||
|
||||
// delete code that was just created
|
||||
|
||||
final Integer deleteResponseId = (Integer) CodeHelper.deleteCodeById(
|
||||
this.requestSpec, this.responseSpec, createResponseId,
|
||||
CodeHelper.RESPONSE_ID_ATTRIBUTE_NAME);
|
||||
assertEquals("Verify code deleted", createResponseId, deleteResponseId);
|
||||
|
||||
// verify code deleted
|
||||
final HashMap deletedCodeAttributes = (HashMap) CodeHelper.getCodeById(
|
||||
this.requestSpec, this.generalResponseSpec, deleteResponseId,
|
||||
"");
|
||||
|
||||
Assert.assertNotNull(deletedCodeAttributes);
|
||||
assertNull("Verify value of codeId",
|
||||
deletedCodeAttributes.get(CodeHelper.CODE_ID_ATTRIBUTE_NAME));
|
||||
|
||||
assertNull("Verify code name",
|
||||
deletedCodeAttributes.get(CodeHelper.CODE_NAME_ATTRIBUTE_NAME));
|
||||
assertNull("Verify system defined is false",
|
||||
deletedCodeAttributes
|
||||
.get(CodeHelper.CODE_SYSTEM_DEFINED_ATTRIBUTE_NAME));
|
||||
|
||||
}
|
||||
|
||||
// @Ignore
|
||||
@Test
|
||||
public void testUpdateDeleteSystemDefinedCode() {
|
||||
|
||||
// get any systemDefined code
|
||||
final HashMap systemDefinedCode = (HashMap) CodeHelper
|
||||
.getSystemDefinedCodes(this.requestSpec, this.responseSpec);
|
||||
|
||||
// delete system-defined code should fail
|
||||
final List<HashMap> error = (List) CodeHelper.deleteCodeById(
|
||||
this.requestSpec, this.generalResponseSpec,
|
||||
(Integer) systemDefinedCode
|
||||
.get(CodeHelper.CODE_ID_ATTRIBUTE_NAME),
|
||||
CommonConstants.RESPONSE_ERROR);
|
||||
|
||||
assertEquals("Cannot delete system-defined code",
|
||||
"error.msg.code.systemdefined",
|
||||
error.get(0).get("userMessageGlobalisationCode"));
|
||||
|
||||
// update system-defined code should fail
|
||||
final List<HashMap> updateError = (List) CodeHelper.updateCode(
|
||||
this.requestSpec, this.generalResponseSpec,
|
||||
(Integer) systemDefinedCode
|
||||
.get(CodeHelper.CODE_ID_ATTRIBUTE_NAME),
|
||||
systemDefinedCode.get(CodeHelper.CODE_NAME_ATTRIBUTE_NAME)
|
||||
+ "CHANGE", CommonConstants.RESPONSE_ERROR);
|
||||
|
||||
assertEquals("Cannot update system-defined code",
|
||||
"error.msg.code.systemdefined",
|
||||
error.get(0).get("userMessageGlobalisationCode"));
|
||||
|
||||
}
|
||||
|
||||
// @Ignore
|
||||
@Test
|
||||
public void testCodeValuesNotAssignedToTable() {
|
||||
|
||||
final String codeName = "Client Marital Status";
|
||||
|
||||
final String codeValue1 = "Married";
|
||||
final String codeValue2 = "Unmarried";
|
||||
|
||||
final int codeValue1Position = 1;
|
||||
final int codeValue2Position = 2;
|
||||
|
||||
// create code
|
||||
final Integer createCodeResponseId = (Integer) CodeHelper.createCode(
|
||||
this.requestSpec, this.responseSpec, codeName,
|
||||
CodeHelper.RESPONSE_ID_ATTRIBUTE_NAME);
|
||||
|
||||
// create first code value
|
||||
final Integer createCodeValueResponseId1 = (Integer) CodeHelper
|
||||
.createCodeValue(this.requestSpec, this.responseSpec,
|
||||
createCodeResponseId, codeValue1, codeValue1Position,
|
||||
CodeHelper.SUBRESPONSE_ID_ATTRIBUTE_NAME);
|
||||
|
||||
// create second code value
|
||||
final Integer createCodeValueResponseId2 = (Integer) CodeHelper
|
||||
.createCodeValue(this.requestSpec, this.responseSpec,
|
||||
createCodeResponseId, codeValue2, codeValue2Position,
|
||||
CodeHelper.SUBRESPONSE_ID_ATTRIBUTE_NAME);
|
||||
|
||||
// verify two code values created
|
||||
|
||||
final List<HashMap> codeValuesList = (List) CodeHelper
|
||||
.getCodeValuesForCode(this.requestSpec, this.responseSpec,
|
||||
createCodeResponseId, "");
|
||||
|
||||
assertEquals("Number of code values returned matches number created",
|
||||
2, codeValuesList.size());
|
||||
|
||||
// verify values of first code value
|
||||
final HashMap codeValuesAttributes1 = (HashMap) CodeHelper
|
||||
.getCodeValueById(this.requestSpec, this.responseSpec,
|
||||
createCodeResponseId, createCodeValueResponseId1, "");
|
||||
|
||||
Assert.assertNotNull(codeValuesAttributes1);
|
||||
assertEquals("Verify value of codeValueId", createCodeValueResponseId1,
|
||||
codeValuesAttributes1
|
||||
.get(CodeHelper.CODE_VALUE_ID_ATTRIBUTE_NAME));
|
||||
|
||||
assertEquals("Verify value of code name", codeValue1,
|
||||
codeValuesAttributes1
|
||||
.get(CodeHelper.CODE_VALUE_NAME_ATTRIBUTE_NAME));
|
||||
|
||||
assertEquals("Verify position of code value", codeValue1Position,
|
||||
codeValuesAttributes1
|
||||
.get(CodeHelper.CODE_VALUE_POSITION_ATTRIBUTE_NAME));
|
||||
|
||||
// verify values of second code value
|
||||
final HashMap codeValuesAttributes2 = (HashMap) CodeHelper
|
||||
.getCodeValueById(this.requestSpec, this.responseSpec,
|
||||
createCodeResponseId, createCodeValueResponseId2, "");
|
||||
|
||||
Assert.assertNotNull(codeValuesAttributes2);
|
||||
assertEquals("Verify value of codeValueId", createCodeValueResponseId2,
|
||||
codeValuesAttributes2
|
||||
.get(CodeHelper.CODE_VALUE_ID_ATTRIBUTE_NAME));
|
||||
|
||||
assertEquals("Verify value of code name", codeValue2,
|
||||
codeValuesAttributes2
|
||||
.get(CodeHelper.CODE_VALUE_NAME_ATTRIBUTE_NAME));
|
||||
|
||||
assertEquals("Verify position of code value", codeValue2Position,
|
||||
codeValuesAttributes2
|
||||
.get(CodeHelper.CODE_VALUE_POSITION_ATTRIBUTE_NAME));
|
||||
|
||||
// update code value 1
|
||||
|
||||
final HashMap codeValueChanges = (HashMap) CodeHelper
|
||||
.updateCodeValue(this.requestSpec, this.responseSpec,
|
||||
createCodeResponseId, createCodeValueResponseId1,
|
||||
codeValue1 + "CHANGE", 4, "changes");
|
||||
|
||||
assertEquals("Verify changed code value name",
|
||||
codeValueChanges.get("name"), codeValue1 + "CHANGE");
|
||||
|
||||
// delete code value
|
||||
final Integer deletedCodeValueResponseId1 = (Integer) CodeHelper
|
||||
.deleteCodeValueById(this.requestSpec,
|
||||
this.generalResponseSpec, createCodeResponseId,
|
||||
createCodeValueResponseId1,
|
||||
CodeHelper.RESPONSE_ID_ATTRIBUTE_NAME);
|
||||
private ResponseSpecification responseSpec;
|
||||
private ResponseSpecification generalResponseSpec;
|
||||
private RequestSpecification requestSpec;
|
||||
|
||||
// Verify code value deleted
|
||||
@Before
|
||||
public void setup() {
|
||||
Utils.initializeRESTAssured();
|
||||
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
|
||||
final HashMap deletedCodeValueAttributes1 = (HashMap) CodeHelper
|
||||
.getCodeValueById(this.requestSpec, this.generalResponseSpec,
|
||||
createCodeResponseId, deletedCodeValueResponseId1, "");
|
||||
this.generalResponseSpec = new ResponseSpecBuilder().build();
|
||||
|
||||
// Assert.assertNotNull(deletedCodeValueAttributes1);
|
||||
assertNull("Verify value of codeValueId",
|
||||
deletedCodeValueAttributes1
|
||||
.get(CodeHelper.CODE_VALUE_ID_ATTRIBUTE_NAME));
|
||||
}
|
||||
|
||||
assertNull("Verify value of code name",
|
||||
deletedCodeValueAttributes1
|
||||
.get(CodeHelper.CODE_VALUE_NAME_ATTRIBUTE_NAME));
|
||||
// @Ignore()
|
||||
@Test
|
||||
// scenario 57, 58, 59, 60
|
||||
public void testCreateCode() {
|
||||
final String codeName = "Client Marital Status";
|
||||
|
||||
assertNull("Verify position of code value",
|
||||
deletedCodeValueAttributes1
|
||||
.get(CodeHelper.CODE_VALUE_POSITION_ATTRIBUTE_NAME));
|
||||
|
||||
final List<HashMap> deletedCodeValuesList = (List) CodeHelper
|
||||
.getCodeValuesForCode(this.requestSpec, this.responseSpec,
|
||||
createCodeResponseId, "");
|
||||
|
||||
assertEquals("Number of code values is 1", 1,
|
||||
deletedCodeValuesList.size());
|
||||
|
||||
// delete code, remaining code values automatically deleted
|
||||
|
||||
final Integer deleteCodeResponseId = (Integer) CodeHelper
|
||||
.deleteCodeById(this.requestSpec, this.generalResponseSpec,
|
||||
createCodeResponseId,
|
||||
CodeHelper.RESPONSE_ID_ATTRIBUTE_NAME);
|
||||
assertEquals("Verify code deleted", createCodeResponseId,
|
||||
deleteCodeResponseId);
|
||||
final Integer createResponseId = (Integer) CodeHelper.createCode(this.requestSpec, this.responseSpec, codeName,
|
||||
CodeHelper.RESPONSE_ID_ATTRIBUTE_NAME);
|
||||
|
||||
// verify code deleted
|
||||
final HashMap deletedCodeAttributes = (HashMap) CodeHelper.getCodeById(
|
||||
this.requestSpec, this.generalResponseSpec,
|
||||
createCodeResponseId, "");
|
||||
// verify code created
|
||||
|
||||
Assert.assertNotNull(deletedCodeAttributes);
|
||||
assertNull("Verify value of codeId is null",
|
||||
deletedCodeAttributes.get(CodeHelper.CODE_ID_ATTRIBUTE_NAME));
|
||||
final HashMap newCodeAttributes = (HashMap) CodeHelper.getCodeById(this.requestSpec, this.responseSpec, createResponseId, "");
|
||||
|
||||
assertNull("Verify code name is null",
|
||||
deletedCodeAttributes.get(CodeHelper.CODE_NAME_ATTRIBUTE_NAME));
|
||||
assertNull("Verify system defined is null",
|
||||
deletedCodeAttributes
|
||||
.get(CodeHelper.CODE_SYSTEM_DEFINED_ATTRIBUTE_NAME));
|
||||
|
||||
// Verify remaining code value deleted
|
||||
final HashMap deletedCodeValues2 = (HashMap) CodeHelper
|
||||
.getCodeValueById(this.requestSpec, this.generalResponseSpec,
|
||||
createCodeResponseId, createCodeValueResponseId2, "");
|
||||
Assert.assertNotNull(newCodeAttributes);
|
||||
assertEquals("Verify value of codeId", createResponseId, newCodeAttributes.get(CodeHelper.CODE_ID_ATTRIBUTE_NAME));
|
||||
|
||||
assertNull("Verify value of codeValueId is null",
|
||||
deletedCodeValues2.get(CodeHelper.CODE_VALUE_ID_ATTRIBUTE_NAME));
|
||||
|
||||
assertNull("Verify value of code name is null",
|
||||
deletedCodeValues2
|
||||
.get(CodeHelper.CODE_VALUE_NAME_ATTRIBUTE_NAME));
|
||||
|
||||
assertNull("Verify position of code value null",
|
||||
deletedCodeValues2
|
||||
.get(CodeHelper.CODE_VALUE_POSITION_ATTRIBUTE_NAME));
|
||||
|
||||
}
|
||||
assertEquals("Verify code name", codeName, newCodeAttributes.get(CodeHelper.CODE_NAME_ATTRIBUTE_NAME));
|
||||
assertEquals("Verify system defined is false", false, newCodeAttributes.get(CodeHelper.CODE_SYSTEM_DEFINED_ATTRIBUTE_NAME));
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testCodeValuesAssignedToTable() {
|
||||
// update code
|
||||
final HashMap updateChangeResponse = (HashMap) CodeHelper.updateCode(this.requestSpec, this.responseSpec, createResponseId,
|
||||
codeName + "(CHANGE)", "changes");
|
||||
|
||||
}
|
||||
assertEquals("Verify code name updated", codeName + "(CHANGE)", updateChangeResponse.get(CodeHelper.CODE_NAME_ATTRIBUTE_NAME));
|
||||
|
||||
// delete code
|
||||
final Integer deleteResponseId = (Integer) CodeHelper.deleteCodeById(this.requestSpec, this.responseSpec, createResponseId,
|
||||
CodeHelper.RESPONSE_ID_ATTRIBUTE_NAME);
|
||||
assertEquals("Verify code deleted", createResponseId, deleteResponseId);
|
||||
|
||||
// verify code deleted
|
||||
final HashMap deletedCodeValues = (HashMap) CodeHelper
|
||||
.getCodeById(this.requestSpec, this.generalResponseSpec, deleteResponseId, "");
|
||||
|
||||
Assert.assertNotNull(deletedCodeValues);
|
||||
assertNull("Verify value of codeId", deletedCodeValues.get(CodeHelper.CODE_ID_ATTRIBUTE_NAME));
|
||||
|
||||
assertNull("Verify code name", deletedCodeValues.get(CodeHelper.CODE_NAME_ATTRIBUTE_NAME));
|
||||
assertNull("Verify system defined is false", deletedCodeValues.get(CodeHelper.CODE_SYSTEM_DEFINED_ATTRIBUTE_NAME));
|
||||
}
|
||||
|
||||
// @Ignore()
|
||||
@Test
|
||||
// scenario 57, 60
|
||||
public void testPreventCreateDuplicateCode() {
|
||||
final String codeName = "Client Marital Status";
|
||||
|
||||
// create code
|
||||
final Integer createResponseId = (Integer) CodeHelper.createCode(this.requestSpec, this.responseSpec, codeName,
|
||||
CodeHelper.RESPONSE_ID_ATTRIBUTE_NAME);
|
||||
|
||||
// verify code created
|
||||
final HashMap newCodeAttributes = (HashMap) CodeHelper.getCodeById(this.requestSpec, this.responseSpec, createResponseId, "");
|
||||
|
||||
Assert.assertNotNull(newCodeAttributes);
|
||||
assertEquals("Verify value of codeId", createResponseId, newCodeAttributes.get(CodeHelper.CODE_ID_ATTRIBUTE_NAME));
|
||||
|
||||
assertEquals("Verify code name", codeName, newCodeAttributes.get(CodeHelper.CODE_NAME_ATTRIBUTE_NAME));
|
||||
assertEquals("Verify system defined is false", false, newCodeAttributes.get(CodeHelper.CODE_SYSTEM_DEFINED_ATTRIBUTE_NAME));
|
||||
|
||||
// try to create duplicate-- should fail
|
||||
final List<HashMap> error = (List) CodeHelper.createCode(this.requestSpec, this.generalResponseSpec, codeName,
|
||||
CommonConstants.RESPONSE_ERROR);
|
||||
|
||||
assertEquals("Verify duplication error", "error.msg.code.duplicate.name", error.get(0).get("userMessageGlobalisationCode"));
|
||||
|
||||
// delete code that was just created
|
||||
|
||||
final Integer deleteResponseId = (Integer) CodeHelper.deleteCodeById(this.requestSpec, this.responseSpec, createResponseId,
|
||||
CodeHelper.RESPONSE_ID_ATTRIBUTE_NAME);
|
||||
assertEquals("Verify code deleted", createResponseId, deleteResponseId);
|
||||
|
||||
// verify code deleted
|
||||
final HashMap deletedCodeAttributes = (HashMap) CodeHelper.getCodeById(this.requestSpec, this.generalResponseSpec,
|
||||
deleteResponseId, "");
|
||||
|
||||
Assert.assertNotNull(deletedCodeAttributes);
|
||||
assertNull("Verify value of codeId", deletedCodeAttributes.get(CodeHelper.CODE_ID_ATTRIBUTE_NAME));
|
||||
|
||||
assertNull("Verify code name", deletedCodeAttributes.get(CodeHelper.CODE_NAME_ATTRIBUTE_NAME));
|
||||
assertNull("Verify system defined is false", deletedCodeAttributes.get(CodeHelper.CODE_SYSTEM_DEFINED_ATTRIBUTE_NAME));
|
||||
|
||||
}
|
||||
|
||||
// @Ignore
|
||||
@Test
|
||||
public void testUpdateDeleteSystemDefinedCode() {
|
||||
|
||||
// get any systemDefined code
|
||||
final HashMap systemDefinedCode = (HashMap) CodeHelper.getSystemDefinedCodes(this.requestSpec, this.responseSpec);
|
||||
|
||||
// delete system-defined code should fail
|
||||
final List<HashMap> error = (List) CodeHelper.deleteCodeById(this.requestSpec, this.generalResponseSpec,
|
||||
(Integer) systemDefinedCode.get(CodeHelper.CODE_ID_ATTRIBUTE_NAME), CommonConstants.RESPONSE_ERROR);
|
||||
|
||||
assertEquals("Cannot delete system-defined code", "error.msg.code.systemdefined", error.get(0).get("userMessageGlobalisationCode"));
|
||||
|
||||
// update system-defined code should fail
|
||||
|
||||
final List<HashMap> updateError = (List) CodeHelper.updateCode(this.requestSpec, this.generalResponseSpec,
|
||||
(Integer) systemDefinedCode.get(CodeHelper.CODE_ID_ATTRIBUTE_NAME),
|
||||
systemDefinedCode.get(CodeHelper.CODE_NAME_ATTRIBUTE_NAME) + "CHANGE", CommonConstants.RESPONSE_ERROR);
|
||||
|
||||
assertEquals("Cannot update system-defined code", "error.msg.code.systemdefined",
|
||||
updateError.get(0).get("userMessageGlobalisationCode"));
|
||||
|
||||
}
|
||||
|
||||
// @Ignore
|
||||
@Test
|
||||
public void testCodeValuesNotAssignedToTable() {
|
||||
|
||||
final String codeName = "Marital Status1";
|
||||
|
||||
final String codeValue1 = "Married1";
|
||||
final String codeValue2 = "Unmarried1";
|
||||
|
||||
final int codeValue1Position = 1;
|
||||
final int codeValue2Position = 1;
|
||||
|
||||
final String codeDescription1 = "Description11";
|
||||
final String codeDescription2 = "Description22";
|
||||
|
||||
// create code
|
||||
final Integer createCodeResponseId = (Integer) CodeHelper.createCode(this.requestSpec, this.responseSpec, codeName,
|
||||
CodeHelper.RESPONSE_ID_ATTRIBUTE_NAME);
|
||||
|
||||
// create first code value
|
||||
final Integer createCodeValueResponseId1 = (Integer) CodeHelper.createCodeValue(this.requestSpec, this.responseSpec,
|
||||
createCodeResponseId, codeValue1, codeDescription1, codeValue1Position, CodeHelper.SUBRESPONSE_ID_ATTRIBUTE_NAME);
|
||||
|
||||
// create second code value
|
||||
final Integer createCodeValueResponseId2 = (Integer) CodeHelper.createCodeValue(this.requestSpec, this.responseSpec,
|
||||
createCodeResponseId, codeValue2, codeDescription2, codeValue1Position, CodeHelper.SUBRESPONSE_ID_ATTRIBUTE_NAME);
|
||||
|
||||
// verify two code values created
|
||||
|
||||
final List<HashMap> codeValuesList = (List) CodeHelper.getCodeValuesForCode(this.requestSpec, this.responseSpec,
|
||||
createCodeResponseId, "");
|
||||
|
||||
assertEquals("Number of code values returned matches number created", 2, codeValuesList.size());
|
||||
|
||||
// verify values of first code value
|
||||
final HashMap codeValuesAttributes1 = (HashMap) CodeHelper.getCodeValueById(this.requestSpec, this.responseSpec,
|
||||
createCodeResponseId, createCodeValueResponseId1, "");
|
||||
|
||||
Assert.assertNotNull(codeValuesAttributes1);
|
||||
assertEquals("Verify value of codeValueId", createCodeValueResponseId1,
|
||||
codeValuesAttributes1.get(CodeHelper.CODE_VALUE_ID_ATTRIBUTE_NAME));
|
||||
|
||||
assertEquals("Verify value of code name", codeValue1, codeValuesAttributes1.get(CodeHelper.CODE_VALUE_NAME_ATTRIBUTE_NAME));
|
||||
|
||||
assertEquals("Verify value of code description", codeDescription1,
|
||||
codeValuesAttributes1.get(CodeHelper.CODE_VALUE_DESCRIPTION_ATTRIBUTE_NAME));
|
||||
|
||||
assertEquals("Verify position of code value", codeValue1Position,
|
||||
codeValuesAttributes1.get(CodeHelper.CODE_VALUE_POSITION_ATTRIBUTE_NAME));
|
||||
|
||||
// verify values of second code value
|
||||
final HashMap codeValuesAttributes2 = (HashMap) CodeHelper.getCodeValueById(this.requestSpec, this.responseSpec,
|
||||
createCodeResponseId, createCodeValueResponseId2, "");
|
||||
|
||||
Assert.assertNotNull(codeValuesAttributes2);
|
||||
assertEquals("Verify value of codeValueId", createCodeValueResponseId2,
|
||||
codeValuesAttributes2.get(CodeHelper.CODE_VALUE_ID_ATTRIBUTE_NAME));
|
||||
|
||||
assertEquals("Verify value of code name", codeValue2, codeValuesAttributes2.get(CodeHelper.CODE_VALUE_NAME_ATTRIBUTE_NAME));
|
||||
|
||||
assertEquals("Verify value of code description", codeDescription2,
|
||||
codeValuesAttributes2.get(CodeHelper.CODE_VALUE_DESCRIPTION_ATTRIBUTE_NAME));
|
||||
|
||||
assertEquals("Verify position of code value", codeValue2Position,
|
||||
codeValuesAttributes2.get(CodeHelper.CODE_VALUE_POSITION_ATTRIBUTE_NAME));
|
||||
|
||||
// update code value 1
|
||||
final HashMap codeValueChanges = (HashMap) CodeHelper.updateCodeValue(this.requestSpec, this.responseSpec, createCodeResponseId,
|
||||
createCodeValueResponseId1, codeValue1 + "CHANGE", codeDescription1 + "CHANGE", 4, "changes");
|
||||
|
||||
assertEquals("Verify changed code value name", codeValueChanges.get("name"), codeValue1 + "CHANGE");
|
||||
|
||||
assertEquals("Verify changed code value description", codeValueChanges.get("description"), codeDescription1 + "CHANGE");
|
||||
|
||||
// delete code value
|
||||
Integer deletedCodeValueResponseId1 = (Integer) CodeHelper.deleteCodeValueById(this.requestSpec, this.generalResponseSpec,
|
||||
createCodeResponseId, createCodeValueResponseId1, CodeHelper.SUBRESPONSE_ID_ATTRIBUTE_NAME);
|
||||
|
||||
// Verify code value deleted
|
||||
|
||||
final ArrayList<HashMap> deletedCodeValueAttributes1 = (ArrayList<HashMap>) CodeHelper.getCodeValueById(this.requestSpec,
|
||||
this.generalResponseSpec, createCodeResponseId, deletedCodeValueResponseId1, CommonConstants.RESPONSE_ERROR);
|
||||
|
||||
assertEquals("error.msg.codevalue.id.invalid", deletedCodeValueAttributes1.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
final List<HashMap> deletedCodeValuesList = (List) CodeHelper.getCodeValuesForCode(this.requestSpec, this.responseSpec,
|
||||
createCodeResponseId, "");
|
||||
|
||||
assertEquals("Number of code values is 1", 1, deletedCodeValuesList.size());
|
||||
|
||||
final Integer deletedCodeValueResponseId2 = (Integer) CodeHelper.deleteCodeValueById(this.requestSpec, this.generalResponseSpec,
|
||||
createCodeResponseId, createCodeValueResponseId2, CodeHelper.SUBRESPONSE_ID_ATTRIBUTE_NAME);
|
||||
|
||||
final ArrayList<HashMap> deletedCodeValueAttributes2 = (ArrayList<HashMap>) CodeHelper.getCodeValueById(this.requestSpec,
|
||||
this.generalResponseSpec, createCodeResponseId, deletedCodeValueResponseId2, CommonConstants.RESPONSE_ERROR);
|
||||
|
||||
assertEquals("error.msg.codevalue.id.invalid", deletedCodeValueAttributes2.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
final List<HashMap> deletedCodeValuesList1 = (List) CodeHelper.getCodeValuesForCode(this.requestSpec, this.responseSpec,
|
||||
createCodeResponseId, "");
|
||||
|
||||
assertEquals("Number of code values is 0", 0, deletedCodeValuesList1.size());
|
||||
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testCodeValuesAssignedToTable() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+7
-2
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -38,9 +43,9 @@ public class TemplateIntegrationTest {
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
final HashMap<String, String> metadata = new HashMap<String, String>();
|
||||
final HashMap<String, String> metadata = new HashMap<>();
|
||||
metadata.put("user", "resource_url");
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("name", "foo");
|
||||
map.put("text", "Hello {{template}}");
|
||||
map.put("mappers", metadata);
|
||||
|
||||
+5
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
+353
@@ -0,0 +1,353 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.mifosplatform.batch.domain.BatchRequest;
|
||||
import org.mifosplatform.batch.domain.BatchResponse;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
/**
|
||||
* Helper class for {@link org.mifosplatform.integrationtests.BatchApiTest}. It
|
||||
* takes care of creation of {@code BatchRequest} list and posting this list to
|
||||
* the server.
|
||||
*
|
||||
* @author Rishabh Shukla
|
||||
*
|
||||
* @see org.mifosplatform.integrationtests.BatchApiTest
|
||||
*/
|
||||
public class BatchHelper {
|
||||
|
||||
private static final String BATCH_API_URL = "/mifosng-provider/api/v1/batches?" + Utils.TENANT_IDENTIFIER;
|
||||
private static final String BATCH_API_URL_EXT = BATCH_API_URL + "&enclosingTransaction=true";
|
||||
|
||||
private BatchHelper() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a JSON String for a list of {@code BatchRequest}s
|
||||
*
|
||||
* @param batchRequests
|
||||
* @return JSON String of BatchRequest
|
||||
*/
|
||||
public static String toJsonString(final List<BatchRequest> batchRequests) {
|
||||
return new Gson().toJson(batchRequests);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the converted string response into JSON.
|
||||
*
|
||||
* @param json
|
||||
* @return List<BatchResponse>
|
||||
*/
|
||||
private static List<BatchResponse> fromJsonString(final String json) {
|
||||
return new Gson().fromJson(json, new TypeToken<List<BatchResponse>>() {}.getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of BatchResponse with query parameter enclosing
|
||||
* transaction set to false by posting the jsonified BatchRequest to the
|
||||
* server.
|
||||
*
|
||||
* @param requestSpec
|
||||
* @param responseSpec
|
||||
* @param jsonifiedBatchRequests
|
||||
* @return a list of BatchResponse
|
||||
*/
|
||||
public static List<BatchResponse> postBatchRequestsWithoutEnclosingTransaction(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final String jsonifiedBatchRequests) {
|
||||
final String response = Utils.performServerPost(requestSpec, responseSpec, BATCH_API_URL, jsonifiedBatchRequests, null);
|
||||
return BatchHelper.fromJsonString(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of BatchResponse with query parameter enclosing
|
||||
* transaction set to true by posting the jsonified BatchRequest to the
|
||||
* server.
|
||||
*
|
||||
* @param requestSpec
|
||||
* @param responseSpec
|
||||
* @param jsonifiedBatchRequests
|
||||
* @return a list of BatchResponse
|
||||
*/
|
||||
public static List<BatchResponse> postBatchRequestsWithEnclosingTransaction(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final String jsonifiedBatchRequests) {
|
||||
final String response = Utils.performServerPost(requestSpec, responseSpec, BATCH_API_URL_EXT, jsonifiedBatchRequests, null);
|
||||
return BatchHelper.fromJsonString(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a BatchResponse based on the given BatchRequest, by posting the
|
||||
* request to the server.
|
||||
*
|
||||
* @param BatchRequest
|
||||
* @return List<BatchResponse>
|
||||
*/
|
||||
public static List<BatchResponse> postWithSingleRequest(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final BatchRequest br) {
|
||||
|
||||
final List<BatchRequest> batchRequests = new ArrayList<>();
|
||||
batchRequests.add(br);
|
||||
|
||||
final String jsonifiedRequest = BatchHelper.toJsonString(batchRequests);
|
||||
final List<BatchResponse> response = BatchHelper.postBatchRequestsWithoutEnclosingTransaction(requestSpec, responseSpec,
|
||||
jsonifiedRequest);
|
||||
|
||||
// Verifies that the response result is there
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertTrue(response.size() > 0);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a
|
||||
* {@link org.mifosplatform.batch.command.internal.CreateClientCommandStrategy}
|
||||
* Request as one of the request in Batch.
|
||||
*
|
||||
* @param reqId
|
||||
* @param externalId
|
||||
* @return BatchRequest
|
||||
*/
|
||||
public static BatchRequest createClientRequest(final Long requestId, final String externalId) {
|
||||
|
||||
final BatchRequest br = new BatchRequest();
|
||||
br.setRequestId(requestId);
|
||||
br.setRelativeUrl("clients");
|
||||
br.setMethod("POST");
|
||||
|
||||
final String extId;
|
||||
if (externalId.equals("")) {
|
||||
extId = "ext" + String.valueOf((10000 * Math.random())) + String.valueOf((10000 * Math.random()));
|
||||
} else {
|
||||
extId = externalId;
|
||||
}
|
||||
|
||||
final String body = "{ \"officeId\": 1, \"firstname\": \"Petra\", \"lastname\": \"Yton\"," + "\"externalId\": " + extId
|
||||
+ ", \"dateFormat\": \"dd MMMM yyyy\", \"locale\": \"en\"," + "\"active\": false, \"submittedOnDate\": \"04 March 2009\"}";
|
||||
|
||||
br.setBody(body);
|
||||
|
||||
return br;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a
|
||||
* {@link org.mifosplatform.batch.command.internal.UpdateClientCommandStrategy}
|
||||
* Request with given requestId and reference.
|
||||
*
|
||||
* @param reqId
|
||||
* @param clientId
|
||||
* @return BatchRequest
|
||||
*/
|
||||
public static BatchRequest updateClientRequest(final Long requestId, final Long reference) {
|
||||
|
||||
final BatchRequest br = new BatchRequest();
|
||||
|
||||
br.setRequestId(requestId);
|
||||
br.setRelativeUrl("clients/$.clientId");
|
||||
br.setMethod("PUT");
|
||||
br.setReference(reference);
|
||||
br.setBody("{\"firstname\": \"TestFirstName\", \"lastname\": \"TestLastName\"}");
|
||||
|
||||
return br;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a
|
||||
* {@link org.mifosplatform.batch.command.internal.ApplyLoanCommandStrategy}
|
||||
* Request with given requestId and reference.
|
||||
*
|
||||
* @param requestId
|
||||
* @param reference
|
||||
* @param productId
|
||||
* @return BatchRequest
|
||||
*/
|
||||
public static BatchRequest applyLoanRequest(final Long requestId, final Long reference, final Integer productId) {
|
||||
|
||||
final BatchRequest br = new BatchRequest();
|
||||
|
||||
br.setRequestId(requestId);
|
||||
br.setRelativeUrl("loans");
|
||||
br.setMethod("POST");
|
||||
br.setReference(reference);
|
||||
|
||||
final String body = "{\"dateFormat\": \"dd MMMM yyyy\", \"locale\": \"en_GB\", \"clientId\": \"$.clientId\"," + "\"productId\": "
|
||||
+ productId + ", \"principal\": \"10,000.00\", \"loanTermFrequency\": 12,"
|
||||
+ "\"loanTermFrequencyType\": 2, \"loanType\": \"individual\", \"numberOfRepayments\": 10,"
|
||||
+ "\"repaymentEvery\": 1, \"repaymentFrequencyType\": 2, \"interestRatePerPeriod\": 10,"
|
||||
+ "\"amortizationType\": 1, \"interestType\": 0, \"interestCalculationPeriodType\": 1,"
|
||||
+ "\"transactionProcessingStrategyId\": 1, \"expectedDisbursementDate\": \"10 Jun 2013\","
|
||||
+ "\"submittedOnDate\": \"10 Jun 2013\"}";
|
||||
br.setBody(body);
|
||||
|
||||
return br;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a
|
||||
* {@link org.mifosplatform.batch.command.internal.ApplySavingsCommandStrategy}
|
||||
* Request with given requestId and reference.
|
||||
*
|
||||
* @param requestId
|
||||
* @param reference
|
||||
* @param productId
|
||||
* @return BatchRequest
|
||||
*/
|
||||
public static BatchRequest applySavingsRequest(final Long requestId, final Long reference, final Integer productId) {
|
||||
|
||||
final BatchRequest br = new BatchRequest();
|
||||
|
||||
br.setRequestId(requestId);
|
||||
br.setRelativeUrl("savingsaccounts");
|
||||
br.setMethod("POST");
|
||||
br.setReference(reference);
|
||||
|
||||
final String body = "{\"clientId\": \"$.clientId\", \"productId\": " + productId + ","
|
||||
+ "\"locale\": \"en\", \"dateFormat\": \"dd MMMM yyyy\", \"submittedOnDate\": \"01 March 2011\"}";
|
||||
br.setBody(body);
|
||||
|
||||
return br;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a
|
||||
* {@link org.mifosplatform.batch.command.internal.CreateChargeCommandStrategy}
|
||||
* Request with given requestId and reference
|
||||
*
|
||||
* @param requestId
|
||||
* @param reference
|
||||
* @return BatchRequest
|
||||
*/
|
||||
public static BatchRequest createChargeRequest(final Long requestId, final Long reference) {
|
||||
|
||||
final BatchRequest br = new BatchRequest();
|
||||
br.setRequestId(requestId);
|
||||
br.setRelativeUrl("loans/$.loanId/charges");
|
||||
br.setMethod("POST");
|
||||
br.setReference(reference);
|
||||
|
||||
final String body = "{\"chargeId\": \"2\", \"locale\": \"en\", \"amount\": \"100\", "
|
||||
+ "\"dateFormat\": \"dd MMMM yyyy\", \"dueDate\": \"29 April 2013\"}";
|
||||
br.setBody(body);
|
||||
|
||||
return br;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a
|
||||
* {@link org.mifosplatform.batch.command.internal.CollectChargesCommandStrategy}
|
||||
* Request with given requestId and reference.
|
||||
*
|
||||
* @param requestId
|
||||
* @param reference
|
||||
* @return BatchRequest
|
||||
*/
|
||||
public static BatchRequest collectChargesRequest(final Long requestId, final Long reference) {
|
||||
|
||||
final BatchRequest br = new BatchRequest();
|
||||
|
||||
br.setRequestId(requestId);
|
||||
br.setRelativeUrl("loans/$.loanId/charges");
|
||||
br.setReference(reference);
|
||||
br.setMethod("GET");
|
||||
br.setBody("{ }");
|
||||
|
||||
return br;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a
|
||||
* {@link org.mifosplatform.batch.command.internal.ActivateClientCommandStrategy}
|
||||
* Request with given requestId and reference.
|
||||
*
|
||||
*
|
||||
* @param requestId
|
||||
* @param reference
|
||||
* @return BatchRequest
|
||||
*/
|
||||
public static BatchRequest activateClientRequest(final Long requestId, final Long reference) {
|
||||
|
||||
final BatchRequest br = new BatchRequest();
|
||||
|
||||
br.setRequestId(requestId);
|
||||
br.setRelativeUrl("clients/$.clientId?command=activate");
|
||||
br.setReference(reference);
|
||||
br.setMethod("POST");
|
||||
br.setBody("{\"locale\": \"en\", \"dateFormat\": \"dd MMMM yyyy\", \"activationDate\": \"01 March 2011\"}");
|
||||
|
||||
return br;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a
|
||||
* {@link org.mifosplatform.batch.command.internal.ApproveLoanCommandStrategy}
|
||||
* Request with given requestId and reference.
|
||||
*
|
||||
*
|
||||
* @param requestId
|
||||
* @param reference
|
||||
* @return BatchRequest
|
||||
*/
|
||||
public static BatchRequest approveLoanRequest(final Long requestId, final Long reference) {
|
||||
final BatchRequest br = new BatchRequest();
|
||||
|
||||
br.setRequestId(requestId);
|
||||
br.setRelativeUrl("loans/$.loanId?command=approve");
|
||||
br.setReference(reference);
|
||||
br.setMethod("POST");
|
||||
br.setBody("{\"locale\": \"en\", \"dateFormat\": \"dd MMMM yyyy\", \"approvedOnDate\": \"12 September 2013\","
|
||||
+ "\"note\": \"Loan approval note\"}");
|
||||
|
||||
return br;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a
|
||||
* {@link org.mifosplatform.batch.command.internal.DisburseLoanCommandStrategy}
|
||||
* Request with given requestId and reference.
|
||||
*
|
||||
*
|
||||
* @param requestId
|
||||
* @param reference
|
||||
* @return BatchRequest
|
||||
*/
|
||||
public static BatchRequest disburseLoanRequest(final Long requestId, final Long reference) {
|
||||
final BatchRequest br = new BatchRequest();
|
||||
|
||||
br.setRequestId(requestId);
|
||||
br.setRelativeUrl("loans/$.loanId?command=disburse");
|
||||
br.setReference(reference);
|
||||
br.setMethod("POST");
|
||||
br.setBody("{\"locale\": \"en\", \"dateFormat\": \"dd MMMM yyyy\", \"actualDisbursementDate\": \"15 September 2013\"}");
|
||||
|
||||
return br;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the client with given externalId is not created on the
|
||||
* server.
|
||||
*
|
||||
* @param requestSpec
|
||||
* @param responseSpec
|
||||
* @param externalId
|
||||
*/
|
||||
public static void verifyClientCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String externalId) {
|
||||
System.out.println("------------------------------CHECK CLIENT DETAILS------------------------------------\n");
|
||||
final String CLIENT_URL = "/mifosng-provider/api/v1/clients?externalId=" + externalId + "&" + Utils.TENANT_IDENTIFIER;
|
||||
final Integer responseRecords = Utils.performServerGet(requestSpec, responseSpec, CLIENT_URL, "totalFilteredRecords");
|
||||
Assert.assertEquals("No records found with given externalId", (long) responseRecords, (long) 0);
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common;
|
||||
|
||||
import static com.jayway.restassured.path.json.JsonPath.from;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
public class CalendarHelper {
|
||||
|
||||
private static final String BASE_URL = "/mifosng-provider/api/v1/";
|
||||
private static final String PARENT_ENTITY_NAME = "groups/";
|
||||
private static final String ENITY_NAME = "/calendars";
|
||||
|
||||
public static Integer createMeetingCalendarForGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer groupId, final String startDate, final String frequency, final String interval, final String repeatsOnDay) {
|
||||
|
||||
System.out.println("---------------------------------CREATING A MEETING CALENDAR FOR THE GROUP------------------------------");
|
||||
|
||||
final String CALENDAR_RESOURCE_URL = BASE_URL + PARENT_ENTITY_NAME + groupId + ENITY_NAME + "?" + Utils.TENANT_IDENTIFIER;
|
||||
|
||||
System.out.println(CALENDAR_RESOURCE_URL);
|
||||
|
||||
return Utils.performServerPost(requestSpec, responseSpec, CALENDAR_RESOURCE_URL, getTestCalendarAsJSON(frequency, interval, repeatsOnDay, startDate),
|
||||
"resourceId");
|
||||
}
|
||||
|
||||
public static String getTestCalendarAsJSON(final String frequency, final String interval,final String repeatsOnDay,
|
||||
final String startDate) {
|
||||
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("locale", "en");
|
||||
map.put("frequency", frequency);
|
||||
map.put("interval", interval);
|
||||
map.put("repeating", "true");
|
||||
map.put("repeatsOnDay", repeatsOnDay );
|
||||
map.put("title", Utils.randomNameGenerator("groups_CollectionMeeting", 4));
|
||||
map.put("typeId", "1");
|
||||
map.put("startDate", startDate);
|
||||
System.out.println("map : " + map);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
public static void verifyCalendarCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer generatedGroupId, final Integer generatedCalendarId) {
|
||||
System.out.println("------------------------------CHECK CALENDAR DETAILS------------------------------------\n");
|
||||
final String CLIENT_URL = "/mifosng-provider/api/v1/groups/" + generatedGroupId + "?associations=all&" + Utils.TENANT_IDENTIFIER;
|
||||
final String responseCalendarDetailsinJSON = Utils.performServerGet(requestSpec, responseSpec, CLIENT_URL, "collectionMeetingCalendar");
|
||||
final Integer responseCalendarId = from(responseCalendarDetailsinJSON).get("id");
|
||||
assertEquals("ERROR IN CREATING THE CALENDAR", generatedCalendarId, responseCalendarId);
|
||||
}
|
||||
}
|
||||
Regular → Executable
+151
-3
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -10,7 +15,27 @@ import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
public class ClientHelper {
|
||||
|
||||
private static final String CREATE_CLIENT_URL = "/mifosng-provider/api/v1/clients?tenantIdentifier=default";
|
||||
private final RequestSpecification requestSpec;
|
||||
private final ResponseSpecification responseSpec;
|
||||
|
||||
private static final String CREATE_CLIENT_URL = "/mifosng-provider/api/v1/clients?" + Utils.TENANT_IDENTIFIER;
|
||||
private static final String CLIENT_URL = "/mifosng-provider/api/v1/clients";
|
||||
private static final String CLOSE_CLIENT_COMMAND = "close";
|
||||
private static final String REACTIVATE_CLIENT_COMMAND = "reactivate";
|
||||
private static final String REJECT_CLIENT_COMMAND = "reject";
|
||||
private static final String ACTIVATE_CLIENT_COMMAND ="activate";
|
||||
private static final String WITHDRAW_CLIENT_COMMAND = "withdraw";
|
||||
|
||||
public static final String CREATED_DATE = "27 November 2014";
|
||||
public static final String CREATED_DATE_PLUS_ONE = "28 November 2014";
|
||||
public static final String CREATED_DATE_MINUS_ONE = "27 November 2014";
|
||||
public static final String TRANSACTION_DATE = "01 March 2013";
|
||||
public static final String LAST_TRANSACTION_DATE = "01 March 2013";
|
||||
|
||||
public ClientHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
this.requestSpec = requestSpec;
|
||||
this.responseSpec = responseSpec;
|
||||
}
|
||||
|
||||
public static Integer createClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
return createClient(requestSpec, responseSpec, "04 March 2011");
|
||||
@@ -28,8 +53,21 @@ public class ClientHelper {
|
||||
"clientId");
|
||||
}
|
||||
|
||||
public static Object assignStaffToClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String clientId, final String staffId) {
|
||||
final String CLIENT_ASSIGN_STAFF_URL = "/mifosng-provider/api/v1/clients/" + clientId + "?" + Utils.TENANT_IDENTIFIER
|
||||
+ "&command=assignStaff";
|
||||
|
||||
System.out.println("---------------------------------CREATING A CLIENT---------------------------------------------");
|
||||
return Utils.performServerPost(requestSpec, responseSpec, CLIENT_ASSIGN_STAFF_URL, assignStaffToClientAsJson(staffId), "changes");
|
||||
}
|
||||
|
||||
public static Integer getClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String clientId) {
|
||||
return (Integer) getClient(requestSpec, responseSpec, clientId, "staffId");
|
||||
}
|
||||
|
||||
public static String getTestClientAsJSON(final String dateOfJoining, final String officeId) {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("officeId", officeId);
|
||||
map.put("firstname", Utils.randomNameGenerator("Client_FirstName_", 5));
|
||||
map.put("lastname", Utils.randomNameGenerator("Client_LastName_", 4));
|
||||
@@ -42,15 +80,125 @@ public class ClientHelper {
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
public static String assignStaffToClientAsJson(final String staffId) {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("staffId", staffId);
|
||||
System.out.println("map : " + map);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
public static void verifyClientCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer generatedClientID) {
|
||||
System.out.println("------------------------------CHECK CLIENT DETAILS------------------------------------\n");
|
||||
final String CLIENT_URL = "/mifosng-provider/api/v1/clients/" + generatedClientID + "?tenantIdentifier=default";
|
||||
final String CLIENT_URL = "/mifosng-provider/api/v1/clients/" + generatedClientID + "?" + Utils.TENANT_IDENTIFIER;
|
||||
final Integer responseClientID = Utils.performServerGet(requestSpec, responseSpec, CLIENT_URL, "id");
|
||||
assertEquals("ERROR IN CREATING THE CLIENT", generatedClientID, responseClientID);
|
||||
}
|
||||
|
||||
public static Object getClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String clientId,
|
||||
final String jsonReturn) {
|
||||
final String GET_CLIENT_URL = "/mifosng-provider/api/v1/clients/" + clientId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
|
||||
System.out.println("---------------------------------GET A CLIENT---------------------------------------------");
|
||||
return Utils.performServerGet(requestSpec, responseSpec, GET_CLIENT_URL, jsonReturn);
|
||||
|
||||
}
|
||||
|
||||
public static HashMap getClientStatus(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String clientId) {
|
||||
return (HashMap) getClient(requestSpec, responseSpec, clientId, "status");
|
||||
}
|
||||
|
||||
private static String randomIDGenerator(final String prefix, final int lenOfRandomSuffix) {
|
||||
return Utils.randomStringGenerator(prefix, lenOfRandomSuffix, "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||
}
|
||||
|
||||
private String getCloseClientAsJSON() {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("closureDate", CREATED_DATE_PLUS_ONE);
|
||||
map.put("closureReasonId", "12");
|
||||
String clientJson = new Gson().toJson(map);
|
||||
System.out.println(clientJson);
|
||||
return clientJson;
|
||||
|
||||
}
|
||||
private String getReactivateClientAsJSON() {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("reactivationDate", CREATED_DATE_PLUS_ONE);
|
||||
String clientJson = new Gson().toJson(map);
|
||||
System.out.println(clientJson);
|
||||
return clientJson;
|
||||
|
||||
}
|
||||
private String getRejectClientAsJSON() {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("rejectDate", CREATED_DATE_PLUS_ONE);
|
||||
map.put("rejectReasonId", "15");
|
||||
String clientJson = new Gson().toJson(map);
|
||||
System.out.println(clientJson);
|
||||
return clientJson;
|
||||
|
||||
}
|
||||
private String getActivateClientAsJSON() {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("activationDate", CREATED_DATE_PLUS_ONE);
|
||||
String clientJson = new Gson().toJson(map);
|
||||
System.out.println(clientJson);
|
||||
return clientJson;
|
||||
|
||||
}
|
||||
|
||||
private String getWithdrawClientAsJSON() {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("withdrawDate", CREATED_DATE_PLUS_ONE);
|
||||
map.put("withdrawReasonId", "17");
|
||||
String clientJson = new Gson().toJson(map);
|
||||
System.out.println(clientJson);
|
||||
return clientJson;
|
||||
|
||||
}
|
||||
public HashMap closeClient(final Integer clientId) {
|
||||
System.out.println("--------------------------------- CLOSE CLIENT -------------------------------");
|
||||
return performClientActions(createClientOperationURL(CLOSE_CLIENT_COMMAND, clientId), getCloseClientAsJSON(), clientId);
|
||||
}
|
||||
|
||||
public HashMap reactivateClient(final Integer clientId) {
|
||||
System.out.println("--------------------------------- REACTIVATE CLIENT -------------------------------");
|
||||
return performClientActions(createClientOperationURL(REACTIVATE_CLIENT_COMMAND, clientId), getReactivateClientAsJSON(), clientId);
|
||||
}
|
||||
public HashMap rejectClient(final Integer clientId) {
|
||||
System.out.println("--------------------------------- REJECT CLIENT -------------------------------");
|
||||
return performClientActions(createClientOperationURL(REJECT_CLIENT_COMMAND, clientId), getRejectClientAsJSON(), clientId);
|
||||
}
|
||||
|
||||
public HashMap activateClient(final Integer clientId) {
|
||||
System.out.println("--------------------------------- ACTIVATE CLIENT -------------------------------");
|
||||
return performClientActions(createClientOperationURL(ACTIVATE_CLIENT_COMMAND, clientId), getActivateClientAsJSON(), clientId);
|
||||
}
|
||||
public HashMap withdrawClient(final Integer clientId) {
|
||||
System.out.println("--------------------------------- WITHDRAWN CLIENT -------------------------------");
|
||||
return performClientActions(createClientOperationURL(WITHDRAW_CLIENT_COMMAND, clientId), getWithdrawClientAsJSON(), clientId);
|
||||
}
|
||||
private String createClientOperationURL(final String command, final Integer clientId) {
|
||||
return CLIENT_URL + "/" + clientId + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER;
|
||||
}
|
||||
|
||||
private HashMap performClientActions(final String postURLForClient, final String jsonToBeSent, final Integer clientId) {
|
||||
HashMap status = null;
|
||||
Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForClient, jsonToBeSent, CommonConstants.RESPONSE_STATUS);
|
||||
HashMap response = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
+6
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common;
|
||||
|
||||
|
||||
@@ -7,6 +12,7 @@ public interface CommonConstants {
|
||||
public static final String dateFormat = "dd MMMM yyyy";
|
||||
public static final String RESPONSE_RESOURCE_ID = "resourceId";
|
||||
public static final String RESPONSE_CHANGES = "changes";
|
||||
public static final String RESPONSE_STATUS = "status";
|
||||
public static final String RESPONSE_ERROR = "errors";
|
||||
public static final String RESPONSE_ERROR_MESSAGE_CODE = "userMessageGlobalisationCode";
|
||||
}
|
||||
|
||||
+13
-8
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -20,7 +25,7 @@ public class GlobalConfigurationHelper {
|
||||
}
|
||||
|
||||
public static ArrayList getAllGlobalConfigurations(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
final String GET_ALL_GLOBAL_CONFIG_URL = "/mifosng-provider/api/v1/configurations?tenantIdentifier=default";
|
||||
final String GET_ALL_GLOBAL_CONFIG_URL = "/mifosng-provider/api/v1/configurations?" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("------------------------ RETRIEVING ALL GLOBAL CONFIGURATIONS -------------------------");
|
||||
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, GET_ALL_GLOBAL_CONFIG_URL, "");
|
||||
return (ArrayList) response.get("globalConfiguration");
|
||||
@@ -28,14 +33,14 @@ public class GlobalConfigurationHelper {
|
||||
|
||||
public static HashMap getGlobalConfigurationById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String configId) {
|
||||
final String GET_GLOBAL_CONFIG_BY_ID_URL = "/mifosng-provider/api/v1/configurations/" + configId + "?tenantIdentifier=default";
|
||||
final String GET_GLOBAL_CONFIG_BY_ID_URL = "/mifosng-provider/api/v1/configurations/" + configId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("------------------------ RETRIEVING GLOBAL CONFIGURATION BY ID -------------------------");
|
||||
return Utils.performServerGet(requestSpec, responseSpec, GET_GLOBAL_CONFIG_BY_ID_URL, "");
|
||||
}
|
||||
|
||||
public static Integer updateValueForGlobalConfiguration(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final String configId, final String value) {
|
||||
final String GLOBAL_CONFIG_UPDATE_URL = "/mifosng-provider/api/v1/configurations/" + configId + "?tenantIdentifier=default";
|
||||
final String GLOBAL_CONFIG_UPDATE_URL = "/mifosng-provider/api/v1/configurations/" + configId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("---------------------------------UPDATE VALUE FOR GLOBAL CONFIG---------------------------------------------");
|
||||
return Utils.performServerPut(requestSpec, responseSpec, GLOBAL_CONFIG_UPDATE_URL, updateGlobalConfigUpdateValueAsJSON(value),
|
||||
"resourceId");
|
||||
@@ -43,7 +48,7 @@ public class GlobalConfigurationHelper {
|
||||
|
||||
public static Integer updateEnabledFlagForGlobalConfiguration(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final String configId, final Boolean enabled) {
|
||||
final String GLOBAL_CONFIG_UPDATE_URL = "/mifosng-provider/api/v1/configurations/" + configId + "?tenantIdentifier=default";
|
||||
final String GLOBAL_CONFIG_UPDATE_URL = "/mifosng-provider/api/v1/configurations/" + configId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
System.out
|
||||
.println("---------------------------------UPDATE GLOBAL CONFIG FOR ENABLED FLAG---------------------------------------------");
|
||||
return Utils.performServerPut(requestSpec, responseSpec, GLOBAL_CONFIG_UPDATE_URL,
|
||||
@@ -52,7 +57,7 @@ public class GlobalConfigurationHelper {
|
||||
|
||||
public static ArrayList getGlobalConfigurationIsCacheEnabled(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec) {
|
||||
final String GET_IS_CACHE_GLOBAL_CONFIG_URL = "/mifosng-provider/api/v1/caches?tenantIdentifier=default";
|
||||
final String GET_IS_CACHE_GLOBAL_CONFIG_URL = "/mifosng-provider/api/v1/caches?" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("------------------------ RETRIEVING IS CACHE ENABLED GLOBAL CONFIGURATION -------------------------");
|
||||
final ArrayList<HashMap> response = Utils.performServerGet(requestSpec, responseSpec, GET_IS_CACHE_GLOBAL_CONFIG_URL, "");
|
||||
return response;
|
||||
@@ -60,14 +65,14 @@ public class GlobalConfigurationHelper {
|
||||
|
||||
public static HashMap updateIsCacheEnabledForGlobalConfiguration(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final String cacheType) {
|
||||
final String IS_CACHE_GLOBAL_CONFIG_UPDATE_URL = "/mifosng-provider/api/v1/caches?tenantIdentifier=default";
|
||||
final String IS_CACHE_GLOBAL_CONFIG_UPDATE_URL = "/mifosng-provider/api/v1/caches?" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("------------------UPDATE GLOBAL CONFIG FOR IS CACHE ENABLED----------------------");
|
||||
return Utils.performServerPut(requestSpec, responseSpec, IS_CACHE_GLOBAL_CONFIG_UPDATE_URL,
|
||||
updateIsCacheEnabledGlobalConfigUpdateAsJSON(cacheType), "changes");
|
||||
}
|
||||
|
||||
public static String updateGlobalConfigUpdateValueAsJSON(final String value) {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("value", value);
|
||||
System.out.println("map : " + map);
|
||||
return new Gson().toJson(map);
|
||||
@@ -81,7 +86,7 @@ public class GlobalConfigurationHelper {
|
||||
}
|
||||
|
||||
public static String updateIsCacheEnabledGlobalConfigUpdateAsJSON(final String cacheType) {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("cacheType", cacheType);
|
||||
System.out.println("map : " + map);
|
||||
return new Gson().toJson(map);
|
||||
|
||||
mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/GroupHelper.java
Regular → Executable
+51
-19
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -16,7 +21,7 @@ import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
public class GroupHelper {
|
||||
|
||||
private static final String CREATE_GROUP_URL = "/mifosng-provider/api/v1/groups?tenantIdentifier=default";
|
||||
private static final String CREATE_GROUP_URL = "/mifosng-provider/api/v1/groups?" + Utils.TENANT_IDENTIFIER;
|
||||
|
||||
public static Integer createGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
@SuppressWarnings("unused") final boolean active) {
|
||||
@@ -38,7 +43,7 @@ public class GroupHelper {
|
||||
public static Integer associateClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String groupId, final String clientMember) {
|
||||
final String GROUP_ASSOCIATE_URL = "/mifosng-provider/api/v1/groups/" + groupId
|
||||
+ "?command=associateClients&tenantIdentifier=default";
|
||||
+ "?command=associateClients&" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("---------------------------------Associate Client To A GROUP---------------------------------------------");
|
||||
return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, associateClientAsJSON(clientMember), "groupId");
|
||||
}
|
||||
@@ -46,33 +51,46 @@ public class GroupHelper {
|
||||
public static Integer disAssociateClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String groupId, final String clientMember) {
|
||||
final String GROUP_ASSOCIATE_URL = "/mifosng-provider/api/v1/groups/" + groupId
|
||||
+ "?command=disassociateClients&tenantIdentifier=default";
|
||||
+ "?command=disassociateClients&" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("---------------------------------Disassociate Client To A GROUP---------------------------------------------");
|
||||
return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, associateClientAsJSON(clientMember), "groupId");
|
||||
}
|
||||
|
||||
public static Integer activateGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String groupId) {
|
||||
final String GROUP_ASSOCIATE_URL = "/mifosng-provider/api/v1/groups/" + groupId + "?command=activate&tenantIdentifier=default";
|
||||
final String GROUP_ASSOCIATE_URL = "/mifosng-provider/api/v1/groups/" + groupId + "?command=activate&" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("---------------------------------Activate A GROUP---------------------------------------------");
|
||||
return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, activateGroupAsJSON(""), "groupId");
|
||||
}
|
||||
|
||||
public static Integer updateGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String name,
|
||||
final String groupId) {
|
||||
final String GROUP_ASSOCIATE_URL = "/mifosng-provider/api/v1/groups/" + groupId + "?tenantIdentifier=default";
|
||||
final String GROUP_ASSOCIATE_URL = "/mifosng-provider/api/v1/groups/" + groupId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("---------------------------------UPDATE GROUP---------------------------------------------");
|
||||
return Utils.performServerPut(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, updateGroupAsJSON(name), "groupId");
|
||||
}
|
||||
|
||||
public static Integer deleteGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String groupId) {
|
||||
final String GROUP_ASSOCIATE_URL = "/mifosng-provider/api/v1/groups/" + groupId + "?tenantIdentifier=default";
|
||||
final String GROUP_ASSOCIATE_URL = "/mifosng-provider/api/v1/groups/" + groupId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("---------------------------------DELETE GROUP---------------------------------------------");
|
||||
return Utils.performServerDelete(requestSpec, responseSpec, GROUP_ASSOCIATE_URL, "groupId");
|
||||
}
|
||||
|
||||
|
||||
public static Object assignStaff(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String groupId,final Long staffId){
|
||||
final String GROUP_ASSIGN_STAFF_URL = "/mifosng-provider/api/v1/groups/" + groupId + "?" + Utils.TENANT_IDENTIFIER + "&command=assignStaff";
|
||||
System.out.println("---------------------------------DELETE GROUP---------------------------------------------");
|
||||
return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSIGN_STAFF_URL,assignStaffAsJSON(staffId),"changes");
|
||||
}
|
||||
public static Object assignStaffInheritStaffForClientAccounts(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String groupId,final String staffId){
|
||||
final String GROUP_ASSIGN_STAFF_URL = "/mifosng-provider/api/v1/groups/" + groupId + "?" + Utils.TENANT_IDENTIFIER + "&command=assignStaff";
|
||||
System.out.println("---------------------------------DELETE GROUP---------------------------------------------");
|
||||
return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSIGN_STAFF_URL,assignStaffAndInheritStaffForClientAccountsAsJSON(staffId),"changes");
|
||||
}
|
||||
|
||||
|
||||
public static String getTestGroupAsJSON(final boolean active, final String activationDate) {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("officeId", "1");
|
||||
map.put("name", randomNameGenerator("Group_Name_", 5));
|
||||
map.put("externalId", randomIDGenerator("ID_", 7));
|
||||
@@ -93,7 +111,7 @@ public class GroupHelper {
|
||||
|
||||
public static String associateClientAsJSON(final String clientMember) {
|
||||
final HashMap<String, List<String>> map = new HashMap<String, List<String>>();
|
||||
final List<String> list = new ArrayList<String>();
|
||||
final List<String> list = new ArrayList<>();
|
||||
list.add(clientMember);
|
||||
map.put("clientMembers", list);
|
||||
System.out.println("map : " + map);
|
||||
@@ -101,7 +119,7 @@ public class GroupHelper {
|
||||
}
|
||||
|
||||
public static String activateGroupAsJSON(final String activationDate) {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("locale", "en");
|
||||
if (StringUtils.isNotEmpty(activationDate)) {
|
||||
@@ -115,16 +133,30 @@ public class GroupHelper {
|
||||
}
|
||||
|
||||
public static String updateGroupAsJSON(final String name) {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("name", name);
|
||||
System.out.println("map : " + map);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
public static String assignStaffAsJSON(final Long staffId) {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("staffId", staffId);
|
||||
System.out.println("map : " + map);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
public static String assignStaffAndInheritStaffForClientAccountsAsJSON(final String staffId) {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("staffId", staffId);
|
||||
map.put("inheritStaffForClientAccounts","true");
|
||||
System.out.println("map : " + map);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
|
||||
public static void verifyGroupCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer generatedGroupID) {
|
||||
System.out.println("------------------------------CHECK GROUP DETAILS------------------------------------\n");
|
||||
final String GROUP_URL = "/mifosng-provider/api/v1/groups/" + generatedGroupID + "?tenantIdentifier=default";
|
||||
final String GROUP_URL = "/mifosng-provider/api/v1/groups/" + generatedGroupID + "?" + Utils.TENANT_IDENTIFIER;
|
||||
final Integer responseGroupID = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "id");
|
||||
assertEquals("ERROR IN CREATING THE GROUP", generatedGroupID, responseGroupID);
|
||||
}
|
||||
@@ -132,7 +164,7 @@ public class GroupHelper {
|
||||
public static void verifyGroupDetails(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer generatedGroupID, final String field, final String expectedValue) {
|
||||
System.out.println("------------------------------CHECK GROUP DETAILS------------------------------------\n");
|
||||
final String GROUP_URL = "/mifosng-provider/api/v1/groups/" + generatedGroupID + "?tenantIdentifier=default";
|
||||
final String GROUP_URL = "/mifosng-provider/api/v1/groups/" + generatedGroupID + "?" + Utils.TENANT_IDENTIFIER;
|
||||
final String responseValue = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, field);
|
||||
assertEquals("ERROR IN CREATING THE GROUP", expectedValue, responseValue);
|
||||
}
|
||||
@@ -140,36 +172,36 @@ public class GroupHelper {
|
||||
public static void verifyGroupActivatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer generatedGroupID, final boolean generatedGroupStatus) {
|
||||
System.out.println("------------------------------CHECK GROUP STATUS------------------------------------\n");
|
||||
final String GROUP_URL = "/mifosng-provider/api/v1/groups/" + generatedGroupID + "?tenantIdentifier=default";
|
||||
final String GROUP_URL = "/mifosng-provider/api/v1/groups/" + generatedGroupID + "?" + Utils.TENANT_IDENTIFIER;
|
||||
final Boolean responseGroupStatus = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "active");
|
||||
assertEquals("ERROR IN ACTIVATING THE GROUP", generatedGroupStatus, responseGroupStatus);
|
||||
}
|
||||
|
||||
public static void verifyGroupMembers(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer generatedGroupID, final Integer groupMember) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
List<String> list = new ArrayList<>();
|
||||
System.out.println("------------------------------CHECK GROUP MEMBERS------------------------------------\n");
|
||||
final String GROUP_URL = "/mifosng-provider/api/v1/groups/" + generatedGroupID
|
||||
+ "?associations=clientMembers&tenantIdentifier=default";
|
||||
+ "?associations=clientMembers&" + Utils.TENANT_IDENTIFIER;
|
||||
list = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "clientMembers");
|
||||
assertTrue("ERROR IN GROUP MEMBER", list.toString().contains("id=" + groupMember.toString()));
|
||||
}
|
||||
|
||||
public static void verifyEmptyGroupMembers(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer generatedGroupID) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
List<String> list = new ArrayList<>();
|
||||
System.out.println("------------------------------CHECK EMPTY GROUP MEMBER LIST------------------------------------\n");
|
||||
final String GROUP_URL = "/mifosng-provider/api/v1/groups/" + generatedGroupID
|
||||
+ "?associations=clientMembers&tenantIdentifier=default";
|
||||
+ "?associations=clientMembers&" + Utils.TENANT_IDENTIFIER;
|
||||
list = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "clientMembers");
|
||||
assertEquals("GROUP MEMBER LIST NOT EMPTY", list, null);
|
||||
}
|
||||
|
||||
public static void verifyGroupDeleted(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer generatedGroupID) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
List<String> list = new ArrayList<>();
|
||||
System.out.println("------------------------------CHECK GROUP DELETED------------------------------------\n");
|
||||
final String GROUP_URL = "/mifosng-provider/api/v1/groups/?tenantIdentifier=default";
|
||||
final String GROUP_URL = "/mifosng-provider/api/v1/groups/?" + Utils.TENANT_IDENTIFIER;
|
||||
list = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "pageItems");
|
||||
|
||||
assertFalse("GROUP NOT DELETED", list.toString().contains("id=" + generatedGroupID.toString()));
|
||||
|
||||
+10
-5
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -28,9 +33,9 @@ public class HolidayHelper {
|
||||
}
|
||||
|
||||
public static String getCreateHolidayDataAsJSON() {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
List<HashMap<String, String>> offices = new ArrayList<HashMap<String, String>>();
|
||||
HashMap<String, String> officeMap = new HashMap<String, String>();
|
||||
HashMap<String, String> officeMap = new HashMap<>();
|
||||
officeMap.put("officeId", OFFICE_ID);
|
||||
offices.add(officeMap);
|
||||
|
||||
@@ -48,7 +53,7 @@ public class HolidayHelper {
|
||||
}
|
||||
|
||||
public static String getActivateHolidayDataAsJSON() {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
String activateHoliday = new Gson().toJson(map);
|
||||
System.out.println(activateHoliday);
|
||||
return activateHoliday;
|
||||
@@ -59,13 +64,13 @@ public class HolidayHelper {
|
||||
}
|
||||
|
||||
public static Integer activateHolidays(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String holidayID) {
|
||||
final String ACTIVATE_HOLIDAY_URL = HOLIDAYS_URL + "/" + holidayID + "?command=activate";
|
||||
final String ACTIVATE_HOLIDAY_URL = HOLIDAYS_URL + "/" + holidayID + "?command=activate&" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerPost(requestSpec, responseSpec, ACTIVATE_HOLIDAY_URL, getActivateHolidayDataAsJSON(), "resourceId");
|
||||
}
|
||||
|
||||
public static HashMap getHolidayById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String holidayID) {
|
||||
final String GET_HOLIDAY_BY_ID_URL = HOLIDAYS_URL + "/" + holidayID + "?tenantIdentifier=default";
|
||||
final String GET_HOLIDAY_BY_ID_URL = HOLIDAYS_URL + "/" + holidayID + "?" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("------------------------ RETRIEVING HOLIDAY BY ID -------------------------");
|
||||
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, GET_HOLIDAY_BY_ID_URL, "");
|
||||
return response;
|
||||
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
public class HookHelper {
|
||||
|
||||
private final RequestSpecification requestSpec;
|
||||
private final ResponseSpecification responseSpec;
|
||||
|
||||
private static final String CREATE_HOOK_URL = "/mifosng-provider/api/v1/hooks?" + Utils.TENANT_IDENTIFIER;
|
||||
|
||||
public HookHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
this.requestSpec = requestSpec;
|
||||
this.responseSpec = responseSpec;
|
||||
}
|
||||
|
||||
public Integer createHook(final String payloadURL) {
|
||||
System.out.println("---------------------------------CREATING A HOOK---------------------------------------------");
|
||||
return Utils.performServerPost(requestSpec, responseSpec, CREATE_HOOK_URL, getTestHookAsJson(payloadURL),
|
||||
"resourceId");
|
||||
}
|
||||
|
||||
public String getTestHookAsJson(final String payloadURL) {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("name", "Web");
|
||||
map.put("displayName", Utils.randomNameGenerator("Hook_DisplayName_", 5));
|
||||
map.put("isActive", "true");
|
||||
final HashMap<String, String> config = new HashMap<>();
|
||||
config.put("Content Type", "json");
|
||||
config.put("Payload URL", payloadURL);
|
||||
map.put("config", config);
|
||||
final ArrayList<HashMap<String, String>> events = new ArrayList<>();
|
||||
final HashMap<String, String> createOfficeEvent = new HashMap<>();
|
||||
createOfficeEvent.put("actionName", "CREATE");
|
||||
createOfficeEvent.put("entityName", "OFFICE");
|
||||
events.add(createOfficeEvent);
|
||||
map.put("events", events);
|
||||
System.out.println("map : " + map);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package org.mifosplatform.integrationtests.common;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
public class LoanRescheduleRequestHelper {
|
||||
private final RequestSpecification requestSpec;
|
||||
private final ResponseSpecification responseSpec;
|
||||
|
||||
private static final String LOAN_RESCHEDULE_REQUEST_URL = "/mifosng-provider/api/v1/rescheduleloans";
|
||||
|
||||
public LoanRescheduleRequestHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
this.requestSpec = requestSpec;
|
||||
this.responseSpec = responseSpec;
|
||||
}
|
||||
|
||||
public Integer createLoanRescheduleRequest(final String requestJSON) {
|
||||
final String URL = LOAN_RESCHEDULE_REQUEST_URL + "?" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerPost(this.requestSpec, this.responseSpec, URL, requestJSON, "resourceId");
|
||||
}
|
||||
|
||||
public Integer rejectLoanRescheduleRequest(final Integer requestId, final String requestJSON) {
|
||||
final String URL = LOAN_RESCHEDULE_REQUEST_URL + "/" + requestId + "?" + Utils.TENANT_IDENTIFIER + "&command=reject";
|
||||
|
||||
return Utils.performServerPost(this.requestSpec, this.responseSpec, URL, requestJSON, "resourceId");
|
||||
}
|
||||
|
||||
public Integer approveLoanRescheduleRequest(final Integer requestId, final String requestJSON) {
|
||||
final String URL = LOAN_RESCHEDULE_REQUEST_URL + "/" + requestId + "?" + Utils.TENANT_IDENTIFIER + "&command=approve";
|
||||
|
||||
return Utils.performServerPost(this.requestSpec, this.responseSpec, URL, requestJSON, "resourceId");
|
||||
}
|
||||
|
||||
public Object getLoanRescheduleRequest(final Integer requestId, final String param) {
|
||||
final String URL = LOAN_RESCHEDULE_REQUEST_URL + "/" + requestId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
|
||||
return Utils.performServerGet(requestSpec, responseSpec, URL, param);
|
||||
}
|
||||
|
||||
public void verifyCreationOfLoanRescheduleRequest(final Integer requestId) {
|
||||
final String URL = LOAN_RESCHEDULE_REQUEST_URL + "/" + requestId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
|
||||
final Integer id = Utils.performServerGet(requestSpec, responseSpec, URL, "id");
|
||||
assertEquals("ERROR IN CREATING LOAN RESCHEDULE REQUEST", requestId, id);
|
||||
}
|
||||
}
|
||||
+6
-1
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -26,7 +31,7 @@ public class OfficeHelper {
|
||||
|
||||
|
||||
public static String getAsJSON(final String openingDate) {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("parentId", "1");
|
||||
map.put("name", Utils.randomNameGenerator("Office_", 4));
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
|
||||
+21
-16
@@ -1,8 +1,12 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
@@ -11,7 +15,7 @@ import com.jayway.restassured.builder.ResponseSpecBuilder;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
@SuppressWarnings({ "unused", "rawtypes", "unchecked" })
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public class SchedulerJobHelper {
|
||||
|
||||
private final RequestSpecification requestSpec;
|
||||
@@ -23,7 +27,7 @@ public class SchedulerJobHelper {
|
||||
}
|
||||
|
||||
public static ArrayList getAllSchedulerJobs(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
final String GET_ALL_SCHEDULER_JOBS_URL = "/mifosng-provider/api/v1/jobs?tenantIdentifier=default";
|
||||
final String GET_ALL_SCHEDULER_JOBS_URL = "/mifosng-provider/api/v1/jobs?" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("------------------------ RETRIEVING ALL SCHEDULER JOBS -------------------------");
|
||||
final ArrayList response = Utils.performServerGet(requestSpec, responseSpec, GET_ALL_SCHEDULER_JOBS_URL, "");
|
||||
return response;
|
||||
@@ -31,28 +35,29 @@ public class SchedulerJobHelper {
|
||||
|
||||
public static HashMap getSchedulerJobById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String jobId) {
|
||||
final String GET_SCHEDULER_JOB_BY_ID_URL = "/mifosng-provider/api/v1/jobs/" + jobId + "?tenantIdentifier=default";
|
||||
final String GET_SCHEDULER_JOB_BY_ID_URL = "/mifosng-provider/api/v1/jobs/" + jobId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("------------------------ RETRIEVING SCHEDULER JOB BY ID -------------------------");
|
||||
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, GET_SCHEDULER_JOB_BY_ID_URL, "");
|
||||
return response;
|
||||
}
|
||||
|
||||
public static HashMap getSchedulerStatus(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
final String GET_SCHEDULER_STATUS_URL = "/mifosng-provider/api/v1/scheduler?tenantIdentifier=default";
|
||||
final String GET_SCHEDULER_STATUS_URL = "/mifosng-provider/api/v1/scheduler?" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("------------------------ RETRIEVING SCHEDULER STATUS -------------------------");
|
||||
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, GET_SCHEDULER_STATUS_URL, "");
|
||||
return response;
|
||||
}
|
||||
|
||||
public static void updateSchedulerStatus(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final String command) {
|
||||
final String UPDATE_SCHEDULER_STATUS_URL = "/mifosng-provider/api/v1/scheduler?command=" + command +"&tenantIdentifier=default";
|
||||
|
||||
public static void updateSchedulerStatus(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String command) {
|
||||
final String UPDATE_SCHEDULER_STATUS_URL = "/mifosng-provider/api/v1/scheduler?command=" + command + "&" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("------------------------ UPDATING SCHEDULER STATUS -------------------------");
|
||||
Utils.performServerPost(requestSpec, responseSpec, UPDATE_SCHEDULER_STATUS_URL, runSchedulerJobAsJSON(), null);
|
||||
}
|
||||
|
||||
public static HashMap updateSchedulerJob(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String jobId, final String active) {
|
||||
final String UPDATE_SCHEDULER_JOB_URL = "/mifosng-provider/api/v1/jobs/" + jobId + "?tenantIdentifier=default";
|
||||
final String UPDATE_SCHEDULER_JOB_URL = "/mifosng-provider/api/v1/jobs/" + jobId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("------------------------ UPDATING SCHEDULER JOB -------------------------");
|
||||
final HashMap response = Utils.performServerPut(requestSpec, responseSpec, UPDATE_SCHEDULER_JOB_URL,
|
||||
updateSchedulerJobAsJSON(active), "changes");
|
||||
@@ -60,7 +65,7 @@ public class SchedulerJobHelper {
|
||||
}
|
||||
|
||||
public static String updateSchedulerJobAsJSON(final String active) {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("active", active);
|
||||
System.out.println("map : " + map);
|
||||
return new Gson().toJson(map);
|
||||
@@ -68,27 +73,27 @@ public class SchedulerJobHelper {
|
||||
|
||||
public static ArrayList getSchedulerJobHistory(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String jobId) {
|
||||
final String GET_SCHEDULER_STATUS_URL = "/mifosng-provider/api/v1/jobs/" + jobId + "/runhistory?tenantIdentifier=default";
|
||||
final String GET_SCHEDULER_STATUS_URL = "/mifosng-provider/api/v1/jobs/" + jobId + "/runhistory?" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("------------------------ RETRIEVING SCHEDULER JOB HISTORY -------------------------");
|
||||
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, GET_SCHEDULER_STATUS_URL, "");
|
||||
return (ArrayList) response.get("pageItems");
|
||||
}
|
||||
|
||||
public static void runSchedulerJob(final RequestSpecification requestSpec, final String jobId) {
|
||||
final ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(202).build();
|
||||
final String RUN_SCHEDULER_JOB_URL = "/mifosng-provider/api/v1/jobs/" + jobId + "?command=executeJob&tenantIdentifier=default";
|
||||
final ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(202).build();
|
||||
final String RUN_SCHEDULER_JOB_URL = "/mifosng-provider/api/v1/jobs/" + jobId + "?command=executeJob&" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("------------------------ RUN SCHEDULER JOB -------------------------");
|
||||
Utils.performServerPost(requestSpec, responseSpec, RUN_SCHEDULER_JOB_URL, runSchedulerJobAsJSON(), null);
|
||||
}
|
||||
|
||||
|
||||
public static String runSchedulerJobAsJSON() {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
String runSchedulerJob = new Gson().toJson(map);
|
||||
System.out.println(runSchedulerJob);
|
||||
return runSchedulerJob;
|
||||
}
|
||||
|
||||
public void excuteJob(String JobName) throws InterruptedException {
|
||||
public void executeJob(String JobName) throws InterruptedException {
|
||||
ArrayList<HashMap> allSchedulerJobsData = getAllSchedulerJobs(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(allSchedulerJobsData);
|
||||
|
||||
|
||||
mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/StaffHelper.java
Executable
+60
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class StaffHelper {
|
||||
|
||||
private static final String TRANSFER_STAFF_URL = "/mifosng-provider/api/v1/groups";
|
||||
|
||||
private static final String CREATE_STAFF_URL = "/mifosng-provider/api/v1/staff";
|
||||
|
||||
private static final String RESOURCE_ID = "resourceId";
|
||||
|
||||
public static final String GROUP_ID = "groupId";
|
||||
|
||||
|
||||
|
||||
public static Integer transferStaffToGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer groupId,final Integer staffToTransfer ,final String note){
|
||||
final String url = TRANSFER_STAFF_URL + "/" + groupId + "?command=transferStaff&"+Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerPost(requestSpec, responseSpec, url, transferStaffToGroupAsJSON(staffToTransfer, note), GROUP_ID);
|
||||
}
|
||||
|
||||
|
||||
public static String transferStaffToGroupAsJSON(final Integer staffToTransferId,final String note) {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("staffId", staffToTransferId);
|
||||
map.put("note", note);
|
||||
System.out.println("map : " + map);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static Integer createStaff(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
final String url = CREATE_STAFF_URL +"?"+ Utils.TENANT_IDENTIFIER ;
|
||||
return Utils.performServerPost(requestSpec, responseSpec, url, createStaffAsJSON(), RESOURCE_ID);
|
||||
}
|
||||
|
||||
|
||||
public static String createStaffAsJSON(){
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("officeId",1);
|
||||
map.put("firstname", Utils.randomNameGenerator("michael_",5));
|
||||
map.put("lastname", Utils.randomNameGenerator("Doe_",4));
|
||||
map.put("isLoanOfficer", true);
|
||||
System.out.println("map : " + map);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+20
-3
@@ -1,6 +1,12 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
|
||||
@@ -10,10 +16,11 @@ import com.google.gson.Gson;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
@SuppressWarnings({ "unused", "rawtypes" })
|
||||
@SuppressWarnings({ "unused", "rawtypes", "unchecked" })
|
||||
public class StandingInstructionsHelper {
|
||||
|
||||
private static final String STANDING_INSTRUCTIONS_URL = "/mifosng-provider/api/v1/standinginstructions";
|
||||
private static final String STANDING_INSTRUCTIONS_RUNHISTORY_URL = "/mifosng-provider/api/v1/standinginstructionrunhistory";
|
||||
private static final String LOCALE = "en_GB";
|
||||
private static final String OFFICE_ID = "1";
|
||||
private static final String INSTRUCTION_TYPE_FIXED = "1";
|
||||
@@ -48,7 +55,7 @@ public class StandingInstructionsHelper {
|
||||
public String build(final String clientId, final String fromAccountId, final String toAccountId, final String fromAccountType,
|
||||
final String toAccountType, final String validFrom, final String validTo, final String monthDay) {
|
||||
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("name", Utils.randomNameGenerator("STANDING_INSTRUCTION_", 5));
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("monthDayFormat", "dd MMMM");
|
||||
@@ -70,7 +77,7 @@ public class StandingInstructionsHelper {
|
||||
map.put("validTill", validTo);
|
||||
map.put("recurrenceType", RECURRENCE_TYPE_PERIODIC);
|
||||
map.put("recurrenceInterval", "1");
|
||||
map.put("recurrenceFrequency", RECURRENCE_FREQUENCY_MONTHS);
|
||||
map.put("recurrenceFrequency", RECURRENCE_FREQUENCY_WEEKS);
|
||||
map.put("recurrenceOnMonthDay", monthDay);
|
||||
String savingsApplicationJSON = new Gson().toJson(map);
|
||||
System.out.println(savingsApplicationJSON);
|
||||
@@ -95,4 +102,14 @@ public class StandingInstructionsHelper {
|
||||
final HashMap response = Utils.performServerGet(this.requestSpec, this.responseSpec, GET_STANDING_INSTRUCTION_BY_ID_URL, "");
|
||||
return response;
|
||||
}
|
||||
|
||||
public List<HashMap> getStandingInstructionHistory(Integer fromSavingsId, Integer fromAccountType, Integer fromClientId, Integer transferType) {
|
||||
final String STANDING_INSTRUCTIONS_HISTORY_URL = STANDING_INSTRUCTIONS_RUNHISTORY_URL + "?" + Utils.TENANT_IDENTIFIER
|
||||
+ "&fromSavingsId=" + fromSavingsId + "&fromAccountType=" + fromAccountType + "&clientId=" + fromClientId
|
||||
+ "&transferType=" + transferType;
|
||||
System.out.println("STANDING_INSTRUCTIONS_HISTORY_URL="+STANDING_INSTRUCTIONS_HISTORY_URL);
|
||||
final List<HashMap> response = (List<HashMap>) Utils.performServerGet(this.requestSpec, this.responseSpec,
|
||||
STANDING_INSTRUCTIONS_HISTORY_URL, "pageItems");
|
||||
return response;
|
||||
}
|
||||
}
|
||||
+9
-4
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
@@ -8,9 +13,9 @@ import java.util.HashMap;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class surveyHelper {
|
||||
public class SurveyHelper {
|
||||
|
||||
private static final String FULFIL_SURVEY_URL = "/mifosng-provider/api/v1/survey/ppi_kenya_2009/clientId?tenantIdentifier=default";
|
||||
private static final String FULFIL_SURVEY_URL = "/mifosng-provider/api/v1/survey/ppi_kenya_2009/clientId?" + Utils.TENANT_IDENTIFIER;
|
||||
|
||||
public static Integer fulfilSurvey(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
return fulfilSurvey(requestSpec, responseSpec, "04 March 2011");
|
||||
@@ -23,7 +28,7 @@ public class surveyHelper {
|
||||
}
|
||||
|
||||
public static String getTestPPIAsJSON() {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
|
||||
map.put("date", "2014-05-19 00:00:00");
|
||||
map.put("ppi_household_members_cd_q1_householdmembers","107");
|
||||
@@ -47,7 +52,7 @@ public class surveyHelper {
|
||||
public static void verifySurveyCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer generatedClientID) {
|
||||
System.out.println("------------------------------CHECK CLIENT DETAILS------------------------------------\n");
|
||||
final String SURVEY_URL = "/mifosng-provider/api/v1/Survey/ppi_kenya_2009/clientid/entryId" + generatedClientID + "?tenantIdentifier=default";
|
||||
final String SURVEY_URL = "/mifosng-provider/api/v1/Survey/ppi_kenya_2009/clientid/entryId" + generatedClientID + "?" + Utils.TENANT_IDENTIFIER;
|
||||
final Integer responseClientID = Utils.performServerGet(requestSpec, responseSpec, SURVEY_URL, "id");
|
||||
assertEquals("ERROR IN CREATING THE CLIENT", generatedClientID, responseClientID);
|
||||
}
|
||||
+13
-2
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common;
|
||||
|
||||
import static com.jayway.restassured.RestAssured.given;
|
||||
@@ -8,6 +13,7 @@ import static org.junit.Assert.fail;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@@ -18,6 +24,11 @@ import com.jayway.restassured.path.json.JsonPath;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
|
||||
/**
|
||||
* Util for RestAssured tests.
|
||||
* This class here in src/integrationTest is copy/pasted to src/test; please keep them in sync.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class Utils {
|
||||
|
||||
@@ -28,7 +39,7 @@ public class Utils {
|
||||
public static void initializeRESTAssured() {
|
||||
RestAssured.baseURI = "https://localhost";
|
||||
RestAssured.port = 8443;
|
||||
RestAssured.keystore("../keystore.jks", "openmf");
|
||||
RestAssured.keystore("src/main/resources/keystore.jks", "openmf");
|
||||
}
|
||||
|
||||
public static String loginIntoServerAndGetBase64EncodedAuthenticationKey() {
|
||||
@@ -76,7 +87,7 @@ public class Utils {
|
||||
}
|
||||
|
||||
public static String convertDateToURLFormat(final String dateToBeConvert) {
|
||||
final SimpleDateFormat oldFormat = new SimpleDateFormat("dd MMMMMM yyyy");
|
||||
final SimpleDateFormat oldFormat = new SimpleDateFormat("dd MMMMMM yyyy", Locale.US);
|
||||
final SimpleDateFormat newFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String reformattedStr = "";
|
||||
try {
|
||||
|
||||
+5
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common.accounting;
|
||||
|
||||
public class Account {
|
||||
|
||||
+8
-3
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common.accounting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -11,7 +16,7 @@ import com.jayway.restassured.specification.ResponseSpecification;
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class AccountHelper {
|
||||
|
||||
private final String CREATE_GL_ACCOUNT_URL = "/mifosng-provider/api/v1/glaccounts?tenantIdentifier=default";
|
||||
private final String CREATE_GL_ACCOUNT_URL = "/mifosng-provider/api/v1/glaccounts?" + Utils.TENANT_IDENTIFIER;
|
||||
private final String GL_ACCOUNT_ID_RESPONSE = "resourceId";
|
||||
|
||||
private final RequestSpecification requestSpec;
|
||||
@@ -44,9 +49,9 @@ public class AccountHelper {
|
||||
}
|
||||
|
||||
public Account createLiabilityAccount() {
|
||||
final String assetAccountJSON = new GLAccountBuilder().withAccountTypeAsLiability().build();
|
||||
final String liabilityAccountJSON = new GLAccountBuilder().withAccountTypeAsLiability().build();
|
||||
final Integer accountID = Utils.performServerPost(this.requestSpec, this.responseSpec, this.CREATE_GL_ACCOUNT_URL,
|
||||
assetAccountJSON, this.GL_ACCOUNT_ID_RESPONSE);
|
||||
liabilityAccountJSON, this.GL_ACCOUNT_ID_RESPONSE);
|
||||
return new Account(accountID, Account.AccountType.LIABILITY);
|
||||
}
|
||||
|
||||
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common.accounting;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class FinancialActivityAccountHelper {
|
||||
|
||||
private static final String FINANCIAL_ACTIVITY_ACCOUNT_MAPPING_URL = "/mifosng-provider/api/v1/financialactivityaccounts";
|
||||
private final RequestSpecification requestSpec;
|
||||
|
||||
public FinancialActivityAccountHelper(final RequestSpecification requestSpec) {
|
||||
this.requestSpec = requestSpec;
|
||||
}
|
||||
|
||||
public Object createFinancialActivityAccount(Integer financialActivityId, Integer glAccountId,
|
||||
final ResponseSpecification responseSpecification, String jsonBack) {
|
||||
String json = FinancialActivityAccountsMappingBuilder.build(financialActivityId, glAccountId);
|
||||
return Utils.performServerPost(this.requestSpec, responseSpecification, FINANCIAL_ACTIVITY_ACCOUNT_MAPPING_URL + "?"
|
||||
+ Utils.TENANT_IDENTIFIER, json, jsonBack);
|
||||
}
|
||||
|
||||
public Object updateFinancialActivityAccount(Integer financialActivityAccountId, Integer financialActivityId, Integer glAccountId,
|
||||
final ResponseSpecification responseSpecification, String jsonBack) {
|
||||
String json = FinancialActivityAccountsMappingBuilder.build(financialActivityId, glAccountId);
|
||||
return Utils.performServerPut(this.requestSpec, responseSpecification, FINANCIAL_ACTIVITY_ACCOUNT_MAPPING_URL + "/"
|
||||
+ financialActivityAccountId + "?" + Utils.TENANT_IDENTIFIER, json, jsonBack);
|
||||
}
|
||||
|
||||
public HashMap getFinancialActivityAccount(final Integer financialActivityAccountId, final ResponseSpecification responseSpecification) {
|
||||
final String url = FINANCIAL_ACTIVITY_ACCOUNT_MAPPING_URL + "/" + financialActivityAccountId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerGet(requestSpec, responseSpecification, url, "");
|
||||
}
|
||||
|
||||
public List<HashMap> getAllFinancialActivityAccounts(final ResponseSpecification responseSpecification) {
|
||||
final String url = FINANCIAL_ACTIVITY_ACCOUNT_MAPPING_URL + "?" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerGet(this.requestSpec, responseSpecification, url, "");
|
||||
}
|
||||
|
||||
public Integer deleteFinancialActivityAccount(final Integer financialActivityAccountId,
|
||||
final ResponseSpecification responseSpecification, String jsonBack) {
|
||||
final String url = FINANCIAL_ACTIVITY_ACCOUNT_MAPPING_URL + "/" + financialActivityAccountId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerDelete(this.requestSpec, responseSpecification, url, jsonBack);
|
||||
}
|
||||
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common.accounting;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class FinancialActivityAccountsMappingBuilder {
|
||||
|
||||
public static String build(Integer financialActivityId, Integer glAccountId) {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("financialActivityId", financialActivityId);
|
||||
map.put("glAccountId", glAccountId);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
}
|
||||
+6
-1
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common.accounting;
|
||||
|
||||
import java.util.Calendar;
|
||||
@@ -29,7 +34,7 @@ public class GLAccountBuilder {
|
||||
private static String description = "DEFAULT_DESCRIPTION";
|
||||
|
||||
public String build() {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("name", GLAccountBuilder.name);
|
||||
map.put("glCode", GLAccountBuilder.GLCode);
|
||||
map.put("manualEntriesAllowed", GLAccountBuilder.manualEntriesAllowed);
|
||||
|
||||
+7
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common.accounting;
|
||||
|
||||
public class JournalEntry {
|
||||
@@ -19,10 +24,12 @@ public class JournalEntry {
|
||||
|
||||
private final Float transactionAmount;
|
||||
private final TransactionType transactionType;
|
||||
private final Integer officeId;
|
||||
|
||||
public JournalEntry(final float transactionAmount, final TransactionType type) {
|
||||
this.transactionAmount = transactionAmount;
|
||||
this.transactionType = type;
|
||||
this.officeId = null;
|
||||
}
|
||||
|
||||
public Float getTransactionAmount() {
|
||||
|
||||
+26
-11
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common.accounting;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
@@ -24,25 +29,31 @@ public class JournalEntryHelper {
|
||||
}
|
||||
|
||||
public void checkJournalEntryForExpenseAccount(final Account expenseAccount, final String date, final JournalEntry... accountEntries) {
|
||||
checkJournalEntry(expenseAccount, date, accountEntries);
|
||||
checkJournalEntry(null, expenseAccount, date, accountEntries);
|
||||
}
|
||||
|
||||
public void checkJournalEntryForAssetAccount(final Account assetAccount, final String date, final JournalEntry... accountEntries) {
|
||||
checkJournalEntry(assetAccount, date, accountEntries);
|
||||
checkJournalEntry(null, assetAccount, date, accountEntries);
|
||||
}
|
||||
|
||||
public void checkJournalEntryForIncomeAccount(final Account incomeAccount, final String date, final JournalEntry... accountEntries) {
|
||||
checkJournalEntry(incomeAccount, date, accountEntries);
|
||||
checkJournalEntry(null, incomeAccount, date, accountEntries);
|
||||
}
|
||||
|
||||
public void checkJournalEntryForLiabilityAccount(final Account liabilityAccount, final String date, final JournalEntry... accountEntries) {
|
||||
checkJournalEntry(liabilityAccount, date, accountEntries);
|
||||
|
||||
public void checkJournalEntryForLiabilityAccount(final Account liabilityAccount, final String date,
|
||||
final JournalEntry... accountEntries) {
|
||||
checkJournalEntry(null, liabilityAccount, date, accountEntries);
|
||||
}
|
||||
|
||||
public void checkJournalEntryForLiabilityAccount(final Integer officeId, final Account liabilityAccount, final String date,
|
||||
final JournalEntry... accountEntries) {
|
||||
checkJournalEntry(officeId, liabilityAccount, date, accountEntries);
|
||||
}
|
||||
|
||||
public void ensureNoAccountingTransactionsWithTransactionId(final String transactionId) {
|
||||
ArrayList<HashMap> transactions = getJournalEntriesByTransactionId(transactionId);
|
||||
assertTrue("Tranasactions are is not empty", transactions.isEmpty());
|
||||
|
||||
|
||||
}
|
||||
|
||||
private String getEntryValueFromJournalEntry(final ArrayList<HashMap> entryResponse, final int entryNumber) {
|
||||
@@ -54,8 +65,8 @@ public class JournalEntryHelper {
|
||||
return (Float) entryResponse.get(entryNumber).get("amount");
|
||||
}
|
||||
|
||||
private void checkJournalEntry(final Account account, final String date, final JournalEntry... accountEntries) {
|
||||
final String url = createURLForGettingAccountEntries(account, date);
|
||||
private void checkJournalEntry(final Integer officeId, final Account account, final String date, final JournalEntry... accountEntries) {
|
||||
final String url = createURLForGettingAccountEntries(account, date, officeId);
|
||||
final ArrayList<HashMap> response = Utils.performServerGet(this.requestSpec, this.responseSpec, url, "pageItems");
|
||||
for (int i = 0; i < accountEntries.length; i++) {
|
||||
assertThat(getEntryValueFromJournalEntry(response, i), equalTo(accountEntries[i].getTransactionType()));
|
||||
@@ -63,10 +74,14 @@ public class JournalEntryHelper {
|
||||
}
|
||||
}
|
||||
|
||||
private String createURLForGettingAccountEntries(final Account account, final String date) {
|
||||
return new String("/mifosng-provider/api/v1/journalentries?glAccountId=" + account.getAccountID() + "&type="
|
||||
private String createURLForGettingAccountEntries(final Account account, final String date, final Integer officeId) {
|
||||
String url = new String("/mifosng-provider/api/v1/journalentries?glAccountId=" + account.getAccountID() + "&type="
|
||||
+ account.getAccountType() + "&fromDate=" + date + "&toDate=" + date + "&tenantIdentifier=default"
|
||||
+ "&orderBy=id&sortOrder=desc&locale=en&dateFormat=dd MMMM yyyy");
|
||||
if (officeId != null) {
|
||||
url = url + "&officeId=" + officeId;
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
private ArrayList<HashMap> getJournalEntriesByTransactionId(final String transactionId) {
|
||||
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
package org.mifosplatform.integrationtests.common.accounting;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class OfficeAccountMappingBuilder {
|
||||
|
||||
public static String build(Integer officeId, Integer glAccountId) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("officeId", officeId);
|
||||
map.put("liabilityTransferInSuspenseAccountId", glAccountId);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
}
|
||||
-44
@@ -1,44 +0,0 @@
|
||||
package org.mifosplatform.integrationtests.common.accounting;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class OfficeAccountMappingHelper {
|
||||
|
||||
private static final String ACCOUNT_MAPPING_URL = "/mifosng-provider/api/v1/officeglaccounts";
|
||||
private final RequestSpecification requestSpec;
|
||||
private final ResponseSpecification responseSpec;
|
||||
|
||||
public OfficeAccountMappingHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
this.requestSpec = requestSpec;
|
||||
this.responseSpec = responseSpec;
|
||||
}
|
||||
|
||||
public Object createOfficeAccountMapping(Integer officeId, Integer glAccountId, String jsonBack) {
|
||||
String json = OfficeAccountMappingBuilder.build(officeId, glAccountId);
|
||||
return Utils.performServerPost(this.requestSpec, this.responseSpec, ACCOUNT_MAPPING_URL + "?" + Utils.TENANT_IDENTIFIER, json,
|
||||
jsonBack);
|
||||
}
|
||||
|
||||
public Object updateOfficeAccountMapping(Integer mappingId, Integer officeId, Integer glAccountId, String jsonBack) {
|
||||
String json = OfficeAccountMappingBuilder.build(officeId, glAccountId);
|
||||
return Utils.performServerPut(this.requestSpec, this.responseSpec, ACCOUNT_MAPPING_URL + "/" + mappingId + "?"
|
||||
+ Utils.TENANT_IDENTIFIER, json, jsonBack);
|
||||
}
|
||||
|
||||
public HashMap getOfficeAccountMapping(final Integer mappingId) {
|
||||
final String URL = ACCOUNT_MAPPING_URL + "/" + mappingId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerGet(requestSpec, responseSpec, URL, "");
|
||||
}
|
||||
|
||||
public HashMap getOfficeAccountMappings() {
|
||||
final String URL = ACCOUNT_MAPPING_URL + "?" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerGet(requestSpec, responseSpec, URL, "");
|
||||
}
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common.accounting;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
public class PeriodicAccrualAccountingHelper {
|
||||
|
||||
private static final String PERIODIC_ACCRUAL_URL = "/mifosng-provider/api/v1/runaccruals";
|
||||
private final RequestSpecification requestSpec;
|
||||
private final ResponseSpecification responseSpec;
|
||||
|
||||
public PeriodicAccrualAccountingHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
this.requestSpec = requestSpec;
|
||||
this.responseSpec = responseSpec;
|
||||
}
|
||||
|
||||
public Object runPeriodicAccrualAccounting(String date) {
|
||||
String json = getRunPeriodicAccrual(date);
|
||||
return Utils.performServerPost(this.requestSpec, this.responseSpec, PERIODIC_ACCRUAL_URL + "?" + Utils.TENANT_IDENTIFIER, json, "");
|
||||
}
|
||||
|
||||
private String getRunPeriodicAccrual(String date) {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("locale", "en_GB");
|
||||
map.put("tillDate", date);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
}
|
||||
+38
-11
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common.charges;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -28,6 +33,7 @@ public class ChargesHelper {
|
||||
private static final Integer CHARGE_INSTALLMENT_FEE = 8;
|
||||
private static final Integer CHARGE_OVERDUE_INSTALLMENT_FEE = 9;
|
||||
private static final Integer CHARGE_OVERDRAFT_FEE = 10;
|
||||
private static final Integer WEEKLY_FEE = 11;
|
||||
|
||||
public static final Integer CHARGE_CALCULATION_TYPE_FLAT = 1;
|
||||
public static final Integer CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT = 2;
|
||||
@@ -92,6 +98,15 @@ public class ChargesHelper {
|
||||
System.out.println(chargesCreateJson);
|
||||
return chargesCreateJson;
|
||||
}
|
||||
|
||||
public static String getSavingsWeeklyFeeJSON() {
|
||||
final HashMap<String, Object> map = populateDefaultsForSavings();
|
||||
map.put("chargeTimeType", WEEKLY_FEE);
|
||||
map.put("feeInterval", 1);
|
||||
String chargesCreateJson = new Gson().toJson(map);
|
||||
System.out.println(chargesCreateJson);
|
||||
return chargesCreateJson;
|
||||
}
|
||||
|
||||
public static String getSavingsOverdraftFeeJSON() {
|
||||
final HashMap<String, Object> map = populateDefaultsForSavings();
|
||||
@@ -102,7 +117,7 @@ public class ChargesHelper {
|
||||
}
|
||||
|
||||
public static HashMap<String, Object> populateDefaultsForSavings() {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("active", ChargesHelper.active);
|
||||
map.put("amount", ChargesHelper.amount);
|
||||
map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_SAVINGS);
|
||||
@@ -207,9 +222,21 @@ public class ChargesHelper {
|
||||
System.out.println(chargesCreateJson);
|
||||
return chargesCreateJson;
|
||||
}
|
||||
|
||||
public static String getLoanOverdueFeeJSONWithCalculattionTypePercentage() {
|
||||
final HashMap<String, Object> map = populateDefaultsForLoan();
|
||||
map.put("penalty", ChargesHelper.penalty);
|
||||
map.put("amount", "10");
|
||||
map.put("chargePaymentMode", ChargesHelper.CHARGE_PAYMENT_MODE_REGULAR);
|
||||
map.put("chargeTimeType", CHARGE_OVERDUE_INSTALLMENT_FEE);
|
||||
map.put("chargeCalculationType", ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST);
|
||||
String chargesCreateJson = new Gson().toJson(map);
|
||||
System.out.println(chargesCreateJson);
|
||||
return chargesCreateJson;
|
||||
}
|
||||
|
||||
public static HashMap<String, Object> populateDefaultsForLoan() {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("active", ChargesHelper.active);
|
||||
map.put("amount", ChargesHelper.amount);
|
||||
map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_LOAN);
|
||||
@@ -254,7 +281,7 @@ public class ChargesHelper {
|
||||
}
|
||||
|
||||
public static String getModifyChargeJSON() {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("amount", "200.0");
|
||||
String json = new Gson().toJson(map);
|
||||
@@ -263,7 +290,7 @@ public class ChargesHelper {
|
||||
}
|
||||
|
||||
public static String getModifyWithdrawalFeeSavingsChargeJSON() {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("chargeCalculationType", CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT);
|
||||
String json = new Gson().toJson(map);
|
||||
@@ -272,7 +299,7 @@ public class ChargesHelper {
|
||||
}
|
||||
|
||||
public static String getModifyChargeAsPecentageAmountJSON() {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("chargeCalculationType", CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT);
|
||||
map.put("chargePaymentMode", CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
|
||||
@@ -282,7 +309,7 @@ public class ChargesHelper {
|
||||
}
|
||||
|
||||
public static String getModifyChargeAsPecentageLoanAmountWithInterestJSON() {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("chargeCalculationType", CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST);
|
||||
map.put("chargePaymentMode", CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
|
||||
@@ -292,7 +319,7 @@ public class ChargesHelper {
|
||||
}
|
||||
|
||||
public static String getModifyChargeAsPercentageInterestJSON() {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("chargeCalculationType", CHARGE_CALCULATION_TYPE_PERCENTAGE_INTEREST);
|
||||
map.put("chargePaymentMode", CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
|
||||
@@ -302,7 +329,7 @@ public class ChargesHelper {
|
||||
}
|
||||
|
||||
public static String getModifyChargeFeeFrequencyAsDaysJSON() {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("feeFrequency", ChargesHelper.CHARGE_FEE_FREQUENCY_DAYS);
|
||||
map.put("feeInterval", 2);
|
||||
@@ -312,7 +339,7 @@ public class ChargesHelper {
|
||||
}
|
||||
|
||||
public static String getModifyChargeFeeFrequencyAsWeeksJSON() {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("feeFrequency", ChargesHelper.CHARGE_FEE_FREQUENCY_WEEKS);
|
||||
map.put("feeInterval", 2);
|
||||
@@ -322,7 +349,7 @@ public class ChargesHelper {
|
||||
}
|
||||
|
||||
public static String getModifyChargeFeeFrequencyAsMonthsJSON() {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("feeFrequency", ChargesHelper.CHARGE_FEE_FREQUENCY_MONTHS);
|
||||
map.put("feeInterval", 2);
|
||||
@@ -332,7 +359,7 @@ public class ChargesHelper {
|
||||
}
|
||||
|
||||
public static String getModifyChargeFeeFrequencyAsYearsJSON() {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("feeFrequency", ChargesHelper.CHARGE_FEE_FREQUENCY_YEARS);
|
||||
map.put("feeInterval", 2);
|
||||
|
||||
+18
-13
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common.fixeddeposit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -80,10 +85,10 @@ public class FixedDepositAccountHelper {
|
||||
|
||||
public String build(final String clientId, final String productId, final String validFrom, final String validTo,
|
||||
final String penalInterestType) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
|
||||
List<HashMap<String, String>> chartSlabs = new ArrayList<HashMap<String, String>>();
|
||||
HashMap<String, String> chartSlabsMap1 = new HashMap<String, String>();
|
||||
HashMap<String, String> chartSlabsMap1 = new HashMap<>();
|
||||
chartSlabsMap1.put("description", "First");
|
||||
chartSlabsMap1.put("periodType", MONTHS);
|
||||
chartSlabsMap1.put("fromPeriod", "1");
|
||||
@@ -92,7 +97,7 @@ public class FixedDepositAccountHelper {
|
||||
chartSlabsMap1.put("locale", LOCALE);
|
||||
chartSlabs.add(0, chartSlabsMap1);
|
||||
|
||||
HashMap<String, String> chartSlabsMap2 = new HashMap<String, String>();
|
||||
HashMap<String, String> chartSlabsMap2 = new HashMap<>();
|
||||
chartSlabsMap2.put("description", "Second");
|
||||
chartSlabsMap2.put("periodType", MONTHS);
|
||||
chartSlabsMap2.put("fromPeriod", "7");
|
||||
@@ -101,7 +106,7 @@ public class FixedDepositAccountHelper {
|
||||
chartSlabsMap2.put("locale", LOCALE);
|
||||
chartSlabs.add(1, chartSlabsMap2);
|
||||
|
||||
HashMap<String, String> chartSlabsMap3 = new HashMap<String, String>();
|
||||
HashMap<String, String> chartSlabsMap3 = new HashMap<>();
|
||||
chartSlabsMap3.put("description", "Third");
|
||||
chartSlabsMap3.put("periodType", MONTHS);
|
||||
chartSlabsMap3.put("fromPeriod", "13");
|
||||
@@ -110,7 +115,7 @@ public class FixedDepositAccountHelper {
|
||||
chartSlabsMap3.put("locale", LOCALE);
|
||||
chartSlabs.add(2, chartSlabsMap3);
|
||||
|
||||
HashMap<String, String> chartSlabsMap4 = new HashMap<String, String>();
|
||||
HashMap<String, String> chartSlabsMap4 = new HashMap<>();
|
||||
chartSlabsMap4.put("description", "Fourth");
|
||||
chartSlabsMap4.put("periodType", MONTHS);
|
||||
chartSlabsMap4.put("fromPeriod", "19");
|
||||
@@ -120,7 +125,7 @@ public class FixedDepositAccountHelper {
|
||||
chartSlabs.add(3, chartSlabsMap4);
|
||||
|
||||
List<HashMap<String, Object>> charts = new ArrayList<HashMap<String, Object>>();
|
||||
HashMap<String, Object> chartsMap = new HashMap<String, Object>();
|
||||
HashMap<String, Object> chartsMap = new HashMap<>();
|
||||
chartsMap.put("fromDate", validFrom);
|
||||
chartsMap.put("endDate", validTo);
|
||||
chartsMap.put("dateFormat", "dd MMMM yyyy");
|
||||
@@ -324,7 +329,7 @@ public class FixedDepositAccountHelper {
|
||||
}
|
||||
|
||||
private String getApproveFixedDepositAccountAsJSON(final String approvedOnDate) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("approvedOnDate", approvedOnDate);
|
||||
@@ -335,7 +340,7 @@ public class FixedDepositAccountHelper {
|
||||
}
|
||||
|
||||
private String getRejectedFixedDepositAsJSON(final String rejectedOnDate) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("rejectedOnDate", rejectedOnDate);
|
||||
@@ -346,7 +351,7 @@ public class FixedDepositAccountHelper {
|
||||
}
|
||||
|
||||
private String getWithdrawnFixedDepositAccountAsJSON(final String withdrawnApplicationOnDate) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("withdrawnOnDate", withdrawnApplicationOnDate);
|
||||
@@ -357,7 +362,7 @@ public class FixedDepositAccountHelper {
|
||||
}
|
||||
|
||||
private String getActivatedFixedDepositAccountAsJSON(final String activationDate) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("activatedOnDate", activationDate);
|
||||
@@ -367,14 +372,14 @@ public class FixedDepositAccountHelper {
|
||||
}
|
||||
|
||||
private String getCalculatedInterestForFixedDepositApplicationAsJSON() {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
String fixedDepositAccountCalculatedInterestJson = new Gson().toJson(map);
|
||||
System.out.println(fixedDepositAccountCalculatedInterestJson);
|
||||
return fixedDepositAccountCalculatedInterestJson;
|
||||
}
|
||||
|
||||
private String getCalculatedPrematureAmountForFixedDepositAccountAsJSON(final String closedOnDate) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("closedOnDate", closedOnDate);
|
||||
@@ -385,7 +390,7 @@ public class FixedDepositAccountHelper {
|
||||
|
||||
private String getPrematureCloseForFixedDepositAccountAsJSON(final String closedOnDate, final String closureType,
|
||||
final Integer toSavingsId) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("closedOnDate", closedOnDate);
|
||||
|
||||
+5
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common.fixeddeposit;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
+12
-7
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common.fixeddeposit;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -81,10 +86,10 @@ public class FixedDepositProductHelper {
|
||||
private Account[] accountList = null;
|
||||
|
||||
public String build(final String validFrom, final String validTo) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
|
||||
List<HashMap<String, String>> chartSlabs = new ArrayList<HashMap<String, String>>();
|
||||
HashMap<String, String> chartSlabsMap1 = new HashMap<String, String>();
|
||||
HashMap<String, String> chartSlabsMap1 = new HashMap<>();
|
||||
chartSlabsMap1.put("description", "First");
|
||||
chartSlabsMap1.put("periodType", MONTHS);
|
||||
chartSlabsMap1.put("fromPeriod", "1");
|
||||
@@ -93,7 +98,7 @@ public class FixedDepositProductHelper {
|
||||
chartSlabsMap1.put("locale", LOCALE);
|
||||
chartSlabs.add(0, chartSlabsMap1);
|
||||
|
||||
HashMap<String, String> chartSlabsMap2 = new HashMap<String, String>();
|
||||
HashMap<String, String> chartSlabsMap2 = new HashMap<>();
|
||||
chartSlabsMap2.put("description", "Second");
|
||||
chartSlabsMap2.put("periodType", MONTHS);
|
||||
chartSlabsMap2.put("fromPeriod", "7");
|
||||
@@ -102,7 +107,7 @@ public class FixedDepositProductHelper {
|
||||
chartSlabsMap2.put("locale", LOCALE);
|
||||
chartSlabs.add(1, chartSlabsMap2);
|
||||
|
||||
HashMap<String, String> chartSlabsMap3 = new HashMap<String, String>();
|
||||
HashMap<String, String> chartSlabsMap3 = new HashMap<>();
|
||||
chartSlabsMap3.put("description", "Third");
|
||||
chartSlabsMap3.put("periodType", MONTHS);
|
||||
chartSlabsMap3.put("fromPeriod", "13");
|
||||
@@ -111,7 +116,7 @@ public class FixedDepositProductHelper {
|
||||
chartSlabsMap3.put("locale", LOCALE);
|
||||
chartSlabs.add(2, chartSlabsMap3);
|
||||
|
||||
HashMap<String, String> chartSlabsMap4 = new HashMap<String, String>();
|
||||
HashMap<String, String> chartSlabsMap4 = new HashMap<>();
|
||||
chartSlabsMap4.put("description", "Fourth");
|
||||
chartSlabsMap4.put("periodType", MONTHS);
|
||||
chartSlabsMap4.put("fromPeriod", "19");
|
||||
@@ -121,7 +126,7 @@ public class FixedDepositProductHelper {
|
||||
chartSlabs.add(3, chartSlabsMap4);
|
||||
|
||||
List<HashMap<String, Object>> charts = new ArrayList<HashMap<String, Object>>();
|
||||
HashMap<String, Object> chartsMap = new HashMap<String, Object>();
|
||||
HashMap<String, Object> chartsMap = new HashMap<>();
|
||||
chartsMap.put("fromDate", validFrom);
|
||||
chartsMap.put("endDate", validTo);
|
||||
chartsMap.put("dateFormat", "dd MMMM yyyy");
|
||||
@@ -177,7 +182,7 @@ public class FixedDepositProductHelper {
|
||||
}
|
||||
|
||||
private Map<String, String> getAccountMappingForCashBased() {
|
||||
final Map<String, String> map = new HashMap<String, String>();
|
||||
final Map<String, String> map = new HashMap<>();
|
||||
if (accountList != null) {
|
||||
for (int i = 0; i < this.accountList.length; i++) {
|
||||
if (this.accountList[i].getAccountType().equals(Account.AccountType.ASSET)) {
|
||||
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common.funds;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class FundsHelper {
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private String name;
|
||||
private String externalId;
|
||||
|
||||
private Builder(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Builder externalId(final String externalId) {
|
||||
this.externalId = externalId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FundsHelper build() {
|
||||
return new FundsHelper(this.name, this.externalId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String name;
|
||||
private String externalId;
|
||||
private Long resourceId;
|
||||
|
||||
FundsHelper() {
|
||||
super();
|
||||
}
|
||||
|
||||
private FundsHelper(final String name,
|
||||
final String externalId) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.externalId = externalId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getExternalId() {
|
||||
return this.externalId;
|
||||
}
|
||||
|
||||
public Long getResourceId() {
|
||||
return this.resourceId;
|
||||
}
|
||||
|
||||
public String toJSON() {
|
||||
return new Gson().toJson(this);
|
||||
}
|
||||
|
||||
public static FundsHelper fromJSON(final String jsonData) {
|
||||
return new Gson().fromJson(jsonData, FundsHelper.class);
|
||||
}
|
||||
|
||||
public static Builder create(final String name) {
|
||||
return new Builder(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (this.name != null) {
|
||||
return this.name.hashCode();
|
||||
}
|
||||
return super.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(o instanceof FundsHelper)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FundsHelper fh = (FundsHelper)o;
|
||||
|
||||
if (this.name.equals(fh.name)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common.funds;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class FundsResourceHandler {
|
||||
|
||||
private static final String FUNDS_URL = "/mifosng-provider/api/v1/funds";
|
||||
private static final String CREATE_FUNDS_URL = FUNDS_URL + "?" + Utils.TENANT_IDENTIFIER;
|
||||
|
||||
public static Integer createFund(final String fundJSON,
|
||||
final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec) {
|
||||
return Utils.performServerPost(requestSpec, responseSpec, CREATE_FUNDS_URL, fundJSON, "resourceId");
|
||||
}
|
||||
|
||||
public static List<FundsHelper> retrieveAllFunds(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec) {
|
||||
final String URL = FUNDS_URL + "?" + Utils.TENANT_IDENTIFIER;
|
||||
List<HashMap<String, Object>> list = Utils.performServerGet(requestSpec, responseSpec, URL, "");
|
||||
final String jsonData = new Gson().toJson(list);
|
||||
return new Gson().fromJson(jsonData, new TypeToken<List<FundsHelper>>(){}.getType());
|
||||
}
|
||||
|
||||
public static String retrieveFund(final Long fundID,
|
||||
final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec) {
|
||||
final String URL = FUNDS_URL + "/" + fundID + "?" + Utils.TENANT_IDENTIFIER;
|
||||
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "");
|
||||
return new Gson().toJson(response);
|
||||
}
|
||||
|
||||
public static FundsHelper updateFund(final Long fundID,
|
||||
final String newName,
|
||||
final String newExternalId,
|
||||
final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec) {
|
||||
FundsHelper fh = FundsHelper.create(newName).externalId(newExternalId).build();
|
||||
String updateJSON = new Gson().toJson(fh);
|
||||
|
||||
final String URL = FUNDS_URL + "/" + fundID + "?" + Utils.TENANT_IDENTIFIER;
|
||||
final HashMap<String, String> response = Utils.performServerPut(requestSpec, responseSpec, URL, updateJSON, "changes");
|
||||
final String jsonData = new Gson().toJson(response);
|
||||
return new Gson().fromJson(jsonData, FundsHelper.class);
|
||||
}
|
||||
|
||||
}
|
||||
+56
-3
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common.loans;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -17,7 +22,8 @@ public class LoanApplicationTestBuilder {
|
||||
private static final String EQUAL_PRINCIPAL_PAYMENTS = "0";
|
||||
private static final String EQUAL_INSTALLMENTS = "1";
|
||||
private static final String CALCULATION_PERIOD_SAME_AS_REPAYMENT_PERIOD = "1";
|
||||
private static final String MIFOS_STANDARD_STRATEGY = "1";
|
||||
public static final String MIFOS_STANDARD_STRATEGY = "1";
|
||||
public static final String RBI_INDIA_STRATEGY = "4";
|
||||
|
||||
private String principal = "10,000";
|
||||
private String loanTermFrequency = "";
|
||||
@@ -30,18 +36,22 @@ public class LoanApplicationTestBuilder {
|
||||
private String interestType = FLAT_BALANCE;
|
||||
private String amortizationType = EQUAL_PRINCIPAL_PAYMENTS;
|
||||
private String interestCalculationPeriodType = CALCULATION_PERIOD_SAME_AS_REPAYMENT_PERIOD;
|
||||
private final String transactionProcessingID = MIFOS_STANDARD_STRATEGY;
|
||||
private String transactionProcessingID = MIFOS_STANDARD_STRATEGY;
|
||||
private String expectedDisbursmentDate = "";
|
||||
private String submittedOnDate = "";
|
||||
private String loanType = "individual";
|
||||
private String fixedEmiAmount = "10000";
|
||||
private String maxOutstandingLoanBalance = "36000";
|
||||
private String graceOnPrincipalPayment = null;
|
||||
private String graceOnInterestPayment = null;
|
||||
private List<HashMap> disbursementData = null;
|
||||
private List<HashMap> charges = new ArrayList<HashMap>();
|
||||
private String recalculationRestFrequencyDate = null;
|
||||
private String repaymentsStartingFromDate = null;
|
||||
|
||||
public String build(final String ID, final String loanProductId, final String savingsID) {
|
||||
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("locale", "en_GB");
|
||||
if (this.loanType == "group") {
|
||||
@@ -64,6 +74,8 @@ public class LoanApplicationTestBuilder {
|
||||
map.put("expectedDisbursementDate", this.expectedDisbursmentDate);
|
||||
map.put("submittedOnDate", this.submittedOnDate);
|
||||
map.put("loanType", this.loanType);
|
||||
map.put("repaymentsStartingFromDate", this.repaymentsStartingFromDate);
|
||||
|
||||
if (charges != null) {
|
||||
map.put("charges", charges);
|
||||
}
|
||||
@@ -71,12 +83,23 @@ public class LoanApplicationTestBuilder {
|
||||
map.put("linkAccountId", savingsID);
|
||||
}
|
||||
|
||||
if (graceOnPrincipalPayment != null) {
|
||||
map.put("graceOnPrincipalPayment", graceOnPrincipalPayment);
|
||||
}
|
||||
|
||||
if (graceOnInterestPayment != null) {
|
||||
map.put("graceOnInterestPayment", graceOnInterestPayment);
|
||||
}
|
||||
|
||||
if (disbursementData != null) {
|
||||
map.put("disbursementData", disbursementData);
|
||||
map.put("fixedEmiAmount", fixedEmiAmount);
|
||||
map.put("maxOutstandingLoanBalance", maxOutstandingLoanBalance);
|
||||
|
||||
}
|
||||
if (recalculationRestFrequencyDate != null) {
|
||||
map.put("recalculationRestFrequencyDate", recalculationRestFrequencyDate);
|
||||
}
|
||||
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
@@ -136,6 +159,11 @@ public class LoanApplicationTestBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanApplicationTestBuilder withRepaymentFrequencyTypeAsYear() {
|
||||
this.repaymentFrequencyType = YEARS;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanApplicationTestBuilder withInterestRatePerPeriod(final String interestRate) {
|
||||
this.interestRate = interestRate;
|
||||
return this;
|
||||
@@ -191,8 +219,33 @@ public class LoanApplicationTestBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanApplicationTestBuilder withPrincipalGrace(final String graceOnPrincipalPayment) {
|
||||
this.graceOnPrincipalPayment = graceOnPrincipalPayment;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanApplicationTestBuilder withInterestGrace(final String graceOnInterestPayment) {
|
||||
this.graceOnInterestPayment = graceOnInterestPayment;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanApplicationTestBuilder withTranches(final List<HashMap> disbursementData) {
|
||||
this.disbursementData = disbursementData;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanApplicationTestBuilder withwithRepaymentStrategy(final String transactionProcessingStrategy) {
|
||||
this.transactionProcessingID = transactionProcessingStrategy;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanApplicationTestBuilder withRestFrequencyDate(final String recalculationRestFrequencyDate) {
|
||||
this.recalculationRestFrequencyDate = recalculationRestFrequencyDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanApplicationTestBuilder withFirstRepaymentDate(final String firstRepaymentDate) {
|
||||
this.repaymentsStartingFromDate = firstRepaymentDate;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
+103
-14
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common.loans;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -13,7 +18,6 @@ import com.google.gson.Gson;
|
||||
public class LoanProductTestBuilder {
|
||||
|
||||
private static final String LOCALE = "en_GB";
|
||||
private static final String DIGITS_AFTER_DECIMAL = "2";
|
||||
private static final String USD = "USD";
|
||||
private static final String DAYS = "0";
|
||||
private static final String WEEK = "1";
|
||||
@@ -24,17 +28,35 @@ public class LoanProductTestBuilder {
|
||||
private static final String EQUAL_INSTALLMENTS = "1";
|
||||
private static final String DECLINING_BALANCE = "0";
|
||||
private static final String FLAT_BALANCE = "1";
|
||||
private static final String MIFOS_STANDARD_STRATEGY = "1";
|
||||
public static final String MIFOS_STANDARD_STRATEGY = "1";
|
||||
// private static final String HEAVENS_FAMILY_STRATEGY ="2";
|
||||
// private static final String CREO_CORE_STRATEGY ="3";
|
||||
// private static final String RBI_INDIA_STRATEGY ="4";
|
||||
public static final String RBI_INDIA_STRATEGY = "4";
|
||||
|
||||
public static final String RECALCULATION_FREQUENCY_TYPE_SAME_AS_REPAYMENT_PERIOD = "1";
|
||||
public static final String RECALCULATION_FREQUENCY_TYPE_DAILY = "2";
|
||||
public static final String RECALCULATION_FREQUENCY_TYPE_WEEKLY = "3";
|
||||
public static final String RECALCULATION_FREQUENCY_TYPE_MONTHLY = "4";
|
||||
|
||||
public static final String RECALCULATION_STRATEGY_RESCHEDULE_NEXT_REPAYMENTS = "1";
|
||||
public static final String RECALCULATION_STRATEGY_REDUCE_NUMBER_OF_INSTALLMENTS = "2";
|
||||
public static final String RECALCULATION_STRATEGY_REDUCE_EMI_AMOUN = "3";
|
||||
|
||||
public static final String RECALCULATION_COMPOUNDING_METHOD_NONE = "0";
|
||||
public static final String RECALCULATION_COMPOUNDING_METHOD_INTEREST = "1";
|
||||
public static final String RECALCULATION_COMPOUNDING_METHOD_FEE = "2";
|
||||
public static final String RECALCULATION_COMPOUNDING_METHOD_INTEREST_AND_FEE = "3";
|
||||
|
||||
private static final String NONE = "1";
|
||||
private static final String CASH_BASED = "2";
|
||||
private static final String ACCRUAL_PERIODIC = "3";
|
||||
private static final String ACCRUAL_UPFRONT = "4";
|
||||
|
||||
private String digitsAfterDecimal = "2";
|
||||
private String inMultiplesOf = "0";
|
||||
|
||||
private String nameOfLoanProduct = Utils.randomNameGenerator("LOAN_PRODUCT_", 6);
|
||||
private String shortName = Utils.randomNameGenerator("", 4);
|
||||
private final String shortName = Utils.randomNameGenerator("", 4);
|
||||
private String principal = "10000.00";
|
||||
private String numberOfRepayments = "5";
|
||||
private String repaymentFrequency = MONTHS;
|
||||
@@ -45,24 +67,34 @@ public class LoanProductTestBuilder {
|
||||
private String overdueDaysForNPA = "5";
|
||||
private String interestCalculationPeriodType = CALCULATION_PERIOD_SAME_AS_REPAYMENT_PERIOD;
|
||||
private String inArrearsTolerance = "0";
|
||||
private final String transactionProcessingStrategy = MIFOS_STANDARD_STRATEGY;
|
||||
private String transactionProcessingStrategy = MIFOS_STANDARD_STRATEGY;
|
||||
private String accountingRule = NONE;
|
||||
private final String currencyCode = USD;
|
||||
private String amortizationType = EQUAL_INSTALLMENTS;
|
||||
private String minPrincipal = "1000.00";
|
||||
private String maxPrincipal = "100000.00";
|
||||
private String maxPrincipal = "10000000.00";
|
||||
private Account[] accountList = null;
|
||||
|
||||
private Boolean multiDisburseLoan = false;
|
||||
private String outstandingLoanBalance = "35000";
|
||||
private String maxTrancheCount = "35000";
|
||||
private final String outstandingLoanBalance = "35000";
|
||||
private final String maxTrancheCount = "35000";
|
||||
|
||||
private Boolean isInterestRecalculationEnabled = false;
|
||||
private String daysInYearType = "1";
|
||||
private String daysInMonthType = "1";
|
||||
private String interestRecalculationCompoundingMethod = "0";
|
||||
private String rescheduleStrategyMethod = "1";
|
||||
private String recalculationRestFrequencyType = "1";
|
||||
private String recalculationRestFrequencyInterval = "0";
|
||||
private String recalculationRestFrequencyDate = null;
|
||||
private String minimumDaysBetweenDisbursalAndFirstRepayment = null;
|
||||
|
||||
public String build(final String chargeId) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
|
||||
if (chargeId != null) {
|
||||
List<HashMap<String, String>> charges = new ArrayList<HashMap<String, String>>();
|
||||
HashMap<String, String> chargeMap = new HashMap<String, String>();
|
||||
List<HashMap<String, String>> charges = new ArrayList<>();
|
||||
HashMap<String, String> chargeMap = new HashMap<>();
|
||||
chargeMap.put("id", chargeId);
|
||||
charges.add(chargeMap);
|
||||
map.put("charges", charges);
|
||||
@@ -71,7 +103,9 @@ public class LoanProductTestBuilder {
|
||||
map.put("shortName", this.shortName);
|
||||
map.put("currencyCode", this.currencyCode);
|
||||
map.put("locale", LOCALE);
|
||||
map.put("digitsAfterDecimal", DIGITS_AFTER_DECIMAL);
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("digitsAfterDecimal", digitsAfterDecimal);
|
||||
map.put("inMultiplesOf", inMultiplesOf);
|
||||
map.put("principal", this.principal);
|
||||
map.put("numberOfRepayments", this.numberOfRepayments);
|
||||
map.put("repaymentEvery", this.repaymentPeriod);
|
||||
@@ -87,6 +121,9 @@ public class LoanProductTestBuilder {
|
||||
map.put("minPrincipal", this.minPrincipal);
|
||||
map.put("maxPrincipal", this.maxPrincipal);
|
||||
map.put("overdueDaysForNPA", this.overdueDaysForNPA);
|
||||
if (this.minimumDaysBetweenDisbursalAndFirstRepayment != null) {
|
||||
map.put("minimumDaysBetweenDisbursalAndFirstRepayment", this.minimumDaysBetweenDisbursalAndFirstRepayment);
|
||||
}
|
||||
if (multiDisburseLoan) {
|
||||
map.put("multiDisburseLoan", this.multiDisburseLoan);
|
||||
map.put("maxTrancheCount", this.maxTrancheCount);
|
||||
@@ -98,6 +135,16 @@ public class LoanProductTestBuilder {
|
||||
} else if (this.accountingRule.equals(CASH_BASED)) {
|
||||
map.putAll(getAccountMappingForCashBased());
|
||||
}
|
||||
map.put("daysInMonthType", this.daysInMonthType);
|
||||
map.put("daysInYearType", this.daysInYearType);
|
||||
map.put("isInterestRecalculationEnabled", this.isInterestRecalculationEnabled);
|
||||
if (this.isInterestRecalculationEnabled) {
|
||||
map.put("interestRecalculationCompoundingMethod", this.interestRecalculationCompoundingMethod);
|
||||
map.put("rescheduleStrategyMethod", this.rescheduleStrategyMethod);
|
||||
map.put("recalculationRestFrequencyType", recalculationRestFrequencyType);
|
||||
map.put("recalculationRestFrequencyInterval", recalculationRestFrequencyInterval);
|
||||
map.put("recalculationRestFrequencyDate", recalculationRestFrequencyDate);
|
||||
}
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
@@ -230,7 +277,7 @@ public class LoanProductTestBuilder {
|
||||
}
|
||||
|
||||
private Map<String, String> getAccountMappingForCashBased() {
|
||||
final Map<String, String> map = new HashMap<String, String>();
|
||||
final Map<String, String> map = new HashMap<>();
|
||||
for (int i = 0; i < this.accountList.length; i++) {
|
||||
if (this.accountList[i].getAccountType().equals(Account.AccountType.ASSET)) {
|
||||
final String ID = this.accountList[i].getAccountID().toString();
|
||||
@@ -258,7 +305,7 @@ public class LoanProductTestBuilder {
|
||||
}
|
||||
|
||||
private Map<String, String> getAccountMappingForAccrualBased() {
|
||||
final Map<String, String> map = new HashMap<String, String>();
|
||||
final Map<String, String> map = new HashMap<>();
|
||||
for (int i = 0; i < this.accountList.length; i++) {
|
||||
if (this.accountList[i].getAccountType().equals(Account.AccountType.ASSET)) {
|
||||
final String ID = this.accountList[i].getAccountID().toString();
|
||||
@@ -296,4 +343,46 @@ public class LoanProductTestBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanProductTestBuilder currencyDetails(final String digitsAfterDecimal, final String inMultiplesOf) {
|
||||
this.digitsAfterDecimal = digitsAfterDecimal;
|
||||
this.inMultiplesOf = inMultiplesOf;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanProductTestBuilder withRepaymentStrategy(final String transactionProcessingStrategy) {
|
||||
this.transactionProcessingStrategy = transactionProcessingStrategy;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanProductTestBuilder withDaysInMonth(final String daysInMonthType) {
|
||||
this.daysInMonthType = daysInMonthType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanProductTestBuilder withDaysInYear(final String daysInYearType) {
|
||||
this.daysInYearType = daysInYearType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanProductTestBuilder withInterestRecalculationDetails(final String interestRecalculationCompoundingMethod,
|
||||
final String rescheduleStrategyMethod) {
|
||||
this.isInterestRecalculationEnabled = true;
|
||||
this.interestRecalculationCompoundingMethod = interestRecalculationCompoundingMethod;
|
||||
this.rescheduleStrategyMethod = rescheduleStrategyMethod;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanProductTestBuilder withInterestRecalculationRestFrequencyDetails(final String recalculationRestFrequencyType,
|
||||
final String recalculationRestFrequencyInterval, final String recalculationRestFrequencyDate) {
|
||||
this.isInterestRecalculationEnabled = true;
|
||||
this.recalculationRestFrequencyType = recalculationRestFrequencyType;
|
||||
this.recalculationRestFrequencyInterval = recalculationRestFrequencyInterval;
|
||||
this.recalculationRestFrequencyDate = recalculationRestFrequencyDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanProductTestBuilder withMinimumDaysBetweenDisbursalAndFirstRepayment(final String minimumDaysBetweenDisbursalAndFirstRepayment) {
|
||||
this.minimumDaysBetweenDisbursalAndFirstRepayment = minimumDaysBetweenDisbursalAndFirstRepayment;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
+136
@@ -0,0 +1,136 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package org.mifosplatform.integrationtests.common.loans;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class LoanRescheduleRequestTestBuilder {
|
||||
private String rescheduleFromDate = "04 December 2014";
|
||||
private String graceOnPrincipal = "2";
|
||||
private String graceOnInterest = "2";
|
||||
private String extraTerms = "2";
|
||||
private Boolean recalculateInterest = false;
|
||||
private String newInterestRate = null;
|
||||
private String adjustedDueDate = null;
|
||||
private String rescheduleReasonId = "1";
|
||||
private String rescheduleReasonComment = null;
|
||||
private String submittedOnDate = "04 September 2014";
|
||||
|
||||
public String build(final String loanId) {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("locale", "en_GB");
|
||||
map.put("loanId", loanId);
|
||||
map.put("submittedOnDate", submittedOnDate);
|
||||
map.put("rescheduleFromDate", rescheduleFromDate);
|
||||
|
||||
if(graceOnPrincipal != null) {
|
||||
map.put("graceOnPrincipal", graceOnPrincipal);
|
||||
}
|
||||
|
||||
if(graceOnInterest != null) {
|
||||
map.put("graceOnInterest", graceOnInterest);
|
||||
}
|
||||
|
||||
if(extraTerms != null) {
|
||||
map.put("extraTerms", extraTerms);
|
||||
}
|
||||
|
||||
map.put("recalculateInterest", recalculateInterest);
|
||||
|
||||
if(newInterestRate != null) {
|
||||
map.put("newInterestRate", newInterestRate);
|
||||
}
|
||||
|
||||
if(adjustedDueDate != null) {
|
||||
map.put("adjustedDueDate", adjustedDueDate);
|
||||
}
|
||||
|
||||
map.put("rescheduleReasonId", rescheduleReasonId);
|
||||
|
||||
if(rescheduleReasonComment != null) {
|
||||
map.put("rescheduleReasonComment", rescheduleReasonComment);
|
||||
}
|
||||
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
public LoanRescheduleRequestTestBuilder updateRescheduleFromDate(final String rescheduleFromDate) {
|
||||
if(rescheduleFromDate != null) {
|
||||
this.rescheduleFromDate = rescheduleFromDate;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanRescheduleRequestTestBuilder updateGraceOnPrincipal(final String graceOnPrincipal) {
|
||||
this.graceOnPrincipal = graceOnPrincipal;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanRescheduleRequestTestBuilder updateGraceOnInterest(final String graceOnInterest) {
|
||||
this.graceOnInterest = graceOnInterest;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanRescheduleRequestTestBuilder updateExtraTerms(final String extraTerms) {
|
||||
this.extraTerms = extraTerms;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanRescheduleRequestTestBuilder updateRecalculateInterest(final Boolean recalculateInterest) {
|
||||
this.recalculateInterest = recalculateInterest;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanRescheduleRequestTestBuilder updateNewInterestRate(final String newInterestRate) {
|
||||
this.newInterestRate = newInterestRate;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanRescheduleRequestTestBuilder updateAdjustedDueDate(final String adjustedDueDate) {
|
||||
this.adjustedDueDate = adjustedDueDate;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanRescheduleRequestTestBuilder updateRescheduleReasonId(final String rescheduleReasonId) {
|
||||
this.rescheduleReasonId = rescheduleReasonId;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanRescheduleRequestTestBuilder updateRescheduleReasonComment(final String rescheduleReasonComment) {
|
||||
this.rescheduleReasonComment = rescheduleReasonComment;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getRejectLoanRescheduleRequestJSON() {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("locale", "en");
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("rejectedOnDate", submittedOnDate);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
public String getApproveLoanRescheduleRequestJSON() {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("locale", "en");
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("approvedOnDate", submittedOnDate);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
}
|
||||
+6
-1
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common.loans;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
@@ -43,7 +48,7 @@ public class LoanStatusChecker {
|
||||
|
||||
public static HashMap getStatusOfLoan(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer loanID) {
|
||||
final String url = "/mifosng-provider/api/v1/loans/" + loanID + "?tenantIdentifier=default";
|
||||
final String url = "/mifosng-provider/api/v1/loans/" + loanID + "?" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerGet(requestSpec, responseSpec, url, "status");
|
||||
}
|
||||
|
||||
|
||||
Regular → Executable
+96
-34
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common.loans;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -19,8 +24,8 @@ public class LoanTransactionHelper {
|
||||
private final RequestSpecification requestSpec;
|
||||
private final ResponseSpecification responseSpec;
|
||||
|
||||
private static final String CREATE_LOAN_PRODUCT_URL = "/mifosng-provider/api/v1/loanproducts?tenantIdentifier=default";
|
||||
private static final String APPLY_LOAN_URL = "/mifosng-provider/api/v1/loans?tenantIdentifier=default";
|
||||
private static final String CREATE_LOAN_PRODUCT_URL = "/mifosng-provider/api/v1/loanproducts?" + Utils.TENANT_IDENTIFIER;
|
||||
private static final String APPLY_LOAN_URL = "/mifosng-provider/api/v1/loans?" + Utils.TENANT_IDENTIFIER;
|
||||
private static final String APPROVE_LOAN_COMMAND = "approve";
|
||||
private static final String UNDO_APPROVAL_LOAN_COMMAND = "undoApproval";
|
||||
private static final String DISBURSE_LOAN_COMMAND = "disburse";
|
||||
@@ -43,28 +48,44 @@ public class LoanTransactionHelper {
|
||||
public Integer getLoanId(final String loanApplicationJSON) {
|
||||
return Utils.performServerPost(this.requestSpec, this.responseSpec, APPLY_LOAN_URL, loanApplicationJSON, "loanId");
|
||||
}
|
||||
public Integer getLoanOfficerId(final String loanId) {
|
||||
final String GET_LOAN_URL = "/mifosng-provider/api/v1/loans/" + loanId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerGet(this.requestSpec, this.responseSpec, GET_LOAN_URL, "loanOfficerId");
|
||||
}
|
||||
|
||||
|
||||
public Object createLoanAccount(final String loanApplicationJSON, final String responseAttribute) {
|
||||
return Utils.performServerPost(this.requestSpec, this.responseSpec, APPLY_LOAN_URL, loanApplicationJSON, responseAttribute);
|
||||
}
|
||||
|
||||
public Integer updateLoan(final Integer id, final String loanApplicationJSON) {
|
||||
return Utils.performServerPut(this.requestSpec, this.responseSpec, "/mifosng-provider/api/v1/loans/" + id
|
||||
+ "?tenantIdentifier=default", loanApplicationJSON, "loanId");
|
||||
+ "?" + Utils.TENANT_IDENTIFIER, loanApplicationJSON, "loanId");
|
||||
}
|
||||
|
||||
public ArrayList getLoanRepaymentSchedule(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer loanID) {
|
||||
final String URL = "/mifosng-provider/api/v1/loans/" + loanID + "?associations=repaymentSchedule&tenantIdentifier=default";
|
||||
final String URL = "/mifosng-provider/api/v1/loans/" + loanID + "?associations=repaymentSchedule&" + Utils.TENANT_IDENTIFIER;
|
||||
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "repaymentSchedule");
|
||||
return (ArrayList) response.get("periods");
|
||||
}
|
||||
|
||||
public ArrayList getLoanFutureRepaymentSchedule(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer loanID) {
|
||||
final String URL = "/mifosng-provider/api/v1/loans/" + loanID + "?associations=repaymentSchedule,futureSchedule&" + Utils.TENANT_IDENTIFIER;
|
||||
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "repaymentSchedule");
|
||||
return (ArrayList) response.get("futurePeriods");
|
||||
}
|
||||
|
||||
public HashMap getLoanSummary(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer loanID) {
|
||||
final String URL = "/mifosng-provider/api/v1/loans/" + loanID + "?associations=all&tenantIdentifier=default";
|
||||
final String URL = "/mifosng-provider/api/v1/loans/" + loanID + "?associations=all&" + Utils.TENANT_IDENTIFIER;
|
||||
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "summary");
|
||||
return response;
|
||||
}
|
||||
|
||||
public Object getLoanDetail(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer loanID,
|
||||
final String param) {
|
||||
final String URL = "/mifosng-provider/api/v1/loans/" + loanID + "?associations=all&tenantIdentifier=default";
|
||||
final String URL = "/mifosng-provider/api/v1/loans/" + loanID + "?associations=all&" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerGet(requestSpec, responseSpec, URL, param);
|
||||
}
|
||||
|
||||
@@ -76,6 +97,19 @@ public class LoanTransactionHelper {
|
||||
public HashMap approveLoan(final String approvalDate, final Integer loanID) {
|
||||
return performLoanTransaction(createLoanOperationURL(APPROVE_LOAN_COMMAND, loanID), getApproveLoanAsJSON(approvalDate));
|
||||
}
|
||||
|
||||
public HashMap approveLoanWithApproveAmount(final String approvalDate, final String approvalAmount, final Integer loanID) {
|
||||
return performLoanTransaction(createLoanOperationURL(APPROVE_LOAN_COMMAND, loanID), getApproveLoanAsJSON(approvalDate, approvalAmount));
|
||||
}
|
||||
|
||||
public Object approveLoanWithApproveAmount(final String approvalDate, final String approvalAmount, final Integer loanID,
|
||||
final String responseAttribute) {
|
||||
|
||||
final String approvalURL = createLoanOperationURL(APPROVE_LOAN_COMMAND, loanID);
|
||||
final String approvalJSONData = getApproveLoanAsJSON(approvalDate, approvalAmount);
|
||||
|
||||
return performLoanTransaction(approvalURL, approvalJSONData, responseAttribute);
|
||||
}
|
||||
|
||||
public HashMap undoApproval(final Integer loanID) {
|
||||
final String undoBodyJson = "{'note':'UNDO APPROVAL'}";
|
||||
@@ -83,11 +117,15 @@ public class LoanTransactionHelper {
|
||||
}
|
||||
|
||||
public HashMap disburseLoan(final String date, final Integer loanID) {
|
||||
return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID), getDisburseLoanAsJSON(date));
|
||||
return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID), getDisburseLoanAsJSON(date, null));
|
||||
}
|
||||
|
||||
|
||||
public HashMap disburseLoan(final String date, final Integer loanID, final String disburseAmt) {
|
||||
return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID), getDisburseLoanAsJSON(date, disburseAmt));
|
||||
}
|
||||
|
||||
public HashMap disburseLoanToSavings(final String date, final Integer loanID) {
|
||||
return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_TO_SAVINGS_COMMAND, loanID), getDisburseLoanAsJSON(date));
|
||||
return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_TO_SAVINGS_COMMAND, loanID), getDisburseLoanAsJSON(date, null));
|
||||
}
|
||||
|
||||
public HashMap undoDisbursal(final Integer loanID) {
|
||||
@@ -105,11 +143,11 @@ public class LoanTransactionHelper {
|
||||
public HashMap waiveInterest(final String date, final String amountToBeWaived, final Integer loanID) {
|
||||
return performLoanTransaction(createLoanTransactionURL(WAIVE_INTEREST_COMMAND, loanID), getWaiveBodyAsJSON(date, amountToBeWaived));
|
||||
}
|
||||
|
||||
|
||||
public Integer waiveInterestAndReturnTransactionId(final String date, final String amountToBeWaived, final Integer loanID) {
|
||||
Integer resourceId = Utils.performServerPost(this.requestSpec, this.responseSpec, createLoanTransactionURL(WAIVE_INTEREST_COMMAND, loanID),
|
||||
getWaiveBodyAsJSON(date, amountToBeWaived), "resourceId");
|
||||
return resourceId;
|
||||
Integer resourceId = Utils.performServerPost(this.requestSpec, this.responseSpec,
|
||||
createLoanTransactionURL(WAIVE_INTEREST_COMMAND, loanID), getWaiveBodyAsJSON(date, amountToBeWaived), "resourceId");
|
||||
return resourceId;
|
||||
}
|
||||
|
||||
public HashMap makeRepayment(final String date, final Float amountToBePaid, final Integer loanID) {
|
||||
@@ -124,7 +162,7 @@ public class LoanTransactionHelper {
|
||||
|
||||
public Integer addChargesForLoan(final Integer loanId, final String request) {
|
||||
System.out.println("--------------------------------- ADD CHARGES FOR LOAN --------------------------------");
|
||||
final String ADD_CHARGES_URL = "/mifosng-provider/api/v1/loans/" + loanId + "/charges?tenantIdentifier=default";
|
||||
final String ADD_CHARGES_URL = "/mifosng-provider/api/v1/loans/" + loanId + "/charges?" + Utils.TENANT_IDENTIFIER;
|
||||
final HashMap response = Utils.performServerPost(requestSpec, responseSpec, ADD_CHARGES_URL, request, "");
|
||||
return (Integer) response.get("resourceId");
|
||||
}
|
||||
@@ -132,7 +170,7 @@ public class LoanTransactionHelper {
|
||||
public Integer updateChargesForLoan(final Integer loanId, final Integer loanchargeId, final String request) {
|
||||
System.out.println("--------------------------------- ADD CHARGES FOR LOAN --------------------------------");
|
||||
final String UPDATE_CHARGES_URL = "/mifosng-provider/api/v1/loans/" + loanId + "/charges/" + loanchargeId
|
||||
+ "?tenantIdentifier=default";
|
||||
+ "?" + Utils.TENANT_IDENTIFIER;
|
||||
final HashMap response = Utils.performServerPut(requestSpec, responseSpec, UPDATE_CHARGES_URL, request, "");
|
||||
return (Integer) response.get("resourceId");
|
||||
}
|
||||
@@ -140,7 +178,7 @@ public class LoanTransactionHelper {
|
||||
public Integer deleteChargesForLoan(final Integer loanId, final Integer loanchargeId) {
|
||||
System.out.println("--------------------------------- DELETE CHARGES FOR LOAN --------------------------------");
|
||||
final String DELETE_CHARGES_URL = "/mifosng-provider/api/v1/loans/" + loanId + "/charges/" + loanchargeId
|
||||
+ "?tenantIdentifier=default";
|
||||
+ "?" + Utils.TENANT_IDENTIFIER;
|
||||
final HashMap response = Utils.performServerDelete(requestSpec, responseSpec, DELETE_CHARGES_URL, "");
|
||||
return (Integer) response.get("resourceId");
|
||||
}
|
||||
@@ -148,7 +186,7 @@ public class LoanTransactionHelper {
|
||||
public Integer waiveChargesForLoan(final Integer loanId, final Integer loanchargeId, final String json) {
|
||||
System.out.println("--------------------------------- WAIVE CHARGES FOR LOAN --------------------------------");
|
||||
final String CHARGES_URL = "/mifosng-provider/api/v1/loans/" + loanId + "/charges/" + loanchargeId
|
||||
+ "?command=waive&tenantIdentifier=default";
|
||||
+ "?command=waive&" + Utils.TENANT_IDENTIFIER;
|
||||
final HashMap response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, json, "");
|
||||
return (Integer) response.get("resourceId");
|
||||
}
|
||||
@@ -156,31 +194,44 @@ public class LoanTransactionHelper {
|
||||
public Integer payChargesForLoan(final Integer loanId, final Integer loanchargeId, final String json) {
|
||||
System.out.println("--------------------------------- WAIVE CHARGES FOR LOAN --------------------------------");
|
||||
final String CHARGES_URL = "/mifosng-provider/api/v1/loans/" + loanId + "/charges/" + loanchargeId
|
||||
+ "?command=pay&tenantIdentifier=default";
|
||||
+ "?command=pay&" + Utils.TENANT_IDENTIFIER;
|
||||
final HashMap response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, json, "");
|
||||
return (Integer) response.get("resourceId");
|
||||
}
|
||||
|
||||
private String getDisburseLoanAsJSON(final String actualDisbursementDate) {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
private String getDisburseLoanAsJSON(final String actualDisbursementDate, final String transactionAmount) {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("locale", "en");
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("actualDisbursementDate", actualDisbursementDate);
|
||||
map.put("note", "DISBURSE NOTE");
|
||||
if (transactionAmount != null) {
|
||||
map.put("transactionAmount", transactionAmount);
|
||||
}
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
private String getApproveLoanAsJSON(final String approvalDate) {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("locale", "en");
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("approvedOnDate", approvalDate);
|
||||
map.put("note", "Approval NOTE");
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
private String getApproveLoanAsJSON(final String approvalDate, final String approvalAmount) {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("locale", "en");
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("approvedLoanAmount", approvalAmount);
|
||||
map.put("approvedOnDate", approvalDate);
|
||||
map.put("note", "Approval NOTE");
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
private String getRepaymentBodyAsJSON(final String transactionDate, final Float transactionAmount) {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("locale", "en");
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("transactionDate", transactionDate);
|
||||
@@ -190,7 +241,7 @@ public class LoanTransactionHelper {
|
||||
}
|
||||
|
||||
private String getWriteOffBodyAsJSON(final String transactionDate) {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("locale", "en");
|
||||
map.put("note", " LOAN WRITE OFF!!!");
|
||||
@@ -199,7 +250,7 @@ public class LoanTransactionHelper {
|
||||
}
|
||||
|
||||
private String getWaiveBodyAsJSON(final String transactionDate, final String amountToBeWaived) {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("locale", "en");
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("transactionDate", transactionDate);
|
||||
@@ -209,7 +260,7 @@ public class LoanTransactionHelper {
|
||||
}
|
||||
|
||||
private String getWithdrawLoanApplicationBodyAsJSON(final String withdrawDate) {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("locale", "en");
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("withdrawnOnDate", withdrawDate);
|
||||
@@ -223,7 +274,7 @@ public class LoanTransactionHelper {
|
||||
}
|
||||
|
||||
public static String getSpecifiedDueDateChargesForLoanAsJSON(final String chargeId, final String dueDate, final String amount) {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("locale", "en_GB");
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("amount", amount);
|
||||
@@ -239,7 +290,7 @@ public class LoanTransactionHelper {
|
||||
}
|
||||
|
||||
public static String getDisbursementChargesForLoanAsJSON(final String chargeId, String amount) {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("locale", "en_GB");
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("amount", amount);
|
||||
@@ -250,7 +301,7 @@ public class LoanTransactionHelper {
|
||||
}
|
||||
|
||||
public static String getInstallmentChargesForLoanAsJSON(final String chargeId, final String amount) {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("locale", "en_GB");
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("amount", amount);
|
||||
@@ -261,7 +312,7 @@ public class LoanTransactionHelper {
|
||||
}
|
||||
|
||||
public static String getUpdateChargesForLoanAsJSON(String amount) {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("locale", "en_GB");
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("amount", amount);
|
||||
@@ -271,7 +322,7 @@ public class LoanTransactionHelper {
|
||||
}
|
||||
|
||||
public static String getPayChargeJSON(final String date, final String installmentNumber) {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("locale", "en_GB");
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("transactionDate", date);
|
||||
@@ -284,7 +335,7 @@ public class LoanTransactionHelper {
|
||||
}
|
||||
|
||||
public static String getWaiveChargeJSON(final String installmentNumber) {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("locale", "en_GB");
|
||||
map.put("installmentNumber", installmentNumber);
|
||||
String json = new Gson().toJson(map);
|
||||
@@ -293,7 +344,7 @@ public class LoanTransactionHelper {
|
||||
}
|
||||
|
||||
public String getLoanCalculationBodyAsJSON(final String productID) {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("locale", "en_GB");
|
||||
map.put("productId", productID);
|
||||
@@ -314,11 +365,11 @@ public class LoanTransactionHelper {
|
||||
}
|
||||
|
||||
private String createLoanOperationURL(final String command, final Integer loanID) {
|
||||
return "/mifosng-provider/api/v1/loans/" + loanID + "?command=" + command + "&tenantIdentifier=default";
|
||||
return "/mifosng-provider/api/v1/loans/" + loanID + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER;
|
||||
}
|
||||
|
||||
private String createLoanTransactionURL(final String command, final Integer loanID) {
|
||||
return "/mifosng-provider/api/v1/loans/" + loanID + "/transactions?command=" + command + "&tenantIdentifier=default";
|
||||
return "/mifosng-provider/api/v1/loans/" + loanID + "/transactions?command=" + command + "&" + Utils.TENANT_IDENTIFIER;
|
||||
}
|
||||
|
||||
private HashMap performLoanTransaction(final String postURLForLoanTransaction, final String jsonToBeSent) {
|
||||
@@ -327,6 +378,17 @@ public class LoanTransactionHelper {
|
||||
"changes");
|
||||
return (HashMap) response.get("status");
|
||||
}
|
||||
|
||||
private Object performLoanTransaction(final String postURLForLoanTransaction, final String jsonToBeSent, final String responseAttribute) {
|
||||
return Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForLoanTransaction, jsonToBeSent, responseAttribute);
|
||||
}
|
||||
|
||||
|
||||
public HashMap getPrepayAmount(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer loanID) {
|
||||
final String URL = "/mifosng-provider/api/v1/loans/" + loanID + "/transactions/template?command=prepayLoan&" + Utils.TENANT_IDENTIFIER;
|
||||
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "");
|
||||
return response;
|
||||
}
|
||||
|
||||
public void verifyRepaymentScheduleEntryFor(final int repaymentNumber, final float expectedPrincipalOutstanding, final Integer loanID) {
|
||||
System.out.println("---------------------------GETTING LOAN REPAYMENT SCHEDULE--------------------------------");
|
||||
|
||||
+22
-16
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common.recurringdeposit;
|
||||
|
||||
import java.text.DateFormat;
|
||||
@@ -6,6 +11,7 @@ import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.mifosplatform.integrationtests.common.CommonConstants;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
@@ -91,10 +97,10 @@ public class RecurringDepositAccountHelper {
|
||||
|
||||
public String build(final String clientId, final String productId, final String validFrom, final String validTo,
|
||||
final String penalInterestType) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
|
||||
List<HashMap<String, String>> chartSlabs = new ArrayList<HashMap<String, String>>();
|
||||
HashMap<String, String> chartSlabsMap1 = new HashMap<String, String>();
|
||||
HashMap<String, String> chartSlabsMap1 = new HashMap<>();
|
||||
chartSlabsMap1.put("description", "First");
|
||||
chartSlabsMap1.put("periodType", MONTHS);
|
||||
chartSlabsMap1.put("fromPeriod", "1");
|
||||
@@ -103,7 +109,7 @@ public class RecurringDepositAccountHelper {
|
||||
chartSlabsMap1.put("locale", LOCALE);
|
||||
chartSlabs.add(0, chartSlabsMap1);
|
||||
|
||||
HashMap<String, String> chartSlabsMap2 = new HashMap<String, String>();
|
||||
HashMap<String, String> chartSlabsMap2 = new HashMap<>();
|
||||
chartSlabsMap2.put("description", "Second");
|
||||
chartSlabsMap2.put("periodType", MONTHS);
|
||||
chartSlabsMap2.put("fromPeriod", "7");
|
||||
@@ -112,7 +118,7 @@ public class RecurringDepositAccountHelper {
|
||||
chartSlabsMap2.put("locale", LOCALE);
|
||||
chartSlabs.add(1, chartSlabsMap2);
|
||||
|
||||
HashMap<String, String> chartSlabsMap3 = new HashMap<String, String>();
|
||||
HashMap<String, String> chartSlabsMap3 = new HashMap<>();
|
||||
chartSlabsMap3.put("description", "Third");
|
||||
chartSlabsMap3.put("periodType", MONTHS);
|
||||
chartSlabsMap3.put("fromPeriod", "13");
|
||||
@@ -121,7 +127,7 @@ public class RecurringDepositAccountHelper {
|
||||
chartSlabsMap3.put("locale", LOCALE);
|
||||
chartSlabs.add(2, chartSlabsMap3);
|
||||
|
||||
HashMap<String, String> chartSlabsMap4 = new HashMap<String, String>();
|
||||
HashMap<String, String> chartSlabsMap4 = new HashMap<>();
|
||||
chartSlabsMap4.put("description", "Fourth");
|
||||
chartSlabsMap4.put("periodType", MONTHS);
|
||||
chartSlabsMap4.put("fromPeriod", "19");
|
||||
@@ -131,7 +137,7 @@ public class RecurringDepositAccountHelper {
|
||||
chartSlabs.add(3, chartSlabsMap4);
|
||||
|
||||
List<HashMap<String, Object>> charts = new ArrayList<HashMap<String, Object>>();
|
||||
HashMap<String, Object> chartsMap = new HashMap<String, Object>();
|
||||
HashMap<String, Object> chartsMap = new HashMap<>();
|
||||
chartsMap.put("fromDate", validFrom);
|
||||
chartsMap.put("endDate", validTo);
|
||||
chartsMap.put("dateFormat", "dd MMMM yyyy");
|
||||
@@ -247,7 +253,7 @@ public class RecurringDepositAccountHelper {
|
||||
public HashMap updateRecurringDepositAccount(final String clientID, final String productID, final String accountID,
|
||||
final String validFrom, final String validTo, final String penalInterestType, final String submittedOnDate) {
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.MONTH, -1);
|
||||
todaysDate.add(Calendar.DATE, -1);
|
||||
@@ -378,7 +384,7 @@ public class RecurringDepositAccountHelper {
|
||||
}
|
||||
|
||||
private String getApproveRecurringDepositAccountAsJSON(final String approvedOnDate) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("approvedOnDate", approvedOnDate);
|
||||
@@ -389,7 +395,7 @@ public class RecurringDepositAccountHelper {
|
||||
}
|
||||
|
||||
private String getUpdateTransactionAsJSON(final String transactionDate, final Float transactionAmount) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("transactionDate", transactionDate);
|
||||
@@ -400,7 +406,7 @@ public class RecurringDepositAccountHelper {
|
||||
}
|
||||
|
||||
private String getRejectedRecurringDepositAsJSON(final String rejectedOnDate) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("rejectedOnDate", rejectedOnDate);
|
||||
@@ -411,7 +417,7 @@ public class RecurringDepositAccountHelper {
|
||||
}
|
||||
|
||||
private String getWithdrawnRecurringDepositAccountAsJSON(final String withdrawnApplicationOnDate) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("withdrawnOnDate", withdrawnApplicationOnDate);
|
||||
@@ -422,7 +428,7 @@ public class RecurringDepositAccountHelper {
|
||||
}
|
||||
|
||||
private String getActivatedRecurringDepositAccountAsJSON(final String activationDate) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("activatedOnDate", activationDate);
|
||||
@@ -432,14 +438,14 @@ public class RecurringDepositAccountHelper {
|
||||
}
|
||||
|
||||
private String getCalculatedInterestForRecurringDepositApplicationAsJSON() {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
String recurringDepositAccountCalculatedInterestJson = new Gson().toJson(map);
|
||||
System.out.println(recurringDepositAccountCalculatedInterestJson);
|
||||
return recurringDepositAccountCalculatedInterestJson;
|
||||
}
|
||||
|
||||
private String getCalculatedPrematureAmountForRecurringDepositAccountAsJSON(final String closedOnDate) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("closedOnDate", closedOnDate);
|
||||
@@ -449,7 +455,7 @@ public class RecurringDepositAccountHelper {
|
||||
}
|
||||
|
||||
private String getDepositToRecurringDepositAccountAsJSON(final Float depositAmount, final String depositedOnDate) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("transactionAmount", depositAmount);
|
||||
@@ -461,7 +467,7 @@ public class RecurringDepositAccountHelper {
|
||||
|
||||
private String getPrematureCloseForRecurringDepositAccountAsJSON(final String closedOnDate, final String closureType,
|
||||
final Integer toSavingsId) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("closedOnDate", closedOnDate);
|
||||
|
||||
+5
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common.recurringdeposit;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
+12
-7
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common.recurringdeposit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -79,10 +84,10 @@ public class RecurringDepositProductHelper {
|
||||
private Account[] accountList = null;
|
||||
|
||||
public String build(final String validFrom, final String validTo) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
|
||||
List<HashMap<String, String>> chartSlabs = new ArrayList<HashMap<String, String>>();
|
||||
HashMap<String, String> chartSlabsMap1 = new HashMap<String, String>();
|
||||
HashMap<String, String> chartSlabsMap1 = new HashMap<>();
|
||||
chartSlabsMap1.put("description", "First");
|
||||
chartSlabsMap1.put("periodType", MONTHS);
|
||||
chartSlabsMap1.put("fromPeriod", "1");
|
||||
@@ -91,7 +96,7 @@ public class RecurringDepositProductHelper {
|
||||
chartSlabsMap1.put("locale", LOCALE);
|
||||
chartSlabs.add(0, chartSlabsMap1);
|
||||
|
||||
HashMap<String, String> chartSlabsMap2 = new HashMap<String, String>();
|
||||
HashMap<String, String> chartSlabsMap2 = new HashMap<>();
|
||||
chartSlabsMap2.put("description", "Second");
|
||||
chartSlabsMap2.put("periodType", MONTHS);
|
||||
chartSlabsMap2.put("fromPeriod", "7");
|
||||
@@ -100,7 +105,7 @@ public class RecurringDepositProductHelper {
|
||||
chartSlabsMap2.put("locale", LOCALE);
|
||||
chartSlabs.add(1, chartSlabsMap2);
|
||||
|
||||
HashMap<String, String> chartSlabsMap3 = new HashMap<String, String>();
|
||||
HashMap<String, String> chartSlabsMap3 = new HashMap<>();
|
||||
chartSlabsMap3.put("description", "Third");
|
||||
chartSlabsMap3.put("periodType", MONTHS);
|
||||
chartSlabsMap3.put("fromPeriod", "13");
|
||||
@@ -109,7 +114,7 @@ public class RecurringDepositProductHelper {
|
||||
chartSlabsMap3.put("locale", LOCALE);
|
||||
chartSlabs.add(2, chartSlabsMap3);
|
||||
|
||||
HashMap<String, String> chartSlabsMap4 = new HashMap<String, String>();
|
||||
HashMap<String, String> chartSlabsMap4 = new HashMap<>();
|
||||
chartSlabsMap4.put("description", "Fourth");
|
||||
chartSlabsMap4.put("periodType", MONTHS);
|
||||
chartSlabsMap4.put("fromPeriod", "19");
|
||||
@@ -119,7 +124,7 @@ public class RecurringDepositProductHelper {
|
||||
chartSlabs.add(3, chartSlabsMap4);
|
||||
|
||||
List<HashMap<String, Object>> charts = new ArrayList<HashMap<String, Object>>();
|
||||
HashMap<String, Object> chartsMap = new HashMap<String, Object>();
|
||||
HashMap<String, Object> chartsMap = new HashMap<>();
|
||||
chartsMap.put("fromDate", validFrom);
|
||||
chartsMap.put("endDate", validTo);
|
||||
chartsMap.put("dateFormat", "dd MMMM yyyy");
|
||||
@@ -181,7 +186,7 @@ public class RecurringDepositProductHelper {
|
||||
}
|
||||
|
||||
private Map<String, String> getAccountMappingForCashBased() {
|
||||
final Map<String, String> map = new HashMap<String, String>();
|
||||
final Map<String, String> map = new HashMap<>();
|
||||
if (accountList != null) {
|
||||
for (int i = 0; i < this.accountList.length; i++) {
|
||||
if (this.accountList[i].getAccountType().equals(Account.AccountType.ASSET)) {
|
||||
|
||||
+6
-1
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common.savings;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -31,7 +36,7 @@ public class AccountTransferHelper {
|
||||
public String build(final String fromAccountId, final String fromClientId, final String toAccountId, final String toClientId,
|
||||
final String fromAccountType, final String toAccountType, final String transferAmount) {
|
||||
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("locale", LOCALE);
|
||||
map.put("fromClientId", fromClientId);
|
||||
|
||||
+84
-21
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common.savings;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -5,6 +10,7 @@ import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.mifosplatform.integrationtests.common.CommonConstants;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
@@ -46,16 +52,21 @@ public class SavingsAccountHelper {
|
||||
}
|
||||
|
||||
public static String getFutureDate() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(CommonConstants.dateFormat);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(CommonConstants.dateFormat, Locale.US);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) + 1);
|
||||
return sdf.format(calendar.getTime());
|
||||
}
|
||||
|
||||
public Integer applyForSavingsApplication(final Integer ID, final Integer savingsProductID, final String accountType) {
|
||||
System.out.println("--------------------------------APPLYING FOR SAVINGS APPLICATION--------------------------------");
|
||||
return applyForSavingsApplicationOnDate(ID, savingsProductID, accountType, CREATED_DATE);
|
||||
}
|
||||
|
||||
public Integer applyForSavingsApplicationOnDate(final Integer ID, final Integer savingsProductID, final String accountType,
|
||||
final String submittedOnDate) {
|
||||
System.out.println("--------------------------------APPLYING FOR SAVINGS APPLICATION--------------------------------");
|
||||
final String savingsApplicationJSON = new SavingsApplicationTestBuilder() //
|
||||
.withSubmittedOnDate(CREATED_DATE) //
|
||||
.withSubmittedOnDate(submittedOnDate) //
|
||||
.build(ID.toString(), savingsProductID.toString(), accountType);
|
||||
return Utils.performServerPost(this.requestSpec, this.responseSpec, SAVINGS_ACCOUNT_URL + "?" + Utils.TENANT_IDENTIFIER,
|
||||
savingsApplicationJSON, "savingsId");
|
||||
@@ -71,8 +82,15 @@ public class SavingsAccountHelper {
|
||||
}
|
||||
|
||||
public HashMap approveSavings(final Integer savingsID) {
|
||||
System.out.println("--------------------------------- APPROVING SAVINGS APPLICATION ------------------------------------");
|
||||
return performSavingApplicationActions(createSavingsOperationURL(APPROVE_SAVINGS_COMMAND, savingsID), getApproveSavingsAsJSON());
|
||||
return approveSavingsOnDate(savingsID, null);
|
||||
}
|
||||
|
||||
public HashMap approveSavingsOnDate(final Integer savingsID, final String approvalDate) {
|
||||
System.out.println("--------------------------------- APPROVING SAVINGS APPLICATION ------------------------------------");
|
||||
final String savingsOperationURL = createSavingsOperationURL(APPROVE_SAVINGS_COMMAND, savingsID);
|
||||
if(approvalDate == null || approvalDate == "")
|
||||
return performSavingApplicationActions(savingsOperationURL, getApproveSavingsAsJSON());
|
||||
return performSavingApplicationActions(savingsOperationURL, getApproveSavingsAsJsonOnDate(approvalDate));
|
||||
}
|
||||
|
||||
public HashMap undoApproval(final Integer savingsID) {
|
||||
@@ -104,9 +122,9 @@ public class SavingsAccountHelper {
|
||||
return performSavingApplicationActions(createSavingsOperationURL(ACTIVATE_SAVINGS_COMMAND, savingsID), getActivatedSavingsAsJSON());
|
||||
}
|
||||
|
||||
public HashMap closeSavingsAccount(final Integer savingsID) {
|
||||
public HashMap closeSavingsAccount(final Integer savingsID, String withdrawBalance) {
|
||||
System.out.println("---------------------------------- CLOSE SAVINGS APPLICATION ----------------------------------");
|
||||
return performSavingApplicationActions(createSavingsOperationURL(CLOSE_SAVINGS_COMMAND, savingsID), getCloseAccountJSON());
|
||||
return performSavingApplicationActions(createSavingsOperationURL(CLOSE_SAVINGS_COMMAND, savingsID), getCloseAccountJSON(withdrawBalance, LAST_TRANSACTION_DATE));
|
||||
}
|
||||
|
||||
public Object deleteSavingsApplication(final Integer savingsId, final String jsonAttributeToGetBack) {
|
||||
@@ -179,10 +197,14 @@ public class SavingsAccountHelper {
|
||||
}
|
||||
|
||||
private String getApproveSavingsAsJSON() {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
return getApproveSavingsAsJsonOnDate(CREATED_DATE_PLUS_ONE);
|
||||
}
|
||||
|
||||
private String getApproveSavingsAsJsonOnDate(final String approvalDate) {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("approvedOnDate", CREATED_DATE_PLUS_ONE);
|
||||
map.put("approvedOnDate", approvalDate);
|
||||
map.put("note", "Approval NOTE");
|
||||
String savingsAccountApproveJson = new Gson().toJson(map);
|
||||
System.out.println(savingsAccountApproveJson);
|
||||
@@ -190,7 +212,7 @@ public class SavingsAccountHelper {
|
||||
}
|
||||
|
||||
private String getRejectedSavingsAsJSON(final String rejectedOnDate) {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("rejectedOnDate", rejectedOnDate);
|
||||
@@ -201,7 +223,7 @@ public class SavingsAccountHelper {
|
||||
}
|
||||
|
||||
private String getWithdrawnSavingsAsJSON() {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("withdrawnOnDate", CREATED_DATE_PLUS_ONE);
|
||||
@@ -212,7 +234,7 @@ public class SavingsAccountHelper {
|
||||
}
|
||||
|
||||
private String getActivatedSavingsAsJSON() {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("activatedOnDate", TRANSACTION_DATE);
|
||||
@@ -222,7 +244,7 @@ public class SavingsAccountHelper {
|
||||
}
|
||||
|
||||
private String getSavingsTransactionJSON(final String amount, final String transactionDate) {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("transactionDate", transactionDate);
|
||||
@@ -233,14 +255,14 @@ public class SavingsAccountHelper {
|
||||
}
|
||||
|
||||
private String getCalculatedInterestForSavingsApplicationAsJSON() {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
String savingsAccountCalculatedInterestJson = new Gson().toJson(map);
|
||||
System.out.println(savingsAccountCalculatedInterestJson);
|
||||
return savingsAccountCalculatedInterestJson;
|
||||
}
|
||||
|
||||
private String getSavingsPayChargeJSON(final String amount, final String dueDate) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("amount", amount);
|
||||
@@ -250,7 +272,7 @@ public class SavingsAccountHelper {
|
||||
}
|
||||
|
||||
private String getSavingsWaiveChargeJSON() {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
String josn = new Gson().toJson(map);
|
||||
@@ -258,7 +280,7 @@ public class SavingsAccountHelper {
|
||||
}
|
||||
|
||||
private String getModifyChargeJSON() {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("amount", "50");
|
||||
@@ -266,11 +288,12 @@ public class SavingsAccountHelper {
|
||||
return josn;
|
||||
}
|
||||
|
||||
private String getCloseAccountJSON() {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
private String getCloseAccountJSON(String withdrawBalance, String closedOnDate) {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("closedOnDate", LAST_TRANSACTION_DATE);
|
||||
map.put("closedOnDate", closedOnDate);
|
||||
map.put("withdrawBalance", withdrawBalance);
|
||||
map.put("note", "Close Test");
|
||||
String josn = new Gson().toJson(map);
|
||||
return josn;
|
||||
@@ -329,6 +352,12 @@ public class SavingsAccountHelper {
|
||||
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "summary");
|
||||
return response;
|
||||
}
|
||||
|
||||
public HashMap getSavingsDetails(final Integer savingsID) {
|
||||
final String URL = SAVINGS_ACCOUNT_URL + "/" + savingsID + "?associations=all&" + Utils.TENANT_IDENTIFIER;
|
||||
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, URL, "");
|
||||
return response;
|
||||
}
|
||||
|
||||
private HashMap performSavingApplicationActions(final String postURLForSavingsTransaction, final String jsonToBeSent) {
|
||||
HashMap status = null;
|
||||
@@ -346,8 +375,15 @@ public class SavingsAccountHelper {
|
||||
jsonAttributeToGetBack);
|
||||
}
|
||||
|
||||
public Object closeSavingsAccountAndGetBackRequiredField(final Integer savingsID, String withdrawBalance,
|
||||
final String jsonAttributeToGetBack, final String closedOnDate) {
|
||||
System.out.println("---------------------------------- CLOSE SAVINGS APPLICATION ----------------------------------");
|
||||
return performSavingActions(createSavingsOperationURL(CLOSE_SAVINGS_COMMAND, savingsID),
|
||||
getCloseAccountJSON(withdrawBalance, closedOnDate), jsonAttributeToGetBack);
|
||||
}
|
||||
|
||||
private String getPeriodChargeRequestJSON(Integer chargeId) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("chargeId", chargeId);
|
||||
map.put("amount", 100);
|
||||
map.put("feeOnMonthDay", "15 January");
|
||||
@@ -358,4 +394,31 @@ public class SavingsAccountHelper {
|
||||
String json = new Gson().toJson(map);
|
||||
return json;
|
||||
}
|
||||
|
||||
private String getAccountActivationJSON(final String activationDate) {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("activatedOnDate", activationDate);
|
||||
String savingsAccountActivateJson = new Gson().toJson(map);
|
||||
return savingsAccountActivateJson;
|
||||
}
|
||||
|
||||
public HashMap activateSavingsAccount(Integer savingsID, String activationDate) {
|
||||
return performSavingApplicationActions(createSavingsOperationURL(ACTIVATE_SAVINGS_COMMAND, savingsID),
|
||||
getAccountActivationJSON(activationDate));
|
||||
}
|
||||
|
||||
public Object inactivateCharge(final Integer chargeId, final Integer savingsId, final String jsonAttributeToGetBack) {
|
||||
return performSavingActions(createChargesURL("inactivate", savingsId, chargeId), getSavingsInactivateChargeJSON(),
|
||||
jsonAttributeToGetBack);
|
||||
}
|
||||
|
||||
private String getSavingsInactivateChargeJSON() {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
String josn = new Gson().toJson(map);
|
||||
return josn;
|
||||
}
|
||||
}
|
||||
+6
-1
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common.savings;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -12,7 +17,7 @@ public class SavingsApplicationTestBuilder {
|
||||
|
||||
public String build(final String ID, final String savingsProductId, final String accountType) {
|
||||
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
if (accountType == "GROUP") {
|
||||
map.put("groupId", ID);
|
||||
|
||||
+38
-2
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common.savings;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -63,9 +68,14 @@ public class SavingsProductHelper {
|
||||
private final String currencyCode = USD;
|
||||
private final String interestCalculationDaysInYearType = DAYS_365;
|
||||
private Account[] accountList = null;
|
||||
private String minBalanceForInterestCalculation = null;
|
||||
private String allowOverdraft = "false";
|
||||
private String overdraftLimit = null;
|
||||
private String minRequiredBalance = null;
|
||||
private String enforceMinRequiredBalance = "false";
|
||||
|
||||
public String build() {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
|
||||
map.put("name", this.nameOfSavingsProduct);
|
||||
map.put("shortName", this.shortName);
|
||||
@@ -93,6 +103,11 @@ public class SavingsProductHelper {
|
||||
map.put("lockinPeriodFrequency", this.lockinPeriodFrequency);
|
||||
map.put("lockinPeriodFrequencyType", this.lockingPeriodFrequencyType);
|
||||
map.put("withdrawalFeeForTransfers", this.withdrawalFeeForTransfers);
|
||||
map.put("minBalanceForInterestCalculation", minBalanceForInterestCalculation);
|
||||
map.put("allowOverdraft", this.allowOverdraft);
|
||||
map.put("overdraftLimit", this.overdraftLimit);
|
||||
map.put("minRequiredBalance", this.minRequiredBalance);
|
||||
map.put("enforceMinRequiredBalance", this.enforceMinRequiredBalance);
|
||||
|
||||
if (this.accountingRule.equals(CASH_BASED)) {
|
||||
map.putAll(getAccountMappingForCashBased());
|
||||
@@ -126,6 +141,11 @@ public class SavingsProductHelper {
|
||||
this.interestPostingPeriodType = MONTHLY;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SavingsProductHelper withMinBalanceForInterestCalculation(final String amount) {
|
||||
this.minBalanceForInterestCalculation = amount;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SavingsProductHelper withInterestPostingPeriodTypeAsQuarterly() {
|
||||
this.interestPostingPeriodType = QUARTERLY;
|
||||
@@ -157,9 +177,25 @@ public class SavingsProductHelper {
|
||||
this.accountList = account_list;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SavingsProductHelper withMinRequiredBalance(String minBalance) {
|
||||
this.minRequiredBalance = minBalance;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SavingsProductHelper withEnforceMinRequiredBalance(String enforceMinRequiredBalance) {
|
||||
this.enforceMinRequiredBalance = enforceMinRequiredBalance;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SavingsProductHelper withOverDraft(final String overDraftLimit) {
|
||||
this.allowOverdraft = "true";
|
||||
this.overdraftLimit = overDraftLimit;
|
||||
return this;
|
||||
}
|
||||
|
||||
private Map<String, String> getAccountMappingForCashBased() {
|
||||
final Map<String, String> map = new HashMap<String, String>();
|
||||
final Map<String, String> map = new HashMap<>();
|
||||
if (accountList != null) {
|
||||
for (int i = 0; i < this.accountList.length; i++) {
|
||||
if (this.accountList[i].getAccountType().equals(Account.AccountType.ASSET)) {
|
||||
|
||||
+5
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common.savings;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
+101
-115
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common.system;
|
||||
|
||||
import static com.jayway.restassured.RestAssured.given;
|
||||
@@ -13,151 +18,132 @@ import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
public class CodeHelper {
|
||||
|
||||
public static final String CODE_ID_ATTRIBUTE_NAME = "id";
|
||||
public static final String RESPONSE_ID_ATTRIBUTE_NAME = "resourceId";
|
||||
public static final String SUBRESPONSE_ID_ATTRIBUTE_NAME = "subResourceId";
|
||||
public static final String CODE_NAME_ATTRIBUTE_NAME = "name";
|
||||
public static final String CODE_SYSTEM_DEFINED_ATTRIBUTE_NAME = "systemDefined";
|
||||
public static final String CODE_URL = "/mifosng-provider/api/v1/codes";
|
||||
public static final String CODE_ID_ATTRIBUTE_NAME = "id";
|
||||
public static final String RESPONSE_ID_ATTRIBUTE_NAME = "resourceId";
|
||||
public static final String SUBRESPONSE_ID_ATTRIBUTE_NAME = "subResourceId";
|
||||
public static final String CODE_NAME_ATTRIBUTE_NAME = "name";
|
||||
public static final String CODE_SYSTEM_DEFINED_ATTRIBUTE_NAME = "systemDefined";
|
||||
public static final String CODE_URL = "/mifosng-provider/api/v1/codes";
|
||||
|
||||
public static final String CODE_VALUE_ID_ATTRIBUTE_NAME = "id";
|
||||
public static final String CODE_VALUE_NAME_ATTRIBUTE_NAME = "name";
|
||||
public static final String CODE_VALUE_POSITION_ATTRIBUTE_NAME = "position";
|
||||
public static final String CODE_VALUE_URL = "/mifosng-provider/api/v1/codes/[codeId]/codevalues";
|
||||
public static final String CODE_VALUE_ID_ATTRIBUTE_NAME = "id";
|
||||
public static final String CODE_VALUE_NAME_ATTRIBUTE_NAME = "name";
|
||||
public static final String CODE_VALUE_DESCRIPTION_ATTRIBUTE_NAME = "description";
|
||||
public static final String CODE_VALUE_POSITION_ATTRIBUTE_NAME = "position";
|
||||
public static final String CODE_VALUE_URL = "/mifosng-provider/api/v1/codes/[codeId]/codevalues";
|
||||
|
||||
public static Object createCode(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final String codeName,
|
||||
final String jsonAttributeToGetback) {
|
||||
public static Object createCode(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String codeName, final String jsonAttributeToGetback) {
|
||||
|
||||
return Utils.performServerPost(requestSpec, responseSpec, CODE_URL
|
||||
+ "?" + Utils.TENANT_IDENTIFIER, getTestCodeAsJSON(codeName),
|
||||
jsonAttributeToGetback);
|
||||
}
|
||||
return Utils.performServerPost(requestSpec, responseSpec, CODE_URL + "?" + Utils.TENANT_IDENTIFIER, getTestCodeAsJSON(codeName),
|
||||
jsonAttributeToGetback);
|
||||
}
|
||||
|
||||
public static Object updateCode(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final Integer codeId,
|
||||
final String codeName, final String jsonAttributeToGetback) {
|
||||
public static Object updateCode(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer codeId,
|
||||
final String codeName, final String jsonAttributeToGetback) {
|
||||
|
||||
return Utils.performServerPut(requestSpec, responseSpec, CODE_URL + "/"
|
||||
+ codeId + "?" + Utils.TENANT_IDENTIFIER,
|
||||
getTestCodeAsJSON(codeName), jsonAttributeToGetback);
|
||||
}
|
||||
return Utils.performServerPut(requestSpec, responseSpec, CODE_URL + "/" + codeId + "?" + Utils.TENANT_IDENTIFIER,
|
||||
getTestCodeAsJSON(codeName), jsonAttributeToGetback);
|
||||
}
|
||||
|
||||
public static Object getCodeById(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final Integer codeId,
|
||||
final String jsonAttributeToGetback) {
|
||||
public static Object getCodeById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer codeId, final String jsonAttributeToGetback) {
|
||||
|
||||
return Utils.performServerGet(requestSpec, responseSpec, CODE_URL + "/"
|
||||
+ codeId + "?" + Utils.TENANT_IDENTIFIER,
|
||||
jsonAttributeToGetback);
|
||||
return Utils.performServerGet(requestSpec, responseSpec, CODE_URL + "/" + codeId + "?" + Utils.TENANT_IDENTIFIER,
|
||||
jsonAttributeToGetback);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static Object getAllCodes(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec) {
|
||||
public static Object getAllCodes(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
|
||||
return Utils.performServerGet(requestSpec, responseSpec, CODE_URL + "?"
|
||||
+ Utils.TENANT_IDENTIFIER, "");
|
||||
return Utils.performServerGet(requestSpec, responseSpec, CODE_URL + "?" + Utils.TENANT_IDENTIFIER, "");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static Object getSystemDefinedCodes(
|
||||
final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec) {
|
||||
public static Object getSystemDefinedCodes(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
|
||||
final String getResponse = given().spec(requestSpec).expect()
|
||||
.spec(responseSpec).when()
|
||||
.get(CodeHelper.CODE_URL + "?" + Utils.TENANT_IDENTIFIER)
|
||||
.asString();
|
||||
final String getResponse = given().spec(requestSpec).expect().spec(responseSpec).when()
|
||||
.get(CodeHelper.CODE_URL + "?" + Utils.TENANT_IDENTIFIER).asString();
|
||||
|
||||
final JsonPath getResponseJsonPath = new JsonPath(getResponse);
|
||||
final JsonPath getResponseJsonPath = new JsonPath(getResponse);
|
||||
|
||||
// get any systemDefined code
|
||||
return getResponseJsonPath.get("find { e -> e.systemDefined == true }");
|
||||
// get any systemDefined code
|
||||
return getResponseJsonPath.get("find { e -> e.systemDefined == true }");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static String getTestCodeAsJSON(final String codeName) {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
map.put(CODE_NAME_ATTRIBUTE_NAME, codeName);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
public static String getTestCodeAsJSON(final String codeName) {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put(CODE_NAME_ATTRIBUTE_NAME, codeName);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
public static String getTestCodeValueAsJSON(final String codeValueName,
|
||||
final Integer position) {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
map.put(CODE_VALUE_NAME_ATTRIBUTE_NAME, codeValueName);
|
||||
map.put(CODE_VALUE_POSITION_ATTRIBUTE_NAME, position);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
public static String getTestCodeValueAsJSON(final String codeValueName, final String description, final Integer position) {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put(CODE_VALUE_NAME_ATTRIBUTE_NAME, codeValueName);
|
||||
if (description != null) {
|
||||
map.put(CODE_VALUE_DESCRIPTION_ATTRIBUTE_NAME, description);
|
||||
}
|
||||
map.put(CODE_VALUE_POSITION_ATTRIBUTE_NAME, position);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
public static Object deleteCodeById(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final Integer codeId,
|
||||
final String jsonAttributeToGetback) {
|
||||
public static Object deleteCodeById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer codeId, final String jsonAttributeToGetback) {
|
||||
|
||||
return Utils.performServerDelete(requestSpec, responseSpec, CODE_URL
|
||||
+ "/" + codeId + "?" + Utils.TENANT_IDENTIFIER,
|
||||
jsonAttributeToGetback);
|
||||
return Utils.performServerDelete(requestSpec, responseSpec, CODE_URL + "/" + codeId + "?" + Utils.TENANT_IDENTIFIER,
|
||||
jsonAttributeToGetback);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static Object createCodeValue(
|
||||
final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final Integer codeId,
|
||||
final String codeValueName, final Integer position,
|
||||
final String jsonAttributeToGetback) {
|
||||
public static Object createCodeValue(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer codeId, final String codeValueName, final Integer position, final String jsonAttributeToGetback) {
|
||||
String description = null;
|
||||
return createCodeValue(requestSpec, responseSpec, codeId, codeValueName, description, position, jsonAttributeToGetback);
|
||||
}
|
||||
|
||||
return Utils.performServerPost(requestSpec, responseSpec,
|
||||
CODE_VALUE_URL.replace("[codeId]", codeId.toString()) + "?"
|
||||
+ Utils.TENANT_IDENTIFIER,
|
||||
getTestCodeValueAsJSON(codeValueName, position),
|
||||
jsonAttributeToGetback);
|
||||
}
|
||||
public static Object createCodeValue(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer codeId, final String codeValueName, final String description, final Integer position,
|
||||
final String jsonAttributeToGetback) {
|
||||
|
||||
public static Object getCodeValuesForCode(
|
||||
final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final Integer codeId,
|
||||
final String jsonAttributeToGetback) {
|
||||
return Utils.performServerPost(requestSpec, responseSpec, CODE_VALUE_URL.replace("[codeId]", codeId.toString()) + "?"
|
||||
+ Utils.TENANT_IDENTIFIER, getTestCodeValueAsJSON(codeValueName, description, position), jsonAttributeToGetback);
|
||||
}
|
||||
|
||||
return Utils.performServerGet(requestSpec, responseSpec,
|
||||
CODE_VALUE_URL.replace("[codeId]", codeId.toString()) + "?"
|
||||
+ Utils.TENANT_IDENTIFIER, jsonAttributeToGetback);
|
||||
}
|
||||
public static Object getCodeValuesForCode(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer codeId, final String jsonAttributeToGetback) {
|
||||
|
||||
public static Object getCodeValueById(
|
||||
final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final Integer codeId,
|
||||
final Integer codeValueId, final String jsonAttributeToGetback) {
|
||||
return Utils.performServerGet(requestSpec, responseSpec, CODE_VALUE_URL.replace("[codeId]", codeId.toString()) + "?"
|
||||
+ Utils.TENANT_IDENTIFIER, jsonAttributeToGetback);
|
||||
}
|
||||
|
||||
|
||||
return Utils.performServerGet(requestSpec, responseSpec,
|
||||
CODE_VALUE_URL.replace("[codeId]", codeId.toString()) + "/"
|
||||
+ codeValueId.toString() + "?"
|
||||
+ Utils.TENANT_IDENTIFIER, jsonAttributeToGetback);
|
||||
}
|
||||
public static Object getCodeValueById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer codeId, final Integer codeValueId, final String jsonAttributeToGetback) {
|
||||
|
||||
public static Object deleteCodeValueById(
|
||||
final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final Integer codeId,
|
||||
final Integer codeValueId, final String jsonAttributeToGetback) {
|
||||
return Utils.performServerGet(requestSpec, responseSpec,
|
||||
CODE_VALUE_URL.replace("[codeId]", codeId.toString()) + "/" + codeValueId.toString() + "?" + Utils.TENANT_IDENTIFIER,
|
||||
jsonAttributeToGetback);
|
||||
}
|
||||
|
||||
return Utils.performServerDelete(requestSpec, responseSpec,
|
||||
CODE_VALUE_URL.replace("[codeId]", codeId.toString()) + "/"
|
||||
+ codeValueId.toString() + "?"
|
||||
+ Utils.TENANT_IDENTIFIER, jsonAttributeToGetback);
|
||||
}
|
||||
public static Object deleteCodeValueById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer codeId, final Integer codeValueId, final String jsonAttributeToGetback) {
|
||||
|
||||
public static Object updateCodeValue(
|
||||
final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final Integer codeId,
|
||||
final Integer codeValueId, final String codeValueName,
|
||||
final Integer position, final String jsonAttributeToGetback) {
|
||||
return Utils.performServerDelete(requestSpec, responseSpec, CODE_VALUE_URL.replace("[codeId]", codeId.toString()) + "/"
|
||||
+ codeValueId.toString() + "?" + Utils.TENANT_IDENTIFIER, jsonAttributeToGetback);
|
||||
}
|
||||
|
||||
return Utils.performServerPut(requestSpec, responseSpec,
|
||||
CODE_VALUE_URL.replace("[codeId]", codeId.toString()) + "/"
|
||||
+ codeValueId + "?" + Utils.TENANT_IDENTIFIER,
|
||||
getTestCodeValueAsJSON(codeValueName, position),
|
||||
jsonAttributeToGetback);
|
||||
}
|
||||
public static Object updateCodeValue(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer codeId, final Integer codeValueId, final String codeValueName, final Integer position,
|
||||
final String jsonAttributeToGetback) {
|
||||
String description = null;
|
||||
return updateCodeValue(requestSpec, responseSpec, codeId, codeValueId, codeValueName, description, position, jsonAttributeToGetback);
|
||||
}
|
||||
|
||||
public static Object updateCodeValue(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer codeId, final Integer codeValueId, final String codeValueName, final String description, final Integer position,
|
||||
final String jsonAttributeToGetback) {
|
||||
|
||||
return Utils.performServerPut(requestSpec, responseSpec, CODE_VALUE_URL.replace("[codeId]", codeId.toString()) + "/" + codeValueId
|
||||
+ "?" + Utils.TENANT_IDENTIFIER, getTestCodeValueAsJSON(codeValueName, description, position), jsonAttributeToGetback);
|
||||
}
|
||||
|
||||
}
|
||||
+7
-2
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common.xbrl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -14,8 +19,8 @@ public class XBRLIntegrationTestHelper {
|
||||
private final RequestSpecification requestSpec;
|
||||
private final ResponseSpecification responseSpec;
|
||||
|
||||
private static final String GET_TAXONOMY_LIST_URL = "/mifosng-provider/api/v1/mixtaxonomy?tenantIdentifier=default";
|
||||
private static final String TAXONOMY_MAPPING_URL = "/mifosng-provider/api/v1/mixmapping?tenantIdentifier=default";
|
||||
private static final String GET_TAXONOMY_LIST_URL = "/mifosng-provider/api/v1/mixtaxonomy?" + Utils.TENANT_IDENTIFIER;
|
||||
private static final String TAXONOMY_MAPPING_URL = "/mifosng-provider/api/v1/mixmapping?" + Utils.TENANT_IDENTIFIER;
|
||||
|
||||
public XBRLIntegrationTestHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
this.requestSpec = requestSpec;
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.boot.AbstractApplicationConfiguration;
|
||||
import org.mifosplatform.infrastructure.core.boot.ApplicationExitUtil;
|
||||
import org.mifosplatform.infrastructure.core.boot.EmbeddedTomcatWithSSLConfiguration;
|
||||
import org.mifosplatform.infrastructure.core.boot.db.DataSourceConfiguration;
|
||||
import org.mifosplatform.infrastructure.core.boot.db.DataSourceProperties;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
/**
|
||||
* Mifos main() application which launches Mifos X in an embedded Tomcat HTTP
|
||||
* (using Spring Boot).
|
||||
*
|
||||
* The DataSource used is a to a "normal" external database (not use MariaDB4j).
|
||||
* This DataSource can be configured with parameters, see {@link DataSourceProperties}.
|
||||
*
|
||||
* You can easily launch this via Debug as Java Application in your IDE -
|
||||
* without needing command line Gradle stuff, no need to build and deploy a WAR,
|
||||
* remote attachment etc.
|
||||
*
|
||||
* It's the old/classic Mifos (non-X) Workspace 2.0 reborn for Mifos X! ;-)
|
||||
*
|
||||
* @see DataSourceProperties about how to configure the DataSource used
|
||||
* @see ServerWithMariaDB4jApplication for an alternative with an embedded DB
|
||||
*/
|
||||
public class ServerApplication {
|
||||
|
||||
@Import({ DataSourceConfiguration.class, EmbeddedTomcatWithSSLConfiguration.class })
|
||||
private static class Configuration extends AbstractApplicationConfiguration { }
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
ConfigurableApplicationContext ctx = SpringApplication.run(Configuration.class, args);
|
||||
ApplicationExitUtil.waitForKeyPressToCleanlyExit(ctx);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.boot.AbstractApplicationConfiguration;
|
||||
import org.mifosplatform.infrastructure.core.boot.ApplicationExitUtil;
|
||||
import org.mifosplatform.infrastructure.core.boot.EmbeddedTomcatWithSSLConfiguration;
|
||||
import org.mifosplatform.infrastructure.core.boot.db.MariaDB4jDataSourceConfiguration;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
/**
|
||||
* Mifos main() application which launches Mifos X in an embedded Tomcat HTTP
|
||||
* server (using Spring Boot), as well as an embedded database (using
|
||||
* MariaDB4j).
|
||||
*
|
||||
* You can easily launch this via Debug as Java Application in your IDE -
|
||||
* without needing command line Gradle stuff, no need to build and deploy a WAR,
|
||||
* remote attachment etc.
|
||||
*
|
||||
* It's the old/classic Mifos (non-X) Workspace 2.0 reborn for Mifos X! ;-)
|
||||
*
|
||||
* @see ServerApplication for the same without the embedded MariaDB4j database
|
||||
*/
|
||||
public class ServerWithMariaDB4jApplication {
|
||||
|
||||
@Import({ MariaDB4jDataSourceConfiguration.class, EmbeddedTomcatWithSSLConfiguration.class })
|
||||
public static class Configuration extends AbstractApplicationConfiguration { }
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
ConfigurableApplicationContext ctx = SpringApplication.run(Configuration.class, args);
|
||||
ApplicationExitUtil.waitForKeyPressToCleanlyExit(ctx);
|
||||
}
|
||||
|
||||
}
|
||||
-47
@@ -1,47 +0,0 @@
|
||||
package org.mifosplatform.accounting.accountmapping.data;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.mifosplatform.accounting.glaccount.data.GLAccountData;
|
||||
import org.mifosplatform.organisation.office.data.OfficeData;
|
||||
|
||||
public class OfficeToGLAccountMappingData {
|
||||
|
||||
private final Long id;
|
||||
private final OfficeData officeData;
|
||||
private final GLAccountData glAccountData;
|
||||
private final Map<String, List<GLAccountData>> accountingMappingOptions;
|
||||
private final Collection<OfficeData> officeOptions;
|
||||
|
||||
public static OfficeToGLAccountMappingData instance(final Long id, final OfficeData officeData, final GLAccountData glAccountData) {
|
||||
final Map<String, List<GLAccountData>> accountingMappingOptions = null;
|
||||
final Collection<OfficeData> officeOptions = null;
|
||||
return new OfficeToGLAccountMappingData(id, officeData, glAccountData, accountingMappingOptions, officeOptions);
|
||||
}
|
||||
|
||||
public static OfficeToGLAccountMappingData template(final Map<String, List<GLAccountData>> accountingMappingOptions,
|
||||
final Collection<OfficeData> officeOptions) {
|
||||
final Long id = null;
|
||||
final OfficeData officeData = null;
|
||||
final GLAccountData glAccountData = null;
|
||||
return new OfficeToGLAccountMappingData(id, officeData, glAccountData, accountingMappingOptions, officeOptions);
|
||||
}
|
||||
|
||||
public static OfficeToGLAccountMappingData associateTemplateData(final OfficeToGLAccountMappingData templateData,
|
||||
final OfficeToGLAccountMappingData accountMappingData) {
|
||||
return new OfficeToGLAccountMappingData(accountMappingData.id, accountMappingData.officeData, accountMappingData.glAccountData,
|
||||
templateData.accountingMappingOptions, templateData.officeOptions);
|
||||
}
|
||||
|
||||
private OfficeToGLAccountMappingData(final Long id, final OfficeData officeData, final GLAccountData glAccountData,
|
||||
final Map<String, List<GLAccountData>> accountingMappingOptions, final Collection<OfficeData> officeOptions) {
|
||||
this.id = id;
|
||||
this.officeData = officeData;
|
||||
this.glAccountData = glAccountData;
|
||||
this.accountingMappingOptions = accountingMappingOptions;
|
||||
this.officeOptions = officeOptions;
|
||||
}
|
||||
|
||||
}
|
||||
-69
@@ -1,69 +0,0 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.accounting.accountmapping.domain;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.mifosplatform.accounting.glaccount.domain.GLAccount;
|
||||
import org.mifosplatform.organisation.office.domain.Office;
|
||||
import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||
|
||||
@Entity
|
||||
@Table(name = "acc_gl_office_mapping")
|
||||
public class OfficeToGLAccountMapping extends AbstractPersistable<Long> {
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "gl_account_id")
|
||||
private GLAccount glAccount;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "office_id")
|
||||
private Office office;
|
||||
|
||||
@Column(name = "financial_account_type", nullable = false)
|
||||
private int financialAccountType;
|
||||
|
||||
public static OfficeToGLAccountMapping createNew(final GLAccount glAccount, final Office office, final int financialAccountType) {
|
||||
return new OfficeToGLAccountMapping(glAccount, office, financialAccountType);
|
||||
}
|
||||
|
||||
protected OfficeToGLAccountMapping() {
|
||||
//
|
||||
}
|
||||
|
||||
private OfficeToGLAccountMapping(final GLAccount glAccount, final Office office, final int financialAccountType) {
|
||||
this.glAccount = glAccount;
|
||||
this.office = office;
|
||||
this.financialAccountType = financialAccountType;
|
||||
}
|
||||
|
||||
public GLAccount glAccount() {
|
||||
return this.glAccount;
|
||||
}
|
||||
|
||||
public void updateGlAccount(final GLAccount glAccount) {
|
||||
this.glAccount = glAccount;
|
||||
}
|
||||
|
||||
public Office office() {
|
||||
return this.office;
|
||||
}
|
||||
|
||||
public void updateOffice(Office office) {
|
||||
this.office = office;
|
||||
}
|
||||
|
||||
public int getFinancialAccountType() {
|
||||
return this.financialAccountType;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.accounting.accountmapping.domain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
public interface OfficeToGLAccountMappingRepository extends JpaRepository<OfficeToGLAccountMapping, Long>,
|
||||
JpaSpecificationExecutor<OfficeToGLAccountMapping> {
|
||||
|
||||
@Query("from OfficeToGLAccountMapping otga where otga.office.id = :officeId and otga.financialAccountType = :financialAccountType")
|
||||
OfficeToGLAccountMapping findByOfficeAndFinancialAccountType(@Param("officeId")Long officeId,@Param("financialAccountType") int financialAccountType);
|
||||
|
||||
@Query("from OfficeToGLAccountMapping otga where otga.office.id =:officeId")
|
||||
List<OfficeToGLAccountMapping> findByOffice(@Param("officeId")Long officeId);
|
||||
}
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.accounting.accountmapping.domain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.mifosplatform.accounting.accountmapping.exception.OfficeToGLAccountMappingNotFoundException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Wrapper for {@link OfficeToGLAccountMappingRepository} that adds NULL
|
||||
* checking and Error handling capabilities
|
||||
* </p>
|
||||
*/
|
||||
@Service
|
||||
public class OfficeToGLAccountMappingRepositoryWrapper {
|
||||
|
||||
private final OfficeToGLAccountMappingRepository repository;
|
||||
|
||||
@Autowired
|
||||
public OfficeToGLAccountMappingRepositoryWrapper(final OfficeToGLAccountMappingRepository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public OfficeToGLAccountMapping findOneWithNotFoundDetection(final Long id) {
|
||||
final OfficeToGLAccountMapping officeToGLAccountMapping = this.repository.findOne(id);
|
||||
if (officeToGLAccountMapping == null) { throw new OfficeToGLAccountMappingNotFoundException(id); }
|
||||
return officeToGLAccountMapping;
|
||||
}
|
||||
|
||||
public OfficeToGLAccountMapping findByOfficeAndFinancialAccountType(final Long officeId, final int financialAccountType) {
|
||||
return this.repository.findByOfficeAndFinancialAccountType(officeId, financialAccountType);
|
||||
}
|
||||
|
||||
public List<OfficeToGLAccountMapping> findByOffice(final Long officeId) {
|
||||
return this.repository.findByOffice(officeId);
|
||||
}
|
||||
|
||||
public void save(final OfficeToGLAccountMapping entity) {
|
||||
this.repository.save(entity);
|
||||
}
|
||||
|
||||
public void saveAndFlush(final OfficeToGLAccountMapping entity) {
|
||||
this.repository.saveAndFlush(entity);
|
||||
}
|
||||
|
||||
public void delete(final OfficeToGLAccountMapping entity) {
|
||||
this.repository.delete(entity);
|
||||
}
|
||||
}
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.accounting.accountmapping.exception;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException;
|
||||
|
||||
/**
|
||||
* A {@link RuntimeException} thrown when product to GL account mapping are not
|
||||
* found.
|
||||
*/
|
||||
public class DuplicateOfficeToGLAccountMappingFoundException extends AbstractPlatformDomainRuleException {
|
||||
|
||||
public DuplicateOfficeToGLAccountMappingFoundException(final Long officeId, final Integer accountType) {
|
||||
super("error.msg.officeToAccountMapping.exists.for.office", "Mapping for office with Id " + officeId
|
||||
+ " exist for an account of type " + accountType, officeId, accountType);
|
||||
}
|
||||
|
||||
}
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.accounting.accountmapping.exception;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException;
|
||||
|
||||
/**
|
||||
* A {@link RuntimeException} thrown when Calendar resources are not found.
|
||||
*/
|
||||
public class MappingUpdateNotSupportedException extends AbstractPlatformDomainRuleException {
|
||||
|
||||
public MappingUpdateNotSupportedException(final String postFix, final String defaultUserMessage,
|
||||
final Object... defaultUserMessageArgs) {
|
||||
super("error.msg.officeToAccountMapping.update.of." + postFix + ".is.not.supported", defaultUserMessage, defaultUserMessageArgs);
|
||||
}
|
||||
}
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.accounting.accountmapping.exception;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
|
||||
|
||||
/**
|
||||
* A {@link RuntimeException} thrown when product to GL account mapping are not
|
||||
* found.
|
||||
*/
|
||||
public class OfficeToGLAccountMappingNotFoundException extends AbstractPlatformResourceNotFoundException {
|
||||
|
||||
public OfficeToGLAccountMappingNotFoundException(final Long officeId, final String accountType) {
|
||||
super("error.msg.officeToAccountMapping.not.found", "Mapping for office with Id " + officeId
|
||||
+ " does not exist for an account of type " + accountType, officeId, accountType);
|
||||
}
|
||||
|
||||
public OfficeToGLAccountMappingNotFoundException(final Long id) {
|
||||
super("error.msg.officeToAccountMapping.not.found", "Mapping for GL Account with Id " + id + " does not exist", id);
|
||||
}
|
||||
}
|
||||
-98
@@ -1,98 +0,0 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.accounting.accountmapping.serialization;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosplatform.accounting.common.AccountingConstants.ORGANIZATION_ACCOUNTING_PARAMS;
|
||||
import org.mifosplatform.infrastructure.core.data.ApiParameterError;
|
||||
import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder;
|
||||
import org.mifosplatform.infrastructure.core.exception.InvalidJsonException;
|
||||
import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException;
|
||||
import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
@Component
|
||||
public final class OfficeToGLAccountMappingDataValidator {
|
||||
|
||||
/**
|
||||
* The parameters supported for this command.
|
||||
*/
|
||||
private final Set<String> supportedParameters = new HashSet<String>(Arrays.asList("locale",
|
||||
ORGANIZATION_ACCOUNTING_PARAMS.LIABILITY_TRANSFER_SUSPENSE.getValue(), "officeId"));
|
||||
|
||||
private final FromJsonHelper fromApiJsonHelper;
|
||||
|
||||
@Autowired
|
||||
public OfficeToGLAccountMappingDataValidator(final FromJsonHelper fromApiJsonHelper) {
|
||||
this.fromApiJsonHelper = fromApiJsonHelper;
|
||||
}
|
||||
|
||||
public void validateForCreate(final String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParameters);
|
||||
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("loanproduct");
|
||||
|
||||
final JsonElement element = this.fromApiJsonHelper.parse(json);
|
||||
|
||||
final Long liabilityTransferInSuspenseAccountId = this.fromApiJsonHelper.extractLongNamed(
|
||||
ORGANIZATION_ACCOUNTING_PARAMS.LIABILITY_TRANSFER_SUSPENSE.getValue(), element);
|
||||
baseDataValidator.reset().parameter(ORGANIZATION_ACCOUNTING_PARAMS.LIABILITY_TRANSFER_SUSPENSE.getValue())
|
||||
.value(liabilityTransferInSuspenseAccountId).notNull().integerGreaterThanZero();
|
||||
|
||||
final Long officeID = this.fromApiJsonHelper.extractLongNamed("officeId", element);
|
||||
baseDataValidator.reset().parameter("officeId").value(officeID).notNull().integerGreaterThanZero();
|
||||
|
||||
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
||||
}
|
||||
|
||||
public void validateForUpdate(final String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParameters);
|
||||
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("loanproduct");
|
||||
|
||||
final JsonElement element = this.fromApiJsonHelper.parse(json);
|
||||
|
||||
if (this.fromApiJsonHelper.parameterExists(ORGANIZATION_ACCOUNTING_PARAMS.LIABILITY_TRANSFER_SUSPENSE.getValue(), element)) {
|
||||
final Long liabilityTransferInSuspenseAccountId = this.fromApiJsonHelper.extractLongNamed(
|
||||
ORGANIZATION_ACCOUNTING_PARAMS.LIABILITY_TRANSFER_SUSPENSE.getValue(), element);
|
||||
baseDataValidator.reset().parameter(ORGANIZATION_ACCOUNTING_PARAMS.LIABILITY_TRANSFER_SUSPENSE.getValue())
|
||||
.value(liabilityTransferInSuspenseAccountId).notNull().integerGreaterThanZero();
|
||||
}
|
||||
|
||||
if (this.fromApiJsonHelper.parameterExists("officeId", element)) {
|
||||
final Long officeID = this.fromApiJsonHelper.extractLongNamed("officeId", element);
|
||||
baseDataValidator.reset().parameter("officeId").value(officeID).notNull().integerGreaterThanZero();
|
||||
}
|
||||
|
||||
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
||||
}
|
||||
|
||||
private void throwExceptionIfValidationWarningsExist(final List<ApiParameterError> dataValidationErrors) {
|
||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist",
|
||||
"Validation errors exist.", dataValidationErrors); }
|
||||
}
|
||||
|
||||
}
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.accounting.accountmapping.service;
|
||||
|
||||
|
||||
import org.mifosplatform.accounting.accountmapping.data.OfficeToGLAccountMappingData;
|
||||
import org.mifosplatform.infrastructure.core.service.Page;
|
||||
import org.mifosplatform.portfolio.group.service.SearchParameters;
|
||||
|
||||
public interface OfficeToGLAccountMappingReadPlatformService {
|
||||
|
||||
Page<OfficeToGLAccountMappingData> retrieveAll(final SearchParameters searchParameters);
|
||||
|
||||
OfficeToGLAccountMappingData retrieve(Long mappingId);
|
||||
|
||||
OfficeToGLAccountMappingData retrieveTemplate();
|
||||
|
||||
}
|
||||
-136
@@ -1,136 +0,0 @@
|
||||
package org.mifosplatform.accounting.accountmapping.service;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosplatform.accounting.accountmapping.data.OfficeToGLAccountMappingData;
|
||||
import org.mifosplatform.accounting.accountmapping.exception.OfficeToGLAccountMappingNotFoundException;
|
||||
import org.mifosplatform.accounting.common.AccountingDropdownReadPlatformService;
|
||||
import org.mifosplatform.accounting.glaccount.data.GLAccountData;
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.Page;
|
||||
import org.mifosplatform.infrastructure.core.service.PaginationHelper;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.organisation.office.data.OfficeData;
|
||||
import org.mifosplatform.organisation.office.service.OfficeReadPlatformService;
|
||||
import org.mifosplatform.portfolio.group.service.SearchParameters;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class OfficeToGLAccountMappingReadPlatformServiceImpl implements OfficeToGLAccountMappingReadPlatformService {
|
||||
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
private final OfficeToGLAccountMappingMapper accountMappingMapper;
|
||||
private final PaginationHelper<OfficeToGLAccountMappingData> paginationHelper = new PaginationHelper<OfficeToGLAccountMappingData>();
|
||||
private final OfficeReadPlatformService officeReadPlatformService;
|
||||
private final AccountingDropdownReadPlatformService accountingDropdownReadPlatformService;
|
||||
|
||||
@Autowired
|
||||
public OfficeToGLAccountMappingReadPlatformServiceImpl(final RoutingDataSource dataSource,
|
||||
final OfficeReadPlatformService officeReadPlatformService,
|
||||
final AccountingDropdownReadPlatformService accountingDropdownReadPlatformService) {
|
||||
accountMappingMapper = new OfficeToGLAccountMappingMapper();
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
this.officeReadPlatformService = officeReadPlatformService;
|
||||
this.accountingDropdownReadPlatformService = accountingDropdownReadPlatformService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<OfficeToGLAccountMappingData> retrieveAll(final SearchParameters searchParameters) {
|
||||
StringBuilder sqlBuilder = new StringBuilder(300);
|
||||
sqlBuilder.append("select SQL_CALC_FOUND_ROWS ");
|
||||
sqlBuilder.append(this.accountMappingMapper.schema());
|
||||
Object[] finalObjectArray = {};
|
||||
if (searchParameters.isOrderByRequested()) {
|
||||
sqlBuilder.append(" order by ").append(searchParameters.getOrderBy());
|
||||
|
||||
if (searchParameters.isSortOrderProvided()) {
|
||||
sqlBuilder.append(' ').append(searchParameters.getSortOrder());
|
||||
}
|
||||
}
|
||||
|
||||
if (searchParameters.isLimited()) {
|
||||
sqlBuilder.append(" limit ").append(searchParameters.getLimit());
|
||||
if (searchParameters.isOffset()) {
|
||||
sqlBuilder.append(" offset ").append(searchParameters.getOffset());
|
||||
}
|
||||
}
|
||||
final String sqlCountRows = "SELECT FOUND_ROWS()";
|
||||
return this.paginationHelper.fetchPage(this.jdbcTemplate, sqlCountRows, sqlBuilder.toString(), finalObjectArray,
|
||||
this.accountMappingMapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OfficeToGLAccountMappingData retrieve(Long mappingId) {
|
||||
try {
|
||||
StringBuilder sqlBuilder = new StringBuilder(200);
|
||||
sqlBuilder.append("select ");
|
||||
sqlBuilder.append(this.accountMappingMapper.schema());
|
||||
sqlBuilder.append(" where om.id=?");
|
||||
return this.jdbcTemplate.queryForObject(sqlBuilder.toString(), this.accountMappingMapper, new Object[] { mappingId });
|
||||
} catch (final EmptyResultDataAccessException e) {
|
||||
throw new OfficeToGLAccountMappingNotFoundException(mappingId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public OfficeToGLAccountMappingData retrieveTemplate() {
|
||||
Collection<OfficeData> officeOptions = this.officeReadPlatformService.retrieveAllOfficesForDropdown();
|
||||
final Map<String, List<GLAccountData>> accountOptions = this.accountingDropdownReadPlatformService.retrieveAccountMappingOptions();
|
||||
return OfficeToGLAccountMappingData.template(accountOptions, officeOptions);
|
||||
}
|
||||
|
||||
private static final class OfficeToGLAccountMappingMapper implements RowMapper<OfficeToGLAccountMappingData> {
|
||||
|
||||
private final String sql;
|
||||
|
||||
public OfficeToGLAccountMappingMapper() {
|
||||
StringBuilder sb = new StringBuilder(300);
|
||||
sb.append("om.id , office.id as officeId, office.name as officeName, ");
|
||||
sb.append(" glaccount.id as glAccountId,glaccount.name as glAccountName,glaccount.gl_code as glCode ");
|
||||
sb.append(" from acc_gl_office_mapping om ");
|
||||
sb.append("inner join m_office office on office.id = om.office_id ");
|
||||
sb.append("inner join acc_gl_account glaccount on glaccount.id = om.gl_account_id");
|
||||
sql = sb.toString();
|
||||
}
|
||||
|
||||
public String schema() {
|
||||
return sql;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OfficeToGLAccountMappingData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
||||
final Long id = JdbcSupport.getLong(rs, "id");
|
||||
final Long officeId = JdbcSupport.getLong(rs, "officeId");
|
||||
final String officeName = rs.getString("officeName");
|
||||
final String nameDecorated = null;
|
||||
final String externalId = null;
|
||||
final LocalDate openingDate = null;
|
||||
final String hierarchy = null;
|
||||
final Long parentId = null;
|
||||
final String parentName = null;
|
||||
final Collection<OfficeData> allowedParents = null;
|
||||
final OfficeData officeData = new OfficeData(officeId, officeName, nameDecorated, externalId, openingDate, hierarchy, parentId,
|
||||
parentName, allowedParents);
|
||||
|
||||
final Long glAccountId = JdbcSupport.getLong(rs, "glAccountId");
|
||||
final String glAccountName = rs.getString("glAccountName");
|
||||
final String glCode = rs.getString("glCode");
|
||||
|
||||
final GLAccountData gLAccountData = new GLAccountData(glAccountId, glAccountName, glCode);
|
||||
|
||||
final OfficeToGLAccountMappingData accountMappingData = OfficeToGLAccountMappingData.instance(id, officeData, gLAccountData);
|
||||
return accountMappingData;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user