Skip to content

[Bug] Integrated test failure issue due to 'HoldingsNotFoundException'. #71

@Hugh-KR

Description

@Hugh-KR

Describe the bug

  • If a buyer has a new stock through a matching, the test fails by conducting verification before updating the quantity.

To Reproduce

  • Integrated test for actual orders.

Expected behavior

  • If you annotate the bottom part, it will be resolved.
       // domain/holdings
       public void updateHoldings(final Type type, final BigDecimal updatePrice, final BigDecimal updateQuantity) {
		// validateExistHoldings();
		if (Type.BUY.equals(type)) {
			updateBuyHoldings(updatePrice, updateQuantity);
		} else {
			updateSellHoldings(updateQuantity);
		}
	}

Screenshots
Image

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context

  • I don't think there will be a problem because we will perform verification of Seller in advance in 'OrderService'.
       // service/OrderService
       private Order createOrder(final OrderRequest request, final String username) {
		final Account account = memberRepository.getByUsername(username).getAccount();

		// 매도 시 보유 주식 확인 및 보유 주식 수량 검증 후 예약 매도 수량 설정
		if (request.type() == Type.SELL) {
			final Holdings holdings = holdingsRepository.findByAccountIdAndCompanyCode(account.getId(),
							request.companyCode())
					.orElseThrow(() -> new HoldingsNotFoundException("보유 주식이 없습니다."));
			holdings.validateExistHoldings();
			holdings.validateEnoughHoldings(request.totalQuantity());
			holdings.processReservedOrder(request.totalQuantity());
		}
		// 매수 시 주문 가능 잔액 검증 후 예약 매수 금액 설정
		else {
			// 매수 가능 잔액 검증
			account.validateDepositBalance(request.price().multiply(request.totalQuantity()));
			account.processReservedOrder(request.price().multiply(request.totalQuantity()));
		}

		// 예약 주문 생성(매수/매도)
		return new OrderDto(request).to(account);
	}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions