Skip to content

Commit e1fd0fc

Browse files
authored
Merge pull request #142 from companieshouse/feature/gci-2239_refactor_get_checkout_item_endpoint
GCI-2335 Change getCheckoutItem to return checkout data
2 parents d2c299c + eacb871 commit e1fd0fc

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

src/main/java/uk/gov/companieshouse/orders/api/controller/OrderController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public ResponseEntity<Item> getOrderItem(final @PathVariable("id") String orderI
102102
}
103103

104104
@GetMapping(GET_CHECKOUT_ITEM_URI)
105-
public ResponseEntity<Checkout> getCheckoutItem(final @PathVariable("id") String checkoutId,
105+
public ResponseEntity<CheckoutData> getCheckoutItem(final @PathVariable("id") String checkoutId,
106106
final @PathVariable("itemId") String itemId,
107107
final @RequestHeader(REQUEST_ID_HEADER_NAME) String requestId) {
108108
Map<String, Object> logMap = createLogMapWithRequestId(requestId);
@@ -113,7 +113,7 @@ public ResponseEntity<Checkout> getCheckoutItem(final @PathVariable("id") String
113113
.orElseThrow(ResourceNotFoundException::new);
114114
logMap.put(LoggingUtils.STATUS, HttpStatus.OK);
115115
LOGGER.info("Checkout with item found and returned", logMap);
116-
return ResponseEntity.ok().body(checkout);
116+
return ResponseEntity.ok().body(checkout.getData());
117117
}
118118

119119
@GetMapping(GET_CHECKOUT_URI)

src/test/java/uk/gov/companieshouse/orders/api/controller/OrderControllerIntegrationTest.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -582,11 +582,8 @@ void getCheckoutItem() throws Exception {
582582
"12345678")));
583583
checkoutRepository.save(preexistingCheckout);
584584

585-
final Checkout expectedCheckout = new Checkout();
586-
expectedCheckout.setId(CHECKOUT_ID);
587585
final CheckoutData expectedCheckoutData = new CheckoutData();
588586
expectedCheckoutData.setItems(Collections.singletonList(expectedItem));
589-
expectedCheckout.setData(expectedCheckoutData);
590587

591588
mockMvc.perform(get("/checkouts/"+CHECKOUT_ID+"/items/CCD-123456-123456")
592589
.header(REQUEST_ID_HEADER_NAME, TOKEN_REQUEST_ID_VALUE)
@@ -596,7 +593,7 @@ void getCheckoutItem() throws Exception {
596593
.header(ERIC_AUTHORISED_TOKEN_PERMISSIONS, String.format(TOKEN_PERMISSION_VALUE, Permission.Value.READ))
597594
.contentType(MediaType.APPLICATION_JSON))
598595
.andExpect(status().isOk())
599-
.andExpect(content().json(mapper.writeValueAsString(expectedCheckout)));
596+
.andExpect(content().json(mapper.writeValueAsString(expectedCheckoutData)));
600597
}
601598

602599
@DisplayName("Get checkout item returns HTTP 404 Not Found if no matching item ID")

0 commit comments

Comments
 (0)