Compare commits
500
Commits
9f78554972
...
9cf159e77c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9cf159e77c | ||
|
|
2587c65b26 | ||
|
|
2273c8ba65 | ||
|
|
4842f3d80b | ||
|
|
f7c0a833cb | ||
|
|
cef018a990 | ||
|
|
da514b8856 | ||
|
|
69f9538905 | ||
|
|
340aa20120 | ||
|
|
b6626b0b83 | ||
|
|
d0fd3e4a6c | ||
|
|
89aab6b93d | ||
|
|
5a9f0f9941 | ||
|
|
fdf31abd22 | ||
|
|
7347012bfa | ||
|
|
34e85b2c89 | ||
|
|
aa214aea92 | ||
|
|
7ccb57eab9 | ||
|
|
8902d2a5cb | ||
|
|
b4b7555bc1 | ||
|
|
68bb26bd58 | ||
|
|
e2ddedd531 | ||
|
|
5536342093 | ||
|
|
f8fa861909 | ||
|
|
fda49b0794 | ||
|
|
222b943bfd | ||
|
|
e751e1f682 | ||
|
|
fce8f73b83 | ||
|
|
95c43200d6 | ||
|
|
dc672153ac | ||
|
|
72495da5b9 | ||
|
|
e4f260bd69 | ||
|
|
fb8eb4a977 | ||
|
|
da59a50299 | ||
|
|
d05f8d8092 | ||
|
|
9947563078 | ||
|
|
e201f37191 | ||
|
|
28d359653e | ||
|
|
9aae2aad3d | ||
|
|
3757e2b689 | ||
|
|
befd953fcf | ||
|
|
16d92b83c4 | ||
|
|
3f9e411670 | ||
|
|
7e093be216 | ||
|
|
39c13268f5 | ||
|
|
a3dcf36e6b | ||
|
|
3698b4fc98 | ||
|
|
a43a117eef | ||
|
|
45688cf408 | ||
|
|
f5b86e52b6 | ||
|
|
6b643eb1a0 | ||
|
|
9aacbb3178 | ||
|
|
1e00782c91 | ||
|
|
19b624eb86 | ||
|
|
ae6877d4a0 | ||
|
|
4d0fc18629 | ||
|
|
f8992fe0f3 | ||
|
|
cc58715575 | ||
|
|
bdfb61eaa9 | ||
|
|
9ed5631033 | ||
|
|
cef55bdde7 | ||
|
|
ee9ed47163 | ||
|
|
5a4dbe3239 | ||
|
|
55ec6df157 | ||
|
|
f2c1b930a8 | ||
|
|
95f8bb8bca | ||
|
|
5d73f2bd1d | ||
|
|
e088d50f5d | ||
|
|
e93072fca1 | ||
|
|
b3735c6270 | ||
|
|
dbd1889bf1 | ||
|
|
be9cb891c9 | ||
|
|
1947031aca | ||
|
|
7d3307a0eb | ||
|
|
52b5efdf89 | ||
|
|
74858671db | ||
|
|
4060ab33a4 | ||
|
|
7ab9f6450f | ||
|
|
6a11ec28b1 | ||
|
|
e834b9c920 | ||
|
|
7926440f37 | ||
|
|
944dc53b26 | ||
|
|
a3ebe54e30 | ||
|
|
09d3eb9c95 | ||
|
|
e8fa4b3cb6 | ||
|
|
2f617529d5 | ||
|
|
542c81cbba | ||
|
|
614df03820 | ||
|
|
eb2d539937 | ||
|
|
1d0892d199 | ||
|
|
8311a5d1fc | ||
|
|
6ccd513236 | ||
|
|
1f3f9e0d2c | ||
|
|
af6bd39186 | ||
|
|
30b4d662ed | ||
|
|
33e72e542d | ||
|
|
66876c0859 | ||
|
|
9402ab5529 | ||
|
|
72d82e3267 | ||
|
|
a59ebad2bf | ||
|
|
9c74145e0a | ||
|
|
8710b7986e | ||
|
|
ae86a229fc | ||
|
|
a6eb16d4a8 | ||
|
|
e89772db78 | ||
|
|
5d713be0d6 | ||
|
|
67eb567b84 | ||
|
|
55e3661a6f | ||
|
|
3c48331480 | ||
|
|
d7e301c5d4 | ||
|
|
acf3c74f37 | ||
|
|
298f3384cf | ||
|
|
abec451ec2 | ||
|
|
75f774e7ee | ||
|
|
26fad113d5 | ||
|
|
e692e1b58b | ||
|
|
5c8691598e | ||
|
|
0061e1dd2e | ||
|
|
4b3e76afc2 | ||
|
|
e8cfdcf865 | ||
|
|
84b9d5f9f2 | ||
|
|
d7ff069e11 | ||
|
|
efa73ed009 | ||
|
|
05675782f5 | ||
|
|
12300255d2 | ||
|
|
257d18798c | ||
|
|
9c32945c2c | ||
|
|
e47cee6cd9 | ||
|
|
570870bfef | ||
|
|
a4dfa7e8c4 | ||
|
|
a1e58b7768 | ||
|
|
37934dab66 | ||
|
|
a20bd6fa7e | ||
|
|
8b71be5106 | ||
|
|
658fb7ea82 | ||
|
|
6b8bae57f9 | ||
|
|
0cf447736e | ||
|
|
0ee38cfbc8 | ||
|
|
e4d231913b | ||
|
|
f84532d88c | ||
|
|
6beac91da7 | ||
|
|
d0f7c8b686 | ||
|
|
514e17494d | ||
|
|
212e2127c5 | ||
|
|
06c57000c7 | ||
|
|
a9ad69f844 | ||
|
|
86d12b57a8 | ||
|
|
d33f762350 | ||
|
|
356ec7bb59 | ||
|
|
ff84a13c4c | ||
|
|
577f59a7a9 | ||
|
|
ebfe13f9c2 | ||
|
|
82d3d692d7 | ||
|
|
3583fabe7a | ||
|
|
5b58bf84bc | ||
|
|
db2934d905 | ||
|
|
ed754fc964 | ||
|
|
38b9ef2b43 | ||
|
|
4ae07dd47c | ||
|
|
511303d9e5 | ||
|
|
7934e54b22 | ||
|
|
8dd47769d1 | ||
|
|
3b304f8c08 | ||
|
|
158e048e87 | ||
|
|
1e7fc9d8c3 | ||
|
|
05ae42b20b | ||
|
|
7e2c33d05d | ||
|
|
d45b3a504e | ||
|
|
5f888ca2f2 | ||
|
|
6da6ec799c | ||
|
|
445f57f81d | ||
|
|
b393b24c2d | ||
|
|
006b14db0a | ||
|
|
19e568e8f9 | ||
|
|
f4ed5f80dd | ||
|
|
864b18d1a0 | ||
|
|
29de3ed745 | ||
|
|
2537b63183 | ||
|
|
18529f0ea6 | ||
|
|
f883158001 | ||
|
|
72be7a82a5 | ||
|
|
edcfce422a | ||
|
|
36aea53215 | ||
|
|
bab630a24e | ||
|
|
e11236dc2b | ||
|
|
f75d2a3b81 | ||
|
|
aa915a122b | ||
|
|
8c03f6e41e | ||
|
|
b0173fa46a | ||
|
|
ce576f10be | ||
|
|
1225a72cee | ||
|
|
f790b7e695 | ||
|
|
ee71366032 | ||
|
|
3561ff1706 | ||
|
|
69150fc7ad | ||
|
|
e6e0af7885 | ||
|
|
7a8702e165 | ||
|
|
6b67e39b72 | ||
|
|
7cf3e05fdc | ||
|
|
d665ff5a00 | ||
|
|
4b110cfe4b | ||
|
|
2b17dba8cd | ||
|
|
48bf33c930 | ||
|
|
ad8d9e792f | ||
|
|
a5a4d1670d | ||
|
|
15fe1477b7 | ||
|
|
8e7ae0ac03 | ||
|
|
e992a2b410 | ||
|
|
741d683af9 | ||
|
|
b1a429e3a2 | ||
|
|
8fc3ace96e | ||
|
|
ade5e76ad9 | ||
|
|
0ab2e727ad | ||
|
|
b6f9ec6bcb | ||
|
|
2ab024e6f7 | ||
|
|
2a1fed6fa1 | ||
|
|
312446e8ed | ||
|
|
3abee1cf40 | ||
|
|
91f21707ab | ||
|
|
52b82f32d0 | ||
|
|
2bfc83722f | ||
|
|
4224fc16cc | ||
|
|
dbb1c18dd4 | ||
|
|
fa5d388084 | ||
|
|
ae36b0ad47 | ||
|
|
3038169bb8 | ||
|
|
c3dc53a4b1 | ||
|
|
d21385792a | ||
|
|
b46e9b66c9 | ||
|
|
8416cd1ec7 | ||
|
|
377dee1984 | ||
|
|
49dc20d2a3 | ||
|
|
cf0f5440a9 | ||
|
|
ea8080f32c | ||
|
|
ecaa78f6b5 | ||
|
|
60d38fbb8f | ||
|
|
a72f1057cd | ||
|
|
30e9e3b330 | ||
|
|
edef7dbf93 | ||
|
|
cc2fdbbacc | ||
|
|
237b967537 | ||
|
|
aaaf47c763 | ||
|
|
94af5d0853 | ||
|
|
f9a33c790e | ||
|
|
3043d2ae99 | ||
|
|
064fb4845c | ||
|
|
3416a8dc8e | ||
|
|
cc010e5b37 | ||
|
|
3b71c90773 | ||
|
|
a687c49eb1 | ||
|
|
392e94f6bf | ||
|
|
1098923689 | ||
|
|
9a55b3ffa8 | ||
|
|
3cb99328eb | ||
|
|
c73e38fc8c | ||
|
|
5624da89ea | ||
|
|
0fabff864c | ||
|
|
5227b48e23 | ||
|
|
1db9345669 | ||
|
|
b8930cb831 | ||
|
|
03a5bb57ce | ||
|
|
2833318fd3 | ||
|
|
cb1510463d | ||
|
|
d91c6a0b64 | ||
|
|
c923cc2723 | ||
|
|
259a9c43c4 | ||
|
|
ef43bbc5b1 | ||
|
|
1a50bd0d47 | ||
|
|
0710ef964b | ||
|
|
a6e764279b | ||
|
|
c5e4f22826 | ||
|
|
89377a23b4 | ||
|
|
94dff21a97 | ||
|
|
c8391d119f | ||
|
|
9813e097c3 | ||
|
|
44e08dd2e6 | ||
|
|
9f92e5cb7e | ||
|
|
4c5d194766 | ||
|
|
0d1439afea | ||
|
|
48ee0c9739 | ||
|
|
ac75cc9ba6 | ||
|
|
7f95e4bf20 | ||
|
|
7fcdb77f36 | ||
|
|
968ddcd8de | ||
|
|
2a800bf367 | ||
|
|
cbe6d672e8 | ||
|
|
a38d3d565d | ||
|
|
fdd84097ea | ||
|
|
f440f294ad | ||
|
|
19021dd18b | ||
|
|
4e7f9031be | ||
|
|
eaa32e9465 | ||
|
|
221cb1c17d | ||
|
|
d00f793f99 | ||
|
|
942eca1243 | ||
|
|
d393812cfe | ||
|
|
5262bb6478 | ||
|
|
12746ebc0f | ||
|
|
a16265eb92 | ||
|
|
1b2ea2ebdd | ||
|
|
3d7ef79d3d | ||
|
|
71cd946d21 | ||
|
|
d9ce1745da | ||
|
|
95acad7cf4 | ||
|
|
ab4e97821c | ||
|
|
0c75d323eb | ||
|
|
d47070a5c2 | ||
|
|
e5ccac0ca2 | ||
|
|
72389cf933 | ||
|
|
445a98d225 | ||
|
|
05fdf84981 | ||
|
|
495126b754 | ||
|
|
6b8b247565 | ||
|
|
0adc4fae19 | ||
|
|
98e9c3d084 | ||
|
|
f179771b8d | ||
|
|
f720bd6627 | ||
|
|
f6f04d7ae3 | ||
|
|
4a2a85d20e | ||
|
|
07ac26b152 | ||
|
|
f22cac3feb | ||
|
|
7ba9a81e53 | ||
|
|
2ab84dfd22 | ||
|
|
d89152ce82 | ||
|
|
1e4b4911e0 | ||
|
|
ad3a77d70c | ||
|
|
8b2843cabd | ||
|
|
7d887a4e0a | ||
|
|
1e3bb039ee | ||
|
|
9e6ec117d3 | ||
|
|
c4a21a8f87 | ||
|
|
57d4c8f868 | ||
|
|
88edeb8ee3 | ||
|
|
13e3c0c605 | ||
|
|
ca0dcba74f | ||
|
|
0182be4cf9 | ||
|
|
b4c354b224 | ||
|
|
3f6d90e7d4 | ||
|
|
b490a42dcf | ||
|
|
371d38e1c9 | ||
|
|
f3c306ffbb | ||
|
|
1d66c3e897 | ||
|
|
b641d92e77 | ||
|
|
19e6c28b5f | ||
|
|
2ec7d2eb22 | ||
|
|
852cb45576 | ||
|
|
d9db7d5313 | ||
|
|
af43e6c58f | ||
|
|
69d1edff32 | ||
|
|
ea51f9fceb | ||
|
|
f438bc6f17 | ||
|
|
d5f0ae53f8 | ||
|
|
2bd1332da7 | ||
|
|
a7ddb1a70f | ||
|
|
bc38cf4ff9 | ||
|
|
20f292d329 | ||
|
|
bd689bc008 | ||
|
|
bdbd1a85ed | ||
|
|
19c7ef1f32 | ||
|
|
f9d4af7d2f | ||
|
|
593ba64eac | ||
|
|
deb506ece3 | ||
|
|
0c7b8c937c | ||
|
|
fe9b3437d4 | ||
|
|
e979bdf6b7 | ||
|
|
7d059acd83 | ||
|
|
0acf7c1498 | ||
|
|
653c534514 | ||
|
|
cfcc2654d4 | ||
|
|
d0bb7c7ae3 | ||
|
|
ebab8699fe | ||
|
|
8b56795821 | ||
|
|
4cd7c79225 | ||
|
|
f46875fcb7 | ||
|
|
f477a190a7 | ||
|
|
e7db6731d9 | ||
|
|
f082ac40a6 | ||
|
|
144860d48c | ||
|
|
70331f8447 | ||
|
|
4b6d794a47 | ||
|
|
d310eb308d | ||
|
|
f5aa3f88e9 | ||
|
|
253fba35c3 | ||
|
|
e4cf90562c | ||
|
|
ed8809f63c | ||
|
|
06bb09f189 | ||
|
|
bedbe7023f | ||
|
|
4ad30d91d9 | ||
|
|
dcff6fbcd3 | ||
|
|
74242ed036 | ||
|
|
37333266aa | ||
|
|
66133d7f22 | ||
|
|
6f16786aa8 | ||
|
|
56a12e3af4 | ||
|
|
8e52dd2a1e | ||
|
|
d8bcbba79c | ||
|
|
3425d762f0 | ||
|
|
8971723d96 | ||
|
|
9b3f56f6f6 | ||
|
|
a19d345d88 | ||
|
|
dc979da263 | ||
|
|
6f0d24ee98 | ||
|
|
fe0438a2ac | ||
|
|
26c8ce6cbe | ||
|
|
da79d20049 | ||
|
|
827e6bdbfb | ||
|
|
38ffaba65b | ||
|
|
b783bc5fad | ||
|
|
54a45c5e41 | ||
|
|
436bdfd538 | ||
|
|
532425626e | ||
|
|
a665beb1b7 | ||
|
|
7acc549a01 | ||
|
|
9d07e9ad7a | ||
|
|
19b2ce6def | ||
|
|
d7b6e22344 | ||
|
|
f72a5efb52 | ||
|
|
c4068df9f4 | ||
|
|
114dcb21c4 | ||
|
|
7ec1f9e808 | ||
|
|
2cef6cfd9a | ||
|
|
7ab8a7bf8e | ||
|
|
73d0017540 | ||
|
|
fcff48ffdc | ||
|
|
90ac626fc1 | ||
|
|
d8ed1b685f | ||
|
|
651da79697 | ||
|
|
11ba1f5301 | ||
|
|
a174469d19 | ||
|
|
18dba2fe2c | ||
|
|
dac4c63632 | ||
|
|
299b52ca45 | ||
|
|
0b9b2bb6f6 | ||
|
|
9160fb5f57 | ||
|
|
66cce837b5 | ||
|
|
9ec0d7acd5 | ||
|
|
88a7ffd75a | ||
|
|
45790c3a60 | ||
|
|
ba52924e2f | ||
|
|
00d00551ad | ||
|
|
f98edc8781 | ||
|
|
d24839267f | ||
|
|
312f016a56 | ||
|
|
a9850c50da | ||
|
|
9e6f8a8e40 | ||
|
|
2c511e8e28 | ||
|
|
8192e55942 | ||
|
|
c94a59c66f | ||
|
|
5d5d79d46c | ||
|
|
64e78540d9 | ||
|
|
c0d76e0d23 | ||
|
|
6e07b83075 | ||
|
|
a72ad7eef3 | ||
|
|
1796310558 | ||
|
|
243893240c | ||
|
|
c1d7f4a744 | ||
|
|
f16ae302d2 | ||
|
|
7a2dec9987 | ||
|
|
632fac4d5b | ||
|
|
fa20a9ccb3 | ||
|
|
020c11c89a | ||
|
|
50db06a5f3 | ||
|
|
0d21a6d60d | ||
|
|
ea53d0ca7c | ||
|
|
f9a57a53ba | ||
|
|
95d74ac11b | ||
|
|
81973c0da9 | ||
|
|
a3da63b760 | ||
|
|
9e7ce7afeb | ||
|
|
6b171c5a3f | ||
|
|
2478851790 | ||
|
|
23af79ce1b | ||
|
|
4caf4efb87 | ||
|
|
38bb259f65 | ||
|
|
97ba2321ac | ||
|
|
77fd8ffe53 | ||
|
|
279660e21b | ||
|
|
c1fa4be549 | ||
|
|
f63bd6c2cf | ||
|
|
f48f7ed0f5 | ||
|
|
6d79d59b74 | ||
|
|
3d399eba10 | ||
|
|
7c64de0a1c | ||
|
|
872cbdf441 | ||
|
|
e6402dec73 | ||
|
|
3d020eb6f5 | ||
|
|
12dfd63a1f | ||
|
|
e5e96319c2 | ||
|
|
af6c9e2ed6 | ||
|
|
452d97cfb0 | ||
|
|
002ef06d51 | ||
|
|
990cab63cf | ||
|
|
cb48a79e24 | ||
|
|
9d11434ee7 | ||
|
|
c7f3f416ad | ||
|
|
a389088709 | ||
|
|
44c9e48479 | ||
|
|
aeb3f051aa | ||
|
|
5afed47767 | ||
|
|
ed03a3078a |
@@ -0,0 +1,4 @@
|
||||
[submodule "apps/community-app"]
|
||||
path = apps/community-app
|
||||
url = https://github.com/openMF/community-app.git
|
||||
branch = develop
|
||||
@@ -1,3 +1,6 @@
|
||||
# This (sudo: false) is needed to "run on container-based infrastructure" on which cache: is available
|
||||
# http://docs.travis-ci.com/user/workers/container-based-infrastructure/
|
||||
sudo: false
|
||||
language: java
|
||||
jdk:
|
||||
- openjdk7
|
||||
@@ -9,3 +12,9 @@ notifications:
|
||||
# @see http://gradle.1045684.n5.nabble.com/Plain-console-output-td5710237.html
|
||||
env:
|
||||
- TERM=dumb
|
||||
# http://docs.travis-ci.com/user/caching/#Arbitrary-directories
|
||||
cache:
|
||||
apt: true
|
||||
directories:
|
||||
- $HOME/.gradle
|
||||
- $HOME/.m2
|
||||
|
||||
+266
@@ -6,6 +6,9 @@ See VERSIONING (https://github.com/openMF/mifosx/blob/master/VERSIONING.md) for
|
||||
Releases
|
||||
===============
|
||||
|
||||
1. 18 May 2015 - 15.03.1.RELEASE
|
||||
1. 06 Apr 2015 - 15.03.RELEASE
|
||||
1. 22 Dec 2014 - 1.26.0.RELEASE
|
||||
1. 1 Nov 2014 - 1.25.1.RELEASE
|
||||
1. 12 Oct 2014 - 1.25.0.RELEASE
|
||||
1. 10 Jul 2014 - 1.24.0.RELEASE
|
||||
@@ -68,6 +71,269 @@ Releases
|
||||
1. 05 April 2013 - 0.11.1.beta
|
||||
1. 05 April 2013 - 0.11.0.beta
|
||||
|
||||
15.03.1.RELEASE
|
||||
=============
|
||||
This minor release ships new functionality like the ability to create loans products whose interest compounding periods may be different from their rest periods and
|
||||
allowing extension of repayment schedule for daily loans when repayments fall on holidays along with a number of bug fixes and improvements to the Community app.
|
||||
|
||||
Important note on API breaking changes for app developers: As a part of the changes made for MIFOSX-2036, Group and center template API's no longer return details of "clientOptions" and "groupMemberOptions".
|
||||
You are requested to use /clients and /groups API's with the newly introduced query parameter "orphansOnly" for retrieving details of Clients and Groups which may be associated with particular Groups and Centers respectively.
|
||||
Sample usage of the same can be found on the "manage members" section on the Group profile screen and "Manage Groups" section of the Center profile screen
|
||||
|
||||
Platform & API
|
||||
|
||||
New Features & Improvements
|
||||
|
||||
- [MIFOSX-1951] - As a operations manager, I want to define loan products that allows interest compounding period to be different from rest period
|
||||
- [MIFOSX-1983] - Allow extending repayment schedule for Daily loans when repayments fall on holidays
|
||||
- [MIFOSX-2035] - Add new boolean parameter orphansOnly to retrieve all clients API
|
||||
- [MIFOSX-2002] - allow search client by mobile_no
|
||||
|
||||
Bugs
|
||||
- [MIFOSX-1831] - Journal entries for "Overpayment Liability" is not getting created for Periodic and Upfront accounting
|
||||
- [MIFOSX-1955] - Cashier transaction beyond specified date should not be displayed for particular cashier in Teller cash management
|
||||
- [MIFOSX-2004] - Not Able to modify Loan Application After Undo Disbursal And Undo Approval with Guarantor Attached
|
||||
- [MIFOSX-1988] - Tranche loan Summary displays entire approved amount as disbursed amount even though the second and higher tranches are not yet disbursed.
|
||||
- [MIFOSX-1995] - Prepay of loan with Grace on Interest is not working as expected
|
||||
- [MIFOSX-1891] - Problem with scheduling day loan repayments
|
||||
- [MIFOSX-1668] - Non-working day's repayment activity
|
||||
- [MIFOSX-2007] - Unable to list Hooks defined in the system
|
||||
- [MIFOSX-2032] - Teller Cash Management not handling multiple currencies accurately
|
||||
- [MIFOSX-2037] - Payment type is not getting displayed in Individual collection sheet
|
||||
- [MIFOSX-2043] - Password preferences API does not support Localization
|
||||
- [MIFOSX-2046] - overpaid loans don't get transferred along when transferring of clients
|
||||
- [MIFOSX-1956] - Accounting multi-currency opening balance
|
||||
- [MIFOSX-2036] - Refactoring Groups and Centers API - removing clientOptions and groupMemberOptions for template true
|
||||
|
||||
Community App
|
||||
- [MIFOSX-1596] - If a stretchy report's query is modified and submitted, it does not save the modified query. It shows the previously defined query.
|
||||
- [MIFOSX-1982] - Formatting issues with Stretchy reports
|
||||
- [MIFOSX-1985] - Unable to create weekly meetings with recurrence of every 4 weeks
|
||||
- [MIFOSX-1986] - Editing a meeting redirects to home page
|
||||
- [MIFOSX-1991] - Client Transfer - should allow selecting any group in the particular office
|
||||
- [MIFOSX-2008] - Enable Vietnamese (tiếng Việt) on the community App
|
||||
- [MIFOSX-2028] - Dynamic Typeahead for Manage Members and Groups
|
||||
- [MIFOSX-1979] - Introduce Better pagination for Groups and centers
|
||||
- [MIFOSX-1980] - Display Account Id and External ID for groups on Group search screen
|
||||
- [MIFOSX-1993] - Create GL Account - improve order of fields
|
||||
- [MIFOSX-1286] - Expand the scope of the "Filter by name/account#/staff/office" filter to filter all data rather than just the data visible on a page.
|
||||
- [MIFOSX-1996] - Issues with search in Client listing page
|
||||
- [MIFOSX-1999] - Issues related to Working days functionality
|
||||
- [MIFOSX-2000] - Not able to edit loan product when recalculate interest is enabled and Frequency of compounding != None
|
||||
- [MIFOSX-2022] - Force password reset days is not working as expected
|
||||
- [MIFOSX-2023] - Force password reset - issue 2
|
||||
- [MIFOSX-2026] - Issues with editing system reports
|
||||
- [MIFOSX-2029] - Small typo on passwordpreferences screen
|
||||
|
||||
15.03.RELEASE
|
||||
=============
|
||||
|
||||
This feature release ships new functionality like Collection sheets for Individual loans along with performance improvements around batch jobs and various enhancements to the community app.
|
||||
|
||||
Enhamcements to the the loans module include the ability to round off installments, fix EMI's for non-tranche loans, improved flexility for pre-closure, ability to specify which loan product attributes may be overridden at an indivdual account level and greater flexibility around editing tranche definitions during loan approval and disbursal.
|
||||
|
||||
Recurring deposits have been enhanced to support open-ended deposits (no maturity amount or period)
|
||||
|
||||
Beta API's shipped in this release add the functionality for setting opening balances for GL accounts and Entity mapping (can be used to map products and charges to Offices or Roles)
|
||||
|
||||
Note that this release moves "Payments types" from Code values to thier own tables, custom reports and queries might be affected as a result of the same
|
||||
|
||||
|
||||
Platform & API
|
||||
|
||||
New Features & Improvements
|
||||
|
||||
- [MIFOSX-1742] - Collection Sheet facility for individual loans.
|
||||
- [MIFOSX-1464] - Loan repayment - Rounding off
|
||||
- [MIFOSX-1844] - Last installment amount should not exceed the specified EMI amount.
|
||||
- [MIFOSX-1667] - As a system Administrator, I must be able to decide which attributes of a loan product may be overridden by the loan account
|
||||
- [MIFOSX-1918] - Allow full installment interest to be collected at time of pre-closure of loan
|
||||
- [MIFOSX-1868] - Ability to have user passwords never expire
|
||||
- [MIFOSX-1823] - Add facility to print receipts for all transactions for Savings
|
||||
- [MIFOSX-1875] - Enforce strict password policies in the system
|
||||
- [MIFOSX-1824] - Ability to allow user to change Tranche amount during loan approval stage.
|
||||
- [MIFOSX-1897] - As an accountant I want to be able to see all journals related to a specific loan or savings
|
||||
- [MIFOSX-1850] - Recurring deposits without maturity date/amount
|
||||
- [MIFOSX-916] - Ability for Client Loan repayments rounding off to the multiples of 10s or 100s
|
||||
- [MIFOSX-1159] - Allow Opening Balances to be set for GL (General Ledger) Accounts
|
||||
- [MIFOSX-1842] - Improvements to disbursal of tranche loans
|
||||
- [MIFOSX-1480] - Create an API for associating and diassociating groups from centers
|
||||
- [MIFOSX-1877] - Allow end-user to reconfigure working-days for the institution
|
||||
- [MIFOSX-1947] - Add API to allow capturing Staff images
|
||||
- [MIFOSX-1670] - Require modification/deleting of created Role
|
||||
- [MIFOSX-1817] - Teller Cash Management - capture Currency for Settle and Allocate transactions
|
||||
- [MIFOSX-1624] - Ability to writeoff loan on the same date of last transaction.
|
||||
- [MIFOSX-1904] - Move Payment Types to their own table
|
||||
- [MIFOSX-1846] - Feature to display and print Loan Transaction Receipt
|
||||
- [MIFOSX-1786] - Allow usage of UGD (Templates) for Hooks
|
||||
- [MIFOSX-1758] - Make the dist ZIP include the community-app in apps/ so that it works OOB
|
||||
- [MIFOSX-1908] - Configurable retries on CannotAcquireLockException or ObjectOptimisticLockingFailureException
|
||||
- [MIFOSX-1613] - The overdue status of a loan should appear only when the principal outstanding from the running schedule is greater than the principal outstanding from the original schedule when compared on current date.
|
||||
|
||||
Bugs
|
||||
|
||||
- [MIFOSX-1116] - Wrong maturity amount is shown when closing recurring deposit account
|
||||
- [MIFOSX-1481] - you cannot write off a loan after making a repayment
|
||||
- [MIFOSX-1729] - Installment amount exceeds the specified emi amount if there are multiple disbursals before the first repayment date.
|
||||
- [MIFOSX-1776] - Group loan application synk repayment with meeting is not working as expected
|
||||
- [MIFOSX-1808] - After moving the group from one center to another "Center Summary" is not geting updated
|
||||
- [MIFOSX-1809] - Closure reason created for Group is displaying in Closure reason for Centers while closing the Center.
|
||||
- [MIFOSX-1830] - Print report icon is not visible in UI for savings transaction receipt and receipt is coming for reverse transaction
|
||||
- [MIFOSX-1836] - Can't Transfer Clients between Groups
|
||||
- [MIFOSX-1839] - Issue related to Show Payment Details in Loans and Savings account Transactions
|
||||
- [MIFOSX-1847] - Data tables - can be deleted - even if data exists
|
||||
- [MIFOSX-1859] - no error indication while doing duplicate entry of one client identifier's Unique ID in another client's identifier's ID
|
||||
- [MIFOSX-1860] - Not able to disburse Second Tranche loan if First repayment date is defined.
|
||||
- [MIFOSX-1864] - cannot remove all Mappping Fees,Penalties to Income Accounts
|
||||
- [MIFOSX-1866] - Guarantor Release funds causes 500 error
|
||||
- [MIFOSX-1878] - Savings account timeline does not include the data of the user that activated the account
|
||||
- [MIFOSX-1884] - Unable to create a loan account with given loan product definition (tranche loan)
|
||||
- [MIFOSX-1885] - Not able to disassociate a Client from attached Group even if he is not having any active JLG loans under that Group
|
||||
- [MIFOSX-1892] - Issues related to Teller/Cashier Management
|
||||
- [MIFOSX-1905] - Consistency w.r.t spelling "principalThresholdForLastInstalment" for loan products
|
||||
- [MIFOSX-1914] - Not able to create loan product with "Principal Threshold (%) for Last Instalment" field added
|
||||
- [MIFOSX-1915] - Repayment schedule is not getting generated as per loan term, rather displaying more term with principal due
|
||||
- [MIFOSX-1926] - https://github.com/openMF/community-app/issues/1285
|
||||
- [MIFOSX-1940] - Accounting running balance job hangs when updating 400,000 or more entries
|
||||
- [MIFOSX-1942] - Edit Tranche option in community app takes you to the wrong page
|
||||
- [MIFOSX-1943] - UI issue in Loan Tranche Details tab - Edit tranche icon is not displayed
|
||||
- [MIFOSX-451] - Not able to close the loan earlier than its scheduled date.
|
||||
- [MIFOSX-1759] - Manage Group under center and Manage member under Group pages are not working as expected
|
||||
- [MIFOSX-1766] - Issues related to Assign and Unassign staff for Savings account
|
||||
- [MIFOSX-1941] - Incorrect GL Account running balance figures
|
||||
- [MIFOSX-1948] - Period accruals jobs does not handle Timezones correctly
|
||||
|
||||
|
||||
Community app
|
||||
|
||||
- [MIFOSX-1888] - Allow a UI configuration to specify which fields should be editable/read only/hidden on the loan account creation page
|
||||
- [MIFOSX-1139] - Cleaner error message when Community app tries to connect to an Invalid Platform URL
|
||||
- [MIFOSX-1825] - Add feature to bulk create loans (group wise)
|
||||
- [MIFOSX-1232] - Inconsistent terminology in Loan Product creation regarding loan cycle / borrower cycle
|
||||
- [MIFOSX-1293] - Add select all option to Pending Tasks in Checker Inbox and Tasks
|
||||
- [MIFOSX-1312] - When viewing a group loan, the group name does not display
|
||||
- [MIFOSX-1903] - Enable easier view of Journal entries created by loan transactions on the Community Application
|
||||
- [MIFOSX-1555] - UI updates to Group screen and applying number formats across the community app
|
||||
- [MIFOSX-1787] - Audit trails - Advanced search is not working as expected
|
||||
- [MIFOSX-1685] - Improve browser-back navigation
|
||||
- [MIFOSX-1690] - Huge dropdown list during account transfers
|
||||
- [MIFOSX-1693] - Chart of Accounts - display improvements
|
||||
- [MIFOSX-1605] - In Edit Recurring deposit product page not able "For Pre-mature Closure: on" field is not working
|
||||
- [MIFOSX-1617] - Better pagination service
|
||||
- [MIFOSX-1621] - Manage Members on group profile does not behave properly when adding first client to a group
|
||||
- [MIFOSX-1754] - Typo in Create Loan Product >> Accounting >> Cash (should be losses written off)
|
||||
- [MIFOSX-1583] - "Help" menu choice on mifos menu should be renamed or linked to the User Manual
|
||||
- [MIFOSX-1590] - Moving icons on Accounting Menu page distracting
|
||||
- [MIFOSX-1602] - Including Mifos X release details in Community-App as about info
|
||||
- [MIFOSX-1793] - Typo's in index.html
|
||||
- [MIFOSX-1833] - In the Add journal entry - Drop down accounts should be sorted with respect to gl code
|
||||
- [MIFOSX-1920] - Hiding Of Deleted Guarantors
|
||||
- [MIFOSX-1777] - Add tooltips for Fixed and Recurring Deposit product labels
|
||||
- [MIFOSX-1778] - Add tooltips for Loan Product Field labels Pt. 1
|
||||
- [MIFOSX-1779] - Add tooltips for Loan Product Field labels Pt. 2
|
||||
- [MIFOSX-1780] - Add tooltips for Loan Product Field labels Pt. 3
|
||||
- [MIFOSX-1781] - Add tooltips for New Loan Account labels
|
||||
- [MIFOSX-1783] - Add tooltips for Savings Product labels
|
||||
- [MIFOSX-1785] - Add tooltips and glossary entires for global configuration and savings accounting labels
|
||||
- [MIFOSX-1849] - Parse Error in Console while viewing a Group
|
||||
- [MIFOSX-1696] - UI Improvements to Manage Roles and Permissions
|
||||
- [MIFOSX-1911] - Deposit Account On Hold Transactions
|
||||
- [MIFOSX-1858] - Smoother sidebar transition on mouseout
|
||||
- [MIFOSX-1872] - Drop down for Account Transfers is not working
|
||||
- [MIFOSX-1640] - Provide select-all checkbox when managing permissions for role
|
||||
- [MIFOSX-1912] - Chrome browser - Language issue(Date format)
|
||||
- [MIFOSX-1544] - While creating a Group under center should not allowed to ask for office again
|
||||
- [MIFOSX-1822] - Create Sub ledger account is not working as expected
|
||||
- [MIFOSX-1900] - List Keyboard shortcuts
|
||||
- [MIFOSX-1960] - Add ID and External ID in Center Listing page
|
||||
- [MIFOSX-1256] - Filter charge and overdue charges drop-down lists to display only valid charges (matching currency)
|
||||
- [MIFOSX-1899] - Payment Details for "Frequent Postings" are not stored in the database.
|
||||
- [MIFOSX-1876] - Client attendance details submitted in collection sheet is not getting updated in database
|
||||
- [MIFOSX-1954] - Start date and end date got interchanged while creating the teller
|
||||
- [MIFOSX-1958] - Payment details is not getting displayed if any transaction detail is viewed from Search Journal entry screen
|
||||
|
||||
|
||||
1.26.0.RELEASE
|
||||
=============
|
||||
This feature release adds support for capturing guarantee requirements for loans and blocking/holding funds in guarantor accounts. It also includes various enhancements like the addition of new statuses for client life cycle, ability to map liability accounts to fees, ability to update deposit amounts for active recurring deposits and the ability to capture client images from a linked webcam along with a number of other improvements and bug fixes
|
||||
|
||||
|
||||
Platform & API
|
||||
|
||||
New Features & Improvements
|
||||
|
||||
- [MIFOSX-1662] - Adding new statuses to Client lifecyle
|
||||
- [MIFOSX-1663] - Add more flexibility for center/group meeting reschedule
|
||||
- [MIFOSX-1584] - Option to set "minimum days between disbursal and first repayment"
|
||||
- [MIFOSX-1641] - Configure Guarantor requirements for loan product
|
||||
- [MIFOSX-1675] - Add support to capture guarantee details for loans
|
||||
- [MIFOSX-1709] - Workflows for holding and releasing funds on savings account linked as guarantee to loan accounts
|
||||
- [MIFOSX-1728] - Introduce tenure Min/Max constraints for Tranche loans
|
||||
- [MIFOSX-1639] - Auto create standing instruction at loan disbursement
|
||||
- [MIFOSX-1700] - Need ability to update deposit amounts for non interest bearing Recurring deposits
|
||||
- [MIFOSX-1727] - Option to make Calendar Mandatory when disbursing JLG loan
|
||||
- [MIFOSX-1068] - Option to change approved amount during loan approval
|
||||
- [MIFOSX-1175] - Ability to transfer loan officer to a group
|
||||
- [MIFOSX-1523] - Loan rescheduling
|
||||
- [MIFOSX-1514] - Refund for Active Loans
|
||||
- [MIFOSX-1463] - Keep track of manually reversed/adjusted loan repayments
|
||||
- [MIFOSX-1511] - Custom Formats for Client number and account number
|
||||
- [MIFOSX-1630] - Bit and DateTime data type support in DataTable API
|
||||
- [MIFOSX-1619] - Add MifosX Eclipse preferences file into source control
|
||||
- [MIFOSX-1642] - add sub status to client
|
||||
- [MIFOSX-1628] - Log current user for loan and deposit transactions
|
||||
- [MIFOSX-1634] - Add option to account fees as liabilities
|
||||
- [MIFOSX-1638] - Waiving charges attached to zero balance installments - Loan Rescheduling
|
||||
- [MIFOSX-1738] - Create dev and production profiles for Gradle build
|
||||
- [MIFOSX-1566] - Constraint for minimum/maximum number of client in a active group
|
||||
- [MIFOSX-1680] - Option to change center meeting frequency and intervals
|
||||
- [MIFOSX-1674] - Allow the description field added to m_code_value to be edited/entered
|
||||
- [MIFOSX-1739] - Loan Products with close date in the past should not appear in loan account creation dropdown
|
||||
|
||||
Bugs
|
||||
|
||||
- [MIFOSX-1699] - Concurrent Savings transactions are not handled correctly
|
||||
- [MIFOSX-1550] - No check for NULL principal amount when creating journal entry for loan write-off
|
||||
- [MIFOSX-1625] - Can't disburse loan with charges configured for periodic accruals
|
||||
- [MIFOSX-1633] - Newly added pentaho reports are missing read permissions
|
||||
- [MIFOSX-1655] - Updating a loan (with charges attached) after submitting throws an error
|
||||
- [MIFOSX-1656] - Bulk JLG Loan application is not working as expected
|
||||
- [MIFOSX-1661] - Some details provided in the Loan Product page is not displaying in the New loan application page
|
||||
- [MIFOSX-1671] - User with "ALL_FUNCTIONS_READ" permission does not have access to /users/{userId} resource
|
||||
- [MIFOSX-1676] - Issues with Interest posting on Fixed deposit Account
|
||||
- [MIFOSX-1704] - makercheckers endpoint broken for non-superuser roles
|
||||
- [MIFOSX-1747] - Issues with logging on the MifosX platform after Spring boot update
|
||||
- [MIFOSX-1760] - For JLG Loans sync repayment with meeting is not working as expected after loan Approval
|
||||
|
||||
|
||||
Community App
|
||||
|
||||
- [MIFOSX-1645] - In UI should not allowed to send multiple requests by submitting request for multiple times for same action
|
||||
- [MIFOSX-1564] - Ability to Capture Client Image from webcams on the Community App
|
||||
- [MIFOSX-1745] - Community app does not allow deleting client images
|
||||
- [MIFOSX-1684] - Default current date for activation dates and submission dates
|
||||
- [MIFOSX-1687] - In search screens, retain the search criteria during browser navigation
|
||||
- [MIFOSX-1692] - Tree view of Chart of Accounts and Offices to have "Expand All" option
|
||||
- [MIFOSX-1591] - The +JLG Loan Application on the view group page has a different colored background color than other actions in the system.
|
||||
- [MIFOSX-1443] - By Clicking on client having Image/Signature, authentication page displays
|
||||
- [MIFOSX-1556] - AdHoc query Search always give error when 'summary' button is clicked
|
||||
- [MIFOSX-1043] - Community app does not support datatables with bit, DateTime fields
|
||||
- [MIFOSX-1559] - Issues related to Manage Groups in Centers and Manage Clients in Groups
|
||||
- [MIFOSX-1239] - Allow tab out from calendar control (to improve data entry efficiency)
|
||||
- [MIFOSX-1529] - Showing Today's Date in Datepicker
|
||||
- [MIFOSX-1546] - Improve UI for Global Configuration
|
||||
- [MIFOSX-1284] - Sort entries in selection lists alphabetically
|
||||
- [MIFOSX-1713] - Ability to hide values in "Approved Amount" and "Disburse Amount" for the loans under submitted and pending approval state
|
||||
- [MIFOSX-1533] - Advanced Search
|
||||
- [MIFOSX-1551] - System -> Audit trails- search is not working as expected
|
||||
- [MIFOSX-1644] - Loans transactions history does not hide transactions which have been undone
|
||||
- [MIFOSX-1730] - Unable to create Tranche loans on the community app when using a Date format other than 'dd MMMM yyyy'
|
||||
- [MIFOSX-1772] - By clicking on the meeting details in Group page (under Center and meeting assigned at center level) displays calendar does not exist error message
|
||||
- [MIFOSX-1575] - Reversing a journal entry does not ask for confirmation.
|
||||
- [MIFOSX-1677] - When moving clients between groups, display customer ids for easier identification
|
||||
- [MIFOSX-1768] - Clean up Loan product creation screen
|
||||
|
||||
|
||||
1.25.1.RELEASE
|
||||
=============
|
||||
Bug Release
|
||||
|
||||
@@ -6,6 +6,9 @@ Before sending out a pull request, please ensure that the following pre-requisit
|
||||
|
||||
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. Any relevant database changes are encapsulated in an SQL file with the next avilable version number at https://github.com/openMF/mifosx/tree/develop/mifosng-provider/src/main/resources/sql/migrations/core_db. These patches are automatically applied by Flyway on server startup.
|
||||
For any modifications to the schema which affects data on existing installations (Ex: moving columns to new table etc), ensure that the upgrade scripts are also accompanied by data migration scripts in the same patch file
|
||||
|
||||
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
|
||||
|
||||
+51
-26
@@ -13,6 +13,8 @@ The release artifact (.zip file) has the following structure:
|
||||
+ database ... folder contains database setup and upgrade scripts along with sample data required for installation
|
||||
+ pentahoReports ... folder contains any out-of-the-box reports provided through pentaho
|
||||
+ apps ... folder contains apps like community app that speak to the platform
|
||||
+ runmifosx.bat ... launch script for Windows
|
||||
+ runmifosx.sh ... launch script for Mac OS X and Linux
|
||||
|
|
||||
-- CHANGELOG.MD ... file documents changelog of project up to this release
|
||||
-- CONTRIBUTORS.MD ... file provides details on contributors to project
|
||||
@@ -25,14 +27,29 @@ The release artifact (.zip file) has the following structure:
|
||||
|
||||
## How to Install
|
||||
|
||||
The two ways to get up and running with mifos platform is:
|
||||
The three ways to get up and running with mifos platform is:
|
||||
|
||||
1. Use Amazon AWS and mifosplatform public AMI to spin up a new instance in the cloud
|
||||
2. Manually install the prerequisite software on your own machine, follow setup instructions and use release artifacts to get platform running yourself.
|
||||
3. ~~The (and the easiest) method is to just fire up the launch script provided in the release artifact and Mifos takes care of all the database, server-side and client-side setup for you.~~ Currently Broken
|
||||
|
||||
## 1. Amazon Public AMI
|
||||
## 1. Launch script automatic out-of-the box setup
|
||||
|
||||
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>
|
||||
Important : Automatic setup is currently broken, please follow the instructions for **Manual Installation** instead. For details of the issue, refer comments at https://mifosforge.jira.com/browse/MIFOSX-1756
|
||||
|
||||
The Mifos release artifact contains two launch scripts with names starting with "**runmifosx**". One of them (the one with the *.bat* file extension) is used to launch the platform on a Windows machine while the other (which has the *.sh* file extension) is used to launch the platform on Mac OS X and Linux. Just double-click on the respective script (depending on your OS) and voila! you have your own Mifos X platform running locally on your computer.
|
||||
|
||||
**Note**: *In case your script does not launch by double clicking on Linux or Mac OS X, here's what you can do. Head over to bash and type the following:*
|
||||
|
||||
```
|
||||
$ cd /path/where/runmifosx.sh/is/located
|
||||
$ chmod 0755 ./runmifosx.sh
|
||||
$ ./runmifosx.sh
|
||||
```
|
||||
|
||||
## 2. 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=ap-southeast-1#launchAmi=ami-2a734b78" title="Latest Mifos Platform Public AMI">Mifos Platform AMI (ami-2a734b78)</a>
|
||||
|
||||
*Note:* Read through the following as you step through the AWS Wizard
|
||||
|
||||
@@ -47,29 +64,29 @@ The two ways to get up and running with mifos platform is:
|
||||
- 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.24.0.RELEASE Public AMI
|
||||
*Name:* Mifos Platform 15.03.1.RELEASE Public AMI
|
||||
|
||||
- AMI ID: ami-a6035af4
|
||||
- AMI ID: ami-2a734b78
|
||||
- Kernel ID: aki-503e7402
|
||||
- Name: Mifos Platform 1.24.0.RELEASE Public AMI
|
||||
- Owner: 540782944231
|
||||
- Source: 540782944231/Mifos X-1.24.0 release
|
||||
- Name: Mifos Platform 15.03.1.RELEASE Public AMI
|
||||
- Owner: 239215483039
|
||||
- Source: 239215483039/Mifos X-15.03.1 release
|
||||
- Architecture: Ubuntu12.04 LTS x86_64
|
||||
- Built starting from Ubuntu AMI ami-35acbb41
|
||||
- Built starting from Ubuntu AMI ami-2a734b78
|
||||
- Java 1.7.0_51 64 bit JVM
|
||||
- Tomcat 7.0.39 (with SSL configured for self-signed certificate)
|
||||
- MySql 5.5.31
|
||||
|
||||
## 2. Manual Installation
|
||||
## 3. Manual Installation
|
||||
|
||||
### 2.1 Prerequisite Software
|
||||
### 3.1 Prerequisite Software
|
||||
|
||||
Before running mifos platform you must have the following software installed:
|
||||
- Oracle Java - JDK 7 (http://www.oracle.com/technetwork/java/javase/downloads/index.html)
|
||||
- Oracle MySQL - (http://dev.mysql.com/downloads/)
|
||||
- Apache Tomcat 7 - (http://tomcat.apache.org/download-70.cgi)
|
||||
|
||||
### 2.2 MySQL Setup
|
||||
### 3.2 MySQL Setup
|
||||
|
||||
Assumption: MySQL server is now installed.
|
||||
|
||||
@@ -81,7 +98,7 @@ The two ways to get up and running with mifos platform is:
|
||||
|
||||
If you have never installed mifosplatform before follow section 2.2.1 for first time setup of database, otherwise read section 2.2.2 on database upgrades.
|
||||
|
||||
#### 2.2.1 First Time Database setup
|
||||
#### 3.2.1 First Time Database setup
|
||||
|
||||
Mifos platform has support for hosting multiple tenants so we use two database schemas:
|
||||
- *mifosplatform-tenants*: which is responsible for persisting the tenant information which is used when deciding what schema each incoming request in the platform should route to. It acts as a registry which contains the details of all the tenant databases, and their connection information, which is used by MifosX to connect to the appropriate tenant.
|
||||
@@ -115,13 +132,13 @@ The two ways to get up and running with mifos platform is:
|
||||
UPDATE tenants SET schema_username = "your_username", schema_password = "your_password" WHERE identifier = "default";
|
||||
```
|
||||
|
||||
#### 2.2.2 Upgrade existing database(s)
|
||||
#### 3.2.2 Upgrade existing database(s)
|
||||
|
||||
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
|
||||
##### 3.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.
|
||||
|
||||
@@ -155,7 +172,7 @@ INSERT INTO `schema_version` (`version_rank`, `installed_rank`, `version`, `desc
|
||||
(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)
|
||||
#### 3.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
|
||||
|
||||
```
|
||||
@@ -163,11 +180,11 @@ INSERT INTO `schema_version` (`version_rank`, `installed_rank`, `version`, `desc
|
||||
```
|
||||
|
||||
|
||||
### 2.3 Tomcat 7 Setup
|
||||
### 3.3 Tomcat 7 Setup
|
||||
|
||||
Assumption: You have downloaded and installed Tomcat 7 correctly for your operation system: see http://tomcat.apache.org/tomcat-7.0-doc/setup.html
|
||||
|
||||
#### 2.3.1 Environment Variables Check
|
||||
#### 3.3.1 Environment Variables Check
|
||||
|
||||
Check that the following environment variables exist:
|
||||
- JAVA_HOME ... should point to directory where a 1.7 JDK or JRE is on machine
|
||||
@@ -176,25 +193,26 @@ INSERT INTO `schema_version` (`version_rank`, `installed_rank`, `version`, `desc
|
||||
Check that the following is on your path:
|
||||
- %JAVA_HOME%\bin;
|
||||
|
||||
#### 2.3.2 Logging
|
||||
#### 3.3.2 Logging
|
||||
|
||||
- In the [TOMCAT_HOME]/logs create a file called ```mifos-platform.log```
|
||||
|
||||
#### 2.3.3 Libraries
|
||||
#### 3.3.3 Libraries
|
||||
|
||||
Ensure the following libraries are in the [TOMCAT_HOME]/lib folder
|
||||
- tomcat-jdbc.jar
|
||||
- mysql-connector-java-5.1.22 (You will need to download latest MySQL Connector/J Jar file from http://dev.mysql.com/downloads/connector/j/)
|
||||
- tomcat-jdbc.jar (You can download the same from http://central.maven.org/maven2/org/apache/tomcat/tomcat-jdbc/7.0.57/tomcat-jdbc-7.0.57.jar)
|
||||
- mysql-connector-java-5.1.22 (You will need to download the latest MySQL Connector/J Jar file from http://dev.mysql.com/downloads/connector/j/)
|
||||
|
||||
#### 2.3.4 Configure for SSL
|
||||
#### 3.3.4 Configure for SSL
|
||||
|
||||
Generate a new keystore using java keytool (if you havent already done this):
|
||||
- Follow docs to create keystore.(http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration)
|
||||
|
||||
- Update server.xml as in docs. (Ther server.xml configuration given in the configure tomcat 7 below is what is need.)
|
||||
|
||||
```sudo keytool -genkey -alias mifostom -keyalg RSA -keystore /home/ubuntu/.keystore```
|
||||
|
||||
#### 2.3.5 Update tomcat configuration files for SSL, compression and JNDI connection to MySql
|
||||
#### 3.3.5 Update tomcat configuration files for SSL, compression and JNDI connection to MySql
|
||||
|
||||
```
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
@@ -263,7 +281,7 @@ INSERT INTO `schema_version` (`version_rank`, `installed_rank`, `version`, `desc
|
||||
</Server>
|
||||
```
|
||||
|
||||
#### 2.3.6 Drop application into tomcat webapps folder
|
||||
#### 3.3.6 Drop application into tomcat webapps folder
|
||||
|
||||
Drop the following from the release artifact into the [TOMCAT_HOME]/webapps folder:
|
||||
- mifosng-provider.war
|
||||
@@ -272,8 +290,15 @@ INSERT INTO `schema_version` (`version_rank`, `installed_rank`, `version`, `desc
|
||||
- The entire ```apps/community-app``` folder.
|
||||
- The entire api-docs folder
|
||||
|
||||
#### 2.3.7 Startup tomcat
|
||||
#### 3.3.7 Startup tomcat
|
||||
Startup tomcat:
|
||||
- Platform application should be available @ https://[server ip address]:8443/mifosng-provider/api/v1/offices?tenantIdentifier=default&pretty=true
|
||||
- Community application should be available @ https://[server ip address]:8443/community-app?baseApiUrl=https://[server ip address]:8443/mifosng-provider/api/v1/
|
||||
- API docs should be available @ https://[server ip address]:8443/api-docs/apiLive.htm
|
||||
|
||||
*where [server ip address] is the hostname or IP address of your computer. For instance, if you've installed Mifos on your local machine then [server ip address] is localhost*
|
||||
|
||||
## How to integrate the web front-end UI with the back-end
|
||||
|
||||
To be able to use the front-end UI along with the back-end, you simply need to copy the webapp's source code files to the ```apps``` folder. For instance, you could copy the source code files of the community app to ```apps/community-app```. This would enable you to access the commuity app from the following URL:
|
||||
*https://[server ip address]:8443/mifosng-provider/apps/community-app?baseApiUrl=https://[server ip address]:8443*
|
||||
|
||||
+20
-28
@@ -1,54 +1,46 @@
|
||||
Versioning
|
||||
=====
|
||||
For releases, we follow a simplified date versioning scheme which ties in nicely with our time based release cycle (with stables releases being promoted on a three month cycle)
|
||||
|
||||
For releases we will follow semantic versioning approach. (http://semver.org/)
|
||||
Prior to 15.03.RELEASE, we followed a semantic versioning approach. (http://semver.org/)
|
||||
|
||||
Semantic Versioning
|
||||
Date Versioning
|
||||
===================
|
||||
|
||||
Semantic versioning is a very simple scheme built around the X.Y.Z-buildNo concept (for example 2.6.0-x or 2.6.0-BUILD-SNAPSHOT):
|
||||
Our date versioning scheme is built around the YY.MM.{PATCH}.{release_type} concept (for example 15.06.RELEASE or 15.06.1.BUILD-SNAPSHOT) where
|
||||
|
||||
Increment Z when you fix something
|
||||
Increment Y when you add a new feature
|
||||
Increment X when you break backwards-compatibility or add major features
|
||||
Use the buildNo to differentiate different builds off the same branch, and to differentiate between development, test and production builds.
|
||||
YY represents the year of the release
|
||||
MM represents the month of the major release
|
||||
PATCH (optional) gets incremented whenever a new release is made from an existing major release
|
||||
release_type differentiates different builds off the same branch. It also differentiates between development, test and production builds.
|
||||
|
||||
Version structure
|
||||
|
||||
{number}.{release_type}
|
||||
|
||||
where {number} is further broken down as {major}.{minor}.{micro}.
|
||||
where {number} is further broken down as YY.MM.{PATCH}.
|
||||
|
||||
Examples:
|
||||
|
||||
1.0.0.BUILD-SNAPSHOT
|
||||
1.0.0.M1
|
||||
1.0.0.RC1
|
||||
1.0.0.RELEASE
|
||||
15.03.BUILD-SNAPSHOT
|
||||
15.03.M1
|
||||
15.03.RC1
|
||||
15.03.RELEASE
|
||||
15.03.1.RC1
|
||||
15.03.1.RELEASE
|
||||
|
||||
Number semantics
|
||||
|
||||
major/minor/micro semantics may have some variance across projects but in general this is what we mean.
|
||||
|
||||
In general:
|
||||
|
||||
a major version suggests many significant new features, an associated marketing campaign, and possible breaking of backward compatibility.
|
||||
a minor version may also contain serious new features, but should not break compatibility. You can expect minor releases every 1-3 months.
|
||||
a micro version typically contains many bug fixes and improvements and perhaps several smaller new features. You can expect micro version approximately every 5-20 days (depending on bugs or suggested improvements).
|
||||
a major version (Ex:15.03) does not have a patch number and suggests many significant new features, an associated marketing campaign, and possible breaking of backward compatibility. You can expect major releases every 3 months
|
||||
a minor version (Ex:15.03.1) may also contain serious new features, but typically contains many bug fixes and improvements and does not break compatibility. You can expect minor releases between the quarterly major release cycle.
|
||||
|
||||
Order matters
|
||||
|
||||
Notice that the following sequence of versions is in ordered ascending both alphabetically and toward GA:
|
||||
|
||||
1.0.0.BUILD-SNAPSHOT
|
||||
1.0.0.M1
|
||||
1.0.0.RC1
|
||||
1.0.0.RELEASE
|
||||
|
||||
What You Should Install Where
|
||||
|
||||
As a rule of thumb …
|
||||
As a rule of thumb …
|
||||
|
||||
Snapshot or Milestone versions should only be installed on dev boxes and integration environments. They shouldn’t be deployed to any of the dedicated test environments.
|
||||
Snapshot or Milestone versions should only be installed on dev boxes and integration environments. They shouldn’t be deployed to any of the dedicated test environments.
|
||||
Release candidates should be installed in the dedicated test environments. In an emergency, a release candidate can be installed into the production environment.
|
||||
Production releases can be installed anywhere - and they are the only kind of build that should be installed into the production environment.
|
||||
Production releases can be installed anywhere - and they are the only kind of build that should be installed into the production environment.
|
||||
|
||||
+3809
-1083
File diff suppressed because it is too large
Load Diff
@@ -192,7 +192,7 @@ body {
|
||||
.flybar-nav {
|
||||
display: block;
|
||||
float: left;
|
||||
width: 90px;
|
||||
min-width: 90px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,20 @@ Mifos Platform Apps
|
||||
|
||||
Community created apps built on top of mifosplatform are stored in source control repository @ https://github.com/openMF/
|
||||
|
||||
To get the Git sub modules from here, use "--recursive" in your original git clone, or, if already cloned, do:
|
||||
|
||||
git submodule update --init --recursive; git submodule status
|
||||
|
||||
Later to update both this main repo but also get the latest from the submodule(s), do:
|
||||
|
||||
git pull; git submodule update --remote
|
||||
|
||||
Here is how a new Git submodule can (was originally) added here:
|
||||
|
||||
git submodule add -b develop https://github.com/openMF/community-app.git
|
||||
git submodule init
|
||||
|
||||
|
||||
The Community App (AngularJS-based)
|
||||
===============
|
||||
https://github.com/openMF/community-app
|
||||
|
||||
Submodule
+1
Submodule apps/community-app added at e4cf52eb74
Executable
+8
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# https://developer.cloudbees.com/bin/view/DEV/Node+Builds
|
||||
curl -s -o use-node https://repository-cloudbees.forge.cloudbees.com/distributions/ci-addons/node/use-node
|
||||
NODE_VERSION=0.11.12 . ./use-node
|
||||
|
||||
./build.sh
|
||||
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Exit the script if any command returns a non-true return value (http://www.davidpashley.com/articles/writing-robust-shell-scripts/)
|
||||
set -e
|
||||
|
||||
git --version
|
||||
# TODO UNCOMMENT THIS once https://github.com/openMF/mifosx/pull/1291 is merged!
|
||||
# git pull
|
||||
# This does NOT get the most recent revision from the submodule repository.
|
||||
# Instead, it only gets the revision of the submodule that is recorded in the revision of the main repository.
|
||||
## NOT git submodule update --remote
|
||||
# The following is very important, because even if the main (API) repo is latest,
|
||||
# the sub-module initially will be a fixed old rev. and only this grabs real latest:
|
||||
git submodule foreach 'git checkout develop && git pull --ff-only origin develop'
|
||||
|
||||
cd apps/community-app
|
||||
./build.sh
|
||||
cd ../../mifosng-provider/
|
||||
./gradlew -Penv=dev clean dist
|
||||
@@ -24,6 +24,7 @@ apply plugin: 'eclipse'
|
||||
apply plugin: 'idea'
|
||||
apply plugin: 'tomcat'
|
||||
apply plugin: 'project-report'
|
||||
apply plugin: 'java'
|
||||
|
||||
/* define the valid syntax level for source files */
|
||||
sourceCompatibility = JavaVersion.VERSION_1_7
|
||||
@@ -44,7 +45,7 @@ group = 'org.mifosplatform'
|
||||
repositories {
|
||||
jcenter()
|
||||
maven {
|
||||
url "http://repository.pentaho.org/artifactory/pentaho/"
|
||||
url "http://nexus.pentaho.org/content/repositories/pentaho-public-release-repos/"
|
||||
}
|
||||
// mavenLocal() // useful for local dev using MariaDB4j SNAPSHOTs (not needed for real-world non-SNAPHOT builds)
|
||||
}
|
||||
@@ -56,110 +57,28 @@ configurations {
|
||||
runtime
|
||||
all*.exclude group: 'commons-logging'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
def tomcatVersion = '7.0.54'
|
||||
tomcat "org.apache.tomcat.embed:tomcat-embed-core:${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'],
|
||||
)
|
||||
|
||||
compile(
|
||||
[group: 'ch.vorburger.mariaDB4j', name: 'mariaDB4j', version: '2.1.1'],
|
||||
|
||||
[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],
|
||||
[group: 'com.sun.jersey', name: 'jersey-servlet', version: jerseyVersion],
|
||||
[group: 'com.sun.jersey', name: 'jersey-server', version: jerseyVersion],
|
||||
[group: 'com.sun.jersey', name: 'jersey-json', version: jerseyVersion],
|
||||
[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: '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.3'],
|
||||
[group: 'org.apache.commons', name: 'commons-lang3', version: '3.3.2'],
|
||||
|
||||
// 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: 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'],
|
||||
[group: 'pentaho-reporting-engine', name: 'pentaho-reporting-engine-classic-extensions-scripting', version: '3.9.1-GA'],
|
||||
[group: 'pentaho-reporting-engine', name: 'pentaho-reporting-engine-wizard-core', version: '3.9.1-GA'],
|
||||
[group: 'pentaho-report-designer', name: 'pentaho-reporting-engine-wizard-xul', version: '3.9.1-GA'],
|
||||
|
||||
[group: 'pentaho-library', name: 'libbase', version: '1.2.8'],
|
||||
[group: 'pentaho-library',name: 'libdocbundle', version: '1.2.8'],
|
||||
[group: 'pentaho-library',name: 'libfonts', version: '1.2.8'],
|
||||
[group: 'pentaho-library',name: 'libformat', version: '1.2.8'],
|
||||
[group: 'pentaho-library',name: 'libformula', version: '1.2.8'],
|
||||
[group: 'pentaho-library',name: 'libloader', version: '1.2.8'],
|
||||
[group: 'pentaho-library',name: 'librepository', version: '1.2.8'],
|
||||
[group: 'pentaho-library',name: 'libserializer', version: '1.2.8'],
|
||||
[group: 'pentaho-library',name: 'libsparkline', version: '1.2.8'],
|
||||
[group: 'pentaho-library',name: 'libxml', version: '1.2.8'],
|
||||
|
||||
[group: 'org.apache.poi',name: 'poi', version: '3.9'],
|
||||
[group: 'org.apache.poi',name: 'poi-ooxml', version: '3.9'],
|
||||
[group: 'org.apache.poi',name: 'poi-ooxml-schemas', version: '3.9'],
|
||||
|
||||
[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-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.jayway.jsonpath', name: 'json-path', version: '0.9.1'],
|
||||
|
||||
// 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]
|
||||
|
||||
/* Pick up dependencies based on the environemnt, defaults to production */
|
||||
if (project.hasProperty('env') && project.getProperty('env') == 'dev') {
|
||||
apply from: 'dev-dependencies.gradle'
|
||||
} else {
|
||||
apply from: 'dependencies.gradle'
|
||||
}
|
||||
|
||||
task dist(type:Zip){
|
||||
baseName= 'mifosplatform'
|
||||
baseName = 'mifosplatform'
|
||||
version = qualifyVersionIfNecessary(releaseVersion)
|
||||
includeEmptyDirs = true
|
||||
from('../') {
|
||||
fileMode = 0755
|
||||
include '*.md'
|
||||
}
|
||||
from('src/main/dist') {
|
||||
fileMode = 0755
|
||||
include '*'
|
||||
}
|
||||
from('../apps') {
|
||||
fileMode = 0755
|
||||
include '*.md'
|
||||
include '**/*'
|
||||
into('apps')
|
||||
}
|
||||
from('src/main/pentahoReports/') {
|
||||
@@ -206,7 +125,7 @@ war {
|
||||
|
||||
license {
|
||||
header rootProject.file('../LICENSE.md')
|
||||
excludes(["**/*.mustache", "**/*.sql", "**/package-info.java", "**/keystore.jks"])
|
||||
excludes(["**/*.html", "**/*.mustache", "**/*.sql", "**/package-info.java", "**/keystore.jks"])
|
||||
strictCheck true
|
||||
}
|
||||
|
||||
@@ -234,8 +153,26 @@ tomcatRunWar {
|
||||
sourceSets.main.output.resourcesDir = sourceSets.main.output.classesDir
|
||||
sourceSets.test.output.resourcesDir = sourceSets.test.output.classesDir
|
||||
|
||||
/* Exclude maria db and embedded tomcat related files for non dev builds */
|
||||
if (!(project.hasProperty('env') && project.getProperty('env') == 'dev')) {
|
||||
sourceSets {
|
||||
integrationTest {
|
||||
main {
|
||||
java {
|
||||
exclude '**/Server*'
|
||||
exclude '**/MariaDB4j*'
|
||||
exclude '**/EmbeddedTomcatWithSSLConfiguration.java'
|
||||
}
|
||||
}
|
||||
test {
|
||||
java {
|
||||
exclude '**/core/boot/tests/**'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
integrationTest {
|
||||
compileClasspath += main.output + test.output
|
||||
runtimeClasspath += main.output + test.output
|
||||
}
|
||||
@@ -325,7 +262,8 @@ task migrateTenantDB<<{
|
||||
|
||||
flyway.url= "jdbc:mysql://localhost:3306/$tenantDbName"
|
||||
flyway.locations= [filePath]
|
||||
|
||||
/**We use ${ as the prefix for strecthy reporting, do not want them to be interpreted by Flyway**/
|
||||
flyway.placeholderPrefix = "\$\${"
|
||||
flywayMigrate.execute()
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
dependencies {
|
||||
def tomcatVersion = '7.0.54'
|
||||
tomcat "org.apache.tomcat.embed:tomcat-embed-core:${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'],
|
||||
)
|
||||
|
||||
compile(
|
||||
// [group: 'ch.vorburger.mariaDB4j', name: 'mariaDB4j', version: '2.1.3'],
|
||||
|
||||
[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],
|
||||
[group: 'com.sun.jersey', name: 'jersey-servlet', version: jerseyVersion],
|
||||
[group: 'com.sun.jersey', name: 'jersey-server', version: jerseyVersion],
|
||||
[group: 'com.sun.jersey', name: 'jersey-json', version: jerseyVersion],
|
||||
[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: '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.3'],
|
||||
[group: 'org.apache.commons', name: 'commons-lang3', version: '3.3.2'],
|
||||
|
||||
// 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: 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'],
|
||||
[group: 'pentaho-reporting-engine', name: 'pentaho-reporting-engine-classic-extensions-scripting', version: '3.9.1-GA'],
|
||||
[group: 'pentaho-reporting-engine', name: 'pentaho-reporting-engine-wizard-core', version: '3.9.1-GA'],
|
||||
[group: 'pentaho-report-designer', name: 'pentaho-reporting-engine-wizard-xul', version: '3.9.1-GA'],
|
||||
|
||||
[group: 'pentaho-library', name: 'libbase', version: '1.2.8'],
|
||||
[group: 'pentaho-library',name: 'libdocbundle', version: '1.2.8'],
|
||||
[group: 'pentaho-library',name: 'libfonts', version: '1.2.8'],
|
||||
[group: 'pentaho-library',name: 'libformat', version: '1.2.8'],
|
||||
[group: 'pentaho-library',name: 'libformula', version: '1.2.8'],
|
||||
[group: 'pentaho-library',name: 'libloader', version: '1.2.8'],
|
||||
[group: 'pentaho-library',name: 'librepository', version: '1.2.8'],
|
||||
[group: 'pentaho-library',name: 'libserializer', version: '1.2.8'],
|
||||
[group: 'pentaho-library',name: 'libsparkline', version: '1.2.8'],
|
||||
[group: 'pentaho-library',name: 'libxml', version: '1.2.8'],
|
||||
|
||||
[group: 'org.apache.poi',name: 'poi', version: '3.9'],
|
||||
[group: 'org.apache.poi',name: 'poi-ooxml', version: '3.9'],
|
||||
[group: 'org.apache.poi',name: 'poi-ooxml-schemas', version: '3.9'],
|
||||
|
||||
[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-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.jayway.jsonpath', name: 'json-path', version: '0.9.1'],
|
||||
|
||||
// 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'],
|
||||
// Once we've switched to Java 8 this dep can be removed.
|
||||
[group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.0']
|
||||
)
|
||||
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]
|
||||
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
dependencies {
|
||||
def tomcatVersion = '7.0.54'
|
||||
tomcat "org.apache.tomcat.embed:tomcat-embed-core:${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'],
|
||||
)
|
||||
|
||||
compile(
|
||||
[group: 'ch.vorburger.mariaDB4j', name: 'mariaDB4j', version: '2.1.3'],
|
||||
|
||||
[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],
|
||||
[group: 'com.sun.jersey', name: 'jersey-servlet', version: jerseyVersion],
|
||||
[group: 'com.sun.jersey', name: 'jersey-server', version: jerseyVersion],
|
||||
[group: 'com.sun.jersey', name: 'jersey-json', version: jerseyVersion],
|
||||
[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: '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.3'],
|
||||
[group: 'org.apache.commons', name: 'commons-lang3', version: '3.3.2'],
|
||||
|
||||
// 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: 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'],
|
||||
[group: 'pentaho-reporting-engine', name: 'pentaho-reporting-engine-classic-extensions-scripting', version: '3.9.1-GA'],
|
||||
[group: 'pentaho-reporting-engine', name: 'pentaho-reporting-engine-wizard-core', version: '3.9.1-GA'],
|
||||
[group: 'pentaho-report-designer', name: 'pentaho-reporting-engine-wizard-xul', version: '3.9.1-GA'],
|
||||
|
||||
[group: 'pentaho-library', name: 'libbase', version: '1.2.8'],
|
||||
[group: 'pentaho-library',name: 'libdocbundle', version: '1.2.8'],
|
||||
[group: 'pentaho-library',name: 'libfonts', version: '1.2.8'],
|
||||
[group: 'pentaho-library',name: 'libformat', version: '1.2.8'],
|
||||
[group: 'pentaho-library',name: 'libformula', version: '1.2.8'],
|
||||
[group: 'pentaho-library',name: 'libloader', version: '1.2.8'],
|
||||
[group: 'pentaho-library',name: 'librepository', version: '1.2.8'],
|
||||
[group: 'pentaho-library',name: 'libserializer', version: '1.2.8'],
|
||||
[group: 'pentaho-library',name: 'libsparkline', version: '1.2.8'],
|
||||
[group: 'pentaho-library',name: 'libxml', version: '1.2.8'],
|
||||
|
||||
[group: 'org.apache.poi',name: 'poi', version: '3.9'],
|
||||
[group: 'org.apache.poi',name: 'poi-ooxml', version: '3.9'],
|
||||
[group: 'org.apache.poi',name: 'poi-ooxml-schemas', version: '3.9'],
|
||||
|
||||
[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-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.jayway.jsonpath', name: 'json-path', version: '0.9.1'],
|
||||
|
||||
// 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'],
|
||||
// Once we've switched to Java 8 this dep can be removed.
|
||||
[group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.0']
|
||||
)
|
||||
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]
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
releaseVersion=1.25.1.RELEASE
|
||||
releaseVersion=15.03.1.RELEASE
|
||||
|
||||
|
||||
|
||||
|
||||
Vendored
+2
-2
@@ -9,8 +9,8 @@
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=8005,server=y,suspend=n"
|
||||
|
||||
CATALINA_OPTS="-Xms512m -Xmx512m"
|
||||
JAVA_OPTS="-Xms512m -Xmx512m -XX:PermSize=256m -XX:MaxPermSize=512m"
|
||||
CATALINA_OPTS="-Xms512m -Xmx2048m"
|
||||
JAVA_OPTS="-Xms512m -Xmx2048m -XX:PermSize=256m -XX:MaxPermSize=512m"
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
+473
@@ -0,0 +1,473 @@
|
||||
/**
|
||||
* 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.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mifosplatform.integrationtests.common.CenterDomain;
|
||||
import org.mifosplatform.integrationtests.common.CenterHelper;
|
||||
import org.mifosplatform.integrationtests.common.ClientHelper;
|
||||
import org.mifosplatform.integrationtests.common.CommonConstants;
|
||||
import org.mifosplatform.integrationtests.common.GroupHelper;
|
||||
import org.mifosplatform.integrationtests.common.OfficeHelper;
|
||||
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.LoanTransactionHelper;
|
||||
import org.mifosplatform.integrationtests.common.savings.SavingsAccountHelper;
|
||||
import org.mifosplatform.integrationtests.common.savings.SavingsProductHelper;
|
||||
import org.mifosplatform.integrationtests.common.system.AccountNumberPreferencesHelper;
|
||||
import org.mifosplatform.integrationtests.common.system.CodeHelper;
|
||||
|
||||
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 AccountNumberPreferencesTest {
|
||||
|
||||
private RequestSpecification requestSpec;
|
||||
private ResponseSpecification responseSpec;
|
||||
private ResponseSpecification responseValidationError;
|
||||
private ResponseSpecification responseNotFoundError;
|
||||
private ResponseSpecification responseForbiddenError;
|
||||
private Integer clientId;
|
||||
private Integer loanProductId;
|
||||
private Integer loanId;
|
||||
private Integer savingsProductId;
|
||||
private Integer savingsId;
|
||||
private final String loanPrincipalAmount = "100000.00";
|
||||
private final String numberOfRepayments = "12";
|
||||
private final String interestRatePerPeriod = "18";
|
||||
private final String dateString = "4 September 2014";
|
||||
private final String minBalanceForInterestCalculation = null;
|
||||
private final String minRequiredBalance = null;
|
||||
private final String enforceMinRequiredBalance = "false";
|
||||
private LoanTransactionHelper loanTransactionHelper;
|
||||
private SavingsAccountHelper savingsAccountHelper;
|
||||
private AccountNumberPreferencesHelper accountNumberPreferencesHelper;
|
||||
private Integer clientAccountNumberPreferenceId;
|
||||
private Integer loanAccountNumberPreferenceId;
|
||||
private Integer savingsAccountNumberPreferenceId;
|
||||
private Integer groupsAccountNumberPreferenceId;
|
||||
private Integer centerAccountNumberPreferenceId;
|
||||
private final String MINIMUM_OPENING_BALANCE = "1000.0";
|
||||
private final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL";
|
||||
private Boolean isAccountPreferenceSetUp = false;
|
||||
private Integer clientTypeCodeId;
|
||||
private String clientCodeValueName;
|
||||
private Integer clientCodeValueId;
|
||||
private final String clientTypeName = "CLIENT_TYPE";
|
||||
private final String officeName = "OFFICE_NAME";
|
||||
private final String loanShortName = "LOAN_PRODUCT_SHORT_NAME";
|
||||
private final String savingsShortName = "SAVINGS_PRODUCT_SHORT_NAME";
|
||||
private Integer groupID;
|
||||
private Integer centerId;
|
||||
private String groupAccountNo;
|
||||
|
||||
@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.responseValidationError = new ResponseSpecBuilder().expectStatusCode(400).build();
|
||||
this.responseNotFoundError = new ResponseSpecBuilder().expectStatusCode(404).build();
|
||||
this.responseForbiddenError = new ResponseSpecBuilder().expectStatusCode(403).build();
|
||||
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||
this.accountNumberPreferencesHelper = new AccountNumberPreferencesHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAccountNumberPreferences() {
|
||||
|
||||
/* Create Loan and Savings Product */
|
||||
this.createLoanAndSavingsProduct();
|
||||
|
||||
/* Ensure no account number preferences are present in the system */
|
||||
this.deleteAllAccountNumberPreferences();
|
||||
|
||||
/*
|
||||
* Validate the default account number generation rules for clients,
|
||||
* loans and savings accounts.
|
||||
*/
|
||||
this.validateDefaultAccountNumberGeneration();
|
||||
|
||||
/* Create and Validate account number preferences */
|
||||
this.createAccountNumberPreference();
|
||||
|
||||
/*
|
||||
* Validate account number preference rules apply to Clients,Loans and
|
||||
* Saving Accounts
|
||||
*/
|
||||
this.validateAccountNumberGenerationWithPreferences();
|
||||
|
||||
/* Validate account number preferences Updation */
|
||||
this.updateAccountNumberPreference();
|
||||
|
||||
/*
|
||||
* Validate account number preference rules apply to Clients,Loans and
|
||||
* Saving Accounts after Updation
|
||||
*/
|
||||
this.validateAccountNumberGenerationWithPreferences();
|
||||
|
||||
/* Delete all account number preferences */
|
||||
this.deleteAllAccountNumberPreferences();
|
||||
|
||||
}
|
||||
|
||||
private void createLoanAndSavingsProduct() {
|
||||
this.createLoanProduct();
|
||||
this.createSavingsProduct();
|
||||
}
|
||||
|
||||
private void deleteAllAccountNumberPreferences() {
|
||||
ArrayList<HashMap<String, Object>> preferenceIds = this.accountNumberPreferencesHelper.getAllAccountNumberPreferences();
|
||||
/* Deletion of valid account preference ID */
|
||||
for (HashMap<String, Object> preferenceId : preferenceIds) {
|
||||
Integer id = (Integer) preferenceId.get("id");
|
||||
HashMap<String, Object> delResponse = this.accountNumberPreferencesHelper.deleteAccountNumberPreference(id, this.responseSpec,
|
||||
"");
|
||||
System.out.println("Successfully deleted account number preference (ID: " + delResponse.get("resourceId") + ")");
|
||||
}
|
||||
/* Deletion of invalid account preference ID should fail */
|
||||
System.out
|
||||
.println("---------------------------------DELETING ACCOUNT NUMBER PREFERENCE WITH INVALID ID------------------------------------------");
|
||||
|
||||
HashMap<String, Object> deletionError = this.accountNumberPreferencesHelper.deleteAccountNumberPreference(10,
|
||||
this.responseNotFoundError, "");
|
||||
Assert.assertEquals("error.msg.resource.not.found", deletionError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
}
|
||||
|
||||
private void validateDefaultAccountNumberGeneration() {
|
||||
this.createAndValidateClientEntity(this.isAccountPreferenceSetUp);
|
||||
this.createAndValidateLoanEntity(this.isAccountPreferenceSetUp);
|
||||
this.createAndValidateSavingsEntity(this.isAccountPreferenceSetUp);
|
||||
this.createAndValidateGroup(this.isAccountPreferenceSetUp);
|
||||
this.createAndValidateCenter(this.isAccountPreferenceSetUp);
|
||||
}
|
||||
|
||||
private void validateAccountNumberGenerationWithPreferences() {
|
||||
this.isAccountPreferenceSetUp = true;
|
||||
this.createAndValidateClientEntity(this.isAccountPreferenceSetUp);
|
||||
this.createAndValidateLoanEntity(this.isAccountPreferenceSetUp);
|
||||
this.createAndValidateSavingsEntity(this.isAccountPreferenceSetUp);
|
||||
this.createAndValidateGroup(this.isAccountPreferenceSetUp);
|
||||
this.createAndValidateCenter(this.isAccountPreferenceSetUp);
|
||||
}
|
||||
|
||||
private void createAccountNumberPreference() {
|
||||
this.clientAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createClientAccountNumberPreference(
|
||||
this.responseSpec, "resourceId");
|
||||
System.out.println("Successfully created account number preferences for Client (ID: " + this.clientAccountNumberPreferenceId);
|
||||
|
||||
this.loanAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createLoanAccountNumberPreference(
|
||||
this.responseSpec, "resourceId");
|
||||
System.out.println("Successfully created account number preferences for Loan (ID: " + this.loanAccountNumberPreferenceId);
|
||||
|
||||
this.savingsAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createSavingsAccountNumberPreference(
|
||||
this.responseSpec, "resourceId");
|
||||
System.out.println("Successfully created account number preferences for Savings (ID: " + this.savingsAccountNumberPreferenceId);
|
||||
|
||||
this.groupsAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createGroupsAccountNumberPreference(
|
||||
this.responseSpec, "resourceId");
|
||||
System.out.println("Successfully created account number preferences for Groups (ID: " + this.groupsAccountNumberPreferenceId);
|
||||
|
||||
this.centerAccountNumberPreferenceId = (Integer) this.accountNumberPreferencesHelper.createCenterAccountNumberPreference(
|
||||
this.responseSpec, "resourceId");
|
||||
System.out.println("Successfully created account number preferences for Center (ID: " + this.centerAccountNumberPreferenceId);
|
||||
|
||||
this.accountNumberPreferencesHelper.verifyCreationOfAccountNumberPreferences(this.clientAccountNumberPreferenceId,
|
||||
this.loanAccountNumberPreferenceId, this.savingsAccountNumberPreferenceId, this.groupsAccountNumberPreferenceId,
|
||||
this.centerAccountNumberPreferenceId, this.responseSpec, this.requestSpec);
|
||||
|
||||
this.createAccountNumberPreferenceInvalidData("1000", "1001");
|
||||
this.createAccountNumberPreferenceDuplicateData("1", "101");
|
||||
|
||||
}
|
||||
|
||||
private void createAccountNumberPreferenceDuplicateData(final String accountType, final String prefixType) {
|
||||
/* Creating account Preference with duplicate data should fail */
|
||||
System.out
|
||||
.println("---------------------------------CREATING ACCOUNT NUMBER PREFERENCE WITH DUPLICATE DATA------------------------------------------");
|
||||
|
||||
HashMap<String, Object> creationError = this.accountNumberPreferencesHelper.createAccountNumberPreferenceWithInvalidData(
|
||||
this.responseForbiddenError, accountType, prefixType, "");
|
||||
|
||||
Assert.assertEquals("error.msg.account.number.format.duplicate.account.type",
|
||||
creationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
}
|
||||
|
||||
private void createAccountNumberPreferenceInvalidData(final String accountType, final String prefixType) {
|
||||
|
||||
/* Creating account Preference with invalid data should fail */
|
||||
System.out
|
||||
.println("---------------------------------CREATING ACCOUNT NUMBER PREFERENCE WITH INVALID DATA------------------------------------------");
|
||||
|
||||
HashMap<String, Object> creationError = this.accountNumberPreferencesHelper.createAccountNumberPreferenceWithInvalidData(
|
||||
this.responseValidationError, accountType, prefixType, "");
|
||||
|
||||
if (creationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE).equals(
|
||||
"validation.msg.accountNumberFormat.accountType.is.not.within.expected.range")) {
|
||||
Assert.assertEquals("validation.msg.accountNumberFormat.accountType.is.not.within.expected.range",
|
||||
creationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
} else if (creationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE).equals(
|
||||
"validation.msg.accountNumberFormat.prefixType.is.not.one.of.expected.enumerations")) {
|
||||
Assert.assertEquals("validation.msg.accountNumberFormat.prefixType.is.not.one.of.expected.enumerations",
|
||||
creationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
}
|
||||
}
|
||||
|
||||
private void updateAccountNumberPreference() {
|
||||
HashMap<String, Object> accountNumberPreferences = this.accountNumberPreferencesHelper.updateAccountNumberPreference(
|
||||
this.clientAccountNumberPreferenceId, "101", this.responseSpec, "");
|
||||
|
||||
System.out.println("--------------------------UPDATION SUCCESSFUL FOR ACCOUNT NUMBER PREFERENCE ID "
|
||||
+ accountNumberPreferences.get("resourceId"));
|
||||
|
||||
this.accountNumberPreferencesHelper.verifyUpdationOfAccountNumberPreferences((Integer) accountNumberPreferences.get("resourceId"),
|
||||
this.responseSpec, this.requestSpec);
|
||||
|
||||
/* Update invalid account preference id should fail */
|
||||
System.out
|
||||
.println("---------------------------------UPDATING ACCOUNT NUMBER PREFERENCE WITH INVALID DATA------------------------------------------");
|
||||
|
||||
/* Invalid Account Type */
|
||||
HashMap<String, Object> updationError = this.accountNumberPreferencesHelper.updateAccountNumberPreference(9999, "101",
|
||||
this.responseNotFoundError, "");
|
||||
if (updationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE).equals("error.msg.resource.not.found")) {
|
||||
Assert.assertEquals("error.msg.resource.not.found", updationError.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
}
|
||||
/* Invalid Prefix Type */
|
||||
HashMap<String, Object> updationError1 = this.accountNumberPreferencesHelper.updateAccountNumberPreference(
|
||||
this.clientAccountNumberPreferenceId, "103", this.responseValidationError, "");
|
||||
|
||||
Assert.assertEquals("validation.msg.validation.errors.exist", updationError1.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
}
|
||||
|
||||
private void createAndValidateClientEntity(Boolean isAccountPreferenceSetUp) {
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
if (isAccountPreferenceSetUp) {
|
||||
this.createAndValidateClientBasedOnAccountPreference();
|
||||
} else {
|
||||
this.createAndValidateClientWithoutAccountPreference();
|
||||
}
|
||||
}
|
||||
|
||||
private void createAndValidateGroup(Boolean isAccountPreferenceSetUp) {
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
this.groupID = GroupHelper.createGroup(this.requestSpec, this.responseSpec);
|
||||
GroupHelper.verifyGroupCreatedOnServer(this.requestSpec, this.responseSpec, groupID);
|
||||
|
||||
this.groupID = GroupHelper.activateGroup(this.requestSpec, this.responseSpec, groupID.toString());
|
||||
GroupHelper.verifyGroupActivatedOnServer(this.requestSpec, this.responseSpec, groupID, true);
|
||||
|
||||
final String GROUP_URL = "/mifosng-provider/api/v1/groups/" + this.groupID + "?" + Utils.TENANT_IDENTIFIER;
|
||||
this.groupAccountNo = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "accountNo");
|
||||
|
||||
if (isAccountPreferenceSetUp) {
|
||||
String groupsPrefixName = (String) this.accountNumberPreferencesHelper.getAccountNumberPreference(
|
||||
this.groupsAccountNumberPreferenceId, "prefixType.value");
|
||||
|
||||
if (groupsPrefixName.equals(this.officeName)) {
|
||||
|
||||
final String groupOfficeName = Utils.performServerGet(requestSpec, responseSpec, GROUP_URL, "officeName");
|
||||
|
||||
this.validateAccountNumberLengthAndStartsWithPrefix(this.groupAccountNo, groupOfficeName);
|
||||
}
|
||||
} else {
|
||||
validateAccountNumberLengthAndStartsWithPrefix(this.groupAccountNo, null);
|
||||
}
|
||||
}
|
||||
|
||||
private void createAndValidateCenter(Boolean isAccountPreferenceSetUp) {
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
Integer officeId = new OfficeHelper(requestSpec, responseSpec).createOffice("01 July 2007");
|
||||
|
||||
String name = "CenterCreation" + new Timestamp(new java.util.Date().getTime());
|
||||
this.centerId = CenterHelper.createCenter(name, officeId, requestSpec, responseSpec);
|
||||
CenterDomain center = CenterHelper.retrieveByID(centerId, requestSpec, responseSpec);
|
||||
Assert.assertNotNull(center);
|
||||
Assert.assertTrue(center.getName().equals(name));
|
||||
|
||||
if (isAccountPreferenceSetUp) {
|
||||
String centerPrefixName = (String) this.accountNumberPreferencesHelper.getAccountNumberPreference(
|
||||
this.centerAccountNumberPreferenceId, "prefixType.value");
|
||||
final String CENTER_URL = "/mifosng-provider/api/v1/centers/" + this.centerId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
|
||||
if (centerPrefixName.equals(this.officeName)) {
|
||||
final String centerOfficeName = Utils.performServerGet(requestSpec, responseSpec, CENTER_URL, "officeName");
|
||||
this.validateAccountNumberLengthAndStartsWithPrefix(center.getAccountNo(), centerOfficeName);
|
||||
}
|
||||
} else {
|
||||
validateAccountNumberLengthAndStartsWithPrefix(center.getAccountNo(), null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void createAndValidateClientWithoutAccountPreference() {
|
||||
this.clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(this.clientId);
|
||||
String clientAccountNo = (String) ClientHelper.getClient(requestSpec, responseSpec, this.clientId.toString(), "accountNo");
|
||||
validateAccountNumberLengthAndStartsWithPrefix(clientAccountNo, null);
|
||||
}
|
||||
|
||||
private void createAndValidateClientBasedOnAccountPreference() {
|
||||
final String codeName = "ClientType";
|
||||
String clientAccountNo = null;
|
||||
String clientPrefixName = (String) this.accountNumberPreferencesHelper.getAccountNumberPreference(
|
||||
this.clientAccountNumberPreferenceId, "prefixType.value");
|
||||
if (clientPrefixName.equals(this.clientTypeName)) {
|
||||
|
||||
/* Retrieve Code id for the Code "ClientType" */
|
||||
HashMap<String, Object> code = CodeHelper.getCodeByName(this.requestSpec, this.responseSpec, codeName);
|
||||
this.clientTypeCodeId = (Integer) code.get("id");
|
||||
|
||||
/* Retrieve/Create Code Values for the Code "ClientType" */
|
||||
HashMap<String, Object> codeValue = CodeHelper.retrieveOrCreateCodeValue(this.clientTypeCodeId, this.requestSpec,
|
||||
this.responseSpec);
|
||||
|
||||
this.clientCodeValueName = (String) codeValue.get("name");
|
||||
this.clientCodeValueId = (Integer) codeValue.get("id");
|
||||
|
||||
/* Create Client with Client Type */
|
||||
this.clientId = ClientHelper.createClientForAccountPreference(this.requestSpec, this.responseSpec, this.clientCodeValueId,
|
||||
"clientId");
|
||||
|
||||
Assert.assertNotNull(clientId);
|
||||
|
||||
clientAccountNo = (String) ClientHelper.getClient(this.requestSpec, this.responseSpec, this.clientId.toString(), "accountNo");
|
||||
this.validateAccountNumberLengthAndStartsWithPrefix(clientAccountNo, this.clientCodeValueName);
|
||||
|
||||
} else if (clientPrefixName.equals(this.officeName)) {
|
||||
this.clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientId);
|
||||
clientAccountNo = (String) ClientHelper.getClient(requestSpec, responseSpec, this.clientId.toString(), "accountNo");
|
||||
String officeName = (String) ClientHelper.getClient(requestSpec, responseSpec, this.clientId.toString(), "officeName");
|
||||
this.validateAccountNumberLengthAndStartsWithPrefix(clientAccountNo, officeName);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateAccountNumberLengthAndStartsWithPrefix(final String accountNumber, final String prefix) {
|
||||
if (prefix != null) {
|
||||
Assert.assertEquals(accountNumber.length(), prefix.length() + 9);
|
||||
Assert.assertTrue(accountNumber.startsWith(prefix));
|
||||
} else {
|
||||
Assert.assertEquals(accountNumber.length(), 9);
|
||||
}
|
||||
}
|
||||
|
||||
private void createLoanProduct() {
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
|
||||
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 + ")");
|
||||
}
|
||||
|
||||
private void createAndValidateLoanEntity(Boolean isAccountPreferenceSetUp) {
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
|
||||
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);
|
||||
|
||||
System.out.println("Loan Application :" + loanApplicationJSON);
|
||||
|
||||
this.loanId = this.loanTransactionHelper.getLoanId(loanApplicationJSON);
|
||||
String loanAccountNo = (String) this.loanTransactionHelper.getLoanDetail(this.requestSpec, this.responseSpec, this.loanId,
|
||||
"accountNo");
|
||||
|
||||
if (isAccountPreferenceSetUp) {
|
||||
String loanPrefixName = (String) this.accountNumberPreferencesHelper.getAccountNumberPreference(
|
||||
this.loanAccountNumberPreferenceId, "prefixType.value");
|
||||
if (loanPrefixName.equals(this.officeName)) {
|
||||
String loanOfficeName = (String) ClientHelper.getClient(requestSpec, responseSpec, this.clientId.toString(), "officeName");
|
||||
this.validateAccountNumberLengthAndStartsWithPrefix(loanAccountNo, loanOfficeName);
|
||||
} else if (loanPrefixName.equals(this.loanShortName)) {
|
||||
String loanShortName = (String) this.loanTransactionHelper.getLoanProductDetail(this.requestSpec, this.responseSpec,
|
||||
this.loanProductId, "shortName");
|
||||
this.validateAccountNumberLengthAndStartsWithPrefix(loanAccountNo, loanShortName);
|
||||
}
|
||||
System.out.println("SUCCESSFULLY CREATED LOAN APPLICATION BASED ON ACCOUNT PREFERENCES (ID: " + this.loanId + ")");
|
||||
} else {
|
||||
this.validateAccountNumberLengthAndStartsWithPrefix(loanAccountNo, null);
|
||||
System.out.println("SUCCESSFULLY CREATED LOAN APPLICATION (ID: " + loanId + ")");
|
||||
}
|
||||
}
|
||||
|
||||
private void createSavingsProduct() {
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
|
||||
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(this.MINIMUM_OPENING_BALANCE).build();
|
||||
this.savingsProductId = SavingsProductHelper.createSavingsProduct(savingsProductJSON, this.requestSpec, this.responseSpec);
|
||||
System.out.println("Sucessfully created savings product (ID: " + this.savingsProductId + ")");
|
||||
|
||||
}
|
||||
|
||||
private void createAndValidateSavingsEntity(Boolean isAccountPreferenceSetUp) {
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
|
||||
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
this.savingsId = this.savingsAccountHelper
|
||||
.applyForSavingsApplication(this.clientId, this.savingsProductId, ACCOUNT_TYPE_INDIVIDUAL);
|
||||
|
||||
String savingsAccountNo = (String) this.savingsAccountHelper.getSavingsAccountDetail(this.savingsId, "accountNo");
|
||||
|
||||
if (isAccountPreferenceSetUp) {
|
||||
String savingsPrefixName = (String) this.accountNumberPreferencesHelper.getAccountNumberPreference(
|
||||
this.savingsAccountNumberPreferenceId, "prefixType.value");
|
||||
|
||||
if (savingsPrefixName.equals(this.officeName)) {
|
||||
String savingsOfficeName = (String) ClientHelper.getClient(requestSpec, responseSpec, this.clientId.toString(),
|
||||
"officeName");
|
||||
this.validateAccountNumberLengthAndStartsWithPrefix(savingsAccountNo, savingsOfficeName);
|
||||
} else if (savingsPrefixName.equals(this.savingsShortName)) {
|
||||
String loanShortName = (String) this.savingsAccountHelper.getSavingsAccountDetail(this.savingsId, "shortName");
|
||||
this.validateAccountNumberLengthAndStartsWithPrefix(savingsAccountNo, loanShortName);
|
||||
}
|
||||
System.out.println("SUCCESSFULLY CREATED SAVINGS APPLICATION BASED ON ACCOUNT PREFERENCES (ID: " + this.loanId + ")");
|
||||
} else {
|
||||
this.validateAccountNumberLengthAndStartsWithPrefix(savingsAccountNo, null);
|
||||
System.out.println("SUCCESSFULLY CREATED SAVINGS APPLICATION (ID: " + this.savingsId + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
+58
@@ -658,6 +658,64 @@ public class AccountingScenarioIntegrationTest {
|
||||
System.out.println("Repayment 5 Done ......");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkPeriodicAccrualAccountingFlow_OVER_PAYMENT() {
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(this.EXPECTED_DISBURSAL_DATE, loanID);
|
||||
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
|
||||
|
||||
// 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, this.EXPECTED_DISBURSAL_DATE, assetAccountInitialEntry);
|
||||
|
||||
final String jobName = "Add Accrual Transactions";
|
||||
try {
|
||||
this.schedulerJobHelper.executeJob(jobName);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// MAKE 1
|
||||
System.out.println("Repayment 1 ......");
|
||||
final float FIRST_INTEREST = 200.0f;
|
||||
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.makeRepayment(this.REPAYMENT_DATE[1], 15000f, loanID);
|
||||
float expected_value = this.LP_PRINCIPAL - PRINCIPAL_VALUE_FOR_EACH_PERIOD;
|
||||
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(1, expected_value, loanID);
|
||||
final JournalEntry[] assetAccountEntry = { new JournalEntry(15000f, JournalEntry.TransactionType.DEBIT),
|
||||
new JournalEntry(1000f, JournalEntry.TransactionType.CREDIT), new JournalEntry(10000f, JournalEntry.TransactionType.CREDIT) };
|
||||
this.journalEntryHelper.checkJournalEntryForAssetAccount(assetAccount, this.REPAYMENT_DATE[1], assetAccountEntry);
|
||||
this.journalEntryHelper.checkJournalEntryForLiabilityAccount(overpaymentAccount, this.REPAYMENT_DATE[1], new JournalEntry(4000f,
|
||||
JournalEntry.TransactionType.CREDIT));
|
||||
System.out.println("Repayment Done......");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkPeriodicAccrualAccountingTillCurrentDateFlow() {
|
||||
final Account assetAccount = this.accountHelper.createAssetAccount();
|
||||
|
||||
+248
@@ -0,0 +1,248 @@
|
||||
/**
|
||||
* 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.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mifosplatform.integrationtests.common.CenterDomain;
|
||||
import org.mifosplatform.integrationtests.common.CenterHelper;
|
||||
import org.mifosplatform.integrationtests.common.OfficeHelper;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
import org.mifosplatform.integrationtests.common.organisation.StaffHelper;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
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 CenterIntegrationTest {
|
||||
|
||||
private RequestSpecification requestSpec;
|
||||
private ResponseSpecification responseSpec;
|
||||
|
||||
@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 testBasicCenterCreation() {
|
||||
int officeId = new OfficeHelper(requestSpec, responseSpec).createOffice("01 July 2007");
|
||||
|
||||
String name = "TestBasicCreation" + new Timestamp(new java.util.Date().getTime());
|
||||
int resourceId = CenterHelper.createCenter(name, officeId, requestSpec, responseSpec);
|
||||
CenterDomain center = CenterHelper.retrieveByID(resourceId, requestSpec, responseSpec);
|
||||
|
||||
Assert.assertNotNull(center);
|
||||
Assert.assertTrue(center.getName().equals(name));
|
||||
Assert.assertTrue(center.getOfficeId() == officeId);
|
||||
Assert.assertTrue(center.isActive() == false);
|
||||
|
||||
// Test retrieval by listing all centers
|
||||
int id = CenterHelper.listCenters(requestSpec, responseSpec).get(0).getId();
|
||||
Assert.assertTrue(id > 0);
|
||||
|
||||
CenterDomain retrievedCenter = CenterHelper.retrieveByID(id, requestSpec, responseSpec);
|
||||
Assert.assertNotNull(retrievedCenter);
|
||||
Assert.assertNotNull(retrievedCenter.getName());
|
||||
Assert.assertNotNull(retrievedCenter.getHierarchy());
|
||||
Assert.assertNotNull(retrievedCenter.getOfficeName());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFullCenterCreation() {
|
||||
|
||||
int officeId = new OfficeHelper(requestSpec, responseSpec).createOffice("01 July 2007");
|
||||
String name = "TestFullCreation" + new Timestamp(new java.util.Date().getTime());
|
||||
String externalId = Utils.randomStringGenerator("ID_", 7, "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||
int staffId = StaffHelper.createStaff(requestSpec, responseSpec);
|
||||
int[] groupMembers = generateGroupMembers(3, officeId);
|
||||
int resourceId = CenterHelper.createCenter(name, officeId, externalId, staffId, groupMembers, requestSpec, responseSpec);
|
||||
CenterDomain center = CenterHelper.retrieveByID(resourceId, requestSpec, responseSpec);
|
||||
|
||||
Assert.assertNotNull(center);
|
||||
Assert.assertTrue(center.getName().equals(name));
|
||||
Assert.assertTrue(center.getOfficeId() == officeId);
|
||||
Assert.assertTrue(center.getExternalId().equals(externalId));
|
||||
Assert.assertTrue(center.getStaffId() == staffId);
|
||||
Assert.assertTrue(center.isActive() == false);
|
||||
Assert.assertArrayEquals(center.getGroupMembers(), groupMembers);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListCenters() {
|
||||
ArrayList<CenterDomain> paginatedList = CenterHelper.paginatedListCenters(requestSpec, responseSpec);
|
||||
ArrayList<CenterDomain> list = CenterHelper.listCenters(requestSpec, responseSpec);
|
||||
|
||||
Assert.assertNotNull(paginatedList);
|
||||
Assert.assertNotNull(list);
|
||||
Assert.assertTrue(Arrays.equals(paginatedList.toArray(new CenterDomain[paginatedList.size()]),
|
||||
list.toArray(new CenterDomain[list.size()])));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVoidCenterRetrieval() {
|
||||
ArrayList<CenterDomain> arr = CenterHelper.listCenters(requestSpec, responseSpec);
|
||||
int id = arr.get(arr.size() - 1).getId() + 1;
|
||||
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(404).build();
|
||||
CenterDomain center = CenterHelper.retrieveByID(id, requestSpec, responseSpec);
|
||||
Assert.assertNotNull(center);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Test
|
||||
public void testCenterUpdate() {
|
||||
int officeId = new OfficeHelper(requestSpec, responseSpec).createOffice("01 July 2007");
|
||||
String name = "TestFullCreation" + new Timestamp(new java.util.Date().getTime());
|
||||
String externalId = Utils.randomStringGenerator("ID_", 7, "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||
int staffId = StaffHelper.createStaff(requestSpec, responseSpec);
|
||||
int[] groupMembers = generateGroupMembers(3, officeId);
|
||||
int resourceId = CenterHelper.createCenter(name, officeId, externalId, staffId, groupMembers, requestSpec, responseSpec);
|
||||
|
||||
String newName = "TestCenterUpdateNew" + new Timestamp(new java.util.Date().getTime());
|
||||
String newExternalId = Utils.randomStringGenerator("newID_", 7, "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||
int newStaffId = StaffHelper.createStaff(requestSpec, responseSpec);
|
||||
int[] associateGroupMembers = generateGroupMembers(2, officeId);
|
||||
|
||||
int[] associateResponse = CenterHelper.associateGroups(resourceId, associateGroupMembers, requestSpec, responseSpec);
|
||||
Arrays.sort(associateResponse);
|
||||
Arrays.sort(associateGroupMembers);
|
||||
Assert.assertArrayEquals(associateResponse, associateGroupMembers);
|
||||
|
||||
int[] newGroupMembers = new int[5];
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (i < 3) {
|
||||
newGroupMembers[i] = groupMembers[i];
|
||||
} else {
|
||||
newGroupMembers[i] = associateGroupMembers[i % 3];
|
||||
}
|
||||
}
|
||||
|
||||
HashMap request = new HashMap();
|
||||
request.put("name", newName);
|
||||
request.put("externalId", newExternalId);
|
||||
request.put("staffId", newStaffId);
|
||||
HashMap response = CenterHelper.updateCenter(resourceId, request, requestSpec, responseSpec);
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(newName, response.get("name"));
|
||||
Assert.assertEquals(newExternalId, response.get("externalId"));
|
||||
Assert.assertEquals(newStaffId, response.get("staffId"));
|
||||
|
||||
CenterDomain center = CenterHelper.retrieveByID(resourceId, requestSpec, responseSpec);
|
||||
Assert.assertNotNull(center);
|
||||
Assert.assertEquals(newName, center.getName());
|
||||
Assert.assertEquals(newExternalId, center.getExternalId());
|
||||
Assert.assertEquals((Integer)newStaffId, center.getStaffId());
|
||||
Assert.assertArrayEquals(newGroupMembers, center.getGroupMembers());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCenterDeletion() {
|
||||
int officeId = new OfficeHelper(requestSpec, responseSpec).createOffice("01 July 2007");
|
||||
String name = "TestBasicCreation" + new Timestamp(new java.util.Date().getTime());
|
||||
int resourceId = CenterHelper.createCenter(name, officeId, requestSpec, responseSpec);
|
||||
|
||||
CenterHelper.deleteCenter(resourceId, requestSpec, responseSpec);
|
||||
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(404).build();
|
||||
CenterDomain center = CenterHelper.retrieveByID(resourceId, requestSpec, responseSpec);
|
||||
Assert.assertNotNull(center);
|
||||
}
|
||||
|
||||
private int[] generateGroupMembers(int size, int officeId) {
|
||||
int[] groupMembers = new int[size];
|
||||
for (int i = 0; i < groupMembers.length; i++) {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("officeId", "" + officeId);
|
||||
map.put("name", Utils.randomStringGenerator("Group_Name_", 5));
|
||||
map.put("externalId", Utils.randomStringGenerator("ID_", 7, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("locale", "en");
|
||||
map.put("active", "true");
|
||||
map.put("activationDate", "04 March 2011");
|
||||
|
||||
groupMembers[i] = Utils.performServerPost(requestSpec, responseSpec, "/mifosng-provider/api/v1/groups?"
|
||||
+ Utils.TENANT_IDENTIFIER, new Gson().toJson(map), "groupId");
|
||||
}
|
||||
return groupMembers;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStaffAssignmentDuringCenterCreation() {
|
||||
|
||||
Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
|
||||
System.out.println("--------------creating first staff with id-------------" + staffId);
|
||||
Assert.assertNotNull(staffId);
|
||||
|
||||
int centerWithStaffId = CenterHelper.createCenterWithStaffId(this.requestSpec, this.responseSpec, staffId);
|
||||
CenterDomain center = CenterHelper.retrieveByID(centerWithStaffId, requestSpec, responseSpec);
|
||||
Assert.assertNotNull(center);
|
||||
Assert.assertTrue(center.getId() == centerWithStaffId);
|
||||
Assert.assertTrue(center.getStaffId() == staffId);
|
||||
Assert.assertTrue(center.isActive() == true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAssignStaffToCenter() {
|
||||
Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
|
||||
System.out.println("--------------creating first staff with id-------------" + staffId);
|
||||
Assert.assertNotNull(staffId);
|
||||
|
||||
Integer groupID = CenterHelper.createCenter(this.requestSpec, this.responseSpec);
|
||||
CenterHelper.verifyCenterCreatedOnServer(this.requestSpec, this.responseSpec, groupID);
|
||||
|
||||
HashMap assignStaffToCenterResponseMap = (HashMap) CenterHelper.assignStaff(this.requestSpec, this.responseSpec, groupID.toString(),
|
||||
staffId.longValue());
|
||||
assertEquals("Verify assigned staff id is the same as id sent", assignStaffToCenterResponseMap.get("staffId"), staffId);
|
||||
|
||||
CenterDomain center = CenterHelper.retrieveByID(groupID, requestSpec, responseSpec);
|
||||
Assert.assertNotNull(center);
|
||||
Assert.assertTrue(center.getId() == groupID);
|
||||
Assert.assertTrue(center.getStaffId() == staffId);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnassignStaffToCenter() {
|
||||
Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
|
||||
System.out.println("--------------creating first staff with id-------------" + staffId);
|
||||
Assert.assertNotNull(staffId);
|
||||
|
||||
Integer groupID = CenterHelper.createCenter(this.requestSpec, this.responseSpec);
|
||||
CenterHelper.verifyCenterCreatedOnServer(this.requestSpec, this.responseSpec, groupID);
|
||||
|
||||
HashMap assignStaffToCenterResponseMap = (HashMap) CenterHelper.assignStaff(this.requestSpec, this.responseSpec, groupID.toString(),
|
||||
staffId.longValue());
|
||||
assertEquals("Verify assigned staff id is the same as id sent", assignStaffToCenterResponseMap.get("staffId"), staffId);
|
||||
CenterDomain centerWithStaffAssigned = CenterHelper.retrieveByID(groupID, requestSpec, responseSpec);
|
||||
Assert.assertNotNull(centerWithStaffAssigned);
|
||||
Assert.assertTrue(centerWithStaffAssigned.getId() == groupID);
|
||||
Assert.assertTrue(centerWithStaffAssigned.getStaffId() == staffId);
|
||||
|
||||
HashMap unassignStaffToCenterResponseMap = (HashMap) CenterHelper.unassignStaff(this.requestSpec, this.responseSpec, groupID.toString(),
|
||||
staffId.longValue());
|
||||
assertEquals("Verify staffId is null after unassigning ", unassignStaffToCenterResponseMap.get("staffId"), null);
|
||||
CenterDomain centerWithStaffUnssigned = CenterHelper.retrieveByID(groupID, requestSpec, responseSpec);
|
||||
Assert.assertNotNull(centerWithStaffUnssigned);
|
||||
Assert.assertTrue(centerWithStaffUnssigned.getId() == groupID);
|
||||
Assert.assertTrue(centerWithStaffUnssigned.getStaffId() == null);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+1518
-336
File diff suppressed because it is too large
Load Diff
+8
-1
@@ -205,7 +205,7 @@ public class ClientSavingsIntegrationTest {
|
||||
final String openningBalance = "1600";
|
||||
final String enforceMinRequiredBalance = "true";
|
||||
final boolean allowOverdraft = false;
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, openningBalance ,
|
||||
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, openningBalance,
|
||||
minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance, allowOverdraft);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
@@ -552,6 +552,13 @@ public class ClientSavingsIntegrationTest {
|
||||
HashMap paidCharge = this.savingsAccountHelper.getSavingsCharge(savingsId, (Integer) savingsChargeForPay.get("id"));
|
||||
assertEquals(savingsChargeForPay.get("amount"), paidCharge.get("amountPaid"));
|
||||
|
||||
// temporary fix, this test case needs to be re-factored (will fail
|
||||
// again on Jan 15 2016)
|
||||
cal.set(Calendar.YEAR, (Integer) dates.get(0) + 1);
|
||||
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"));
|
||||
|
||||
Integer inactivatedChargeId = (Integer) this.savingsAccountHelper.inactivateCharge(annualSavingsChargeId, savingsId,
|
||||
CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
assertEquals("Inactivated Savings Charges Id", annualSavingsChargeId, inactivatedChargeId);
|
||||
|
||||
+34
-34
@@ -6,43 +6,43 @@
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
public static void verifyClientIsActive(final HashMap<String, Object> clientStatusHashMap) {
|
||||
assertEquals((int) clientStatusHashMap.get("id"), 300);
|
||||
}
|
||||
|
||||
public static void verifyClientClosed(final HashMap<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> clientStatusHashMap) {
|
||||
System.out.println("\n-------------------------------------- VERIFYING CLIENT IS WITHDRAWN ------------------------------------");
|
||||
assertEquals((int) clientStatusHashMap.get("id"), 800);
|
||||
System.out.println("Client Status:" + clientStatusHashMap + "\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+8
-17
@@ -11,14 +11,7 @@ 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;
|
||||
@@ -46,32 +39,30 @@ public class ClientTest {
|
||||
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));
|
||||
|
||||
HashMap<String, Object> status = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
|
||||
ClientStatusChecker.verifyClientIsActive(status);
|
||||
|
||||
HashMap clientStatusHashMap = this.clientHelper.closeClient(clientId);
|
||||
HashMap<String, Object> 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);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
/**
|
||||
* 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.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mifosplatform.integrationtests.common.ClientHelper;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
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 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 ConcurrencyIntegrationTest {
|
||||
|
||||
private ResponseSpecification responseSpec;
|
||||
private RequestSpecification requestSpec;
|
||||
private LoanTransactionHelper loanTransactionHelper;
|
||||
|
||||
private static final String NO_ACCOUNTING = "1";
|
||||
|
||||
final int MYTHREADS = 30;
|
||||
|
||||
@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.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyConcurrentLoanRepayments() {
|
||||
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
|
||||
final Integer loanProductID = createLoanProduct(false, NO_ACCOUNTING);
|
||||
final Integer loanID = applyForLoanApplication(clientID, loanProductID, "12,000.00");
|
||||
this.loanTransactionHelper.approveLoan("20 September 2011", loanID);
|
||||
this.loanTransactionHelper.disburseLoan("20 September 2011", loanID, "12,000.00");
|
||||
|
||||
ExecutorService executor = Executors.newFixedThreadPool(MYTHREADS);
|
||||
Calendar date = Calendar.getInstance();
|
||||
date.set(2011, 9, 20);
|
||||
Float repaymentAmount = 100.0f;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
System.out.println("Starting concurrent transaction number " + i);
|
||||
date.add(Calendar.DAY_OF_MONTH, 1);
|
||||
repaymentAmount = repaymentAmount + 100;
|
||||
Runnable worker = new LoanRepaymentExecutor(loanTransactionHelper, loanID, repaymentAmount, date);
|
||||
executor.execute(worker);
|
||||
}
|
||||
|
||||
executor.shutdown();
|
||||
// Wait until all threads are finish
|
||||
while (!executor.isTerminated()) {
|
||||
|
||||
}
|
||||
System.out.println("\nFinished all threads");
|
||||
|
||||
}
|
||||
|
||||
private Integer createLoanProduct(final boolean multiDisburseLoan, final String accountingRule, final Account... accounts) {
|
||||
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
|
||||
final String loanProductJSON = new LoanProductTestBuilder() //
|
||||
.withPrincipal("12,000.00") //
|
||||
.withNumberOfRepayments("4") //
|
||||
.withRepaymentAfterEvery("1") //
|
||||
.withRepaymentTypeAsMonth() //
|
||||
.withinterestRatePerPeriod("1") //
|
||||
.withInterestRateFrequencyTypeAsMonths() //
|
||||
.withAmortizationTypeAsEqualInstallments() //
|
||||
.withInterestTypeAsDecliningBalance() //
|
||||
.withTranches(multiDisburseLoan) //
|
||||
.withAccounting(accountingRule, accounts).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 2011") //
|
||||
.withSubmittedOnDate("20 September 2011") //
|
||||
.build(clientID.toString(), loanProductID.toString(), null);
|
||||
return this.loanTransactionHelper.getLoanId(loanApplicationJSON);
|
||||
}
|
||||
|
||||
public static class LoanRepaymentExecutor implements Runnable {
|
||||
|
||||
private final Integer loanId;
|
||||
private final Float repaymentAmount;
|
||||
private final String repaymentDate;
|
||||
private final LoanTransactionHelper loanTransactionHelper;
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
|
||||
|
||||
LoanRepaymentExecutor(LoanTransactionHelper loanTransactionHelper, Integer loanId, Float repaymentAmount, Calendar repaymentDate) {
|
||||
this.loanId = loanId;
|
||||
this.repaymentAmount = repaymentAmount;
|
||||
this.repaymentDate = dateFormat.format(repaymentDate.getTime());
|
||||
this.loanTransactionHelper = loanTransactionHelper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
this.loanTransactionHelper.makeRepayment(repaymentDate, repaymentAmount, loanId);
|
||||
} catch (Exception e) {
|
||||
System.out.println("Found an exception" + e.getMessage());
|
||||
System.out.println("Details of failed concurrent transaction (date, amount, loanId) are " + repaymentDate + ","
|
||||
+ repaymentAmount + "," + loanId);
|
||||
throw (e);
|
||||
}
|
||||
System.out.println("Details of passed concurrent transaction, details (date, amount, loanId) are " + repaymentDate + ","
|
||||
+ repaymentAmount + "," + loanId);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* 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.Collections;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mifosplatform.integrationtests.common.CurrenciesHelper;
|
||||
import org.mifosplatform.integrationtests.common.CurrencyDomain;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
|
||||
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({ "unused", "rawtypes" })
|
||||
public class CurrenciesTest {
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCurrencyElements() {
|
||||
|
||||
CurrencyDomain currency = CurrenciesHelper.getCurrencybyCode(requestSpec, responseSpec, "USD");
|
||||
CurrencyDomain usd = CurrencyDomain.create("USD", "US Dollar", 2, "$", "currency.USD", "US Dollar ($)").build();
|
||||
|
||||
Assert.assertTrue(currency.getDecimalPlaces() >= 0);
|
||||
Assert.assertNotNull(currency.getName());
|
||||
Assert.assertNotNull(currency.getDisplaySymbol());
|
||||
Assert.assertNotNull(currency.getDisplayLabel());
|
||||
Assert.assertNotNull(currency.getNameCode());
|
||||
|
||||
Assert.assertEquals(usd, currency);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateCurrencySelection() {
|
||||
|
||||
// Test updation
|
||||
ArrayList<String> currenciestoUpdate = new ArrayList<String>();
|
||||
currenciestoUpdate.add("KES");
|
||||
currenciestoUpdate.add("BND");
|
||||
currenciestoUpdate.add("LBP");
|
||||
currenciestoUpdate.add("GHC");
|
||||
currenciestoUpdate.add("USD");
|
||||
|
||||
ArrayList<String> currenciesOutput = CurrenciesHelper.updateSelectedCurrencies(this.requestSpec, this.responseSpec,
|
||||
currenciestoUpdate);
|
||||
Assert.assertNotNull(currenciesOutput);
|
||||
|
||||
Assert.assertEquals("Verifying Do Outputed Currencies Match after Updation", currenciestoUpdate, currenciesOutput);
|
||||
|
||||
// Test that output matches updation
|
||||
ArrayList<CurrencyDomain> currenciesBeforeUpdate = new ArrayList<CurrencyDomain>();
|
||||
for (String e : currenciestoUpdate) {
|
||||
currenciesBeforeUpdate.add(CurrenciesHelper.getCurrencybyCode(requestSpec, responseSpec, e));
|
||||
}
|
||||
Collections.sort(currenciesBeforeUpdate);
|
||||
|
||||
ArrayList<CurrencyDomain> currenciesAfterUpdate = CurrenciesHelper.getSelectedCurrencies(requestSpec, responseSpec);
|
||||
Assert.assertNotNull(currenciesAfterUpdate);
|
||||
|
||||
Assert.assertEquals("Verifying Do Selected Currencies Match after Updation", currenciesBeforeUpdate, currenciesAfterUpdate);
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* 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;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
import org.mifosplatform.integrationtests.common.savings.SavingsAccountHelper;
|
||||
|
||||
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 CurrencyIntegrationTest {
|
||||
|
||||
private ResponseSpecification responseSpec;
|
||||
private RequestSpecification requestSpec;
|
||||
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();
|
||||
}
|
||||
}
|
||||
+355
@@ -0,0 +1,355 @@
|
||||
/**
|
||||
* 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.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.mifosplatform.integrationtests.common.*;
|
||||
import org.mifosplatform.integrationtests.common.loans.*;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* Tests loan schedule change based on group meeting changes and loan
|
||||
* rescheduling
|
||||
**/
|
||||
@SuppressWarnings({ "rawtypes" })
|
||||
@Ignore
|
||||
public class DisbursalAndRepaymentScheduleTest {
|
||||
|
||||
private ResponseSpecification responseSpec;
|
||||
private ResponseSpecification responseSpecForStatusCode403;
|
||||
private ResponseSpecification generalResponseSpec;
|
||||
private RequestSpecification requestSpec;
|
||||
private LoanTransactionHelper loanTransactionHelper;
|
||||
private LoanRescheduleRequestHelper loanRescheduleRequestHelper;
|
||||
private Integer loanRescheduleRequestId;
|
||||
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 SimpleDateFormat dateFormatterMifosStandard = new SimpleDateFormat("dd MMMM yyyy");
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
Utils.initializeRESTAssured();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRescheduleJLGLoanSynk() {
|
||||
System.out.println("---------------------------------STARTING RESCHEDULE JLG LOAN TEST ------------------------------------------");
|
||||
|
||||
Calendar meetingCalendar = Calendar.getInstance();
|
||||
meetingCalendar.setFirstDayOfWeek(Calendar.MONDAY);
|
||||
meetingCalendar.setTime(new java.util.Date());
|
||||
|
||||
int today = meetingCalendar.get(Calendar.DAY_OF_WEEK);
|
||||
// making sure that the meeting calendar is set for the coming monday.
|
||||
if (today >= Calendar.MONDAY) {
|
||||
meetingCalendar.add(Calendar.DAY_OF_YEAR, +(Calendar.MONDAY - today + 7));
|
||||
} else {
|
||||
meetingCalendar.add(Calendar.DAY_OF_YEAR, +(Calendar.MONDAY - today));
|
||||
}
|
||||
|
||||
Calendar groupMeetingChangeCalendar = (Calendar) meetingCalendar.clone();
|
||||
|
||||
meetingCalendar.add(Calendar.WEEK_OF_YEAR, -3);
|
||||
|
||||
final String groupMeetingDate = this.dateFormatterMifosStandard.format(meetingCalendar.getTime());
|
||||
|
||||
final String disbursalDate = groupMeetingDate; // first meeting date
|
||||
// after group creation
|
||||
|
||||
final String rescheduleSubmittedDate = this.dateFormatterMifosStandard.format(new java.util.Date());
|
||||
|
||||
final String loanType = "jlg";
|
||||
final String rescheduleInterestRate = "28.0";
|
||||
groupMeetingChangeCalendar.add(Calendar.DAY_OF_YEAR, 1);
|
||||
final String groupMeetingNewStartDate = this.dateFormatterMifosStandard.format(groupMeetingChangeCalendar.getTime());
|
||||
// The date
|
||||
// from
|
||||
// which we
|
||||
// start the
|
||||
// new group
|
||||
// meeting
|
||||
// occasion,
|
||||
// this is a
|
||||
// tuesday.
|
||||
groupMeetingChangeCalendar.add(Calendar.WEEK_OF_YEAR, 2);
|
||||
final String rescheduleDate = this.dateFormatterMifosStandard.format(groupMeetingChangeCalendar.getTime());
|
||||
|
||||
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
this.requestSpec.header("X-Mifos-Platform-TenantId", "default");
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
this.generalResponseSpec = new ResponseSpecBuilder().build();
|
||||
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
this.loanRescheduleRequestHelper = new LoanRescheduleRequestHelper(this.requestSpec, this.responseSpec);
|
||||
System.out.println("---------------------------------CREATING ENTITIES AND JLG LOAN ------------------------------------------");
|
||||
// create all required entities
|
||||
this.createRequiredEntitiesForJLGLoanSync(groupMeetingDate);
|
||||
|
||||
final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(loanPrincipalAmount).withLoanTermFrequency("24")
|
||||
.withLoanTermFrequencyAsWeeks().withNumberOfRepayments("12").withRepaymentEveryAfter("2")
|
||||
.withRepaymentFrequencyTypeAsMonths().withAmortizationTypeAsEqualInstallments().withInterestCalculationPeriodTypeAsDays()
|
||||
.withInterestRatePerPeriod(interestRatePerPeriod).withRepaymentFrequencyTypeAsWeeks().withSubmittedOnDate(disbursalDate)
|
||||
.withExpectedDisbursementDate(disbursalDate).withLoanType(loanType).withSyncDisbursementWithMeetin()
|
||||
.withCalendarID(this.groupCalendarId.toString())
|
||||
.build(this.clientId.toString(), this.groupId.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);
|
||||
|
||||
System.out.println("---------------------------------CHANGING GROUP MEETING DATE ------------------------------------------");
|
||||
CalendarHelper.updateMeetingCalendarForGroup(this.requestSpec, this.responseSpec, this.groupId, this.groupCalendarId.toString(),
|
||||
groupMeetingNewStartDate, "2", "2", "2"); // New meeting dates
|
||||
// will be the tuesday
|
||||
// after the
|
||||
// coming
|
||||
// monday
|
||||
|
||||
ArrayList loanRepaymnetSchedule = this.loanTransactionHelper
|
||||
.getLoanRepaymentSchedule(requestSpec, generalResponseSpec, this.loanId);
|
||||
|
||||
ArrayList dueDateLoanSchedule = (ArrayList) ((HashMap) loanRepaymnetSchedule.get(2)).get("dueDate");
|
||||
Calendar dueDateCalendar = Calendar.getInstance();
|
||||
dueDateCalendar.setFirstDayOfWeek(Calendar.MONDAY);
|
||||
dueDateCalendar.set((Integer) dueDateLoanSchedule.get(0), (Integer) dueDateLoanSchedule.get(1) - 1,
|
||||
(Integer) dueDateLoanSchedule.get(2));
|
||||
assertEquals("AFTER MEETING CHANGE DATE THE NEXT REPAYMENT SHOULD BE ON TUESDAY", 3, dueDateCalendar.get(Calendar.DAY_OF_WEEK));
|
||||
|
||||
System.out.println("---------------------------------CREATING LOAN RESCHEDULE REQUEST------------------------------------------");
|
||||
|
||||
String requestJSON = new LoanRescheduleRequestTestBuilder().updateGraceOnInterest("2").updateGraceOnPrincipal("2")
|
||||
.updateNewInterestRate(rescheduleInterestRate).updateRescheduleFromDate(rescheduleDate)
|
||||
.updateSubmittedOnDate(rescheduleSubmittedDate).build(this.loanId.toString());
|
||||
|
||||
this.loanRescheduleRequestId = this.loanRescheduleRequestHelper.createLoanRescheduleRequest(requestJSON);
|
||||
this.loanRescheduleRequestHelper.verifyCreationOfLoanRescheduleRequest(this.loanRescheduleRequestId);
|
||||
|
||||
loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, generalResponseSpec, this.loanId);
|
||||
dueDateLoanSchedule = (ArrayList) ((HashMap) loanRepaymnetSchedule.get(2)).get("dueDate");
|
||||
dueDateCalendar.set((Integer) dueDateLoanSchedule.get(0), (Integer) dueDateLoanSchedule.get(1) - 1,
|
||||
(Integer) dueDateLoanSchedule.get(2));
|
||||
assertEquals("AFTER MEETING CHANGE DATE THE NEXT REPAYMENT SHOULD BE ON TUESDAY, EVEN AFTER LOAN RESCHEDULE REQUEST WAS SENT", 3,
|
||||
dueDateCalendar.get(Calendar.DAY_OF_WEEK));
|
||||
|
||||
System.out.println("Successfully created loan reschedule request (ID: " + this.loanRescheduleRequestId + ")");
|
||||
|
||||
System.out.println("-----------------------------APPROVING LOAN RESCHEDULE REQUEST--------------------------");
|
||||
|
||||
requestJSON = new LoanRescheduleRequestTestBuilder().updateSubmittedOnDate(rescheduleSubmittedDate)
|
||||
.getApproveLoanRescheduleRequestJSON();
|
||||
this.loanRescheduleRequestHelper.approveLoanRescheduleRequest(this.loanRescheduleRequestId, requestJSON);
|
||||
|
||||
final HashMap response = (HashMap) this.loanRescheduleRequestHelper.getLoanRescheduleRequest(loanRescheduleRequestId, "statusEnum");
|
||||
assertTrue((Boolean) response.get("approved"));
|
||||
|
||||
loanRepaymnetSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(requestSpec, generalResponseSpec, this.loanId);
|
||||
|
||||
dueDateLoanSchedule = (ArrayList) ((HashMap) loanRepaymnetSchedule.get(2)).get("dueDate");
|
||||
dueDateCalendar.set((Integer) dueDateLoanSchedule.get(0), (Integer) dueDateLoanSchedule.get(1) - 1,
|
||||
(Integer) dueDateLoanSchedule.get(2));
|
||||
assertEquals("AFTER MEETING CHANGE DATE THE NEXT REPAYMENT SHOULD BE ON TUESDAY, EVEN AFTER RESCHEDULE", 3,
|
||||
dueDateCalendar.get(Calendar.DAY_OF_WEEK));
|
||||
System.out.println("Successfully changed group meeting date (CAELNDAR ID: " + this.groupCalendarId
|
||||
+ ") and rescheduled loan (RESCHEDULE ID: " + this.loanRescheduleRequestId + ")");
|
||||
|
||||
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpecForStatusCode403);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChangeGroupMeetingMaturedOnDate() {
|
||||
System.out
|
||||
.println("---------------------------------STARTING GROUP LOAN MEETING CHANGE DATE EXPECTED MATURED CHANGE------------------------------------------");
|
||||
|
||||
Calendar meetingCalendar = Calendar.getInstance();
|
||||
meetingCalendar.setFirstDayOfWeek(Calendar.MONDAY);
|
||||
meetingCalendar.setTime(new java.util.Date());
|
||||
|
||||
int today = meetingCalendar.get(Calendar.DAY_OF_WEEK);
|
||||
// making sure that the meeting calendar is set for the coming monday.
|
||||
if (today >= Calendar.MONDAY) {
|
||||
meetingCalendar.add(Calendar.DAY_OF_YEAR, +(Calendar.MONDAY - today + 7));
|
||||
} else {
|
||||
meetingCalendar.add(Calendar.DAY_OF_YEAR, +(Calendar.MONDAY - today));
|
||||
}
|
||||
|
||||
Calendar groupMeetingChangeCalendar = (Calendar) meetingCalendar.clone();
|
||||
|
||||
meetingCalendar.add(Calendar.WEEK_OF_YEAR, -3);
|
||||
|
||||
final String groupMeetingDate = this.dateFormatterMifosStandard.format(meetingCalendar.getTime());
|
||||
|
||||
final String disbursalDate = groupMeetingDate; // first meeting date
|
||||
// after group creation
|
||||
|
||||
final String loanType = "jlg";
|
||||
groupMeetingChangeCalendar.add(Calendar.DAY_OF_YEAR, 1);
|
||||
final String groupMeetingNewStartDate = this.dateFormatterMifosStandard.format(groupMeetingChangeCalendar.getTime());
|
||||
// The date
|
||||
// from
|
||||
// which we
|
||||
// start the
|
||||
// new group
|
||||
// meeting
|
||||
// occasion,
|
||||
// this is a
|
||||
// tuesday.
|
||||
|
||||
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
this.requestSpec.header("X-Mifos-Platform-TenantId", "default");
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
this.generalResponseSpec = new ResponseSpecBuilder().build();
|
||||
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
this.loanRescheduleRequestHelper = new LoanRescheduleRequestHelper(this.requestSpec, this.responseSpec);
|
||||
System.out.println("---------------------------------CREATING ENTITIES AND JLG LOAN ------------------------------------------");
|
||||
// create all required entities
|
||||
this.createRequiredEntitiesForJLGLoanSync(groupMeetingDate);
|
||||
|
||||
final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(loanPrincipalAmount).withLoanTermFrequency("24")
|
||||
.withLoanTermFrequencyAsWeeks().withNumberOfRepayments("12").withRepaymentEveryAfter("2")
|
||||
.withRepaymentFrequencyTypeAsMonths().withAmortizationTypeAsEqualInstallments().withInterestCalculationPeriodTypeAsDays()
|
||||
.withInterestRatePerPeriod(interestRatePerPeriod).withRepaymentFrequencyTypeAsWeeks().withSubmittedOnDate(disbursalDate)
|
||||
.withExpectedDisbursementDate(disbursalDate).withLoanType(loanType).withSyncDisbursementWithMeetin()
|
||||
.withCalendarID(this.groupCalendarId.toString())
|
||||
.build(this.clientId.toString(), this.groupId.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);
|
||||
|
||||
System.out.println("---------------------------------CHANGING GROUP MEETING DATE ------------------------------------------");
|
||||
CalendarHelper.updateMeetingCalendarForGroup(this.requestSpec, this.responseSpec, this.groupId, this.groupCalendarId.toString(),
|
||||
groupMeetingNewStartDate, "2", "2", "2"); // New meeting dates
|
||||
// will be the tuesday
|
||||
// after the
|
||||
// coming
|
||||
// monday
|
||||
|
||||
Calendar expectedMaturityCalendar = Calendar.getInstance();
|
||||
expectedMaturityCalendar.setFirstDayOfWeek(Calendar.MONDAY);
|
||||
ArrayList expectedMaturityDate = ((ArrayList) ((HashMap) this.loanTransactionHelper.getLoanDetail(requestSpec, generalResponseSpec,
|
||||
this.loanId, "timeline")).get("expectedMaturityDate"));
|
||||
|
||||
expectedMaturityCalendar.set((Integer) expectedMaturityDate.get(0), (Integer) expectedMaturityDate.get(1) - 1,
|
||||
(Integer) expectedMaturityDate.get(2));
|
||||
|
||||
assertEquals("AFTER MEETING CHANGE DATE THE EXPECTED MATURITY SHOULD BE ON TUESDAY", 3,
|
||||
expectedMaturityCalendar.get(Calendar.DAY_OF_WEEK));
|
||||
|
||||
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpecForStatusCode403);
|
||||
}
|
||||
|
||||
/**
|
||||
* entities for jlg loan
|
||||
**/
|
||||
private void createRequiredEntitiesForJLGLoanSync(final String groupActivationDate) {
|
||||
this.createGroupEntityWithCalendar("2", "2", "1", groupActivationDate);// frequency=2:Weekly
|
||||
// , interval=2:
|
||||
// Every two weeks ,
|
||||
// repeatsOnDay=1:Monday
|
||||
// groupActivationDate is decided by the current date
|
||||
this.createClientEntity();
|
||||
this.associateClientToGroup(this.groupId, this.clientId);
|
||||
this.createLoanProductEntity();
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
|
||||
private void createGroupEntityWithCalendar(final String frequency, final String interval, final String repeatsOnDay,
|
||||
final String groupActivationDate) {
|
||||
this.groupId = GroupHelper.createGroup(this.requestSpec, this.responseSpec, groupActivationDate);
|
||||
GroupHelper.verifyGroupCreatedOnServer(this.requestSpec, this.responseSpec, this.groupId);
|
||||
|
||||
final String startDate = groupActivationDate;
|
||||
|
||||
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 loanProductJSON = new LoanProductTestBuilder().withPrincipal(loanPrincipalAmount)
|
||||
.withNumberOfRepayments(numberOfRepayments).withinterestRatePerPeriod(interestRatePerPeriod)
|
||||
.withInterestRateFrequencyTypeAsYear().build(null);
|
||||
this.loanProductId = this.loanTransactionHelper.getLoanProductId(loanProductJSON);
|
||||
}
|
||||
|
||||
public void setGroupCalendarId(Integer groupCalendarId) {
|
||||
this.groupCalendarId = groupCalendarId;
|
||||
}
|
||||
}
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
* 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.HashMap;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mifosplatform.integrationtests.common.ExternalServicesConfigurationHelper;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
|
||||
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", "unchecked", "static-access" })
|
||||
public class ExternalServicesConfigurationTest {
|
||||
|
||||
private ResponseSpecification responseSpec;
|
||||
private RequestSpecification requestSpec;
|
||||
private ExternalServicesConfigurationHelper externalServicesConfigurationHelper;
|
||||
private ResponseSpecification httpStatusForidden;
|
||||
|
||||
@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.httpStatusForidden = new ResponseSpecBuilder().expectStatusCode(403).build();
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExternalServicesConfiguration() {
|
||||
this.externalServicesConfigurationHelper = new ExternalServicesConfigurationHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
// Checking for S3
|
||||
String configName = "s3_access_key";
|
||||
ArrayList<HashMap> externalServicesConfig = this.externalServicesConfigurationHelper
|
||||
.getExternalServicesConfigurationByServiceName(requestSpec, responseSpec, "S3");
|
||||
Assert.assertNotNull(externalServicesConfig);
|
||||
for (Integer configIndex = 0; configIndex < (externalServicesConfig.size()); configIndex++) {
|
||||
String name = (String) externalServicesConfig.get(configIndex).get("name");
|
||||
String value = null;
|
||||
if (name.equals(configName)) {
|
||||
value = (String) externalServicesConfig.get(configIndex).get("value");
|
||||
if(value == null){
|
||||
value = "testnull";
|
||||
}
|
||||
String newValue = "test";
|
||||
System.out.println(name + ":" + value);
|
||||
HashMap arrayListValue = this.externalServicesConfigurationHelper.updateValueForExternaServicesConfiguration(requestSpec,
|
||||
responseSpec, "S3", name, newValue);
|
||||
Assert.assertNotNull(arrayListValue.get("value"));
|
||||
Assert.assertEquals(arrayListValue.get("value"), newValue);
|
||||
HashMap arrayListValue1 = this.externalServicesConfigurationHelper.updateValueForExternaServicesConfiguration(requestSpec,
|
||||
responseSpec, "S3", name, value);
|
||||
Assert.assertNotNull(arrayListValue1.get("value"));
|
||||
Assert.assertEquals(arrayListValue1.get("value"), value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Checking for SMTP:
|
||||
|
||||
configName = "username";
|
||||
externalServicesConfig = this.externalServicesConfigurationHelper.getExternalServicesConfigurationByServiceName(requestSpec,
|
||||
responseSpec, "SMTP");
|
||||
Assert.assertNotNull(externalServicesConfig);
|
||||
for (Integer configIndex = 0; configIndex < (externalServicesConfig.size()); configIndex++) {
|
||||
String name = (String) externalServicesConfig.get(configIndex).get("name");
|
||||
String value = null;
|
||||
if (name.equals(configName)) {
|
||||
value = (String) externalServicesConfig.get(configIndex).get("value");
|
||||
if(value == null){
|
||||
value = "testnull";
|
||||
}
|
||||
String newValue = "test";
|
||||
System.out.println(name + ":" + value);
|
||||
HashMap arrayListValue = this.externalServicesConfigurationHelper.updateValueForExternaServicesConfiguration(requestSpec,
|
||||
responseSpec, "SMTP", name, newValue);
|
||||
Assert.assertNotNull(arrayListValue.get("value"));
|
||||
Assert.assertEquals(arrayListValue.get("value"), newValue);
|
||||
HashMap arrayListValue1 = this.externalServicesConfigurationHelper.updateValueForExternaServicesConfiguration(requestSpec,
|
||||
responseSpec, "SMTP", name, value);
|
||||
Assert.assertNotNull(arrayListValue1.get("value"));
|
||||
Assert.assertEquals(arrayListValue1.get("value"), value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+4
-4
@@ -7,6 +7,7 @@ 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;
|
||||
@@ -1407,6 +1408,7 @@ public class FixedDepositTest {
|
||||
final String ACTIVATION_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final String MONTH_DAY = monthDayFormat.format(todaysDate.getTime());
|
||||
|
||||
System.out.println("Submitted Date:"+SUBMITTED_ON_DATE);
|
||||
Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(clientId);
|
||||
|
||||
@@ -1450,10 +1452,8 @@ public class FixedDepositTest {
|
||||
principal = this.fixedDepositAccountHelper.getPrincipalAfterCompoundingInterest(todaysDate, principal, depositPeriod,
|
||||
interestPerDay, DAILY_COMPOUNDING_INTERVAL, MONTHLY_INTERVAL);
|
||||
|
||||
DecimalFormat decimalFormat = new DecimalFormat("", new DecimalFormatSymbols(Locale.US));
|
||||
decimalFormat.applyPattern(".");
|
||||
principal = new Float(decimalFormat.format(principal));
|
||||
maturityAmount = new Float(decimalFormat.format(maturityAmount));
|
||||
principal = new BigDecimal(principal).setScale(0, BigDecimal.ROUND_FLOOR).floatValue();
|
||||
maturityAmount = new BigDecimal(maturityAmount).setScale(0, BigDecimal.ROUND_FLOOR).floatValue();
|
||||
System.out.println(principal);
|
||||
Assert.assertEquals("Verifying Maturity amount for Fixed Deposit Account", principal, maturityAmount);
|
||||
|
||||
|
||||
+50
-57
@@ -31,14 +31,14 @@ import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unused", "unchecked" })
|
||||
public class FlexibleSavingsInterestPostingIntegrationTest {
|
||||
|
||||
public static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL";
|
||||
|
||||
private ResponseSpecification responseSpec;
|
||||
|
||||
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();
|
||||
@@ -47,47 +47,46 @@ public class FlexibleSavingsInterestPostingIntegrationTest {
|
||||
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);
|
||||
// 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);
|
||||
|
||||
|
||||
Integer depositTransactionId = (Integer) this.savingsAccountHelper.depositToSavingsAccount(savingsId, "1000", startDate,
|
||||
CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
|
||||
/***
|
||||
* Perform Post interest transaction and verify the posted transaction date
|
||||
* 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());
|
||||
|
||||
ArrayList<HashMap<String, Object>> transactions = (ArrayList<HashMap<String, Object>>) accountDetails.get("transactions");
|
||||
HashMap<String, Object> interestPostingTransaction = transactions.get(transactions.size() - 2);
|
||||
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();
|
||||
final Integer savingsProductID = createSavingsProduct();
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplicationOnDate(clientID,
|
||||
savingsProductID, ACCOUNT_TYPE_INDIVIDUAL, startDate);
|
||||
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);
|
||||
@@ -95,54 +94,48 @@ public class FlexibleSavingsInterestPostingIntegrationTest {
|
||||
SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
|
||||
return savingsId;
|
||||
}
|
||||
|
||||
private void configureInterestPosting(final Boolean periodEndEnable,
|
||||
final Integer financialYearBeginningMonth) {
|
||||
final ArrayList<HashMap> globalConfig = GlobalConfigurationHelper.getAllGlobalConfigurations(this.requestSpec,
|
||||
this.responseSpec);
|
||||
|
||||
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());
|
||||
periodEndConfigId.toString());
|
||||
Assert.assertNotNull(periodEndConfigData);
|
||||
|
||||
Boolean enabled = (Boolean) globalConfig.get(10).get("enabled");
|
||||
|
||||
if (enabled != periodEndEnable)
|
||||
if (enabled != periodEndEnable)
|
||||
periodEndConfigId = GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec,
|
||||
periodEndConfigId.toString(), periodEndEnable);
|
||||
|
||||
|
||||
//Updating value for financial year beginning month
|
||||
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());
|
||||
HashMap financialYearBeginningConfigData = GlobalConfigurationHelper.getGlobalConfigurationById(this.requestSpec,
|
||||
this.responseSpec, financialYearBeginningConfigId.toString());
|
||||
Assert.assertNotNull(financialYearBeginningConfigData);
|
||||
|
||||
financialYearBeginningConfigId = GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec,
|
||||
financialYearBeginningConfigId.toString(), financialYearBeginningMonth.toString());
|
||||
financialYearBeginningConfigId.toString(), financialYearBeginningMonth.toString());
|
||||
Assert.assertNotNull(financialYearBeginningConfigId);
|
||||
}
|
||||
|
||||
|
||||
private Integer createSavingsProduct() {
|
||||
final String savingsProductJSON = this.savingsProductHelper
|
||||
.withInterestCompoundingPeriodTypeAsDaily()
|
||||
.withInterestPostingPeriodTypeAsAnnual()
|
||||
.withInterestCalculationPeriodTypeAsDailyBalance()
|
||||
.build();
|
||||
final String savingsProductJSON = this.savingsProductHelper.withInterestCompoundingPeriodTypeAsDaily()
|
||||
.withInterestPostingPeriodTypeAsAnnual().withInterestCalculationPeriodTypeAsDailyBalance().build();
|
||||
return SavingsProductHelper.createSavingsProduct(savingsProductJSON, requestSpec, responseSpec);
|
||||
}
|
||||
|
||||
//Reset configuration fields
|
||||
|
||||
// Reset configuration fields
|
||||
@After
|
||||
public void tearDown() {
|
||||
configureInterestPosting(false, 1);
|
||||
configureInterestPosting(false, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+84
@@ -11,6 +11,7 @@ import java.util.HashMap;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mifosplatform.integrationtests.common.CommonConstants;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
import org.mifosplatform.integrationtests.common.GlobalConfigurationHelper;
|
||||
|
||||
@@ -26,6 +27,7 @@ public class GlobalConfigurationTest {
|
||||
private ResponseSpecification responseSpec;
|
||||
private RequestSpecification requestSpec;
|
||||
private GlobalConfigurationHelper globalConfigurationHelper;
|
||||
private ResponseSpecification httpStatusForidden;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
@@ -33,6 +35,7 @@ public class GlobalConfigurationTest {
|
||||
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
this.httpStatusForidden = new ResponseSpecBuilder().expectStatusCode(403).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -121,4 +124,85 @@ public class GlobalConfigurationTest {
|
||||
Assert.assertEquals("Verifying Is Cache Enabled Global Config after Updation", cacheTypeId, changes.get("cacheType"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGlobalConfigForcePasswordResetDays() {
|
||||
|
||||
// Retrieving All Global Configuration details
|
||||
final ArrayList<HashMap> globalConfig = this.globalConfigurationHelper
|
||||
.getAllGlobalConfigurations(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(globalConfig);
|
||||
|
||||
String configName = "force-password-reset-days";
|
||||
String newValue = "0";
|
||||
String newBooleanValue = "true";
|
||||
|
||||
for (Integer configIndex = 0; configIndex < (globalConfig.size() - 1); configIndex++) {
|
||||
if (globalConfig.get(configIndex).get("name").equals(configName)) {
|
||||
Integer configId = (Integer) globalConfig.get(configIndex).get(
|
||||
"id");
|
||||
Assert.assertNotNull(configId);
|
||||
|
||||
/*
|
||||
* Update force-password-reset-days with value as 0 and Enable
|
||||
* as true - failure case
|
||||
*/
|
||||
ArrayList error = (ArrayList) this.globalConfigurationHelper
|
||||
.updatePasswordResetDaysForGlobalConfiguration(
|
||||
this.requestSpec, this.httpStatusForidden,
|
||||
configId, newValue, newBooleanValue,
|
||||
CommonConstants.RESPONSE_ERROR);
|
||||
HashMap hash = (HashMap) error.get(0);
|
||||
|
||||
Assert.assertEquals(
|
||||
"Force Password Reset days value must be greater than zero.",
|
||||
"error.msg.password.reset.days.value.must.be.greater.than.zero",
|
||||
hash.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
/*
|
||||
* Update force-password-reset-days with value as 50 and Enable
|
||||
* as true - success case
|
||||
*/
|
||||
final HashMap updateSuccess = (HashMap) this.globalConfigurationHelper
|
||||
.updatePasswordResetDaysForGlobalConfiguration(
|
||||
this.requestSpec, this.responseSpec, configId,
|
||||
"50", newBooleanValue, "changes");
|
||||
Assert.assertNotNull(updateSuccess);
|
||||
|
||||
/* Update with value as 0 and Enable as false - success case */
|
||||
final HashMap updateSuccess1 = (HashMap) this.globalConfigurationHelper
|
||||
.updatePasswordResetDaysForGlobalConfiguration(
|
||||
this.requestSpec, this.responseSpec, configId,
|
||||
newValue, "false", "changes");
|
||||
Assert.assertNotNull(updateSuccess1);
|
||||
|
||||
/* Update without sending value and Enable as true - failure case*/
|
||||
ArrayList failure = (ArrayList) this.globalConfigurationHelper
|
||||
.updatePasswordResetDaysForGlobalConfiguration(
|
||||
this.requestSpec, this.httpStatusForidden, configId,
|
||||
null, newBooleanValue, CommonConstants.RESPONSE_ERROR);
|
||||
HashMap failureHash = (HashMap) failure.get(0);
|
||||
Assert.assertEquals(
|
||||
"Force Password Reset days value must be greater than zero.",
|
||||
"error.msg.password.reset.days.value.must.be.greater.than.zero",
|
||||
failureHash.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Update other global configuration property */
|
||||
String otherConfigName = "maker-checker";
|
||||
for (Integer configIndex = 0; configIndex < (globalConfig.size() - 1); configIndex++) {
|
||||
if (globalConfig.get(configIndex).get("name")
|
||||
.equals(otherConfigName)) {
|
||||
String configId = (globalConfig.get(configIndex).get("id"))
|
||||
.toString();
|
||||
Integer updateConfigId = this.globalConfigurationHelper
|
||||
.updateValueForGlobalConfiguration(this.requestSpec,
|
||||
this.responseSpec, configId, newValue);
|
||||
Assert.assertNotNull(updateConfigId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -105,17 +105,17 @@ public class GroupLoanIntegrationTest {
|
||||
|
||||
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 Principal Due for 2nd Month", new Float("2969.72"), 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<>(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 Principal Due for 3rd Month", new Float("3029.11"), 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<>(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 Principal Due for 4th Month", new Float("3089.68"), loanSchedule.get(4).get("principalDue"));
|
||||
assertEquals("Checking for Interest Due for 4th Month", new Float("61.79"), loanSchedule.get(4).get("interestOriginalDue"));
|
||||
}
|
||||
}
|
||||
+49
-51
@@ -5,29 +5,27 @@
|
||||
*/
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
|
||||
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.GroupHelper;
|
||||
import org.mifosplatform.integrationtests.common.StaffHelper;
|
||||
import org.mifosplatform.integrationtests.common.organisation.StaffHelper;
|
||||
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.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;
|
||||
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,
|
||||
@@ -38,11 +36,10 @@ 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";
|
||||
|
||||
private final String principal = "10000.00";
|
||||
private final String accountingRule = "1";
|
||||
private final String numberOfRepayments = "5";
|
||||
private final String interestRatePerPeriod = "18";
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
@@ -73,29 +70,32 @@ public class GroupTest {
|
||||
groupID = GroupHelper.updateGroup(this.requestSpec, this.responseSpec, updatedGroupName, groupID.toString());
|
||||
GroupHelper.verifyGroupDetails(this.requestSpec, this.responseSpec, groupID, "name", updatedGroupName);
|
||||
|
||||
// NOTE: removed as consistently provides false positive result on cloudbees server.
|
||||
// groupID = GroupHelper.createGroup(this.requestSpec, this.responseSpec);
|
||||
// GroupHelper.deleteGroup(this.requestSpec, this.responseSpec, groupID.toString());
|
||||
// GroupHelper.verifyGroupDeleted(this.requestSpec, this.responseSpec, groupID);
|
||||
// NOTE: removed as consistently provides false positive result on
|
||||
// cloudbees server.
|
||||
// groupID = GroupHelper.createGroup(this.requestSpec,
|
||||
// this.responseSpec);
|
||||
// GroupHelper.deleteGroup(this.requestSpec, this.responseSpec,
|
||||
// groupID.toString());
|
||||
// GroupHelper.verifyGroupDeleted(this.requestSpec, this.responseSpec,
|
||||
// groupID);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void assignStaffToGroup(){
|
||||
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);
|
||||
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());
|
||||
Integer updateGroupId = GroupHelper.updateGroup(this.requestSpec, this.responseSpec, updateGroupName, groupID.toString());
|
||||
|
||||
//create client and add client to group
|
||||
// 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) ;
|
||||
// create staff
|
||||
Integer createStaffId1 = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
|
||||
System.out.println("--------------creating first staff with id-------------" + createStaffId1);
|
||||
Assert.assertNotNull(createStaffId1);
|
||||
|
||||
@@ -103,45 +103,43 @@ public class GroupTest {
|
||||
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);
|
||||
// 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);
|
||||
final Integer loanId = this.applyForLoanApplication(clientID, loanProductId, this.principal);
|
||||
|
||||
this.loanTransactionHelper.approveLoan("20 September 2014",loanId);
|
||||
this.loanTransactionHelper.disburseLoan("20 September 2014",loanId);
|
||||
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());
|
||||
final HashMap assignStaffAndInheritStaffForClientAccounts = (HashMap) GroupHelper.assignStaffInheritStaffForClientAccounts(
|
||||
this.requestSpec, this.responseSpec, groupID.toString(), createStaffId1.toString());
|
||||
final Integer getClientStaffId = ClientHelper.getClientsStaffId(this.requestSpec, this.responseSpec, clientID.toString());
|
||||
|
||||
//assert if client staff officer has change Note client was assigned staff with createStaffId2
|
||||
// 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);
|
||||
assertEquals("Verify if client inherited staff assigned above", assignStaffAndInheritStaffForClientAccounts.get("staffId"),
|
||||
getClientStaffId);
|
||||
|
||||
//assert if clients loan officer has changed
|
||||
// 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);
|
||||
final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(this.principal)
|
||||
.withNumberOfRepayments(this.numberOfRepayments).withinterestRatePerPeriod(this.interestRatePerPeriod)
|
||||
.withInterestRateFrequencyTypeAsYear().build(null);
|
||||
return this.loanTransactionHelper.getLoanProductId(loanProductJSON);
|
||||
}
|
||||
|
||||
|
||||
+21
-2
@@ -5,7 +5,8 @@
|
||||
*/
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Assert;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -62,7 +63,7 @@ public class HookIntegrationTest {
|
||||
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,
|
||||
Assert.assertEquals("Equality check for created officeId and hook received payload officeId", createdOfficeID,
|
||||
notificationOfficeId);
|
||||
System.out.println("Notification Office Id - " + notificationOfficeId);
|
||||
i = 6;
|
||||
@@ -80,4 +81,22 @@ public class HookIntegrationTest {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createUpdateAndDeleteHook(){
|
||||
final String payloadURL = "http://echo-webhook.herokuapp.com:80/Z7RXoCBdLSFMDrpn?";
|
||||
final String updateURL = "http://localhost";
|
||||
|
||||
Long hookId = this.hookHelper.createHook(payloadURL).longValue();
|
||||
Assert.assertNotNull(hookId);
|
||||
this.hookHelper.verifyHookCreatedOnServer(hookId);
|
||||
System.out.println("---------------------SUCCESSFULLY CREATED AND VERIFIED HOOK-------------------------"+hookId);
|
||||
this.hookHelper.updateHook(updateURL, hookId);
|
||||
this.hookHelper.verifyUpdateHook(updateURL, hookId);
|
||||
System.out.println("---------------------SUCCESSFULLY UPDATED AND VERIFIED HOOK-------------------------"+hookId);
|
||||
this.hookHelper.deleteHook(hookId);
|
||||
this.hookHelper.verifyDeleteHook(hookId);
|
||||
System.out.println("---------------------SUCCESSFULLY DELETED AND VERIFIED HOOK-------------------------"+hookId);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+184
-24
@@ -5,20 +5,14 @@
|
||||
*/
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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;
|
||||
@@ -27,11 +21,18 @@ 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;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class LoanApplicationApprovalTest {
|
||||
|
||||
private ResponseSpecification responseSpec;
|
||||
private ResponseSpecification responseSpecForStatusCode403;
|
||||
private ResponseSpecification responseSpecForStatusCode400;
|
||||
private RequestSpecification requestSpec;
|
||||
private LoanTransactionHelper loanTransactionHelper;
|
||||
|
||||
@@ -42,20 +43,20 @@ public class LoanApplicationApprovalTest {
|
||||
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||
this.responseSpecForStatusCode403 = new ResponseSpecBuilder().expectStatusCode(403).build();
|
||||
this.responseSpecForStatusCode400 = new ResponseSpecBuilder().expectStatusCode(400).build();
|
||||
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||
}
|
||||
|
||||
/*
|
||||
* Positive test case: Approved amount non zero is less than proposed amount
|
||||
*
|
||||
* 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);
|
||||
@@ -63,22 +64,25 @@ public class LoanApplicationApprovalTest {
|
||||
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
|
||||
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
|
||||
|
||||
loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount(approveDate, approvalAmount, loanID);
|
||||
final String expectedDisbursementDate = null;
|
||||
List<HashMap> approveTranches = null;
|
||||
loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount(approveDate, expectedDisbursementDate, approvalAmount,
|
||||
loanID, approveTranches);
|
||||
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Negative test case: Approved amount non zero is greater than proposed amount
|
||||
*
|
||||
* 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);
|
||||
@@ -87,14 +91,147 @@ public class LoanApplicationApprovalTest {
|
||||
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
|
||||
|
||||
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpecForStatusCode403);
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<HashMap> error = (List<HashMap>) this.loanTransactionHelper.approveLoanWithApproveAmount(approveDate, approvalAmount, loanID,
|
||||
List<HashMap> error = (List<HashMap>) this.loanTransactionHelper.approveLoan(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));
|
||||
|
||||
|
||||
assertEquals("error.msg.loan.approval.amount.can't.be.greater.than.loan.amount.demanded",
|
||||
error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
}
|
||||
|
||||
private HashMap createTrancheDetail(final String date, final String amount) {
|
||||
HashMap<String, Object> detail = new HashMap<>();
|
||||
detail.put("expectedDisbursementDate", date);
|
||||
detail.put("principal", amount);
|
||||
|
||||
return detail;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loanApplicationApprovalAndValidationForMultiDisburseLoans() {
|
||||
|
||||
List<HashMap> createTranches = new ArrayList<>();
|
||||
createTranches.add(createTrancheDetail("1 March 2014", "1000"));
|
||||
createTranches.add(createTrancheDetail("23 March 2014", "4000"));
|
||||
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014");
|
||||
System.out.println("---------------------------------CLIENT CREATED WITH ID---------------------------------------------------"
|
||||
+ clientID);
|
||||
|
||||
final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder()
|
||||
.withInterestTypeAsDecliningBalance().withTranches(true).build(null));
|
||||
System.out.println("----------------------------------LOAN PRODUCT CREATED WITH ID-------------------------------------------"
|
||||
+ loanProductID);
|
||||
|
||||
this.trancheLoansApprovedAmountLesserThanProposedAmount(clientID, loanProductID, createTranches);
|
||||
this.trancheLoansApprovalValidation(clientID, loanProductID, createTranches);
|
||||
|
||||
}
|
||||
|
||||
private void trancheLoansApprovedAmountLesserThanProposedAmount(Integer clientID, Integer loanProductID, List<HashMap> createTranches) {
|
||||
final String proposedAmount = "5000";
|
||||
final String approvalAmount = "2000";
|
||||
final String approveDate = "1 March 2014";
|
||||
final String expectedDisbursementDate = "1 March 2014";
|
||||
|
||||
List<HashMap> approveTranches = new ArrayList<>();
|
||||
approveTranches.add(createTrancheDetail("1 March 2014", "1000"));
|
||||
approveTranches.add(createTrancheDetail("23 March 2014", "1000"));
|
||||
|
||||
final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches);
|
||||
System.out.println("-----------------------------------LOAN CREATED WITH LOANID-------------------------------------------------"
|
||||
+ loanID);
|
||||
|
||||
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
|
||||
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
|
||||
|
||||
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------");
|
||||
loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount(approveDate, expectedDisbursementDate, approvalAmount,
|
||||
loanID, approveTranches);
|
||||
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
|
||||
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
|
||||
System.out
|
||||
.println("-----------------------------------MULTI DISBURSAL LOAN APPROVED SUCCESSFULLY---------------------------------------");
|
||||
|
||||
}
|
||||
|
||||
private void trancheLoansApprovalValidation(Integer clientID, Integer loanProductID, List<HashMap> createTranches) {
|
||||
final String proposedAmount = "5000";
|
||||
final String approvalAmount1 = "10000";
|
||||
final String approvalAmount2 = "3000";
|
||||
final String approvalAmount3 = "400";
|
||||
final String approvalAmount4 = "200";
|
||||
|
||||
final String approveDate = "1 March 2014";
|
||||
final String expectedDisbursementDate = "1 March 2014";
|
||||
|
||||
List<HashMap> approveTranche1 = new ArrayList<>();
|
||||
approveTranche1.add(createTrancheDetail("1 March 2014", "5000"));
|
||||
approveTranche1.add(createTrancheDetail("23 March 2014", "5000"));
|
||||
|
||||
List<HashMap> approveTranche2 = new ArrayList<>();
|
||||
approveTranche2.add(createTrancheDetail("1 March 2014", "1000"));
|
||||
approveTranche2.add(createTrancheDetail("23 March 2014", "1000"));
|
||||
approveTranche2.add(createTrancheDetail("23 March 2014", "1000"));
|
||||
|
||||
List<HashMap> approveTranche3 = new ArrayList<>();
|
||||
approveTranche3.add(createTrancheDetail("1 March 2014", "100"));
|
||||
approveTranche3.add(createTrancheDetail("23 March 2014", "100"));
|
||||
approveTranche3.add(createTrancheDetail("24 March 2014", "100"));
|
||||
approveTranche3.add(createTrancheDetail("25 March 2014", "100"));
|
||||
|
||||
List<HashMap> approveTranche4 = new ArrayList<>();
|
||||
approveTranche4.add(createTrancheDetail("1 March 2014", "100"));
|
||||
approveTranche4.add(createTrancheDetail("23 March 2014", "100"));
|
||||
approveTranche4.add(createTrancheDetail("24 March 2014", "100"));
|
||||
|
||||
final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, proposedAmount, createTranches);
|
||||
System.out.println("-----------------------------------LOAN CREATED WITH LOANID-------------------------------------------------"
|
||||
+ loanID);
|
||||
|
||||
HashMap<String, Object> loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
|
||||
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
|
||||
|
||||
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------");
|
||||
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpecForStatusCode400);
|
||||
|
||||
/* Tranches with same expected disbursement date */
|
||||
List<HashMap<String, Object>> error = this.loanTransactionHelper.approveLoanForTranches(approveDate, expectedDisbursementDate,
|
||||
approvalAmount2, loanID, approveTranche2, CommonConstants.RESPONSE_ERROR);
|
||||
assertEquals("validation.msg.loan.expectedDisbursementDate.disbursement.date.must.be.unique.for.tranches",
|
||||
error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
/* Sum of tranches is greater than approved amount */
|
||||
error = this.loanTransactionHelper.approveLoanForTranches(approveDate, expectedDisbursementDate, approvalAmount4, loanID,
|
||||
approveTranche4, CommonConstants.RESPONSE_ERROR);
|
||||
assertEquals("validation.msg.loan.principal.sum.of.multi.disburse.amounts.must.be.equal.to.or.lesser.than.approved.principal",
|
||||
error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpecForStatusCode403);
|
||||
|
||||
/* Sum of tranches exceeds the proposed amount */
|
||||
error = this.loanTransactionHelper.approveLoanForTranches(approveDate, expectedDisbursementDate, approvalAmount1, loanID,
|
||||
approveTranche1, 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));
|
||||
|
||||
/* No. of tranches exceeds the max tranche count at product level */
|
||||
error = this.loanTransactionHelper.approveLoanForTranches(approveDate, expectedDisbursementDate, approvalAmount3, loanID,
|
||||
approveTranche3, CommonConstants.RESPONSE_ERROR);
|
||||
assertEquals("error.msg.disbursementData.exceeding.max.tranche.count", error.get(0)
|
||||
.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
/* If tranches are not specified for a multi-disburse loan */
|
||||
/**
|
||||
* error =
|
||||
* this.loanTransactionHelper.approveLoanForTranches(approveDate,
|
||||
* expectedDisbursementDate, approvalAmount5, loanID, approveTranche5,
|
||||
* CommonConstants.RESPONSE_ERROR);
|
||||
* assertEquals("error.msg.disbursementData.required",
|
||||
* error.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
**/
|
||||
}
|
||||
|
||||
private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID, final String proposedAmount) {
|
||||
@@ -104,4 +241,27 @@ public class LoanApplicationApprovalTest {
|
||||
.withSubmittedOnDate("02 April 2012").build(clientID.toString(), loanProductID.toString(), null);
|
||||
return this.loanTransactionHelper.getLoanId(loanApplication);
|
||||
}
|
||||
|
||||
private Integer applyForLoanApplicationWithTranches(final Integer clientID, final Integer loanProductID, String principal,
|
||||
List<HashMap> tranches) {
|
||||
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
|
||||
final String loanApplicationJSON = new LoanApplicationTestBuilder()
|
||||
//
|
||||
.withPrincipal(principal)
|
||||
//
|
||||
.withLoanTermFrequency("5")
|
||||
//
|
||||
.withLoanTermFrequencyAsMonths()
|
||||
//
|
||||
.withNumberOfRepayments("5").withRepaymentEveryAfter("1").withRepaymentFrequencyTypeAsMonths() //
|
||||
.withInterestRatePerPeriod("2") //
|
||||
.withExpectedDisbursementDate("1 March 2014") //
|
||||
.withTranches(tranches) //
|
||||
.withInterestTypeAsDecliningBalance() //
|
||||
.withSubmittedOnDate("1 March 2014") //
|
||||
.build(clientID.toString(), loanProductID.toString(), null);
|
||||
|
||||
return this.loanTransactionHelper.getLoanId(loanApplicationJSON);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+51
@@ -7,6 +7,7 @@ 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;
|
||||
@@ -116,6 +117,56 @@ public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkClientLoan_WRITTEN_OFF() {
|
||||
// CREATE CLIENT
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, this.DATE_OF_JOINING);
|
||||
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
|
||||
|
||||
// CREATE LOAN PRODUCT
|
||||
final Integer loanProductID = createLoanProduct();
|
||||
// APPLY FOR LOAN
|
||||
final Integer loanID = applyForLoanApplication(clientID, loanProductID);
|
||||
|
||||
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
|
||||
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
|
||||
|
||||
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------");
|
||||
loanStatusHashMap = this.loanTransactionHelper.approveLoan("28 September 2010", loanID);
|
||||
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
|
||||
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
|
||||
|
||||
// DISBURSE
|
||||
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(this.DISBURSEMENT_DATE, loanID);
|
||||
System.out.println("DISBURSE " + loanStatusHashMap);
|
||||
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
|
||||
|
||||
// MAKE REPAYMENTS
|
||||
final float repayment_with_interest = 680.0f;
|
||||
|
||||
this.loanTransactionHelper.verifyRepaymentScheduleEntryFor(1, 4000.0F, loanID);
|
||||
this.loanTransactionHelper.makeRepayment("1 January 2011", repayment_with_interest, loanID);
|
||||
|
||||
HashMap toLoanSummaryAfter = this.loanTransactionHelper.getLoanSummary(requestSpec, responseSpec, loanID);
|
||||
Assert.assertTrue("Checking for Principal paid ",
|
||||
new Float("500.0").compareTo(new Float(String.valueOf(toLoanSummaryAfter.get("principalPaid")))) == 0);
|
||||
Assert.assertTrue("Checking for interestPaid paid ",
|
||||
new Float("180.0").compareTo(new Float(String.valueOf(toLoanSummaryAfter.get("interestPaid")))) == 0);
|
||||
Assert.assertTrue("Checking for total paid ",
|
||||
new Float("680.0").compareTo(new Float(String.valueOf(toLoanSummaryAfter.get("totalRepayment")))) == 0);
|
||||
|
||||
// WRITE OFF LOAN AND CHECK ACCOUNT IS CLOSED
|
||||
LoanStatusChecker.verifyLoanAccountIsClosed(this.loanTransactionHelper.writeOffLoan("1 January 2011", loanID));
|
||||
toLoanSummaryAfter = this.loanTransactionHelper.getLoanSummary(requestSpec, responseSpec, loanID);
|
||||
Assert.assertTrue("Checking for Principal written off ",
|
||||
new Float("4000.0").compareTo(new Float(String.valueOf(toLoanSummaryAfter.get("principalWrittenOff")))) == 0);
|
||||
Assert.assertTrue("Checking for interestPaid written off ",
|
||||
new Float("1440.0").compareTo(new Float(String.valueOf(toLoanSummaryAfter.get("interestWrittenOff")))) == 0);
|
||||
Assert.assertTrue("Checking for total written off ",
|
||||
new Float("5440.0").compareTo(new Float(String.valueOf(toLoanSummaryAfter.get("totalWrittenOff")))) == 0);
|
||||
|
||||
}
|
||||
|
||||
private Integer createLoanProduct() {
|
||||
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
|
||||
final String loanProductJSON = new LoanProductTestBuilder().withPrincipal(this.LP_PRINCIPAL).withRepaymentTypeAsMonth()
|
||||
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* 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.OfficeDomain;
|
||||
import org.mifosplatform.integrationtests.common.OfficeHelper;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
|
||||
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 OfficeIntegrationTest {
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOfficeModification() {
|
||||
OfficeHelper oh = new OfficeHelper(requestSpec, responseSpec);
|
||||
int officeId = oh.createOffice("01 July 2007");
|
||||
String name = Utils.randomNameGenerator("New_Office_", 4);
|
||||
String date = "02 July 2007";
|
||||
String[] dateArr = { "2007", "7", "2" };
|
||||
|
||||
oh.updateOffice(officeId, name, date);
|
||||
OfficeDomain newOffice = oh.retrieveOfficeByID(officeId);
|
||||
|
||||
Assert.assertTrue(name.equals(newOffice.getName()));
|
||||
Assert.assertArrayEquals(dateArr, newOffice.getOpeningDate());
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* 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.Before;
|
||||
import org.junit.Test;
|
||||
import org.mifosplatform.integrationtests.common.CommonConstants;
|
||||
import org.mifosplatform.integrationtests.common.PasswordPreferencesHelper;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
|
||||
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", "unchecked" })
|
||||
public class PasswordPreferencesIntegrationTest {
|
||||
|
||||
private ResponseSpecification responseSpec;
|
||||
private RequestSpecification requestSpec;
|
||||
private ResponseSpecification generalResponseSpec;
|
||||
|
||||
@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();
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updatePasswordPreferences() {
|
||||
String validationPolicyId = "2";
|
||||
PasswordPreferencesHelper.updatePasswordPreferences(requestSpec, responseSpec, validationPolicyId);
|
||||
this.validateIfThePasswordIsUpdated(validationPolicyId);
|
||||
}
|
||||
|
||||
private void validateIfThePasswordIsUpdated(String validationPolicyId){
|
||||
Integer id = PasswordPreferencesHelper.getActivePasswordPreference(requestSpec, responseSpec);
|
||||
assertEquals(validationPolicyId, id.toString());
|
||||
System.out.println("---------------------------------PASSWORD PREFERENCE VALIDATED SUCCESSFULLY-----------------------------------------");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateWithInvalidPolicyId() {
|
||||
String invalidValidationPolicyId = "2000";
|
||||
final List<HashMap> error = (List) PasswordPreferencesHelper.updateWithInvalidValidationPolicyId(requestSpec, generalResponseSpec, invalidValidationPolicyId,
|
||||
CommonConstants.RESPONSE_ERROR);
|
||||
assertEquals("Password Validation Policy with identifier 2000 does not exist", "error.msg.password.validation.policy.id.invalid",
|
||||
error.get(0).get("userMessageGlobalisationCode"));
|
||||
}
|
||||
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* 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.PaymentTypeDomain;
|
||||
import org.mifosplatform.integrationtests.common.PaymentTypeHelper;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
|
||||
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 PaymentTypeIntegrationTest {
|
||||
|
||||
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({ "rawtypes", "unchecked" })
|
||||
@Test
|
||||
public void testPaymentType() {
|
||||
String name = PaymentTypeHelper.randomNameGenerator("P_T", 5);
|
||||
String description = PaymentTypeHelper.randomNameGenerator("PT_Desc", 15);
|
||||
Boolean isCashPayment = true;
|
||||
Integer position = 1;
|
||||
|
||||
Integer paymentTypeId = PaymentTypeHelper.createPaymentType(requestSpec, responseSpec, name, description, isCashPayment, position);
|
||||
Assert.assertNotNull(paymentTypeId);
|
||||
PaymentTypeHelper.verifyPaymentTypeCreatedOnServer(requestSpec, responseSpec, paymentTypeId);
|
||||
PaymentTypeDomain paymentTypeResponse = PaymentTypeHelper.retrieveById(requestSpec, responseSpec, paymentTypeId);
|
||||
Assert.assertEquals(name, paymentTypeResponse.getName());
|
||||
Assert.assertEquals(description, paymentTypeResponse.getDescription());
|
||||
Assert.assertEquals(isCashPayment, paymentTypeResponse.getIsCashPayment());
|
||||
Assert.assertEquals(position, paymentTypeResponse.getPosition());
|
||||
|
||||
// Update Payment Type
|
||||
String newName = PaymentTypeHelper.randomNameGenerator("P_TU", 5);
|
||||
String newDescription = PaymentTypeHelper.randomNameGenerator("PTU_Desc", 15);
|
||||
Boolean isCashPaymentUpdatedValue = false;
|
||||
Integer newPosition = 2;
|
||||
|
||||
HashMap request = new HashMap();
|
||||
request.put("name", newName);
|
||||
request.put("description", newDescription);
|
||||
request.put("isCashPayment", isCashPaymentUpdatedValue);
|
||||
request.put("position", newPosition);
|
||||
PaymentTypeHelper.updatePaymentType(paymentTypeId, request, requestSpec, responseSpec);
|
||||
PaymentTypeDomain paymentTypeUpdatedResponse = PaymentTypeHelper.retrieveById(requestSpec, responseSpec, paymentTypeId);
|
||||
Assert.assertEquals(newName, paymentTypeUpdatedResponse.getName());
|
||||
Assert.assertEquals(newDescription, paymentTypeUpdatedResponse.getDescription());
|
||||
Assert.assertEquals(isCashPaymentUpdatedValue, paymentTypeUpdatedResponse.getIsCashPayment());
|
||||
Assert.assertEquals(newPosition, paymentTypeUpdatedResponse.getPosition());
|
||||
|
||||
// Delete
|
||||
Integer deletedPaymentTypeId = PaymentTypeHelper.deletePaymentType(paymentTypeId, requestSpec, responseSpec);
|
||||
Assert.assertEquals(paymentTypeId, deletedPaymentTypeId);
|
||||
ResponseSpecification responseSpecification = new ResponseSpecBuilder().expectStatusCode(404).build();
|
||||
PaymentTypeHelper.retrieveById(requestSpec, responseSpecification, paymentTypeId);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
/**
|
||||
* 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.assertNotEquals;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
import org.mifosplatform.integrationtests.common.organisation.StaffHelper;
|
||||
import org.mifosplatform.integrationtests.useradministration.roles.RolesHelper;
|
||||
import org.mifosplatform.integrationtests.useradministration.users.UserHelper;
|
||||
|
||||
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 RolesTest {
|
||||
|
||||
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("cast")
|
||||
@Test
|
||||
public void testCreateRolesStatus() {
|
||||
|
||||
System.out.println("---------------------------------CREATING A ROLE---------------------------------------------");
|
||||
final Integer roleId = RolesHelper.createRole(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(roleId);
|
||||
|
||||
System.out.println("--------------------------------- Getting ROLE -------------------------------");
|
||||
HashMap<String, Object> role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId);
|
||||
assertEquals((Integer) role.get("id"), roleId);
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("cast")
|
||||
@Test
|
||||
public void testDisableRolesStatus() {
|
||||
|
||||
System.out.println("---------------------------------CREATING A ROLE---------------------------------------------");
|
||||
final Integer roleId = RolesHelper.createRole(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(roleId);
|
||||
|
||||
System.out.println("--------------------------------- Getting ROLE -------------------------------");
|
||||
HashMap<String, Object> role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId);
|
||||
assertEquals((Integer) role.get("id"), roleId);
|
||||
|
||||
System.out.println("--------------------------------- DISABLING ROLE -------------------------------");
|
||||
final Integer disableRoleId = RolesHelper.disableRole(this.requestSpec, this.responseSpec, roleId);
|
||||
assertEquals(disableRoleId, roleId);
|
||||
role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId);
|
||||
assertEquals((Integer) role.get("id"), roleId);
|
||||
assertEquals((Boolean) role.get("disabled"), true);
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("cast")
|
||||
@Test
|
||||
public void testEnableRolesStatus() {
|
||||
|
||||
System.out.println("---------------------------------CREATING A ROLE---------------------------------------------");
|
||||
final Integer roleId = RolesHelper.createRole(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(roleId);
|
||||
|
||||
System.out.println("--------------------------------- Getting ROLE -------------------------------");
|
||||
HashMap<String, Object> role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId);
|
||||
assertEquals((Integer) role.get("id"), roleId);
|
||||
|
||||
System.out.println("--------------------------------- DISABLING ROLE -------------------------------");
|
||||
final Integer disableRoleId = RolesHelper.disableRole(this.requestSpec, this.responseSpec, roleId);
|
||||
assertEquals(disableRoleId, roleId);
|
||||
role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId);
|
||||
assertEquals((Integer) role.get("id"), roleId);
|
||||
assertEquals((Boolean) role.get("disabled"), true);
|
||||
|
||||
System.out.println("--------------------------------- ENABLING ROLE -------------------------------");
|
||||
final Integer enableRoleId = RolesHelper.enableRole(this.requestSpec, this.responseSpec, roleId);
|
||||
assertEquals(enableRoleId, roleId);
|
||||
role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId);
|
||||
assertEquals((Integer) role.get("id"), roleId);
|
||||
assertEquals((Boolean) role.get("disabled"), false);
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("cast")
|
||||
@Test
|
||||
public void testDeleteRoleStatus() {
|
||||
|
||||
System.out.println("-------------------------------- CREATING A ROLE---------------------------------------------");
|
||||
final Integer roleId = RolesHelper.createRole(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(roleId);
|
||||
|
||||
System.out.println("--------------------------------- Getting ROLE -------------------------------");
|
||||
HashMap<String, Object> role = RolesHelper.getRoleDetails(requestSpec, responseSpec, roleId);
|
||||
assertEquals((Integer) role.get("id"), roleId);
|
||||
|
||||
System.out.println("--------------------------------- DELETE ROLE -------------------------------");
|
||||
final Integer deleteRoleId = RolesHelper.deleteRole(this.requestSpec, this.responseSpec, roleId);
|
||||
assertEquals(deleteRoleId, roleId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRoleShouldGetDeletedIfNoActiveUserExists() {
|
||||
final Integer roleId = RolesHelper.createRole(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(roleId);
|
||||
|
||||
final Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(staffId);
|
||||
|
||||
final Integer userId = UserHelper.createUser(this.requestSpec, this.responseSpec, roleId, staffId);
|
||||
Assert.assertNotNull(userId);
|
||||
|
||||
final Integer deletedUserId = UserHelper.deleteUser(this.requestSpec, this.responseSpec, userId);
|
||||
Assert.assertEquals(deletedUserId, userId);
|
||||
|
||||
final Integer deletedRoleId = RolesHelper.deleteRole(this.requestSpec, this.responseSpec, roleId);
|
||||
assertEquals(deletedRoleId, roleId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRoleShouldNotGetDeletedIfActiveUserExists() {
|
||||
final Integer roleId = RolesHelper.createRole(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(roleId);
|
||||
|
||||
final Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
|
||||
Assert.assertNotNull(staffId);
|
||||
|
||||
final Integer userId = UserHelper.createUser(this.requestSpec, this.responseSpec, roleId, staffId);
|
||||
Assert.assertNotNull(userId);
|
||||
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(403).build();
|
||||
final Integer deletedRoleId = RolesHelper.deleteRole(this.requestSpec, this.responseSpec, roleId);
|
||||
assertNotEquals(deletedRoleId, roleId);
|
||||
}
|
||||
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
/**
|
||||
* 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 com.sun.jersey.core.util.Base64;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mifosplatform.integrationtests.common.ImageHelper;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
import org.mifosplatform.integrationtests.common.accounting.AccountHelper;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanTransactionHelper;
|
||||
import org.mifosplatform.integrationtests.common.organisation.StaffHelper;
|
||||
|
||||
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.io.IOException;
|
||||
|
||||
public class StaffImageApiTest {
|
||||
|
||||
private RequestSpecification requestSpec;
|
||||
private ResponseSpecification responseSpec;
|
||||
private LoanTransactionHelper loanTransactionHelper;
|
||||
private AccountHelper accountHelper;
|
||||
|
||||
@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.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||
this.accountHelper = new AccountHelper(this.requestSpec, this.responseSpec);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createStaffImage() {
|
||||
|
||||
Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
|
||||
Integer imageId = ImageHelper.createImageForStaff(this.requestSpec, this.responseSpec, staffId);
|
||||
Assert.assertNotNull("Image id should not be null", imageId);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getStaffImage(){
|
||||
Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
|
||||
Integer imageId = ImageHelper.createImageForStaff(this.requestSpec, this.responseSpec, staffId);
|
||||
Assert.assertNotNull("Image id should not be null", imageId);
|
||||
String imageAsText = ImageHelper.getStaffImageAsText(this.requestSpec, this.responseSpec, staffId);
|
||||
Assert.assertNotNull("Image id should not be null", imageAsText);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getStaffImageAsBinary(){
|
||||
Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
|
||||
Integer imageId = ImageHelper.createImageForStaff(this.requestSpec, this.responseSpec, staffId);
|
||||
Assert.assertNotNull("Image id should not be null", imageId);
|
||||
byte[] imageAsBytes = ImageHelper.getStaffImageAsBinary(this.requestSpec, this.responseSpec, staffId);
|
||||
Assert.assertNotNull("Image content should not be null", imageAsBytes);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateImage() {
|
||||
|
||||
Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
|
||||
Integer imageId = ImageHelper.createImageForStaff(this.requestSpec, this.responseSpec, staffId);
|
||||
Assert.assertNotNull("Image id should not be null", imageId);
|
||||
imageId = ImageHelper.updateImageForStaff(this.requestSpec, this.responseSpec, staffId);
|
||||
Assert.assertNotNull("Image id should not be null", imageId);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteStaffImage() {
|
||||
|
||||
Integer staffId = StaffHelper.createStaff(this.requestSpec, this.responseSpec);
|
||||
Integer imageId = ImageHelper.createImageForStaff(this.requestSpec, this.responseSpec, staffId);
|
||||
Assert.assertNotNull("Image id should not be null", imageId);
|
||||
imageId = ImageHelper.deleteStaffImage(this.requestSpec, this.responseSpec, staffId);
|
||||
Assert.assertNotNull("Image id should not be null", imageId);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+226
@@ -0,0 +1,226 @@
|
||||
/**
|
||||
* 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.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
import org.mifosplatform.integrationtests.common.organisation.StaffHelper;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
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 StaffTest {
|
||||
|
||||
private RequestSpecification requestSpec;
|
||||
private ResponseSpecification responseSpec;
|
||||
private ResponseSpecification responseSpecForValidationError;
|
||||
private ResponseSpecification responseSpecForNotFoundError;
|
||||
|
||||
@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.responseSpecForNotFoundError = new ResponseSpecBuilder().expectStatusCode(404).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStaffCreate() {
|
||||
final HashMap response = StaffHelper.createStaffMap(requestSpec, responseSpec);
|
||||
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertEquals(response.get("officeId"), 1);
|
||||
Assert.assertNotNull(response.get("resourceId"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStaffCreateValidationError() {
|
||||
|
||||
final String noOfficeJson = StaffHelper.createStaffWithJSONFields("firstname", "lastname");
|
||||
final String noFirstnameJson = StaffHelper.createStaffWithJSONFields("officeId", "lastname");
|
||||
final String noLastnameJson = StaffHelper.createStaffWithJSONFields("officeId", "firstname");
|
||||
|
||||
StaffHelper.createStaffWithJson(requestSpec, responseSpecForValidationError, noOfficeJson);
|
||||
StaffHelper.createStaffWithJson(requestSpec, responseSpecForValidationError, noFirstnameJson);
|
||||
StaffHelper.createStaffWithJson(requestSpec, responseSpecForValidationError, noLastnameJson);
|
||||
|
||||
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));
|
||||
|
||||
/** Long firstname test */
|
||||
map.put("firstname", Utils.randomNameGenerator("michael_", 43));
|
||||
StaffHelper.createStaffWithJson(requestSpec, responseSpecForValidationError, new Gson().toJson(map));
|
||||
map.put("firstname", Utils.randomNameGenerator("michael_", 5));
|
||||
|
||||
/** Long lastname test */
|
||||
map.put("lastname", Utils.randomNameGenerator("Doe_", 47));
|
||||
StaffHelper.createStaffWithJson(requestSpec, responseSpecForValidationError, new Gson().toJson(map));
|
||||
map.put("lastname", Utils.randomNameGenerator("Doe_",4));
|
||||
|
||||
/** Long mobileNo test */
|
||||
map.put("mobileNo", Utils.randomNameGenerator("num_", 47));
|
||||
StaffHelper.createStaffWithJson(requestSpec, responseSpecForValidationError, new Gson().toJson(map));
|
||||
}
|
||||
|
||||
public void testStaffCreateMaxNameLength() {
|
||||
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
|
||||
map.put("officeId", 1);
|
||||
map.put("firstname", Utils.randomNameGenerator("michael_", 42));
|
||||
map.put("lastname", Utils.randomNameGenerator("Doe_", 46));
|
||||
|
||||
StaffHelper.createStaffWithJson(requestSpec, responseSpec, new Gson().toJson(map));
|
||||
}
|
||||
|
||||
public void testStaffCreateExternalIdValidationError() {
|
||||
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("externalId", Utils.randomStringGenerator("EXT", 98));
|
||||
StaffHelper.createStaffWithJson(requestSpec, responseSpecForValidationError, new Gson().toJson(map));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStaffFetch() {
|
||||
final HashMap response = StaffHelper.getStaff(requestSpec, responseSpec, 1);
|
||||
Assert.assertNotNull(response);
|
||||
Assert.assertNotNull(response.get("id"));
|
||||
Assert.assertEquals(response.get("id"), 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStaffListFetch() {
|
||||
StaffHelper.getStaffList(requestSpec, responseSpec);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStaffListStatusAll() {
|
||||
StaffHelper.getStaffListWithState(requestSpec, responseSpec, "all");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStaffListStatusActive() {
|
||||
final List<HashMap> responseActive = (List<HashMap>) StaffHelper.getStaffListWithState(requestSpec, responseSpec, "active");
|
||||
for(final HashMap staff : responseActive) {
|
||||
Assert.assertNotNull(staff.get("id"));
|
||||
Assert.assertEquals(staff.get("isActive"), true);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStaffListStatusInactive() {
|
||||
final List<HashMap> responseInactive = (List<HashMap>) StaffHelper.getStaffListWithState(requestSpec, responseSpec, "inactive");
|
||||
|
||||
for(final HashMap staff : responseInactive) {
|
||||
Assert.assertNotNull(staff.get("id"));
|
||||
Assert.assertEquals(staff.get("isActive"), false);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStaffListFetchWrongState() {
|
||||
StaffHelper.getStaffListWithState(requestSpec, responseSpecForValidationError, "xyz");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStaffFetchNotFound() {
|
||||
StaffHelper.getStaff(requestSpec, responseSpecForNotFoundError, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStaffUpdate() {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
final String firstname = Utils.randomNameGenerator("michael_", 10);
|
||||
final String lastname = Utils.randomNameGenerator("Doe_", 10);
|
||||
final String externalId = Utils.randomStringGenerator("EXT", 97);
|
||||
final String mobileNo = Utils.randomStringGenerator("num_", 10);
|
||||
|
||||
map.put("firstname", firstname);
|
||||
map.put("lastname", lastname);
|
||||
map.put("externalId", externalId);
|
||||
map.put("mobileNo", mobileNo);
|
||||
|
||||
final HashMap response = (HashMap) StaffHelper.updateStaff(requestSpec, responseSpec, 1, map);
|
||||
final HashMap changes = (HashMap) response.get("changes");
|
||||
|
||||
Assert.assertEquals(1, response.get("resourceId"));
|
||||
Assert.assertEquals(firstname, changes.get("firstname"));
|
||||
Assert.assertEquals(lastname, changes.get("lastname"));
|
||||
Assert.assertEquals(externalId, changes.get("externalId"));
|
||||
Assert.assertEquals(mobileNo, changes.get("mobileNo"));
|
||||
}
|
||||
|
||||
public void testStaffUpdateLongExternalIdError() {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("externalId", Utils.randomStringGenerator("EXT", 98));
|
||||
|
||||
StaffHelper.updateStaff(requestSpec, responseSpecForValidationError, 1, map);
|
||||
}
|
||||
|
||||
public void testStaffUpdateWrongActiveState() {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("isActive", "xyz");
|
||||
|
||||
StaffHelper.updateStaff(requestSpec, responseSpecForValidationError, 1, map);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStaffUpdateNotFoundError() {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("firstname", Utils.randomNameGenerator("michael_", 5));
|
||||
|
||||
StaffHelper.updateStaff(requestSpec, responseSpecForNotFoundError, Integer.MAX_VALUE, map);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStaffUpdateValidationError() {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
final String firstname = Utils.randomNameGenerator("michael_", 5);
|
||||
final String lastname = Utils.randomNameGenerator("Doe_", 4);
|
||||
final String firstnameLong = Utils.randomNameGenerator("michael_", 43);
|
||||
final String lastnameLong = Utils.randomNameGenerator("Doe_", 47);
|
||||
|
||||
map.put("firstname", firstname);
|
||||
map.put("lastname", lastname);
|
||||
|
||||
/** Test long firstname */
|
||||
map.put("firstname", firstnameLong);
|
||||
StaffHelper.updateStaff(requestSpec, responseSpecForValidationError, 1, map);
|
||||
map.put("firstname", firstname);
|
||||
|
||||
/** Test long lastname */
|
||||
map.put("lastname", lastnameLong);
|
||||
StaffHelper.updateStaff(requestSpec, responseSpecForValidationError, 1, map);
|
||||
map.put("lastname", lastname);
|
||||
|
||||
/** Long mobileNo test */
|
||||
map.put("mobileNo", Utils.randomNameGenerator("num_", 47));
|
||||
StaffHelper.updateStaff(requestSpec, responseSpecForValidationError, 1, map);
|
||||
map.remove("mobileNo");
|
||||
|
||||
/** Test unsupported parameter */
|
||||
map.put("xyz", "xyz");
|
||||
StaffHelper.updateStaff(requestSpec, responseSpecForValidationError, 1, map);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -160,7 +160,7 @@ public class SystemCodeTest {
|
||||
@Test
|
||||
public void testCodeValuesNotAssignedToTable() {
|
||||
|
||||
final String codeName = "Marital Status1";
|
||||
final String codeName = Utils.randomNameGenerator("Marital Status1", 10);
|
||||
|
||||
final String codeValue1 = "Married1";
|
||||
final String codeValue2 = "Unmarried1";
|
||||
|
||||
Executable
+57
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* 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.CommonConstants;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
import org.mifosplatform.integrationtests.common.WorkingDaysHelper;
|
||||
|
||||
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", "unchecked" })
|
||||
public class WorkingDaysTest {
|
||||
|
||||
private ResponseSpecification responseSpec;
|
||||
private RequestSpecification requestSpec;
|
||||
private ResponseSpecification generalResponseSpec;
|
||||
|
||||
@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();
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateWorkingDays() {
|
||||
HashMap response = (HashMap) WorkingDaysHelper.updateWorkingDays(requestSpec, responseSpec);
|
||||
Assert.assertNotNull(response.get("resourceId"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateWorkingDaysWithWrongRecurrencePattern() {
|
||||
final List<HashMap> error = (List) WorkingDaysHelper.updateWorkingDaysWithWrongRecurrence(requestSpec, generalResponseSpec,
|
||||
CommonConstants.RESPONSE_ERROR);
|
||||
assertEquals("Verify wrong recurrence pattern error", "error.msg.recurring.rule.parsing.error",
|
||||
error.get(0).get("userMessageGlobalisationCode"));
|
||||
}
|
||||
|
||||
}
|
||||
+29
-14
@@ -20,29 +20,43 @@ public class CalendarHelper {
|
||||
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) {
|
||||
|
||||
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;
|
||||
|
||||
|
||||
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");
|
||||
|
||||
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) {
|
||||
|
||||
public static Integer updateMeetingCalendarForGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer groupId, String calendarID, final String startDate, final String frequency, final String interval,
|
||||
final String repeatsOnDay) {
|
||||
|
||||
System.out.println("---------------------------------UPDATING A MEETING CALENDAR FOR THE GROUP------------------------------");
|
||||
|
||||
final String CALENDAR_RESOURCE_URL = BASE_URL + PARENT_ENTITY_NAME + groupId + ENITY_NAME + "/" + calendarID;
|
||||
|
||||
System.out.println(CALENDAR_RESOURCE_URL);
|
||||
// TODO: check that resource id indeed exists in calendar update put.
|
||||
return Utils.performServerPut(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("repeatsOnDay", repeatsOnDay);
|
||||
map.put("title", Utils.randomNameGenerator("groups_CollectionMeeting", 4));
|
||||
map.put("typeId", "1");
|
||||
map.put("startDate", startDate);
|
||||
@@ -54,7 +68,8 @@ public class CalendarHelper {
|
||||
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 String responseCalendarDetailsinJSON = Utils.performServerGet(requestSpec, responseSpec, CLIENT_URL,
|
||||
"collectionMeetingCalendar");
|
||||
final Integer responseCalendarId = from(responseCalendarDetailsinJSON).get("id");
|
||||
assertEquals("ERROR IN CREATING THE CALENDAR", generatedCalendarId, responseCalendarId);
|
||||
}
|
||||
|
||||
+235
@@ -0,0 +1,235 @@
|
||||
/**
|
||||
* 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 org.mifosplatform.infrastructure.core.service.DateUtils;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class CenterDomain implements Comparable<CenterDomain> {
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private Integer id;
|
||||
private String accountNo;
|
||||
private HashMap status;
|
||||
private boolean active;
|
||||
private String name;
|
||||
private String externalId;
|
||||
private Integer staffId;
|
||||
private Integer officeId;
|
||||
private String officeName;
|
||||
private String hierarchy;
|
||||
private ArrayList<HashMap> groupMembers;
|
||||
|
||||
private Builder(final Integer id, final Integer statusid, final String statuscode, final String statusvalue, final boolean active,
|
||||
final String name, final String externalId, final Integer staffId, final int officeID, final String officeName,
|
||||
final String hierarchy, final ArrayList<HashMap> groupMembers) {
|
||||
this.id = id;
|
||||
this.accountNo = accountNo;
|
||||
this.status = new HashMap();
|
||||
this.status.put("id", statusid);
|
||||
this.status.put("code", statuscode);
|
||||
this.status.put("value", statusvalue);
|
||||
this.active = active;
|
||||
this.name = name;
|
||||
this.externalId = externalId;
|
||||
this.staffId = staffId;
|
||||
this.officeId = officeID;
|
||||
this.officeName = officeName;
|
||||
this.hierarchy = hierarchy;
|
||||
this.groupMembers = groupMembers;
|
||||
}
|
||||
|
||||
public CenterDomain build() {
|
||||
return new CenterDomain(this.id, this.accountNo, (int) this.status.get("id"), (String) this.status.get("code"),
|
||||
(String) this.status.get("value"), this.active, this.name, this.externalId, this.staffId, this.officeId,
|
||||
this.officeName, this.hierarchy, groupMembers);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Integer id;
|
||||
private String accountNo;
|
||||
private HashMap status;
|
||||
private boolean active;
|
||||
private String name;
|
||||
private String externalId;
|
||||
private Integer staffId;
|
||||
private Integer officeId;
|
||||
private String officeName;
|
||||
private String hierarchy;
|
||||
private ArrayList<HashMap> groupMembers;
|
||||
|
||||
CenterDomain() {
|
||||
/* super(); */
|
||||
}
|
||||
|
||||
private CenterDomain(final Integer id, final String accountNo, final Integer statusid, final String statuscode, final String statusvalue, final boolean active,
|
||||
final String name, final String externalId, final Integer staffId, final Integer officeID, final String officeName,
|
||||
final String hierarchy, final ArrayList<HashMap> groupMembers) {
|
||||
this.id = id;
|
||||
this.accountNo = accountNo;
|
||||
this.status = new HashMap();
|
||||
this.status.put("id", statusid);
|
||||
this.status.put("code", statuscode);
|
||||
this.status.put("value", statusvalue);
|
||||
this.active = active;
|
||||
this.name = name;
|
||||
this.externalId = externalId;
|
||||
this.staffId = staffId;
|
||||
this.officeId = officeID;
|
||||
this.officeName = officeName;
|
||||
this.hierarchy = hierarchy;
|
||||
this.groupMembers = groupMembers;
|
||||
}
|
||||
|
||||
public String toJSON() {
|
||||
return new Gson().toJson(this);
|
||||
}
|
||||
|
||||
public static CurrencyDomain fromJSON(final String jsonData) {
|
||||
return new Gson().fromJson(jsonData, CurrencyDomain.class);
|
||||
}
|
||||
|
||||
public static Builder create(final Integer id, final Integer statusid, final String statuscode, final String statusvalue,
|
||||
final boolean active, final String name, final String externalId, final Integer staffId, final Integer officeID,
|
||||
final String officeName, final String hierarchy, final ArrayList<HashMap> groupMembers) {
|
||||
return new Builder(id, statusid, statuscode, statusvalue, active, name, externalId, staffId, officeID, officeName, hierarchy,
|
||||
groupMembers);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public static String jsonRequestToCreateCenter(Integer id, Integer statusId, String statusCode, String statusValue, Boolean active,
|
||||
String activationDate, String submittedDate, String name, String externalId, Integer staffId, Integer officeID,
|
||||
String officeName, String hierarchy, final int[] groupMembers) {
|
||||
// String ids = String.valueOf(id);
|
||||
final HashMap map = new HashMap<>();
|
||||
if (id != null) map.put("id", id);
|
||||
if (statusId != null) map.put("statusId", statusId);
|
||||
if (statusCode != null) map.put("statusCode", statusCode);
|
||||
if (statusValue != null) map.put("statusValue", statusValue);
|
||||
map.put("officeId", "1");
|
||||
map.put("name", randomNameGenerator("Center_Name_", 5));
|
||||
map.put("externalId", randomIDGenerator("ID_", 7));
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("locale", "en");
|
||||
if (staffId != null) {
|
||||
map.put("staffId", String.valueOf(staffId));
|
||||
}
|
||||
if (active) {
|
||||
map.put("active", "true");
|
||||
map.put("locale", "en");
|
||||
map.put("dateFormat", "dd MMM yyyy");
|
||||
map.put("activationDate", activationDate);
|
||||
} else {
|
||||
map.put("active", "false");
|
||||
if (submittedDate == null)
|
||||
map.put("submittedOnDate", DateUtils.getDateOfTenant());
|
||||
else
|
||||
map.put("submittedOnDate", submittedDate);
|
||||
}
|
||||
if (externalId != null) map.put("externalId", externalId);
|
||||
if (groupMembers != null) map.put("groupMembers", groupMembers);
|
||||
System.out.println(map);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
public static String randomNameGenerator(final String prefix, final int lenOfRandomSuffix) {
|
||||
return Utils.randomStringGenerator(prefix, lenOfRandomSuffix);
|
||||
}
|
||||
|
||||
private static String randomIDGenerator(final String prefix, final int lenOfRandomSuffix) {
|
||||
return Utils.randomStringGenerator(prefix, lenOfRandomSuffix, "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||
}
|
||||
|
||||
public String getExternalId() {
|
||||
return this.externalId;
|
||||
}
|
||||
|
||||
public Integer getStaffId() {
|
||||
return this.staffId;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public HashMap getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return this.active;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public Integer getOfficeId() {
|
||||
return this.officeId;
|
||||
}
|
||||
|
||||
public String getOfficeName() {
|
||||
return this.officeName;
|
||||
}
|
||||
|
||||
public String getHierarchy() {
|
||||
return this.hierarchy;
|
||||
}
|
||||
|
||||
public String getAccountNo(){
|
||||
return this.accountNo;
|
||||
}
|
||||
|
||||
public int[] getGroupMembers() {
|
||||
int[] groupMemberList = new int[this.groupMembers.size()];
|
||||
for (int i = 0; i < groupMemberList.length; i++) {
|
||||
groupMemberList[i] = ((Double) this.groupMembers.get(i).get("id")).intValue();
|
||||
}
|
||||
return groupMemberList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 1;
|
||||
|
||||
if (this.id >= 0) hash += this.id;
|
||||
if (this.status != null) {
|
||||
if ((Double) this.status.get("id") >= 0) hash += (Double) this.status.get("id");
|
||||
if ((String) this.status.get("code") != null) hash += this.status.get("code").hashCode();
|
||||
if ((String) this.status.get("value") != null) hash += this.status.get("value").hashCode();
|
||||
}
|
||||
if (this.name != null) hash += this.name.hashCode();
|
||||
if (this.officeId >= 0) hash += this.officeId;
|
||||
if (this.officeName != null) hash += this.officeName.hashCode();
|
||||
if (this.hierarchy != null) hash += this.hierarchy.hashCode();
|
||||
if (this.groupMembers != null) hash += this.groupMembers.hashCode();
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) { return true; }
|
||||
|
||||
if (!(obj instanceof CenterDomain)) return false;
|
||||
|
||||
CenterDomain cd = (CenterDomain) obj;
|
||||
|
||||
if (this.hashCode() == cd.hashCode()) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(CenterDomain cd) {
|
||||
return ((Integer) this.id).compareTo(cd.getId());
|
||||
}
|
||||
}
|
||||
+255
@@ -0,0 +1,255 @@
|
||||
/**
|
||||
* 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 static org.junit.Assert.assertEquals;
|
||||
import java.util.HashMap;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public class CenterHelper {
|
||||
|
||||
private static final String CENTERS_URL = "/mifosng-provider/api/v1/centers";
|
||||
|
||||
public static final String CREATED_DATE = "29 December 2014";
|
||||
private static final String CREATE_CENTER_URL = "/mifosng-provider/api/v1/centers?" + Utils.TENANT_IDENTIFIER;
|
||||
|
||||
public static CenterDomain retrieveByID(int id, final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
final String GET_CENTER_BY_ID_URL = CENTERS_URL + "/" + id + "?associations=groupMembers&" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("------------------------ RETRIEVING CENTER AT " + id + "-------------------------");
|
||||
final String jsonData = new Gson().toJson(Utils.performServerGet(requestSpec, responseSpec, GET_CENTER_BY_ID_URL, ""));
|
||||
return new Gson().fromJson(jsonData, new TypeToken<CenterDomain>() {}.getType());
|
||||
}
|
||||
|
||||
public static ArrayList<CenterDomain> paginatedListCenters(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec) {
|
||||
final String GET_CENTER = CENTERS_URL + "?paged=true&limit=-1&" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("------------------------ RETRIEVING CENTERS-------------------------");
|
||||
final String jsonData = new Gson().toJson(Utils.performServerGet(requestSpec, responseSpec, GET_CENTER, "pageItems"));
|
||||
return new Gson().fromJson(jsonData, new TypeToken<ArrayList<CenterDomain>>() {}.getType());
|
||||
}
|
||||
|
||||
public static ArrayList<CenterDomain> listCenters(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
final String GET_CENTER = CENTERS_URL + "?limit=-1&" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("------------------------ RETRIEVING CENTERS-------------------------");
|
||||
final String jsonData = new Gson().toJson(Utils.performServerGet(requestSpec, responseSpec, GET_CENTER, ""));
|
||||
return new Gson().fromJson(jsonData, new TypeToken<ArrayList<CenterDomain>>() {}.getType());
|
||||
}
|
||||
|
||||
public static int createCenter(final String name, final int officeId, final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec) {
|
||||
return createCenter(name, officeId, null, -1, null, null, requestSpec, responseSpec);
|
||||
}
|
||||
|
||||
public static int createCenter(final String name, final int officeId, final String activationDate,
|
||||
final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
return createCenter(name, officeId, null, -1, null, activationDate, requestSpec, responseSpec);
|
||||
}
|
||||
|
||||
public static int createCenter(final String name, final int officeId, final String externalId, final int staffId,
|
||||
final int[] groupMembers, final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
return createCenter(name, officeId, externalId, staffId, groupMembers, null, requestSpec, responseSpec);
|
||||
}
|
||||
|
||||
public static int createCenter(final String name, final int officeId, final String externalId, final int staffId,
|
||||
final int[] groupMembers, final String activationDate, final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec) {
|
||||
final String CREATE_CENTER_URL = CENTERS_URL + "?" + Utils.TENANT_IDENTIFIER;
|
||||
HashMap hm = new HashMap();
|
||||
hm.put("name", name);
|
||||
hm.put("officeId", officeId);
|
||||
hm.put("active", false);
|
||||
|
||||
if (externalId != null) hm.put("externalId", externalId);
|
||||
if (staffId != -1) hm.put("staffId", staffId);
|
||||
if (groupMembers != null) hm.put("groupMembers", groupMembers);
|
||||
if (activationDate != null) {
|
||||
hm.put("active", true);
|
||||
hm.put("locale", "en");
|
||||
hm.put("dateFormat", "dd MMM yyyy");
|
||||
hm.put("activationDate", activationDate);
|
||||
}
|
||||
|
||||
System.out.println("------------------------CREATING CENTER-------------------------");
|
||||
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CENTER_URL, new Gson().toJson(hm), "resourceId");
|
||||
}
|
||||
|
||||
public static HashMap<String, String> updateCenter(final int id, HashMap request, final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec) {
|
||||
final String UPDATE_CENTER_URL = CENTERS_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("---------------------------------UPDATE CENTER AT " + id + "---------------------------------------------");
|
||||
HashMap<String, String> hash = Utils.performServerPut(requestSpec, responseSpec, UPDATE_CENTER_URL, new Gson().toJson(request),
|
||||
"changes");
|
||||
return hash;
|
||||
}
|
||||
|
||||
public static int[] associateGroups(final int id, final int[] groupMembers, final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec) {
|
||||
final String ASSOCIATE_GROUP_CENTER_URL = CENTERS_URL + "/" + id + "?command=associateGroups&" + Utils.TENANT_IDENTIFIER;
|
||||
HashMap groupMemberHashMap = new HashMap();
|
||||
groupMemberHashMap.put("groupMembers", groupMembers);
|
||||
System.out.println("---------------------------------ASSOCIATING GROUPS AT " + id + "--------------------------------------------");
|
||||
HashMap hash = Utils.performServerPost(requestSpec, responseSpec, ASSOCIATE_GROUP_CENTER_URL,
|
||||
new Gson().toJson(groupMemberHashMap), "changes");
|
||||
System.out.println(hash);
|
||||
ArrayList<String> arr = (ArrayList<String>) hash.get("groupMembers");
|
||||
int[] ret = new int[arr.size()];
|
||||
for (int i = 0; i < ret.length; i++) {
|
||||
ret[i] = Integer.parseInt(arr.get(i));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static void deleteCenter(final int id, final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
final String DELETE_CENTER_URL = CENTERS_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("---------------------------------DELETING CENTER AT " + id + "--------------------------------------------");
|
||||
Utils.performServerDelete(requestSpec, responseSpec, DELETE_CENTER_URL, "");
|
||||
}
|
||||
|
||||
public static Integer createCenter(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
@SuppressWarnings("unused") final boolean active) {
|
||||
System.out.println("---------------------------------CREATING A CENTER---------------------------------------------");
|
||||
return createCenter(requestSpec, responseSpec, "CREATED_DATE");
|
||||
}
|
||||
|
||||
public static Integer createCenter(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String activationDate) {
|
||||
System.out.println("---------------------------------CREATING A CENTER---------------------------------------------");
|
||||
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CENTER_URL, getTestCenterAsJSON(true, activationDate), "groupId");
|
||||
}
|
||||
|
||||
public static Integer createCenter(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
System.out.println("---------------------------------CREATING A CENTER---------------------------------------------");
|
||||
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CENTER_URL, getTestCenterAsJSON(true, CenterHelper.CREATED_DATE),
|
||||
"groupId");
|
||||
}
|
||||
|
||||
public static int createCenterWithStaffId(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer staffId) {
|
||||
System.out.println("---------------------------------CREATING A CENTER---------------------------------------------");
|
||||
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CENTER_URL,
|
||||
getTestCenterWithStaffAsJSON(true, CenterHelper.CREATED_DATE, staffId), "groupId");
|
||||
}
|
||||
|
||||
public static void verifyCenterCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer generatedCenterID) {
|
||||
System.out.println("------------------------------CHECK CENTER DETAILS------------------------------------\n");
|
||||
final String CENTER_URL = "/mifosng-provider/api/v1/centers/" + generatedCenterID + "?" + Utils.TENANT_IDENTIFIER;
|
||||
final Integer responseCenterID = Utils.performServerGet(requestSpec, responseSpec, CENTER_URL, "id");
|
||||
assertEquals("ERROR IN CREATING THE CENTER", generatedCenterID, responseCenterID);
|
||||
}
|
||||
|
||||
public static void verifyCenterActivatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer generatedCenterID, final boolean generatedCenterStatus) {
|
||||
System.out.println("------------------------------CHECK CENTER STATUS------------------------------------\n");
|
||||
final String CENTER_URL = "/mifosng-provider/api/v1/centers/" + generatedCenterID + "?" + Utils.TENANT_IDENTIFIER;
|
||||
final Boolean responseCenterStatus = Utils.performServerGet(requestSpec, responseSpec, CENTER_URL, "active");
|
||||
assertEquals("ERROR IN ACTIVATING THE CENTER", generatedCenterStatus, responseCenterStatus);
|
||||
}
|
||||
|
||||
public static Integer activateCenter(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String centerId) {
|
||||
final String CENTER_ASSOCIATE_URL = "/mifosng-provider/api/v1/centers/" + centerId + "?command=activate&" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("---------------------------------ACTIVATE A CENTER---------------------------------------------");
|
||||
return Utils.performServerPost(requestSpec, responseSpec, CENTER_ASSOCIATE_URL, activateCenterAsJSON(""), "groupId");
|
||||
}
|
||||
|
||||
public static String getTestCenterWithStaffAsJSON(final boolean active, final String activationDate, final Integer staffId) {
|
||||
|
||||
Integer id = null;
|
||||
Integer statusid = null;
|
||||
String statuscode = null;
|
||||
String statusvalue = null;
|
||||
String name = null;
|
||||
String externalId = null;
|
||||
Integer officeID = null;
|
||||
String officeName = null;
|
||||
String hierarchy = null;
|
||||
int[] groupMembers = null;
|
||||
String submittedDate = null;
|
||||
|
||||
return CenterDomain.jsonRequestToCreateCenter(id, statusid, statuscode, statusvalue, active, activationDate,submittedDate,name,
|
||||
externalId, staffId, officeID, officeName, hierarchy, groupMembers);
|
||||
}
|
||||
|
||||
public static String getTestCenterAsJSON(final boolean active, final String activationDate) {
|
||||
|
||||
Integer id = null;
|
||||
Integer statusid = null;
|
||||
String statuscode = null;
|
||||
String statusvalue = null;
|
||||
String name = null;
|
||||
String externalId = null;
|
||||
Integer officeID = null;
|
||||
String officeName = null;
|
||||
Integer staffId = null;
|
||||
String hierarchy = null;
|
||||
final int[] groupMembers = null;
|
||||
String submittedDate = null;
|
||||
|
||||
return CenterDomain.jsonRequestToCreateCenter(id, statusid, statuscode, statusvalue, active, activationDate,submittedDate,name,
|
||||
externalId, staffId, officeID, officeName, hierarchy, groupMembers);
|
||||
|
||||
}
|
||||
|
||||
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 unassignStaffAsJSON(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 activateCenterAsJSON(final String activationDate) {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("locale", "en");
|
||||
if (StringUtils.isNotEmpty(activationDate)) {
|
||||
map.put("activationDate", activationDate);
|
||||
} else {
|
||||
map.put("activationDate", "CREATED_DATE");
|
||||
System.out.println("defaulting to fixed date: CREATED_DATE");
|
||||
}
|
||||
System.out.println("map : " + map);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
public static String randomNameGenerator(final String prefix, final int lenOfRandomSuffix) {
|
||||
return Utils.randomStringGenerator(prefix, lenOfRandomSuffix);
|
||||
}
|
||||
|
||||
private static String randomIDGenerator(final String prefix, final int lenOfRandomSuffix) {
|
||||
return Utils.randomStringGenerator(prefix, lenOfRandomSuffix, "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||
}
|
||||
|
||||
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("---------------------------------Assign Staff---------------------------------------------");
|
||||
return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSIGN_STAFF_URL, assignStaffAsJSON(staffId), "changes");
|
||||
}
|
||||
|
||||
public static Object unassignStaff(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=unassignStaff";
|
||||
System.out.println("---------------------------------Unassign Staff---------------------------------------------");
|
||||
return Utils.performServerPost(requestSpec, responseSpec, GROUP_ASSIGN_STAFF_URL, unassignStaffAsJSON(staffId), "changes");
|
||||
}
|
||||
|
||||
}
|
||||
+85
-19
@@ -9,6 +9,8 @@ import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.mifosplatform.integrationtests.common.system.CodeHelper;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
@@ -23,7 +25,7 @@ public class ClientHelper {
|
||||
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 ACTIVATE_CLIENT_COMMAND = "activate";
|
||||
private static final String WITHDRAW_CLIENT_COMMAND = "withdraw";
|
||||
|
||||
public static final String CREATED_DATE = "27 November 2014";
|
||||
@@ -53,6 +55,16 @@ public class ClientHelper {
|
||||
"clientId");
|
||||
}
|
||||
|
||||
public static Integer createClientForAccountPreference(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final Integer clientType, String jsonAttributeToGetBack) {
|
||||
final String activationDate = "04 March 2011";
|
||||
final String officeId = "1";
|
||||
System.out
|
||||
.println("---------------------------------CREATING A CLIENT BASED ON ACCOUNT PREFERENCE---------------------------------------------");
|
||||
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL,
|
||||
getTestClientWithClientTypeAsJSON(activationDate, officeId, clientType.toString()), jsonAttributeToGetBack);
|
||||
}
|
||||
|
||||
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
|
||||
@@ -62,7 +74,8 @@ public class ClientHelper {
|
||||
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) {
|
||||
public static Integer getClientsStaffId(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String clientId) {
|
||||
return (Integer) getClient(requestSpec, responseSpec, clientId, "staffId");
|
||||
}
|
||||
|
||||
@@ -80,6 +93,21 @@ public class ClientHelper {
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
public static String getTestClientWithClientTypeAsJSON(final String dateOfJoining, final String officeId, final String clientType) {
|
||||
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));
|
||||
map.put("externalId", randomIDGenerator("ID_", 7));
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("locale", "en");
|
||||
map.put("active", "true");
|
||||
map.put("activationDate", dateOfJoining);
|
||||
map.put("clientTypeId", clientType);
|
||||
System.out.println("map : " + map);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
public static String assignStaffToClientAsJson(final String staffId) {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("staffId", staffId);
|
||||
@@ -98,15 +126,16 @@ public class ClientHelper {
|
||||
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,
|
||||
/* Client status is a map.So adding SuppressWarnings */
|
||||
@SuppressWarnings("unchecked")
|
||||
public static HashMap<String, Object> getClientStatus(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String clientId) {
|
||||
return (HashMap) getClient(requestSpec, responseSpec, clientId, "status");
|
||||
return (HashMap<String, Object>) getClient(requestSpec, responseSpec, clientId, "status");
|
||||
}
|
||||
|
||||
private static String randomIDGenerator(final String prefix, final int lenOfRandomSuffix) {
|
||||
@@ -115,15 +144,27 @@ public class ClientHelper {
|
||||
|
||||
private String getCloseClientAsJSON() {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
|
||||
/* Retrieve Code id for the Code "ClientClosureReason" */
|
||||
String codeName = "ClientClosureReason";
|
||||
HashMap<String, Object> code = CodeHelper.getCodeByName(this.requestSpec, this.responseSpec, codeName);
|
||||
Integer clientClosureCodeId = (Integer) code.get("id");
|
||||
|
||||
/* Retrieve/Create Code Values for the Code "ClientClosureReason" */
|
||||
HashMap<String, Object> codeValue = CodeHelper.retrieveOrCreateCodeValue(clientClosureCodeId, this.requestSpec, this.responseSpec);
|
||||
Integer closureReasonId = (Integer) codeValue.get("id");
|
||||
|
||||
map.put("closureReasonId", closureReasonId.toString());
|
||||
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);
|
||||
@@ -134,17 +175,29 @@ public class ClientHelper {
|
||||
return clientJson;
|
||||
|
||||
}
|
||||
|
||||
private String getRejectClientAsJSON() {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
/* Retrieve Code id for the Code "ClientRejectReason" */
|
||||
String codeName = "ClientRejectReason";
|
||||
HashMap<String, Object> code = CodeHelper.getCodeByName(this.requestSpec, this.responseSpec, codeName);
|
||||
Integer clientRejectionReasonCodeId = (Integer) code.get("id");
|
||||
|
||||
/* Retrieve/Create Code Values for the Code "ClientRejectReason" */
|
||||
HashMap<String, Object> codeValue = CodeHelper.retrieveOrCreateCodeValue(clientRejectionReasonCodeId, this.requestSpec,
|
||||
this.responseSpec);
|
||||
Integer rejectionReasonId = (Integer) codeValue.get("id");
|
||||
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("rejectDate", CREATED_DATE_PLUS_ONE);
|
||||
map.put("rejectReasonId", "15");
|
||||
map.put("rejectionDate", CREATED_DATE_PLUS_ONE);
|
||||
map.put("rejectionReasonId", rejectionReasonId.toString());
|
||||
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);
|
||||
@@ -158,45 +211,58 @@ public class ClientHelper {
|
||||
|
||||
private String getWithdrawClientAsJSON() {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
/* Retrieve Code id for the Code "ClientWithdrawReason" */
|
||||
String codeName = "ClientWithdrawReason";
|
||||
HashMap<String, Object> code = CodeHelper.getCodeByName(this.requestSpec, this.responseSpec, codeName);
|
||||
Integer clientWithdrawReasonCodeId = (Integer) code.get("id");
|
||||
|
||||
/* Retrieve/Create Code Values for the Code "ClientWithdrawReason" */
|
||||
HashMap<String, Object> codeValue = CodeHelper.retrieveOrCreateCodeValue(clientWithdrawReasonCodeId, this.requestSpec,
|
||||
this.responseSpec);
|
||||
Integer withdrawalReasonId = (Integer) codeValue.get("id");
|
||||
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("withdrawDate", CREATED_DATE_PLUS_ONE);
|
||||
map.put("withdrawReasonId", "17");
|
||||
map.put("withdrawalDate", CREATED_DATE_PLUS_ONE);
|
||||
map.put("withdrawalReasonId", withdrawalReasonId.toString());
|
||||
String clientJson = new Gson().toJson(map);
|
||||
System.out.println(clientJson);
|
||||
return clientJson;
|
||||
|
||||
}
|
||||
public HashMap closeClient(final Integer clientId) {
|
||||
|
||||
public HashMap<String, Object> closeClient(final Integer clientId) {
|
||||
System.out.println("--------------------------------- CLOSE CLIENT -------------------------------");
|
||||
return performClientActions(createClientOperationURL(CLOSE_CLIENT_COMMAND, clientId), getCloseClientAsJSON(), clientId);
|
||||
}
|
||||
|
||||
public HashMap reactivateClient(final Integer clientId) {
|
||||
public HashMap<String, Object> reactivateClient(final Integer clientId) {
|
||||
System.out.println("--------------------------------- REACTIVATE CLIENT -------------------------------");
|
||||
return performClientActions(createClientOperationURL(REACTIVATE_CLIENT_COMMAND, clientId), getReactivateClientAsJSON(), clientId);
|
||||
}
|
||||
public HashMap rejectClient(final Integer clientId) {
|
||||
|
||||
public HashMap<String, Object> rejectClient(final Integer clientId) {
|
||||
System.out.println("--------------------------------- REJECT CLIENT -------------------------------");
|
||||
return performClientActions(createClientOperationURL(REJECT_CLIENT_COMMAND, clientId), getRejectClientAsJSON(), clientId);
|
||||
}
|
||||
|
||||
public HashMap activateClient(final Integer clientId) {
|
||||
|
||||
public HashMap<String, Object> activateClient(final Integer clientId) {
|
||||
System.out.println("--------------------------------- ACTIVATE CLIENT -------------------------------");
|
||||
return performClientActions(createClientOperationURL(ACTIVATE_CLIENT_COMMAND, clientId), getActivateClientAsJSON(), clientId);
|
||||
}
|
||||
public HashMap withdrawClient(final Integer clientId) {
|
||||
|
||||
public HashMap<String, Object> 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;
|
||||
private HashMap<String, Object> performClientActions(final String postURLForClient, final String jsonToBeSent, final Integer clientId) {
|
||||
Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForClient, jsonToBeSent, CommonConstants.RESPONSE_STATUS);
|
||||
HashMap response = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
|
||||
HashMap<String, Object> response = ClientHelper.getClientStatus(requestSpec, responseSpec, String.valueOf(clientId));
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* 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.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
@SuppressWarnings({ "unused", "rawtypes", "unchecked" })
|
||||
public class CurrenciesHelper {
|
||||
|
||||
private static final String CURRENCIES_URL = "/mifosng-provider/api/v1/currencies";
|
||||
|
||||
public static ArrayList<CurrencyDomain> getAllCurrencies(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec) {
|
||||
final String GET_ALL_CURRENCIES_URL = CURRENCIES_URL + "?" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("------------------------ RETRIEVING ALL CURRENCIES -------------------------");
|
||||
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, GET_ALL_CURRENCIES_URL, "");
|
||||
ArrayList<HashMap> selectedCurrencyOptions = (ArrayList<HashMap>) response.get("selectedCurrencyOptions");
|
||||
ArrayList<HashMap> currencyOptions = (ArrayList<HashMap>) response.get("currencyOptions");
|
||||
currencyOptions.addAll(selectedCurrencyOptions);
|
||||
final String jsonData = new Gson().toJson(new ArrayList<HashMap>(selectedCurrencyOptions));
|
||||
return new Gson().fromJson(jsonData, new TypeToken<ArrayList<CurrencyDomain>>() {}.getType());
|
||||
}
|
||||
|
||||
public static ArrayList<CurrencyDomain> getSelectedCurrencies(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec) {
|
||||
final String GET_ALL_SELECTED_CURRENCIES_URL = CURRENCIES_URL + "?fields=selectedCurrencyOptions" + "&" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("------------------------ RETRIEVING ALL SELECTED CURRENCIES -------------------------");
|
||||
final HashMap response = Utils.performServerGet(requestSpec, responseSpec, GET_ALL_SELECTED_CURRENCIES_URL, "");
|
||||
final String jsonData = new Gson().toJson(response.get("selectedCurrencyOptions"));
|
||||
return new Gson().fromJson(jsonData, new TypeToken<ArrayList<CurrencyDomain>>() {}.getType());
|
||||
}
|
||||
|
||||
public static CurrencyDomain getCurrencybyCode(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String code) {
|
||||
ArrayList<CurrencyDomain> currenciesList = getAllCurrencies(requestSpec, responseSpec);
|
||||
for (CurrencyDomain e : currenciesList) {
|
||||
if (e.getCode().equals(code)) return e;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ArrayList<String> updateSelectedCurrencies(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final ArrayList<String> currencies) {
|
||||
final String CURRENCIES_UPDATE_URL = CURRENCIES_URL + "?" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("---------------------------------UPDATE SELECTED CURRENCIES LIST---------------------------------------------");
|
||||
HashMap hash = Utils.performServerPut(requestSpec, responseSpec, CURRENCIES_UPDATE_URL, currenciesToJSON(currencies), "changes");
|
||||
return (ArrayList<String>) hash.get("currencies");
|
||||
}
|
||||
|
||||
private static String currenciesToJSON(final ArrayList<String> currencies) {
|
||||
HashMap map = new HashMap<>();
|
||||
map.put("currencies", currencies);
|
||||
System.out.println("map : " + map);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
}
|
||||
+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.common;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class CurrencyDomain implements Comparable<CurrencyDomain> {
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private String code;
|
||||
private String name;
|
||||
private int decimalPlaces;
|
||||
private String displaySymbol;
|
||||
private String nameCode;
|
||||
private String displayLabel;
|
||||
|
||||
private Builder(final String code, final String name, final int decimalPlaces, final String displaySymbol, final String nameCode,
|
||||
final String displayLabel) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
this.decimalPlaces = decimalPlaces;
|
||||
this.displaySymbol = displaySymbol;
|
||||
this.nameCode = nameCode;
|
||||
this.displayLabel = displayLabel;
|
||||
}
|
||||
|
||||
public CurrencyDomain build() {
|
||||
return new CurrencyDomain(this.code, this.name, this.decimalPlaces, this.displaySymbol, this.nameCode, this.displayLabel);
|
||||
}
|
||||
}
|
||||
|
||||
private String code;
|
||||
private String name;
|
||||
private int decimalPlaces;
|
||||
private String displaySymbol;
|
||||
private String nameCode;
|
||||
private String displayLabel;
|
||||
|
||||
CurrencyDomain() {
|
||||
super();
|
||||
}
|
||||
|
||||
private CurrencyDomain(final String code, final String name, final int decimalPlaces, final String displaySymbol,
|
||||
final String nameCode, final String displayLabel) {
|
||||
super();
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
this.decimalPlaces = decimalPlaces;
|
||||
this.displaySymbol = displaySymbol;
|
||||
this.nameCode = nameCode;
|
||||
this.displayLabel = displayLabel;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public int getDecimalPlaces() {
|
||||
return this.decimalPlaces;
|
||||
}
|
||||
|
||||
public String getDisplaySymbol() {
|
||||
return this.displaySymbol;
|
||||
}
|
||||
|
||||
public String getNameCode() {
|
||||
return this.nameCode;
|
||||
}
|
||||
|
||||
public String getDisplayLabel() {
|
||||
return this.displayLabel;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String toJSON() {
|
||||
return new Gson().toJson(this);
|
||||
}
|
||||
|
||||
public static CurrencyDomain fromJSON(final String jsonData) {
|
||||
return new Gson().fromJson(jsonData, CurrencyDomain.class);
|
||||
}
|
||||
|
||||
public static Builder create(final String code, final String name, final int decimalPlaces, final String displaySymbol,
|
||||
final String nameCode, final String displayLabel) {
|
||||
return new Builder(code, name, decimalPlaces, displaySymbol, nameCode, displayLabel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 1;
|
||||
|
||||
if (this.name != null) hash += this.name.hashCode();
|
||||
if (this.code != null) hash += this.code.hashCode();
|
||||
if (this.decimalPlaces >= 0) hash += this.decimalPlaces;
|
||||
if (this.displaySymbol != null) hash += this.displaySymbol.hashCode();
|
||||
if (this.nameCode != null) hash += this.nameCode.hashCode();
|
||||
if (this.displayLabel != null) hash += this.displayLabel.hashCode();
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) { return true; }
|
||||
|
||||
if (!(obj instanceof CurrencyDomain)) return false;
|
||||
|
||||
CurrencyDomain cd = (CurrencyDomain) obj;
|
||||
|
||||
if (this.name.equals(cd.name) && this.code.equals(cd.code) && this.decimalPlaces == cd.decimalPlaces
|
||||
&& this.displaySymbol.equals(cd.displaySymbol) && this.nameCode.equals(cd.nameCode)
|
||||
&& this.displayLabel.equals(cd.displayLabel)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(CurrencyDomain cd) {
|
||||
return this.name.compareTo(cd.getName());
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* 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 ExternalServicesConfigurationHelper {
|
||||
|
||||
private final RequestSpecification requestSpec;
|
||||
private final ResponseSpecification responseSpec;
|
||||
|
||||
public ExternalServicesConfigurationHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
this.requestSpec = requestSpec;
|
||||
this.responseSpec = responseSpec;
|
||||
}
|
||||
|
||||
public static ArrayList<HashMap> getExternalServicesConfigurationByServiceName(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final String serviceName) {
|
||||
final String GET_EXTERNAL_SERVICES_CONFIG_BY_SERVICE_NAME_URL = "/mifosng-provider/api/v1/externalservice/" + serviceName + "?"
|
||||
+ Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("------------------------ RETRIEVING GLOBAL CONFIGURATION BY ID -------------------------");
|
||||
return Utils.performServerGet(requestSpec, responseSpec, GET_EXTERNAL_SERVICES_CONFIG_BY_SERVICE_NAME_URL, "");
|
||||
}
|
||||
|
||||
public static HashMap updateValueForExternaServicesConfiguration(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final String serviceName, final String name, final String value) {
|
||||
final String EXTERNAL_SERVICES_CONFIG_UPDATE_URL = "/mifosng-provider/api/v1/externalservice/" + serviceName + "?"
|
||||
+ Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("---------------------------------UPDATE VALUE FOR GLOBAL CONFIG---------------------------------------------");
|
||||
HashMap map = Utils.performServerPut(requestSpec, responseSpec, EXTERNAL_SERVICES_CONFIG_UPDATE_URL,
|
||||
updateExternalServicesConfigUpdateValueAsJSON(name, value), "");
|
||||
|
||||
return (HashMap) map.get("changes");
|
||||
}
|
||||
|
||||
public static String updateExternalServicesConfigUpdateValueAsJSON(final String name, final String value) {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put(name, value);
|
||||
System.out.println("map : " + map);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
}
|
||||
+19
@@ -7,6 +7,7 @@ package org.mifosplatform.integrationtests.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
@@ -70,6 +71,14 @@ public class GlobalConfigurationHelper {
|
||||
return Utils.performServerPut(requestSpec, responseSpec, IS_CACHE_GLOBAL_CONFIG_UPDATE_URL,
|
||||
updateIsCacheEnabledGlobalConfigUpdateAsJSON(cacheType), "changes");
|
||||
}
|
||||
|
||||
public static Object updatePasswordResetDaysForGlobalConfiguration(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final Integer configId, final String value, final String enabled, final String jsonAttributeToGetBack) {
|
||||
final String UPDATE_URL = "/mifosng-provider/api/v1/configurations/" + configId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("------------------UPDATE GLOBAL CONFIG FOR FORCE PASSWORD RESET DAYS----------------------");
|
||||
return Utils.performServerPut(requestSpec, responseSpec, UPDATE_URL,
|
||||
updatePasswordResetDaysGlobalConfigAsJSON(value, enabled), jsonAttributeToGetBack);
|
||||
}
|
||||
|
||||
public static String updateGlobalConfigUpdateValueAsJSON(final String value) {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
@@ -77,6 +86,16 @@ public class GlobalConfigurationHelper {
|
||||
System.out.println("map : " + map);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
public static String updatePasswordResetDaysGlobalConfigAsJSON(final String value, final String enabled) {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
if(value != null){
|
||||
map.put("value", value);
|
||||
}
|
||||
map.put("enabled", enabled);
|
||||
System.out.println("map : " + map);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
public static String updateGlobalConfigUpdateEnabledFlagAsJSON(final Boolean enabled) {
|
||||
final HashMap<String, Boolean> map = new HashMap<String, Boolean>();
|
||||
|
||||
+39
-1
@@ -5,10 +5,13 @@
|
||||
*/
|
||||
package org.mifosplatform.integrationtests.common;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.jayway.restassured.builder.ResponseSpecBuilder;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
@@ -18,7 +21,7 @@ public class HookHelper {
|
||||
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;
|
||||
@@ -48,5 +51,40 @@ public class HookHelper {
|
||||
System.out.println("map : " + map);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
public Integer updateHook(final String payloadURL, final Long hookId) {
|
||||
System.out.println("---------------------------------UPDATING HOOK---------------------------------------------");
|
||||
final String UPDATE_HOOK_URL = "/mifosng-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerPut(this.requestSpec, this.responseSpec, UPDATE_HOOK_URL, getTestHookAsJson(payloadURL), "resourceId");
|
||||
}
|
||||
|
||||
public Integer deleteHook(final Long hookId) {
|
||||
System.out.println("---------------------------------DELETING HOOK---------------------------------------------");
|
||||
final String DELETE_HOOK_URL = "/mifosng-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerDelete(this.requestSpec, this.responseSpec, DELETE_HOOK_URL, "resourceId");
|
||||
}
|
||||
|
||||
public void verifyHookCreatedOnServer(final Long hookId) {
|
||||
System.out.println("------------------------------CHECK CREATE HOOK DETAILS------------------------------------\n");
|
||||
final String GET_URL = "/mifosng-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
final Integer responseHookId = Utils.performServerGet(this.requestSpec, this.responseSpec, GET_URL, "id");
|
||||
assertEquals(hookId.toString(), responseHookId.toString());
|
||||
}
|
||||
|
||||
public void verifyUpdateHook(final String updateURL, final Long hookId) {
|
||||
System.out.println("------------------------------CHECK UPDATE HOOK DETAILS------------------------------------\n");
|
||||
final String GET_URL = "/mifosng-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
ArrayList map = Utils.performServerGet(this.requestSpec, this.responseSpec, GET_URL, "config");
|
||||
HashMap<String, String> hash = (HashMap<String, String>) map.get(1);
|
||||
assertEquals(updateURL, hash.get("fieldValue"));
|
||||
}
|
||||
|
||||
public void verifyDeleteHook(final Long hookId) {
|
||||
System.out.println("------------------------------CHECK DELETE HOOK DETAILS------------------------------------\n");
|
||||
final String GET_URL = "/mifosng-provider/api/v1/hooks/" + hookId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
ResponseSpecification responseSpec404 = new ResponseSpecBuilder().expectStatusCode(404).build();
|
||||
ArrayList array = Utils.performServerGet(this.requestSpec, responseSpec404, GET_URL, "errors");
|
||||
HashMap<String, String> map = (HashMap<String, String>)array.get(0);
|
||||
assertEquals("error.msg.hook.identifier.not.found",map.get("userMessageGlobalisationCode"));
|
||||
}
|
||||
}
|
||||
|
||||
+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 org.apache.http.HttpHeaders;
|
||||
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
public class ImageHelper {
|
||||
|
||||
private static final String STAFF_IMAGE_URL = "/mifosng-provider/api/v1/staff/";
|
||||
private static final String IMAGES_URI = "/images";
|
||||
|
||||
public static Integer createImageForStaff(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
Integer staffId) {
|
||||
System.out.println("---------------------------------CREATING AN IMAGE FOR STAFF---------------------------------------------");
|
||||
String URL = STAFF_IMAGE_URL + staffId + IMAGES_URI + "?" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerPost(requestSpec, responseSpec, URL, generateImageAsText(), "resourceId");
|
||||
}
|
||||
|
||||
public static Integer updateImageForStaff(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
Integer staffId) {
|
||||
System.out.println("---------------------------------UPDATING AN IMAGE FOR STAFF---------------------------------------------");
|
||||
String URL = STAFF_IMAGE_URL + staffId + IMAGES_URI + "?" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerPut(requestSpec, responseSpec, URL, generateImageAsText(), "resourceId");
|
||||
}
|
||||
|
||||
public static String getStaffImageAsText(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
Integer staffId) {
|
||||
System.out.println("---------------------------------RETRIEVING STAFF IMAGE---------------------------------------------");
|
||||
String URL = STAFF_IMAGE_URL + staffId + IMAGES_URI + "?" + Utils.TENANT_IDENTIFIER;
|
||||
requestSpec.header(HttpHeaders.ACCEPT, "text/plain");
|
||||
return Utils.performGetTextResponse(requestSpec, responseSpec, URL);
|
||||
}
|
||||
|
||||
public static byte[] getStaffImageAsBinary(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
Integer staffId) {
|
||||
System.out.println("---------------------------------RETRIEVING STAFF IMAGE---------------------------------------------");
|
||||
String URL = STAFF_IMAGE_URL + staffId + IMAGES_URI + "?" + Utils.TENANT_IDENTIFIER;
|
||||
requestSpec.header(HttpHeaders.ACCEPT, "application/octet-stream");
|
||||
return Utils.performGetBinaryResponse(requestSpec, responseSpec, URL);
|
||||
}
|
||||
|
||||
public static Integer deleteStaffImage(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, Integer staffId) {
|
||||
System.out.println("---------------------------------RETRIEVING STAFF IMAGE---------------------------------------------");
|
||||
String URL = STAFF_IMAGE_URL + staffId + IMAGES_URI + "?" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerDelete(requestSpec, responseSpec, URL, "resourceId");
|
||||
}
|
||||
|
||||
private static String generateImageAsText() {
|
||||
return "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJ\n"
|
||||
+ "bWFnZVJlYWR5ccllPAAAAJ1JREFUeNpi+P//PwMIA4E9EG8E4idQDGLbw+WhiiqA+D8OXAFVAzbp\n"
|
||||
+ "DxBvB2JLIGaGYkuoGEjOhhFIHAbij0BdPgxYACMj42ogJQpifwBiXSDeC8JIbt4LxSC5DyxQjTeB\n"
|
||||
+ "+BeaYb+Q5EBOAVutCzMJHUNNPADzzDokiYdAfAmJvwLkGeTgWQfyKZICS6hYBTwc0QL8ORSjBDhA\n" + "gAEAOg13B6R/SAgAAAAASUVORK5CYII=";
|
||||
}
|
||||
}
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
public class OfficeDomain {
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private int id;
|
||||
private String name;
|
||||
private String nameDecorated;
|
||||
private String externalId;
|
||||
private String[] openingDate;
|
||||
private String hierarchy;
|
||||
|
||||
private Builder(final int id, final String name,
|
||||
final String nameDecorated, final String externalId,
|
||||
final String[] openingDate, final String hierarchy) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.nameDecorated = nameDecorated;
|
||||
this.externalId = externalId;
|
||||
this.openingDate = openingDate;
|
||||
this.hierarchy = hierarchy;
|
||||
}
|
||||
|
||||
public OfficeDomain build() {
|
||||
return new OfficeDomain(this.id, this.name, this.nameDecorated,
|
||||
this.externalId, this.openingDate, this.hierarchy);
|
||||
}
|
||||
}
|
||||
|
||||
private int id;
|
||||
private String name;
|
||||
private String nameDecorated;
|
||||
private String externalId;
|
||||
private String[] openingDate;
|
||||
private String hierarchy;
|
||||
|
||||
OfficeDomain() {
|
||||
super();
|
||||
}
|
||||
|
||||
private OfficeDomain(final int id, final String name,
|
||||
final String nameDecorated, final String externalId,
|
||||
final String[] openingDate, final String hierarchy) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.nameDecorated = nameDecorated;
|
||||
this.externalId = externalId;
|
||||
this.openingDate = openingDate;
|
||||
this.hierarchy = hierarchy;
|
||||
}
|
||||
|
||||
public String toJSON() {
|
||||
return new Gson().toJson(this);
|
||||
}
|
||||
|
||||
public static OfficeDomain fromJSON(final String jsonData) {
|
||||
return new Gson().fromJson(jsonData, OfficeDomain.class);
|
||||
}
|
||||
|
||||
public static Builder create(final int id, final String name,
|
||||
final String nameDecorated, final String externalId,
|
||||
final String[] openingDate, final String hierarchy) {
|
||||
return new Builder(id, name, nameDecorated, externalId, openingDate,
|
||||
hierarchy);
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getNameDecorated() {
|
||||
return this.nameDecorated;
|
||||
}
|
||||
|
||||
public String getExternalId() {
|
||||
return this.externalId;
|
||||
}
|
||||
|
||||
public String[] getOpeningDate() {
|
||||
return this.openingDate;
|
||||
}
|
||||
|
||||
public String getHierarchy() {
|
||||
return this.hierarchy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 1;
|
||||
|
||||
if (this.id > 0)
|
||||
hash += this.id;
|
||||
if (this.name != null)
|
||||
hash += this.name.hashCode();
|
||||
if (this.nameDecorated != null)
|
||||
hash += this.nameDecorated.hashCode();
|
||||
if (this.externalId != null)
|
||||
hash += this.externalId.hashCode();
|
||||
if (this.openingDate != null)
|
||||
hash += this.openingDate.hashCode();
|
||||
if (this.hierarchy != null)
|
||||
hash += this.hierarchy.hashCode();
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(obj instanceof OfficeDomain))
|
||||
return false;
|
||||
|
||||
OfficeDomain od = (OfficeDomain) obj;
|
||||
|
||||
if (this.id == od.getId() && this.name.equals(od.getName())
|
||||
&& this.nameDecorated.equals(od.getName())
|
||||
&& this.externalId.equals(od.getExternalId())
|
||||
&& this.openingDate.equals(od.getOpeningDate())
|
||||
&& this.hierarchy.equals(od.getHierarchy()))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+47
-24
@@ -7,37 +7,60 @@ package org.mifosplatform.integrationtests.common;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
|
||||
public class OfficeHelper {
|
||||
|
||||
private static final String OFFICE_URL = "/mifosng-provider/api/v1/offices";
|
||||
private final RequestSpecification requestSpec;
|
||||
private final ResponseSpecification responseSpec;
|
||||
private static final String OFFICE_URL = "/mifosng-provider/api/v1/offices";
|
||||
private final RequestSpecification requestSpec;
|
||||
private final ResponseSpecification responseSpec;
|
||||
|
||||
public OfficeHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
this.requestSpec = requestSpec;
|
||||
this.responseSpec = responseSpec;
|
||||
}
|
||||
public OfficeHelper(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec) {
|
||||
this.requestSpec = requestSpec;
|
||||
this.responseSpec = responseSpec;
|
||||
}
|
||||
|
||||
public Integer createOffice(final String openingDate) {
|
||||
String json = getAsJSON(openingDate);
|
||||
return Utils.performServerPost(this.requestSpec, this.responseSpec, OFFICE_URL + "?" + Utils.TENANT_IDENTIFIER, json,
|
||||
CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
}
|
||||
public OfficeDomain retrieveOfficeByID(int id) {
|
||||
final String json = new Gson().toJson(Utils.performServerGet(
|
||||
requestSpec, responseSpec, OFFICE_URL + "/" + id + "?"
|
||||
+ Utils.TENANT_IDENTIFIER, ""));
|
||||
return new Gson().fromJson(json, new TypeToken<OfficeDomain>() {
|
||||
}.getType());
|
||||
}
|
||||
|
||||
|
||||
public static String getAsJSON(final String openingDate) {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("parentId", "1");
|
||||
map.put("name", Utils.randomNameGenerator("Office_", 4));
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("locale", "en");
|
||||
map.put("openingDate", openingDate);
|
||||
System.out.println("map : " + map);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
public Integer createOffice(final String openingDate) {
|
||||
String json = getAsJSON(openingDate);
|
||||
return Utils.performServerPost(this.requestSpec, this.responseSpec,
|
||||
OFFICE_URL + "?" + Utils.TENANT_IDENTIFIER, json,
|
||||
CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
}
|
||||
|
||||
public Integer updateOffice(int id, String name, String openingDate) {
|
||||
final HashMap map = new HashMap<>();
|
||||
map.put("name", name);
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("locale", "en");
|
||||
map.put("openingDate", openingDate);
|
||||
|
||||
System.out.println("map : " + map);
|
||||
|
||||
return Utils.performServerPut(requestSpec, responseSpec, OFFICE_URL
|
||||
+ "/" + id + "?" + Utils.TENANT_IDENTIFIER,
|
||||
new Gson().toJson(map), "resourceId");
|
||||
}
|
||||
|
||||
public static String getAsJSON(final String openingDate) {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("parentId", "1");
|
||||
map.put("name", Utils.randomNameGenerator("Office_", 4));
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("locale", "en");
|
||||
map.put("openingDate", openingDate);
|
||||
System.out.println("map : " + map);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
}
|
||||
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* 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 com.google.gson.Gson;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
public class PasswordPreferencesHelper {
|
||||
|
||||
private static final String PASSWORD_PREFERENCES_URL = "/mifosng-provider/api/v1/passwordpreferences";
|
||||
|
||||
public static Object updatePasswordPreferences(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
String validationPolicyId) {
|
||||
final String UPDATE_PASSWORD_PREFERENCES_URL = PASSWORD_PREFERENCES_URL + "?" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("---------------------------------UPDATE PASSWORD PREFERENCE---------------------------------------------");
|
||||
return Utils.performServerPut(requestSpec, responseSpec, UPDATE_PASSWORD_PREFERENCES_URL, updatePreferencesAsJson(validationPolicyId), "");
|
||||
}
|
||||
|
||||
public static Object updateWithInvalidValidationPolicyId(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec,String invalidValidationPolicyId, String jsonAttributeToGetback) {
|
||||
final String UPDATE_PASSWORD_PREFERENCES_URL = PASSWORD_PREFERENCES_URL + "?" + Utils.TENANT_IDENTIFIER;
|
||||
System.out
|
||||
.println("---------------------------------UPDATE PASSWORD PREFERENCES WITH INVALID ID-----------------------------------------");
|
||||
return Utils.performServerPut(requestSpec, responseSpec, UPDATE_PASSWORD_PREFERENCES_URL, updatePreferencesWithInvalidId(invalidValidationPolicyId),
|
||||
jsonAttributeToGetback);
|
||||
}
|
||||
|
||||
public static String updatePreferencesAsJson(String validationPolicyId) {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("validationPolicyId", validationPolicyId);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
public static String updatePreferencesWithInvalidId(String invalidValidationPolicyId) {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("validationPolicyId", invalidValidationPolicyId);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
|
||||
public static int getActivePasswordPreference(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
return Utils.performServerGet(requestSpec, responseSpec, PASSWORD_PREFERENCES_URL + "?" + Utils.TENANT_IDENTIFIER, "id");
|
||||
}
|
||||
|
||||
public static HashMap<String, Object> getAllPreferences(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
|
||||
return Utils.performServerGet(requestSpec, responseSpec, PASSWORD_PREFERENCES_URL + "/template" + "?" + Utils.TENANT_IDENTIFIER, "");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
public class PaymentTypeDomain {
|
||||
|
||||
private Integer id;
|
||||
private String name;
|
||||
private String description;
|
||||
private Boolean isCashPayment;
|
||||
private Integer position;
|
||||
|
||||
private PaymentTypeDomain(final Integer id, final String name, final String description, final Boolean isCashPayment,
|
||||
final Integer position) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.isCashPayment = isCashPayment;
|
||||
this.position = position;
|
||||
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Boolean getIsCashPayment() {
|
||||
return this.isCashPayment;
|
||||
}
|
||||
|
||||
public void setIsCashPayment(Boolean isCashPayment) {
|
||||
this.isCashPayment = isCashPayment;
|
||||
}
|
||||
|
||||
public Integer getPosition() {
|
||||
return this.position;
|
||||
}
|
||||
|
||||
public void setPosition(Integer position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
}
|
||||
+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.common;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public class PaymentTypeHelper {
|
||||
|
||||
private static final String CREATE_PAYMENTTYPE_URL = "/mifosng-provider/api/v1/paymenttypes?" + Utils.TENANT_IDENTIFIER;
|
||||
private static final String PAYMENTTYPE_URL = "/mifosng-provider/api/v1/paymenttypes";
|
||||
|
||||
public static Integer createPaymentType(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String name, final String description, final Boolean isCashPayment, final Integer position) {
|
||||
System.out.println("---------------------------------CREATING A PAYMENT TYPE---------------------------------------------");
|
||||
return Utils.performServerPost(requestSpec, responseSpec, CREATE_PAYMENTTYPE_URL,
|
||||
getJsonToCreatePaymentType(name, description, isCashPayment, position), "resourceId");
|
||||
}
|
||||
|
||||
public static String getJsonToCreatePaymentType(final String name, final String description, final Boolean isCashPayment,
|
||||
final Integer position) {
|
||||
HashMap hm = new HashMap();
|
||||
hm.put("name", name);
|
||||
if (description != null) hm.put("description", description);
|
||||
hm.put("isCashPayment", isCashPayment);
|
||||
if (position != null) hm.put("position", position);
|
||||
|
||||
System.out.println("------------------------CREATING PAYMENT TYPE-------------------------" + hm);
|
||||
return new Gson().toJson(hm);
|
||||
}
|
||||
|
||||
public static void verifyPaymentTypeCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer generatedPaymentTypeID) {
|
||||
System.out.println("------------------------------CHECK PAYMENT DETAILS------------------------------------\n");
|
||||
final String GET_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + generatedPaymentTypeID + "?" + Utils.TENANT_IDENTIFIER;
|
||||
final Integer responsePaymentTypeID = Utils.performServerGet(requestSpec, responseSpec, GET_PAYMENTTYPE_URL, "id");
|
||||
assertEquals("ERROR IN CREATING THE PAYMENT TYPE", generatedPaymentTypeID, responsePaymentTypeID);
|
||||
}
|
||||
|
||||
public static PaymentTypeDomain retrieveById(RequestSpecification requestSpec, ResponseSpecification responseSpec,
|
||||
final Integer paymentTypeId) {
|
||||
final String GET_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + paymentTypeId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("---------------------------------GET PAYMENT TYPE---------------------------------------------");
|
||||
final String jsonData = new Gson().toJson(Utils.performServerGet(requestSpec, responseSpec, GET_PAYMENTTYPE_URL, ""));
|
||||
return new Gson().fromJson(jsonData, new TypeToken<PaymentTypeDomain>() {}.getType());
|
||||
|
||||
}
|
||||
|
||||
public static HashMap<String, String> updatePaymentType(final int id, HashMap request, final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec) {
|
||||
final String UPDATE_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("---------------------------------UPDATE PAYMENT TYPE " + id + "---------------------------------------------");
|
||||
HashMap<String, String> hash = Utils.performServerPut(requestSpec, responseSpec, UPDATE_PAYMENTTYPE_URL,
|
||||
new Gson().toJson(request), "changes");
|
||||
return hash;
|
||||
}
|
||||
|
||||
public static Integer deletePaymentType(final int id, final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
final String DELETE_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + id + "?" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("---------------------------------DELETING PAYMENT TYPE " + id + "--------------------------------------------");
|
||||
return Utils.performServerDelete(requestSpec, responseSpec, DELETE_PAYMENTTYPE_URL, "resourceId");
|
||||
}
|
||||
|
||||
public static String randomNameGenerator(final String prefix, final int lenOfRandomSuffix) {
|
||||
return Utils.randomStringGenerator(prefix, lenOfRandomSuffix);
|
||||
}
|
||||
|
||||
}
|
||||
+6
@@ -118,6 +118,12 @@ public class SchedulerJobHelper {
|
||||
|
||||
ArrayList<HashMap> jobHistoryData = getSchedulerJobHistory(this.requestSpec, this.responseSpec, jobId.toString());
|
||||
|
||||
// print error associated with recent job failure (if any)
|
||||
System.out.println("Job run error message (printed only if the job fails: "
|
||||
+ jobHistoryData.get(jobHistoryData.size() - 1).get("jobRunErrorMessage"));
|
||||
System.out.println("Job failure error log (printed only if the job fails: "
|
||||
+ jobHistoryData.get(jobHistoryData.size() - 1).get("jobRunErrorLog"));
|
||||
|
||||
// Verifying the Status of the Recently executed Scheduler Job
|
||||
Assert.assertEquals("Verifying Last Scheduler Job Status", "success",
|
||||
jobHistoryData.get(jobHistoryData.size() - 1).get("status"));
|
||||
|
||||
-60
@@ -1,60 +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.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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+39
-3
@@ -11,29 +11,35 @@ import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.http.conn.HttpHostConnectException;
|
||||
import org.joda.time.DateTimeZone;
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
import com.jayway.restassured.RestAssured;
|
||||
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.
|
||||
* 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 {
|
||||
|
||||
public static final String TENANT_IDENTIFIER = "tenantIdentifier=default";
|
||||
|
||||
public static final String TENANT_TIME_ZONE = "Asia/Kolkata";
|
||||
|
||||
private static final String LOGIN_URL = "/mifosng-provider/api/v1/authentication?username=mifos&password=password&" + TENANT_IDENTIFIER;
|
||||
|
||||
public static void initializeRESTAssured() {
|
||||
@@ -61,9 +67,20 @@ public class Utils {
|
||||
public static <T> T performServerGet(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String getURL, final String jsonAttributeToGetBack) {
|
||||
final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getURL).andReturn().asString();
|
||||
if (jsonAttributeToGetBack == null) { return (T) json; }
|
||||
return (T) from(json).get(jsonAttributeToGetBack);
|
||||
}
|
||||
|
||||
public static String performGetTextResponse(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String getURL){
|
||||
return given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getURL).andReturn().asString();
|
||||
}
|
||||
|
||||
public static byte[] performGetBinaryResponse(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String getURL){
|
||||
return given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getURL).andReturn().asByteArray();
|
||||
}
|
||||
|
||||
public static <T> T performServerPost(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String postURL, final String jsonBodyToSend, final String jsonAttributeToGetBack) {
|
||||
final String json = given().spec(requestSpec).body(jsonBodyToSend).expect().spec(responseSpec).log().ifError().when().post(postURL)
|
||||
@@ -116,4 +133,23 @@ public class Utils {
|
||||
return randomStringGenerator(prefix, lenOfRandomSuffix);
|
||||
}
|
||||
|
||||
public static String convertDateToURLFormat(final Calendar dateToBeConvert) {
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMMMM yyyy");
|
||||
dateFormat.setTimeZone(Utils.getTimeZoneOfTenant());
|
||||
return dateFormat.format(dateToBeConvert.getTime());
|
||||
}
|
||||
|
||||
public static LocalDate getLocalDateOfTenant() {
|
||||
LocalDate today = new LocalDate();
|
||||
final DateTimeZone zone = DateTimeZone.forID(TENANT_TIME_ZONE);
|
||||
if (zone != null) {
|
||||
today = new LocalDate(zone);
|
||||
}
|
||||
return today;
|
||||
}
|
||||
|
||||
public static TimeZone getTimeZoneOfTenant() {
|
||||
return TimeZone.getTimeZone(TENANT_TIME_ZONE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* 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.Random;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
public class WorkingDaysHelper {
|
||||
|
||||
private static final String WORKINGDAYS_URL = "/mifosng-provider/api/v1/workingdays";
|
||||
|
||||
public static Object updateWorkingDays(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
final String UPDATE_WORKINGDAYS_URL = WORKINGDAYS_URL + "?" + Utils.TENANT_IDENTIFIER;
|
||||
System.out.println("---------------------------------UPDATE WORKINGDAY---------------------------------------------");
|
||||
return Utils.performServerPut(requestSpec, responseSpec, UPDATE_WORKINGDAYS_URL, updateWorkingDaysAsJson(), "");
|
||||
}
|
||||
|
||||
public static Object updateWorkingDaysWithWrongRecurrence(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, String jsonAttributeToGetback) {
|
||||
final String UPDATE_WORKINGDAYS_URL = WORKINGDAYS_URL + "?" + Utils.TENANT_IDENTIFIER;
|
||||
System.out
|
||||
.println("---------------------------------UPDATE WORKINGDAY WITH WRONG RECURRENCE-----------------------------------------");
|
||||
return Utils.performServerPut(requestSpec, responseSpec, UPDATE_WORKINGDAYS_URL, updateWorkingDayWithWrongRecur(),
|
||||
jsonAttributeToGetback);
|
||||
}
|
||||
|
||||
public static String updateWorkingDaysAsJson() {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("recurrence", "FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR,SA,SU");
|
||||
map.put("locale", "en");
|
||||
map.put("repaymentRescheduleType", randomInt(1, 4));
|
||||
map.put("extendTermForDailyRepayments", false);
|
||||
System.out.println("map : " + map);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
public static String updateWorkingDayWithWrongRecur() {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("recurrence", "FREQ=WEEKLY;INTERVAL=1;BYDAY=MP,TI,TE,TH");
|
||||
map.put("locale", "en");
|
||||
map.put("repaymentRescheduleType", randomInt(1, 4));
|
||||
map.put("extendTermForDailyRepayments", false);
|
||||
System.out.println("map : " + map);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
public static int randomInt(int low, int high) {
|
||||
int i = new Random().nextInt(high) + low;
|
||||
return i;
|
||||
}
|
||||
|
||||
public static int workingDaysId(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
HashMap<String, Object> workingDays = getAllWorkingDays(requestSpec, responseSpec);
|
||||
return (int) workingDays.get("id");
|
||||
}
|
||||
|
||||
public static HashMap<String, Object> getAllWorkingDays(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
|
||||
return Utils.performServerGet(requestSpec, responseSpec, WORKINGDAYS_URL + "?" + Utils.TENANT_IDENTIFIER, "");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+65
-5
@@ -47,18 +47,40 @@ public class LoanApplicationTestBuilder {
|
||||
private List<HashMap> disbursementData = null;
|
||||
private List<HashMap> charges = new ArrayList<HashMap>();
|
||||
private String recalculationRestFrequencyDate = null;
|
||||
private String recalculationCompoundingFrequencyDate = null;
|
||||
private String repaymentsStartingFromDate = null;
|
||||
|
||||
private String calendarId;
|
||||
private boolean syncDisbursementWithMeeting = false;
|
||||
|
||||
public String build(final String clientID, final String groupID, final String loanProductId, final String savingsID) {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("groupId", groupID);
|
||||
map.put("clientId", clientID);
|
||||
if (this.loanType == "jlg") {
|
||||
if (this.calendarId != null) {
|
||||
map.put("calendarId", this.calendarId);
|
||||
}
|
||||
map.put("syncDisbursementWithMeeting", this.syncDisbursementWithMeeting);
|
||||
}
|
||||
return build(map, loanProductId, savingsID);
|
||||
}
|
||||
|
||||
public String build(final String ID, final String loanProductId, final String savingsID) {
|
||||
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("locale", "en_GB");
|
||||
|
||||
if (this.loanType == "group") {
|
||||
map.put("groupId", ID);
|
||||
} else {
|
||||
map.put("clientId", ID);
|
||||
}
|
||||
return build(map, loanProductId, savingsID);
|
||||
}
|
||||
|
||||
private String build(final HashMap<String, Object> map, final String loanProductId, final String savingsID) {
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("locale", "en_GB");
|
||||
map.put("productId", loanProductId);
|
||||
map.put("principal", this.principal);
|
||||
map.put("loanTermFrequency", this.loanTermFrequency);
|
||||
@@ -74,8 +96,9 @@ public class LoanApplicationTestBuilder {
|
||||
map.put("expectedDisbursementDate", this.expectedDisbursmentDate);
|
||||
map.put("submittedOnDate", this.submittedOnDate);
|
||||
map.put("loanType", this.loanType);
|
||||
map.put("repaymentsStartingFromDate", this.repaymentsStartingFromDate);
|
||||
|
||||
if (repaymentsStartingFromDate != null) {
|
||||
map.put("repaymentsStartingFromDate", this.repaymentsStartingFromDate);
|
||||
}
|
||||
if (charges != null) {
|
||||
map.put("charges", charges);
|
||||
}
|
||||
@@ -100,7 +123,11 @@ public class LoanApplicationTestBuilder {
|
||||
if (recalculationRestFrequencyDate != null) {
|
||||
map.put("recalculationRestFrequencyDate", recalculationRestFrequencyDate);
|
||||
}
|
||||
if (recalculationCompoundingFrequencyDate != null) {
|
||||
map.put("recalculationCompoundingFrequencyDate", recalculationCompoundingFrequencyDate);
|
||||
}
|
||||
|
||||
System.out.println("Loan Application request : " + map);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
@@ -243,9 +270,42 @@ public class LoanApplicationTestBuilder {
|
||||
this.recalculationRestFrequencyDate = recalculationRestFrequencyDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public LoanApplicationTestBuilder withCompoundingFrequencyDate(final String recalculationCompoundingFrequencyDate) {
|
||||
this.recalculationCompoundingFrequencyDate = recalculationCompoundingFrequencyDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanApplicationTestBuilder withFirstRepaymentDate(final String firstRepaymentDate) {
|
||||
this.repaymentsStartingFromDate = firstRepaymentDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* calendarID parameter is used to sync repayments with group meetings,
|
||||
* especially when using jlg loans
|
||||
*
|
||||
* @param calendarId
|
||||
* the id of the calender record of the group meeting from
|
||||
* m_calendar table
|
||||
* @return
|
||||
*/
|
||||
public LoanApplicationTestBuilder withCalendarID(String calendarId) {
|
||||
this.calendarId = calendarId;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* This indicator is used mainly for jlg loans when we want to sync
|
||||
* disbursement with the group meetings (it seems that if we do use this
|
||||
* parameter we should also use calendarID to sync repayment with group
|
||||
* meetings)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public LoanApplicationTestBuilder withSyncDisbursementWithMeetin() {
|
||||
this.syncDisbursementWithMeeting = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+75
-2
@@ -14,6 +14,7 @@ import org.mifosplatform.integrationtests.common.Utils;
|
||||
import org.mifosplatform.integrationtests.common.accounting.Account;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
public class LoanProductTestBuilder {
|
||||
|
||||
@@ -52,6 +53,9 @@ public class LoanProductTestBuilder {
|
||||
private static final String ACCRUAL_PERIODIC = "3";
|
||||
private static final String ACCRUAL_UPFRONT = "4";
|
||||
|
||||
public static final String INTEREST_APPLICABLE_STRATEGY_REST_DATE = "2";
|
||||
public static final String INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE = "1";
|
||||
|
||||
private String digitsAfterDecimal = "2";
|
||||
private String inMultiplesOf = "0";
|
||||
|
||||
@@ -77,17 +81,29 @@ public class LoanProductTestBuilder {
|
||||
|
||||
private Boolean multiDisburseLoan = false;
|
||||
private final String outstandingLoanBalance = "35000";
|
||||
private final String maxTrancheCount = "35000";
|
||||
private final String maxTrancheCount = "3";
|
||||
|
||||
private Boolean isInterestRecalculationEnabled = false;
|
||||
private String daysInYearType = "1";
|
||||
private String daysInMonthType = "1";
|
||||
private String interestRecalculationCompoundingMethod = "0";
|
||||
private String preCloseInterestCalculationStrategy = INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE;
|
||||
private String rescheduleStrategyMethod = "1";
|
||||
private String recalculationRestFrequencyType = "1";
|
||||
private String recalculationRestFrequencyInterval = "0";
|
||||
private String recalculationRestFrequencyDate = null;
|
||||
private String recalculationCompoundingFrequencyType = null;
|
||||
private String recalculationCompoundingFrequencyInterval = null;
|
||||
private String recalculationCompoundingFrequencyDate = null;
|
||||
private String minimumDaysBetweenDisbursalAndFirstRepayment = null;
|
||||
private Boolean holdGuaranteeFunds = null;
|
||||
private String mandatoryGuarantee = null;
|
||||
private String minimumGuaranteeFromOwnFunds = null;
|
||||
private String minimumGuaranteeFromGuarantor = null;
|
||||
private String isArrearsBasedOnOriginalSchedule = null;
|
||||
private String graceOnPrincipalPayment = "1";
|
||||
private String graceOnInterestPayment = "1";
|
||||
private JsonObject allowAttributeOverrides = null;
|
||||
|
||||
public String build(final String chargeId) {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
@@ -144,6 +160,28 @@ public class LoanProductTestBuilder {
|
||||
map.put("recalculationRestFrequencyType", recalculationRestFrequencyType);
|
||||
map.put("recalculationRestFrequencyInterval", recalculationRestFrequencyInterval);
|
||||
map.put("recalculationRestFrequencyDate", recalculationRestFrequencyDate);
|
||||
if (!RECALCULATION_COMPOUNDING_METHOD_NONE.equals(this.interestRecalculationCompoundingMethod)) {
|
||||
map.put("recalculationCompoundingFrequencyType", recalculationCompoundingFrequencyType);
|
||||
map.put("recalculationCompoundingFrequencyInterval", recalculationCompoundingFrequencyInterval);
|
||||
map.put("recalculationCompoundingFrequencyDate", recalculationCompoundingFrequencyDate);
|
||||
}
|
||||
map.put("preClosureInterestCalculationStrategy", preCloseInterestCalculationStrategy);
|
||||
if (isArrearsBasedOnOriginalSchedule != null) {
|
||||
map.put("isArrearsBasedOnOriginalSchedule", isArrearsBasedOnOriginalSchedule);
|
||||
}
|
||||
}
|
||||
if (holdGuaranteeFunds != null) {
|
||||
map.put("holdGuaranteeFunds", this.holdGuaranteeFunds);
|
||||
if (this.holdGuaranteeFunds) {
|
||||
map.put("mandatoryGuarantee", this.mandatoryGuarantee);
|
||||
map.put("minimumGuaranteeFromGuarantor", this.minimumGuaranteeFromGuarantor);
|
||||
map.put("minimumGuaranteeFromOwnFunds", this.minimumGuaranteeFromOwnFunds);
|
||||
}
|
||||
}
|
||||
map.put("graceOnPrincipalPayment", graceOnPrincipalPayment);
|
||||
map.put("graceOnInterestPayment", graceOnInterestPayment);
|
||||
if (allowAttributeOverrides != null) {
|
||||
map.put("allowAttributeOverrides", this.allowAttributeOverrides);
|
||||
}
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
@@ -365,10 +403,11 @@ public class LoanProductTestBuilder {
|
||||
}
|
||||
|
||||
public LoanProductTestBuilder withInterestRecalculationDetails(final String interestRecalculationCompoundingMethod,
|
||||
final String rescheduleStrategyMethod) {
|
||||
final String rescheduleStrategyMethod, String preCloseInterestCalculationStrategy) {
|
||||
this.isInterestRecalculationEnabled = true;
|
||||
this.interestRecalculationCompoundingMethod = interestRecalculationCompoundingMethod;
|
||||
this.rescheduleStrategyMethod = rescheduleStrategyMethod;
|
||||
this.preCloseInterestCalculationStrategy = preCloseInterestCalculationStrategy;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -380,9 +419,43 @@ public class LoanProductTestBuilder {
|
||||
this.recalculationRestFrequencyDate = recalculationRestFrequencyDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanProductTestBuilder withInterestRecalculationCompoundingFrequencyDetails(final String recalculationCompoundingFrequencyType,
|
||||
final String recalculationCompoundingFrequencyInterval, final String recalculationCompoundingFrequencyDate) {
|
||||
this.isInterestRecalculationEnabled = true;
|
||||
this.recalculationCompoundingFrequencyType = recalculationCompoundingFrequencyType;
|
||||
this.recalculationCompoundingFrequencyInterval = recalculationCompoundingFrequencyInterval;
|
||||
this.recalculationCompoundingFrequencyDate = recalculationCompoundingFrequencyDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanProductTestBuilder withMinimumDaysBetweenDisbursalAndFirstRepayment(final String minimumDaysBetweenDisbursalAndFirstRepayment) {
|
||||
this.minimumDaysBetweenDisbursalAndFirstRepayment = minimumDaysBetweenDisbursalAndFirstRepayment;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanProductTestBuilder withArrearsConfiguration() {
|
||||
this.isArrearsBasedOnOriginalSchedule = "true";
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanProductTestBuilder withOnHoldFundDetails(final String mandatoryGuarantee, final String minimumGuaranteeFromGuarantor,
|
||||
final String minimumGuaranteeFromOwnFunds) {
|
||||
this.holdGuaranteeFunds = true;
|
||||
this.mandatoryGuarantee = mandatoryGuarantee;
|
||||
this.minimumGuaranteeFromGuarantor = minimumGuaranteeFromGuarantor;
|
||||
this.minimumGuaranteeFromOwnFunds = minimumGuaranteeFromOwnFunds;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanProductTestBuilder withMoratorium(String principal, String interest) {
|
||||
this.graceOnPrincipalPayment = principal;
|
||||
this.graceOnInterestPayment = interest;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanProductTestBuilder withLoanProductConfiguration(JsonObject loanProductConfigurableAttributes) {
|
||||
this.allowAttributeOverrides = loanProductConfigurableAttributes;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
+118
-111
@@ -11,126 +11,133 @@ 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");
|
||||
|
||||
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("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 LoanRescheduleRequestTestBuilder updateSubmittedOnDate(final String submittedOnDate) {
|
||||
this.submittedOnDate = submittedOnDate;
|
||||
|
||||
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<>();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ public class LoanStatusChecker {
|
||||
assertTrue(getStatus(loanStatusHashMap, "overpaid"));
|
||||
}
|
||||
|
||||
public static HashMap getStatusOfLoan(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
public static HashMap<String, Object> getStatusOfLoan(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer loanID) {
|
||||
final String url = "/mifosng-provider/api/v1/loans/" + loanID + "?" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerGet(requestSpec, responseSpec, url, "status");
|
||||
|
||||
+146
-39
@@ -10,6 +10,7 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
@@ -35,6 +36,8 @@ public class LoanTransactionHelper {
|
||||
private static final String WAIVE_INTEREST_COMMAND = "waiveinterest";
|
||||
private static final String MAKE_REPAYMENT_COMMAND = "repayment";
|
||||
private static final String WITHDRAW_LOAN_APPLICATION_COMMAND = "withdrawnByApplicant";
|
||||
private static final String RECOVER_FROM_GUARANTORS_COMMAND = "recoverGuarantees";
|
||||
private static final String MAKE_REFUND_BY_CASH_COMMAND = "refundByCash";
|
||||
|
||||
public LoanTransactionHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
this.requestSpec = requestSpec;
|
||||
@@ -48,19 +51,19 @@ 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
|
||||
+ "?" + Utils.TENANT_IDENTIFIER, loanApplicationJSON, "loanId");
|
||||
return Utils.performServerPut(this.requestSpec, this.responseSpec, "/mifosng-provider/api/v1/loans/" + id + "?"
|
||||
+ Utils.TENANT_IDENTIFIER, loanApplicationJSON, "loanId");
|
||||
}
|
||||
|
||||
public ArrayList getLoanRepaymentSchedule(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
@@ -69,10 +72,11 @@ public class LoanTransactionHelper {
|
||||
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 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");
|
||||
}
|
||||
@@ -89,25 +93,53 @@ public class LoanTransactionHelper {
|
||||
return Utils.performServerGet(requestSpec, responseSpec, URL, param);
|
||||
}
|
||||
|
||||
public String getLoanDetails(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer loanID) {
|
||||
final String URL = "/mifosng-provider/api/v1/loans/" + loanID + "?associations=all&" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerGet(requestSpec, responseSpec, URL, null);
|
||||
}
|
||||
|
||||
public Object getLoanProductDetail(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer loanProductId, final String jsonAttributeToGetBack) {
|
||||
final String URL = "/mifosng-provider/api/v1/loanproducts/" + loanProductId + "?associations=all&" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerGet(requestSpec, responseSpec, URL, jsonAttributeToGetBack);
|
||||
}
|
||||
|
||||
public String getLoanProductDetails(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer loanProductId) {
|
||||
final String URL = "/mifosng-provider/api/v1/loanproducts/" + loanProductId + "?associations=all&" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerGet(requestSpec, responseSpec, URL, null);
|
||||
}
|
||||
|
||||
public ArrayList getLoanCharges(final Integer loanId) {
|
||||
final String GET_LOAN_CHARGES_URL = "/mifosng-provider/api/v1/loans/" + loanId + "/charges?" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerGet(requestSpec, responseSpec, GET_LOAN_CHARGES_URL, "");
|
||||
}
|
||||
|
||||
public HashMap approveLoan(final String approvalDate, final Integer loanID) {
|
||||
return performLoanTransaction(createLoanOperationURL(APPROVE_LOAN_COMMAND, loanID), getApproveLoanAsJSON(approvalDate));
|
||||
String loanApprovalCommand = createLoanOperationURL(APPROVE_LOAN_COMMAND, loanID);
|
||||
String loanApprovalRequest = getApproveLoanAsJSON(approvalDate);
|
||||
System.out.println("Loan approval command:" + loanApprovalCommand);
|
||||
System.out.println("Loan approval request:" + loanApprovalRequest);
|
||||
return performLoanTransaction(loanApprovalCommand, loanApprovalRequest);
|
||||
}
|
||||
|
||||
public HashMap approveLoanWithApproveAmount(final String approvalDate, final String approvalAmount, final Integer loanID) {
|
||||
return performLoanTransaction(createLoanOperationURL(APPROVE_LOAN_COMMAND, loanID), getApproveLoanAsJSON(approvalDate, approvalAmount));
|
||||
|
||||
public HashMap approveLoanWithApproveAmount(final String approvalDate, final String expectedDisbursementDate,
|
||||
final String approvalAmount, final Integer loanID, List<HashMap> tranches) {
|
||||
return performLoanTransaction(createLoanOperationURL(APPROVE_LOAN_COMMAND, loanID),
|
||||
getApproveLoanAsJSON(approvalDate, expectedDisbursementDate, approvalAmount, tranches));
|
||||
}
|
||||
|
||||
public Object approveLoanWithApproveAmount(final String approvalDate, final String approvalAmount, final Integer loanID,
|
||||
final String responseAttribute) {
|
||||
|
||||
|
||||
public List<HashMap<String, Object>> approveLoanForTranches(final String approvalDate, final String expectedDisbursementDate,
|
||||
final String approvalAmount, final Integer loanID, List<HashMap> tranches, final String responseAttribute) {
|
||||
return (List<HashMap<String, Object>>) performLoanTransaction(createLoanOperationURL(APPROVE_LOAN_COMMAND, loanID),
|
||||
getApproveLoanAsJSON(approvalDate, expectedDisbursementDate, approvalAmount, tranches), responseAttribute);
|
||||
}
|
||||
|
||||
public Object approveLoan(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);
|
||||
|
||||
final String approvalJSONData = getApproveLoanAsJSON(approvalDate, null, approvalAmount, null);
|
||||
|
||||
return performLoanTransaction(approvalURL, approvalJSONData, responseAttribute);
|
||||
}
|
||||
|
||||
@@ -136,6 +168,10 @@ public class LoanTransactionHelper {
|
||||
return performLoanTransaction(createLoanOperationURL(UNDO_DISBURSE_LOAN_COMMAND, loanID), undoDisburseJson);
|
||||
}
|
||||
|
||||
public void recoverFromGuarantor(final Integer loanID) {
|
||||
performLoanTransaction(createLoanOperationURL(RECOVER_FROM_GUARANTORS_COMMAND, loanID), "", "");
|
||||
}
|
||||
|
||||
public HashMap writeOffLoan(final String date, final Integer loanID) {
|
||||
return performLoanTransaction(createLoanTransactionURL(WRITE_OFF_LOAN_COMMAND, loanID), getWriteOffBodyAsJSON(date));
|
||||
}
|
||||
@@ -151,8 +187,8 @@ public class LoanTransactionHelper {
|
||||
}
|
||||
|
||||
public HashMap makeRepayment(final String date, final Float amountToBePaid, final Integer loanID) {
|
||||
return performLoanTransaction(createLoanTransactionURL(MAKE_REPAYMENT_COMMAND, loanID),
|
||||
getRepaymentBodyAsJSON(date, amountToBePaid));
|
||||
return (HashMap) performLoanTransaction(createLoanTransactionURL(MAKE_REPAYMENT_COMMAND, loanID),
|
||||
getRepaymentBodyAsJSON(date, amountToBePaid), "");
|
||||
}
|
||||
|
||||
public HashMap withdrawLoanApplicationByClient(final String date, final Integer loanID) {
|
||||
@@ -169,32 +205,32 @@ 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
|
||||
+ "?" + Utils.TENANT_IDENTIFIER;
|
||||
final String UPDATE_CHARGES_URL = "/mifosng-provider/api/v1/loans/" + loanId + "/charges/" + loanchargeId + "?"
|
||||
+ Utils.TENANT_IDENTIFIER;
|
||||
final HashMap response = Utils.performServerPut(requestSpec, responseSpec, UPDATE_CHARGES_URL, request, "");
|
||||
return (Integer) response.get("resourceId");
|
||||
}
|
||||
|
||||
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
|
||||
+ "?" + Utils.TENANT_IDENTIFIER;
|
||||
final String DELETE_CHARGES_URL = "/mifosng-provider/api/v1/loans/" + loanId + "/charges/" + loanchargeId + "?"
|
||||
+ Utils.TENANT_IDENTIFIER;
|
||||
final HashMap response = Utils.performServerDelete(requestSpec, responseSpec, DELETE_CHARGES_URL, "");
|
||||
return (Integer) response.get("resourceId");
|
||||
}
|
||||
|
||||
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&" + Utils.TENANT_IDENTIFIER;
|
||||
final String CHARGES_URL = "/mifosng-provider/api/v1/loans/" + loanId + "/charges/" + loanchargeId + "?command=waive&"
|
||||
+ Utils.TENANT_IDENTIFIER;
|
||||
final HashMap response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, json, "");
|
||||
return (Integer) response.get("resourceId");
|
||||
}
|
||||
|
||||
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&" + Utils.TENANT_IDENTIFIER;
|
||||
final String CHARGES_URL = "/mifosng-provider/api/v1/loans/" + loanId + "/charges/" + loanchargeId + "?command=pay&"
|
||||
+ Utils.TENANT_IDENTIFIER;
|
||||
final HashMap response = Utils.performServerPost(requestSpec, responseSpec, CHARGES_URL, json, "");
|
||||
return (Integer) response.get("resourceId");
|
||||
}
|
||||
@@ -208,24 +244,29 @@ public class LoanTransactionHelper {
|
||||
if (transactionAmount != null) {
|
||||
map.put("transactionAmount", transactionAmount);
|
||||
}
|
||||
System.out.println("Loan Application disburse request : " + map);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
private String getApproveLoanAsJSON(final String approvalDate) {
|
||||
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);
|
||||
return getApproveLoanAsJSON(approvalDate, null, null, null);
|
||||
}
|
||||
|
||||
private String getApproveLoanAsJSON(final String approvalDate, final String approvalAmount) {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
|
||||
private String getApproveLoanAsJSON(final String approvalDate, final String expectedDisbursementDate, final String approvalAmount,
|
||||
List<HashMap> tranches) {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("locale", "en");
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("approvedLoanAmount", approvalAmount);
|
||||
if (approvalAmount != null) {
|
||||
map.put("approvedLoanAmount", approvalAmount);
|
||||
}
|
||||
map.put("approvedOnDate", approvalDate);
|
||||
if (expectedDisbursementDate != null) {
|
||||
map.put("expectedDisbursementDate", expectedDisbursementDate);
|
||||
}
|
||||
if (tranches != null && tranches.size() > 0) {
|
||||
map.put("disbursementData", tranches);
|
||||
}
|
||||
map.put("note", "Approval NOTE");
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
@@ -378,18 +419,44 @@ 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 Object adjustLoanTransaction(final Integer loanId, final Integer transactionId, final String date,
|
||||
final String transactionAmount, final String responseAttribute) {
|
||||
return adjustLoanTransaction(loanId, transactionId, getAdjustTransactionJSON(date, transactionAmount), responseAttribute);
|
||||
}
|
||||
|
||||
private Object adjustLoanTransaction(final Integer loanId, final Integer tansactionId, final String jsonToBeSent,
|
||||
final String responseAttribute) {
|
||||
final String URL = "/mifosng-provider/api/v1/loans/" + loanId + "/transactions/" + tansactionId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerPost(this.requestSpec, this.responseSpec, URL, jsonToBeSent, responseAttribute);
|
||||
}
|
||||
|
||||
private String getAdjustTransactionJSON(final String date, final String transactionAmount) {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("locale", "en_GB");
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("transactionDate", date);
|
||||
map.put("transactionAmount", transactionAmount);
|
||||
String json = new Gson().toJson(map);
|
||||
System.out.println(json);
|
||||
return json;
|
||||
}
|
||||
|
||||
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 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;
|
||||
}
|
||||
|
||||
private String createLoanRefundTransferURL() {
|
||||
return "/mifosng-provider/api/v1/accounttransfers/refundByTransfer?tenantIdentifier=default";
|
||||
}
|
||||
|
||||
public void verifyRepaymentScheduleEntryFor(final int repaymentNumber, final float expectedPrincipalOutstanding, final Integer loanID) {
|
||||
System.out.println("---------------------------GETTING LOAN REPAYMENT SCHEDULE--------------------------------");
|
||||
final ArrayList<HashMap> repaymentPeriods = getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID);
|
||||
@@ -426,4 +493,44 @@ public class LoanTransactionHelper {
|
||||
assertTrue("No Accrual entries are posted", isTransactionFound);
|
||||
|
||||
}
|
||||
|
||||
public HashMap makeRefundByCash(final String date, final Float amountToBeRefunded, final Integer loanID) {
|
||||
return performLoanTransaction(createLoanTransactionURL(MAKE_REFUND_BY_CASH_COMMAND, loanID),
|
||||
getRefundByCashBodyAsJSON(date, amountToBeRefunded));
|
||||
}
|
||||
|
||||
public HashMap makeRefundByTransfer(final Integer fromAccountId, final Integer toClientId, final Integer toAccountId,
|
||||
final Integer fromClientId, final String date, final Float amountToBeRefunded) {
|
||||
return performLoanTransaction(createLoanRefundTransferURL(),
|
||||
getRefundByTransferBodyAsJSON(fromAccountId, toClientId, toAccountId, fromClientId, date, amountToBeRefunded));
|
||||
}
|
||||
|
||||
private String getRefundByCashBodyAsJSON(final String transactionDate, final Float transactionAmount) {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("locale", "en");
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("transactionDate", transactionDate);
|
||||
map.put("transactionAmount", transactionAmount.toString());
|
||||
map.put("note", "Refund Made!!!");
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
private String getRefundByTransferBodyAsJSON(final Integer fromAccountId, final Integer toClientId, final Integer toAccountId,
|
||||
final Integer fromClientId, final String transactionDate, final Float transactionAmount) {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("fromAccountId", fromAccountId.toString());
|
||||
map.put("fromAccountType", "1");
|
||||
map.put("toOfficeId", "1");
|
||||
map.put("toClientId", toClientId.toString());
|
||||
map.put("toAccountType", "2");
|
||||
map.put("toAccountId", toAccountId.toString());
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("transferDate", transactionDate);
|
||||
map.put("transferAmount", transactionAmount.toString());
|
||||
map.put("transferDescription", "Refund Made!!!");
|
||||
map.put("fromClientId", fromClientId.toString());
|
||||
map.put("fromOfficeId", "1");
|
||||
map.put("locale", "en");
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* 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.organisation;
|
||||
|
||||
public class Currency {
|
||||
|
||||
String code;
|
||||
String name;
|
||||
Integer decimalPlaces;
|
||||
String displaySymbol;
|
||||
String nameCode;
|
||||
String displayLabel;
|
||||
|
||||
public Currency(String code, String name, Integer decimalPlaces, String displaySymbol,
|
||||
String nameCode, String displayLabel) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
this.decimalPlaces = decimalPlaces;
|
||||
this.displaySymbol = displaySymbol;
|
||||
this.nameCode = nameCode;
|
||||
this.displayLabel = displayLabel;
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return (this.code != null && this.code.length() == 3) &&
|
||||
(this.name != null && this.name.length() > 0) &&
|
||||
(this.decimalPlaces != null && this.decimalPlaces >= 0) &&
|
||||
(this.nameCode != null && this.nameCode.startsWith("currency.")) &&
|
||||
(this.displayLabel != null && this.displayLabel.length() > 0);
|
||||
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/**
|
||||
* 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.organisation;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
import static com.jayway.restassured.RestAssured.given;
|
||||
|
||||
public class CurrencyHelper {
|
||||
|
||||
private static final String CURRENCY_URL = "/mifosng-provider/api/v1/currencies?" + Utils.TENANT_IDENTIFIER;
|
||||
private static final String CURRENCY_URL_SELECTED = CURRENCY_URL + "&fields=selectedCurrencyOptions";
|
||||
|
||||
private static final List<String> permittedCurrencyArray = Arrays.asList("currencyOptions",
|
||||
"selectedCurrencyOptions");
|
||||
|
||||
private static final List<String> permittedCurrencyArraySelected = Arrays.asList("selectedCurrencyOptions");
|
||||
|
||||
private final RequestSpecification requestSpec;
|
||||
private final ResponseSpecification responseSpec;
|
||||
|
||||
public CurrencyHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
this.requestSpec = requestSpec;
|
||||
this.responseSpec = responseSpec;
|
||||
}
|
||||
|
||||
public ArrayList<Currency> getPermittedCurrencies() {
|
||||
return getCurrencies(CURRENCY_URL, permittedCurrencyArray);
|
||||
}
|
||||
|
||||
public ArrayList<Currency> getSelectedCurrencies() {
|
||||
return getCurrencies(CURRENCY_URL_SELECTED, permittedCurrencyArraySelected);
|
||||
}
|
||||
|
||||
|
||||
private ArrayList<Currency> getCurrencies(final String getUrl, final List<String> permittedCurrencyArrays) {
|
||||
System.out.println("--------------------------------- GET CURRENCY OPTIONS -------------------------------");
|
||||
final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when()
|
||||
.get(getUrl).andReturn().asString();
|
||||
final Gson gson = new Gson();
|
||||
Assert.notNull(json);
|
||||
final ArrayList<Currency> currencyList = new ArrayList<Currency>();
|
||||
final Type typeOfHashMap = new TypeToken<Map<String, List<Currency>>>() { }.getType();
|
||||
final Map<String, List<Currency>> responseMap = gson.fromJson(json, typeOfHashMap);
|
||||
for(Map.Entry<String, List<Currency>> entry : responseMap.entrySet()) {
|
||||
Assert.isTrue(permittedCurrencyArrays.contains(entry.getKey()));
|
||||
for(Currency currency : entry.getValue()) {
|
||||
currencyList.add(currency);
|
||||
}
|
||||
}
|
||||
return currencyList;
|
||||
}
|
||||
|
||||
public List<String> updateCurrencies(final List<String> currencies) {
|
||||
System.out.println("--------------------------------- UPDATE CURRENCY OPTIONS -------------------------------");
|
||||
final String json = given().spec(requestSpec).body(getUpdateJSON(currencies)).expect().spec(responseSpec).log().ifError().when()
|
||||
.put(CURRENCY_URL).andReturn().asString();
|
||||
final Gson gson = new Gson();
|
||||
Assert.notNull(json);
|
||||
final Type typeOfHashMap = new TypeToken<Map<String,Map<String, List<String>>>>() { }.getType();
|
||||
final Map<String,Map<String, List<String>>> responseMap = gson.fromJson(json, typeOfHashMap);
|
||||
return responseMap.get("changes").get("currencies");
|
||||
}
|
||||
|
||||
private String getUpdateJSON(final List<String> currencies) {
|
||||
final HashMap<String, List<String>> map = new HashMap<>();
|
||||
map.put("currencies", currencies);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
}
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
/**
|
||||
* 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.organisation;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
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 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) {
|
||||
return (Integer) createStaffWithJson(requestSpec, responseSpec, createStaffAsJSON()).get("resourceId");
|
||||
}
|
||||
|
||||
public static HashMap createStaffMap(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
return createStaffWithJson(requestSpec, responseSpec, createStaffAsJSON());
|
||||
}
|
||||
|
||||
public static HashMap createStaffWithJson(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final String json) {
|
||||
final String url = CREATE_STAFF_URL + "?" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerPost(requestSpec, responseSpec, url, json, "");
|
||||
}
|
||||
|
||||
public static HashMap getStaff(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final Integer staffId) {
|
||||
final String url = CREATE_STAFF_URL + "/" + staffId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerGet(requestSpec, responseSpec, url, "");
|
||||
}
|
||||
|
||||
public static List<HashMap> getStaffList(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
final String url = CREATE_STAFF_URL + "?" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerGet(requestSpec, responseSpec, url, "");
|
||||
}
|
||||
|
||||
public static Object getStaffListWithState(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final String status) {
|
||||
final String url = CREATE_STAFF_URL + "?" + Utils.TENANT_IDENTIFIER + "&status=" + status;
|
||||
return Utils.performServerGet(requestSpec, responseSpec, url, "");
|
||||
}
|
||||
|
||||
public static Object updateStaff(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final Integer staffId, final HashMap<String, Object> changes) {
|
||||
final String url = CREATE_STAFF_URL + "/" + staffId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
final String json = new Gson().toJson(changes);
|
||||
return Utils.performServerPut(requestSpec, responseSpec, url, json, "");
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public static String createStaffWithJSONFields(String... fields) {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
final List<String> fieldList = Arrays.asList(fields);
|
||||
if(fieldList.contains("officeId")) {
|
||||
map.put("officeId", 1);
|
||||
}
|
||||
if(fieldList.contains("firstname")) {
|
||||
map.put("firstname", Utils.randomNameGenerator("michael_", 5));
|
||||
}
|
||||
if(fieldList.contains("lastname")) {
|
||||
map.put("lastname", Utils.randomNameGenerator("Doe_", 4));
|
||||
}
|
||||
if(fieldList.contains("isLoanOfficer")) {
|
||||
map.put("isLoanOfficer", true);
|
||||
}
|
||||
if(fieldList.contains("mobileNo")) {
|
||||
map.put("mobileNo", "+123515198");
|
||||
}
|
||||
System.out.println("map : " + map);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
}
|
||||
+12
@@ -16,6 +16,7 @@ import com.jayway.restassured.specification.ResponseSpecification;
|
||||
public class AccountTransferHelper {
|
||||
|
||||
private static final String ACCOUNT_TRANSFER_URL = "/mifosng-provider/api/v1/accounttransfers";
|
||||
private static final String LOAN_REFUND_BY_TRANSFER_URL = "/mifosng-provider/api/v1/accounttransfers/refundByTransfer";
|
||||
private static final String LOCALE = "en_GB";
|
||||
private static final String OFFICE_ID = "1";
|
||||
private static final String TRANSFER_DESCRIPTION = "Transfer";
|
||||
@@ -70,4 +71,15 @@ public class AccountTransferHelper {
|
||||
return Utils.performServerPost(this.requestSpec, this.responseSpec, ACCOUNT_TRANSFER_URL + "?" + Utils.TENANT_IDENTIFIER,
|
||||
accountTransferJSON, "savingsId");
|
||||
}
|
||||
|
||||
public Integer refundLoanByTransfer(final String date, final Integer fromClientId, final Integer fromAccountId, final Integer toClientId,
|
||||
final Integer toAccountId, final String fromAccountType, final String toAccountType, final String transferAmount) {
|
||||
System.out.println("--------------------------------ACCOUNT TRANSFER--------------------------------");
|
||||
final String accountTransferJSON = new AccountTransferHelper(this.requestSpec, this.responseSpec) //
|
||||
.withTransferOnDate(date) //
|
||||
.build(fromAccountId.toString(), fromClientId.toString(), toAccountId.toString(), toClientId.toString(), fromAccountType,
|
||||
toAccountType, transferAmount);
|
||||
return Utils.performServerPost(this.requestSpec, this.responseSpec, LOAN_REFUND_BY_TRANSFER_URL + "?" + Utils.TENANT_IDENTIFIER,
|
||||
accountTransferJSON, "savingsId");
|
||||
}
|
||||
}
|
||||
+63
-15
@@ -12,6 +12,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.mifosplatform.integrationtests.common.CommonConstants;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
|
||||
@@ -45,6 +46,7 @@ public class SavingsAccountHelper {
|
||||
public static final String CREATED_DATE_MINUS_ONE = "07 January 2013";
|
||||
public static final String TRANSACTION_DATE = "01 March 2013";
|
||||
public static final String LAST_TRANSACTION_DATE = "01 March 2013";
|
||||
public static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL";
|
||||
|
||||
public SavingsAccountHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
this.requestSpec = requestSpec;
|
||||
@@ -59,12 +61,12 @@ public class SavingsAccountHelper {
|
||||
}
|
||||
|
||||
public Integer applyForSavingsApplication(final Integer ID, final Integer savingsProductID, final String accountType) {
|
||||
return applyForSavingsApplicationOnDate(ID, savingsProductID, accountType, CREATED_DATE);
|
||||
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 submittedOnDate) {
|
||||
System.out.println("--------------------------------APPLYING FOR SAVINGS APPLICATION--------------------------------");
|
||||
final String savingsApplicationJSON = new SavingsApplicationTestBuilder() //
|
||||
.withSubmittedOnDate(submittedOnDate) //
|
||||
.build(ID.toString(), savingsProductID.toString(), accountType);
|
||||
@@ -82,15 +84,15 @@ public class SavingsAccountHelper {
|
||||
}
|
||||
|
||||
public HashMap approveSavings(final Integer savingsID) {
|
||||
return approveSavingsOnDate(savingsID, null);
|
||||
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));
|
||||
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) {
|
||||
@@ -124,7 +126,8 @@ public class SavingsAccountHelper {
|
||||
|
||||
public HashMap closeSavingsAccount(final Integer savingsID, String withdrawBalance) {
|
||||
System.out.println("---------------------------------- CLOSE SAVINGS APPLICATION ----------------------------------");
|
||||
return performSavingApplicationActions(createSavingsOperationURL(CLOSE_SAVINGS_COMMAND, savingsID), getCloseAccountJSON(withdrawBalance, LAST_TRANSACTION_DATE));
|
||||
return performSavingApplicationActions(createSavingsOperationURL(CLOSE_SAVINGS_COMMAND, savingsID),
|
||||
getCloseAccountJSON(withdrawBalance, LAST_TRANSACTION_DATE));
|
||||
}
|
||||
|
||||
public Object deleteSavingsApplication(final Integer savingsId, final String jsonAttributeToGetBack) {
|
||||
@@ -199,9 +202,9 @@ public class SavingsAccountHelper {
|
||||
private String getApproveSavingsAsJSON() {
|
||||
return getApproveSavingsAsJsonOnDate(CREATED_DATE_PLUS_ONE);
|
||||
}
|
||||
|
||||
|
||||
private String getApproveSavingsAsJsonOnDate(final String approvalDate) {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("approvedOnDate", approvalDate);
|
||||
@@ -325,6 +328,11 @@ public class SavingsAccountHelper {
|
||||
final ArrayList<HashMap> response = Utils.performServerGet(requestSpec, responseSpec, URL, jSONAttribute);
|
||||
return response;
|
||||
}
|
||||
|
||||
public Object getSavingsAccountDetail(final Integer savingsID, final String jsonAttribute){
|
||||
final String URL = SAVINGS_ACCOUNT_URL + "/" + savingsID + "?associations=all&" + Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerGet(requestSpec, responseSpec, URL, jsonAttribute);
|
||||
}
|
||||
|
||||
public ArrayList getSavingsCharges(final Integer savingsID) {
|
||||
final String URL = SAVINGS_ACCOUNT_URL + "/" + savingsID + "/charges?" + Utils.TENANT_IDENTIFIER;
|
||||
@@ -352,13 +360,19 @@ 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;
|
||||
}
|
||||
|
||||
public Object getSavingsDetails(final Integer savingsID, final String returnAttribute) {
|
||||
final String URL = SAVINGS_ACCOUNT_URL + "/" + savingsID + "?" + Utils.TENANT_IDENTIFIER;
|
||||
final Object response = Utils.performServerGet(requestSpec, responseSpec, URL, returnAttribute);
|
||||
return response;
|
||||
}
|
||||
|
||||
private HashMap performSavingApplicationActions(final String postURLForSavingsTransaction, final String jsonToBeSent) {
|
||||
HashMap status = null;
|
||||
final HashMap response = Utils.performServerPost(this.requestSpec, this.responseSpec, postURLForSavingsTransaction, jsonToBeSent,
|
||||
@@ -421,4 +435,38 @@ public class SavingsAccountHelper {
|
||||
String josn = new Gson().toJson(map);
|
||||
return josn;
|
||||
}
|
||||
|
||||
public static Integer openSavingsAccount(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer clientId, final String minimumOpeningBalance) {
|
||||
final Integer savingsProductID = createSavingsProduct(requestSpec, responseSpec, minimumOpeningBalance);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
SavingsAccountHelper savingsAccountHelper = new SavingsAccountHelper(requestSpec, responseSpec);
|
||||
|
||||
final Integer savingsId = savingsAccountHelper.applyForSavingsApplication(clientId, savingsProductID, ACCOUNT_TYPE_INDIVIDUAL);
|
||||
Assert.assertNotNull(savingsProductID);
|
||||
|
||||
HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(requestSpec, responseSpec, savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
|
||||
|
||||
savingsStatusHashMap = savingsAccountHelper.approveSavings(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
|
||||
|
||||
savingsStatusHashMap = savingsAccountHelper.activateSavings(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
|
||||
return savingsId;
|
||||
}
|
||||
|
||||
private static Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String minOpenningBalance) {
|
||||
System.out.println("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------");
|
||||
SavingsProductHelper savingsProductHelper = new SavingsProductHelper();
|
||||
final String savingsProductJSON = savingsProductHelper //
|
||||
.withInterestCompoundingPeriodTypeAsDaily() //
|
||||
.withInterestPostingPeriodTypeAsMonthly() //
|
||||
.withInterestCalculationPeriodTypeAsDailyBalance() //
|
||||
.withMinimumOpenningBalance(minOpenningBalance).build();
|
||||
return SavingsProductHelper.createSavingsProduct(savingsProductJSON, requestSpec, responseSpec);
|
||||
}
|
||||
|
||||
}
|
||||
+213
@@ -0,0 +1,213 @@
|
||||
/**
|
||||
* 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 java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
public class AccountNumberPreferencesHelper {
|
||||
|
||||
private final RequestSpecification requestSpec;
|
||||
|
||||
private final ResponseSpecification responseSpec;
|
||||
|
||||
private static final String ACCOUNT_NUMBER_FORMATS_REQUEST_URL = "/mifosng-provider/api/v1/accountnumberformats";
|
||||
|
||||
public AccountNumberPreferencesHelper(
|
||||
final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec) {
|
||||
this.requestSpec = requestSpec;
|
||||
this.responseSpec = responseSpec;
|
||||
}
|
||||
|
||||
public Object createClientAccountNumberPreference(
|
||||
ResponseSpecification responseSpec, String jsonAttributeToGetBack) {
|
||||
System.out
|
||||
.println("---------------------------------CREATING CLIENT ACCOUNT NUMBER PREFERENCE------------------------------------------");
|
||||
|
||||
final String requestJSON = new AccountNumberPreferencesTestBuilder()
|
||||
.clientBuild();
|
||||
|
||||
final String URL = ACCOUNT_NUMBER_FORMATS_REQUEST_URL + "?"
|
||||
+ Utils.TENANT_IDENTIFIER;
|
||||
|
||||
return Utils.performServerPost(this.requestSpec, responseSpec, URL,
|
||||
requestJSON, jsonAttributeToGetBack);
|
||||
}
|
||||
|
||||
public Object createLoanAccountNumberPreference(
|
||||
ResponseSpecification responseSpec, String jsonAttributeToGetBack) {
|
||||
System.out
|
||||
.println("---------------------------------CREATING LOAN ACCOUNT NUMBER PREFERENCE------------------------------------------");
|
||||
|
||||
final String requestJSON = new AccountNumberPreferencesTestBuilder()
|
||||
.loanBuild();
|
||||
|
||||
final String URL = ACCOUNT_NUMBER_FORMATS_REQUEST_URL + "?"
|
||||
+ Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerPost(this.requestSpec, responseSpec, URL,
|
||||
requestJSON, jsonAttributeToGetBack);
|
||||
}
|
||||
|
||||
public Object createSavingsAccountNumberPreference(
|
||||
ResponseSpecification responseSpec, String jsonAttributeToGetBack) {
|
||||
System.out
|
||||
.println("---------------------------------CREATING SAVINGS ACCOUNT NUMBER PREFERENCE------------------------------------------");
|
||||
|
||||
final String requestJSON = new AccountNumberPreferencesTestBuilder()
|
||||
.savingsBuild();
|
||||
|
||||
final String URL = ACCOUNT_NUMBER_FORMATS_REQUEST_URL + "?"
|
||||
+ Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerPost(this.requestSpec, responseSpec, URL,
|
||||
requestJSON, jsonAttributeToGetBack);
|
||||
|
||||
}
|
||||
|
||||
public Object createGroupsAccountNumberPreference(
|
||||
ResponseSpecification responseSpec, String jsonAttributeToGetBack) {
|
||||
System.out
|
||||
.println("---------------------------------CREATING GROUPS ACCOUNT NUMBER PREFERENCE------------------------------------------");
|
||||
|
||||
final String requestJSON = new AccountNumberPreferencesTestBuilder()
|
||||
.groupsBuild();
|
||||
|
||||
final String URL = ACCOUNT_NUMBER_FORMATS_REQUEST_URL + "?"
|
||||
+ Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerPost(this.requestSpec, responseSpec, URL,
|
||||
requestJSON, jsonAttributeToGetBack);
|
||||
|
||||
}
|
||||
|
||||
public Object createCenterAccountNumberPreference(
|
||||
ResponseSpecification responseSpec, String jsonAttributeToGetBack) {
|
||||
System.out
|
||||
.println("---------------------------------CREATING CENTER ACCOUNT NUMBER PREFERENCE------------------------------------------");
|
||||
|
||||
final String requestJSON = new AccountNumberPreferencesTestBuilder()
|
||||
.centerBuild();
|
||||
|
||||
final String URL = ACCOUNT_NUMBER_FORMATS_REQUEST_URL + "?"
|
||||
+ Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerPost(this.requestSpec, responseSpec, URL,
|
||||
requestJSON, jsonAttributeToGetBack);
|
||||
|
||||
}
|
||||
|
||||
public HashMap<String, Object> createAccountNumberPreferenceWithInvalidData(
|
||||
ResponseSpecification responseSpec, String accountType,
|
||||
String prefixType, String jsonAttributeToGetBack) {
|
||||
|
||||
final String requestJSON = new AccountNumberPreferencesTestBuilder()
|
||||
.invalidDataBuild(accountType, prefixType);
|
||||
|
||||
final String URL = ACCOUNT_NUMBER_FORMATS_REQUEST_URL + "?"
|
||||
+ Utils.TENANT_IDENTIFIER;
|
||||
return Utils.performServerPost(this.requestSpec, responseSpec, URL,
|
||||
requestJSON, jsonAttributeToGetBack);
|
||||
|
||||
}
|
||||
|
||||
public HashMap<String, Object> updateAccountNumberPreference(
|
||||
final Integer accountNumberFormatId, final String prefixType,
|
||||
ResponseSpecification responseSpec, String jsonAttributeToGetBack) {
|
||||
|
||||
final String requestJSON = new AccountNumberPreferencesTestBuilder()
|
||||
.updatePrefixType(prefixType);
|
||||
|
||||
final String URL = ACCOUNT_NUMBER_FORMATS_REQUEST_URL + "/"
|
||||
+ accountNumberFormatId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
|
||||
return Utils.performServerPut(this.requestSpec, responseSpec, URL,
|
||||
requestJSON, jsonAttributeToGetBack);
|
||||
|
||||
}
|
||||
|
||||
public HashMap<String, Object> deleteAccountNumberPreference(
|
||||
final Integer accountNumberFormatId,
|
||||
ResponseSpecification responseSpec, String jsonAttributeToGetBack) {
|
||||
|
||||
System.out
|
||||
.println("---------------------------------DELETING ACCOUNT NUMBER PREFERENCE------------------------------------------");
|
||||
|
||||
final String URL = ACCOUNT_NUMBER_FORMATS_REQUEST_URL + "/"
|
||||
+ accountNumberFormatId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
|
||||
return Utils.performServerDelete(this.requestSpec, responseSpec, URL,
|
||||
jsonAttributeToGetBack);
|
||||
}
|
||||
|
||||
public Object getAccountNumberPreference(
|
||||
final Integer accountNumberFormatId,
|
||||
final String jsonAttributeToGetBack) {
|
||||
final String URL = ACCOUNT_NUMBER_FORMATS_REQUEST_URL + "/"
|
||||
+ accountNumberFormatId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
|
||||
return Utils.performServerGet(requestSpec, responseSpec, URL,
|
||||
jsonAttributeToGetBack);
|
||||
}
|
||||
|
||||
public ArrayList<HashMap<String, Object>> getAllAccountNumberPreferences() {
|
||||
final String URL = ACCOUNT_NUMBER_FORMATS_REQUEST_URL + "?"
|
||||
+ Utils.TENANT_IDENTIFIER;
|
||||
final ArrayList<HashMap<String, Object>> response = Utils
|
||||
.performServerGet(requestSpec, responseSpec, URL, "");
|
||||
return response;
|
||||
}
|
||||
|
||||
public void verifyCreationOfAccountNumberPreferences(
|
||||
final Integer clientAccountNumberPreferenceId,
|
||||
final Integer loanAccountNumberPreferenceId,
|
||||
final Integer savingsAccountNumberPreferenceId,
|
||||
final Integer groupsAccountNumberPreferenceId,
|
||||
final Integer centerAccountNumberPreferenceId,
|
||||
ResponseSpecification responseSpec, RequestSpecification requestSpec) {
|
||||
|
||||
final String clientURL = ACCOUNT_NUMBER_FORMATS_REQUEST_URL + "/"
|
||||
+ clientAccountNumberPreferenceId + "?"
|
||||
+ Utils.TENANT_IDENTIFIER;
|
||||
|
||||
Utils.performServerGet(requestSpec, responseSpec, clientURL, "id");
|
||||
|
||||
final String loanURL = ACCOUNT_NUMBER_FORMATS_REQUEST_URL + "/"
|
||||
+ loanAccountNumberPreferenceId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
|
||||
Utils.performServerGet(requestSpec, responseSpec, loanURL, "id");
|
||||
|
||||
final String savingsURL = ACCOUNT_NUMBER_FORMATS_REQUEST_URL + "/"
|
||||
+ savingsAccountNumberPreferenceId + "?"
|
||||
+ Utils.TENANT_IDENTIFIER;
|
||||
|
||||
Utils.performServerGet(requestSpec, responseSpec, savingsURL, "id");
|
||||
|
||||
final String groupsURL = ACCOUNT_NUMBER_FORMATS_REQUEST_URL + "/"
|
||||
+ groupsAccountNumberPreferenceId + "?"
|
||||
+ Utils.TENANT_IDENTIFIER;
|
||||
|
||||
Utils.performServerGet(requestSpec, responseSpec, groupsURL, "id");
|
||||
|
||||
final String centerURL = ACCOUNT_NUMBER_FORMATS_REQUEST_URL + "/"
|
||||
+ centerAccountNumberPreferenceId + "?"
|
||||
+ Utils.TENANT_IDENTIFIER;
|
||||
|
||||
Utils.performServerGet(requestSpec, responseSpec, centerURL, "id");
|
||||
}
|
||||
|
||||
public void verifyUpdationOfAccountNumberPreferences(
|
||||
final Integer accountNumberPreferenceId,
|
||||
ResponseSpecification responseSpec, RequestSpecification requestSpec) {
|
||||
|
||||
final String URL = ACCOUNT_NUMBER_FORMATS_REQUEST_URL + "/"
|
||||
+ accountNumberPreferenceId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
Utils.performServerGet(requestSpec, responseSpec, URL, "id");
|
||||
|
||||
}
|
||||
}
|
||||
+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.common.system;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class AccountNumberPreferencesTestBuilder {
|
||||
private String clientAccountType = "1";
|
||||
private String clientPrefixType = "101";
|
||||
private String loanAccountType = "2";
|
||||
private String loanPrefixType = "1";
|
||||
private String savingsAccountType = "3";
|
||||
private String savingsPrefixType = "1";
|
||||
private String centerAccountType = "4";
|
||||
private String centerPrefixType = "1";
|
||||
private String groupsAccountType = "5";
|
||||
private String groupsPrefixType = "1";
|
||||
|
||||
public String clientBuild() {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("accountType", clientAccountType);
|
||||
map.put("prefixType", clientPrefixType);
|
||||
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
public String loanBuild() {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("accountType", loanAccountType);
|
||||
map.put("prefixType", loanPrefixType);
|
||||
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
public String savingsBuild() {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("accountType", savingsAccountType);
|
||||
map.put("prefixType", savingsPrefixType);
|
||||
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
public String groupsBuild() {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("accountType", groupsAccountType);
|
||||
map.put("prefixType", groupsPrefixType);
|
||||
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
public String centerBuild() {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("accountType", centerAccountType);
|
||||
map.put("prefixType", centerPrefixType);
|
||||
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
public String invalidDataBuild(String accountType, String prefixType) {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("accountType", accountType);
|
||||
map.put("prefixType", prefixType);
|
||||
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
public String updatePrefixType(final String prefixType) {
|
||||
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("prefixType", prefixType);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
}
|
||||
+185
-94
@@ -7,7 +7,9 @@ package org.mifosplatform.integrationtests.common.system;
|
||||
|
||||
import static com.jayway.restassured.RestAssured.given;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
|
||||
@@ -18,132 +20,221 @@ 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_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 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 HashMap<String, Object> getCodeByName(
|
||||
final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final String codeName) {
|
||||
|
||||
return Utils.performServerGet(requestSpec, responseSpec, CODE_URL + "?" + Utils.TENANT_IDENTIFIER, "");
|
||||
final HashMap<String, Object> code = new HashMap<>();
|
||||
|
||||
}
|
||||
ArrayList<HashMap<String, Object>> getAllCodes = CodeHelper
|
||||
.getAllCodes(requestSpec, responseSpec);
|
||||
for (HashMap<String, Object> map : getAllCodes) {
|
||||
String name = (String) map.get("name");
|
||||
if (name.equals(codeName)) {
|
||||
code.put("id", map.get("id"));
|
||||
code.put("name", map.get("name"));
|
||||
code.put("systemDefined", map.get("systemDefined"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
public static Object getSystemDefinedCodes(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
public static HashMap<String, Object> retrieveOrCreateCodeValue(
|
||||
Integer codeId, final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec) {
|
||||
Integer codeValueId = null;
|
||||
final List<HashMap<String, Object>> codeValuesList = CodeHelper
|
||||
.getCodeValuesForCode(requestSpec, responseSpec, codeId, "");
|
||||
/* If Code Values doesn't exist,then create Code value */
|
||||
if (codeValuesList.size() == 0) {
|
||||
final Integer codeValuePosition = 0;
|
||||
final String codeValue = Utils.randomNameGenerator("", 3);
|
||||
codeValueId = (Integer) CodeHelper.createCodeValue(requestSpec,
|
||||
responseSpec, codeId, codeValue, codeValuePosition,
|
||||
"subResourceId");
|
||||
|
||||
} else {
|
||||
return codeValuesList.get(0);
|
||||
}
|
||||
return Utils.performServerGet(requestSpec, responseSpec,
|
||||
CODE_VALUE_URL.replace("[codeId]", codeId.toString()) + "/"
|
||||
+ codeValueId.toString() + "?"
|
||||
+ Utils.TENANT_IDENTIFIER, "");
|
||||
|
||||
}
|
||||
|
||||
final String getResponse = given().spec(requestSpec).expect().spec(responseSpec).when()
|
||||
.get(CodeHelper.CODE_URL + "?" + Utils.TENANT_IDENTIFIER).asString();
|
||||
public static ArrayList<HashMap<String, Object>> getAllCodes(
|
||||
final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec) {
|
||||
|
||||
final JsonPath getResponseJsonPath = new JsonPath(getResponse);
|
||||
return Utils.performServerGet(requestSpec, responseSpec, CODE_URL + "?"
|
||||
+ Utils.TENANT_IDENTIFIER, "");
|
||||
|
||||
// get any systemDefined code
|
||||
return getResponseJsonPath.get("find { e -> e.systemDefined == true }");
|
||||
}
|
||||
|
||||
}
|
||||
public static Object getSystemDefinedCodes(
|
||||
final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec) {
|
||||
|
||||
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);
|
||||
}
|
||||
final String getResponse = given().spec(requestSpec).expect()
|
||||
.spec(responseSpec).when()
|
||||
.get(CodeHelper.CODE_URL + "?" + Utils.TENANT_IDENTIFIER)
|
||||
.asString();
|
||||
|
||||
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);
|
||||
}
|
||||
final JsonPath getResponseJsonPath = new JsonPath(getResponse);
|
||||
|
||||
public static Object deleteCodeById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer codeId, final String jsonAttributeToGetback) {
|
||||
// get any systemDefined code
|
||||
return getResponseJsonPath.get("find { e -> e.systemDefined == true }");
|
||||
|
||||
return Utils.performServerDelete(requestSpec, responseSpec, CODE_URL + "/" + codeId + "?" + Utils.TENANT_IDENTIFIER,
|
||||
jsonAttributeToGetback);
|
||||
}
|
||||
|
||||
}
|
||||
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 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);
|
||||
}
|
||||
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 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 deleteCodeById(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.performServerDelete(requestSpec, responseSpec, CODE_URL
|
||||
+ "/" + codeId + "?" + Utils.TENANT_IDENTIFIER,
|
||||
jsonAttributeToGetback);
|
||||
|
||||
public static Object getCodeValuesForCode(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer codeId, final String jsonAttributeToGetback) {
|
||||
}
|
||||
|
||||
return Utils.performServerGet(requestSpec, responseSpec, CODE_VALUE_URL.replace("[codeId]", codeId.toString()) + "?"
|
||||
+ 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) {
|
||||
String description = null;
|
||||
return createCodeValue(requestSpec, responseSpec, codeId,
|
||||
codeValueName, description, position, jsonAttributeToGetback);
|
||||
}
|
||||
|
||||
public static Object getCodeValueById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer codeId, final Integer codeValueId, final String 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) {
|
||||
|
||||
return Utils.performServerGet(requestSpec, responseSpec,
|
||||
CODE_VALUE_URL.replace("[codeId]", codeId.toString()) + "/" + codeValueId.toString() + "?" + Utils.TENANT_IDENTIFIER,
|
||||
jsonAttributeToGetback);
|
||||
}
|
||||
return Utils.performServerPost(requestSpec, responseSpec,
|
||||
CODE_VALUE_URL.replace("[codeId]", codeId.toString()) + "?"
|
||||
+ Utils.TENANT_IDENTIFIER,
|
||||
getTestCodeValueAsJSON(codeValueName, description, position),
|
||||
jsonAttributeToGetback);
|
||||
}
|
||||
|
||||
public static Object deleteCodeValueById(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer codeId, final Integer codeValueId, final String jsonAttributeToGetback) {
|
||||
public static List<HashMap<String, Object>> getCodeValuesForCode(
|
||||
final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final Integer codeId,
|
||||
final String jsonAttributeToGetback) {
|
||||
|
||||
return Utils.performServerDelete(requestSpec, responseSpec, CODE_VALUE_URL.replace("[codeId]", codeId.toString()) + "/"
|
||||
+ codeValueId.toString() + "?" + Utils.TENANT_IDENTIFIER, jsonAttributeToGetback);
|
||||
}
|
||||
return Utils.performServerGet(requestSpec, responseSpec,
|
||||
CODE_VALUE_URL.replace("[codeId]", codeId.toString()) + "?"
|
||||
+ Utils.TENANT_IDENTIFIER, 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 getCodeValueById(
|
||||
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 String description, final Integer position,
|
||||
final String jsonAttributeToGetback) {
|
||||
return Utils.performServerGet(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, description, position), jsonAttributeToGetback);
|
||||
}
|
||||
public static Object deleteCodeValueById(
|
||||
final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final Integer codeId,
|
||||
final Integer codeValueId, final String jsonAttributeToGetback) {
|
||||
|
||||
return Utils.performServerDelete(requestSpec, responseSpec,
|
||||
CODE_VALUE_URL.replace("[codeId]", codeId.toString()) + "/"
|
||||
+ codeValueId.toString() + "?"
|
||||
+ Utils.TENANT_IDENTIFIER, 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);
|
||||
}
|
||||
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* 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.loanaccount.guarantor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.mifosplatform.integrationtests.common.CommonConstants;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
public class GuarantorHelper {
|
||||
|
||||
private static final String LOAN_URL = "/mifosng-provider/api/v1/loans/";
|
||||
private static final String GUARANTOR_API_URL = "/guarantors/";
|
||||
private static final String TENANT = "?" + Utils.TENANT_IDENTIFIER;
|
||||
private final RequestSpecification requestSpec;
|
||||
private final ResponseSpecification responseSpec;
|
||||
|
||||
public GuarantorHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
this.requestSpec = requestSpec;
|
||||
this.responseSpec = responseSpec;
|
||||
}
|
||||
|
||||
public Integer createGuarantor(final Integer loanId, final String guarantorJSON) {
|
||||
return Utils.performServerPost(this.requestSpec, this.responseSpec, LOAN_URL + loanId + GUARANTOR_API_URL + TENANT, guarantorJSON,
|
||||
CommonConstants.RESPONSE_RESOURCE_ID);
|
||||
}
|
||||
|
||||
public HashMap updateGuarantor(final Integer guarantorId, final Integer loanId, final String guarantorJSON) {
|
||||
return Utils.performServerPut(this.requestSpec, this.responseSpec, LOAN_URL + loanId + GUARANTOR_API_URL + guarantorId + TENANT,
|
||||
guarantorJSON, CommonConstants.RESPONSE_CHANGES);
|
||||
}
|
||||
|
||||
public HashMap deleteGuarantor(final Integer guarantorId, final Integer fundId, final Integer loanId) {
|
||||
return Utils.performServerDelete(this.requestSpec, this.responseSpec, LOAN_URL + loanId + GUARANTOR_API_URL + guarantorId + TENANT
|
||||
+ "&guarantorFundingId=" + fundId, "");
|
||||
}
|
||||
|
||||
public HashMap deleteGuarantor(final Integer guarantorId, final Integer loanId) {
|
||||
return Utils.performServerDelete(this.requestSpec, this.responseSpec, LOAN_URL + loanId + GUARANTOR_API_URL + guarantorId + TENANT,
|
||||
"");
|
||||
}
|
||||
|
||||
public Object getGuarantor(final Integer guarantorId, final Integer loanId, final String jsonToGetBack) {
|
||||
return Utils.performServerGet(this.requestSpec, this.responseSpec, LOAN_URL + loanId + GUARANTOR_API_URL + guarantorId + TENANT,
|
||||
jsonToGetBack);
|
||||
}
|
||||
|
||||
public List getAllGuarantor(final Integer loanId) {
|
||||
return Utils.performServerGet(this.requestSpec, this.responseSpec, LOAN_URL + loanId + GUARANTOR_API_URL + TENANT, "");
|
||||
}
|
||||
|
||||
}
|
||||
+681
@@ -0,0 +1,681 @@
|
||||
/**
|
||||
* 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.loanaccount.guarantor;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
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.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.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 org.mifosplatform.integrationtests.common.savings.SavingsAccountHelper;
|
||||
|
||||
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 GuarantorTest {
|
||||
|
||||
private ResponseSpecification responseSpec;
|
||||
private RequestSpecification requestSpec;
|
||||
private LoanTransactionHelper loanTransactionHelper;
|
||||
private GuarantorHelper guarantorHelper;
|
||||
private SavingsAccountHelper savingsAccountHelper;
|
||||
private final Float self1_balance = new Float(5000);
|
||||
private final Float external1_balance = new Float(5000);
|
||||
private final Float external2_balance = new Float(5000);
|
||||
private final Float self1_guarantee = new Float(2000);
|
||||
private final Float external1_guarantee = new Float(2000);
|
||||
private final Float external2_guarantee = new Float(1000);
|
||||
|
||||
@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().build();
|
||||
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||
this.guarantorHelper = new GuarantorHelper(this.requestSpec, this.responseSpec);
|
||||
savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Test
|
||||
public void testGuarantor() {
|
||||
|
||||
Float self1_hold_funds = new Float(0);
|
||||
Float external1_hold_funds = new Float(0);
|
||||
Float external2_hold_funds = new Float(0);
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
|
||||
final Integer clientID_external = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
final Integer clientID_external2 = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
|
||||
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID_external);
|
||||
|
||||
final Integer selfSavigsId = SavingsAccountHelper.openSavingsAccount(this.requestSpec, this.responseSpec, clientID,
|
||||
String.valueOf(self1_balance));
|
||||
final Integer externalSavigsId_1 = SavingsAccountHelper.openSavingsAccount(this.requestSpec, this.responseSpec, clientID_external,
|
||||
String.valueOf(external1_balance));
|
||||
final Integer externalSavigsId_2 = SavingsAccountHelper.openSavingsAccount(this.requestSpec, this.responseSpec, clientID_external2,
|
||||
String.valueOf(external2_balance));
|
||||
|
||||
final Integer loanProductID = createLoanProductWithHoldFunds("50", "20", "20");
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.DAY_OF_MONTH, -7 * 4);
|
||||
String LOAN_DISBURSEMENT_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final Integer loanID = applyForLoanApplication(clientID, loanProductID, LOAN_DISBURSEMENT_DATE);
|
||||
Assert.assertNotNull(loanID);
|
||||
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
|
||||
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
|
||||
|
||||
String guarantorJSON = new GuarantorTestBuilder().externalCustomer().build();
|
||||
Integer externalGuarantor = this.guarantorHelper.createGuarantor(loanID, guarantorJSON);
|
||||
Assert.assertNotNull(externalGuarantor);
|
||||
|
||||
guarantorJSON = new GuarantorTestBuilder().existingCustomerWithoutGuaranteeAmount(String.valueOf(clientID_external)).build();
|
||||
Integer withoutGuaranteeAmount = this.guarantorHelper.createGuarantor(loanID, guarantorJSON);
|
||||
Assert.assertNotNull(withoutGuaranteeAmount);
|
||||
|
||||
ArrayList<HashMap> errorData = (ArrayList<HashMap>) this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, null, loanID,
|
||||
CommonConstants.RESPONSE_ERROR);
|
||||
assertTrue(checkForErrorCode(errorData, "validation.msg.loan.guarantor.min.self.guarantee.required"));
|
||||
assertTrue(checkForErrorCode(errorData, "validation.msg.loan.guarantor.min.external.guarantee.required"));
|
||||
assertTrue(checkForErrorCode(errorData, "validation.msg.loan.guarantor.mandated.guarantee.required"));
|
||||
|
||||
guarantorJSON = new GuarantorTestBuilder().existingCustomerWithGuaranteeAmount(String.valueOf(clientID),
|
||||
String.valueOf(selfSavigsId), String.valueOf(self1_guarantee)).build();
|
||||
Integer selfGuarantee = this.guarantorHelper.createGuarantor(loanID, guarantorJSON);
|
||||
verifySavingsOnHoldBalance(selfSavigsId, null);
|
||||
Assert.assertNotNull(selfGuarantee);
|
||||
|
||||
errorData = (ArrayList<HashMap>) this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, null, loanID,
|
||||
CommonConstants.RESPONSE_ERROR);
|
||||
assertFalse(checkForErrorCode(errorData, "validation.msg.loan.guarantor.min.self.guarantee.required"));
|
||||
assertTrue(checkForErrorCode(errorData, "validation.msg.loan.guarantor.min.external.guarantee.required"));
|
||||
assertTrue(checkForErrorCode(errorData, "validation.msg.loan.guarantor.mandated.guarantee.required"));
|
||||
|
||||
guarantorJSON = new GuarantorTestBuilder().existingCustomerWithGuaranteeAmount(String.valueOf(clientID_external),
|
||||
String.valueOf(externalSavigsId_1), String.valueOf(external1_guarantee)).build();
|
||||
Integer externalGuarantee_1 = this.guarantorHelper.createGuarantor(loanID, guarantorJSON);
|
||||
verifySavingsOnHoldBalance(externalSavigsId_1, null);
|
||||
Assert.assertNotNull(externalGuarantee_1);
|
||||
|
||||
errorData = (ArrayList<HashMap>) this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, null, loanID,
|
||||
CommonConstants.RESPONSE_ERROR);
|
||||
assertFalse(checkForErrorCode(errorData, "validation.msg.loan.guarantor.min.self.guarantee.required"));
|
||||
assertFalse(checkForErrorCode(errorData, "validation.msg.loan.guarantor.min.external.guarantee.required"));
|
||||
assertTrue(checkForErrorCode(errorData, "validation.msg.loan.guarantor.mandated.guarantee.required"));
|
||||
|
||||
guarantorJSON = new GuarantorTestBuilder().existingCustomerWithGuaranteeAmount(String.valueOf(clientID_external2),
|
||||
String.valueOf(externalSavigsId_2), String.valueOf(external2_guarantee)).build();
|
||||
Integer externalGuarantee_2 = this.guarantorHelper.createGuarantor(loanID, guarantorJSON);
|
||||
verifySavingsOnHoldBalance(externalSavigsId_2, null);
|
||||
Assert.assertNotNull(externalGuarantee_2);
|
||||
|
||||
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------");
|
||||
loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID);
|
||||
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
|
||||
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
|
||||
self1_hold_funds += self1_guarantee;
|
||||
external1_hold_funds += external1_guarantee;
|
||||
external2_hold_funds += external2_guarantee;
|
||||
verifySavingsOnHoldBalance(selfSavigsId, self1_hold_funds);
|
||||
verifySavingsOnHoldBalance(externalSavigsId_1, external1_hold_funds);
|
||||
verifySavingsOnHoldBalance(externalSavigsId_2, external2_hold_funds);
|
||||
|
||||
System.out.println("-----------------------------------UNDO APPROVE LOAN-----------------------------------------");
|
||||
loanStatusHashMap = this.loanTransactionHelper.undoApproval(loanID);
|
||||
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
|
||||
verifySavingsOnHoldBalance(selfSavigsId, new Float(0));
|
||||
verifySavingsOnHoldBalance(externalSavigsId_1, new Float(0));
|
||||
verifySavingsOnHoldBalance(externalSavigsId_2, new Float(0));
|
||||
|
||||
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------");
|
||||
loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID);
|
||||
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
|
||||
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
|
||||
verifySavingsOnHoldBalance(selfSavigsId, self1_hold_funds);
|
||||
verifySavingsOnHoldBalance(externalSavigsId_1, external1_hold_funds);
|
||||
verifySavingsOnHoldBalance(externalSavigsId_2, external2_hold_funds);
|
||||
|
||||
System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------");
|
||||
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID);
|
||||
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
|
||||
|
||||
// First repayment
|
||||
ArrayList<HashMap> loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID);
|
||||
todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.DAY_OF_MONTH, -7 * 3);
|
||||
String LOAN_REPAYMENT_DATE = dateFormat.format(todaysDate.getTime());
|
||||
Float totalDueForCurrentPeriod = (Float) loanSchedule.get(1).get("totalDueForPeriod");
|
||||
external1_hold_funds -= new Float(827.5867);
|
||||
external2_hold_funds -= new Float(413.7933);
|
||||
this.loanTransactionHelper.makeRepayment(LOAN_REPAYMENT_DATE, totalDueForCurrentPeriod, loanID);
|
||||
verifySavingsOnHoldBalance(selfSavigsId, self1_hold_funds);
|
||||
verifySavingsOnHoldBalance(externalSavigsId_1, external1_hold_funds);
|
||||
verifySavingsOnHoldBalance(externalSavigsId_2, external2_hold_funds);
|
||||
|
||||
// Second repayment
|
||||
todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.DAY_OF_MONTH, -7 * 2);
|
||||
LOAN_REPAYMENT_DATE = dateFormat.format(todaysDate.getTime());
|
||||
totalDueForCurrentPeriod = (Float) loanSchedule.get(2).get("totalDueForPeriod");
|
||||
external1_hold_funds -= new Float(831.4067);
|
||||
external2_hold_funds -= new Float(415.7033333);
|
||||
this.loanTransactionHelper.makeRepayment(LOAN_REPAYMENT_DATE, totalDueForCurrentPeriod, loanID);
|
||||
verifySavingsOnHoldBalance(selfSavigsId, self1_hold_funds);
|
||||
verifySavingsOnHoldBalance(externalSavigsId_1, external1_hold_funds);
|
||||
verifySavingsOnHoldBalance(externalSavigsId_2, external2_hold_funds);
|
||||
|
||||
// third repayment
|
||||
todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.DAY_OF_MONTH, -7);
|
||||
LOAN_REPAYMENT_DATE = dateFormat.format(todaysDate.getTime());
|
||||
totalDueForCurrentPeriod = (Float) loanSchedule.get(3).get("totalDueForPeriod");
|
||||
self1_hold_funds -= new Float(741.355);
|
||||
this.loanTransactionHelper.makeRepayment(LOAN_REPAYMENT_DATE, totalDueForCurrentPeriod, loanID);
|
||||
verifySavingsOnHoldBalance(selfSavigsId, self1_hold_funds);
|
||||
verifySavingsOnHoldBalance(externalSavigsId_1, new Float(0));
|
||||
verifySavingsOnHoldBalance(externalSavigsId_2, new Float(0));
|
||||
|
||||
// forth repayment
|
||||
todaysDate = Calendar.getInstance();
|
||||
LOAN_REPAYMENT_DATE = dateFormat.format(todaysDate.getTime());
|
||||
totalDueForCurrentPeriod = (Float) loanSchedule.get(3).get("totalDueForPeriod");
|
||||
this.loanTransactionHelper.makeRepayment(LOAN_REPAYMENT_DATE, totalDueForCurrentPeriod, loanID);
|
||||
verifySavingsOnHoldBalance(selfSavigsId, new Float(0));
|
||||
verifySavingsOnHoldBalance(externalSavigsId_1, new Float(0));
|
||||
verifySavingsOnHoldBalance(externalSavigsId_2, new Float(0));
|
||||
|
||||
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
|
||||
LoanStatusChecker.verifyLoanAccountIsClosed(loanStatusHashMap);
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Test
|
||||
public void testGuarantor_UNDO_DISBURSAL() {
|
||||
|
||||
Float self1_hold_funds = new Float(0);
|
||||
Float external1_hold_funds = new Float(0);
|
||||
Float external2_hold_funds = new Float(0);
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
|
||||
final Integer clientID_external = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
final Integer clientID_external2 = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
|
||||
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID_external);
|
||||
|
||||
final Integer selfSavigsId = SavingsAccountHelper.openSavingsAccount(this.requestSpec, this.responseSpec, clientID,
|
||||
String.valueOf(self1_balance));
|
||||
final Integer externalSavigsId_1 = SavingsAccountHelper.openSavingsAccount(this.requestSpec, this.responseSpec, clientID_external,
|
||||
String.valueOf(external1_balance));
|
||||
final Integer externalSavigsId_3 = SavingsAccountHelper.openSavingsAccount(this.requestSpec, this.responseSpec, clientID_external,
|
||||
String.valueOf(external1_balance));
|
||||
final Integer externalSavigsId_2 = SavingsAccountHelper.openSavingsAccount(this.requestSpec, this.responseSpec, clientID_external2,
|
||||
String.valueOf(external2_balance));
|
||||
|
||||
final Integer loanProductID = createLoanProductWithHoldFunds("50", "20", "20");
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.DAY_OF_MONTH, -7 * 4);
|
||||
String LOAN_DISBURSEMENT_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final Integer loanID = applyForLoanApplication(clientID, loanProductID, LOAN_DISBURSEMENT_DATE);
|
||||
Assert.assertNotNull(loanID);
|
||||
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
|
||||
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
|
||||
|
||||
String guarantorJSON = new GuarantorTestBuilder().externalCustomer().build();
|
||||
Integer externalGuarantor = this.guarantorHelper.createGuarantor(loanID, guarantorJSON);
|
||||
Assert.assertNotNull(externalGuarantor);
|
||||
|
||||
guarantorJSON = new GuarantorTestBuilder().existingCustomerWithoutGuaranteeAmount(String.valueOf(clientID_external)).build();
|
||||
Integer withoutGuaranteeAmount = this.guarantorHelper.createGuarantor(loanID, guarantorJSON);
|
||||
Assert.assertNotNull(withoutGuaranteeAmount);
|
||||
|
||||
ArrayList<HashMap> errorData = (ArrayList<HashMap>) this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, null, loanID,
|
||||
CommonConstants.RESPONSE_ERROR);
|
||||
assertTrue(checkForErrorCode(errorData, "validation.msg.loan.guarantor.min.self.guarantee.required"));
|
||||
assertTrue(checkForErrorCode(errorData, "validation.msg.loan.guarantor.min.external.guarantee.required"));
|
||||
assertTrue(checkForErrorCode(errorData, "validation.msg.loan.guarantor.mandated.guarantee.required"));
|
||||
|
||||
guarantorJSON = new GuarantorTestBuilder().existingCustomerWithGuaranteeAmount(String.valueOf(clientID),
|
||||
String.valueOf(selfSavigsId), String.valueOf(self1_guarantee)).build();
|
||||
Integer selfGuarantee = this.guarantorHelper.createGuarantor(loanID, guarantorJSON);
|
||||
verifySavingsOnHoldBalance(selfSavigsId, null);
|
||||
Assert.assertNotNull(selfGuarantee);
|
||||
|
||||
errorData = (ArrayList<HashMap>) this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, null, loanID,
|
||||
CommonConstants.RESPONSE_ERROR);
|
||||
assertFalse(checkForErrorCode(errorData, "validation.msg.loan.guarantor.min.self.guarantee.required"));
|
||||
assertTrue(checkForErrorCode(errorData, "validation.msg.loan.guarantor.min.external.guarantee.required"));
|
||||
assertTrue(checkForErrorCode(errorData, "validation.msg.loan.guarantor.mandated.guarantee.required"));
|
||||
|
||||
guarantorJSON = new GuarantorTestBuilder().existingCustomerWithGuaranteeAmount(String.valueOf(clientID_external),
|
||||
String.valueOf(externalSavigsId_1), String.valueOf(external1_guarantee)).build();
|
||||
Integer externalGuarantee_1 = this.guarantorHelper.createGuarantor(loanID, guarantorJSON);
|
||||
verifySavingsOnHoldBalance(externalSavigsId_1, null);
|
||||
Assert.assertNotNull(externalGuarantee_1);
|
||||
|
||||
errorData = (ArrayList<HashMap>) this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, null, loanID,
|
||||
CommonConstants.RESPONSE_ERROR);
|
||||
assertFalse(checkForErrorCode(errorData, "validation.msg.loan.guarantor.min.self.guarantee.required"));
|
||||
assertFalse(checkForErrorCode(errorData, "validation.msg.loan.guarantor.min.external.guarantee.required"));
|
||||
assertTrue(checkForErrorCode(errorData, "validation.msg.loan.guarantor.mandated.guarantee.required"));
|
||||
|
||||
guarantorJSON = new GuarantorTestBuilder().existingCustomerWithGuaranteeAmount(String.valueOf(clientID_external2),
|
||||
String.valueOf(externalSavigsId_2), String.valueOf(external2_guarantee)).build();
|
||||
Integer externalGuarantee_2 = this.guarantorHelper.createGuarantor(loanID, guarantorJSON);
|
||||
Assert.assertNotNull(externalGuarantee_2);
|
||||
verifySavingsOnHoldBalance(externalSavigsId_2, null);
|
||||
|
||||
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------");
|
||||
loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID);
|
||||
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
|
||||
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
|
||||
self1_hold_funds += self1_guarantee;
|
||||
external1_hold_funds += external1_guarantee;
|
||||
external2_hold_funds += external2_guarantee;
|
||||
verifySavingsOnHoldBalance(selfSavigsId, self1_hold_funds);
|
||||
verifySavingsOnHoldBalance(externalSavigsId_1, external1_hold_funds);
|
||||
verifySavingsOnHoldBalance(externalSavigsId_2, external2_hold_funds);
|
||||
|
||||
System.out.println("-----------------------------------UNDO APPROVE LOAN-----------------------------------------");
|
||||
loanStatusHashMap = this.loanTransactionHelper.undoApproval(loanID);
|
||||
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
|
||||
verifySavingsOnHoldBalance(selfSavigsId, new Float(0));
|
||||
verifySavingsOnHoldBalance(externalSavigsId_1, new Float(0));
|
||||
verifySavingsOnHoldBalance(externalSavigsId_2, new Float(0));
|
||||
|
||||
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------");
|
||||
loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID);
|
||||
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
|
||||
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
|
||||
verifySavingsOnHoldBalance(selfSavigsId, self1_hold_funds);
|
||||
verifySavingsOnHoldBalance(externalSavigsId_1, external1_hold_funds);
|
||||
verifySavingsOnHoldBalance(externalSavigsId_2, external2_hold_funds);
|
||||
List<HashMap> guarantors = this.guarantorHelper.getAllGuarantor(loanID);
|
||||
this.guarantorHelper.deleteGuarantor(externalGuarantor, loanID);
|
||||
assertFalse((Boolean) this.guarantorHelper.getGuarantor(externalGuarantor, loanID, "status"));
|
||||
HashMap errorlog = this.guarantorHelper.deleteGuarantor(withoutGuaranteeAmount, loanID);
|
||||
ArrayList<HashMap> error = (ArrayList<HashMap>) errorlog.get(CommonConstants.RESPONSE_ERROR);
|
||||
assertTrue(checkForErrorCode(error, "error.msg.loan.guarantor.not.found"));
|
||||
guarantors = this.guarantorHelper.getAllGuarantor(loanID);
|
||||
assertEquals(4, guarantors.size());
|
||||
List<HashMap> externalGuarantee_1_details = (List<HashMap>) this.guarantorHelper.getGuarantor(externalGuarantee_1, loanID,
|
||||
"guarantorFundingDetails");
|
||||
Integer fundDetailId = (Integer) externalGuarantee_1_details.get(0).get("id");
|
||||
errorlog = this.guarantorHelper.deleteGuarantor(externalGuarantee_1, fundDetailId, loanID);
|
||||
error = (ArrayList<HashMap>) errorlog.get(CommonConstants.RESPONSE_ERROR);
|
||||
assertTrue(checkForErrorCode(error, "validation.msg.loan.guarantor.min.external.guarantee.required"));
|
||||
|
||||
guarantorJSON = new GuarantorTestBuilder().existingCustomerWithGuaranteeAmount(String.valueOf(clientID_external),
|
||||
String.valueOf(externalSavigsId_3), String.valueOf(external1_guarantee)).build();
|
||||
Integer externalGuarantee_3 = this.guarantorHelper.createGuarantor(loanID, guarantorJSON);
|
||||
verifySavingsOnHoldBalance(externalSavigsId_3, external1_guarantee);
|
||||
Assert.assertNotNull(externalGuarantee_3);
|
||||
|
||||
this.guarantorHelper.deleteGuarantor(externalGuarantee_1, fundDetailId, loanID);
|
||||
guarantors = this.guarantorHelper.getAllGuarantor(loanID);
|
||||
assertEquals(4, guarantors.size());
|
||||
externalGuarantee_1_details = (List<HashMap>) this.guarantorHelper.getGuarantor(externalGuarantee_1, loanID,
|
||||
"guarantorFundingDetails");
|
||||
assertEquals(2, externalGuarantee_1_details.size());
|
||||
|
||||
for (HashMap map : externalGuarantee_1_details) {
|
||||
if (map.get("id").equals(fundDetailId)) {
|
||||
HashMap status = (HashMap) map.get("status");
|
||||
assertEquals("guarantorFundStatusType.withdrawn", status.get("code"));
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------");
|
||||
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID);
|
||||
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
|
||||
|
||||
// First repayment
|
||||
ArrayList<HashMap> loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID);
|
||||
todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.DAY_OF_MONTH, -7 * 3);
|
||||
String LOAN_REPAYMENT_DATE = dateFormat.format(todaysDate.getTime());
|
||||
Float totalDueForCurrentPeriod = (Float) loanSchedule.get(1).get("totalDueForPeriod");
|
||||
external1_hold_funds -= new Float(827.5867);
|
||||
external2_hold_funds -= new Float(413.7933);
|
||||
this.loanTransactionHelper.makeRepayment(LOAN_REPAYMENT_DATE, totalDueForCurrentPeriod, loanID);
|
||||
verifySavingsOnHoldBalance(selfSavigsId, self1_hold_funds);
|
||||
verifySavingsOnHoldBalance(externalSavigsId_3, external1_hold_funds);
|
||||
verifySavingsOnHoldBalance(externalSavigsId_2, external2_hold_funds);
|
||||
|
||||
// Second repayment
|
||||
todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.DAY_OF_MONTH, -7 * 2);
|
||||
LOAN_REPAYMENT_DATE = dateFormat.format(todaysDate.getTime());
|
||||
totalDueForCurrentPeriod = (Float) loanSchedule.get(2).get("totalDueForPeriod");
|
||||
external1_hold_funds -= new Float(831.4067);
|
||||
external2_hold_funds -= new Float(415.7033333);
|
||||
this.loanTransactionHelper.makeRepayment(LOAN_REPAYMENT_DATE, totalDueForCurrentPeriod, loanID);
|
||||
verifySavingsOnHoldBalance(selfSavigsId, self1_hold_funds);
|
||||
verifySavingsOnHoldBalance(externalSavigsId_3, external1_hold_funds);
|
||||
verifySavingsOnHoldBalance(externalSavigsId_2, external2_hold_funds);
|
||||
|
||||
// third repayment
|
||||
todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.DAY_OF_MONTH, -7);
|
||||
LOAN_REPAYMENT_DATE = dateFormat.format(todaysDate.getTime());
|
||||
totalDueForCurrentPeriod = (Float) loanSchedule.get(3).get("totalDueForPeriod");
|
||||
Float self1_hold_funds_temp = self1_hold_funds - new Float(741.355);
|
||||
HashMap transactionDetail = this.loanTransactionHelper.makeRepayment(LOAN_REPAYMENT_DATE, totalDueForCurrentPeriod, loanID);
|
||||
verifySavingsOnHoldBalance(selfSavigsId, self1_hold_funds_temp);
|
||||
verifySavingsOnHoldBalance(externalSavigsId_3, new Float(0));
|
||||
verifySavingsOnHoldBalance(externalSavigsId_2, new Float(0));
|
||||
|
||||
// undo repayment
|
||||
this.loanTransactionHelper.adjustLoanTransaction(loanID, (Integer) transactionDetail.get(CommonConstants.RESPONSE_RESOURCE_ID),
|
||||
LOAN_REPAYMENT_DATE, "0", "");
|
||||
verifySavingsOnHoldBalance(selfSavigsId, self1_hold_funds);
|
||||
verifySavingsOnHoldBalance(externalSavigsId_3, external1_hold_funds);
|
||||
verifySavingsOnHoldBalance(externalSavigsId_2, external2_hold_funds);
|
||||
|
||||
// undo disbursal
|
||||
loanStatusHashMap = this.loanTransactionHelper.undoDisbursal(loanID);
|
||||
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
|
||||
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
|
||||
verifySavingsOnHoldBalance(selfSavigsId, new Float(self1_guarantee));
|
||||
verifySavingsOnHoldBalance(externalSavigsId_3, new Float(external1_guarantee));
|
||||
verifySavingsOnHoldBalance(externalSavigsId_2, new Float(external2_guarantee));
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Test
|
||||
public void testGuarantor_RECOVER_GUARANTEES() {
|
||||
|
||||
Float self1_hold_funds = new Float(0);
|
||||
Float external1_hold_funds = new Float(0);
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
|
||||
final Integer clientID_external = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID_external);
|
||||
|
||||
final Integer selfSavigsId = SavingsAccountHelper.openSavingsAccount(this.requestSpec, this.responseSpec, clientID,
|
||||
String.valueOf(self1_balance));
|
||||
final Integer externalSavigsId_1 = SavingsAccountHelper.openSavingsAccount(this.requestSpec, this.responseSpec, clientID_external,
|
||||
String.valueOf(external1_balance));
|
||||
|
||||
final Integer loanProductID = createLoanProductWithHoldFunds("40", "20", "20");
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.DAY_OF_MONTH, -21);
|
||||
String LOAN_DISBURSEMENT_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final Integer loanID = applyForLoanApplication(clientID, loanProductID, LOAN_DISBURSEMENT_DATE);
|
||||
Assert.assertNotNull(loanID);
|
||||
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
|
||||
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
|
||||
|
||||
String guarantorJSON = new GuarantorTestBuilder().existingCustomerWithGuaranteeAmount(String.valueOf(clientID),
|
||||
String.valueOf(selfSavigsId), String.valueOf(self1_guarantee)).build();
|
||||
Integer selfGuarantee = this.guarantorHelper.createGuarantor(loanID, guarantorJSON);
|
||||
verifySavingsOnHoldBalance(selfSavigsId, null);
|
||||
Assert.assertNotNull(selfGuarantee);
|
||||
|
||||
guarantorJSON = new GuarantorTestBuilder().existingCustomerWithGuaranteeAmount(String.valueOf(clientID_external),
|
||||
String.valueOf(externalSavigsId_1), String.valueOf(external1_guarantee)).build();
|
||||
Integer externalGuarantee_1 = this.guarantorHelper.createGuarantor(loanID, guarantorJSON);
|
||||
verifySavingsOnHoldBalance(externalSavigsId_1, null);
|
||||
Assert.assertNotNull(externalGuarantee_1);
|
||||
|
||||
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------");
|
||||
loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID);
|
||||
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
|
||||
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
|
||||
self1_hold_funds += self1_guarantee;
|
||||
external1_hold_funds += external1_guarantee;
|
||||
verifySavingsOnHoldBalance(selfSavigsId, self1_hold_funds);
|
||||
verifySavingsOnHoldBalance(externalSavigsId_1, external1_hold_funds);
|
||||
|
||||
System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------");
|
||||
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID);
|
||||
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
|
||||
|
||||
// First repayment
|
||||
ArrayList<HashMap> loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID);
|
||||
todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.DAY_OF_MONTH, -14);
|
||||
String LOAN_REPAYMENT_DATE = dateFormat.format(todaysDate.getTime());
|
||||
Float totalDueForCurrentPeriod = (Float) loanSchedule.get(1).get("totalDueForPeriod");
|
||||
external1_hold_funds -= new Float(993.104);
|
||||
this.loanTransactionHelper.makeRepayment(LOAN_REPAYMENT_DATE, totalDueForCurrentPeriod, loanID);
|
||||
verifySavingsOnHoldBalance(selfSavigsId, self1_hold_funds);
|
||||
verifySavingsOnHoldBalance(externalSavigsId_1, external1_hold_funds);
|
||||
|
||||
this.loanTransactionHelper.recoverFromGuarantor(loanID);
|
||||
verifySavingsBalanceAndOnHoldBalance(selfSavigsId, new Float(0), self1_balance - self1_hold_funds);
|
||||
verifySavingsBalanceAndOnHoldBalance(externalSavigsId_1, new Float(0), external1_balance - external1_hold_funds);
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Test
|
||||
public void testGuarantor_RECOVER_GUARANTEES_WITH_MORE_GUARANTEE() {
|
||||
|
||||
Float self1_hold_funds = new Float(0);
|
||||
Float external1_hold_funds = new Float(0);
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
|
||||
final Integer clientID_external = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID_external);
|
||||
|
||||
Float selfBalance = new Float(10000);
|
||||
Float externalBalance = new Float(10000);
|
||||
Float selfguarantee = new Float(6000);
|
||||
Float externalguarantee = new Float(7000);
|
||||
|
||||
final Integer selfSavigsId = SavingsAccountHelper.openSavingsAccount(this.requestSpec, this.responseSpec, clientID,
|
||||
String.valueOf(selfBalance));
|
||||
final Integer externalSavigsId_1 = SavingsAccountHelper.openSavingsAccount(this.requestSpec, this.responseSpec, clientID_external,
|
||||
String.valueOf(externalBalance));
|
||||
|
||||
final Integer loanProductID = createLoanProductWithHoldFunds("40", "20", "20");
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.DAY_OF_MONTH, -21);
|
||||
String LOAN_DISBURSEMENT_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final Integer loanID = applyForLoanApplication(clientID, loanProductID, LOAN_DISBURSEMENT_DATE);
|
||||
Assert.assertNotNull(loanID);
|
||||
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
|
||||
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
|
||||
|
||||
String guarantorJSON = new GuarantorTestBuilder().existingCustomerWithGuaranteeAmount(String.valueOf(clientID),
|
||||
String.valueOf(selfSavigsId), String.valueOf(selfguarantee)).build();
|
||||
Integer selfGuarantee = this.guarantorHelper.createGuarantor(loanID, guarantorJSON);
|
||||
verifySavingsOnHoldBalance(selfSavigsId, null);
|
||||
Assert.assertNotNull(selfGuarantee);
|
||||
|
||||
guarantorJSON = new GuarantorTestBuilder().existingCustomerWithGuaranteeAmount(String.valueOf(clientID_external),
|
||||
String.valueOf(externalSavigsId_1), String.valueOf(externalguarantee)).build();
|
||||
Integer externalGuarantee_1 = this.guarantorHelper.createGuarantor(loanID, guarantorJSON);
|
||||
verifySavingsOnHoldBalance(externalSavigsId_1, null);
|
||||
Assert.assertNotNull(externalGuarantee_1);
|
||||
|
||||
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------");
|
||||
loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID);
|
||||
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
|
||||
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
|
||||
self1_hold_funds += selfguarantee;
|
||||
external1_hold_funds += externalguarantee;
|
||||
verifySavingsOnHoldBalance(selfSavigsId, self1_hold_funds);
|
||||
verifySavingsOnHoldBalance(externalSavigsId_1, external1_hold_funds);
|
||||
|
||||
System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------");
|
||||
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID);
|
||||
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
|
||||
|
||||
// First repayment
|
||||
ArrayList<HashMap> loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID);
|
||||
todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.DAY_OF_MONTH, -14);
|
||||
String LOAN_REPAYMENT_DATE = dateFormat.format(todaysDate.getTime());
|
||||
Float totalDueForCurrentPeriod = (Float) loanSchedule.get(1).get("totalDueForPeriod");
|
||||
external1_hold_funds -= new Float(3227.588);
|
||||
this.loanTransactionHelper.makeRepayment(LOAN_REPAYMENT_DATE, totalDueForCurrentPeriod, loanID);
|
||||
verifySavingsOnHoldBalance(selfSavigsId, self1_hold_funds);
|
||||
verifySavingsOnHoldBalance(externalSavigsId_1, external1_hold_funds);
|
||||
|
||||
this.loanTransactionHelper.recoverFromGuarantor(loanID);
|
||||
verifySavingsBalanceAndOnHoldBalance(selfSavigsId, new Float(0), selfBalance - new Float(4615.385));
|
||||
verifySavingsBalanceAndOnHoldBalance(externalSavigsId_1, new Float(0), externalBalance - new Float(2901.8553));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Test
|
||||
public void testGuarantor_WRITE_OFF_LOAN() {
|
||||
|
||||
Float self1_hold_funds = new Float(0);
|
||||
Float external1_hold_funds = new Float(0);
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
|
||||
final Integer clientID_external = ClientHelper.createClient(this.requestSpec, this.responseSpec);
|
||||
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID_external);
|
||||
|
||||
final Integer selfSavigsId = SavingsAccountHelper.openSavingsAccount(this.requestSpec, this.responseSpec, clientID,
|
||||
String.valueOf(self1_balance));
|
||||
final Integer externalSavigsId_1 = SavingsAccountHelper.openSavingsAccount(this.requestSpec, this.responseSpec, clientID_external,
|
||||
String.valueOf(external1_balance));
|
||||
|
||||
final Integer loanProductID = createLoanProductWithHoldFunds("40", "20", "20");
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy", Locale.US);
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.DAY_OF_MONTH, -21);
|
||||
String LOAN_DISBURSEMENT_DATE = dateFormat.format(todaysDate.getTime());
|
||||
final Integer loanID = applyForLoanApplication(clientID, loanProductID, LOAN_DISBURSEMENT_DATE);
|
||||
Assert.assertNotNull(loanID);
|
||||
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
|
||||
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
|
||||
|
||||
String guarantorJSON = new GuarantorTestBuilder().existingCustomerWithGuaranteeAmount(String.valueOf(clientID),
|
||||
String.valueOf(selfSavigsId), String.valueOf(self1_guarantee)).build();
|
||||
Integer selfGuarantee = this.guarantorHelper.createGuarantor(loanID, guarantorJSON);
|
||||
verifySavingsOnHoldBalance(selfSavigsId, null);
|
||||
Assert.assertNotNull(selfGuarantee);
|
||||
|
||||
guarantorJSON = new GuarantorTestBuilder().existingCustomerWithGuaranteeAmount(String.valueOf(clientID_external),
|
||||
String.valueOf(externalSavigsId_1), String.valueOf(external1_guarantee)).build();
|
||||
Integer externalGuarantee_1 = this.guarantorHelper.createGuarantor(loanID, guarantorJSON);
|
||||
Assert.assertNotNull(externalGuarantee_1);
|
||||
verifySavingsOnHoldBalance(externalSavigsId_1, null);
|
||||
|
||||
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------");
|
||||
loanStatusHashMap = this.loanTransactionHelper.approveLoan(LOAN_DISBURSEMENT_DATE, loanID);
|
||||
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
|
||||
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
|
||||
self1_hold_funds += self1_guarantee;
|
||||
external1_hold_funds += external1_guarantee;
|
||||
verifySavingsOnHoldBalance(selfSavigsId, self1_hold_funds);
|
||||
verifySavingsOnHoldBalance(externalSavigsId_1, external1_hold_funds);
|
||||
|
||||
System.out.println("-------------------------------DISBURSE LOAN-------------------------------------------");
|
||||
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID);
|
||||
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
|
||||
|
||||
// First repayment
|
||||
ArrayList<HashMap> loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID);
|
||||
todaysDate = Calendar.getInstance();
|
||||
todaysDate.add(Calendar.DAY_OF_MONTH, -14);
|
||||
String LOAN_REPAYMENT_DATE = dateFormat.format(todaysDate.getTime());
|
||||
Float totalDueForCurrentPeriod = (Float) loanSchedule.get(1).get("totalDueForPeriod");
|
||||
external1_hold_funds -= new Float(993.104);
|
||||
this.loanTransactionHelper.makeRepayment(LOAN_REPAYMENT_DATE, totalDueForCurrentPeriod, loanID);
|
||||
verifySavingsOnHoldBalance(selfSavigsId, self1_hold_funds);
|
||||
verifySavingsOnHoldBalance(externalSavigsId_1, external1_hold_funds);
|
||||
|
||||
todaysDate = Calendar.getInstance();
|
||||
String LOAN_WRITEOFF_DATE = dateFormat.format(todaysDate.getTime());
|
||||
this.loanTransactionHelper.writeOffLoan(LOAN_WRITEOFF_DATE, loanID);
|
||||
verifySavingsBalanceAndOnHoldBalance(selfSavigsId, new Float(0), self1_balance);
|
||||
verifySavingsBalanceAndOnHoldBalance(externalSavigsId_1, new Float(0), external1_balance);
|
||||
|
||||
}
|
||||
|
||||
private void verifySavingsOnHoldBalance(final Integer savingsId, final Float expectedBalance) {
|
||||
Float onHoldAmount = (Float) this.savingsAccountHelper.getSavingsDetails(savingsId, "onHoldFunds");
|
||||
assertEquals("Verifying On Hold Funds", expectedBalance, onHoldAmount);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "cast" })
|
||||
private void verifySavingsBalanceAndOnHoldBalance(final Integer savingsId, final Float expectedBalance, final Float accountBalance) {
|
||||
HashMap savingsDetails = (HashMap) this.savingsAccountHelper.getSavingsDetails(savingsId);
|
||||
assertEquals("Verifying On Hold Funds", expectedBalance, savingsDetails.get("onHoldFunds"));
|
||||
HashMap summary = (HashMap) savingsDetails.get("summary");
|
||||
assertEquals("Verifying Account balance", accountBalance, summary.get("accountBalance"));
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private boolean checkForErrorCode(final ArrayList<HashMap> errorData, final String errorcode) {
|
||||
boolean isExists = false;
|
||||
for (HashMap errorMap : errorData) {
|
||||
String actualErrorCode = (String) errorMap.get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE);
|
||||
if (actualErrorCode != null && actualErrorCode.equals(errorcode)) {
|
||||
isExists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return isExists;
|
||||
|
||||
}
|
||||
|
||||
private Integer createLoanProductWithHoldFunds(final String mandatoryGuarantee, final String minimumGuaranteeFromGuarantor,
|
||||
final String minimumGuaranteeFromOwnFunds) {
|
||||
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
|
||||
LoanProductTestBuilder builder = new LoanProductTestBuilder().withPrincipal("10000.00").withNumberOfRepayments("4")
|
||||
.withRepaymentAfterEvery("1").withRepaymentTypeAsWeek().withinterestRatePerPeriod("2")
|
||||
.withInterestRateFrequencyTypeAsMonths().withAmortizationTypeAsEqualPrincipalPayment().withInterestTypeAsDecliningBalance()
|
||||
.withOnHoldFundDetails(mandatoryGuarantee, minimumGuaranteeFromGuarantor, minimumGuaranteeFromOwnFunds);
|
||||
|
||||
final String loanProductJSON = builder.build(null);
|
||||
return this.loanTransactionHelper.getLoanProductId(loanProductJSON);
|
||||
}
|
||||
|
||||
private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID, final String disbursementDate) {
|
||||
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
|
||||
final String loanApplicationJSON = new LoanApplicationTestBuilder() //
|
||||
.withPrincipal("10000.00") //
|
||||
.withLoanTermFrequency("4") //
|
||||
.withLoanTermFrequencyAsWeeks() //
|
||||
.withNumberOfRepayments("4") //
|
||||
.withRepaymentEveryAfter("1") //
|
||||
.withRepaymentFrequencyTypeAsWeeks() //
|
||||
.withInterestRatePerPeriod("2") //
|
||||
.withAmortizationTypeAsEqualInstallments() //
|
||||
.withInterestTypeAsDecliningBalance() //
|
||||
.withInterestCalculationPeriodTypeSameAsRepaymentPeriod() //
|
||||
.withExpectedDisbursementDate(disbursementDate) //
|
||||
.withSubmittedOnDate(disbursementDate) //
|
||||
.build(clientID.toString(), loanProductID.toString(), null);
|
||||
return this.loanTransactionHelper.getLoanId(loanApplicationJSON);
|
||||
}
|
||||
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* 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.loanaccount.guarantor;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class GuarantorTestBuilder {
|
||||
|
||||
private static final String GUARANTOR_TYPE_CUSTOMER = "1";
|
||||
@SuppressWarnings("unused")
|
||||
private static final String GUARANTOR_TYPE_STAFF = "2";
|
||||
private static final String GUARANTOR_TYPE_EXTERNAL = "3";
|
||||
|
||||
private String guarantorTypeId = "1";
|
||||
private String entityId = null;
|
||||
private String addressLine1 = "addressLine1";
|
||||
private String addressLine2 = "addressLine2";
|
||||
private String city = "city";
|
||||
private String state = "state";
|
||||
private String zip = "123456";
|
||||
private String guaranteeAmount = "500";
|
||||
private String savingsId = null;
|
||||
|
||||
public String build() {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("guarantorTypeId", guarantorTypeId);
|
||||
map.put("locale", "en");
|
||||
if (GUARANTOR_TYPE_EXTERNAL.equals(guarantorTypeId)) {
|
||||
map.put("firstname", Utils.randomNameGenerator("guarantor_FirstName_", 5));
|
||||
map.put("lastname", Utils.randomNameGenerator("guarantor_LastName_", 4));
|
||||
map.put("addressLine1", addressLine1);
|
||||
map.put("addressLine2", addressLine2);
|
||||
map.put("city", city);
|
||||
map.put("state", state);
|
||||
map.put("zip", zip);
|
||||
|
||||
} else if (GUARANTOR_TYPE_CUSTOMER.equals(guarantorTypeId)) {
|
||||
map.put("entityId", entityId);
|
||||
map.put("amount", guaranteeAmount);
|
||||
map.put("savingsId", savingsId);
|
||||
}
|
||||
System.out.println("map : " + map);
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
public GuarantorTestBuilder existingCustomerWithGuaranteeAmount(final String entityId, final String savingsId,
|
||||
final String guaranteeAmount) {
|
||||
this.entityId = entityId;
|
||||
this.savingsId = savingsId;
|
||||
this.guaranteeAmount = guaranteeAmount;
|
||||
this.guarantorTypeId = GUARANTOR_TYPE_CUSTOMER;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GuarantorTestBuilder existingCustomerWithoutGuaranteeAmount(final String entityId) {
|
||||
this.entityId = entityId;
|
||||
this.savingsId = null;
|
||||
this.guaranteeAmount = null;
|
||||
this.guarantorTypeId = GUARANTOR_TYPE_CUSTOMER;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GuarantorTestBuilder externalCustomer() {
|
||||
this.guarantorTypeId = GUARANTOR_TYPE_EXTERNAL;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* 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.useradministration.roles;
|
||||
|
||||
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 RolesHelper {
|
||||
|
||||
private static final String CREATE_ROLE_URL = "/mifosng-provider/api/v1/roles?" + Utils.TENANT_IDENTIFIER;
|
||||
private static final String ROLE_URL = "/mifosng-provider/api/v1/roles";
|
||||
private static final String DISABLE_ROLE_COMMAND = "disable";
|
||||
private static final String ENABLE_ROLE_COMMAND = "enable";
|
||||
|
||||
public static Integer createRole(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
return Utils.performServerPost(requestSpec, responseSpec, CREATE_ROLE_URL, getTestCreaRoleAsJSON(), "resourceId");
|
||||
}
|
||||
|
||||
public static String getTestCreaRoleAsJSON() {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("name", Utils.randomNameGenerator("Role_Name_", 5));
|
||||
map.put("description", Utils.randomNameGenerator("Role_Description_", 10));
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
public static HashMap<String, Object> getRoleDetails(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer roleId) {
|
||||
final String GET_ROLE_URL = "/mifosng-provider/api/v1/roles/" + roleId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
HashMap<String, Object> role = Utils.performServerGet(requestSpec, responseSpec, GET_ROLE_URL, "");
|
||||
return role;
|
||||
}
|
||||
|
||||
public static Integer disableRole(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer roleId) {
|
||||
return Utils.performServerPost(requestSpec, responseSpec, createRoleOperationURL(DISABLE_ROLE_COMMAND, roleId), "", "resourceId");
|
||||
}
|
||||
|
||||
public static Integer enableRole(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer roleId) {
|
||||
return Utils.performServerPost(requestSpec, responseSpec, createRoleOperationURL(ENABLE_ROLE_COMMAND, roleId), "", "resourceId");
|
||||
}
|
||||
|
||||
public static Integer deleteRole(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer roleId) {
|
||||
return Utils.performServerDelete(requestSpec, responseSpec, createRoleOperationURL(ENABLE_ROLE_COMMAND, roleId), "resourceId");
|
||||
}
|
||||
|
||||
private static String createRoleOperationURL(final String command, final Integer roleId) {
|
||||
return ROLE_URL + "/" + roleId + "?command=" + command + "&" + Utils.TENANT_IDENTIFIER;
|
||||
}
|
||||
|
||||
}
|
||||
+39
@@ -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.integrationtests.useradministration.users;
|
||||
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
|
||||
|
||||
public class UserHelper {
|
||||
private static final String CREATE_USER_URL = "/mifosng-provider/api/v1/users?" + Utils.TENANT_IDENTIFIER;
|
||||
private static final String USER_URL = "/mifosng-provider/api/v1/users";
|
||||
|
||||
public static Integer createUser(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, int roleId, int staffId) {
|
||||
return Utils.performServerPost(requestSpec, responseSpec, CREATE_USER_URL, getTestCreateUserAsJSON(roleId, staffId), "resourceId");
|
||||
}
|
||||
|
||||
public static String getTestCreateUserAsJSON(int roleId, int staffId) {
|
||||
String json = "{ \"username\": \"" + Utils.randomNameGenerator("User_Name_", 3)
|
||||
+ "\", \"firstname\": \"Test\", \"lastname\": \"User\", \"email\": \"whatever@mifos.org\","
|
||||
+ " \"officeId\": \"1\", \"staffId\": " + "\""
|
||||
+ Integer.toString(staffId)+"\",\"roles\": [\""
|
||||
+ Integer.toString(roleId) + "\"], \"sendPasswordToEmail\": false}";
|
||||
System.out.println(json);
|
||||
return json;
|
||||
|
||||
}
|
||||
|
||||
public static Integer deleteUser(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer userId) {
|
||||
return Utils.performServerDelete(requestSpec, responseSpec, createRoleOperationURL(userId), "resourceId");
|
||||
}
|
||||
|
||||
private static String createRoleOperationURL(final Integer userId) {
|
||||
return USER_URL + "/" + userId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
Welcome to the Mifos community!
|
||||
===============================
|
||||
|
||||
Depending on the OS you're running, you should have "runmifosx.sh" (for Linux and Mac) and
|
||||
"runmifosx.bat" (for Windows) in this directory. These are small scripts that allow you to
|
||||
run MifosX on your computer locally. To be able to run MifosX, just double-click on the script,
|
||||
that is, "runmifosx.sh" if you are on Linux or Mac, or "runmifosx.bat" if you are on Windows.
|
||||
|
||||
If you have a web front-end that you want to use along with the backend server, put your index.html
|
||||
along with all the other source files inside a (sub-folder of) the "apps" folder in the current
|
||||
directory from where runmifosx.bat/.sh is launched. The web UI front-end is then accessible
|
||||
under mifosng-provider/apps - for example:
|
||||
|
||||
https://localhost:8443/mifosng-provider/apps/community-app/index.html?baseApiUrl=https://localhost:8443&tenantIdentifier=default#/home
|
||||
|
||||
We hope you'll have an amazing experience working with MifosX!
|
||||
|
||||
|
||||
PS, internal note to Mifos developers preparing packages, only: For this to work, the WAR of
|
||||
the Mifos X distribution ZIP package will (currently) have to be built using
|
||||
the Gradle 'dev' environment profile - e.g. using this command:
|
||||
|
||||
./gradlew -Penv=dev clean war dist
|
||||
|
||||
We now also have a script which convenently prepares both the
|
||||
UI front-end and the API back-end together into a ZIP:
|
||||
|
||||
git clone --recursive https://github.com/openMF/mifosx/
|
||||
git submodule update --init --recursive; git submodule status
|
||||
./build.sh
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
java -version >nul 2>&1 && (
|
||||
echo "Found Java."
|
||||
) || (
|
||||
echo "Java should be installed to run MifosX."
|
||||
exit
|
||||
)
|
||||
|
||||
echo "Starting MifosX ..... "
|
||||
|
||||
java -Djava.awt.headless=false -jar mifosng-provider.war
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
# First of all, check if Java is installed on this computer
|
||||
|
||||
if hash java; then
|
||||
echo "Found Java:"
|
||||
echo $(java -version)
|
||||
else
|
||||
echo "Java should be installed to run MifosX."
|
||||
exit
|
||||
fi
|
||||
|
||||
echo "Starting MifosX ..... "
|
||||
|
||||
java -Djava.awt.headless=false -jar mifosng-provider.war
|
||||
@@ -5,13 +5,20 @@
|
||||
*/
|
||||
package org.mifosplatform;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
||||
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.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
/**
|
||||
* Mifos main() application which launches Mifos X in an embedded Tomcat HTTP
|
||||
@@ -27,13 +34,59 @@ import org.springframework.context.annotation.Import;
|
||||
* @see ServerApplication for the same without the embedded MariaDB4j database
|
||||
*/
|
||||
public class ServerWithMariaDB4jApplication {
|
||||
private final static Logger logger = LoggerFactory.getLogger(ServerWithMariaDB4jApplication.class);
|
||||
|
||||
@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);
|
||||
if (!Desktop.isDesktopSupported()) {
|
||||
logger.info("Not going to open UI homepage in local web browser, because !Desktop.isDesktopSupported()");
|
||||
|
||||
} else {
|
||||
// apps/community-app/dist/community-app/index.html
|
||||
Resource distResource = ctx.getResource("file:" + System.getProperty("user.dir") +
|
||||
System.getProperty("file.separator") + "apps" +
|
||||
System.getProperty("file.separator") + "community-app" +
|
||||
System.getProperty("file.separator") + "dist" +
|
||||
System.getProperty("file.separator") + "community-app" +
|
||||
System.getProperty("file.separator") + "index.html");
|
||||
URI distURI = URI.create("https://localhost:8443/mifosng-provider" +
|
||||
"/apps/community-app/index.html?baseApiUrl=https://localhost:8443" +
|
||||
"&tenantIdentifier=default#/");
|
||||
|
||||
// apps/community-app/app/index.html
|
||||
Resource devResource = ctx.getResource("file:" + System.getProperty("user.dir") +
|
||||
System.getProperty("file.separator") + "apps" +
|
||||
System.getProperty("file.separator") + "community-app" +
|
||||
System.getProperty("file.separator") + "app" +
|
||||
System.getProperty("file.separator") + "index.html");
|
||||
URI devURI = URI.create("https://localhost:8443/mifosng-provider" +
|
||||
"/apps/community-app/app/index.html?baseApiUrl=https://localhost:8443" +
|
||||
"&tenantIdentifier=default#/");
|
||||
|
||||
if (distResource.exists()) {
|
||||
openWebBrowser(distURI);
|
||||
} else if (devResource.exists()) {
|
||||
openWebBrowser(devURI);
|
||||
} else {
|
||||
logger.error("Cannot open Mifos X UI in browser; not found: " + distResource.toString());
|
||||
}
|
||||
}
|
||||
|
||||
// TODO Tray Icon stuff; dig out my very own old @see https://github.com/mifos/head/tree/hudsonBuild-MIFOS-5157_Launch4j-EXE_NewDist-squash1/server-jetty/src/main/java/org/mifos/server/tray
|
||||
|
||||
ApplicationExitUtil.waitForKeyPressToCleanlyExit(ctx);
|
||||
}
|
||||
|
||||
private static void openWebBrowser(URI uri) {
|
||||
try {
|
||||
logger.info("Opening Mifos X UI in browser: " + uri.toString());
|
||||
Desktop.getDesktop().browse(uri);
|
||||
} catch (IOException e) {
|
||||
logger.error("IOException when opening Mifos X UI in browser: " + uri.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
@@ -6,6 +6,7 @@
|
||||
package org.mifosplatform.accounting.accrual.handler;
|
||||
|
||||
import org.mifosplatform.accounting.accrual.service.AccrualAccountingWritePlatformService;
|
||||
import org.mifosplatform.commands.annotation.CommandType;
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
@@ -14,6 +15,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@CommandType(entity = "PERIODICACCRUALACCOUNTING", action = "EXECUTE")
|
||||
public class ExecutePeriodicAccrualCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
private final AccrualAccountingWritePlatformService writePlatformService;
|
||||
|
||||
+2
-1
@@ -22,6 +22,7 @@ import org.mifosplatform.infrastructure.core.exception.InvalidJsonException;
|
||||
import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException;
|
||||
import org.mifosplatform.infrastructure.core.serialization.FromApiJsonDeserializer;
|
||||
import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
|
||||
import org.mifosplatform.infrastructure.core.service.DateUtils;
|
||||
import org.mifosplatform.portfolio.loanaccount.guarantor.command.GuarantorCommand;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -54,7 +55,7 @@ public final class AccrualAccountingDataValidator {
|
||||
.resource(PERIODIC_ACCRUAL_ACCOUNTING_RESOURCE_NAME);
|
||||
|
||||
final LocalDate date = this.fromApiJsonHelper.extractLocalDateNamed(accrueTillParamName, element);
|
||||
baseDataValidator.reset().parameter(accrueTillParamName).value(date).notNull().validateDateBefore(LocalDate.now());
|
||||
baseDataValidator.reset().parameter(accrueTillParamName).value(date).notNull().validateDateBefore(DateUtils.getLocalDateOfTenant());
|
||||
|
||||
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
||||
|
||||
|
||||
+5
-5
@@ -19,20 +19,20 @@ import org.mifosplatform.infrastructure.core.data.ApiParameterError;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder;
|
||||
import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException;
|
||||
import org.mifosplatform.portfolio.loanaccount.service.LoanAccrualWritePlatformService;
|
||||
import org.mifosplatform.portfolio.loanaccount.service.LoanAccrualPlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AccrualAccountingWritePlatformServiceImpl implements AccrualAccountingWritePlatformService {
|
||||
|
||||
private final LoanAccrualWritePlatformService loanAccrualWritePlatformService;
|
||||
private final LoanAccrualPlatformService loanAccrualPlatformService;
|
||||
private final AccrualAccountingDataValidator accountingDataValidator;
|
||||
|
||||
@Autowired
|
||||
public AccrualAccountingWritePlatformServiceImpl(final LoanAccrualWritePlatformService loanAccrualWritePlatformService,
|
||||
public AccrualAccountingWritePlatformServiceImpl(final LoanAccrualPlatformService loanAccrualPlatformService,
|
||||
final AccrualAccountingDataValidator accountingDataValidator) {
|
||||
this.loanAccrualWritePlatformService = loanAccrualWritePlatformService;
|
||||
this.loanAccrualPlatformService = loanAccrualPlatformService;
|
||||
this.accountingDataValidator = accountingDataValidator;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class AccrualAccountingWritePlatformServiceImpl implements AccrualAccount
|
||||
public CommandProcessingResult executeLoansPeriodicAccrual(JsonCommand command) {
|
||||
this.accountingDataValidator.validateLoanPeriodicAccrualData(command.json());
|
||||
LocalDate tilldate = command.localDateValueOfParameterNamed(accrueTillParamName);
|
||||
String errorlog = this.loanAccrualWritePlatformService.addPeriodicAccruals(tilldate);
|
||||
String errorlog = this.loanAccrualPlatformService.addPeriodicAccruals(tilldate);
|
||||
if (errorlog.length() > 0) {
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
|
||||
|
||||
+2
@@ -6,6 +6,7 @@
|
||||
package org.mifosplatform.accounting.closure.handler;
|
||||
|
||||
import org.mifosplatform.accounting.closure.service.GLClosureWritePlatformService;
|
||||
import org.mifosplatform.commands.annotation.CommandType;
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
@@ -14,6 +15,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@CommandType(entity = "GLCLOSURE", action = "CREATE")
|
||||
public class CreateGLClosureCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
private final GLClosureWritePlatformService writePlatformService;
|
||||
|
||||
+2
@@ -6,6 +6,7 @@
|
||||
package org.mifosplatform.accounting.closure.handler;
|
||||
|
||||
import org.mifosplatform.accounting.closure.service.GLClosureWritePlatformService;
|
||||
import org.mifosplatform.commands.annotation.CommandType;
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
@@ -14,6 +15,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@CommandType(entity = "GLCLOSURE", action = "DELETE")
|
||||
public class DeleteGLClosureCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
private final GLClosureWritePlatformService closureWritePlatformService;
|
||||
|
||||
+2
@@ -6,6 +6,7 @@
|
||||
package org.mifosplatform.accounting.closure.handler;
|
||||
|
||||
import org.mifosplatform.accounting.closure.service.GLClosureWritePlatformService;
|
||||
import org.mifosplatform.commands.annotation.CommandType;
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
@@ -14,6 +15,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@CommandType(entity = "GLCLOSURE", action = "UPDATE")
|
||||
public class UpdateGLClosureCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
private final GLClosureWritePlatformService writePlatformService;
|
||||
|
||||
+3
-1
@@ -221,7 +221,9 @@ public class AccountingConstants {
|
||||
}
|
||||
|
||||
public static enum FINANCIAL_ACTIVITY {
|
||||
ASSET_TRANSFER(100, "assetTransfer", GLAccountType.ASSET), LIABILITY_TRANSFER(200, "liabilityTransfer", GLAccountType.LIABILITY);
|
||||
ASSET_TRANSFER(100, "assetTransfer", GLAccountType.ASSET), LIABILITY_TRANSFER(200, "liabilityTransfer", GLAccountType.LIABILITY),
|
||||
CASH_AT_MAINVAULT (101, "cashAtMainVault", GLAccountType.ASSET),
|
||||
CASH_AT_TELLER (102, "cashAtTeller", GLAccountType.ASSET),OPENING_BALANCES_TRANSFER_CONTRA (300,"openingBalancesTransferContra",GLAccountType.EQUITY);;
|
||||
|
||||
private final Integer value;
|
||||
private final String code;
|
||||
|
||||
+8
@@ -86,6 +86,14 @@ public class AccountingDropdownReadPlatformServiceImpl implements AccountingDrop
|
||||
liabilityAccountOptions = null;
|
||||
}
|
||||
accountOptions.put("liabilityAccountOptions", liabilityAccountOptions);
|
||||
|
||||
List<GLAccountData> equityAccountOptions = this.accountReadPlatformService
|
||||
.retrieveAllEnabledDetailGLAccounts(GLAccountType.EQUITY);
|
||||
if (equityAccountOptions.isEmpty()) {
|
||||
equityAccountOptions = null;
|
||||
}
|
||||
accountOptions.put("equityAccountOptions",equityAccountOptions);
|
||||
|
||||
return accountOptions;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||
@Table(name = "acc_gl_financial_activity_account")
|
||||
public class FinancialActivityAccount extends AbstractPersistable<Long> {
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "gl_account_id")
|
||||
private GLAccount glAccount;
|
||||
|
||||
|
||||
+2
@@ -6,6 +6,7 @@
|
||||
package org.mifosplatform.accounting.financialactivityaccount.handler;
|
||||
|
||||
import org.mifosplatform.accounting.financialactivityaccount.service.FinancialActivityAccountWritePlatformService;
|
||||
import org.mifosplatform.commands.annotation.CommandType;
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
@@ -14,6 +15,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@CommandType(entity = "FINANCIALACTIVITYACCOUNT", action = "CREATE")
|
||||
public class CreateFinancialActivityAccountHandler implements NewCommandSourceHandler {
|
||||
|
||||
private final FinancialActivityAccountWritePlatformService writePlatformService;
|
||||
|
||||
+2
@@ -6,6 +6,7 @@
|
||||
package org.mifosplatform.accounting.financialactivityaccount.handler;
|
||||
|
||||
import org.mifosplatform.accounting.financialactivityaccount.service.FinancialActivityAccountWritePlatformService;
|
||||
import org.mifosplatform.commands.annotation.CommandType;
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
@@ -14,6 +15,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@CommandType(entity = "FINANCIALACTIVITYACCOUNT", action = "DELETE")
|
||||
public class DeleteFinancialActivityAccountCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
private final FinancialActivityAccountWritePlatformService writePlatformService;
|
||||
|
||||
+2
@@ -6,6 +6,7 @@
|
||||
package org.mifosplatform.accounting.financialactivityaccount.handler;
|
||||
|
||||
import org.mifosplatform.accounting.financialactivityaccount.service.FinancialActivityAccountWritePlatformService;
|
||||
import org.mifosplatform.commands.annotation.CommandType;
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
@@ -14,6 +15,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@CommandType(entity = "FINANCIALACTIVITYACCOUNT", action = "UPDATE")
|
||||
public class UpdateFinancialActivityAccountCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
private final FinancialActivityAccountWritePlatformService writePlatformService;
|
||||
|
||||
+3
-2
@@ -53,7 +53,8 @@ public final class FinancialActivityAccountDataValidator {
|
||||
|
||||
final Integer financialActivityId = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(paramNameForFinancialActivity, element);
|
||||
baseDataValidator.reset().parameter(paramNameForFinancialActivity).value(financialActivityId).notNull()
|
||||
.isOneOfTheseValues(FINANCIAL_ACTIVITY.ASSET_TRANSFER.getValue(), FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue());
|
||||
.isOneOfTheseValues(FINANCIAL_ACTIVITY.ASSET_TRANSFER.getValue(), FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue(),
|
||||
FINANCIAL_ACTIVITY.CASH_AT_MAINVAULT.getValue(), FINANCIAL_ACTIVITY.CASH_AT_TELLER.getValue(),FINANCIAL_ACTIVITY.OPENING_BALANCES_TRANSFER_CONTRA.getValue());
|
||||
|
||||
final Long glAccountId = this.fromApiJsonHelper.extractLongNamed(paramNameForGLAccount, element);
|
||||
baseDataValidator.reset().parameter(paramNameForGLAccount).value(glAccountId).notNull().integerGreaterThanZero();
|
||||
@@ -78,7 +79,7 @@ public final class FinancialActivityAccountDataValidator {
|
||||
final Integer financialActivityId = this.fromApiJsonHelper
|
||||
.extractIntegerSansLocaleNamed(paramNameForFinancialActivity, element);
|
||||
baseDataValidator.reset().parameter(paramNameForFinancialActivity).value(financialActivityId).ignoreIfNull()
|
||||
.isOneOfTheseValues(FINANCIAL_ACTIVITY.ASSET_TRANSFER.getValue(), FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue());
|
||||
.isOneOfTheseValues(FINANCIAL_ACTIVITY.ASSET_TRANSFER.getValue(), FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue(),FINANCIAL_ACTIVITY.OPENING_BALANCES_TRANSFER_CONTRA.getValue());
|
||||
}
|
||||
|
||||
if (this.fromApiJsonHelper.parameterExists(paramNameForGLAccount, element)) {
|
||||
|
||||
+9
@@ -173,4 +173,13 @@ public class GLAccountData {
|
||||
return this.glCode;
|
||||
}
|
||||
|
||||
public EnumOptionData getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public Integer getTypeId() {
|
||||
if (this.type != null) { return this.type.getId().intValue(); }
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user