Skip to content

Commit 4146d37

Browse files
Tess Stoddardtessstoddard
authored andcommitted
fix: revert version endpoint changes for payments and recurring payments
1 parent 92c058c commit 4146d37

6 files changed

Lines changed: 9 additions & 109 deletions

File tree

mdx-models/src/main/java/com/mx/path/model/mdx/accessor/payment/PaymentBaseAccessor.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -194,17 +194,6 @@ public AccessorResponse<MdxList<Payment>> list() {
194194
throw new AccessorMethodNotImplementedException();
195195
}
196196

197-
/**
198-
* List all payments - Version 20260427
199-
*
200-
* @return
201-
*/
202-
@GatewayAPI
203-
@API(description = "List all payments version 20260427")
204-
public AccessorResponse<MdxList<Payment>> list20260427() {
205-
throw new AccessorMethodNotImplementedException();
206-
}
207-
208197
/**
209198
* Accessor for bill operations
210199
*

mdx-models/src/main/java/com/mx/path/model/mdx/accessor/payment/RecurringPaymentBaseAccessor.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,6 @@ public AccessorResponse<MdxList<Frequency>> frequencies() {
6767
throw new AccessorMethodNotImplementedException();
6868
}
6969

70-
/**
71-
* List all recurring payments - Version 20260427
72-
*
73-
* @return
74-
*/
75-
@GatewayAPI
76-
@API(description = "List all recurring payments verion 20260427")
77-
public AccessorResponse<MdxList<RecurringPayment>> list20260427() {
78-
throw new AccessorMethodNotImplementedException();
79-
}
80-
8170
/**
8271
* List all recurring payments
8372
*

mdx-web/src/main/java/com/mx/path/model/mdx/web/controller/PaymentsController.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,10 @@ public final ResponseEntity<Payment> createPayment(@RequestBody Payment paymentR
9090
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
9191
}
9292

93-
@SuppressWarnings("MagicNumber")
9493
@RequestMapping(value = "/payments", method = RequestMethod.GET)
95-
public final ResponseEntity<?> getPaymentList(HttpServletRequest request) {
96-
return versioned(request)
97-
.defaultVersion(MdxList.class, MdxList.class, payments -> {
98-
AccessorResponse<MdxList<Payment>> response = gateway().payments().list();
99-
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
100-
})
101-
.version(20260427, MdxList.class, MdxList.class, payments -> {
102-
AccessorResponse<MdxList<Payment>> response = gateway().payments().list20260427();
103-
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
104-
})
105-
.execute();
94+
public final ResponseEntity<MdxList<Payment>> getPaymentList() {
95+
AccessorResponse<MdxList<Payment>> response = gateway().payments().list();
96+
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
10697
}
10798

10899
@RequestMapping(value = "/payments/{id}", method = RequestMethod.GET)

mdx-web/src/main/java/com/mx/path/model/mdx/web/controller/RecurringPaymentsController.java

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
import org.springframework.web.bind.annotation.RequestMethod;
1414
import org.springframework.web.bind.annotation.RestController;
1515

16-
import jakarta.servlet.http.HttpServletRequest;
17-
1816
@RestController
1917
@RequestMapping(value = "{clientId}", produces = BaseController.MDX_MEDIA)
2018
public class RecurringPaymentsController extends BaseController {
@@ -25,19 +23,10 @@ public final ResponseEntity<MdxList<Frequency>> getRecurringPaymentFrequencies()
2523
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
2624
}
2725

28-
@SuppressWarnings("MagicNumber")
2926
@RequestMapping(value = "/users/{userId}/recurring_payments", method = RequestMethod.GET)
30-
public final ResponseEntity<?> getRecurringPayments(HttpServletRequest request) {
31-
return versioned(request)
32-
.defaultVersion(MdxList.class, MdxList.class, recurringPayments -> {
33-
AccessorResponse<MdxList<RecurringPayment>> response = gateway().payments().recurring().list();
34-
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
35-
})
36-
.version(20260427, MdxList.class, MdxList.class, recurringPayments -> {
37-
AccessorResponse<MdxList<RecurringPayment>> response = gateway().payments().recurring().list20260427();
38-
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
39-
})
40-
.execute();
27+
public final ResponseEntity<MdxList<RecurringPayment>> getRecurringPayments() {
28+
AccessorResponse<MdxList<RecurringPayment>> response = gateway().payments().recurring().list();
29+
return new ResponseEntity<>(response.getResult().wrapped(), createMultiMapForResponse(response.getHeaders()), HttpStatus.OK);
4130
}
4231

4332
@RequestMapping(value = "/users/{userId}/recurring_payments", method = RequestMethod.POST, consumes = MDX_MEDIA)

mdx-web/src/test/groovy/com/mx/path/model/mdx/web/controller/PaymentsControllerTest.groovy

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -68,35 +68,18 @@ class PaymentsControllerTest extends Specification {
6868
BaseController.setGateway(gateway)
6969

7070
def payment = new Payment()
71-
def payments = new MdxList<Payment>().tap { add(payment) }
71+
def payments = new MdxList<>().tap { add(payment) }
7272

7373
when:
7474
Mockito.doReturn(new AccessorResponse<MdxList<Payment>>().withResult(payments)).when(paymentGateway).list()
75-
def response = subject.getPaymentList(buildRequest(null, "application/vnd.mx.mdx.v6+json"))
75+
def response = subject.getPaymentList()
7676

7777
then:
7878
HttpStatus.OK == response.getStatusCode()
7979
response.getBody() == payments
8080
verify(paymentGateway).list() || true
8181
}
8282

83-
def "getPayments v20260427 interacts with gateway"() {
84-
given:
85-
BaseController.setGateway(gateway)
86-
87-
def payment = new Payment()
88-
def payments = new MdxList<Payment>().tap { add(payment) }
89-
90-
when:
91-
Mockito.doReturn(new AccessorResponse<MdxList<Payment>>().withResult(payments)).when(paymentGateway).list20260427()
92-
def response = subject.getPaymentList(buildRequest(null, "application/vnd.mx.mdx.v6+json;version=20260427"))
93-
94-
then:
95-
HttpStatus.OK == response.getStatusCode()
96-
response.getBody() == payments
97-
verify(paymentGateway).list20260427() || true
98-
}
99-
10083
def "createPayment interacts with gateway"() {
10184
given:
10285
BaseController.setGateway(gateway)

mdx-web/src/test/groovy/com/mx/path/model/mdx/web/controller/RecurringPaymentsControllerTest.groovy

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,32 @@
11
package com.mx.path.model.mdx.web.controller
22

3-
import static org.mockito.Mockito.mock
43
import static org.mockito.Mockito.spy
54
import static org.mockito.Mockito.verify
6-
import static org.mockito.Mockito.when
75

8-
import com.google.gson.Gson
9-
import com.google.gson.GsonBuilder
10-
import com.mx.path.core.context.Session
116
import com.mx.path.gateway.accessor.AccessorResponse
127
import com.mx.path.gateway.api.Gateway
138
import com.mx.path.gateway.api.payment.PaymentGateway
149
import com.mx.path.gateway.api.payment.RecurringPaymentGateway
1510
import com.mx.path.model.mdx.model.Frequency
1611
import com.mx.path.model.mdx.model.MdxList
17-
import com.mx.path.model.mdx.model.Resources
1812
import com.mx.path.model.mdx.model.payment.RecurringPayment
1913

2014
import org.mockito.Mockito
2115
import org.springframework.http.HttpStatus
2216

2317
import spock.lang.Specification
2418

25-
import jakarta.servlet.http.HttpServletRequest
26-
2719
class RecurringPaymentsControllerTest extends Specification {
2820
RecurringPaymentsController subject
2921
Gateway gateway
3022
PaymentGateway paymentGateway
3123
RecurringPaymentGateway recurringPaymentGateway
32-
Gson gson
3324

3425
def setup() {
3526
subject = new RecurringPaymentsController()
3627
recurringPaymentGateway = spy(RecurringPaymentGateway.builder().build())
3728
paymentGateway = PaymentGateway.builder().recurring(recurringPaymentGateway).build()
3829
gateway = Gateway.builder().payments(paymentGateway).build()
39-
40-
GsonBuilder builder = new GsonBuilder()
41-
Resources.registerResources(builder)
42-
gson = builder.create()
4330
}
4431

4532
def cleanup() {
@@ -71,29 +58,13 @@ class RecurringPaymentsControllerTest extends Specification {
7158

7259
when:
7360
Mockito.doReturn(new AccessorResponse<MdxList<RecurringPayment>>().withResult(recurringPayments)).when(recurringPaymentGateway).list()
74-
def response = subject.getRecurringPayments(buildRequest(null, "application/vnd.mx.mdx.v6+json"))
61+
def response = subject.getRecurringPayments()
7562

7663
then:
7764
verify(recurringPaymentGateway).list() || true
7865
response.getBody() == recurringPayments
7966
}
8067

81-
def "index recurring payments v20260427 invokes gateway"() {
82-
given:
83-
RecurringPayment recurringPayment = new RecurringPayment()
84-
MdxList<RecurringPayment> recurringPayments = new MdxList<>()
85-
recurringPayments.add(recurringPayment)
86-
BaseController.setGateway(gateway)
87-
88-
when:
89-
Mockito.doReturn(new AccessorResponse<MdxList<RecurringPayment>>().withResult(recurringPayments)).when(recurringPaymentGateway).list20260427()
90-
def response = subject.getRecurringPayments(buildRequest(null, "application/vnd.mx.mdx.v6+json;version=20260427"))
91-
92-
then:
93-
verify(recurringPaymentGateway).list20260427() || true
94-
response.getBody() == recurringPayments
95-
}
96-
9768
def "get recurring payment invokes gateway"() {
9869
given:
9970
RecurringPayment recurringPayment = new RecurringPayment()
@@ -155,16 +126,4 @@ class RecurringPaymentsControllerTest extends Specification {
155126
verify(recurringPaymentGateway).cancel(recurringPayment.id) || true
156127
HttpStatus.NO_CONTENT == response.getStatusCode()
157128
}
158-
159-
def buildRequest(Object body, String contentType) {
160-
HttpServletRequest request = mock(HttpServletRequest.class)
161-
when(request.getReader()).thenReturn(new BufferedReader(new StringReader(gson.toJson(body))))
162-
if (Session.current() != null) {
163-
when(request.getHeader("mx-session-key")).thenReturn(Session.current().getId())
164-
}
165-
when(request.getHeaders("Content-Type")).thenReturn(Collections.enumeration([contentType]))
166-
when(request.getHeaders("Accept")).thenReturn(Collections.enumeration([contentType]))
167-
168-
return request
169-
}
170129
}

0 commit comments

Comments
 (0)