Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4

- name: Set up Java JDK
uses: actions/setup-java@v2
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4
with:
java-version: 8
distribution: 'adopt'
distribution: 'temurin'

- name: Install dependencies
run: mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V -Dgpg.skip
Expand All @@ -30,7 +30,7 @@ jobs:
run: mvn -B test

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4
with:
fail_ci_if_error: false
verbose: true
Expand All @@ -40,12 +40,12 @@ jobs:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
- name: Set up Maven Central Repository
uses: actions/setup-java@v2
uses: actions/setup-java@8df103950f1a284ea214c9acc06196fd9f766f2a # v4
with:
java-version: 8
distribution: 'adopt'
distribution: 'temurin'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
Expand Down
32 changes: 18 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,11 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<version>2.13.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>4.11.0</version>
<scope>test</scope>
</dependency>
<!-- test dependencies -->


<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
Expand Down Expand Up @@ -100,11 +94,11 @@
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/releases/</url>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/repositories/releases/content/</url>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>

Expand All @@ -121,7 +115,7 @@
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.9</version>
<version>1.7.0</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
Expand All @@ -132,7 +126,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<version>3.3.1</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -145,7 +139,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.1</version>
<version>3.8.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
Expand All @@ -158,7 +152,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.7</version>
<version>0.8.11</version>
<configuration>
<excludes>
<exclude>com/razorpay/**/EntityNameURLMapping.class</exclude>
Expand Down Expand Up @@ -186,7 +180,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<version>3.2.7</version>
<executions>
<execution>
<id>sign-artifacts</id>
Expand All @@ -204,6 +198,16 @@
</gpgArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
<configuration>
<argLine>
-XX:+EnableDynamicAgentLoading -Dnet.bytebuddy.experimental=true @{argLine}
</argLine>
</configuration>
</plugin>
</plugins>

</build>
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/razorpay/ApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ else if(response.code()==204){
private <T extends Entity> T parseResponse(JSONObject jsonObject, String entity) throws RazorpayException {
if (entity != null) {
Class<T> cls = getClass(entity);
if (cls == null) {
throw new RazorpayException("Unable to find class for entity: " + entity);
}
try {
return cls.getConstructor(JSONObject.class).newInstance(jsonObject);
} catch (Exception e) {
Expand Down Expand Up @@ -247,7 +250,7 @@ private void throwServerException(int statusCode, String responseBody) throws Ra

private Class getClass(String entity) {
try {
String entityClass = "com.razorpay." + WordUtils.capitalize(entity, '_').replaceAll("_", "");
String entityClass = getClass().getPackage().getName() + "." + WordUtils.capitalize(entity, '_').replaceAll("_", "");
return Class.forName(entityClass);
} catch (ClassNotFoundException e) {
return null;
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/com/razorpay/BaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import java.util.Map;

import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.anyObject;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

Expand All @@ -30,7 +30,7 @@ public class BaseTest {
@Before
public void setUp() throws Exception {

MockitoAnnotations.initMocks(this);
MockitoAnnotations.openMocks(this);
mockGetCall();
mockURL(Collections.emptyList());
}
Expand All @@ -44,7 +44,7 @@ private void mockGetCall() throws IOException, IllegalAccessException {

Call call = mock(Call.class);
when(call.execute()).thenReturn(mockedResponse);
when(okHttpClient.newCall(anyObject())).thenReturn(call);
when(okHttpClient.newCall(any())).thenReturn(call);

}

Expand Down