Skip to content
This repository has been archived by the owner on Nov 11, 2023. It is now read-only.

Commit

Permalink
Version 3.0.0 #41 from PatilShreyas/version-3.0.0-dev
Browse files Browse the repository at this point in the history
Version 3.0.0 dev
  • Loading branch information
PatilShreyas authored Sep 4, 2020
2 parents dec2f53 + 0323f34 commit ac69904
Show file tree
Hide file tree
Showing 124 changed files with 1,836 additions and 16,844 deletions.
18 changes: 18 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

85 changes: 67 additions & 18 deletions EasyUpiPayment/build.gradle
Original file line number Diff line number Diff line change
@@ -1,37 +1,85 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: "com.jfrog.bintray"
apply plugin: 'com.jfrog.bintray'
apply plugin: 'org.jetbrains.dokka'

version = "2.2"
version = "3.0.0"

android {
compileSdkVersion 29

compileSdkVersion 30
buildToolsVersion '30.0.2'
defaultConfig {
minSdkVersion 19
targetSdkVersion 29
targetSdkVersion 30
versionCode 4
versionName version
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

multiDexEnabled true
}

buildTypes {
release {
minifyEnabled false
consumerProguardFiles 'consumer-rules.pro'
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

testOptions {
unitTests.returnDefaultValues = true
unitTests.includeAndroidResources = true
}

sourceSets {
androidTest.java.srcDirs += "src/test-common/java"
test.java.srcDirs += "src/test-common/java"
}
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
jvmTarget = "1.8"
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation "androidx.core:core-ktx:1.3.1"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.annotation:annotation:1.1.0'

testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
// Testing
testImplementation 'junit:junit:4.13'
testImplementation 'androidx.test:core:1.3.0'
testImplementation 'org.mockito:mockito-core:3.5.0'

// Android Testing
androidTestImplementation 'androidx.test:core:1.3.0'
androidTestImplementation 'androidx.test:core-ktx:1.3.0'
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation 'org.mockito:mockito-core:3.5.0'
androidTestImplementation 'com.linkedin.dexmaker:dexmaker-mockito-inline-extended:2.28.0'

}

dokka {
outputFormat = 'html'
outputDirectory = "ktdocs/"

configuration {
includeNonPublic = false
}
}

ext {
Expand Down Expand Up @@ -107,20 +155,18 @@ task sourcesJar(type: Jar) {
classifier = 'sources'
}

// Avoid Kotlin docs error
tasks.withType(Javadoc) {
enabled = false
}

// Remove javadoc related tasks
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
options.addStringOption('Xdoclint:none', '-quiet')
options.addStringOption('encoding', 'UTF-8')
options.addStringOption('charSet', 'UTF-8')
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}

Expand Down Expand Up @@ -150,3 +196,6 @@ bintray {
}
}
}
repositories {
mavenCentral()
}
1 change: 1 addition & 0 deletions EasyUpiPayment/consumer-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-keepclasseswithmembernames public class com.shreyaspatil.easyupipayment.model.** {*;}
21 changes: 21 additions & 0 deletions EasyUpiPayment/src/androidTest/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.shreyaspatil.EasyUpiPayment">

<application>
<activity
android:name="com.shreyaspatil.easyupipayment.FakeUpiActivity"
android:launchMode="singleInstance"
android:theme="@style/Theme.AppCompat">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data android:scheme="upi" />
</intent-filter>
</activity>
</application>

</manifest>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.shreyaspatil.easyupipayment

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity

class FakeUpiActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
finish()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
package com.shreyaspatil.easyupipayment.ui

import android.app.Activity
import android.content.Intent
import androidx.lifecycle.Lifecycle
import androidx.test.core.app.ApplicationProvider
import androidx.test.core.app.launchActivity
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn
import com.shreyaspatil.easyupipayment.model.PaymentApp
import com.shreyaspatil.easyupipayment.testutils.paymentWith
import junit.framework.TestCase.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mockito.verify

@RunWith(AndroidJUnit4::class)
class PaymentUiActivityTest {

@Test
fun shouldNotThrowIllegalStateException_whenPaymentDetailsProvided() {
val intent = getPaymentIntent()
launchActivity<PaymentUiActivity>(intent).onActivity {
assertTrue(it.lifecycle.currentState.isAtLeast(Lifecycle.State.STARTED))
}
}

@Test
fun shouldFinishActivity_whenTransactionIsOver() {
launchActivity<PaymentUiActivity>(getPaymentIntent()).onActivity {
val responseIntent = Intent().apply { putExtra("response", "") }

// Give transaction result
it.onActivityResult(PaymentUiActivity.PAYMENT_REQUEST, Activity.RESULT_OK, responseIntent)

// Verify Activity is destroyed or not
assertTrue(it.lifecycle.currentState.isAtLeast(Lifecycle.State.DESTROYED))
}
}

@Test
fun shouldGiveCancelledCallback_whenTransactionIsCancelled() {
launchActivity<PaymentUiActivity>(getPaymentIntent()).onActivity {
spyOn(it)

it.onActivityResult(
PaymentUiActivity.PAYMENT_REQUEST,
Activity.RESULT_CANCELED,
null
)

verify(it).callbackTransactionCancelled()
}
}

@Test
fun shouldGiveCompletedCallback_whenTransactionIsFailed() {
launchActivity<PaymentUiActivity>(getPaymentIntent()).onActivity {
spyOn(it)

val transactionDetails = it.getTransactionDetails(RESPONSE_TRANSACTION_FAILURE)

it.onActivityResult(
PaymentUiActivity.PAYMENT_REQUEST,
Activity.RESULT_OK,
getResponseIntent(RESPONSE_TRANSACTION_FAILURE)
)

verify(it).callbackTransactionCompleted(transactionDetails)
}
}

@Test
fun shouldGiveCompletedCallback_whenTransactionIsSuccessful() {
launchActivity<PaymentUiActivity>(getPaymentIntent()).onActivity {
spyOn(it)

val transactionDetails = it.getTransactionDetails(RESPONSE_TRANSACTION_SUCCESS)

it.onActivityResult(
PaymentUiActivity.PAYMENT_REQUEST,
Activity.RESULT_OK,
getResponseIntent(RESPONSE_TRANSACTION_SUCCESS)
)

verify(it).callbackTransactionCompleted(transactionDetails)
}
}

@Test
fun shouldGiveCompletedCallback_whenTransactionIsSubmitted() {
launchActivity<PaymentUiActivity>(getPaymentIntent()).onActivity {
spyOn(it)

val transactionDetails = it.getTransactionDetails(RESPONSE_TRANSACTION_SUBMITTED)

it.onActivityResult(
PaymentUiActivity.PAYMENT_REQUEST,
Activity.RESULT_OK,
getResponseIntent(RESPONSE_TRANSACTION_SUBMITTED)
)

verify(it).callbackTransactionCompleted(transactionDetails)
}
}

private fun getPaymentIntent(paymentApp: PaymentApp? = null) = Intent(
ApplicationProvider.getApplicationContext(),
PaymentUiActivity::class.java
).apply {
putExtra(PaymentUiActivity.EXTRA_KEY_PAYMENT, paymentWith(paymentApp))
}

private fun getResponseIntent(response: String) = Intent().apply {
putExtra("response", response)
}

companion object {
const val RESPONSE_TRANSACTION_SUCCESS = "txnId=abcdefghijklmnopqrstuvwxyz123456789&responseCode=00&ApprovalRefNo=122321&Status=SUCCESS&txnRef=6655443322"
const val RESPONSE_TRANSACTION_SUBMITTED = "txnId=abcdefghijklmnopqrstuvwxyz123456789&responseCode=ZM&ApprovalRefNo=122321&Status=SUBMITTED&txnRef=6655443322"
const val RESPONSE_TRANSACTION_FAILURE = "txnId=abcdefghijklmnopqrstuvwxyz123456789&responseCode=Y1&ApprovalRefNo=122321&Status=FAILURE&txnRef=6655443322"
}
}

4 changes: 2 additions & 2 deletions EasyUpiPayment/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.shreyaspatil.EasyUpiPayment">
package="com.shreyaspatil.easyupipayment">

<application>
<activity
android:name="com.shreyaspatil.EasyUpiPayment.ui.PaymentUiActivity"
android:name="com.shreyaspatil.easyupipayment.ui.PaymentUiActivity"
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar" />
</application>

Expand Down
Loading

0 comments on commit ac69904

Please sign in to comment.