Skip to content

Commit 46b979c

Browse files
committed
Unit Testing of GaClientLib.
1 parent 1f00aa4 commit 46b979c

File tree

2 files changed

+74
-3
lines changed

2 files changed

+74
-3
lines changed

pos-client-library/src/main/java/com/globalaccelerex/globalaccelerexandroidposclientlibrary/transactions/MobileMoneyTransactions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class MobileMoneyTransactions(countryCode: Countries) {
1313
private val transactionRequest = TransactionRequest()
1414

1515
init {
16-
require(countryCode == Countries.KENYA) {
16+
require(countryCode == Countries.GHANA) {
1717
throw UnsupportedFeatureException("This feature is not available in your specified country.")
1818
}
1919
}
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,87 @@
11
package com.globalaccelerex.globalaccelerexandroidposclientlibrary
22

3+
import com.globalaccelerex.globalaccelerexandroidposclientlibrary.exceptions.UnsupportedFeatureException
34
import com.globalaccelerex.globalaccelerexandroidposclientlibrary.util.Countries
45
import junit.framework.Assert.assertNotNull
6+
import org.junit.Rule
57
import org.junit.Test
8+
import org.junit.rules.ExpectedException
69

710
class GAClientLibTest{
811

12+
lateinit var clientLib: GAClientLib
13+
14+
@get: Rule
15+
val expectedException: ExpectedException = ExpectedException.none()
16+
917
@Test
1018
fun checkCardTransaction_isInitialized_onlyWhenCalled(){
1119

12-
val clientLib = GAClientLib.Builder().setCountryCode(Countries.NIGERIA).build()
20+
clientLib = GAClientLib.Builder().setCountryCode(Countries.NIGERIA).build()
1321

1422
assertNotNull(clientLib.cardTransactions)
1523
}
16-
}
24+
25+
@Test
26+
fun checkMobileMoneyTransaction_isOnlyAvailable_withGhanaConfig() {
27+
28+
//Should work fine with Ghana config
29+
clientLib = GAClientLib.Builder().setCountryCode(Countries.GHANA).build()
30+
assertNotNull(clientLib.mobileMoneyTransaction)
31+
println("Mobile money Works with Ghana config")
32+
33+
//Should throw exception with kenya configuration
34+
clientLib = GAClientLib.Builder().setCountryCode(Countries.KENYA).build()
35+
expectedException.expect(UnsupportedFeatureException::class.java)
36+
println("Mobile money Threw correct exception for Kenya config")
37+
clientLib.mobileMoneyTransaction
38+
}
39+
40+
@Test(expected = UnsupportedFeatureException::class)
41+
fun checkMobileMoneyTransaction_throwsException_withNigeriaConfig() {
42+
43+
//Should throw exception with Nigeria configuration
44+
clientLib = GAClientLib.Builder().setCountryCode(Countries.NIGERIA).build()
45+
println("Mobile Money Threw correct exception for Nigeria config")
46+
clientLib.mobileMoneyTransaction
47+
48+
}
49+
50+
@Test
51+
fun checkCardNotPresentTransaction_isNotAvailable_inNigeria() {
52+
53+
clientLib = GAClientLib.Builder().setCountryCode(Countries.NIGERIA).build()
54+
expectedException.expect(UnsupportedFeatureException::class.java)
55+
println("Throw correct exception for CNP attempt with Nigeria config.")
56+
clientLib.cardNotPresentTransactions
57+
58+
}
59+
60+
61+
}
62+
63+
64+
65+
66+
67+
68+
69+
70+
71+
72+
73+
74+
75+
76+
77+
78+
79+
80+
81+
82+
83+
84+
85+
86+
87+

0 commit comments

Comments
 (0)