Skip to content

Commit 85a4a3a

Browse files
authored
Merge pull request #92 from pduvvur/fix-coveralls-for-payments
Fixed coveralls reporting for payments-api module and re added tests
2 parents 99b56e1 + 280362f commit 85a4a3a

File tree

2 files changed

+52
-31
lines changed

2 files changed

+52
-31
lines changed

payments-api/pom.xml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,12 @@
3535
<artifactId>jackson-module-jaxb-annotations</artifactId>
3636
<version>2.9.6</version>
3737
</dependency>
38-
<!--
3938
<dependency>
4039
<groupId>org.jmockit</groupId>
4140
<artifactId>jmockit</artifactId>
4241
<version>1.25</version>
4342
<scope>test</scope>
4443
</dependency>
45-
-->
4644
</dependencies>
4745
<build>
4846
<testResources>
@@ -111,16 +109,14 @@
111109
</archive>
112110
</configuration>
113111
</plugin>
114-
<!--
115112
<plugin>
116113
<groupId>org.apache.maven.plugins</groupId>
117114
<artifactId>maven-surefire-plugin</artifactId>
118115
<version>3.0.0-M3</version>
119116
<configuration>
120-
<argLine>
121-
-Djdk.attach.allowAttachSelf
122-
</argLine>
123-
</plugin> -->
117+
<argLine>${argLine} -Djdk.attach.allowAttachSelf</argLine>
118+
</configuration>
119+
</plugin>
124120
<plugin>
125121
<groupId>org.jacoco</groupId>
126122
<artifactId>jacoco-maven-plugin</artifactId>

payments-api/src/test/java/com/intuit/payment/services/base/ServiceBaseTest.java

Lines changed: 49 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,32 @@
1515
*******************************************************************************/
1616
package com.intuit.payment.services.base;
1717

18-
public class ServiceBaseTest {/*
18+
import com.fasterxml.jackson.core.type.TypeReference;
19+
import com.intuit.payment.config.RequestContext;
20+
import com.intuit.payment.data.ECheck;
21+
import com.intuit.payment.data.Entity;
22+
import com.intuit.payment.data.Error;
23+
import com.intuit.payment.data.Errors;
24+
import com.intuit.payment.exception.AuthorizationException;
25+
import com.intuit.payment.exception.BadRequestException;
26+
import com.intuit.payment.exception.BaseException;
27+
import com.intuit.payment.exception.ServiceException;
28+
import com.intuit.payment.http.HttpRequestClient;
29+
import com.intuit.payment.http.MethodType;
30+
import com.intuit.payment.http.Request;
31+
import com.intuit.payment.http.Response;
32+
import mockit.Mock;
33+
import mockit.MockUp;
34+
import org.testng.Assert;
35+
import org.testng.annotations.BeforeClass;
36+
import org.testng.annotations.BeforeMethod;
37+
import org.testng.annotations.Test;
38+
39+
import java.math.BigDecimal;
40+
41+
import static org.testng.Assert.fail;
42+
43+
public class ServiceBaseTest {
1944
private ServiceBase serviceBase;
2045
private MockHttpRequestClient mockHttpRequestClient;
2146

@@ -75,10 +100,10 @@ public void testSendRequest_successPostRequest() throws BaseException {
75100
Assert.assertEquals(actualResponse.getIntuit_tid(), tid);
76101
}
77102

78-
*//**
103+
/**
79104
* Tests that the "sendRequest" function is able to serialize the Response content to the expected object (ECheck in this test)
80105
* during a GET request
81-
*//*
106+
*/
82107
@Test
83108
public void testSendRequest_successGetRequest() throws BaseException {
84109
String eCheckId = "5";
@@ -106,9 +131,9 @@ public void testSendRequest_successGetRequest() throws BaseException {
106131
Assert.assertEquals(actualResponse.getIntuit_tid(), tid);
107132
}
108133

109-
*//**
134+
/**
110135
* Tests the case where response payload is empty
111-
*//*
136+
*/
112137
@Test
113138
public void testSendRequest_successEmptyResponsePayload() throws BaseException {
114139
int httpStatusCode = 200;
@@ -129,9 +154,9 @@ public void testSendRequest_successEmptyResponsePayload() throws BaseException {
129154
Assert.assertEquals(actualResponse.getIntuit_tid(), tid);
130155
}
131156

132-
*//**
157+
/**
133158
* Tests that a BaseException is thrown when the response is null for the service request
134-
*//*
159+
*/
135160
@Test(expectedExceptions = BaseException.class,
136161
expectedExceptionsMessageRegExp = "Unexpected Error , service response object was null ")
137162
public void testSendRequest_nullResponse() throws BaseException {
@@ -145,10 +170,10 @@ public void testSendRequest_nullResponse() throws BaseException {
145170
serviceBase.sendRequest(serviceRequest);
146171
}
147172

148-
*//**
173+
/**
149174
* Tests the case where the HTTP status code is 404 and the call to httpRequestClient.makeRequest()
150175
* sets the errors in the response content and deserialization of the error goes through fine
151-
*//*
176+
*/
152177
@Test
153178
public void testSendRequest_errorPageNotFound() throws BaseException {
154179
int httpStatusCode = 404;
@@ -180,10 +205,10 @@ public void testSendRequest_errorPageNotFound() throws BaseException {
180205
}
181206
}
182207

183-
*//**
208+
/**
184209
* Tests the case where the HTTP status code is 404 and the call to httpRequestClient.makeRequest()
185210
* sets the errors in the response content but the deserialization of the response error content fails
186-
*//*
211+
*/
187212
@Test
188213
public void testSendRequest_errorDeserializingErrorResponse() throws BaseException {
189214
int httpStatusCode = 404;
@@ -211,10 +236,10 @@ public void testSendRequest_errorDeserializingErrorResponse() throws BaseExcepti
211236
}
212237
}
213238

214-
*//**
239+
/**
215240
* Tests the case where the HTTP status code is 401 but there is no Error set in the response content from the
216241
* call to httpRequestClient.makeRequest()
217-
*//*
242+
*/
218243
@Test
219244
public void testSendRequest_errorUnauthorized() throws BaseException {
220245
int httpStatusCode = 401;
@@ -239,10 +264,10 @@ public void testSendRequest_errorUnauthorized() throws BaseException {
239264
assertErrorsInException(errors, httpStatusCode, mockResponseContent);}
240265
}
241266

242-
*//**
267+
/**
243268
* Tests the case where the HTTP status code is 400 but there is no Error set in the response content from the
244269
* call to httpRequestClient.makeRequest()
245-
*//*
270+
*/
246271
@Test
247272
public void testSendRequest_errorBadRequest() throws BaseException {
248273
int httpStatusCode = 400;
@@ -268,10 +293,10 @@ public void testSendRequest_errorBadRequest() throws BaseException {
268293
}
269294
}
270295

271-
*//**
296+
/**
272297
* Tests the case where the HTTP status code is 500 but there is no Error set in the response content from the
273298
* call to httpRequestClient.makeRequest()
274-
*//*
299+
*/
275300
@Test
276301
public void testSendRequest_errorInternalServerError() throws BaseException {
277302
int httpStatusCode = 500;
@@ -297,10 +322,10 @@ public void testSendRequest_errorInternalServerError() throws BaseException {
297322
}
298323
}
299324

300-
*//**
325+
/**
301326
* Tests the case where the HTTP status code is 301 but there is no Error set in the response content from the
302327
* call to httpRequestClient.makeRequest()
303-
*//*
328+
*/
304329
@Test
305330
public void testSendRequest_errorMovedPermanently() {
306331
int httpStatusCode = 301;
@@ -326,9 +351,9 @@ public void testSendRequest_errorMovedPermanently() {
326351
}
327352
}
328353

329-
*//**
354+
/**
330355
* Tests that intuit_tid and requestId is being set on the entity
331-
*//*
356+
*/
332357
@Test
333358
public void testPrepareResponse_success() {
334359
String expectedRequestId = "146-request-id";
@@ -360,10 +385,10 @@ private void assertErrorsInException(Errors actualErrors, int expectedHttpStatus
360385
Assert.assertEquals(error.getDetail(), "ResponsePayload: " + expectedErrorContent);
361386
}
362387

363-
*//**
388+
/**
364389
* This is a mock implementation of the HttpRequestClient to mock the response from this class
365390
* Only the "makeRequest()" method is mocked. Other methods can be mocked if necessary.
366-
*//*
391+
*/
367392
private final class MockHttpRequestClient extends MockUp<HttpRequestClient> {
368393

369394
private Response mockResponse;
@@ -384,4 +409,4 @@ public Response makeRequest(Request serviceRequest) throws BadRequestException {
384409
return this.mockResponse;
385410
}
386411
}
387-
*/}
412+
}

0 commit comments

Comments
 (0)