diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 675be26..6294a70 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,7 +13,7 @@ jobs: uses: actions/setup-java@v4 with: distribution: 'zulu' - java-version: 11 + java-version: 17 - name: Get app version id: app_version run: echo "APP_VERSION=$(./gradlew version --no-daemon --console=plain -q | tail -n 1)" >> $GITHUB_OUTPUT diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 14c1208..9d85ec1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,7 +9,7 @@ jobs: uses: actions/setup-java@v4 with: distribution: 'zulu' - java-version: 11 + java-version: 17 - name: Run test run: ./gradlew test - name: Run build diff --git a/build.gradle b/build.gradle index e17b41d..c24e1a0 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:7.4.2' + classpath 'com.android.tools.build:gradle:8.0.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.33.12" @@ -63,7 +63,6 @@ project.ext { assertJsVersion = "3.24.2" assertJGuavaVersion = "3.24.2" mockitoVersion = "5.8.0" - catchException2Version = "1.4.6" } project.ext { diff --git a/gradle.properties b/gradle.properties index 6e3a187..19a455b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,10 +11,12 @@ # The setting is particularly useful for tweaking memory settings. android.enableJetifier=true android.useAndroidX=true -org.gradle.jvmargs=-Xmx4608m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 +org.gradle.jvmargs=-Xmx4608m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 android.jetifier.ignorelist=bcprov-jdk15on -Xjvm-default=enable -android.disableAutomaticComponentCreation=true +android.defaults.buildfeatures.buildconfig=true +android.nonTransitiveRClass=false +android.nonFinalResIds=false # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3119bf6..b73be3f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Sat Oct 15 22:38:33 CEST 2022 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/payment-add-card-module/build.gradle b/payment-add-card-module/build.gradle index 15399ee..971a4f0 100644 --- a/payment-add-card-module/build.gradle +++ b/payment-add-card-module/build.gradle @@ -40,7 +40,6 @@ dependencies { api project(path:':payment-library-api-client') testImplementation "org.assertj:assertj-core:$project.assertJsVersion" - testImplementation "eu.codearte.catch-exception:catch-exception:$project.catchException2Version" testImplementation "org.mockito:mockito-core:$project.mockitoVersion" testImplementation "org.robolectric:robolectric:$project.robolectricVersion" testImplementation "junit:junit:$project.junitVersion" diff --git a/payment-library-api-client/build.gradle b/payment-library-api-client/build.gradle index 95e6f6e..e59caa1 100644 --- a/payment-library-api-client/build.gradle +++ b/payment-library-api-client/build.gradle @@ -41,7 +41,6 @@ dependencies { api "com.squareup.okhttp3:logging-interceptor:$project.okhttpLogInterceptorVersion" testImplementation "org.mockito:mockito-core:$project.mockitoVersion" - testImplementation "eu.codearte.catch-exception:catch-exception:$project.catchException2Version" testImplementation "org.assertj:assertj-core:$project.assertJsVersion" testImplementation "junit:junit:$project.junitVersion" testImplementation "org.robolectric:robolectric:$project.robolectricVersion" diff --git a/payment-library-api-client/src/test/java/com/payu/android/front/sdk/payment_library_api_client/internal/rest/client/ssl/AndroidAndProvidedCertificateListVerifierTest.java b/payment-library-api-client/src/test/java/com/payu/android/front/sdk/payment_library_api_client/internal/rest/client/ssl/AndroidAndProvidedCertificateListVerifierTest.java index eeb24c2..d7cf609 100644 --- a/payment-library-api-client/src/test/java/com/payu/android/front/sdk/payment_library_api_client/internal/rest/client/ssl/AndroidAndProvidedCertificateListVerifierTest.java +++ b/payment-library-api-client/src/test/java/com/payu/android/front/sdk/payment_library_api_client/internal/rest/client/ssl/AndroidAndProvidedCertificateListVerifierTest.java @@ -1,10 +1,8 @@ package com.payu.android.front.sdk.payment_library_api_client.internal.rest.client.ssl; import static com.google.common.collect.Lists.newArrayList; -import static com.googlecode.catchexception.CatchException.catchException; -import static com.googlecode.catchexception.CatchException.caughtException; -import static com.googlecode.catchexception.CatchException.resetCaughtException; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatNoException; import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.openMocks; import static java.util.Arrays.asList; @@ -59,15 +57,12 @@ public void shouldAcceptTrustedCertificateThatMatchesFirstCertificateInChain() t fakeCertificates.add(new SslCertificate(knownPublicKeyHash, serialNumber)); objectUnderTest = new AndroidAndProvidedCertificateListVerifier(trustManagerMock, fakeCertificates); - // when - objectUnderTest.checkServerTrusted(asList(certificateMock, caCertificateMock).toArray(new X509Certificate[2]), null); - - // then - assertThat((Throwable) caughtException()).isNull(); + // when + then + assertThatNoException().isThrownBy(() -> objectUnderTest.checkServerTrusted(asList(certificateMock, caCertificateMock).toArray(new X509Certificate[2]), null)); } @Test - public void shouldAcceptTrustedCertificateThatMatchesSecondCertificateInChain() throws CertificateException { + public void shouldAcceptTrustedCertificateThatMatchesSecondCertificateInChain() { // given String knownPublicKeyHash = "knownPublicKeyHash"; String serialNumber = "36122296c5e338a520a1d25f4cd70954"; @@ -76,21 +71,15 @@ public void shouldAcceptTrustedCertificateThatMatchesSecondCertificateInChain() fakeCertificates.add(new SslCertificate(knownPublicKeyHash, serialNumber)); objectUnderTest = new AndroidAndProvidedCertificateListVerifier(trustManagerMock, fakeCertificates); - // when - objectUnderTest.checkServerTrusted(asList(certificateMock, caCertificateMock).toArray(new X509Certificate[2]), null); - - // then - assertThat((Throwable) caughtException()).isNull(); + // when + then + assertThatNoException().isThrownBy(() -> objectUnderTest.checkServerTrusted(asList(certificateMock, caCertificateMock).toArray(new X509Certificate[2]), null)); } @Test - public void shouldCheckClientPositivelyWithAndroidVerifier() throws CertificateException { - // when - catchException(objectUnderTest).checkClientTrusted(null, null); - - // then - assertThat((Throwable) caughtException()).isNull(); + public void shouldCheckClientPositivelyWithAndroidVerifier() { + // when + then + assertThatNoException().isThrownBy(() -> objectUnderTest.checkClientTrusted(null, null)); } @Test @@ -106,43 +95,29 @@ public void shouldGetNullIssuersIfAndroidTrustManagerIsNotSet() { } @Test - public void shouldNotThrowCertificateExceptionIfAndroidVerifierIsNotAvailable() throws CertificateException { + public void shouldNotThrowCertificateExceptionIfAndroidVerifierIsNotAvailable() { // given objectUnderTest = new AndroidAndProvidedCertificateListVerifier(null, fakeCertificates); - // when - catchException(objectUnderTest).checkClientTrusted(null, null); - - // then - assertThat((Throwable) caughtException()).isNull(); + // when + then + assertThatNoException().isThrownBy(() -> objectUnderTest.checkClientTrusted(null, null)); } - @Test + @Test(expected = CertificateException.class) public void shouldRejectUntrustedCertificatesIfNoCertificatesConfigured() throws CertificateException { // when - catchException(objectUnderTest).checkServerTrusted(asList(certificateMock, caCertificateMock).toArray(new + objectUnderTest.checkServerTrusted(asList(certificateMock, caCertificateMock).toArray(new X509Certificate[2]), null); - - // then - assertThat((Throwable) caughtException()).isInstanceOf(CertificateException.class); } - @Test + @Test(expected = CertificateException.class) public void shouldRejectUntrustedCertificatesIfUnknownCertificatesConfigured() throws CertificateException { // given fakeCertificates.add(new SslCertificate("anypublickeyhash", "serialnumber")); // when - catchException(objectUnderTest).checkServerTrusted(asList(certificateMock, caCertificateMock).toArray(new + objectUnderTest.checkServerTrusted(asList(certificateMock, caCertificateMock).toArray(new X509Certificate[2]), null); - - // then - assertThat((Throwable) caughtException()).isInstanceOf(CertificateException.class); - } - - @After - public void tearDown() { - resetCaughtException(); } private void configureCertificateAndPublicKeyMocks(String firstCertificateSerialNumber, String knownPublicKeyHash, diff --git a/payment-library-webview-module/build.gradle b/payment-library-webview-module/build.gradle index 1d8e35c..b5d77e9 100644 --- a/payment-library-webview-module/build.gradle +++ b/payment-library-webview-module/build.gradle @@ -51,7 +51,6 @@ dependencies { testImplementation "org.robolectric:robolectric:$project.robolectricVersion" testImplementation "org.mockito:mockito-core:$project.mockitoVersion" - testImplementation "eu.codearte.catch-exception:catch-exception:$project.catchException2Version" testImplementation "org.assertj:assertj-core:$project.assertJsVersion" androidTestImplementation "androidx.test.ext:junit:$project.junitAssertionsVersion" diff --git a/payment-library-webview-module/src/test/java/com/payu/android/front/sdk/payment_library_webview_module/web/authorization/client/WebAuthorizationViewChromeClientTest.java b/payment-library-webview-module/src/test/java/com/payu/android/front/sdk/payment_library_webview_module/web/authorization/client/WebAuthorizationViewChromeClientTest.java index 3ccdd38..2f3b2e1 100644 --- a/payment-library-webview-module/src/test/java/com/payu/android/front/sdk/payment_library_webview_module/web/authorization/client/WebAuthorizationViewChromeClientTest.java +++ b/payment-library-webview-module/src/test/java/com/payu/android/front/sdk/payment_library_webview_module/web/authorization/client/WebAuthorizationViewChromeClientTest.java @@ -1,8 +1,6 @@ package com.payu.android.front.sdk.payment_library_webview_module.web.authorization.client; -import static com.googlecode.catchexception.CatchException.catchException; -import static com.googlecode.catchexception.CatchException.caughtException; -import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatNoException; import static org.mockito.Mockito.verify; import android.view.View; @@ -45,11 +43,8 @@ public void shouldReactForLostViewReference() { // given objectUnderTest = new WebAuthorizationViewChromeClient(null); - // when - catchException(objectUnderTest).onProgressChanged(null, 64); - - // then - assertThat((Throwable) caughtException()).isNull(); + // when + then + assertThatNoException().isThrownBy(() -> objectUnderTest.onProgressChanged(null, 64)); } @Test @@ -75,4 +70,4 @@ public void shouldShouldHideProgressWhenFinished() { // then verify(progressBar).setVisibility(View.GONE); } -} \ No newline at end of file +}