Skip to content

Commit

Permalink
GetPurchaseTickets EP 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
dla0510 committed Jun 11, 2024
1 parent 5bf67fd commit e763745
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 272 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
Expand All @@ -20,9 +19,6 @@
import com.tiketeer.Tiketeer.domain.purchase.controller.dto.PostPurchaseResponseDto;
import com.tiketeer.Tiketeer.domain.purchase.usecase.CreatePurchaseUseCase;
import com.tiketeer.Tiketeer.domain.purchase.usecase.DeletePurchaseItemsUseCase;
import com.tiketeer.Tiketeer.domain.purchase.usecase.GetPurchaseTicketsUseCase;
import com.tiketeer.Tiketeer.domain.purchase.usecase.dto.GetPurchaseTicketsCommandDto;
import com.tiketeer.Tiketeer.domain.purchase.usecase.dto.GetPurchaseTicketsResponseDto;
import com.tiketeer.Tiketeer.response.ApiResponse;

import jakarta.validation.Valid;
Expand All @@ -32,16 +28,13 @@
public class PurchaseController {
private final CreatePurchaseUseCase createPurchaseUseCase;
private final DeletePurchaseItemsUseCase deletePurchaseItemsUseCase;
private final GetPurchaseTicketsUseCase getPurchaseTicketsUseCase;
private final SecurityContextHelper securityContextHelper;

@Autowired
PurchaseController(CreatePurchaseUseCase createPurchaseUseCase,
DeletePurchaseItemsUseCase deletePurchaseItemsUseCase, SecurityContextHelper securityContextHelper,
GetPurchaseTicketsUseCase getPurchaseTicketsUseCase) {
DeletePurchaseItemsUseCase deletePurchaseItemsUseCase, SecurityContextHelper securityContextHelper) {
this.createPurchaseUseCase = createPurchaseUseCase;
this.deletePurchaseItemsUseCase = deletePurchaseItemsUseCase;
this.getPurchaseTicketsUseCase = getPurchaseTicketsUseCase;
this.securityContextHelper = securityContextHelper;
}

Expand All @@ -62,17 +55,4 @@ public ResponseEntity<?> deletePurchaseItems(@PathVariable UUID purchaseId,
deletePurchaseItemsUseCase.deletePurchaseItems(request.convertToDto(memberEmail, purchaseId));
return ResponseEntity.status(HttpStatus.OK).build();
}

@GetMapping("/{purchaseId}/tickets")
public ResponseEntity<ApiResponse<GetPurchaseTicketsResponseDto>> getPurchaseTickets(
@PathVariable UUID purchaseId) {

var memberEmail = securityContextHelper.getEmailInToken();
var result = getPurchaseTicketsUseCase.getPurchaseTickets(
new GetPurchaseTicketsCommandDto(purchaseId, memberEmail));
var responseBody = ApiResponse.wrap(GetPurchaseTicketsResponseDto.convertFromDto(result));

return ResponseEntity.status(HttpStatus.OK).body(responseBody);
}

}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@
import com.tiketeer.Tiketeer.domain.purchase.repository.PurchaseItemRepository;
import com.tiketeer.Tiketeer.domain.purchase.repository.PurchaseRepository;
import com.tiketeer.Tiketeer.domain.purchase.usecase.dto.CreatePurchaseCommandDto;
import com.tiketeer.Tiketeer.domain.purchase.usecase.dto.GetPurchaseTicketsResponseDto;
import com.tiketeer.Tiketeer.domain.role.constant.RoleEnum;
import com.tiketeer.Tiketeer.domain.ticket.repository.TicketRepository;
import com.tiketeer.Tiketeer.domain.ticketing.TicketingTestHelper;
import com.tiketeer.Tiketeer.infra.redis.RedisService;
import com.tiketeer.Tiketeer.response.ApiResponse;
import com.tiketeer.Tiketeer.testhelper.RedisTestHelper;
import com.tiketeer.Tiketeer.testhelper.TestHelper;

Expand Down Expand Up @@ -402,42 +400,4 @@ void deletePurchaseAllTicketsSuccess() throws Exception {
assertThat(purchaseRepository.findById(purchase.getId())).isEmpty();
assertThat(purchaseItemRepository.findAll().size()).isEqualTo(0);
}

@Test
@DisplayName("티켓팅 및 티켓 생성 및 구매 > 구매 하위 티켓 목록 조회 > 성공")
@Transactional
void getPurchaseTicketsSuccess() throws Exception {
//given
String token = testHelper.registerAndLoginAndReturnAccessToken("[email protected]", RoleEnum.SELLER);
Member member = memberRepository.findAll().getFirst();
Cookie cookie = new Cookie(JwtMetadata.ACCESS_TOKEN, token);
var ticketing = ticketingTestHelper.createTicketing(member.getId(), 1, 1000, 4);
var ticketId = ticketRepository.findAll().getFirst().getId();
var purchaseTicketPair = purchaseTestHelper.createPurchase(member.getId(), ticketId, 2);
var purchase = purchaseTicketPair.getFirst();
var purchaseItems = purchaseTicketPair.getSecond();

// when
var result = mockMvc
.perform(get("/api/purchases/{purchaseId}/tickets", purchase.getId())
.contextPath("/api")
.contentType(MediaType.APPLICATION_JSON)
.characterEncoding("utf-8")
.cookie(cookie)
)
//then
.andExpect(status().isOk());
//then

ApiResponse<GetPurchaseTicketsResponseDto> response = testHelper.getDeserializedApiResponse(
result.andReturn().getResponse().getContentAsString(),
GetPurchaseTicketsResponseDto.class);

var ticketIds = response.getData().getTicketIds();
assertThat(ticketIds.size()).isEqualTo(2);
purchaseItems.forEach(ticket -> {
assertThat(ticketIds.contains(ticket.getId())).isTrue();
});
}

}

This file was deleted.

0 comments on commit e763745

Please sign in to comment.