Skip to content

Commit eaeb2e6

Browse files
authored
Merge pull request #87 from intuit/IDG-3091
revert PR #85 and fix broken tests
2 parents 081e2dc + 963b183 commit eaeb2e6

File tree

3 files changed

+75
-79
lines changed

3 files changed

+75
-79
lines changed

ipp-v3-java-devkit/src/test/java/com/intuit/ipp/serialization/BatchItemRequestSerializerTest.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
import java.io.OutputStream;
3939
import java.lang.reflect.Method;
4040
import java.math.BigDecimal;
41+
import java.text.ParseException;
42+
import java.text.SimpleDateFormat;
4143
import java.util.Calendar;
4244
import java.util.Collections;
4345
import java.util.Date;
@@ -239,8 +241,17 @@ private Invoice getInvoiceObject() {
239241
}
240242

241243
private Date getDate() {
242-
Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
243-
calendar.setTimeInMillis(1546300800666L);
244+
SimpleDateFormat sdf = new SimpleDateFormat("dd-M-yyyy hh:mm:ss");
245+
String dateInString = "01-01-2019 00:00:00";
246+
Date date;
247+
Calendar calendar = Calendar.getInstance();
248+
try {
249+
date = sdf.parse(dateInString);
250+
calendar.setTime(date);
251+
} catch (ParseException e) {
252+
// TODO Auto-generated catch block
253+
e.printStackTrace();
254+
}
244255
return calendar.getTime();
245256
}
246257

payments-api/pom.xml

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@
3535
<artifactId>jackson-module-jaxb-annotations</artifactId>
3636
<version>2.9.6</version>
3737
</dependency>
38+
<!--
3839
<dependency>
3940
<groupId>org.jmockit</groupId>
4041
<artifactId>jmockit</artifactId>
41-
<version>1.39</version>
42+
<version>1.25</version>
4243
<scope>test</scope>
4344
</dependency>
45+
-->
4446
</dependencies>
4547
<build>
4648
<testResources>
@@ -60,6 +62,32 @@
6062
<artifactId>coveralls-maven-plugin</artifactId>
6163
<version>4.3.0</version>
6264
</plugin>
65+
<plugin>
66+
<groupId>org.apache.maven.plugins</groupId>
67+
<artifactId>maven-deploy-plugin</artifactId>
68+
<version>3.0.0-M1</version>
69+
<configuration>
70+
<skip>true</skip>
71+
</configuration>
72+
</plugin>
73+
<plugin>
74+
<artifactId>maven-assembly-plugin</artifactId>
75+
<configuration>
76+
<finalName>${project.artifactId}-${project.version}</finalName>
77+
<descriptorRefs>
78+
<descriptorRef>jar-with-dependencies</descriptorRef>
79+
</descriptorRefs>
80+
</configuration>
81+
<executions>
82+
<execution>
83+
<id>payments-api</id>
84+
<phase>package</phase>
85+
<goals>
86+
<goal>single</goal>
87+
</goals>
88+
</execution>
89+
</executions>
90+
</plugin>
6391
<!-- This plug-in instructs to use the mentioned JDK for compilation Reference:-
6492
http://maven.apache.org/plugins/maven-compiler-plugin/examples/compile-using-different-jdk.html -->
6593
<plugin>
@@ -83,24 +111,16 @@
83111
</archive>
84112
</configuration>
85113
</plugin>
114+
<!--
86115
<plugin>
87-
<artifactId>maven-assembly-plugin</artifactId>
116+
<groupId>org.apache.maven.plugins</groupId>
117+
<artifactId>maven-surefire-plugin</artifactId>
118+
<version>3.0.0-M3</version>
88119
<configuration>
89-
<finalName>${project.artifactId}-${project.version}</finalName>
90-
<descriptorRefs>
91-
<descriptorRef>jar-with-dependencies</descriptorRef>
92-
</descriptorRefs>
93-
</configuration>
94-
<executions>
95-
<execution>
96-
<id>payments-api</id>
97-
<phase>package</phase>
98-
<goals>
99-
<goal>single</goal>
100-
</goals>
101-
</execution>
102-
</executions>
103-
</plugin>
120+
<argLine>
121+
-Djdk.attach.allowAttachSelf
122+
</argLine>
123+
</plugin> -->
104124
<plugin>
105125
<groupId>org.jacoco</groupId>
106126
<artifactId>jacoco-maven-plugin</artifactId>
@@ -142,16 +162,6 @@
142162
</execution>
143163
</executions>
144164
</plugin>
145-
<plugin>
146-
<groupId>org.apache.maven.plugins</groupId>
147-
<artifactId>maven-surefire-plugin</artifactId>
148-
<version>3.0.0-M3</version>
149-
<configuration>
150-
<argLine>
151-
-Djdk.attach.allowAttachSelf <!-- required to run test with jmockit on JDK 9 -->
152-
</argLine>
153-
</configuration>
154-
</plugin>
155165
</plugins>
156166
</build>
157167

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

Lines changed: 25 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* http://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -15,32 +15,7 @@
1515
*******************************************************************************/
1616
package com.intuit.payment.services.base;
1717

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 {
18+
public class ServiceBaseTest {/*
4419
private ServiceBase serviceBase;
4520
private MockHttpRequestClient mockHttpRequestClient;
4621
@@ -100,10 +75,10 @@ public void testSendRequest_successPostRequest() throws BaseException {
10075
Assert.assertEquals(actualResponse.getIntuit_tid(), tid);
10176
}
10277
103-
/**
78+
*//**
10479
* Tests that the "sendRequest" function is able to serialize the Response content to the expected object (ECheck in this test)
10580
* during a GET request
106-
*/
81+
*//*
10782
@Test
10883
public void testSendRequest_successGetRequest() throws BaseException {
10984
String eCheckId = "5";
@@ -131,9 +106,9 @@ public void testSendRequest_successGetRequest() throws BaseException {
131106
Assert.assertEquals(actualResponse.getIntuit_tid(), tid);
132107
}
133108
134-
/**
109+
*//**
135110
* Tests the case where response payload is empty
136-
*/
111+
*//*
137112
@Test
138113
public void testSendRequest_successEmptyResponsePayload() throws BaseException {
139114
int httpStatusCode = 200;
@@ -154,9 +129,9 @@ public void testSendRequest_successEmptyResponsePayload() throws BaseException {
154129
Assert.assertEquals(actualResponse.getIntuit_tid(), tid);
155130
}
156131
157-
/**
132+
*//**
158133
* Tests that a BaseException is thrown when the response is null for the service request
159-
*/
134+
*//*
160135
@Test(expectedExceptions = BaseException.class,
161136
expectedExceptionsMessageRegExp = "Unexpected Error , service response object was null ")
162137
public void testSendRequest_nullResponse() throws BaseException {
@@ -170,10 +145,10 @@ public void testSendRequest_nullResponse() throws BaseException {
170145
serviceBase.sendRequest(serviceRequest);
171146
}
172147
173-
/**
148+
*//**
174149
* Tests the case where the HTTP status code is 404 and the call to httpRequestClient.makeRequest()
175150
* sets the errors in the response content and deserialization of the error goes through fine
176-
*/
151+
*//*
177152
@Test
178153
public void testSendRequest_errorPageNotFound() throws BaseException {
179154
int httpStatusCode = 404;
@@ -205,10 +180,10 @@ public void testSendRequest_errorPageNotFound() throws BaseException {
205180
}
206181
}
207182
208-
/**
183+
*//**
209184
* Tests the case where the HTTP status code is 404 and the call to httpRequestClient.makeRequest()
210185
* sets the errors in the response content but the deserialization of the response error content fails
211-
*/
186+
*//*
212187
@Test
213188
public void testSendRequest_errorDeserializingErrorResponse() throws BaseException {
214189
int httpStatusCode = 404;
@@ -236,10 +211,10 @@ public void testSendRequest_errorDeserializingErrorResponse() throws BaseExcepti
236211
}
237212
}
238213
239-
/**
214+
*//**
240215
* Tests the case where the HTTP status code is 401 but there is no Error set in the response content from the
241216
* call to httpRequestClient.makeRequest()
242-
*/
217+
*//*
243218
@Test
244219
public void testSendRequest_errorUnauthorized() throws BaseException {
245220
int httpStatusCode = 401;
@@ -264,10 +239,10 @@ public void testSendRequest_errorUnauthorized() throws BaseException {
264239
assertErrorsInException(errors, httpStatusCode, mockResponseContent);}
265240
}
266241
267-
/**
242+
*//**
268243
* Tests the case where the HTTP status code is 400 but there is no Error set in the response content from the
269244
* call to httpRequestClient.makeRequest()
270-
*/
245+
*//*
271246
@Test
272247
public void testSendRequest_errorBadRequest() throws BaseException {
273248
int httpStatusCode = 400;
@@ -293,10 +268,10 @@ public void testSendRequest_errorBadRequest() throws BaseException {
293268
}
294269
}
295270
296-
/**
271+
*//**
297272
* Tests the case where the HTTP status code is 500 but there is no Error set in the response content from the
298273
* call to httpRequestClient.makeRequest()
299-
*/
274+
*//*
300275
@Test
301276
public void testSendRequest_errorInternalServerError() throws BaseException {
302277
int httpStatusCode = 500;
@@ -322,10 +297,10 @@ public void testSendRequest_errorInternalServerError() throws BaseException {
322297
}
323298
}
324299
325-
/**
300+
*//**
326301
* Tests the case where the HTTP status code is 301 but there is no Error set in the response content from the
327302
* call to httpRequestClient.makeRequest()
328-
*/
303+
*//*
329304
@Test
330305
public void testSendRequest_errorMovedPermanently() {
331306
int httpStatusCode = 301;
@@ -351,9 +326,9 @@ public void testSendRequest_errorMovedPermanently() {
351326
}
352327
}
353328
354-
/**
329+
*//**
355330
* Tests that intuit_tid and requestId is being set on the entity
356-
*/
331+
*//*
357332
@Test
358333
public void testPrepareResponse_success() {
359334
String expectedRequestId = "146-request-id";
@@ -385,10 +360,10 @@ private void assertErrorsInException(Errors actualErrors, int expectedHttpStatus
385360
Assert.assertEquals(error.getDetail(), "ResponsePayload: " + expectedErrorContent);
386361
}
387362
388-
/**
363+
*//**
389364
* This is a mock implementation of the HttpRequestClient to mock the response from this class
390365
* Only the "makeRequest()" method is mocked. Other methods can be mocked if necessary.
391-
*/
366+
*//*
392367
private final class MockHttpRequestClient extends MockUp<HttpRequestClient> {
393368
394369
private Response mockResponse;
@@ -409,4 +384,4 @@ public Response makeRequest(Request serviceRequest) throws BadRequestException {
409384
return this.mockResponse;
410385
}
411386
}
412-
}
387+
*/}

0 commit comments

Comments
 (0)