Skip to content

Commit

Permalink
PIN-3395: trigger eserviceDescriptor archiviation (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
AsterITA authored Jul 10, 2023
1 parent 468ab63 commit af33f78
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 15 deletions.
19 changes: 10 additions & 9 deletions src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,18 @@ agreement-process {
user-registry-api-key = ${USER_REGISTRY_API_KEY}
party-process-api-key = ${PARTY_PROCESS_API_KEY}
services {
catalog-management = ${CATALOG_MANAGEMENT_URL}
tenant-management = ${TENANT_MANAGEMENT_URL}
agreement-management = ${AGREEMENT_MANAGEMENT_URL}
attribute-registry-management = ${ATTRIBUTE_REGISTRY_MANAGEMENT_URL}
authorization-management = ${AUTHORIZATION_MANAGEMENT_URL}
party-process = ${PARTY_PROCESS_URL}
user-registry = ${USER_REGISTRY_URL}
catalog-management = ${CATALOG_MANAGEMENT_URL}
tenant-management = ${TENANT_MANAGEMENT_URL}
agreement-management = ${AGREEMENT_MANAGEMENT_URL}
attribute-registry-management = ${ATTRIBUTE_REGISTRY_MANAGEMENT_URL}
authorization-management = ${AUTHORIZATION_MANAGEMENT_URL}
party-process = ${PARTY_PROCESS_URL}
user-registry = ${USER_REGISTRY_URL}
}

archiving-purposes-queue-name = ${ARCHIVING_PURPOSES_QUEUE_NAME}
certified-mail-queue-name = ${CERTIFIED_MAIL_QUEUE_NAME}
archiving-purposes-queue-name = ${ARCHIVING_PURPOSES_QUEUE_NAME}
archiving-eservices-queue-name = ${ARCHIVING_ESERVICES_QUEUE_NAME}
certified-mail-queue-name = ${CERTIFIED_MAIL_QUEUE_NAME}

storage {
kind = "S3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ final case class AgreementApiServiceImpl(
offsetDateTimeSupplier: OffsetDateTimeSupplier,
uuidSupplier: UUIDSupplier,
certifiedMailQueueService: QueueService,
archivingPurposesQueueService: QueueService
archivingPurposesQueueService: QueueService,
archivingEservicesQueueService: QueueService
)(implicit ec: ExecutionContext, readModel: ReadModelService)
extends AgreementApiService {

Expand Down Expand Up @@ -261,6 +262,7 @@ final case class AgreementApiServiceImpl(
newAgreement <-
if (verifiedAndDeclareSatisfied(agreement, newDescriptor, tenant)) upgradeAgreement(agreement.id, newDescriptor)
else createNewDraftAgreement(agreement, newDescriptor.id)
_ <- archivingEservicesQueueService.send[ArchiveEvent](ArchiveEvent(agreement.id, offsetDateTimeSupplier.get()))
} yield newAgreement.toApi

onComplete(result) {
Expand Down Expand Up @@ -1340,6 +1342,7 @@ final case class AgreementApiServiceImpl(
_ <- assertRequesterIsConsumer(requesterOrgId, agreement)
updated <- archive(agreement.toManagement)
_ <- archivingPurposesQueueService.send[ArchiveEvent](ArchiveEvent(updated.id, offsetDateTimeSupplier.get()))
_ <- archivingEservicesQueueService.send[ArchiveEvent](ArchiveEvent(updated.id, offsetDateTimeSupplier.get()))
} yield updated.toApi

onComplete(result) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ object ApplicationConfiguration {
val userRegistryApiKey: String = config.getString("agreement-process.user-registry-api-key")
val partyProcessApiKey: String = config.getString("agreement-process.party-process-api-key")

val readModelConfig: ReadModelConfig = {
val readModelConfig: ReadModelConfig = {
val connectionString: String = config.getString("agreement-process.read-model.db.connection-string")
val dbName: String = config.getString("agreement-process.read-model.db.name")

ReadModelConfig(connectionString, dbName)
}
val archivingPurposesQueueName: String = config.getString("agreement-process.archiving-purposes-queue-name")
val certifiedMailQueueName: String = config.getString("agreement-process.certified-mail-queue-name")
val archivingPurposesQueueName: String = config.getString("agreement-process.archiving-purposes-queue-name")
val archivingEservicesQueueName: String = config.getString("agreement-process.archiving-eservices-queue-name")
val certifiedMailQueueName: String = config.getString("agreement-process.certified-mail-queue-name")

}
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ trait Dependencies {
def archivingPurposesQueueName(blockingEc: ExecutionContextExecutor): QueueService =
new QueueServiceImpl(ApplicationConfiguration.archivingPurposesQueueName)(blockingEc)

def archivingEservicesQueueName(blockingEc: ExecutionContextExecutor): QueueService =
new QueueServiceImpl(ApplicationConfiguration.archivingEservicesQueueName)(blockingEc)

def agreementApi(jwtReader: JWTReader, blockingEc: ExecutionContextExecutor)(implicit
actorSystem: ActorSystem[_],
ec: ExecutionContext
Expand All @@ -113,7 +116,8 @@ trait Dependencies {
OffsetDateTimeSupplier,
UUIDSupplier,
certifiedMailQueueName(blockingEc),
archivingPurposesQueueName(blockingEc)
archivingPurposesQueueName(blockingEc),
archivingEservicesQueueName(blockingEc)
),
AgreementApiMarshallerImpl,
jwtReader.OAuth2JWTValidatorAsContexts
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/application-test.conf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ agreement-process {
}

archiving-purposes-queue-name = "archiving-purposes-queue-name"
archiving-eservices-queue-name = "archiving-eservices-queue-name"
certified-mail-queue-name = "certified-mail-queue-name"

storage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class AgreementApiAuthzSpec extends AnyWordSpecLike with MockFactory with AuthzS
offsetDateTimeSupplier = OffsetDateTimeSupplier,
uuidSupplier = UUIDSupplier,
fakerQueueService,
fakerQueueService,
fakerQueueService
)(ExecutionContext.global, fakeReadModel)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class AgreementArchiviationSpec extends AnyWordSpecLike with SpecHelper with Sca
val now = SpecData.when
mockAgreementRetrieve(agreement.toPersistent)
mockAgreementUpdate(agreement.id, expectedSeed, agreement.copy(stamps = SpecData.archiviationStamps))
mockArchiveEventSending(ArchiveEvent(agreement.id, now))
mockArchiveEventSending(ArchiveEvent(agreement.id, now)).twice()

Get() ~> service.archiveAgreement(agreement.id.toString) ~> check {
status shouldEqual StatusCodes.OK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.testkit.ScalatestRouteTest
import it.pagopa.interop.agreementprocess.common.Adapters._
import it.pagopa.interop.agreementmanagement.client.model.UpgradeAgreementSeed
import it.pagopa.interop.agreementprocess.events.ArchiveEvent
import it.pagopa.interop.authorizationmanagement.client.model.{
ClientAgreementAndEServiceDetailsUpdate,
ClientComponentState
Expand Down Expand Up @@ -54,6 +55,7 @@ class AgreementUpgradeSpec extends AnyWordSpecLike with SpecHelper with Scalates
eserviceState = ClientComponentState.ACTIVE
)
)
mockArchiveEventSending(ArchiveEvent(agreement.id, SpecData.when))

Get() ~> service.upgradeAgreementById(agreement.id.toString) ~> check {
status shouldEqual StatusCodes.OK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ trait SpecHelper extends MockFactory {
mockOffsetDateTimeSupplier,
mockUUIDSupplier,
mockQueueService,
mockQueueService,
mockQueueService
)(ExecutionContext.global, mockReadModel)

Expand Down

0 comments on commit af33f78

Please sign in to comment.