@@ -19,17 +19,16 @@ import com.cm.androidposintegration.enums.TransactionType
1919import com.cm.androidposintegration.intent.IntentHelper.EXTRA_ERROR_CODE
2020import com.cm.androidposintegration.intent.IntentHelper.EXTRA_INFORMATION_VALUE_TRANSACTION
2121import com.cm.androidposintegration.intent.IntentHelper.EXTRA_INTERNAL_INTENT_TYPE
22+ import com.cm.androidposintegration.intent.IntentHelper.EXTRA_MAX_OFFLINE_SALE_AMOUNT
23+ import com.cm.androidposintegration.intent.IntentHelper.EXTRA_MAX_OFFLINE_SALE_AMOUNT_PER_TRANSACTION
24+ import com.cm.androidposintegration.intent.IntentHelper.EXTRA_MAX_OFFLINE_TRANSACTIONS_COUNT
2225import com.cm.androidposintegration.intent.IntentHelper.EXTRA_MERCHANT_RECEIPT
2326import com.cm.androidposintegration.intent.IntentHelper.EXTRA_ORD_REF
2427import com.cm.androidposintegration.intent.IntentHelper.EXTRA_SDK_VERSION
2528import com.cm.androidposintegration.intent.IntentHelper.EXTRA_TRANSACTION_RESULT
2629import com.cm.androidposintegration.service.PosIntegrationServiceImpl
27- import com.cm.androidposintegration.service.callback.beans.LastReceiptResultData
28- import com.cm.androidposintegration.service.callback.ReceiptCallback
29- import com.cm.androidposintegration.service.callback.StatusesCallback
3030import com.cm.androidposintegration.service.callback.TransactionCallback
3131import com.cm.androidposintegration.service.callback.beans.ErrorCode
32- import com.cm.androidposintegration.service.callback.beans.TransactionStatusesData
3332import com.cm.androidposintegration.service.callback.beans.TransactionResultData
3433import org.hamcrest.CoreMatchers.allOf
3534import org.junit.After
@@ -49,6 +48,9 @@ class PosIntegrationServiceImplTests {
4948
5049 private lateinit var targetContext: Context
5150 private lateinit var receipt: Array <String >
51+ private val maxStoredTransactionsCount = 50
52+ private val maxStoredTransactionSaleAmount = BigDecimal (25000.0 )
53+ private val maxStoredTransactionSaleAmountPerTransaction = BigDecimal (250.0 )
5254
5355 inner class TestBroadcastReceiver : BroadcastReceiver () {
5456 override fun onReceive (p0 : Context ? , p1 : Intent ? ) {
@@ -93,7 +95,11 @@ class PosIntegrationServiceImplTests {
9395 BigDecimal (0.50 ),
9496 Currency .getInstance(" EUR" ),
9597 " 0123-12345"
96- )
98+ ).apply {
99+ maxOfflineTransactionsCount = maxStoredTransactionsCount
100+ maxOfflineSaleAmount = maxStoredTransactionSaleAmount
101+ maxOfflineSaleAmountPerTransaction = maxStoredTransactionSaleAmountPerTransaction
102+ }
97103
98104 service.doTransaction(data, callback)
99105
@@ -103,7 +109,13 @@ class PosIntegrationServiceImplTests {
103109 allOf(
104110 hasComponent(IntegrationActivity ::class .java.name),
105111 hasExtra(EXTRA_INTERNAL_INTENT_TYPE , EXTRA_INFORMATION_VALUE_TRANSACTION ),
106- hasExtra(EXTRA_SDK_VERSION , BuildConfig .VERSION_NAME )
112+ hasExtra(EXTRA_SDK_VERSION , BuildConfig .VERSION_NAME ),
113+ hasExtra(EXTRA_MAX_OFFLINE_TRANSACTIONS_COUNT , maxStoredTransactionsCount),
114+ hasExtra(EXTRA_MAX_OFFLINE_SALE_AMOUNT , maxStoredTransactionSaleAmount),
115+ hasExtra(
116+ EXTRA_MAX_OFFLINE_SALE_AMOUNT_PER_TRANSACTION ,
117+ maxStoredTransactionSaleAmountPerTransaction
118+ )
107119 )
108120 )
109121
@@ -112,91 +124,15 @@ class PosIntegrationServiceImplTests {
112124 resultIntent.putExtra(EXTRA_TRANSACTION_RESULT , " success" )
113125 resultIntent.putExtra(EXTRA_ERROR_CODE , 0 )
114126 resultIntent.putExtra(EXTRA_MERCHANT_RECEIPT , receipt)
115- val activityResult = Instrumentation .ActivityResult (Activity .RESULT_OK , resultIntent)
116-
117- intending(hasAction(BuildConfig .ACTION_TRANSACTION )).respondWith(activityResult)
118-
119- }
120-
121- /* @Test
122- fun transactionStatusesTest() {
123- val service = PosIntegrationServiceImpl(targetContext)
124- val callback = object : StatusesCallback {
125- override fun onResult(data: TransactionStatusesData) {
126- // Default implementation
127- }
128-
129- override fun onError(error: ErrorCode) {
130- // Default implementation
131- }
132-
133- override fun onCrash() {
134- // Default implementation
135- }
136-
137- }
138-
139- val requestStatusData = RequestStatusData("876432")
140-
141-
142- service.transactionStatuses(requestStatusData, callback)
143-
144- // Check that doTransaction calls the ecr app
145- intended(
146- allOf(
147- hasComponent(IntegrationActivity::class.java.name),
148- hasExtra(EXTRA_INTERNAL_INTENT_TYPE, EXTRA_INFORMATION_VALUE_STATUSES)
149- )
127+ resultIntent.putExtra(EXTRA_MAX_OFFLINE_TRANSACTIONS_COUNT , maxStoredTransactionsCount)
128+ resultIntent.putExtra(EXTRA_MAX_OFFLINE_SALE_AMOUNT , maxStoredTransactionSaleAmount)
129+ resultIntent.putExtra(
130+ EXTRA_MAX_OFFLINE_SALE_AMOUNT_PER_TRANSACTION ,
131+ maxStoredTransactionSaleAmountPerTransaction
150132 )
151-
152- val resultIntent = Intent()
153- resultIntent.putExtra(EXTRA_ORD_REF, "0123-12345")
154- resultIntent.putExtra(EXTRA_TRANSACTION_RESULT, "success")
155- resultIntent.putExtra(EXTRA_ERROR_CODE, 0)
156- resultIntent.putExtra(EXTRA_MERCHANT_RECEIPT, receipt)
157- val activityResult = Instrumentation.ActivityResult(Activity.RESULT_OK, resultIntent)
158-
159- intending(hasAction(BuildConfig.ACTION_STATUSES)).respondWith(activityResult)
160-
161- }*/
162-
163- /* @Test
164- fun getLastReceiptTest() {
165- val service = PosIntegrationServiceImpl(targetContext)
166- val callback = object : ReceiptCallback {
167- override fun onResult(data: LastReceiptResultData) {
168- assert(data.receiptData != null)
169- }
170-
171- override fun onError(error: ErrorCode) {
172- // Should not be called
173- }
174-
175- override fun onCrash() {
176- // Should not be called
177- }
178-
179- }
180-
181- val options = LastReceiptOptions(true)
182- service.getLastReceipt(options, callback)
183-
184- // Check that doTransaction calls the ecr app
185- intended(
186- allOf(
187- hasComponent(IntegrationActivity::class.java.name),
188- hasExtra(EXTRA_INTERNAL_INTENT_TYPE, EXTRA_INFORMATION_VALUE_RECEIPT)
189- )
190- )
191-
192- val resultIntent = Intent()
193- resultIntent.putExtra(EXTRA_ORD_REF, "0123-12345")
194- resultIntent.putExtra(EXTRA_TRANSACTION_RESULT, "success")
195- resultIntent.putExtra(EXTRA_ERROR_CODE, 0)
196- resultIntent.putExtra(EXTRA_MERCHANT_RECEIPT, receipt)
197133 val activityResult = Instrumentation .ActivityResult (Activity .RESULT_OK , resultIntent)
198134
199135 intending(hasAction(BuildConfig .ACTION_TRANSACTION )).respondWith(activityResult)
200136
201- }*/
137+ }
202138}
0 commit comments