Skip to content

Commit

Permalink
Move variable declaration into when clause
Browse files Browse the repository at this point in the history
  • Loading branch information
KjellBerlin committed Aug 28, 2024
1 parent ce310ef commit ae798c9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main/kotlin/com/carbonara/core/order/OrderQuery.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ class OrderQuery(

@GraphQLDescription("Get all paid orders of an user")
suspend fun paidOrders(userId: String): List<OrderDto> {
return orderService.getPaidOrdersByAuth0UserId(userId)
return orderService.getNonPendingOrdersByAuth0UserId(userId)
}
}
2 changes: 1 addition & 1 deletion src/main/kotlin/com/carbonara/core/order/OrderService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class OrderService(
}
}

suspend fun getPaidOrdersByAuth0UserId(
suspend fun getNonPendingOrdersByAuth0UserId(
auth0UserId: String
): List<OrderDto> {
return orderRepository.findAllByAuth0UserIdAndPaymentStatuses(
Expand Down
6 changes: 3 additions & 3 deletions src/test/kotlin/com/carbonara/core/order/OrderServiceTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class OrderServiceTest {
}

@Nested
inner class GetPaidAndFailedOrdersByAuth0UserIdTests {
inner class GetNonPendingOrdersByAuth0UserIdTests {

@Test
fun `Happy case`() {
Expand All @@ -154,7 +154,7 @@ class OrderServiceTest {
paymentStatuses = listOf(InternalPaymentStatus.PAID.name, InternalPaymentStatus.FAILED.name)
) } returns listOf(ORDER_DAO_PAID, ORDER_DAO_PAYMENT_FAILED).toFlux()

val result = runBlocking { orderService.getPaidOrdersByAuth0UserId(AUTH0_USER_ID) }
val result = runBlocking { orderService.getNonPendingOrdersByAuth0UserId(AUTH0_USER_ID) }
assertEquals(listOf(ORDER_DAO_PAID.toOrderDto(), ORDER_DAO_PAYMENT_FAILED.toOrderDto()), result)

coVerify(exactly = 1) { orderRepository.findAllByAuth0UserIdAndPaymentStatuses(
Expand All @@ -170,7 +170,7 @@ class OrderServiceTest {
paymentStatuses = listOf(InternalPaymentStatus.PAID.name, InternalPaymentStatus.FAILED.name)
) } returns emptyList<OrderDao>().toFlux()

val result = runBlocking { orderService.getPaidOrdersByAuth0UserId(AUTH0_USER_ID) }
val result = runBlocking { orderService.getNonPendingOrdersByAuth0UserId(AUTH0_USER_ID) }
assertEquals(emptyList<OrderDao>(), result)

coVerify(exactly = 1) { orderRepository.findAllByAuth0UserIdAndPaymentStatuses(
Expand Down

0 comments on commit ae798c9

Please sign in to comment.