diff --git a/pom.xml b/pom.xml index 6a07fcda..36670843 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ it.gov.pagopa idpay-admissibility-assessor idpay-admissibility-assessor - 1.3.2 + 1.3.3 17 diff --git a/specs/asyncapi.yml b/specs/asyncapi.yml new file mode 100644 index 00000000..4d957b60 --- /dev/null +++ b/specs/asyncapi.yml @@ -0,0 +1,872 @@ +asyncapi: 2.0.0 +info: + title: Admissibility Assessor Service + version: 1.0.0 + description: >- + Its purpose is +tags: + - name: "sendOnboardingNotify" + description: "Send onboarding request" + + - name: "sendRankingNotify" + description: "Send onboarding request " + + - name: "sendReschedulingOnboardingRequest" + description: "Send rescheduling of an onboarding request" + + - name: "processInitiative" + description: "Trigger building and saving drools rules " + + - name: "notifyBeneficiaryRuleError" + description: "Send an error occurred during the processInitiative flow" + - name: "beneficiaryRuleDeserializationError" + description: "Send an error occurred during payload deserialization " + + - name: "notifyCommandMediatorError" + description: "Send an error occurred during the deleteInitiative flow" + - name: "commandMediatorDeserializationError" + description: "Send an error occurred during payload deserialization " + + - name: "rescheduleError" + description: "Send a rescheduling error" + - name: "onboardingRequestError" + description: "Send an onboarding request error" + - name: "onboardingRequestDeserializationError" + description: "Send error occurred during payload deserialization" + + - name: "onboardingNotifierError" + description: "Send an unexpected error during onboarding result publishing" + + - name: "rankingNotifierError" + description: "Send an unexpected error during ranking result publishing" + + - name: "deleteInitiative" + description: "Initiative documents deletion " + + - name: "onboardingRequest" + description: "Process onboarding request" +channels: + admissibiliy-send-onboarding-notiy: + publish: + message: + $ref: '#/components/messages/sendOnboardingNotify' + bindings: + kafka: + topic: idpay-onboarding-outcome + tags: + - name: "sendOnboardingNotify" + admissibiliy-send-ranking-notiy: + publish: + message: + $ref: '#/components/messages/sendRankingNotify' + bindings: + kafka: + topic: idpay-onboarding-ranking-request + tags: + - name: "sendRankingNotify" + admissibiliy-send-rescheduling-onboarding-request: + publish: + message: + $ref: '#/components/messages/SendReschedulingOnboardingRequest' + bindings: + servicebus: + topic: idpay-onboarding-request + tags: + - name: "sendReschedulingOnboardingRequest" + admissibiliy-process-initiative: + subscribe: + message: + $ref: '#/components/messages/ProcessInitiative' + bindings: + kafka: + topic: idpay_rule_update + tags: + - name: "processInitiative" + admissibiliy-notify-beneficiary-rule-error: + publish: + message: + $ref: '#/components/messages/NotifyBeneficiaryRuleError' + bindings: + kafka: + topic: idpay-errors + tags: + - name: "notifyBeneficiaryRuleError" + admissibiliy-beneficiary-rule-deserialization-error: + publish: + message: + $ref: '#/components/messages/BeneficiaryRuleDeserializationError' + bindings: + kafka: + topic: idpay-errors + tags: + - name: "beneficiaryRuleDeserializationError" + admissibiliy-notify-command-mediator-error: + publish: + message: + $ref: '#/components/messages/NotifyCommandMediatorError' + bindings: + kafka: + topic: idpay-errors + tags: + - name: "notifyCommandMediatorError" + admissibiliy-command-mediator-deserialization-error: + publish: + message: + $ref: '#/components/messages/CommandMediatorDeserializationError' + bindings: + kafka: + topic: idpay-errors + tags: + - name: "commandMediatorDeserializationError" + admissibiliy-reschedule-error: + publish: + message: + $ref: '#/components/messages/RescheduleError' + bindings: + kafka: + topic: idpay-errors + tags: + - name: "rescheduleError" + admissibiliy-onboarding-request-error: + publish: + message: + $ref: '#/components/messages/OnboardingRequestError' + bindings: + kafka: + topic: idpay-errors + tags: + - name: "onboardingRequestError" + admissibiliy-onboarding-request-deserialization-error: + publish: + message: + $ref: '#/components/messages/OnboardingRequestDeserializationError' + bindings: + kafka: + topic: idpay-errors + tags: + - name: "onboardingRequestDeserializationError" + admissibiliy-onboarding-notifier-error: + publish: + message: + $ref: '#/components/messages/OnboardingNotifierError' + bindings: + kafka: + topic: idpay-errors + tags: + - name: "onboardingNotifierError" + admissibiliy-ranking-notifier-error: + publish: + message: + $ref: '#/components/messages/RankingNotifierError' + bindings: + kafka: + topic: idpay-errors + tags: + - name: "rankingNotifierError" + admissibiliy-delete-initiative: + subscribe: + message: + $ref: '#/components/messages/DeleteInitiative' + bindings: + kafka: + topic: idpay-commands + tags: + - name: "deleteInitiative" + admissibiliy-onboarding-request: + subscribe: + message: + $ref: '#/components/messages/OnboardingRequest' + bindings: + servicebus: + topic: idpay-onboarding-request + tags: + - name: "onboardingRequest" +components: + messages: + sendOnboardingNotify: + contentType: application/json + description: >- + This event is triggered to notify the outcome topic about an onboarding request. + summary: Notifies the outcome topic about an onboarding request. + payload: + $ref: "#/components/schemas/EvaluationCompletedDTO" + sendRankingNotify: + contentType: application/json + description: >- + This event is triggered to notify the ranking topic about an onboarding request. + summary: Notifies the ranking topic about an onboarding request. + payload: + $ref: "#/components/schemas/RankingRequestDTO" + SendReschedulingOnboardingRequest: + contentType: application/json + description: >- + This event is triggered to reschedule an onboarding request for a user. + summary: Notifies the rescheduling of an onboarding request for a user. + payload: + $ref: "#/components/schemas/OnboardingDTO" + ProcessInitiative: + contentType: application/json + description: >- + This event is triggered to build and save drools rules based on received initiative information. + summary: Trigger the initiation of building and saving Drools rules. + payload: + $ref: "https://raw.githubusercontent.com/pagopa/idpay-portal-welfare-backend-initiative/main/specs/asyncapi.yml#/components/schemas/RuleUpdate" + + NotifyBeneficiaryRuleError: + contentType: application/json + description: >- + This event is triggered when an error occurs during the processInitiative flow. + It provides details about the error encountered. + summary: Notification of an error during the processInitiative flow. + headers: + $ref: "#/components/schemas/ErrorQueueHeader" + payload: + $ref: "https://raw.githubusercontent.com/pagopa/idpay-portal-welfare-backend-initiative/main/specs/asyncapi.yml#/components/schemas/RuleUpdate" + BeneficiaryRuleDeserializationError: + contentType: application/json + description: >- + This event is triggered when an error occurs during the deserialization of the payload in the processInitiative flow. + It provides details about the deserialization failure. + summary: Notification of an error during payload deserialization in the processInitiative flow. + headers: + $ref: "#/components/schemas/ErrorQueueHeader" + payload: + $ref: "https://raw.githubusercontent.com/pagopa/idpay-portal-welfare-backend-initiative/main/specs/asyncapi.yml#/components/schemas/RuleUpdate" + NotifyCommandMediatorError: + contentType: application/json + description: >- + This event is triggered when an error occurs during the deleteInitiative flow. + It provides details about the error encountered. + summary: Notification of an error during the deleteInitiative flow. + headers: + $ref: "#/components/schemas/ErrorQueueHeader" + payload: + $ref: "https://raw.githubusercontent.com/pagopa/idpay-portal-welfare-backend-initiative/main/specs/asyncapi.yml#/components/schemas/QueueCommandOperationDTO" + CommandMediatorDeserializationError: + contentType: application/json + description: >- + This event is triggered when an error occurs during the deserialization of the payload in the deleteInitiative flow. + It provides details about the deserialization failure. + summary: Notification of an error during payload deserialization in the deleteInitiative flow. + headers: + $ref: "#/components/schemas/ErrorQueueHeader" + payload: + $ref: "https://raw.githubusercontent.com/pagopa/idpay-portal-welfare-backend-initiative/main/specs/asyncapi.yml#/components/schemas/QueueCommandOperationDTO" + RescheduleError: + contentType: application/json + description: >- + This event is triggered when it's not possible to reschedule an onboarding request. + It provides details about the error encountered. + summary: Notification of a rescheduling error. + headers: + $ref: "#/components/schemas/ErrorQueueHeader" + payload: + $ref: "#/components/schemas/OnboardingDTO" + OnboardingRequestError: + contentType: application/json + description: >- + This event is triggered when an error occurs during the onboarding request process. + It provides details about the error encountered. + summary: Notification of an onboarding request error. + headers: + $ref: "#/components/schemas/ErrorQueueHeader" + payload: + $ref: "#/components/schemas/OnboardingDTO" + OnboardingRequestDeserializationError: + contentType: application/json + description: >- + This event is triggered when an error occurs during the deserialization of the payload in the onboarding request process. + It provides details about the deserialization failure. + summary: Notification of an error during payload deserialization in the onboarding request process. + headers: + $ref: "#/components/schemas/ErrorQueueHeader" + payload: + $ref: "#/components/schemas/OnboardingDTO" + OnboardingNotifierError: + contentType: application/json + description: >- + This event is triggered when an unexpected error occurs while publishing the onboarding result. + It provides details about the error encountered. + summary: Notification of an unexpected error during onboarding result publishing. + headers: + $ref: "#/components/schemas/ErrorQueueHeader" + payload: + $ref: "#/components/schemas/EvaluationCompletedDTO" + RankingNotifierError: + contentType: application/json + description: >- + This event is triggered when an unexpected error occurs while publishing the ranking result. + It provides details about the error encountered. + summary: Notification of an unexpected error during ranking result publishing. + headers: + $ref: "#/components/schemas/ErrorQueueHeader" + payload: + $ref: "#/components/schemas/RankingRequestDTO" + DeleteInitiative: + contentType: application/json + description: >- + This event is sent to the application when a command to delete an initiative is published. + It triggers the deletion of all documents related to the specified initiative. + summary: Trigger the application to delete all documents associated with the initiative. + payload: + $ref: "https://raw.githubusercontent.com/pagopa/idpay-portal-welfare-backend-initiative/main/specs/asyncapi.yml#/components/schemas/QueueCommandOperationDTO" + OnboardingRequest: + contentType: application/json + description: Receive information about onboarding request. + summary: Onboarding request information + payload: + oneOf: + - $ref: "#/components/schemas/OnboardingDTO" + - $ref: "https://raw.githubusercontent.com/pagopa/idpay-onboarding-workflow/main/specs/asyncapi.yaml#/components/schemas/OnboardingDTO" + + schemas: + TransactionDTO: + type: object + properties: + idTrxAcquirer: + type: string + description: ID of the acquiring transaction + example: "198937549309371755007410777179935955803" + EvaluationDTO: + type: object + properties: + userId: + type: string + description: ID of the user + notEmpty: true + example: bcf3651c-d2d3-4998-81a9-5f24302ab674 + familyId: + type: string + description: ID of the family + initiativeId: + type: string + description: ID of the initiative + notEmpty: true + example: 661626073785876cb5aa7601 + organizationId: + type: string + description: ID of the organization + admissibilityCheckDate: + type: string + format: date-time + description: Date of admissibility check + notNull: true + criteriaConsensusTimestamp: + type: string + format: date-time + description: Timestamp of criteria consensus + RankingRequestDTO: + type: object + allOf: + - $ref: "#/components/schemas/EvaluationDTO" + properties: + rankingValue: + type: integer + format: int64 + description: Ranking Value + example: 999 + onboardingKo: + type: boolean + description: Onboarding Status KO + example: true + ErrorQueueHeader: + type: object + properties: + group: + type: string + description: The Kafka group to which the error message belongs. + example: "group" + srcType: + type: string + description: The type of the source of the error message. + example: "kafka" + srcServer: + type: string + description: The source server of the error message. + example: cstar-u-idpay-evh-ns-00.servicebus.windows.net:9093 + srcTopic: + type: string + description: The Kafka topic of the source of the error message. + example: idpay-transaction + description: + type: string + description: Description of the error. + example: "[CONFIRM_PAYMENT] An error occurred while publishing the confirmation Payment result" + retryable: + type: boolean + description: Indicates whether the error is retryable or not. + stacktrace: + type: string + description: The stack trace of the error. + example: "InternalServerErrorException -> Something gone wrong while Confirm Payment notify" + rootCauseClass: + type: string + description: Cause class of the error. + example: "java.lang.InternalServerErrorException" + rootCauseMessage: + type: string + description: Message of the error. + example: "Something gone wrong while Confirm Payment notify" + OnboardingDTO: + type: object + properties: + userId: + type: string + description: User ID + example: "bcf3651c-d2d3-4998-81a9-5f24302ab674" + initiativeId: + type: string + description: Initiative ID + example: "661626073785876cb5aa7601" + tc: + type: boolean + description: Terms and conditions acceptance flag + example: true + status: + type: string + description: Status of the onboarding process + example: "COMPLETED" + pdndAccept: + type: boolean + description: PDND acceptance flag + example: true + tcAcceptTimestamp: + type: string + format: date-time + description: Timestamp when terms and conditions were accepted + example: "2024-05-28T12:34:56" + criteriaConsensusTimestamp: + type: string + format: date-time + description: Timestamp when criteria consensus was given + example: "2024-05-28T12:45:00" + isee: + type: number + format: decimal + description: ISEE value + example: 12345.67 + residence: + type: object + description: Residence information + $ref: "#/components/schemas/Residence" + birthDate: + type: object + description: Birth date information + $ref: "#/components/schemas/BirthDate" + family: + type: object + description: Family information + $ref: "#/components/schemas/Family" + budgetReserved: + type: boolean + description: Flag indicating if the budget has been reserved + example: true + Residence: + type: object + properties: + postalCode: + type: string + description: Postal code of residence + example: "00100" + cityCouncil: + type: string + description: City council of residence + example: "Rome" + province: + type: string + description: Province of residence + example: "RM" + city: + type: string + description: City of residence + example: "Rome" + region: + type: string + description: Region of residence + example: "Lazio" + nation: + type: string + description: Nation of residence + example: "Italy" + BirthDate: + type: object + properties: + year: + type: string + description: Year of birth + example: "1990" + age: + type: integer + description: Age + example: 34 + Family: + type: object + properties: + familyId: + type: string + description: Family ID + example: "f1234567-89ab-cdef-0123-456789abcdef" + memberIds: + type: array + items: + type: string + description: Set of family member IDs + example: [ "m123", "m124", "m125" ] + EvaluationCompletedDTO: + type: object + allOf: + - $ref: "#/components/schemas/EvaluationDTO" + properties: + initiativeName: + type: string + description: Name of the initiative + example: "Green Initiative" + organizationName: + type: string + description: Name of the organization + example: "Green Organization" + initiativeEndDate: + type: string + format: date + description: End date of the initiative + example: "2024-12-31" + status: + type: string + description: Status of the onboarding evaluation + example: "COMPLETED" + notEmpty: true + onboardingRejectionReasons: + type: array + description: List of rejection reasons during onboarding + items: + $ref: "#/components/schemas/OnboardingRejectionReason" + beneficiaryBudgetCents: + type: integer + format: int64 + description: Beneficiary's budget in cents + example: 100000 + rankingValue: + type: integer + format: int64 + description: Ranking value (ignored in JSON) + example: 50 + readOnly: true + initiativeRewardType: + type: string + description: Type of initiative reward + example: "CASHBACK" + isLogoPresent: + type: boolean + description: Flag indicating if the logo is present + example: true + OnboardingRejectionReason: + type: object + properties: + type: + type: string + description: Type of rejection reason + enum: + - TECHNICAL_ERROR + - CONSENSUS_MISSED + - INVALID_REQUEST + - BUDGET_EXHAUSTED + - AUTOMATED_CRITERIA_FAIL + - ISEE_TYPE_KO + - FAMILY_KO + - RESIDENCE_KO + - BIRTHDATE_KO + - OUT_OF_RANKING + - FAMILY_CRITERIA_KO + example: TECHNICAL_ERROR + notNull: true + code: + type: string + description: Code of the rejection reason + example: ELIG001 + notNull: true + authority: + type: string + description: Authority responsible for the rejection + example: Local Government + authorityLabel: + type: string + description: Label for the authority responsible + example: Local Gov + detail: + type: string + description: Additional detail about the rejection reason + example: Not eligible due to income + Initiative2BuildDTO: + type: object + properties: + initiativeId: + type: string + description: ID of the initiative + example: "661626073785876cb5aa7601" + initiativeName: + type: string + description: Name of the initiative + example: "Green Energy Initiative" + organizationId: + type: string + description: ID of the organization + example: "org123456" + organizationName: + type: string + description: Name of the organization + example: "Green Energy Org" + status: + type: string + description: Status of the initiative + example: "ACTIVE" + beneficiaryRule: + $ref: "#/components/schemas/InitiativeBeneficiaryRuleDTO" + general: + $ref: "#/components/schemas/InitiativeGeneralDTO" + additionalInfo: + $ref: "#/components/schemas/InitiativeAdditionalInfoDTO" + initiativeRewardType: + type: string + description: Type of reward for the initiative + example: "CASHBACK" + InitiativeGeneralDTO: + type: object + properties: + name: + type: string + description: Name of the initiative + example: "Energy Conservation Plan" + budgetCents: + type: integer + format: int64 + description: Total budget of the initiative in cents + example: 50000000 + beneficiaryType: + type: string + description: Type of beneficiary + enum: + - PF + - PG + - NF + example: PF + beneficiaryKnown: + type: boolean + description: Indicates if the beneficiary is known + example: true + beneficiaryBudgetCents: + type: integer + format: int64 + description: Budget allocated per beneficiary in cents + example: 1000000 + startDate: + type: string + format: date + description: Start date of the initiative + example: "2024-01-01" + endDate: + type: string + format: date + description: End date of the initiative + example: "2024-12-31" + rankingStartDate: + type: string + format: date + description: Start date of the ranking period + example: "2024-02-01" + rankingEndDate: + type: string + format: date + description: End date of the ranking period + example: "2024-11-30" + rankingEnabled: + type: boolean + description: Indicates if ranking is enabled + example: true + InitiativeAdditionalInfoDTO: + type: object + properties: + serviceName: + type: string + description: Name of the service + example: "Energy Saving Program" + argument: + type: string + description: Argument or main topic of the initiative + example: "Promoting energy efficiency" + description: + type: string + description: Description of the initiative + example: "This initiative aims to reduce energy consumption through various incentives." + channels: + type: array + items: + $ref: "#/components/schemas/ChannelsDTO" + logoFileName: + type: string + description: Name of the logo file + example: "energy_saving_logo.png" + ChannelsDTO: + type: object + properties: + type: + type: string + description: Type of communication channel + example: "EMAIL" + contact: + type: string + description: Contact information for the channel + example: "support@energysaving.org" + InitiativeBeneficiaryRuleDTO: + type: object + properties: + selfDeclarationCriteria: + type: array + description: List of self-declaration criteria + items: + $ref: "#/components/schemas/AnyOfInitiativeBeneficiaryRuleDTOSelfDeclarationCriteriaItems" + automatedCriteria: + type: array + description: List of automated criteria + items: + $ref: "#/components/schemas/AutomatedCriteriaDTO" + AutomatedCriteriaDTO: + type: object + properties: + authority: + type: string + description: Authority responsible for the criteria + example: "Tax Authority" + code: + type: string + description: Code of the criteria + example: "CRIT001" + field: + type: string + description: Field name to be evaluated + example: "income" + operator: + type: string + description: Operator used for comparison + enum: + - EQ + - NOT_EQ + - LT + - LE + - GT + - GE + - INSTANCE_OF + - IN + - BTW_CLOSED + - BTW_OPEN + example: "EQ" + value: + type: string + description: Value for the comparison + example: "50000" + value2: + type: string + description: Second value for comparison, if needed + example: "100000" + orderDirection: + type: string + description: Direction of sorting + enum: + - ASC + - DESC + example: "ASC" + iseeTypes: + type: array + description: List of ISEE typologies + items: + type: string + enum: + - ORDINARIO + - MINORENNE + - UNIVERSITARIO + - SOCIOSANITARIO + - DOTTORATO + - RESIDENZIALE + - CORRENTE + example: "ORDINARIO" + pdndConfig: + $ref: "#/components/schemas/PdndInitiativeConfig" + FilterOperator: + type: string + enum: + - EQ + - NOT_EQ + - LT + - LE + - GT + - GE + - INSTANCE_OF + - IN + - BTW_CLOSED + - BTW_OPEN + IseeTypologyEnum: + type: string + enum: + - ORDINARIO + - MINORENNE + - UNIVERSITARIO + - SOCIOSANITARIO + - DOTTORATO + - RESIDENZIALE + - CORRENTE + PdndInitiativeConfig: + type: object + properties: + clientId: + type: string + description: Client ID for PDND initiative + example: "client123" + kid: + type: string + description: Key ID for PDND initiative + example: "kid456" + purposeId: + type: string + description: Purpose ID for PDND initiative + example: "purpose789" + Direction: + type: string + enum: + - ASC + - DESC + AnyOfInitiativeBeneficiaryRuleDTOSelfDeclarationCriteriaItems: + type: object + oneOf: + - $ref: '#/components/schemas/SelfCriteriaMultiDTO' + - $ref: '#/components/schemas/SelfCriteriaBoolDTO' + SelfCriteriaBoolDTO: + type: object + properties: + description: + type: string + description: Description of the criteria + example: "Agrees to terms and conditions" + value: + type: boolean + description: Value of the boolean criteria + example: true + code: + type: string + description: Code of the criteria + example: "TC_AGREEMENT" + SelfCriteriaMultiDTO: + type: object + properties: + description: + type: string + description: Description of the criteria + example: "Select preferred interests" + value: + type: array + description: List of selected values for the multi-selection criteria + items: + type: string + example: [ "Sports", "Music", "Art" ] + code: + type: string + description: Code of the criteria + example: "INTEREST_SELECTION" \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/admissibility/connector/repository/InitiativeCountersReservationOpsRepository.java b/src/main/java/it/gov/pagopa/admissibility/connector/repository/InitiativeCountersReservationOpsRepository.java index 132e5d13..9b9508df 100644 --- a/src/main/java/it/gov/pagopa/admissibility/connector/repository/InitiativeCountersReservationOpsRepository.java +++ b/src/main/java/it/gov/pagopa/admissibility/connector/repository/InitiativeCountersReservationOpsRepository.java @@ -3,8 +3,6 @@ import it.gov.pagopa.admissibility.model.InitiativeCounters; import reactor.core.publisher.Mono; -import java.math.BigDecimal; - public interface InitiativeCountersReservationOpsRepository { - Mono reserveBudget(String initiativeId, BigDecimal reservation); + Mono reserveBudget(String initiativeId, Long reservationCents); } diff --git a/src/main/java/it/gov/pagopa/admissibility/connector/repository/InitiativeCountersReservationOpsRepositoryImpl.java b/src/main/java/it/gov/pagopa/admissibility/connector/repository/InitiativeCountersReservationOpsRepositoryImpl.java index 44300941..db102c10 100644 --- a/src/main/java/it/gov/pagopa/admissibility/connector/repository/InitiativeCountersReservationOpsRepositoryImpl.java +++ b/src/main/java/it/gov/pagopa/admissibility/connector/repository/InitiativeCountersReservationOpsRepositoryImpl.java @@ -1,7 +1,6 @@ package it.gov.pagopa.admissibility.connector.repository; import it.gov.pagopa.admissibility.model.InitiativeCounters; -import it.gov.pagopa.common.utils.CommonUtilities; import lombok.extern.slf4j.Slf4j; import org.springframework.data.mongodb.core.FindAndModifyOptions; import org.springframework.data.mongodb.core.ReactiveMongoTemplate; @@ -11,8 +10,6 @@ import org.springframework.stereotype.Repository; import reactor.core.publisher.Mono; -import java.math.BigDecimal; - @Repository @Slf4j public class InitiativeCountersReservationOpsRepositoryImpl implements InitiativeCountersReservationOpsRepository { @@ -28,9 +25,8 @@ public InitiativeCountersReservationOpsRepositoryImpl(ReactiveMongoTemplate mong this.mongoTemplate = mongoTemplate; } - public Mono reserveBudget(String initiativeId, BigDecimal reservation) { - log.trace("[ONBOARDING_REQUEST] [BUDGET_RESERVATION] Reserving budget {} on initiative {}", reservation, initiativeId); - long reservationCents = CommonUtilities.euroToCents(reservation); + public Mono reserveBudget(String initiativeId, Long reservationCents) { + log.trace("[ONBOARDING_REQUEST] [BUDGET_RESERVATION] Reserving budget {} on initiative {}", reservationCents, initiativeId); return mongoTemplate.findAndModify( Query.query(Criteria diff --git a/src/main/java/it/gov/pagopa/admissibility/dto/onboarding/EvaluationCompletedDTO.java b/src/main/java/it/gov/pagopa/admissibility/dto/onboarding/EvaluationCompletedDTO.java index 3e4a2838..e9271700 100644 --- a/src/main/java/it/gov/pagopa/admissibility/dto/onboarding/EvaluationCompletedDTO.java +++ b/src/main/java/it/gov/pagopa/admissibility/dto/onboarding/EvaluationCompletedDTO.java @@ -3,17 +3,13 @@ import it.gov.pagopa.admissibility.enums.OnboardingEvaluationStatus; import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; -import java.math.BigDecimal; +import lombok.*; +import lombok.experimental.SuperBuilder; +import net.minidev.json.annotate.JsonIgnore; + import java.time.LocalDate; import java.util.ArrayList; import java.util.List; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.ToString; -import lombok.experimental.SuperBuilder; -import net.minidev.json.annotate.JsonIgnore; @Data @EqualsAndHashCode(callSuper = true) @@ -29,7 +25,7 @@ public class EvaluationCompletedDTO extends EvaluationDTO{ private OnboardingEvaluationStatus status; @NotNull private List onboardingRejectionReasons = new ArrayList<>(); - private BigDecimal beneficiaryBudget; + private Long beneficiaryBudgetCents; @JsonIgnore private Long rankingValue; private String initiativeRewardType; diff --git a/src/main/java/it/gov/pagopa/admissibility/dto/rule/InitiativeGeneralDTO.java b/src/main/java/it/gov/pagopa/admissibility/dto/rule/InitiativeGeneralDTO.java index d194e3d8..3f42144a 100644 --- a/src/main/java/it/gov/pagopa/admissibility/dto/rule/InitiativeGeneralDTO.java +++ b/src/main/java/it/gov/pagopa/admissibility/dto/rule/InitiativeGeneralDTO.java @@ -3,16 +3,11 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonValue; -import java.math.BigDecimal; -import java.time.LocalDate; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.ToString; +import lombok.*; import org.springframework.validation.annotation.Validated; +import java.time.LocalDate; + /** * InitiativeGeneralDTO */ @@ -30,8 +25,8 @@ public class InitiativeGeneralDTO { @JsonProperty("name") private String name; - @JsonProperty("budget") - private BigDecimal budget; + @JsonProperty("budgetCents") + private Long budgetCents; @JsonProperty("beneficiaryType") private BeneficiaryTypeEnum beneficiaryType; @@ -39,8 +34,8 @@ public class InitiativeGeneralDTO { @JsonProperty("beneficiaryKnown") private Boolean beneficiaryKnown; - @JsonProperty("beneficiaryBudget") - private BigDecimal beneficiaryBudget; + @JsonProperty("beneficiaryBudgetCents") + private Long beneficiaryBudgetCents; @JsonProperty("startDate") private LocalDate startDate; diff --git a/src/main/java/it/gov/pagopa/admissibility/mapper/Initiative2InitiativeConfigMapper.java b/src/main/java/it/gov/pagopa/admissibility/mapper/Initiative2InitiativeConfigMapper.java index 47fc6143..72d5ce9a 100644 --- a/src/main/java/it/gov/pagopa/admissibility/mapper/Initiative2InitiativeConfigMapper.java +++ b/src/main/java/it/gov/pagopa/admissibility/mapper/Initiative2InitiativeConfigMapper.java @@ -28,8 +28,8 @@ public InitiativeConfig apply(Initiative2BuildDTO initiative) { .status(initiative.getStatus()) .automatedCriteria(automatedCriteriaList) .automatedCriteriaCodes(automatedCriteriaList != null ? automatedCriteriaList.stream().map(AutomatedCriteriaDTO::getCode).toList() : null) - .initiativeBudget(initiative.getGeneral().getBudget()) - .beneficiaryInitiativeBudget(initiative.getGeneral().getBeneficiaryBudget()) + .initiativeBudgetCents(initiative.getGeneral().getBudgetCents()) + .beneficiaryInitiativeBudgetCents(initiative.getGeneral().getBeneficiaryBudgetCents()) .startDate(ObjectUtils.firstNonNull(initiative.getGeneral().getRankingStartDate(), initiative.getGeneral().getStartDate())) .endDate(ObjectUtils.firstNonNull(initiative.getGeneral().getRankingEndDate(), initiative.getGeneral().getEndDate())) .rankingInitiative(initiative.getGeneral().isRankingEnabled()) diff --git a/src/main/java/it/gov/pagopa/admissibility/mapper/Onboarding2EvaluationMapper.java b/src/main/java/it/gov/pagopa/admissibility/mapper/Onboarding2EvaluationMapper.java index 93f9fdd9..c0702e1f 100644 --- a/src/main/java/it/gov/pagopa/admissibility/mapper/Onboarding2EvaluationMapper.java +++ b/src/main/java/it/gov/pagopa/admissibility/mapper/Onboarding2EvaluationMapper.java @@ -47,7 +47,7 @@ private EvaluationCompletedDTO getEvaluationCompletedDTO(OnboardingDTO onboardin out.setInitiativeEndDate(initiative.getEndDate()); out.setOrganizationId(initiative.getOrganizationId()); out.setOrganizationName(initiative.getOrganizationName()); - out.setBeneficiaryBudget(initiative.getBeneficiaryInitiativeBudget()); + out.setBeneficiaryBudgetCents(initiative.getBeneficiaryInitiativeBudgetCents()); out.setInitiativeRewardType(initiative.getInitiativeRewardType()); out.setIsLogoPresent(initiative.getIsLogoPresent()); setRankingValue(onboardingDTO, initiative, out); diff --git a/src/main/java/it/gov/pagopa/admissibility/model/InitiativeConfig.java b/src/main/java/it/gov/pagopa/admissibility/model/InitiativeConfig.java index 99ff12ef..079536b1 100644 --- a/src/main/java/it/gov/pagopa/admissibility/model/InitiativeConfig.java +++ b/src/main/java/it/gov/pagopa/admissibility/model/InitiativeConfig.java @@ -8,7 +8,6 @@ import lombok.NoArgsConstructor; import lombok.experimental.FieldNameConstants; -import java.math.BigDecimal; import java.time.LocalDate; import java.util.List; @@ -28,8 +27,8 @@ public class InitiativeConfig { private LocalDate endDate; private List automatedCriteria; private List automatedCriteriaCodes; - private BigDecimal initiativeBudget; - private BigDecimal beneficiaryInitiativeBudget; + private Long initiativeBudgetCents; + private Long beneficiaryInitiativeBudgetCents; private boolean rankingInitiative; private List rankingFields; private String initiativeRewardType; diff --git a/src/main/java/it/gov/pagopa/admissibility/service/InitiativeStatusServiceImpl.java b/src/main/java/it/gov/pagopa/admissibility/service/InitiativeStatusServiceImpl.java index ca3265ae..dc9c0494 100644 --- a/src/main/java/it/gov/pagopa/admissibility/service/InitiativeStatusServiceImpl.java +++ b/src/main/java/it/gov/pagopa/admissibility/service/InitiativeStatusServiceImpl.java @@ -1,14 +1,12 @@ package it.gov.pagopa.admissibility.service; -import it.gov.pagopa.admissibility.dto.onboarding.InitiativeStatusDTO; import it.gov.pagopa.admissibility.connector.repository.InitiativeCountersRepository; +import it.gov.pagopa.admissibility.dto.onboarding.InitiativeStatusDTO; import it.gov.pagopa.admissibility.service.onboarding.OnboardingContextHolderService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import reactor.core.publisher.Mono; -import java.math.BigDecimal; - @Service @Slf4j public class InitiativeStatusServiceImpl implements InitiativeStatusService { @@ -33,7 +31,7 @@ public Mono getInitiativeStatusAndBudgetAvailable(String in initiativeStatus.setBudgetAvailable( isInitiativeBudgetAvailable( initiativeCounters.getResidualInitiativeBudgetCents(), - initiativeConfig.getBeneficiaryInitiativeBudget() + initiativeConfig.getBeneficiaryInitiativeBudgetCents() ) ); @@ -44,8 +42,7 @@ public Mono getInitiativeStatusAndBudgetAvailable(String in ); } - private boolean isInitiativeBudgetAvailable(Long residualBudget, BigDecimal beneficiaryBudget) { - BigDecimal residualBudgetBigDecimal = BigDecimal.valueOf(residualBudget); - return residualBudgetBigDecimal.compareTo(beneficiaryBudget.multiply(BigDecimal.valueOf(100))) > -1; + private boolean isInitiativeBudgetAvailable(Long residualBudget, Long beneficiaryBudget) { + return residualBudget.compareTo(beneficiaryBudget) > -1; } } diff --git a/src/main/java/it/gov/pagopa/admissibility/service/build/InitInitiativeCounterServiceImpl.java b/src/main/java/it/gov/pagopa/admissibility/service/build/InitInitiativeCounterServiceImpl.java index a89e0363..61c4e784 100644 --- a/src/main/java/it/gov/pagopa/admissibility/service/build/InitInitiativeCounterServiceImpl.java +++ b/src/main/java/it/gov/pagopa/admissibility/service/build/InitInitiativeCounterServiceImpl.java @@ -3,7 +3,6 @@ import it.gov.pagopa.admissibility.connector.repository.InitiativeCountersRepository; import it.gov.pagopa.admissibility.model.InitiativeConfig; import it.gov.pagopa.admissibility.model.InitiativeCounters; -import it.gov.pagopa.common.utils.CommonUtilities; import org.springframework.stereotype.Service; import reactor.core.publisher.Mono; @@ -20,7 +19,7 @@ public InitInitiativeCounterServiceImpl(InitiativeCountersRepository initiativeC public Mono initCounters(InitiativeConfig initiative) { return initiativeCountersRepository.findById(initiative.getInitiativeId()) .map(counter2update -> { - final long initiativeBudgetCents = CommonUtilities.euroToCents(initiative.getInitiativeBudget()); + final long initiativeBudgetCents = initiative.getInitiativeBudgetCents(); final long deltaBudget = initiativeBudgetCents - counter2update.getInitiativeBudgetCents(); counter2update.setInitiativeBudgetCents(initiativeBudgetCents); @@ -33,11 +32,10 @@ public Mono initCounters(InitiativeConfig initiative) { } private InitiativeCounters initiativeConfig2InitiativeCounter(InitiativeConfig initiative) { - final long initiativeBudgetCents = CommonUtilities.euroToCents(initiative.getInitiativeBudget()); return InitiativeCounters.builder() .id(initiative.getInitiativeId()) - .initiativeBudgetCents(initiativeBudgetCents) - .residualInitiativeBudgetCents(initiativeBudgetCents) + .initiativeBudgetCents(initiative.getInitiativeBudgetCents()) + .residualInitiativeBudgetCents(initiative.getInitiativeBudgetCents()) .build(); } } diff --git a/src/main/java/it/gov/pagopa/admissibility/service/onboarding/evaluate/OnboardingRequestEvaluatorServiceImpl.java b/src/main/java/it/gov/pagopa/admissibility/service/onboarding/evaluate/OnboardingRequestEvaluatorServiceImpl.java index 43105816..b8d1a805 100644 --- a/src/main/java/it/gov/pagopa/admissibility/service/onboarding/evaluate/OnboardingRequestEvaluatorServiceImpl.java +++ b/src/main/java/it/gov/pagopa/admissibility/service/onboarding/evaluate/OnboardingRequestEvaluatorServiceImpl.java @@ -1,12 +1,12 @@ package it.gov.pagopa.admissibility.service.onboarding.evaluate; +import it.gov.pagopa.admissibility.connector.repository.InitiativeCountersRepository; import it.gov.pagopa.admissibility.dto.onboarding.EvaluationCompletedDTO; import it.gov.pagopa.admissibility.dto.onboarding.EvaluationDTO; import it.gov.pagopa.admissibility.dto.onboarding.OnboardingDTO; import it.gov.pagopa.admissibility.dto.onboarding.OnboardingRejectionReason; import it.gov.pagopa.admissibility.enums.OnboardingEvaluationStatus; import it.gov.pagopa.admissibility.model.InitiativeConfig; -import it.gov.pagopa.admissibility.connector.repository.InitiativeCountersRepository; import it.gov.pagopa.admissibility.utils.OnboardingConstants; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -31,7 +31,7 @@ public Mono evaluate(OnboardingDTO onboardingRequest, InitiativeC if (result instanceof EvaluationCompletedDTO evaluationCompletedDTO) { if (OnboardingEvaluationStatus.ONBOARDING_OK.equals((evaluationCompletedDTO.getStatus()))) { log.trace("[ONBOARDING_REQUEST] [RULE_ENGINE] rule engine meet automated criteria of user {} into initiative {}", onboardingRequest.getUserId(), onboardingRequest.getInitiativeId()); - return initiativeCountersRepository.reserveBudget(onboardingRequest.getInitiativeId(), initiativeConfig.getBeneficiaryInitiativeBudget()) + return initiativeCountersRepository.reserveBudget(onboardingRequest.getInitiativeId(), initiativeConfig.getBeneficiaryInitiativeBudgetCents()) .map(c -> { log.info("[ONBOARDING_REQUEST] [ONBOARDING_OK] [BUDGET_RESERVATION] user {} reserved budget on initiative {}", onboardingRequest.getUserId(), initiativeConfig.getInitiativeId()); onboardingRequest.setBudgetReserved(true); diff --git a/src/test/java/it/gov/pagopa/admissibility/connector/repository/InitiativeCountersReservationOpsRepositoryImplTest.java b/src/test/java/it/gov/pagopa/admissibility/connector/repository/InitiativeCountersReservationOpsRepositoryImplTest.java index 7716b7dd..40db1962 100644 --- a/src/test/java/it/gov/pagopa/admissibility/connector/repository/InitiativeCountersReservationOpsRepositoryImplTest.java +++ b/src/test/java/it/gov/pagopa/admissibility/connector/repository/InitiativeCountersReservationOpsRepositoryImplTest.java @@ -27,7 +27,7 @@ void testReservation() { int N = 1000; final BigDecimal budget = BigDecimal.valueOf(10099); - final BigDecimal budgetReservedPerRequest = BigDecimal.valueOf(100); + final Long budgetReservedPerRequest = 100_00L; final BigDecimal expectedBudgetReserved = BigDecimal.valueOf(10000); final BigDecimal expectedBudgetResidual = BigDecimal.valueOf(99); final int expectedReservations = 100; diff --git a/src/test/java/it/gov/pagopa/admissibility/dto/rule/Initiative2BuildDTOTest.java b/src/test/java/it/gov/pagopa/admissibility/dto/rule/Initiative2BuildDTOTest.java index c4477664..799adf10 100644 --- a/src/test/java/it/gov/pagopa/admissibility/dto/rule/Initiative2BuildDTOTest.java +++ b/src/test/java/it/gov/pagopa/admissibility/dto/rule/Initiative2BuildDTOTest.java @@ -7,7 +7,6 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import java.math.BigDecimal; import java.time.LocalDate; import java.util.List; @@ -16,7 +15,7 @@ class Initiative2BuildDTOTest { @Test void testDeserialization() throws JsonProcessingException { //given - String payload = "{\"initiativeId\":\"62f12c58f85da16207b3c593\",\"initiativeName\":\"Ball\",\"organizationId\":\"2f63a151-da4e-4e1e-acf9-adecc0c4d727\",\"status\":\"DRAFT\",\"creationDate\":\"2022-08-08T15:31:36.572\",\"updateDate\":\"2022-08-08T15:31:41.9943445\",\"general\":{\"budget\":61514.86,\"beneficiaryType\":\"PF\",\"beneficiaryKnown\":false,\"beneficiaryBudget\":381,\"startDate\":\"2022-10-08\",\"endDate\":\"2022-11-08\",\"rankingStartDate\":\"2022-08-08\",\"rankingEndDate\":\"2022-09-08\"},\"additionalInfo\":{\"serviceName\":\"Tuna\",\"argument\":\"Velit mollitia consequatur aut mollitia quas modi a quia.\",\"description\":\"Totam sit aspernatur natus est accusantium ad quisquam architecto.\",\"channels\":[{\"type\":\"web\",\"contact\":\"http://jayme.name\"}]},\"beneficiaryRule\":{\"selfDeclarationCriteria\":[{\"_type\":\"boolean\",\"description\":\"Modi tempora nesciunt excepturi doloribus accusamus corporis ut.\",\"value\":false,\"code\":\"1\"},{\"_type\":\"multi\",\"description\":\"Et aut consequatur at.\",\"value\":[\"Shoes\",\"Games\",\"Jewelery\"],\"code\":\"2\"}],\"automatedCriteria\":[{\"authority\":\"INPS\",\"code\":\"ISEE\",\"operator\":\"BTW_OPEN\",\"value\":\"6.62\",\"value2\":\"54.8\",\"pdndConfig\":{\"clientId\":\"CLIENTID\",\"kid\":\"KID\",\"purposeId\":\"PURPOSEID_ISEE\"}},{\"authority\":\"AUTH2\",\"code\":\"RESIDENCE\",\"field\":\"city\",\"operator\":\"IN\",\"value\":\"Roma\",\"pdndConfig\":{\"clientId\":\"CLIENTID\",\"kid\":\"KID\",\"purposeId\":\"PURPOSEID_RESIDENCE\"}},{\"authority\":\"AUTH1\",\"code\":\"BIRTHDATE\",\"field\":\"year\",\"operator\":\"LT\",\"value\":\"1801\",\"pdndConfig\":{\"clientId\":\"CLIENTID\",\"kid\":\"KID\",\"purposeId\":\"PURPOSEID_BIRTHDATE\"}}],\"apiKeyClientId\":\"apiKeyClientId\",\"apiKeyClientAssertion\":\"apiKeyClientAssertion\"},\"rewardRule\":{\"_type\":\"rewardGroups\",\"rewardGroups\":[{\"from\":0.25,\"to\":1,\"rewardValue\":100}]},\"trxRule\":{\"daysOfWeek\":[{\"daysOfWeek\":[\"FRIDAY\"],\"intervals\":[{\"startTime\":\"00:00:00.000\",\"endTime\":\"15:31:41.794\"}]}],\"threshold\":{\"from\":10,\"fromIncluded\":true,\"to\":50,\"toIncluded\":true},\"trxCount\":{\"from\":1,\"fromIncluded\":true,\"to\":3,\"toIncluded\":true},\"mccFilter\":{\"allowedList\":true,\"values\":[\"0743\",\"0744\",\"0742\"]},\"rewardLimits\":[{\"frequency\":\"DAILY\",\"rewardLimit\":3}]}}"; + String payload = "{\"initiativeId\":\"62f12c58f85da16207b3c593\",\"initiativeName\":\"Ball\",\"organizationId\":\"2f63a151-da4e-4e1e-acf9-adecc0c4d727\",\"status\":\"DRAFT\",\"creationDate\":\"2022-08-08T15:31:36.572\",\"updateDate\":\"2022-08-08T15:31:41.9943445\",\"general\":{\"budgetCents\":6151486,\"beneficiaryType\":\"PF\",\"beneficiaryKnown\":false,\"beneficiaryBudgetCents\":38100,\"startDate\":\"2022-10-08\",\"endDate\":\"2022-11-08\",\"rankingStartDate\":\"2022-08-08\",\"rankingEndDate\":\"2022-09-08\"},\"additionalInfo\":{\"serviceName\":\"Tuna\",\"argument\":\"Velit mollitia consequatur aut mollitia quas modi a quia.\",\"description\":\"Totam sit aspernatur natus est accusantium ad quisquam architecto.\",\"channels\":[{\"type\":\"web\",\"contact\":\"http://jayme.name\"}]},\"beneficiaryRule\":{\"selfDeclarationCriteria\":[{\"_type\":\"boolean\",\"description\":\"Modi tempora nesciunt excepturi doloribus accusamus corporis ut.\",\"value\":false,\"code\":\"1\"},{\"_type\":\"multi\",\"description\":\"Et aut consequatur at.\",\"value\":[\"Shoes\",\"Games\",\"Jewelery\"],\"code\":\"2\"}],\"automatedCriteria\":[{\"authority\":\"INPS\",\"code\":\"ISEE\",\"operator\":\"BTW_OPEN\",\"value\":\"6.62\",\"value2\":\"54.8\",\"pdndConfig\":{\"clientId\":\"CLIENTID\",\"kid\":\"KID\",\"purposeId\":\"PURPOSEID_ISEE\"}},{\"authority\":\"AUTH2\",\"code\":\"RESIDENCE\",\"field\":\"city\",\"operator\":\"IN\",\"value\":\"Roma\",\"pdndConfig\":{\"clientId\":\"CLIENTID\",\"kid\":\"KID\",\"purposeId\":\"PURPOSEID_RESIDENCE\"}},{\"authority\":\"AUTH1\",\"code\":\"BIRTHDATE\",\"field\":\"year\",\"operator\":\"LT\",\"value\":\"1801\",\"pdndConfig\":{\"clientId\":\"CLIENTID\",\"kid\":\"KID\",\"purposeId\":\"PURPOSEID_BIRTHDATE\"}}],\"apiKeyClientId\":\"apiKeyClientId\",\"apiKeyClientAssertion\":\"apiKeyClientAssertion\"},\"rewardRule\":{\"_type\":\"rewardGroups\",\"rewardGroups\":[{\"from\":0.25,\"to\":1,\"rewardValue\":100}]},\"trxRule\":{\"daysOfWeek\":[{\"daysOfWeek\":[\"FRIDAY\"],\"intervals\":[{\"startTime\":\"00:00:00.000\",\"endTime\":\"15:31:41.794\"}]}],\"threshold\":{\"from\":10,\"fromIncluded\":true,\"to\":50,\"toIncluded\":true},\"trxCount\":{\"from\":1,\"fromIncluded\":true,\"to\":3,\"toIncluded\":true},\"mccFilter\":{\"allowedList\":true,\"values\":[\"0743\",\"0744\",\"0742\"]},\"rewardLimits\":[{\"frequency\":\"DAILY\",\"rewardLimit\":3}]}}"; Initiative2BuildDTO expected = new Initiative2BuildDTO(); expected.setInitiativeId("62f12c58f85da16207b3c593"); @@ -25,10 +24,10 @@ void testDeserialization() throws JsonProcessingException { expected.setStatus("DRAFT"); final InitiativeGeneralDTO expectedGeneral = new InitiativeGeneralDTO(); - expectedGeneral.setBudget(BigDecimal.valueOf(61514.86)); + expectedGeneral.setBudgetCents(61514_86L); expectedGeneral.setBeneficiaryType(InitiativeGeneralDTO.BeneficiaryTypeEnum.PF); expectedGeneral.setBeneficiaryKnown(false); - expectedGeneral.setBeneficiaryBudget(BigDecimal.valueOf(381)); + expectedGeneral.setBeneficiaryBudgetCents(381_00L); expectedGeneral.setStartDate(LocalDate.of(2022, 10, 8)); expectedGeneral.setEndDate(LocalDate.of(2022, 11, 8)); expectedGeneral.setRankingStartDate(LocalDate.of(2022, 8, 8)); diff --git a/src/test/java/it/gov/pagopa/admissibility/mapper/Initiative2InitiativeConfigMapperTest.java b/src/test/java/it/gov/pagopa/admissibility/mapper/Initiative2InitiativeConfigMapperTest.java index 3a1e65c8..1bb17bf2 100644 --- a/src/test/java/it/gov/pagopa/admissibility/mapper/Initiative2InitiativeConfigMapperTest.java +++ b/src/test/java/it/gov/pagopa/admissibility/mapper/Initiative2InitiativeConfigMapperTest.java @@ -9,7 +9,6 @@ import org.junit.jupiter.api.Test; import org.springframework.data.domain.Sort; -import java.math.BigDecimal; import java.time.LocalDate; import java.util.List; @@ -129,8 +128,8 @@ private Initiative2BuildDTO initDto() { initiative2BuildDTO.setGeneral(InitiativeGeneralDTO.builder() .startDate(LocalDate.MIN) .endDate(LocalDate.MAX) - .budget(BigDecimal.TEN) - .beneficiaryBudget(BigDecimal.ONE) + .budgetCents(10_00L) + .beneficiaryBudgetCents(1_00L) .beneficiaryType(InitiativeGeneralDTO.BeneficiaryTypeEnum.PF) .build()); @@ -153,8 +152,8 @@ private void commonAssertions(Initiative2BuildDTO initiative2BuildDTO, Initiativ Assertions.assertSame(initiative2BuildDTO.getOrganizationName(), result.getOrganizationName()); Assertions.assertSame(initiative2BuildDTO.getGeneral().getStartDate(), result.getStartDate()); Assertions.assertSame(initiative2BuildDTO.getGeneral().getEndDate(), result.getEndDate()); - Assertions.assertSame(initiative2BuildDTO.getGeneral().getBudget(), result.getInitiativeBudget()); - Assertions.assertSame(initiative2BuildDTO.getGeneral().getBeneficiaryBudget(), result.getBeneficiaryInitiativeBudget()); + Assertions.assertSame(initiative2BuildDTO.getGeneral().getBudgetCents(), result.getInitiativeBudgetCents()); + Assertions.assertSame(initiative2BuildDTO.getGeneral().getBeneficiaryBudgetCents(), result.getBeneficiaryInitiativeBudgetCents()); Assertions.assertSame(initiative2BuildDTO.getGeneral().getBeneficiaryType(), result.getBeneficiaryType()); Assertions.assertSame(initiative2BuildDTO.getStatus(), result.getStatus()); Assertions.assertSame(initiative2BuildDTO.getBeneficiaryRule().getAutomatedCriteria(), result.getAutomatedCriteria()); diff --git a/src/test/java/it/gov/pagopa/admissibility/mapper/Onboarding2EvaluationMapperTest.java b/src/test/java/it/gov/pagopa/admissibility/mapper/Onboarding2EvaluationMapperTest.java index d1e787f7..2742183e 100644 --- a/src/test/java/it/gov/pagopa/admissibility/mapper/Onboarding2EvaluationMapperTest.java +++ b/src/test/java/it/gov/pagopa/admissibility/mapper/Onboarding2EvaluationMapperTest.java @@ -61,7 +61,7 @@ void setUp() { initiativeConfig.setInitiativeName("INITIATIVENAME"); initiativeConfig.setOrganizationId("ORGANIZATIONID"); initiativeConfig.setOrganizationName("ORGANIZATIONNAME"); - initiativeConfig.setBeneficiaryInitiativeBudget(BigDecimal.TEN); + initiativeConfig.setBeneficiaryInitiativeBudgetCents(10_00L); initiativeConfig.setInitiativeRewardType("REFUND"); initiativeConfig.setIsLogoPresent(Boolean.FALSE); initiativeConfig.setEndDate(LocalDate.now()); @@ -87,7 +87,7 @@ void onboarding2EvaluationOnboardingOkTest() { Assertions.assertEquals(OnboardingEvaluationStatus.ONBOARDING_OK, resultCompleted.getStatus()); - Assertions.assertEquals(0, BigDecimal.TEN.compareTo(resultCompleted.getBeneficiaryBudget())); + Assertions.assertEquals(0, Long.valueOf(10_00L).compareTo(resultCompleted.getBeneficiaryBudgetCents())); Assertions.assertTrue(CollectionUtils.isEmpty(resultCompleted.getOnboardingRejectionReasons())); TestUtils.checkNotNullFields(resultCompleted,"rankingValue"); @@ -118,7 +118,7 @@ void onboarding2EvaluationOnboardingKoTest() { Assertions.assertNull(resultCompleted.getInitiativeName()); Assertions.assertNull(resultCompleted.getOrganizationId()); Assertions.assertNull(resultCompleted.getOrganizationName()); - Assertions.assertNull(resultCompleted.getBeneficiaryBudget()); + Assertions.assertNull(resultCompleted.getBeneficiaryBudgetCents()); Assertions.assertNull(resultCompleted.getInitiativeEndDate()); Assertions.assertNull(resultCompleted.getInitiativeRewardType()); Assertions.assertNull(resultCompleted.getRankingValue()); @@ -126,7 +126,7 @@ void onboarding2EvaluationOnboardingKoTest() { Assertions.assertEquals(rejectReasons, resultCompleted.getOnboardingRejectionReasons()); - TestUtils.checkNotNullFields(resultCompleted, "familyId", "memberIds", "initiativeName", "organizationId", "organizationName", "serviceId", "initiativeEndDate", "beneficiaryBudget", "rankingValue", "initiativeRewardType", "isLogoPresent"); + TestUtils.checkNotNullFields(resultCompleted, "familyId", "memberIds", "initiativeName", "organizationId", "organizationName", "serviceId", "initiativeEndDate", "beneficiaryBudgetCents", "rankingValue", "initiativeRewardType", "isLogoPresent"); } @Test @@ -198,7 +198,7 @@ void onboarding2EvaluationOnboardingKoRankingTest() { Assertions.assertEquals(OnboardingEvaluationStatus.ONBOARDING_KO, resultCompleted.getStatus()); commonAssertionsInitiativeConfig2EvaluationCompleted(resultCompleted, CommonUtilities.euroToCents(onboardingRequest.getIsee())); - Assertions.assertEquals(initiativeConfig.getBeneficiaryInitiativeBudget(), resultCompleted.getBeneficiaryBudget()); + Assertions.assertEquals(initiativeConfig.getBeneficiaryInitiativeBudgetCents(), resultCompleted.getBeneficiaryBudgetCents()); Assertions.assertNotNull(resultCompleted.getInitiativeEndDate()); Assertions.assertEquals(rejectReasons, resultCompleted.getOnboardingRejectionReasons()); diff --git a/src/test/java/it/gov/pagopa/admissibility/service/InitiativeStatusServiceImplTest.java b/src/test/java/it/gov/pagopa/admissibility/service/InitiativeStatusServiceImplTest.java index 763684da..dc302cca 100644 --- a/src/test/java/it/gov/pagopa/admissibility/service/InitiativeStatusServiceImplTest.java +++ b/src/test/java/it/gov/pagopa/admissibility/service/InitiativeStatusServiceImplTest.java @@ -12,8 +12,6 @@ import org.mockito.junit.jupiter.MockitoExtension; import reactor.core.publisher.Mono; -import java.math.BigDecimal; - @ExtendWith(MockitoExtension.class) class InitiativeStatusServiceImplTest { @@ -23,12 +21,7 @@ void test() { InitiativeCountersRepository initiativeCountersRepositoryMock = Mockito.mock(InitiativeCountersRepository.class); OnboardingContextHolderService onboardingContextHolderServiceMock = Mockito.mock(OnboardingContextHolderService.class); - InitiativeConfig initiativeConfigMock = InitiativeConfig.builder() - .initiativeId("INITIATIVE1") - .initiativeBudget(BigDecimal.ONE) - .beneficiaryInitiativeBudget(BigDecimal.TEN) - .status("STATUS1") - .build(); + InitiativeConfig initiativeConfigMock = getInitiativeConfigForContextMock(); Mockito.when(onboardingContextHolderServiceMock.getInitiativeConfig(Mockito.anyString())).thenReturn(Mono.just(initiativeConfigMock)); InitiativeCounters initiativeCountersMock = InitiativeCounters.builder() @@ -57,12 +50,7 @@ void testNoInitiative() { InitiativeCountersRepository initiativeCountersRepositoryMock = Mockito.mock(InitiativeCountersRepository.class); OnboardingContextHolderService onboardingContextHolderServiceMock = Mockito.mock(OnboardingContextHolderService.class); - InitiativeConfig initiativeConfigMock = InitiativeConfig.builder() - .initiativeId("INITIATIVE1") - .initiativeBudget(BigDecimal.ONE) - .beneficiaryInitiativeBudget(BigDecimal.TEN) - .status("STATUS1") - .build(); + InitiativeConfig initiativeConfigMock = getInitiativeConfigForContextMock(); Mockito.when(onboardingContextHolderServiceMock.getInitiativeConfig(Mockito.anyString())).thenReturn(Mono.just(initiativeConfigMock)); Mockito.when(initiativeCountersRepositoryMock.findById(Mockito.anyString())).thenReturn(Mono.empty()); @@ -75,4 +63,43 @@ void testNoInitiative() { // Then Assertions.assertNull(result); } + + @Test + void testNotBudgetAvailable(){ + // Given + InitiativeCountersRepository initiativeCountersRepositoryMock = Mockito.mock(InitiativeCountersRepository.class); + OnboardingContextHolderService onboardingContextHolderServiceMock = Mockito.mock(OnboardingContextHolderService.class); + + InitiativeConfig initiativeConfigMock = getInitiativeConfigForContextMock(); + Mockito.when(onboardingContextHolderServiceMock.getInitiativeConfig(Mockito.anyString())).thenReturn(Mono.just(initiativeConfigMock)); + + InitiativeCounters initiativeCountersMock = InitiativeCounters.builder() + .id("INITIATIVE1") + .initiativeBudgetCents(100L) + .onboarded(1L) + .residualInitiativeBudgetCents(100L) + .reservedInitiativeBudgetCents(1000L) + .build(); + Mockito.when(initiativeCountersRepositoryMock.findById(Mockito.anyString())).thenReturn(Mono.just(initiativeCountersMock)); + + InitiativeStatusService initiativeStatusService = new InitiativeStatusServiceImpl(onboardingContextHolderServiceMock, initiativeCountersRepositoryMock); + + InitiativeStatusDTO expected = new InitiativeStatusDTO("STATUS1", false); + + // When + InitiativeStatusDTO result = initiativeStatusService.getInitiativeStatusAndBudgetAvailable("INITIATIVE1").block(); + + // Then + Assertions.assertEquals(expected, result); + + } + + private static InitiativeConfig getInitiativeConfigForContextMock() { + return InitiativeConfig.builder() + .initiativeId("INITIATIVE1") + .initiativeBudgetCents(1_00L) + .beneficiaryInitiativeBudgetCents(10_00L) + .status("STATUS1") + .build(); + } } \ No newline at end of file diff --git a/src/test/java/it/gov/pagopa/admissibility/service/build/BeneficiaryRule2DroolsRuleImplTest.java b/src/test/java/it/gov/pagopa/admissibility/service/build/BeneficiaryRule2DroolsRuleImplTest.java index 49d65174..5f0cf899 100644 --- a/src/test/java/it/gov/pagopa/admissibility/service/build/BeneficiaryRule2DroolsRuleImplTest.java +++ b/src/test/java/it/gov/pagopa/admissibility/service/build/BeneficiaryRule2DroolsRuleImplTest.java @@ -131,8 +131,8 @@ private void checkResult(DroolsRule result, Initiative2BuildDTO dto) { .endDate(LocalDate.of(2025, 12, 1)) .automatedCriteria(dto.getBeneficiaryRule().getAutomatedCriteria()) .automatedCriteriaCodes(List.of("ISEE", "BIRTHDATE")) - .initiativeBudget(new BigDecimal("100000.00")) - .beneficiaryInitiativeBudget(new BigDecimal("1000.00")) + .initiativeBudgetCents(100000_00L) + .beneficiaryInitiativeBudgetCents(1000_00L) .isLogoPresent(Boolean.TRUE) .beneficiaryType(InitiativeGeneralDTO.BeneficiaryTypeEnum.PF) .build()); @@ -197,7 +197,7 @@ void testExecution(List failingCode) { expectedEvaluationResult.setOrganizationId("ORGANIZATIONID"); expectedEvaluationResult.setAdmissibilityCheckDate(evaluationResult.getAdmissibilityCheckDate()); expectedEvaluationResult.setInitiativeEndDate(LocalDate.of(2025, 12, 1)); - expectedEvaluationResult.setBeneficiaryBudget(new BigDecimal("1000.00")); + expectedEvaluationResult.setBeneficiaryBudgetCents(1000_00L); expectedEvaluationResult.setIsLogoPresent(Boolean.TRUE); if (expectedIseeFail) { expectedEvaluationResult.getOnboardingRejectionReasons().add(OnboardingRejectionReason.builder() @@ -242,10 +242,10 @@ private Initiative2BuildDTO buildInitiative() { dto.setGeneral( InitiativeGeneralDTO.builder() .name("NAME") - .budget(new BigDecimal("100000.00")) + .budgetCents(100_000_00L) .beneficiaryType(InitiativeGeneralDTO.BeneficiaryTypeEnum.PF) .beneficiaryKnown(Boolean.TRUE) - .beneficiaryBudget(new BigDecimal("1000.00")) + .beneficiaryBudgetCents(1_000_00L) .startDate(LocalDate.of(2021, 1, 1)) .endDate(LocalDate.of(2025, 12, 1)) .build() diff --git a/src/test/java/it/gov/pagopa/admissibility/service/build/BeneficiaryRuleBuilderMediatorServiceTest.java b/src/test/java/it/gov/pagopa/admissibility/service/build/BeneficiaryRuleBuilderMediatorServiceTest.java index 296d0136..2717cc61 100644 --- a/src/test/java/it/gov/pagopa/admissibility/service/build/BeneficiaryRuleBuilderMediatorServiceTest.java +++ b/src/test/java/it/gov/pagopa/admissibility/service/build/BeneficiaryRuleBuilderMediatorServiceTest.java @@ -60,8 +60,8 @@ void configureMocks() { .startDate(i.getGeneral().getStartDate()) .endDate(i.getGeneral().getEndDate()) .automatedCriteriaCodes(List.of("CODE")) - .initiativeBudget(i.getGeneral().getBudget()) - .beneficiaryInitiativeBudget(i.getGeneral().getBeneficiaryBudget()) + .initiativeBudgetCents(i.getGeneral().getBudgetCents()) + .beneficiaryInitiativeBudgetCents(i.getGeneral().getBeneficiaryBudgetCents()) .build(), LocalDateTime.now()); }); diff --git a/src/test/java/it/gov/pagopa/admissibility/service/build/InitInitiativeCounterServiceImplTest.java b/src/test/java/it/gov/pagopa/admissibility/service/build/InitInitiativeCounterServiceImplTest.java index 888d581d..954ae760 100644 --- a/src/test/java/it/gov/pagopa/admissibility/service/build/InitInitiativeCounterServiceImplTest.java +++ b/src/test/java/it/gov/pagopa/admissibility/service/build/InitInitiativeCounterServiceImplTest.java @@ -13,8 +13,6 @@ import org.mockito.junit.jupiter.MockitoExtension; import reactor.core.publisher.Mono; -import java.math.BigDecimal; - @ExtendWith(MockitoExtension.class) class InitInitiativeCounterServiceImplTest { @@ -28,8 +26,8 @@ class InitInitiativeCounterServiceImplTest { public InitInitiativeCounterServiceImplTest(){ this.initiative = InitiativeConfig.builder() .initiativeId("ID") - .initiativeBudget(BigDecimal.ONE) - .beneficiaryInitiativeBudget(BigDecimal.TEN) + .initiativeBudgetCents(1_00L) + .beneficiaryInitiativeBudgetCents(10_00L) .build(); } @@ -63,21 +61,17 @@ private void test(Long expectedOnboarded, Long expectedReservationCents) { Assertions.assertNotNull(result); Assertions.assertSame(initiative.getInitiativeId(), result.getId()); - Assertions.assertEquals(euro2cents(initiative.getInitiativeBudget()), result.getInitiativeBudgetCents()); + Assertions.assertEquals(initiative.getInitiativeBudgetCents(), result.getInitiativeBudgetCents()); checkCounters(result, expectedOnboarded, expectedReservationCents); Mockito.verify(initiativeCountersRepositoryMock).save(Mockito.same(result)); } - private long euro2cents(BigDecimal beneficiaryInitiativeBudget) { - return beneficiaryInitiativeBudget.longValue() * 100; - } - private void checkCounters(InitiativeCounters result, Long expectedOnboarded, Long expectedReservationCents) { Assertions.assertEquals(expectedOnboarded, result.getOnboarded()); Assertions.assertEquals(expectedReservationCents, result.getReservedInitiativeBudgetCents()); - Assertions.assertEquals(euro2cents(initiative.getInitiativeBudget()), result.getResidualInitiativeBudgetCents()); + Assertions.assertEquals(initiative.getInitiativeBudgetCents(), result.getResidualInitiativeBudgetCents()); } } diff --git a/src/test/java/it/gov/pagopa/admissibility/service/onboarding/AuthoritiesDataRetrieverServiceImplTest.java b/src/test/java/it/gov/pagopa/admissibility/service/onboarding/AuthoritiesDataRetrieverServiceImplTest.java index d71792e9..e2905165 100644 --- a/src/test/java/it/gov/pagopa/admissibility/service/onboarding/AuthoritiesDataRetrieverServiceImplTest.java +++ b/src/test/java/it/gov/pagopa/admissibility/service/onboarding/AuthoritiesDataRetrieverServiceImplTest.java @@ -108,8 +108,8 @@ void setUp() { .status("STATUS") .startDate(now) .endDate(now) - .initiativeBudget(new BigDecimal("100")) - .beneficiaryInitiativeBudget(BigDecimal.TEN) + .initiativeBudgetCents(100_00L) + .beneficiaryInitiativeBudgetCents(10_00L) .rankingInitiative(Boolean.TRUE) .automatedCriteria(List.of( new AutomatedCriteriaDTO("AUTH1", CRITERIA_CODE_ISEE, null, FilterOperator.EQ, "1", null, Sort.Direction.ASC, ISEE_TYPOLOGIES_REQUESTED, PDND_INITIATIVE_CONFIG))) diff --git a/src/test/java/it/gov/pagopa/admissibility/service/onboarding/OnboardingContextHolderServiceImplTest.java b/src/test/java/it/gov/pagopa/admissibility/service/onboarding/OnboardingContextHolderServiceImplTest.java index a44d7dc5..0c750e6f 100644 --- a/src/test/java/it/gov/pagopa/admissibility/service/onboarding/OnboardingContextHolderServiceImplTest.java +++ b/src/test/java/it/gov/pagopa/admissibility/service/onboarding/OnboardingContextHolderServiceImplTest.java @@ -27,7 +27,6 @@ import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; -import java.math.BigDecimal; import java.time.LocalDate; import java.util.ArrayList; import java.util.Collections; @@ -134,10 +133,10 @@ void testSetInitiativeConfig(boolean isRedisCacheEnabled){ InitiativeConfig initiativeConfig = InitiativeConfig.builder() .initiativeId(initiativeId) .beneficiaryType(InitiativeGeneralDTO.BeneficiaryTypeEnum.PF) - .beneficiaryInitiativeBudget(BigDecimal.valueOf(100)) + .beneficiaryInitiativeBudgetCents(100_00L) .endDate(LocalDate.MAX) .initiativeName("NAME") - .initiativeBudget(BigDecimal.valueOf(100)) + .initiativeBudgetCents(100_00L) .status("STATUS") .automatedCriteria(new ArrayList<>()) .automatedCriteriaCodes(List.of("CODE1")) diff --git a/src/test/java/it/gov/pagopa/admissibility/service/onboarding/evaluate/OnboardingRequestEvaluatorServiceTest.java b/src/test/java/it/gov/pagopa/admissibility/service/onboarding/evaluate/OnboardingRequestEvaluatorServiceTest.java index 6e1301fa..d2197604 100644 --- a/src/test/java/it/gov/pagopa/admissibility/service/onboarding/evaluate/OnboardingRequestEvaluatorServiceTest.java +++ b/src/test/java/it/gov/pagopa/admissibility/service/onboarding/evaluate/OnboardingRequestEvaluatorServiceTest.java @@ -1,5 +1,6 @@ package it.gov.pagopa.admissibility.service.onboarding.evaluate; +import it.gov.pagopa.admissibility.connector.repository.InitiativeCountersRepository; import it.gov.pagopa.admissibility.dto.onboarding.EvaluationCompletedDTO; import it.gov.pagopa.admissibility.dto.onboarding.EvaluationDTO; import it.gov.pagopa.admissibility.dto.onboarding.OnboardingDTO; @@ -7,7 +8,6 @@ import it.gov.pagopa.admissibility.enums.OnboardingEvaluationStatus; import it.gov.pagopa.admissibility.model.InitiativeConfig; import it.gov.pagopa.admissibility.model.InitiativeCounters; -import it.gov.pagopa.admissibility.connector.repository.InitiativeCountersRepository; import it.gov.pagopa.admissibility.utils.OnboardingConstants; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -18,7 +18,6 @@ import org.mockito.junit.jupiter.MockitoExtension; import reactor.core.publisher.Mono; -import java.math.BigDecimal; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -40,8 +39,8 @@ class OnboardingRequestEvaluatorServiceTest { public OnboardingRequestEvaluatorServiceTest(){ onboardingRequest.setInitiativeId("ID"); - initiativeConfig.setInitiativeBudget(BigDecimal.TEN); - initiativeConfig.setBeneficiaryInitiativeBudget(BigDecimal.ONE); + initiativeConfig.setInitiativeBudgetCents(10_00L); + initiativeConfig.setBeneficiaryInitiativeBudgetCents(1_00L); } @Test @@ -87,7 +86,7 @@ private void configureSuccesfulRuleEngine(){ void testRejectedNoBudget(){ //given configureSuccesfulRuleEngine(); - Mockito.when(initiativeCountersRepository.reserveBudget(Mockito.same(onboardingRequest.getInitiativeId()), Mockito.same(initiativeConfig.getBeneficiaryInitiativeBudget()))) + Mockito.when(initiativeCountersRepository.reserveBudget(Mockito.same(onboardingRequest.getInitiativeId()), Mockito.same(initiativeConfig.getBeneficiaryInitiativeBudgetCents()))) .thenReturn(Mono.empty()); //when @@ -108,7 +107,7 @@ void testRejectedNoBudget(){ , resultCompleted.getOnboardingRejectionReasons()); Mockito.verify(ruleEngineService).applyRules(Mockito.same(onboardingRequest), Mockito.same(initiativeConfig)); - Mockito.verify(initiativeCountersRepository).reserveBudget(Mockito.same(onboardingRequest.getInitiativeId()), Mockito.same(initiativeConfig.getBeneficiaryInitiativeBudget())); + Mockito.verify(initiativeCountersRepository).reserveBudget(Mockito.same(onboardingRequest.getInitiativeId()), Mockito.same(initiativeConfig.getBeneficiaryInitiativeBudgetCents())); Mockito.verifyNoMoreInteractions(ruleEngineService, initiativeCountersRepository); } @@ -117,7 +116,7 @@ void testRejectedNoBudget(){ void testSuccessful(){ //give configureSuccesfulRuleEngine(); - Mockito.when(initiativeCountersRepository.reserveBudget(Mockito.same(onboardingRequest.getInitiativeId()), Mockito.same(initiativeConfig.getBeneficiaryInitiativeBudget()))) + Mockito.when(initiativeCountersRepository.reserveBudget(Mockito.same(onboardingRequest.getInitiativeId()), Mockito.same(initiativeConfig.getBeneficiaryInitiativeBudgetCents()))) .thenReturn(Mono.just(new InitiativeCounters())); //when @@ -132,7 +131,7 @@ void testSuccessful(){ Assertions.assertEquals(Collections.emptyList(), resultCompleted.getOnboardingRejectionReasons()); Mockito.verify(ruleEngineService).applyRules(Mockito.same(onboardingRequest), Mockito.same(initiativeConfig)); - Mockito.verify(initiativeCountersRepository).reserveBudget(Mockito.same(onboardingRequest.getInitiativeId()), Mockito.same(initiativeConfig.getBeneficiaryInitiativeBudget())); + Mockito.verify(initiativeCountersRepository).reserveBudget(Mockito.same(onboardingRequest.getInitiativeId()), Mockito.same(initiativeConfig.getBeneficiaryInitiativeBudgetCents())); Mockito.verifyNoMoreInteractions(ruleEngineService, initiativeCountersRepository); } diff --git a/src/test/java/it/gov/pagopa/admissibility/test/fakers/Initiative2BuildDTOFaker.java b/src/test/java/it/gov/pagopa/admissibility/test/fakers/Initiative2BuildDTOFaker.java index f5377c57..36f93a8c 100644 --- a/src/test/java/it/gov/pagopa/admissibility/test/fakers/Initiative2BuildDTOFaker.java +++ b/src/test/java/it/gov/pagopa/admissibility/test/fakers/Initiative2BuildDTOFaker.java @@ -8,7 +8,6 @@ import it.gov.pagopa.admissibility.model.PdndInitiativeConfig; import it.gov.pagopa.common.utils.TestUtils; -import java.math.BigDecimal; import java.time.LocalDate; import java.util.ArrayList; import java.util.List; @@ -17,7 +16,7 @@ public final class Initiative2BuildDTOFaker { - public static final BigDecimal BENEFICIARY_BUDGET = new BigDecimal("1000.00"); + public static final Long BENEFICIARY_BUDGET = 1000_00L; private Initiative2BuildDTOFaker(){} @@ -28,9 +27,9 @@ public static Initiative2BuildDTO mockInstance(Integer bias){ return mockInstanceBuilder(bias).build(); } public static Initiative2BuildDTO.Initiative2BuildDTOBuilder mockInstanceBuilder(Integer bias){ - return mockInstanceBuilder(bias, new BigDecimal("100000.00")); + return mockInstanceBuilder(bias, 100_000_00L); } - public static Initiative2BuildDTO.Initiative2BuildDTOBuilder mockInstanceBuilder(Integer bias, BigDecimal budget){ + public static Initiative2BuildDTO.Initiative2BuildDTOBuilder mockInstanceBuilder(Integer bias, Long budget){ Initiative2BuildDTO.Initiative2BuildDTOBuilder out = Initiative2BuildDTO.builder(); FakeValuesService fakeValuesService = getFakeValuesService(bias); @@ -53,10 +52,10 @@ public static Initiative2BuildDTO.Initiative2BuildDTOBuilder mockInstanceBuilder out.general( InitiativeGeneralDTO.builder() .name("NAME") - .budget(budget) + .budgetCents(budget) .beneficiaryType(InitiativeGeneralDTO.BeneficiaryTypeEnum.PF) .beneficiaryKnown(Boolean.TRUE) - .beneficiaryBudget(BENEFICIARY_BUDGET) + .beneficiaryBudgetCents(BENEFICIARY_BUDGET) .startDate(LocalDate.of(2021, 1, 1)) .endDate(LocalDate.of(2025, 12, 1)) .rankingEnabled(false)