diff --git a/Dockerfile b/Dockerfile
index bce8c3bd..85a202e8 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,9 +1,13 @@
-FROM openjdk:17-slim as build
+FROM openjdk:17-jdk as build
WORKDIR /workspace/app
+RUN microdnf install git
+
COPY mvnw .
COPY .mvn .mvn
COPY pom.xml .
+#validate step will execute the scm plugin to perform checkout and installation of the pagopa-commons library
+RUN ./mvnw validate -DskipTests
RUN ./mvnw dependency:copy-dependencies
# RUN ./mvnw dependency:go-offline
diff --git a/pom.xml b/pom.xml
index daf7936d..f227dd4a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -27,6 +27,7 @@
**/it/pagopa/ecommerce/payment/requests/warmup/**/*
2.28.0
+ 0.7.3
@@ -96,6 +97,33 @@
lombok
true
+
+ it.pagopa
+ pagopa-ecommerce-commons
+ ${pagopa-ecommerce-commons.version}
+
+
+ org.springframework.boot
+ spring-boot-starter-data-mongodb-reactive
+
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+
+
+ com.azure.spring
+ spring-cloud-azure-dependencies
+
+
+ com.azure.spring
+ spring-cloud-azure-starter
+
+
+ com.azure.spring
+ spring-cloud-azure-starter-data-cosmos
+
+
+
org.springframework.boot
spring-boot-starter-test
@@ -157,6 +185,13 @@
jsr305
3.0.2
+
+ it.pagopa
+ pagopa-ecommerce-commons
+ ${pagopa-ecommerce-commons.version}
+ test-jar
+ test
+
@@ -377,6 +412,26 @@
+
+ org.apache.maven.plugins
+ maven-scm-plugin
+ 2.0.0-M3
+
+ true
+ scm:git:https://github.com/pagopa/pagopa-ecommerce-commons.git
+ tag
+ ${pagopa-ecommerce-commons.version}
+ install
+
+
+
+ validate
+
+ bootstrap
+
+
+
+
com.diffplug.spotless
spotless-maven-plugin
diff --git a/src/main/kotlin/it/pagopa/ecommerce/payment/requests/PagopaEcommercePaymentRequestsServiceApplication.kt b/src/main/kotlin/it/pagopa/ecommerce/payment/requests/PagopaEcommercePaymentRequestsServiceApplication.kt
index 495b8a8b..88fc6922 100644
--- a/src/main/kotlin/it/pagopa/ecommerce/payment/requests/PagopaEcommercePaymentRequestsServiceApplication.kt
+++ b/src/main/kotlin/it/pagopa/ecommerce/payment/requests/PagopaEcommercePaymentRequestsServiceApplication.kt
@@ -1,9 +1,19 @@
package it.pagopa.ecommerce.payment.requests
+import it.pagopa.ecommerce.commons.ConfigScan
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
+import org.springframework.context.annotation.Import
+import org.springframework.data.redis.repository.configuration.EnableRedisRepositories
-@SpringBootApplication class PagopaEcommercePaymentRequestsServiceApplication
+@SpringBootApplication
+@EnableRedisRepositories(
+ basePackages =
+ [
+ "it.pagopa.ecommerce.commons.repositories",
+ "it.pagopa.ecommerce.payment.requests.repositories"])
+@Import(ConfigScan::class)
+class PagopaEcommercePaymentRequestsServiceApplication
fun main(args: Array) {
runApplication(*args)
diff --git a/src/main/kotlin/it/pagopa/ecommerce/payment/requests/configurations/redis/RedisConfiguration.kt b/src/main/kotlin/it/pagopa/ecommerce/payment/requests/configurations/redis/RedisConfiguration.kt
deleted file mode 100644
index 936b476b..00000000
--- a/src/main/kotlin/it/pagopa/ecommerce/payment/requests/configurations/redis/RedisConfiguration.kt
+++ /dev/null
@@ -1,28 +0,0 @@
-package it.pagopa.ecommerce.payment.requests.configurations.redis
-
-import it.pagopa.ecommerce.payment.requests.configurations.redis.converters.rptId.RptIdReadingByteConverter
-import it.pagopa.ecommerce.payment.requests.configurations.redis.converters.rptId.RptIdReadingStringConverter
-import it.pagopa.ecommerce.payment.requests.configurations.redis.converters.rptId.RptIdWritingByteConverter
-import it.pagopa.ecommerce.payment.requests.configurations.redis.converters.rptId.RptIdWritingStringConverter
-import org.springframework.context.annotation.Bean
-import org.springframework.context.annotation.Configuration
-import org.springframework.data.redis.core.convert.RedisCustomConversions
-
-@Configuration
-class RedisConfiguration {
-
- @Bean
- fun redisCustomConversions(
- rptIdReadingByteConverter: RptIdReadingByteConverter,
- rptIdReadingStringConverter: RptIdReadingStringConverter,
- rptIdWritingByteConverter: RptIdWritingByteConverter,
- rptIdWritingStringConverter: RptIdWritingStringConverter,
- ) =
- RedisCustomConversions(
- listOf(
- rptIdReadingByteConverter,
- rptIdReadingStringConverter,
- rptIdWritingByteConverter,
- rptIdWritingStringConverter,
- ))
-}
diff --git a/src/main/kotlin/it/pagopa/ecommerce/payment/requests/configurations/redis/converters/rptId/RptIdReadingByteConverter.kt b/src/main/kotlin/it/pagopa/ecommerce/payment/requests/configurations/redis/converters/rptId/RptIdReadingByteConverter.kt
deleted file mode 100644
index 59ce3619..00000000
--- a/src/main/kotlin/it/pagopa/ecommerce/payment/requests/configurations/redis/converters/rptId/RptIdReadingByteConverter.kt
+++ /dev/null
@@ -1,15 +0,0 @@
-package it.pagopa.ecommerce.payment.requests.configurations.redis.converters.rptId
-
-import it.pagopa.ecommerce.payment.requests.domain.RptId
-import java.nio.charset.StandardCharsets
-import org.springframework.core.convert.converter.Converter
-import org.springframework.data.convert.ReadingConverter
-import org.springframework.stereotype.Component
-
-@Component
-@ReadingConverter
-class RptIdReadingByteConverter : Converter {
- override fun convert(source: ByteArray): RptId {
- return RptId(String(source, StandardCharsets.UTF_8))
- }
-}
diff --git a/src/main/kotlin/it/pagopa/ecommerce/payment/requests/configurations/redis/converters/rptId/RptIdReadingStringConverter.kt b/src/main/kotlin/it/pagopa/ecommerce/payment/requests/configurations/redis/converters/rptId/RptIdReadingStringConverter.kt
deleted file mode 100644
index cf6b742d..00000000
--- a/src/main/kotlin/it/pagopa/ecommerce/payment/requests/configurations/redis/converters/rptId/RptIdReadingStringConverter.kt
+++ /dev/null
@@ -1,14 +0,0 @@
-package it.pagopa.ecommerce.payment.requests.configurations.redis.converters.rptId
-
-import it.pagopa.ecommerce.payment.requests.domain.RptId
-import org.springframework.core.convert.converter.Converter
-import org.springframework.data.convert.ReadingConverter
-import org.springframework.stereotype.Component
-
-@Component
-@ReadingConverter
-class RptIdReadingStringConverter : Converter {
- override fun convert(source: String): RptId {
- return RptId(source)
- }
-}
diff --git a/src/main/kotlin/it/pagopa/ecommerce/payment/requests/configurations/redis/converters/rptId/RptIdWritingByteConverter.kt b/src/main/kotlin/it/pagopa/ecommerce/payment/requests/configurations/redis/converters/rptId/RptIdWritingByteConverter.kt
deleted file mode 100644
index db52fafc..00000000
--- a/src/main/kotlin/it/pagopa/ecommerce/payment/requests/configurations/redis/converters/rptId/RptIdWritingByteConverter.kt
+++ /dev/null
@@ -1,15 +0,0 @@
-package it.pagopa.ecommerce.payment.requests.configurations.redis.converters.rptId
-
-import it.pagopa.ecommerce.payment.requests.domain.RptId
-import java.nio.charset.StandardCharsets
-import org.springframework.core.convert.converter.Converter
-import org.springframework.data.convert.WritingConverter
-import org.springframework.stereotype.Component
-
-@Component
-@WritingConverter
-class RptIdWritingByteConverter : Converter {
- override fun convert(source: RptId): ByteArray {
- return source.value.toByteArray(StandardCharsets.UTF_8)
- }
-}
diff --git a/src/main/kotlin/it/pagopa/ecommerce/payment/requests/configurations/redis/converters/rptId/RptIdWritingStringConverter.kt b/src/main/kotlin/it/pagopa/ecommerce/payment/requests/configurations/redis/converters/rptId/RptIdWritingStringConverter.kt
deleted file mode 100644
index 5b358514..00000000
--- a/src/main/kotlin/it/pagopa/ecommerce/payment/requests/configurations/redis/converters/rptId/RptIdWritingStringConverter.kt
+++ /dev/null
@@ -1,14 +0,0 @@
-package it.pagopa.ecommerce.payment.requests.configurations.redis.converters.rptId
-
-import it.pagopa.ecommerce.payment.requests.domain.RptId
-import org.springframework.core.convert.converter.Converter
-import org.springframework.data.convert.WritingConverter
-import org.springframework.stereotype.Component
-
-@Component
-@WritingConverter
-class RptIdWritingStringConverter : Converter {
- override fun convert(source: RptId): String {
- return source.value
- }
-}
diff --git a/src/main/kotlin/it/pagopa/ecommerce/payment/requests/domain/IdempotencyKey.kt b/src/main/kotlin/it/pagopa/ecommerce/payment/requests/domain/IdempotencyKey.kt
deleted file mode 100644
index f42158b3..00000000
--- a/src/main/kotlin/it/pagopa/ecommerce/payment/requests/domain/IdempotencyKey.kt
+++ /dev/null
@@ -1,57 +0,0 @@
-package it.pagopa.ecommerce.payment.requests.domain
-
-import java.util.regex.Pattern
-import org.springframework.data.annotation.PersistenceCreator
-
-class IdempotencyKey {
- val key: String
-
- constructor(pspFiscalCode: String, keyIdentifier: String) {
- validateComponents(pspFiscalCode, keyIdentifier)
- key = pspFiscalCode + "_" + keyIdentifier
- }
-
- @PersistenceCreator
- constructor(key: String) {
- val matches = key.split("_".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
- require(matches.size == 2) { "Key doesn't match format `\$pspFiscalCode_\$keyIdentifier`" }
- val pspFiscalCode = matches[0]
- val keyIdentifier = matches[1]
- validateComponents(pspFiscalCode, keyIdentifier)
- this.key = key
- }
-
- companion object {
- private val pspFiscalCodeRegex = Pattern.compile("\\d{11}")
- private val keyIdentifierRegex = Pattern.compile("[a-zA-Z\\d]{10}")
-
- private fun validateComponents(pspFiscalCode: String, keyIdentifier: String) {
- require(pspFiscalCodeRegex.matcher(pspFiscalCode).matches()) {
- "PSP fiscal code doesn't match regex: " + pspFiscalCodeRegex.pattern()
- }
-
- require(keyIdentifierRegex.matcher(keyIdentifier).matches()) {
- "Key identifier doesn't match regex: " + keyIdentifierRegex.pattern()
- }
- }
- }
-
- override fun equals(other: Any?): Boolean {
- if (this === other) return true
- if (javaClass != other?.javaClass) return false
-
- other as IdempotencyKey
-
- if (key != other.key) return false
-
- return true
- }
-
- override fun hashCode(): Int {
- return key.hashCode()
- }
-
- override fun toString(): String {
- return "IdempotencyKey(key='$key')"
- }
-}
diff --git a/src/main/kotlin/it/pagopa/ecommerce/payment/requests/domain/RptId.kt b/src/main/kotlin/it/pagopa/ecommerce/payment/requests/domain/RptId.kt
deleted file mode 100644
index 6d5268fe..00000000
--- a/src/main/kotlin/it/pagopa/ecommerce/payment/requests/domain/RptId.kt
+++ /dev/null
@@ -1,51 +0,0 @@
-package it.pagopa.ecommerce.payment.requests.domain
-
-import java.util.regex.Pattern
-
-class RptId(val value: String) {
- companion object {
- private val rptIdRegex = Pattern.compile("([a-zA-Z\\d]{29})")
- }
-
- // RtpId = CF(0,10)+NotID(11,28)
- // NotID = AuxDigit(0)+ApplicationCode(1,2)+CodiceIUV(3,18) || AuxDigit(0)+CodiceIUV(1,18)
- init {
- require(rptIdRegex.matcher(value).matches()) {
- "Ill-formed RPT id: " + value + ". Doesn't match format: " + rptIdRegex.pattern()
- }
- }
-
- val fiscalCode: String
- get() = value.substring(0, 11)
-
- val noticeId: String
- get() = value.substring(11)
-
- val auxDigit: String
- get() = noticeId.substring(0, 1)
-
- val applicationCode: String?
- get() = if ("0" == auxDigit) noticeId.substring(1, 3) else null
-
- val IUV: String
- get() = noticeId.substring(if (applicationCode != null) 3 else 1, 18)
-
- override fun toString(): String {
- return "RptId(value='$value')"
- }
-
- override fun equals(other: Any?): Boolean {
- if (this === other) return true
- if (javaClass != other?.javaClass) return false
-
- other as RptId
-
- if (value != other.value) return false
-
- return true
- }
-
- override fun hashCode(): Int {
- return value.hashCode()
- }
-}
diff --git a/src/main/kotlin/it/pagopa/ecommerce/payment/requests/repositories/PaymentInfo.kt b/src/main/kotlin/it/pagopa/ecommerce/payment/requests/repositories/PaymentInfo.kt
index e972d31f..86fe4547 100644
--- a/src/main/kotlin/it/pagopa/ecommerce/payment/requests/repositories/PaymentInfo.kt
+++ b/src/main/kotlin/it/pagopa/ecommerce/payment/requests/repositories/PaymentInfo.kt
@@ -1,6 +1,6 @@
package it.pagopa.ecommerce.payment.requests.repositories
-import it.pagopa.ecommerce.payment.requests.domain.RptId
+import it.pagopa.ecommerce.commons.domain.v1.RptId
import org.springframework.data.annotation.PersistenceCreator
data class PaymentInfo
diff --git a/src/main/kotlin/it/pagopa/ecommerce/payment/requests/repositories/PaymentRequestInfo.kt b/src/main/kotlin/it/pagopa/ecommerce/payment/requests/repositories/PaymentRequestInfo.kt
deleted file mode 100644
index 77c9a041..00000000
--- a/src/main/kotlin/it/pagopa/ecommerce/payment/requests/repositories/PaymentRequestInfo.kt
+++ /dev/null
@@ -1,22 +0,0 @@
-package it.pagopa.ecommerce.payment.requests.repositories
-
-import it.pagopa.ecommerce.payment.requests.domain.IdempotencyKey
-import it.pagopa.ecommerce.payment.requests.domain.RptId
-import org.springframework.data.annotation.Id
-import org.springframework.data.annotation.PersistenceCreator
-import org.springframework.data.redis.core.RedisHash
-
-@RedisHash(value = "keys", timeToLive = 10 * 60)
-class PaymentRequestInfo
-@PersistenceCreator
-constructor(
- @Id val id: RptId,
- val paFiscalCode: String?,
- val paName: String?,
- val description: String?,
- val amount: Int,
- val dueDate: String?,
- val paymentToken: String?,
- val idempotencyKey: IdempotencyKey?,
- val isCart: Boolean
-)
diff --git a/src/main/kotlin/it/pagopa/ecommerce/payment/requests/repositories/PaymentRequestInfoRepository.kt b/src/main/kotlin/it/pagopa/ecommerce/payment/requests/repositories/PaymentRequestInfoRepository.kt
deleted file mode 100644
index bc29ea29..00000000
--- a/src/main/kotlin/it/pagopa/ecommerce/payment/requests/repositories/PaymentRequestInfoRepository.kt
+++ /dev/null
@@ -1,6 +0,0 @@
-package it.pagopa.ecommerce.payment.requests.repositories
-
-import it.pagopa.ecommerce.payment.requests.domain.RptId
-import org.springframework.data.repository.CrudRepository
-
-interface PaymentRequestInfoRepository : CrudRepository
diff --git a/src/main/kotlin/it/pagopa/ecommerce/payment/requests/services/CartService.kt b/src/main/kotlin/it/pagopa/ecommerce/payment/requests/services/CartService.kt
index b49b61f6..e2f586c7 100644
--- a/src/main/kotlin/it/pagopa/ecommerce/payment/requests/services/CartService.kt
+++ b/src/main/kotlin/it/pagopa/ecommerce/payment/requests/services/CartService.kt
@@ -1,5 +1,6 @@
package it.pagopa.ecommerce.payment.requests.services
+import it.pagopa.ecommerce.commons.domain.v1.RptId
import it.pagopa.ecommerce.generated.nodoperpm.v1.dto.CheckPositionDto
import it.pagopa.ecommerce.generated.nodoperpm.v1.dto.CheckPositionResponseDto
import it.pagopa.ecommerce.generated.nodoperpm.v1.dto.ListelementRequestDto
@@ -7,7 +8,6 @@ import it.pagopa.ecommerce.generated.payment.requests.server.model.CartRequestDt
import it.pagopa.ecommerce.generated.payment.requests.server.model.CartRequestReturnUrlsDto
import it.pagopa.ecommerce.generated.payment.requests.server.model.PaymentNoticeDto
import it.pagopa.ecommerce.payment.requests.client.NodoPerPmClient
-import it.pagopa.ecommerce.payment.requests.domain.RptId
import it.pagopa.ecommerce.payment.requests.exceptions.CartNotFoundException
import it.pagopa.ecommerce.payment.requests.exceptions.RestApiException
import it.pagopa.ecommerce.payment.requests.repositories.CartInfo
diff --git a/src/main/kotlin/it/pagopa/ecommerce/payment/requests/services/PaymentRequestsService.kt b/src/main/kotlin/it/pagopa/ecommerce/payment/requests/services/PaymentRequestsService.kt
index 212b015c..2daecec6 100644
--- a/src/main/kotlin/it/pagopa/ecommerce/payment/requests/services/PaymentRequestsService.kt
+++ b/src/main/kotlin/it/pagopa/ecommerce/payment/requests/services/PaymentRequestsService.kt
@@ -1,16 +1,16 @@
package it.pagopa.ecommerce.payment.requests.services
+import it.pagopa.ecommerce.commons.domain.v1.RptId
+import it.pagopa.ecommerce.commons.repositories.PaymentRequestInfo
+import it.pagopa.ecommerce.commons.repositories.PaymentRequestsInfoRepository
import it.pagopa.ecommerce.generated.payment.requests.server.model.PaymentRequestsGetResponseDto
import it.pagopa.ecommerce.generated.transactions.model.CtQrCode
import it.pagopa.ecommerce.generated.transactions.model.StOutcome
import it.pagopa.ecommerce.generated.transactions.model.VerifyPaymentNoticeRes
import it.pagopa.ecommerce.payment.requests.client.NodeForPspClient
import it.pagopa.ecommerce.payment.requests.configurations.nodo.NodoConfig
-import it.pagopa.ecommerce.payment.requests.domain.RptId
import it.pagopa.ecommerce.payment.requests.exceptions.InvalidRptException
import it.pagopa.ecommerce.payment.requests.exceptions.NodoErrorException
-import it.pagopa.ecommerce.payment.requests.repositories.PaymentRequestInfo
-import it.pagopa.ecommerce.payment.requests.repositories.PaymentRequestInfoRepository
import it.pagopa.ecommerce.payment.requests.utils.NodoOperations
import java.util.*
import javax.xml.datatype.XMLGregorianCalendar
@@ -23,7 +23,7 @@ import reactor.core.publisher.Mono
@Service
class PaymentRequestsService(
- @Autowired private val paymentRequestInfoRepository: PaymentRequestInfoRepository,
+ @Autowired private val paymentRequestInfoRepository: PaymentRequestsInfoRepository,
@Autowired private val nodeForPspClient: NodeForPspClient,
@Autowired
private val objectFactoryNodeForPsp:
@@ -62,7 +62,7 @@ class PaymentRequestsService(
paName = paymentInfo.paName,
dueDate = paymentInfo.dueDate,
description = paymentInfo.description,
- amount = paymentInfo.amount,
+ amount = paymentInfo.amount!!,
paymentContextCode = paymentContextCode)
}
.doOnNext { logger.info("PaymentRequestInfo retrieved for {}", rptId) }
@@ -105,19 +105,16 @@ class PaymentRequestsService(
} else {
Mono.just(
PaymentRequestInfo(
- id = rptId,
- paFiscalCode = verifyPaymentNoticeResponse.fiscalCodePA,
- paName = verifyPaymentNoticeResponse.companyName,
- description = verifyPaymentNoticeResponse.paymentDescription,
- amount =
- nodoOperations.getEuroCentsFromNodoAmount(
- verifyPaymentNoticeResponse.paymentList.paymentOptionDescription[0].amount),
- dueDate =
- getDueDateString(
- verifyPaymentNoticeResponse.paymentList.paymentOptionDescription[0].dueDate),
- paymentToken = null,
- idempotencyKey = null,
- isCart = false))
+ rptId,
+ verifyPaymentNoticeResponse.fiscalCodePA,
+ verifyPaymentNoticeResponse.companyName,
+ verifyPaymentNoticeResponse.paymentDescription,
+ nodoOperations.getEuroCentsFromNodoAmount(
+ verifyPaymentNoticeResponse.paymentList.paymentOptionDescription[0].amount),
+ getDueDateString(
+ verifyPaymentNoticeResponse.paymentList.paymentOptionDescription[0].dueDate),
+ null,
+ null))
}
}
return@flatMap paymentRequestInfo
diff --git a/src/test/kotlin/it/pagopa/ecommerce/payment/requests/configurations/redis/RedisConfigurationTests.kt b/src/test/kotlin/it/pagopa/ecommerce/payment/requests/configurations/redis/RedisConfigurationTests.kt
deleted file mode 100644
index 31c7e453..00000000
--- a/src/test/kotlin/it/pagopa/ecommerce/payment/requests/configurations/redis/RedisConfigurationTests.kt
+++ /dev/null
@@ -1,47 +0,0 @@
-package it.pagopa.ecommerce.payment.requests.configurations.redis
-
-import it.pagopa.ecommerce.payment.requests.configurations.redis.converters.rptId.RptIdReadingByteConverter
-import it.pagopa.ecommerce.payment.requests.configurations.redis.converters.rptId.RptIdReadingStringConverter
-import it.pagopa.ecommerce.payment.requests.configurations.redis.converters.rptId.RptIdWritingByteConverter
-import it.pagopa.ecommerce.payment.requests.configurations.redis.converters.rptId.RptIdWritingStringConverter
-import it.pagopa.ecommerce.payment.requests.domain.RptId
-import kotlinx.coroutines.test.runTest
-import org.junit.jupiter.api.Assertions.assertEquals
-import org.junit.jupiter.api.Test
-import org.junit.jupiter.api.assertDoesNotThrow
-
-class RedisConfigurationTests {
-
- private val rptIdReadingByteConverter = RptIdReadingByteConverter()
- private val rptIdReadingStringConverter = RptIdReadingStringConverter()
- private val rptIdWritingByteConverter = RptIdWritingByteConverter()
- private val rptIdWritingStringConverter = RptIdWritingStringConverter()
-
- @Test
- fun `should return valid configuration`() = runTest {
- assertDoesNotThrow {
- RedisConfiguration()
- .redisCustomConversions(
- rptIdReadingByteConverter,
- rptIdReadingStringConverter,
- rptIdWritingByteConverter,
- rptIdWritingStringConverter)
- }
- }
-
- @Test
- fun `should convert RPT id from and to byte`() = runTest {
- val rptIdString = "77777777777302000100000009424"
- val byteArray = rptIdWritingByteConverter.convert(RptId(rptIdString))
- val rptId = rptIdReadingByteConverter.convert(byteArray)
- assertEquals(rptIdString, rptId.value)
- }
-
- @Test
- fun `should convert RPT id from and to string`() = runTest {
- val rptIdString = "77777777777302000100000009424"
- val stringConversion = rptIdWritingStringConverter.convert(RptId(rptIdString))
- val rptId = rptIdReadingStringConverter.convert(stringConversion)
- assertEquals(rptIdString, rptId.value)
- }
-}
diff --git a/src/test/kotlin/it/pagopa/ecommerce/payment/requests/domain/IdempotencyKeyTests.kt b/src/test/kotlin/it/pagopa/ecommerce/payment/requests/domain/IdempotencyKeyTests.kt
deleted file mode 100644
index d8a554f4..00000000
--- a/src/test/kotlin/it/pagopa/ecommerce/payment/requests/domain/IdempotencyKeyTests.kt
+++ /dev/null
@@ -1,44 +0,0 @@
-package it.pagopa.ecommerce.payment.requests.domain
-
-import org.junit.jupiter.api.Assertions.assertEquals
-import org.junit.jupiter.api.Assertions.assertTrue
-import org.junit.jupiter.api.Test
-import org.junit.jupiter.api.assertThrows
-
-class IdempotencyKeyTests {
-
- companion object {
- const val VALID_FISCAL_CODE = "32009090901"
- const val INVALID_FISCAL_CODE = "3200909090"
- const val VALID_KEY_ID = "aabbccddee"
- const val INVALID_KEY_ID = "aabbccddeeffgg"
- }
-
- @Test
- fun `should throw invalid fiscal code`() {
- val exception =
- assertThrows { IdempotencyKey(INVALID_FISCAL_CODE, VALID_KEY_ID) }
- assertEquals("PSP fiscal code doesn't match regex: \\d{11}", exception.message)
- }
-
- @Test
- fun `should throw invalid key id`() {
- val exception =
- assertThrows { IdempotencyKey(VALID_FISCAL_CODE, INVALID_KEY_ID) }
- assertEquals("Key identifier doesn't match regex: [a-zA-Z\\d]{10}", exception.message)
- }
-
- @Test
- fun `should return key`() {
- val idempotencyKey = IdempotencyKey(VALID_FISCAL_CODE, VALID_KEY_ID)
- assertTrue(idempotencyKey.key == VALID_FISCAL_CODE + "_" + VALID_KEY_ID)
- }
-
- @Test
- fun `should generate same key`() {
- val key1 = IdempotencyKey(VALID_FISCAL_CODE, VALID_KEY_ID)
- val key2 = IdempotencyKey(VALID_FISCAL_CODE + "_" + VALID_KEY_ID)
- assertEquals(key1, key2)
- assertEquals(key1, key1)
- }
-}
diff --git a/src/test/kotlin/it/pagopa/ecommerce/payment/requests/domain/RptIdTests.kt b/src/test/kotlin/it/pagopa/ecommerce/payment/requests/domain/RptIdTests.kt
deleted file mode 100644
index 83ef5823..00000000
--- a/src/test/kotlin/it/pagopa/ecommerce/payment/requests/domain/RptIdTests.kt
+++ /dev/null
@@ -1,75 +0,0 @@
-package it.pagopa.ecommerce.payment.requests.domain
-
-import org.junit.jupiter.api.Assertions.assertEquals
-import org.junit.jupiter.api.Assertions.assertTrue
-import org.junit.jupiter.api.Test
-import org.junit.jupiter.api.assertDoesNotThrow
-import org.junit.jupiter.api.assertThrows
-
-class RptIdTests {
-
- companion object {
- const val VALID_FISCAL_CODE = "32009090901"
- const val VALID_NOTICE_CODE = "002016723749670035"
- const val VALID_RPT_ID = VALID_FISCAL_CODE + VALID_NOTICE_CODE
- }
-
- @Test
- fun `empty RptId is invalid`() {
- assertThrows { RptId("") }
- }
-
- @Test
- fun `RptId too long is rejected`() {
- assertThrows { RptId("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") }
- }
-
- @Test
- fun `valid RptId is ok`() {
- assertDoesNotThrow { RptId("aaaaaaaaaaaaaaaaaaaaaaaaaaaaa") }
- }
-
- @Test
- fun `should return rpt id`() {
- val rptId = RptId(VALID_RPT_ID)
- assertEquals(VALID_RPT_ID, rptId.value)
- }
-
- @Test
- fun `should return fiscal code`() {
- val rptId = RptId(VALID_RPT_ID)
- assertEquals(VALID_FISCAL_CODE, rptId.fiscalCode)
- }
-
- @Test
- fun `should return notice code`() {
- val rptId = RptId(VALID_RPT_ID)
- assertEquals(VALID_NOTICE_CODE, rptId.noticeId)
- }
-
- @Test
- fun `should return aux digit`() {
- val rptId = RptId(VALID_RPT_ID)
- assertEquals("0", rptId.auxDigit)
- }
-
- @Test
- fun `should return application code`() {
- val rptId = RptId(VALID_RPT_ID)
- assertEquals("02", rptId.applicationCode)
- }
-
- @Test
- fun `should return IUV code`() {
- val rptId = RptId(VALID_RPT_ID)
- assertEquals("016723749670035", rptId.IUV)
- }
-
- @Test
- fun `should get same RPT id`() {
- val rptId1 = RptId(VALID_RPT_ID)
- val rptId2 = RptId(VALID_RPT_ID)
- assertTrue(rptId1 == rptId2)
- assertEquals(rptId1.hashCode(), rptId2.hashCode())
- }
-}
diff --git a/src/test/kotlin/it/pagopa/ecommerce/payment/requests/services/CartsServiceTests.kt b/src/test/kotlin/it/pagopa/ecommerce/payment/requests/services/CartsServiceTests.kt
index 495c1584..3ee0f3e5 100644
--- a/src/test/kotlin/it/pagopa/ecommerce/payment/requests/services/CartsServiceTests.kt
+++ b/src/test/kotlin/it/pagopa/ecommerce/payment/requests/services/CartsServiceTests.kt
@@ -1,8 +1,8 @@
package it.pagopa.ecommerce.payment.requests.services
+import it.pagopa.ecommerce.commons.domain.v1.RptId
import it.pagopa.ecommerce.generated.nodoperpm.v1.dto.CheckPositionResponseDto
import it.pagopa.ecommerce.payment.requests.client.NodoPerPmClient
-import it.pagopa.ecommerce.payment.requests.domain.RptId
import it.pagopa.ecommerce.payment.requests.exceptions.CartNotFoundException
import it.pagopa.ecommerce.payment.requests.exceptions.RestApiException
import it.pagopa.ecommerce.payment.requests.repositories.CartInfo
diff --git a/src/test/kotlin/it/pagopa/ecommerce/payment/requests/services/PaymentRequestsServiceTests.kt b/src/test/kotlin/it/pagopa/ecommerce/payment/requests/services/PaymentRequestsServiceTests.kt
index e7bc8fec..3cecbe0a 100644
--- a/src/test/kotlin/it/pagopa/ecommerce/payment/requests/services/PaymentRequestsServiceTests.kt
+++ b/src/test/kotlin/it/pagopa/ecommerce/payment/requests/services/PaymentRequestsServiceTests.kt
@@ -1,13 +1,13 @@
package it.pagopa.ecommerce.payment.requests.services
+import it.pagopa.ecommerce.commons.domain.v1.RptId
+import it.pagopa.ecommerce.commons.repositories.PaymentRequestInfo
+import it.pagopa.ecommerce.commons.repositories.PaymentRequestsInfoRepository
import it.pagopa.ecommerce.generated.transactions.model.*
import it.pagopa.ecommerce.payment.requests.client.NodeForPspClient
import it.pagopa.ecommerce.payment.requests.configurations.nodo.NodoConfig
-import it.pagopa.ecommerce.payment.requests.domain.RptId
import it.pagopa.ecommerce.payment.requests.exceptions.InvalidRptException
import it.pagopa.ecommerce.payment.requests.exceptions.NodoErrorException
-import it.pagopa.ecommerce.payment.requests.repositories.PaymentRequestInfo
-import it.pagopa.ecommerce.payment.requests.repositories.PaymentRequestInfoRepository
import it.pagopa.ecommerce.payment.requests.utils.NodoOperations
import java.math.BigDecimal
import java.text.DateFormat
@@ -34,7 +34,7 @@ class PaymentRequestsServiceTests {
private lateinit var paymentRequestsService: PaymentRequestsService
- @Mock private lateinit var paymentRequestsInfoRepository: PaymentRequestInfoRepository
+ @Mock private lateinit var paymentRequestsInfoRepository: PaymentRequestsInfoRepository
@Mock private lateinit var nodeForPspClient: NodeForPspClient
@@ -62,8 +62,7 @@ class PaymentRequestsServiceTests {
val description = "Payment request description"
val amount = Integer.valueOf(1000)
val paymentRequestInfo =
- PaymentRequestInfo(
- rptIdAsObject, paTaxCode, paName, description, amount, null, null, null, false)
+ PaymentRequestInfo(rptIdAsObject, paTaxCode, paName, description, amount, null, null, null)
/** preconditions */
given(paymentRequestsInfoRepository.findById(rptIdAsObject))
.willReturn(Optional.of(paymentRequestInfo))