feat(tickets): ticket codes on payment, ticket state and lookup by code
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
This commit is contained in:
1 parent
d56d0c3450
commit
1d6b265fd2
9 files changed
+389
-3
No files matched your search
@@ -17,7 +17,7 @@ Design: `design.md` (technical contracts) and `docs/superpowers/specs/2026-12-04
|
||||
|
||||
## 2. services-counter
|
||||
|
||||
- [ ] 2.1 Ticket codes, ticket state and the ticket lookups.
|
||||
- [x] 2.1 Ticket codes, ticket state and the ticket lookups.
|
||||
- Depends on: 1.1
|
||||
- Tests first:
|
||||
- **Codes:**
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.solvway.services.counter.controller;
|
||||
|
||||
import com.solvway.services.counter.service.TicketService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/** Tickets (add-event-tickets). byCode is a public path; mobile-api checks the code's shape first. */
|
||||
@RestController
|
||||
@RequestMapping("/counter/ticket")
|
||||
@AllArgsConstructor
|
||||
public class TicketController {
|
||||
private final TicketService service;
|
||||
|
||||
@GetMapping("/byCode/{code}")
|
||||
public TicketService.TicketView byCode(@PathVariable String code) {
|
||||
return service.byCode(code);
|
||||
}
|
||||
}
|
||||
@@ -63,4 +63,13 @@ public class Ticket {
|
||||
|
||||
@Column(name = "checked_in_by")
|
||||
private String checkedInBy;
|
||||
|
||||
@Column(name = "attendee_named_at")
|
||||
private LocalDateTime attendeeNamedAt;
|
||||
|
||||
@Column(name = "attendee_consent_at")
|
||||
private LocalDateTime attendeeConsentAt;
|
||||
|
||||
@Column(name = "attendee_notice_id")
|
||||
private Long attendeeNoticeId;
|
||||
}
|
||||
+2
@@ -22,6 +22,8 @@ public interface TicketRepository extends JpaRepository<Ticket, Long> {
|
||||
|
||||
List<Ticket> findByOrderIdOrderByIdAsc(long orderId);
|
||||
|
||||
java.util.Optional<Ticket> findByCode(String code);
|
||||
|
||||
/** Active tickets per order for one page of the staff list: one query, no N+1. */
|
||||
@Query("select new com.solvway.services.counter.repo.TicketCount(t.orderId, count(t)) from Ticket t"
|
||||
+ " where t.orderId in :orderIds and t.status = 'ACTIVE' group by t.orderId")
|
||||
|
||||
+15
-2
@@ -76,14 +76,26 @@ public class TicketOrderService {
|
||||
|
||||
/** The public order page: the buyer's name but no other personal details. */
|
||||
public record OrderView(long companyId, Long eventUuid, String reference, String status, String buyerName, int totalSen,
|
||||
LocalDateTime holdUntil, LocalDateTime createdAt, List<LineView> lines) {}
|
||||
LocalDateTime holdUntil, LocalDateTime createdAt, List<LineView> lines, List<OrderTicket> tickets) {}
|
||||
|
||||
/** add-event-tickets: a Paid order's ticket on its order page; never the attendee's contact. */
|
||||
public record OrderTicket(long id, String typeName, String attendeeName, String code, String state, LocalDateTime checkedInAt) {}
|
||||
|
||||
public OrderView byToken(String token) {
|
||||
ShopOrder o = orders.findByToken(token).orElseThrow(() -> status(HttpStatus.NOT_FOUND, "ORDER_NOT_FOUND"));
|
||||
List<LineView> views = lines.findByOrderIdOrderByIdAsc(o.getId()).stream()
|
||||
.map(l -> new LineView(l.getName(), l.getUnitPriceSen(), l.getQuantity())).toList();
|
||||
List<OrderTicket> paid = List.of();
|
||||
if (ShopOrder.PAID.equals(o.getStatus())) {
|
||||
Map<Long, String> names = lines.findByOrderIdOrderByIdAsc(o.getId()).stream()
|
||||
.collect(Collectors.toMap(ShopOrderLine::getId, ShopOrderLine::getName));
|
||||
paid = tickets.findByOrderIdOrderByIdAsc(o.getId()).stream().filter(t -> Ticket.ACTIVE.equals(t.getStatus()))
|
||||
.map(t -> new OrderTicket(t.getId(), names.get(t.getOrderLineId()), t.getAttendeeName(), t.getCode(),
|
||||
TicketState.of(o, t), t.getCheckedInAt()))
|
||||
.toList();
|
||||
}
|
||||
return new OrderView(o.getCompanyId(), o.getEventUuid(), o.getReference(), o.getStatus(), o.getBuyerName(), o.getTotalSen(),
|
||||
o.getHoldUntil(), o.getCreatedAt(), views);
|
||||
o.getHoldUntil(), o.getCreatedAt(), views, paid);
|
||||
}
|
||||
|
||||
public Result request(Request r) {
|
||||
@@ -175,6 +187,7 @@ public class TicketOrderService {
|
||||
ticket.setOrderId(o.getId());
|
||||
ticket.setOrderLineId(line.getId());
|
||||
ticket.setTicketTypeId(t.getId());
|
||||
if (total == 0) ticket.setCode(TicketState.newCode()); // add-event-tickets: a free order is Paid at once
|
||||
tickets.save(ticket);
|
||||
}
|
||||
views.add(new LineView(t.getName(), t.getPriceSen(), l.quantity()));
|
||||
|
||||
+6
@@ -110,6 +110,12 @@ public class TicketOrderStaffService {
|
||||
o.setPaymentRef(ref);
|
||||
o.setLastEmail(TicketOrderMailer.PAID);
|
||||
orders.save(o);
|
||||
for (Ticket t : tickets.findByOrderIdOrderByIdAsc(o.getId())) { // add-event-tickets: the codes come with payment
|
||||
if (Ticket.ACTIVE.equals(t.getStatus()) && t.getCode() == null) {
|
||||
t.setCode(TicketState.newCode());
|
||||
tickets.save(t);
|
||||
}
|
||||
}
|
||||
mailer.send(o, TicketOrderMailer.PAID);
|
||||
}
|
||||
|
||||
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package com.solvway.services.counter.service;
|
||||
|
||||
import com.solvway.services.counter.repo.ShopOrderLineRepository;
|
||||
import com.solvway.services.counter.repo.ShopOrderRepository;
|
||||
import com.solvway.services.counter.repo.TicketRepository;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.solvway.services.counter.model.ShopOrder;
|
||||
import com.solvway.services.counter.model.ShopOrderLine;
|
||||
import com.solvway.services.counter.model.Ticket;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/** add-event-tickets: tickets by their code. */
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class TicketService {
|
||||
private final TicketRepository tickets;
|
||||
private final ShopOrderRepository orders;
|
||||
private final ShopOrderLineRepository lines;
|
||||
|
||||
/** The public ticket page: no buyer details and no attendee contact. */
|
||||
public record TicketView(long companyId, long eventUuid, String typeName, String attendeeFirstName, boolean named, String state,
|
||||
LocalDateTime checkedInAt) {}
|
||||
|
||||
public TicketView byCode(String code) {
|
||||
Ticket t = ticket(code);
|
||||
ShopOrder o = orders.findById(t.getOrderId()).orElseThrow(TicketService::notFound);
|
||||
String typeName = lines.findById(t.getOrderLineId()).map(ShopOrderLine::getName).orElse(null);
|
||||
return new TicketView(t.getCompanyId(), t.getEventUuid(), typeName, firstName(t.getAttendeeName()), t.getAttendeeName() != null,
|
||||
TicketState.of(o, t), t.getCheckedInAt());
|
||||
}
|
||||
|
||||
Ticket ticket(String code) {
|
||||
if (code == null) throw notFound();
|
||||
return tickets.findByCode(code).orElseThrow(TicketService::notFound);
|
||||
}
|
||||
|
||||
static ResponseStatusException notFound() {
|
||||
return new ResponseStatusException(HttpStatus.NOT_FOUND, "TICKET_NOT_FOUND");
|
||||
}
|
||||
|
||||
static String firstName(String name) {
|
||||
if (name == null || name.isBlank()) return null;
|
||||
String t = name.strip();
|
||||
int sp = t.indexOf(' ');
|
||||
return sp < 0 ? t : t.substring(0, sp);
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.solvway.services.counter.service;
|
||||
|
||||
import com.solvway.services.counter.model.ShopOrder;
|
||||
import com.solvway.services.counter.model.Ticket;
|
||||
|
||||
/** add-event-tickets: one ticket's state, the single rule the ticket page, the door and self check-in all use. */
|
||||
public final class TicketState {
|
||||
public static final String VALID = "VALID";
|
||||
public static final String CHECKED_IN = "CHECKED_IN";
|
||||
public static final String AWAITING = "AWAITING";
|
||||
public static final String ORDER_CANCELLED = "ORDER_CANCELLED";
|
||||
public static final String ORDER_EXPIRED = "ORDER_EXPIRED";
|
||||
public static final String TICKET_CANCELLED = "TICKET_CANCELLED";
|
||||
|
||||
private TicketState() {}
|
||||
|
||||
public static String of(ShopOrder order, Ticket ticket) {
|
||||
if (Ticket.CANCELLED.equals(ticket.getStatus())) return TICKET_CANCELLED;
|
||||
return switch (order.getStatus()) {
|
||||
case ShopOrder.PAID -> ticket.getCheckedInAt() != null ? CHECKED_IN : VALID;
|
||||
case ShopOrder.CANCELLED -> ORDER_CANCELLED;
|
||||
case ShopOrder.EXPIRED -> ORDER_EXPIRED;
|
||||
default -> AWAITING;
|
||||
};
|
||||
}
|
||||
|
||||
/** A new ticket code: 22 URL-safe characters, as the other link tokens. */
|
||||
public static String newCode() {
|
||||
return RegistrationLinkService.newToken();
|
||||
}
|
||||
}
|
||||
+252
@@ -0,0 +1,252 @@
|
||||
package com.solvway.services.counter.service;
|
||||
|
||||
import com.solvway.services.counter.model.Event;
|
||||
import com.solvway.services.counter.model.ShopOrder;
|
||||
import com.solvway.services.counter.model.ShopOrderLine;
|
||||
import com.solvway.services.counter.model.Ticket;
|
||||
import com.solvway.services.counter.model.TicketType;
|
||||
import com.solvway.services.counter.repo.EventGuestRepository;
|
||||
import com.solvway.services.counter.repo.EventLeadRepository;
|
||||
import com.solvway.services.counter.repo.EventRepository;
|
||||
import com.solvway.services.counter.repo.ShopOrderLineRepository;
|
||||
import com.solvway.services.counter.repo.ShopOrderRepository;
|
||||
import com.solvway.services.counter.repo.TicketRepository;
|
||||
import com.solvway.services.counter.repo.TicketTypeRepository;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.lenient;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/** add-event-tickets: codes on payment, ticket state, the code lookup and the order page's tickets (spec: Ticket Codes, Ticket Page,
|
||||
* Invalid Ticket Links, Tickets On The Order Page). */
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class TicketCodesTest {
|
||||
private static final long COMPANY = 7L;
|
||||
private static final long EVENT = 900L;
|
||||
private static final LocalDate TODAY = LocalDate.now(ZoneId.of("Asia/Kuala_Lumpur"));
|
||||
private static final String CODE_SHAPE = "[A-Za-z0-9_-]{22}";
|
||||
|
||||
@Mock private EventRepository events;
|
||||
@Mock private TicketTypeRepository types;
|
||||
@Mock private TicketRepository tickets;
|
||||
@Mock private ShopOrderRepository orders;
|
||||
@Mock private ShopOrderLineRepository lines;
|
||||
@Mock private EventGuestRepository guests;
|
||||
@Mock private EventLeadRepository eventLeads;
|
||||
@Mock private RegistrationService registration;
|
||||
@Mock private TicketOrderMailer mailer;
|
||||
|
||||
private TicketOrderService orderService;
|
||||
private TicketOrderStaffService staff;
|
||||
private TicketService ticketService;
|
||||
private final List<Ticket> saved = new ArrayList<>();
|
||||
private ShopOrder order;
|
||||
private ShopOrderLine line;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
TicketTypeService typeService = new TicketTypeService(events, types, tickets, lines);
|
||||
orderService = new TicketOrderService(new TransactionTemplate(mock(PlatformTransactionManager.class)), events, typeService, types,
|
||||
orders, lines, tickets, guests, eventLeads, registration, mailer);
|
||||
staff = new TicketOrderStaffService(events, typeService, types, tickets, orders, lines, mailer);
|
||||
ticketService = new TicketService(tickets, orders, lines);
|
||||
Event event = new Event();
|
||||
event.setUuid(EVENT);
|
||||
event.setCompanyId(COMPANY);
|
||||
event.setDateStart(TODAY.plusDays(7).atTime(9, 0));
|
||||
event.setDateEnd(TODAY.plusDays(8).atTime(18, 0));
|
||||
event.setTicketsEnabled(true);
|
||||
event.setHoldDays(3);
|
||||
lenient().when(events.lockByUuid(EVENT)).thenReturn(Optional.of(event));
|
||||
TicketType free = new TicketType();
|
||||
free.setId(5L);
|
||||
free.setCompanyId(COMPANY);
|
||||
free.setEventUuid(EVENT);
|
||||
free.setName("Community pass");
|
||||
free.setQuantity(50);
|
||||
free.setEnabled(true);
|
||||
TicketType general = new TicketType();
|
||||
general.setId(2L);
|
||||
general.setCompanyId(COMPANY);
|
||||
general.setEventUuid(EVENT);
|
||||
general.setName("General");
|
||||
general.setPriceSen(25000);
|
||||
general.setQuantity(50);
|
||||
general.setEnabled(true);
|
||||
lenient().when(types.findByEventUuidOrderBySortAscIdAsc(EVENT)).thenReturn(List.of(general, free));
|
||||
lenient().when(orders.saveAndFlush(any(ShopOrder.class))).thenAnswer(i -> {
|
||||
ShopOrder o = i.getArgument(0);
|
||||
o.setId(300L);
|
||||
return o;
|
||||
});
|
||||
lenient().when(orders.save(any(ShopOrder.class))).thenAnswer(i -> i.getArgument(0));
|
||||
lenient().when(lines.save(any(ShopOrderLine.class))).thenAnswer(i -> {
|
||||
ShopOrderLine l = i.getArgument(0);
|
||||
l.setId(400L);
|
||||
return l;
|
||||
});
|
||||
lenient().when(tickets.save(any(Ticket.class))).thenAnswer(i -> {
|
||||
saved.add(i.getArgument(0));
|
||||
return i.getArgument(0);
|
||||
});
|
||||
lenient().when(registration.register(any())).thenReturn(new RegistrationService.RegisterResult("CREATED", null));
|
||||
|
||||
order = new ShopOrder();
|
||||
order.setId(300L);
|
||||
order.setCompanyId(COMPANY);
|
||||
order.setEventUuid(EVENT);
|
||||
order.setReference("T-7K3M9Q");
|
||||
order.setStatus(ShopOrder.AWAITING);
|
||||
order.setBuyerName("Aisyah Rahman");
|
||||
order.setBuyerEmail("a@example.test");
|
||||
lenient().when(orders.findById(300L)).thenReturn(Optional.of(order));
|
||||
line = new ShopOrderLine();
|
||||
line.setId(400L);
|
||||
line.setOrderId(300L);
|
||||
line.setItemId(2L);
|
||||
line.setName("General");
|
||||
line.setUnitPriceSen(25000);
|
||||
line.setQuantity(2);
|
||||
lenient().when(lines.findByOrderIdOrderByIdAsc(300L)).thenReturn(List.of(line));
|
||||
lenient().when(lines.findById(400L)).thenReturn(Optional.of(line));
|
||||
}
|
||||
|
||||
private static TicketOrderService.Request request(long typeId, int qty) {
|
||||
return new TicketOrderService.Request(COMPANY, EVENT, List.of(new TicketOrderService.LineRequest(typeId, qty)), "Aisyah",
|
||||
"a@example.test", null, null, 77L, LocalDateTime.now(), null, null, null, null);
|
||||
}
|
||||
|
||||
private static Ticket ticket(long id, String status) {
|
||||
Ticket t = new Ticket();
|
||||
t.setId(id);
|
||||
t.setCompanyId(COMPANY);
|
||||
t.setEventUuid(EVENT);
|
||||
t.setOrderId(300L);
|
||||
t.setOrderLineId(400L);
|
||||
t.setTicketTypeId(2L);
|
||||
t.setStatus(status);
|
||||
return t;
|
||||
}
|
||||
|
||||
@Test
|
||||
void aFreeOrdersTicketsGetDistinctCodesAtOnce() {
|
||||
orderService.request(request(5L, 3));
|
||||
assertThat(saved).hasSize(3).allSatisfy(t -> assertThat(t.getCode()).matches(CODE_SHAPE));
|
||||
assertThat(new HashSet<>(saved.stream().map(Ticket::getCode).toList())).hasSize(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
void anAwaitingOrdersTicketsHaveNoCode() {
|
||||
orderService.request(request(2L, 2));
|
||||
assertThat(saved).hasSize(2).allSatisfy(t -> assertThat(t.getCode()).isNull());
|
||||
}
|
||||
|
||||
@Test
|
||||
void markPaidGivesEachActiveTicketACode() {
|
||||
Ticket a = ticket(1L, Ticket.ACTIVE), b = ticket(2L, Ticket.ACTIVE), c = ticket(3L, Ticket.CANCELLED);
|
||||
when(tickets.findByOrderIdOrderByIdAsc(300L)).thenReturn(List.of(a, b, c));
|
||||
staff.markPaid(new TicketOrderStaffService.PayRequest(COMPANY, EVENT, 300L, null, "staff1"));
|
||||
assertThat(a.getCode()).matches(CODE_SHAPE);
|
||||
assertThat(b.getCode()).matches(CODE_SHAPE).isNotEqualTo(a.getCode());
|
||||
assertThat(c.getCode()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void anExpiredOrderMarkedPaidGetsCodes() {
|
||||
order.setStatus(ShopOrder.EXPIRED);
|
||||
Ticket a = ticket(1L, Ticket.ACTIVE);
|
||||
when(tickets.findByOrderIdOrderByIdAsc(300L)).thenReturn(List.of(a));
|
||||
staff.markPaid(new TicketOrderStaffService.PayRequest(COMPANY, EVENT, 300L, null, "staff1"));
|
||||
assertThat(a.getCode()).matches(CODE_SHAPE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void ticketStateCoversEveryCase() {
|
||||
Ticket t = ticket(1L, Ticket.ACTIVE);
|
||||
order.setStatus(ShopOrder.PAID);
|
||||
assertThat(TicketState.of(order, t)).isEqualTo(TicketState.VALID);
|
||||
t.setCheckedInAt(LocalDateTime.now());
|
||||
assertThat(TicketState.of(order, t)).isEqualTo(TicketState.CHECKED_IN);
|
||||
t.setCheckedInAt(null);
|
||||
t.setStatus(Ticket.CANCELLED);
|
||||
assertThat(TicketState.of(order, t)).isEqualTo(TicketState.TICKET_CANCELLED);
|
||||
t.setStatus(Ticket.ACTIVE);
|
||||
order.setStatus(ShopOrder.AWAITING);
|
||||
assertThat(TicketState.of(order, t)).isEqualTo(TicketState.AWAITING);
|
||||
order.setStatus(ShopOrder.CANCELLED);
|
||||
assertThat(TicketState.of(order, t)).isEqualTo(TicketState.ORDER_CANCELLED);
|
||||
order.setStatus(ShopOrder.EXPIRED);
|
||||
assertThat(TicketState.of(order, t)).isEqualTo(TicketState.ORDER_EXPIRED);
|
||||
}
|
||||
|
||||
@Test
|
||||
void byCodeShowsTheTicketWithoutContactDetails() {
|
||||
order.setStatus(ShopOrder.PAID);
|
||||
Ticket t = ticket(1L, Ticket.ACTIVE);
|
||||
t.setCode("abcdefghijklmnopqrstuv");
|
||||
t.setAttendeeName("Tan Mei Ling");
|
||||
t.setAttendeeEmail("tan@example.test");
|
||||
t.setAttendeeMobileE164("+60125550101");
|
||||
when(tickets.findByCode("abcdefghijklmnopqrstuv")).thenReturn(Optional.of(t));
|
||||
TicketService.TicketView v = ticketService.byCode("abcdefghijklmnopqrstuv");
|
||||
assertThat(v.companyId()).isEqualTo(COMPANY);
|
||||
assertThat(v.eventUuid()).isEqualTo(EVENT);
|
||||
assertThat(v.typeName()).isEqualTo("General");
|
||||
assertThat(v.attendeeFirstName()).isEqualTo("Tan");
|
||||
assertThat(v.named()).isTrue();
|
||||
assertThat(v.state()).isEqualTo(TicketState.VALID);
|
||||
assertThat(v.toString()).doesNotContain("tan@example.test", "+60125550101", "Aisyah");
|
||||
}
|
||||
|
||||
@Test
|
||||
void anUnknownCodeIsNotFound() {
|
||||
when(tickets.findByCode("zzzzzzzzzzzzzzzzzzzzzz")).thenReturn(Optional.empty());
|
||||
assertThatThrownBy(() -> ticketService.byCode("zzzzzzzzzzzzzzzzzzzzzz")).isInstanceOfSatisfying(ResponseStatusException.class, e -> {
|
||||
assertThat(e.getStatusCode().value()).isEqualTo(404);
|
||||
assertThat(e.getReason()).isEqualTo("TICKET_NOT_FOUND");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void thePaidOrderPageListsTicketsWithoutContacts() {
|
||||
order.setStatus(ShopOrder.PAID);
|
||||
Ticket a = ticket(1L, Ticket.ACTIVE), b = ticket(2L, Ticket.ACTIVE), c = ticket(3L, Ticket.CANCELLED);
|
||||
a.setCode("aaaaaaaaaaaaaaaaaaaaaa");
|
||||
a.setAttendeeName("Tan Mei Ling");
|
||||
a.setAttendeeEmail("tan@example.test");
|
||||
b.setCode("bbbbbbbbbbbbbbbbbbbbbb");
|
||||
when(orders.findByToken("tokentokentokentokento")).thenReturn(Optional.of(order));
|
||||
when(tickets.findByOrderIdOrderByIdAsc(300L)).thenReturn(List.of(a, b, c));
|
||||
TicketOrderService.OrderView v = orderService.byToken("tokentokentokentokento");
|
||||
assertThat(v.tickets()).extracting(TicketOrderService.OrderTicket::id).containsExactly(1L, 2L);
|
||||
assertThat(v.tickets().get(0)).isEqualTo(new TicketOrderService.OrderTicket(1L, "General", "Tan Mei Ling", "aaaaaaaaaaaaaaaaaaaaaa",
|
||||
TicketState.VALID, null));
|
||||
assertThat(v.tickets().get(1).attendeeName()).isNull();
|
||||
assertThat(v.toString()).doesNotContain("tan@example.test");
|
||||
}
|
||||
|
||||
@Test
|
||||
void anUnpaidOrderPageHasNoTickets() {
|
||||
when(orders.findByToken("tokentokentokentokento")).thenReturn(Optional.of(order));
|
||||
assertThat(orderService.byToken("tokentokentokentokento").tickets()).isEmpty();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user