Skip to content

Commit

Permalink
Merge pull request #119 from Tiketeer/feat/DEV-322
Browse files Browse the repository at this point in the history
[DEV-322] 특정 ticketing 조회 마이그레이션
  • Loading branch information
punkryn authored Jun 18, 2024
2 parents 9951cd8 + 492bf52 commit 7904eee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public interface GetTicketing {
@Value("#{target.createdAt}")
LocalDateTime getCreatedAt();

@Value("#{target.owner}")
@Value("#{target.member.email}")
String getOwner();

@Value("#{target.thumbnailPath}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ void getTicketingSuccess() {
var member = testHelper.createMember(mockEmail);
var ticketings = createTicketings(member, 1);
var ticketing = ticketings.getFirst();
var stock = 10;
var purchasedStock = 2;
createTickets(ticketing, stock);
createPurchase(member, ticketing, purchasedStock);
createTickets(ticketing);

var command = GetTicketingCommandDto.builder().ticketingId(ticketing.getId()).build();

Expand All @@ -74,8 +71,8 @@ void getTicketingSuccess() {

// then
Assertions.assertThat(result.getTitle()).isEqualTo("0");
// Assertions.assertThat(result.getStock()).isEqualTo(stock);
// Assertions.assertThat(result.getRemainStock()).isEqualTo(stock - purchasedStock);
Assertions.assertThat(result.getTickets().size()).isEqualTo(3);
Assertions.assertThat(result.getTickets().getFirst().getStock()).isEqualTo(10);
Assertions.assertThat(result.getOwner()).isEqualTo(member.getEmail());

}
Expand All @@ -100,15 +97,14 @@ private List<Ticketing> createTicketings(Member member, int count) {
return ticketingRepository.saveAll(ticketings);
}

private List<Ticket> createTickets(Ticketing ticketing, int stock) {
return ticketRepository.saveAll(Arrays.stream(new int[stock])
.mapToObj(i -> Ticket.builder().ticketing(ticketing).build())
.toList());
private List<Ticket> createTickets(Ticketing ticketing) {
return ticketRepository.saveAll(
Arrays.asList(
new Ticket(3000, 10, 10, "Gold", "", ticketing),
new Ticket(2000, 10, 10, "Silver", "", ticketing),
new Ticket(3000, 10, 10, "Bronze", "", ticketing)
)
);
}

private Purchase createPurchase(Member member, Ticketing ticketing, int count) {
var purchase = purchaseRepository.save(Purchase.builder().member(member).build());
var tickets = ticketRepository.findByTicketingIdOrderById(ticketing.getId(), Limit.of(count));
return purchase;
}
}

0 comments on commit 7904eee

Please sign in to comment.