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
20 changes: 12 additions & 8 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 @@ -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 @@ -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 @@ -118,6 +118,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 @@ -239,7 +242,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