Skip to content

Commit

Permalink
rest api: integration tests + handle error in release ticket #588
Browse files Browse the repository at this point in the history
  • Loading branch information
syjer committed Jun 12, 2019
1 parent bcb75ba commit 4e92f90
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,12 @@ public ResponseEntity<Boolean> sendTicketByEmail(@PathVariable("eventName") Stri
public ResponseEntity<Boolean> releaseTicket(@PathVariable("eventName") String eventName,
@PathVariable("ticketIdentifier") String ticketIdentifier) {
var oData = ticketReservationManager.fetchCompleteAndAssigned(eventName, ticketIdentifier);
oData.ifPresent(triple -> ticketReservationManager.releaseTicket(triple.getLeft(), triple.getMiddle(), triple.getRight()));
return ResponseEntity.ok(true);
try {
oData.ifPresent(triple -> ticketReservationManager.releaseTicket(triple.getLeft(), triple.getMiddle(), triple.getRight()));
return ResponseEntity.ok(true);
} catch (IllegalStateException ise) {
return ResponseEntity.badRequest().body(false);
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,11 +521,10 @@ public void reservationFlowTest() throws Exception {
assertEquals(fullTicketInfo.ticketCode(event.getPrivateKey()), qrCodeRead.getText());

//can only be done for free tickets
//var releaseTicketFailure = ticketApiV2Controller.releaseTicket(event.getShortName(), ticket.getUuid());
//assertEquals(HttpStatus.OK, releaseTicketFailure.getStatusCode());
//ticketFoundRes = ticketApiV2Controller.getTicketInfo(event.getShortName(), ticket.getUuid());
//
//assertEquals(HttpStatus.OK, ticketFoundRes.getStatusCode());
var releaseTicketFailure = ticketApiV2Controller.releaseTicket(event.getShortName(), ticket.getUuid());
assertEquals(HttpStatus.BAD_REQUEST, releaseTicketFailure.getStatusCode());
assertEquals(HttpStatus.OK, ticketApiV2Controller.getTicketInfo(event.getShortName(), ticket.getUuid()).getStatusCode());

}

}
Expand Down

0 comments on commit 4e92f90

Please sign in to comment.