Skip to content

Commit

Permalink
Add negative test case scenarios for GetPaymentRequestCommand and `…
Browse files Browse the repository at this point in the history
…PayPaymentRequestCommand`
  • Loading branch information
Abdulaziz-Hassan committed May 1, 2024
1 parent c6e2d23 commit 158bf1f
Showing 1 changed file with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,20 @@ void testGetPaymentRequest() {
() -> assertEquals(paymentRequest.getFreelancerId(), requestDTO.getFreelancerId()));
}

@Test
void testGetPaymentRequestNotFound() {
GetPaymentRequestRequest getPaymentRequest =
GetPaymentRequestRequest.builder().withPaymentRequestId("123").build();

GetPaymentRequestResponse response =
(GetPaymentRequestResponse)
template.convertSendAndReceive(ServiceQueueNames.PAYMENTS, getPaymentRequest);

assertNotNull(response);
assertEquals(HttpStatusCode.NOT_FOUND, response.getStatusCode());
assertNull(response.getRequest());
}

@Test
void testPayPaymentRequest() {
PaymentRequest paymentRequest =
Expand Down Expand Up @@ -317,4 +331,43 @@ void testPayPaymentRequest() {
() -> assertEquals(paymentRequest.getDescription(), walletTransaction.getDescription()),
() -> assertEquals(WalletTransactionType.CREDIT, walletTransaction.getTransactionType()));
}

@Test
void testPayPaymentRequestNotFound() {
PayPaymentRequestRequest payPaymentRequest =
PayPaymentRequestRequest.builder().withPaymentRequestId("123").build();

PayPaymentRequestResponse response =
(PayPaymentRequestResponse)
template.convertSendAndReceive(ServiceQueueNames.PAYMENTS, payPaymentRequest);

assertNotNull(response);
assertEquals(HttpStatusCode.NOT_FOUND, response.getStatusCode());
assertNull(response.getTransactionId());
assertNull(response.getTransactionStatus());
}

@Test
void testPayPaymentRequestFreelancerWalletNotFound() {
PaymentRequest paymentRequest =
PaymentRequest.builder()
.withAmount(1200)
.withDescription("Payment for services rendered")
.withClientId("3")
.withFreelancerId("4")
.build();
paymentRequestRepository.save(paymentRequest);

PayPaymentRequestRequest payPaymentRequest =
PayPaymentRequestRequest.builder().withPaymentRequestId(paymentRequest.getId()).build();

PayPaymentRequestResponse response =
(PayPaymentRequestResponse)
template.convertSendAndReceive(ServiceQueueNames.PAYMENTS, payPaymentRequest);

assertNotNull(response);
assertEquals(HttpStatusCode.INTERNAL_SERVER_ERROR, response.getStatusCode());
assertNull(response.getTransactionId());
assertNull(response.getTransactionStatus());
}
}

0 comments on commit 158bf1f

Please sign in to comment.