From 28eb6decbbcaaf045f6fddff3902ea1f1693d2b2 Mon Sep 17 00:00:00 2001 From: Pietro Tota <115724836+pietro-tota@users.noreply.github.com> Date: Mon, 11 Mar 2024 09:46:57 +0100 Subject: [PATCH] fix: read correlation id also for transactions without requested authorization (#89) --- .../ecommerce/helpdesk/utils/ResponseBuilderV2.kt | 11 ++++------- .../EcommerceForTransactionV2DataProviderTest.kt | 4 +++- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/it/pagopa/ecommerce/helpdesk/utils/ResponseBuilderV2.kt b/src/main/kotlin/it/pagopa/ecommerce/helpdesk/utils/ResponseBuilderV2.kt index e0fae9c..4413c54 100644 --- a/src/main/kotlin/it/pagopa/ecommerce/helpdesk/utils/ResponseBuilderV2.kt +++ b/src/main/kotlin/it/pagopa/ecommerce/helpdesk/utils/ResponseBuilderV2.kt @@ -135,13 +135,10 @@ private fun getTransactionAuthRequestedData( private fun getTransactionActivatedData( baseTransaction: BaseTransaction ): TransactionActivatedData? = - when (baseTransaction) { - is BaseTransactionExpired -> - getTransactionActivatedData(baseTransaction.transactionAtPreviousState) - is BaseTransactionWithClosureError -> - getTransactionActivatedData(baseTransaction.transactionAtPreviousState) - is BaseTransactionWithRequestedAuthorization -> baseTransaction.transactionActivatedData - else -> null + if (baseTransaction is BaseTransactionWithPaymentToken) { + baseTransaction.transactionActivatedData + } else { + null } private fun getTransactionAuthCompletedData( diff --git a/src/test/kotlin/it/pagopa/ecommerce/helpdesk/dataproviders/mongo/EcommerceForTransactionV2DataProviderTest.kt b/src/test/kotlin/it/pagopa/ecommerce/helpdesk/dataproviders/mongo/EcommerceForTransactionV2DataProviderTest.kt index 6fa8629..98e9479 100644 --- a/src/test/kotlin/it/pagopa/ecommerce/helpdesk/dataproviders/mongo/EcommerceForTransactionV2DataProviderTest.kt +++ b/src/test/kotlin/it/pagopa/ecommerce/helpdesk/dataproviders/mongo/EcommerceForTransactionV2DataProviderTest.kt @@ -32,7 +32,6 @@ import it.pagopa.generated.ecommerce.helpdesk.model.* import java.time.ZonedDateTime import java.util.* import java.util.stream.Stream -import kotlin.collections.HashSet import org.junit.jupiter.api.AfterAll import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions.assertEquals @@ -234,6 +233,7 @@ class EcommerceForTransactionV2DataProviderTest { .authorizationCode(null) .paymentMethodName(null) .brand(null) + .correlationId(UUID.fromString(correlationId)) ) .paymentInfo( PaymentInfoDto() @@ -1147,6 +1147,7 @@ class EcommerceForTransactionV2DataProviderTest { .authorizationCode(null) .paymentMethodName(null) .brand(null) + .correlationId(UUID.fromString(correlationId)) ) .paymentInfo( PaymentInfoDto() @@ -1254,6 +1255,7 @@ class EcommerceForTransactionV2DataProviderTest { .authorizationCode(null) .paymentMethodName(null) .brand(null) + .correlationId(UUID.fromString(correlationId)) ) .paymentInfo( PaymentInfoDto()