diff --git a/src/main/java/it/gov/pagopa/atmlayer/service/model/dto/BpmnCreationDto.java b/src/main/java/it/gov/pagopa/atmlayer/service/model/dto/BpmnCreationDto.java index 97020ab2..a02c8b8b 100644 --- a/src/main/java/it/gov/pagopa/atmlayer/service/model/dto/BpmnCreationDto.java +++ b/src/main/java/it/gov/pagopa/atmlayer/service/model/dto/BpmnCreationDto.java @@ -1,6 +1,5 @@ package it.gov.pagopa.atmlayer.service.model.dto; -import it.gov.pagopa.atmlayer.service.model.enumeration.FunctionTypeEnum; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Pattern; import jakarta.ws.rs.FormParam; @@ -26,5 +25,5 @@ public class BpmnCreationDto { @FormParam("functionType") @NotNull(message = "function type is required") - private FunctionTypeEnum functionType; + private String functionType; } diff --git a/src/main/java/it/gov/pagopa/atmlayer/service/model/dto/BpmnUpgradeDto.java b/src/main/java/it/gov/pagopa/atmlayer/service/model/dto/BpmnUpgradeDto.java index acfa5f7d..bec7a1c6 100644 --- a/src/main/java/it/gov/pagopa/atmlayer/service/model/dto/BpmnUpgradeDto.java +++ b/src/main/java/it/gov/pagopa/atmlayer/service/model/dto/BpmnUpgradeDto.java @@ -1,6 +1,5 @@ package it.gov.pagopa.atmlayer.service.model.dto; -import it.gov.pagopa.atmlayer.service.model.enumeration.FunctionTypeEnum; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Pattern; import jakarta.ws.rs.FormParam; @@ -8,6 +7,7 @@ import lombok.Data; import lombok.NoArgsConstructor; import org.jboss.resteasy.reactive.PartType; + import java.io.File; import java.util.UUID; @@ -15,21 +15,21 @@ @NoArgsConstructor public class BpmnUpgradeDto { - @FormParam("uuid") - @NotNull(message = "uuid is required") - private UUID uuid; + @FormParam("uuid") + @NotNull(message = "uuid is required") + private UUID uuid; - @FormParam("file") - @PartType(MediaType.APPLICATION_XML) - @NotNull(message = "bpmn file is required") - private File file; + @FormParam("file") + @PartType(MediaType.APPLICATION_XML) + @NotNull(message = "bpmn file is required") + private File file; - @FormParam("filename") - @NotNull(message = "filename is required") - @Pattern(regexp = "^[a-zA-Z0-9_-]+$", message = "deve essere della forma ${regexp} e non contenere l'estensione del file") - private String filename; + @FormParam("filename") + @NotNull(message = "filename is required") + @Pattern(regexp = "^[a-zA-Z0-9_-]+$", message = "deve essere della forma ${regexp} e non contenere l'estensione del file") + private String filename; - @FormParam("functionType") - @NotNull(message = "function type is required") - private FunctionTypeEnum functionType; + @FormParam("functionType") + @NotNull(message = "function type is required") + private String functionType; } diff --git a/src/main/java/it/gov/pagopa/atmlayer/service/model/entity/BpmnBankConfig.java b/src/main/java/it/gov/pagopa/atmlayer/service/model/entity/BpmnBankConfig.java index db463efb..ada71810 100644 --- a/src/main/java/it/gov/pagopa/atmlayer/service/model/entity/BpmnBankConfig.java +++ b/src/main/java/it/gov/pagopa/atmlayer/service/model/entity/BpmnBankConfig.java @@ -1,7 +1,6 @@ package it.gov.pagopa.atmlayer.service.model.entity; import io.quarkus.hibernate.reactive.panache.PanacheEntityBase; -import it.gov.pagopa.atmlayer.service.model.enumeration.FunctionTypeEnum; import jakarta.persistence.Column; import jakarta.persistence.EmbeddedId; import jakarta.persistence.Entity; @@ -30,8 +29,7 @@ public class BpmnBankConfig extends PanacheEntityBase implements Serializable { private BpmnBankConfigPK bpmnBankConfigPK; @Column(name = "function_type") - @Enumerated(EnumType.STRING) - private FunctionTypeEnum functionType; + private String functionType; @CreationTimestamp @Column(name = "created_at") diff --git a/src/main/java/it/gov/pagopa/atmlayer/service/model/entity/BpmnVersion.java b/src/main/java/it/gov/pagopa/atmlayer/service/model/entity/BpmnVersion.java index d76a4ed5..4f635e74 100644 --- a/src/main/java/it/gov/pagopa/atmlayer/service/model/entity/BpmnVersion.java +++ b/src/main/java/it/gov/pagopa/atmlayer/service/model/entity/BpmnVersion.java @@ -1,7 +1,6 @@ package it.gov.pagopa.atmlayer.service.model.entity; import io.quarkus.hibernate.reactive.panache.PanacheEntityBase; -import it.gov.pagopa.atmlayer.service.model.enumeration.FunctionTypeEnum; import it.gov.pagopa.atmlayer.service.model.enumeration.StatusEnum; import jakarta.persistence.CascadeType; import jakarta.persistence.Column; @@ -49,8 +48,7 @@ public class BpmnVersion extends PanacheEntityBase implements Serializable { private String definitionKey; @Column(name = "function_type") - @Enumerated(EnumType.STRING) - private FunctionTypeEnum functionType; + private String functionType; @Column(name = "status") @Enumerated(EnumType.STRING) diff --git a/src/main/java/it/gov/pagopa/atmlayer/service/model/model/BpmnBankConfigDTO.java b/src/main/java/it/gov/pagopa/atmlayer/service/model/model/BpmnBankConfigDTO.java index 3b6a1ae7..77bd52f0 100644 --- a/src/main/java/it/gov/pagopa/atmlayer/service/model/model/BpmnBankConfigDTO.java +++ b/src/main/java/it/gov/pagopa/atmlayer/service/model/model/BpmnBankConfigDTO.java @@ -1,6 +1,5 @@ package it.gov.pagopa.atmlayer.service.model.model; -import it.gov.pagopa.atmlayer.service.model.enumeration.FunctionTypeEnum; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.EqualsAndHashCode; @@ -26,7 +25,7 @@ public class BpmnBankConfigDTO { private String acquirerId; private String branchId; private String terminalId; - private FunctionTypeEnum functionType; + private String functionType; @Schema(description = "Creation Timestamp", format = "date-time", pattern = "DD/MM/YYYY", example = "2023-11-03T14:18:36.635+00:00") private Timestamp createdAt; @Schema(description = "Last Update Timestamp", format = "date-time", pattern = "DD/MM/YYYY", example = "2023-11-03T14:18:36.635+00:00") diff --git a/src/main/java/it/gov/pagopa/atmlayer/service/model/model/BpmnDTO.java b/src/main/java/it/gov/pagopa/atmlayer/service/model/model/BpmnDTO.java index 9f991691..59c86756 100644 --- a/src/main/java/it/gov/pagopa/atmlayer/service/model/model/BpmnDTO.java +++ b/src/main/java/it/gov/pagopa/atmlayer/service/model/model/BpmnDTO.java @@ -1,6 +1,5 @@ package it.gov.pagopa.atmlayer.service.model.model; -import it.gov.pagopa.atmlayer.service.model.enumeration.FunctionTypeEnum; import it.gov.pagopa.atmlayer.service.model.enumeration.StatusEnum; import lombok.AllArgsConstructor; import lombok.Builder; @@ -27,7 +26,7 @@ public class BpmnDTO { private Long modelVersion; private String deployedFileName; private String definitionKey; - private FunctionTypeEnum functionType; + private String functionType; private StatusEnum status; private String sha256; private Integer definitionVersionCamunda; diff --git a/src/main/java/it/gov/pagopa/atmlayer/service/model/model/WorkflowResourceDTO.java b/src/main/java/it/gov/pagopa/atmlayer/service/model/model/WorkflowResourceDTO.java index eb8a03b9..c0600734 100644 --- a/src/main/java/it/gov/pagopa/atmlayer/service/model/model/WorkflowResourceDTO.java +++ b/src/main/java/it/gov/pagopa/atmlayer/service/model/model/WorkflowResourceDTO.java @@ -1,7 +1,6 @@ package it.gov.pagopa.atmlayer.service.model.model; import it.gov.pagopa.atmlayer.service.model.enumeration.DeployableResourceType; -import it.gov.pagopa.atmlayer.service.model.enumeration.FunctionTypeEnum; import it.gov.pagopa.atmlayer.service.model.enumeration.StatusEnum; import lombok.AllArgsConstructor; import lombok.Builder; @@ -26,7 +25,7 @@ public class WorkflowResourceDTO { private UUID workflowResourceId; private String deployedFileName; private String definitionKey; - private FunctionTypeEnum functionType; + private String functionType; private StatusEnum status; private String sha256; private Integer definitionVersionCamunda; diff --git a/src/main/java/it/gov/pagopa/atmlayer/service/model/repository/BpmnBankConfigRepository.java b/src/main/java/it/gov/pagopa/atmlayer/service/model/repository/BpmnBankConfigRepository.java index 2b20828f..3cff5fa4 100644 --- a/src/main/java/it/gov/pagopa/atmlayer/service/model/repository/BpmnBankConfigRepository.java +++ b/src/main/java/it/gov/pagopa/atmlayer/service/model/repository/BpmnBankConfigRepository.java @@ -4,7 +4,6 @@ import io.smallrye.mutiny.Uni; import it.gov.pagopa.atmlayer.service.model.entity.BpmnBankConfig; import it.gov.pagopa.atmlayer.service.model.entity.BpmnBankConfigPK; -import it.gov.pagopa.atmlayer.service.model.enumeration.FunctionTypeEnum; import jakarta.enterprise.context.ApplicationScoped; import java.util.HashMap; @@ -14,7 +13,7 @@ @ApplicationScoped public class BpmnBankConfigRepository implements PanacheRepositoryBase { - public Uni deleteByAcquirerIdAndFunctionType(String acquirerId, FunctionTypeEnum functionType) { + public Uni deleteByAcquirerIdAndFunctionType(String acquirerId, String functionType) { Map params = new HashMap<>(); params.put("acquirerId", acquirerId); params.put("functionType", functionType); @@ -22,14 +21,14 @@ public Uni deleteByAcquirerIdAndFunctionType(String acquirerId, FunctionTy "delete from BpmnBankConfig b where b.bpmnBankConfigPK.acquirerId = :acquirerId and b.functionType= :functionType", params); } - public Uni> findByAcquirerIdAndFunctionType(String acquirerId, FunctionTypeEnum functionType) { + public Uni> findByAcquirerIdAndFunctionType(String acquirerId, String functionType) { Map params = new HashMap<>(); params.put("acquirerId", acquirerId); params.put("functionType", functionType); return list("select b from BpmnBankConfig b where b.bpmnBankConfigPK.acquirerId = :acquirerId and b.functionType= :functionType", params); } - public Uni> findByConfigAndFunctionType(String acquirerId, String branchId, String terminalId, FunctionTypeEnum functionType) { + public Uni> findByConfigAndFunctionType(String acquirerId, String branchId, String terminalId, String functionType) { Map params = new HashMap<>(); params.put("acquirerId", acquirerId); params.put("branchId", branchId); diff --git a/src/main/java/it/gov/pagopa/atmlayer/service/model/repository/BpmnVersionRepository.java b/src/main/java/it/gov/pagopa/atmlayer/service/model/repository/BpmnVersionRepository.java index fefdb992..1cfaf4e0 100644 --- a/src/main/java/it/gov/pagopa/atmlayer/service/model/repository/BpmnVersionRepository.java +++ b/src/main/java/it/gov/pagopa/atmlayer/service/model/repository/BpmnVersionRepository.java @@ -5,7 +5,6 @@ import io.smallrye.mutiny.Uni; import it.gov.pagopa.atmlayer.service.model.entity.BpmnVersion; import it.gov.pagopa.atmlayer.service.model.entity.BpmnVersionPK; -import it.gov.pagopa.atmlayer.service.model.enumeration.FunctionTypeEnum; import jakarta.enterprise.context.ApplicationScoped; import java.util.List; @@ -26,7 +25,7 @@ public Uni> findByIds(Set ids) { return find("where concat(bpmnId,'_',modelVersion) in ?1", bpmnIdVersion).list(); } - public Uni> findByIdAndFunction(UUID uuid, FunctionTypeEnum functionType) { + public Uni> findByIdAndFunction(UUID uuid, String functionType) { return find( "select b from BpmnVersion b where b.bpmnId = :bpmnId and b.functionType = :functionType order by b.modelVersion DESC", Parameters.with("bpmnId", uuid).and("functionType", functionType)).list(); diff --git a/src/main/java/it/gov/pagopa/atmlayer/service/model/resource/BpmnResource.java b/src/main/java/it/gov/pagopa/atmlayer/service/model/resource/BpmnResource.java index 8c410c23..7e2a393f 100644 --- a/src/main/java/it/gov/pagopa/atmlayer/service/model/resource/BpmnResource.java +++ b/src/main/java/it/gov/pagopa/atmlayer/service/model/resource/BpmnResource.java @@ -14,7 +14,6 @@ import it.gov.pagopa.atmlayer.service.model.entity.ResourceFile; import it.gov.pagopa.atmlayer.service.model.enumeration.AppErrorCodeEnum; import it.gov.pagopa.atmlayer.service.model.enumeration.BankConfigUtilityValues; -import it.gov.pagopa.atmlayer.service.model.enumeration.FunctionTypeEnum; import it.gov.pagopa.atmlayer.service.model.exception.AtmLayerException; import it.gov.pagopa.atmlayer.service.model.mapper.BpmnConfigMapper; import it.gov.pagopa.atmlayer.service.model.mapper.BpmnVersionMapper; @@ -80,7 +79,7 @@ public class BpmnResource { @GET @Produces(MediaType.APPLICATION_JSON) - public Uni> getAllBpmn(){ + public Uni> getAllBpmn() { return this.bpmnVersionService.getAll() .onItem() .transform(Unchecked.function(list -> { @@ -116,15 +115,15 @@ public Uni getEncodedFile(@PathParam("bpmnId") UUID bpmnId, @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Uni> associateBPMN(@PathParam("acquirerId") String acquirerId, - @PathParam("functionType") FunctionTypeEnum functionTypeEnum, + @PathParam("functionType") String functionType, @RequestBody(required = true) @Valid BpmnAssociationDto bpmnAssociationDto) throws NoSuchAlgorithmException, IOException { List configs = getAcquirerConfigs(bpmnAssociationDto, acquirerId, - functionTypeEnum); + functionType); Set bpmnIds = BpmnUtils.extractBpmnUUIDFromAssociations(configs); - return bpmnEntityValidator.validateExistenceStatusAndFunctionType(bpmnIds, functionTypeEnum) + return bpmnEntityValidator.validateExistenceStatusAndFunctionType(bpmnIds, functionType) .onItem().transformToUni( - x -> this.bpmnVersionService.putAssociations(acquirerId, functionTypeEnum, configs)) + x -> this.bpmnVersionService.putAssociations(acquirerId, functionType, configs)) .onItem() .transformToUni(list -> Uni.createFrom().item(this.bpmnConfigMapper.toDTOList(list))); } @@ -189,24 +188,24 @@ public Multi downloadBpmn(@PathParam("uuid") UUID bpmnId, @GET @Path("/function/{functionType}/bank/{acquirerId}/branch/{branchId}/terminal/{terminalId}") @Produces(MediaType.APPLICATION_JSON) - public Uni findBPMNByTriad(@PathParam("functionType") FunctionTypeEnum functionTypeEnum, + public Uni findBPMNByTriad(@PathParam("functionType") String functionType, @PathParam("acquirerId") String acquirerId, @PathParam("branchId") String branchId, @PathParam("terminalId") String terminalId) { - return bpmnBankConfigService.findByConfigurationsAndFunction(acquirerId, branchId, terminalId, functionTypeEnum) + return bpmnBankConfigService.findByConfigurationsAndFunction(acquirerId, branchId, terminalId, functionType) .onItem() .transformToUni(x1 -> { if (x1.isPresent()) { return bpmnVersionService.findByPk(new BpmnVersionPK(x1.get().getBpmnBankConfigPK().getBpmnId(), x1.get().getBpmnBankConfigPK().getBpmnModelVersion())) .onItem().transformToUni(bpmn1 -> Uni.createFrom().item(this.bpmnVersionMapper.toDTO(bpmn1.get()))); } - return bpmnBankConfigService.findByConfigurationsAndFunction(acquirerId, branchId, BankConfigUtilityValues.NULL_VALUE.getValue(), functionTypeEnum) + return bpmnBankConfigService.findByConfigurationsAndFunction(acquirerId, branchId, BankConfigUtilityValues.NULL_VALUE.getValue(), functionType) .onItem().transformToUni(x2 -> { if (x2.isPresent()) { return bpmnVersionService.findByPk(new BpmnVersionPK(x2.get().getBpmnBankConfigPK().getBpmnId(), x2.get().getBpmnBankConfigPK().getBpmnModelVersion())) .onItem().transformToUni(bpmn2 -> Uni.createFrom().item(this.bpmnVersionMapper.toDTO(bpmn2.get()))); } - return bpmnBankConfigService.findByConfigurationsAndFunction(acquirerId, BankConfigUtilityValues.NULL_VALUE.getValue(), BankConfigUtilityValues.NULL_VALUE.getValue(), functionTypeEnum) + return bpmnBankConfigService.findByConfigurationsAndFunction(acquirerId, BankConfigUtilityValues.NULL_VALUE.getValue(), BankConfigUtilityValues.NULL_VALUE.getValue(), functionType) .onItem().transformToUni(Unchecked.function(x3 -> { if (x3.isPresent()) { return bpmnVersionService.findByPk(new BpmnVersionPK(x3.get().getBpmnBankConfigPK().getBpmnId(), x3.get().getBpmnBankConfigPK().getBpmnModelVersion())) diff --git a/src/main/java/it/gov/pagopa/atmlayer/service/model/service/BpmnVersionService.java b/src/main/java/it/gov/pagopa/atmlayer/service/model/service/BpmnVersionService.java index 27b4a111..6427e52f 100644 --- a/src/main/java/it/gov/pagopa/atmlayer/service/model/service/BpmnVersionService.java +++ b/src/main/java/it/gov/pagopa/atmlayer/service/model/service/BpmnVersionService.java @@ -5,7 +5,6 @@ import it.gov.pagopa.atmlayer.service.model.entity.BpmnBankConfig; import it.gov.pagopa.atmlayer.service.model.entity.BpmnVersion; import it.gov.pagopa.atmlayer.service.model.entity.BpmnVersionPK; -import it.gov.pagopa.atmlayer.service.model.enumeration.FunctionTypeEnum; import it.gov.pagopa.atmlayer.service.model.enumeration.StatusEnum; import it.gov.pagopa.atmlayer.service.model.model.BpmnDTO; @@ -22,6 +21,7 @@ public interface BpmnVersionService { Uni> findByPKSet(Set bpmnVersionPKSet); Uni setBpmnVersionStatus(BpmnVersionPK key, StatusEnum status); + Uni save(BpmnVersion bpmnVersion); Uni delete(BpmnVersionPK bpmnVersionPK); @@ -32,7 +32,7 @@ public interface BpmnVersionService { Uni> findByPk(BpmnVersionPK bpmnVersionPK); - Uni> putAssociations(String acquirerId, FunctionTypeEnum functionTypeEnum, List bpmnBankConfigs); + Uni> putAssociations(String acquirerId, String functionTypeEnum, List bpmnBankConfigs); Uni deploy(BpmnVersionPK bpmnVersionPK); diff --git a/src/main/java/it/gov/pagopa/atmlayer/service/model/service/impl/BpmnBankConfigService.java b/src/main/java/it/gov/pagopa/atmlayer/service/model/service/impl/BpmnBankConfigService.java index 92e05ed0..c873675f 100644 --- a/src/main/java/it/gov/pagopa/atmlayer/service/model/service/impl/BpmnBankConfigService.java +++ b/src/main/java/it/gov/pagopa/atmlayer/service/model/service/impl/BpmnBankConfigService.java @@ -5,7 +5,6 @@ import io.smallrye.mutiny.unchecked.Unchecked; import it.gov.pagopa.atmlayer.service.model.entity.BpmnBankConfig; import it.gov.pagopa.atmlayer.service.model.enumeration.AppErrorCodeEnum; -import it.gov.pagopa.atmlayer.service.model.enumeration.FunctionTypeEnum; import it.gov.pagopa.atmlayer.service.model.exception.AtmLayerException; import it.gov.pagopa.atmlayer.service.model.mapper.BpmnConfigMapper; import it.gov.pagopa.atmlayer.service.model.model.BpmnBankConfigDTO; @@ -31,16 +30,16 @@ public Uni saveList(List bpmnBankConfigs) { return bankConfigRepository.persist(bpmnBankConfigs); } - public Uni> findByAcquirerIdAndFunctionType(String acquirerId, FunctionTypeEnum functionType) { + public Uni> findByAcquirerIdAndFunctionType(String acquirerId, String functionType) { return this.bankConfigRepository.findByAcquirerIdAndFunctionType(acquirerId, functionType); } @WithTransaction - public Uni deleteByAcquirerIdAndFunctionType(String acquirerId, FunctionTypeEnum functionTypeEnum) { + public Uni deleteByAcquirerIdAndFunctionType(String acquirerId, String functionTypeEnum) { return this.bankConfigRepository.deleteByAcquirerIdAndFunctionType(acquirerId, functionTypeEnum); } - public Uni> findByConfigurationsAndFunction(String acquirerId, String branchId, String terminalId, FunctionTypeEnum functionTypeEnum) { + public Uni> findByConfigurationsAndFunction(String acquirerId, String branchId, String terminalId, String functionTypeEnum) { return this.bankConfigRepository.findByConfigAndFunctionType(acquirerId, branchId, terminalId, functionTypeEnum) .onItem().transformToUni(Unchecked.function(x -> { if (!x.isEmpty() && x.size() > 1) { diff --git a/src/main/java/it/gov/pagopa/atmlayer/service/model/service/impl/BpmnVersionServiceImpl.java b/src/main/java/it/gov/pagopa/atmlayer/service/model/service/impl/BpmnVersionServiceImpl.java index 47c4e04d..c879b0a9 100644 --- a/src/main/java/it/gov/pagopa/atmlayer/service/model/service/impl/BpmnVersionServiceImpl.java +++ b/src/main/java/it/gov/pagopa/atmlayer/service/model/service/impl/BpmnVersionServiceImpl.java @@ -14,8 +14,6 @@ import it.gov.pagopa.atmlayer.service.model.entity.ResourceFile; import it.gov.pagopa.atmlayer.service.model.enumeration.AppErrorCodeEnum; import it.gov.pagopa.atmlayer.service.model.enumeration.DeployableResourceType; -import it.gov.pagopa.atmlayer.service.model.enumeration.FunctionTypeEnum; -import it.gov.pagopa.atmlayer.service.model.enumeration.S3ResourceTypeEnum; import it.gov.pagopa.atmlayer.service.model.enumeration.StatusEnum; import it.gov.pagopa.atmlayer.service.model.exception.AtmLayerException; import it.gov.pagopa.atmlayer.service.model.mapper.BpmnVersionMapper; @@ -131,7 +129,7 @@ public Uni> findByPk(BpmnVersionPK bpmnVersionPK) { @Override @WithTransaction - public Uni> putAssociations(String acquirerId, FunctionTypeEnum functionType, List bpmnBankConfigs) { + public Uni> putAssociations(String acquirerId, String functionType, List bpmnBankConfigs) { Uni deleteExistingUni = this.bpmnBankConfigService.deleteByAcquirerIdAndFunctionType(acquirerId, functionType); return deleteExistingUni .onItem() @@ -241,7 +239,7 @@ public Uni deploy(BpmnVersionPK bpmnVersionPK) { .onItem().transformToUni(x -> Uni.createFrom().failure(new AtmLayerException("Error in BPMN deploy. Fail to generate presigned URL", Response.Status.INTERNAL_SERVER_ERROR, ATMLM_500))); }); }) - .onItem().transformToUni(presignedUrl -> processClient.deploy(presignedUrl.toString(),DeployableResourceType.BPMN.name()) + .onItem().transformToUni(presignedUrl -> processClient.deploy(presignedUrl.toString(), DeployableResourceType.BPMN.name()) .onFailure().recoverWithUni(failure -> { log.error(failure.getMessage()); return this.setBpmnVersionStatus(bpmnVersionPK, StatusEnum.DEPLOY_ERROR) @@ -282,7 +280,7 @@ public Uni setDeployInfo(BpmnVersionPK key, DeployResponseDto respo })); } - public Uni getLatestVersion(UUID uuid, FunctionTypeEnum functionType) { + public Uni getLatestVersion(UUID uuid, String functionType) { return this.bpmnVersionRepository.findByIdAndFunction(uuid, functionType) .onItem() .transform(list -> list.get(0)) diff --git a/src/main/java/it/gov/pagopa/atmlayer/service/model/utils/BpmnUtils.java b/src/main/java/it/gov/pagopa/atmlayer/service/model/utils/BpmnUtils.java index ebef6293..f8392640 100644 --- a/src/main/java/it/gov/pagopa/atmlayer/service/model/utils/BpmnUtils.java +++ b/src/main/java/it/gov/pagopa/atmlayer/service/model/utils/BpmnUtils.java @@ -8,7 +8,6 @@ import it.gov.pagopa.atmlayer.service.model.entity.BpmnBankConfigPK; import it.gov.pagopa.atmlayer.service.model.entity.BpmnVersionPK; import it.gov.pagopa.atmlayer.service.model.enumeration.BankConfigUtilityValues; -import it.gov.pagopa.atmlayer.service.model.enumeration.FunctionTypeEnum; import jakarta.enterprise.context.ApplicationScoped; import java.io.File; @@ -71,7 +70,7 @@ public static Set extractBpmnUUIDFromAssociations(List getAcquirerConfigs(BpmnAssociationDto bpmnAssociationDto, String acquirerId, FunctionTypeEnum functionTypeEnum) { + public static List getAcquirerConfigs(BpmnAssociationDto bpmnAssociationDto, String acquirerId, String functionTypeEnum) { List bpmnBankConfigs = new ArrayList<>(); BpmnBankConfig bpmnBankConfigAcquirerDefault = new BpmnBankConfig(); bpmnBankConfigAcquirerDefault.setBpmnBankConfigPK(new BpmnBankConfigPK(bpmnAssociationDto.getDefaultTemplateId(), diff --git a/src/main/java/it/gov/pagopa/atmlayer/service/model/validators/BpmnEntityValidator.java b/src/main/java/it/gov/pagopa/atmlayer/service/model/validators/BpmnEntityValidator.java index f0a3e5a5..8e6803a6 100644 --- a/src/main/java/it/gov/pagopa/atmlayer/service/model/validators/BpmnEntityValidator.java +++ b/src/main/java/it/gov/pagopa/atmlayer/service/model/validators/BpmnEntityValidator.java @@ -6,7 +6,6 @@ import it.gov.pagopa.atmlayer.service.model.entity.BpmnVersion; import it.gov.pagopa.atmlayer.service.model.entity.BpmnVersionPK; import it.gov.pagopa.atmlayer.service.model.enumeration.AppErrorCodeEnum; -import it.gov.pagopa.atmlayer.service.model.enumeration.FunctionTypeEnum; import it.gov.pagopa.atmlayer.service.model.enumeration.StatusEnum; import it.gov.pagopa.atmlayer.service.model.exception.AtmLayerException; import it.gov.pagopa.atmlayer.service.model.service.BpmnVersionService; @@ -28,7 +27,7 @@ public BpmnEntityValidator(BpmnVersionService bpmnVersionService) { this.bpmnVersionService = bpmnVersionService; } - public Uni validateExistenceStatusAndFunctionType(Set ids, FunctionTypeEnum functionTypeEnum) { + public Uni validateExistenceStatusAndFunctionType(Set ids, String functionType) { return this.bpmnVersionService.findByPKSet(ids) .onItem() .invoke(Unchecked.consumer(list -> { @@ -38,9 +37,9 @@ public Uni validateExistenceStatusAndFunctionType(Set ids, String errorMessage = String.format("One or some of the referenced BPMN files are not deployed: %s", notDeployedBpmnFiles.stream().map(x -> new BpmnVersionPK(x.getBpmnId(), x.getModelVersion())).collect(Collectors.toSet())); throw new AtmLayerException(errorMessage, Response.Status.BAD_REQUEST, AppErrorCodeEnum.BPMN_FILE_NOT_DEPLOYED); } - Set notValidFunctionTypeBpmnFiles = list.stream().filter(bpmnVersion -> !bpmnVersion.getFunctionType().equals(functionTypeEnum)).collect(Collectors.toSet()); + Set notValidFunctionTypeBpmnFiles = list.stream().filter(bpmnVersion -> !bpmnVersion.getFunctionType().equals(functionType)).collect(Collectors.toSet()); if (!CollectionUtils.isNullOrEmpty(notValidFunctionTypeBpmnFiles)) { - String errorMessage = String.format("One or some of the referenced BPMN do not have functionType %s: %s", functionTypeEnum.name(), notValidFunctionTypeBpmnFiles.stream().map(x -> new BpmnVersionPK(x.getBpmnId(), x.getModelVersion())).collect(Collectors.toSet())); + String errorMessage = String.format("One or some of the referenced BPMN do not have functionType %s: %s", functionType, notValidFunctionTypeBpmnFiles.stream().map(x -> new BpmnVersionPK(x.getBpmnId(), x.getModelVersion())).collect(Collectors.toSet())); throw new AtmLayerException(errorMessage, Response.Status.BAD_REQUEST, AppErrorCodeEnum.BPMN_FUNCTION_TYPE_DIFFERENT_FROM_REQUESTED); } Set missingBpmn = Sets.difference(ids, extractedKeys); diff --git a/src/test/java/it/gov/pagopa/atmlayer/service/model/dto/BpmnCreationDtoTest.java b/src/test/java/it/gov/pagopa/atmlayer/service/model/dto/BpmnCreationDtoTest.java index 7827463f..d635cee6 100644 --- a/src/test/java/it/gov/pagopa/atmlayer/service/model/dto/BpmnCreationDtoTest.java +++ b/src/test/java/it/gov/pagopa/atmlayer/service/model/dto/BpmnCreationDtoTest.java @@ -20,10 +20,10 @@ void testConstructor() { actualBpmnCreationDto.setFile( Paths.get(System.getProperty("java.io.tmpdir"), "test.txt").toFile()); actualBpmnCreationDto.setFilename("foo.txt"); - actualBpmnCreationDto.setFunctionType(FunctionTypeEnum.MENU); + actualBpmnCreationDto.setFunctionType(FunctionTypeEnum.MENU.name()); String actualToStringResult = actualBpmnCreationDto.toString(); assertEquals("foo.txt", actualBpmnCreationDto.getFilename()); - assertEquals(FunctionTypeEnum.MENU, actualBpmnCreationDto.getFunctionType()); + assertEquals(FunctionTypeEnum.MENU.name(), actualBpmnCreationDto.getFunctionType()); assertEquals( String.join("", "BpmnCreationDto(file=", Paths.get(System.getProperty("java.io.tmpdir"), "test.txt").toString(), @@ -36,7 +36,7 @@ void testEquals() { BpmnCreationDto bpmnCreationDto = new BpmnCreationDto(); bpmnCreationDto.setFile(Paths.get(System.getProperty("java.io.tmpdir"), "test.txt").toFile()); bpmnCreationDto.setFilename("foo.txt"); - bpmnCreationDto.setFunctionType(FunctionTypeEnum.MENU); + bpmnCreationDto.setFunctionType(FunctionTypeEnum.MENU.name()); assertNotEquals(bpmnCreationDto, null); } } diff --git a/src/test/java/it/gov/pagopa/atmlayer/service/model/dto/BpmnUpgradeDtoTest.java b/src/test/java/it/gov/pagopa/atmlayer/service/model/dto/BpmnUpgradeDtoTest.java index d9d2a290..771a74be 100644 --- a/src/test/java/it/gov/pagopa/atmlayer/service/model/dto/BpmnUpgradeDtoTest.java +++ b/src/test/java/it/gov/pagopa/atmlayer/service/model/dto/BpmnUpgradeDtoTest.java @@ -26,12 +26,12 @@ void testConstructor() { actualBpmnUpgradeDto.setFile( Paths.get(System.getProperty("java.io.tmpdir"), "test.txt").toFile()); actualBpmnUpgradeDto.setFilename("foo.txt"); - actualBpmnUpgradeDto.setFunctionType(FunctionTypeEnum.MENU); + actualBpmnUpgradeDto.setFunctionType(FunctionTypeEnum.MENU.name()); UUID randomUUIDResult = UUID.randomUUID(); actualBpmnUpgradeDto.setUuid(randomUUIDResult); actualBpmnUpgradeDto.toString(); assertEquals("foo.txt", actualBpmnUpgradeDto.getFilename()); - assertEquals(FunctionTypeEnum.MENU, actualBpmnUpgradeDto.getFunctionType()); + assertEquals(FunctionTypeEnum.MENU.name(), actualBpmnUpgradeDto.getFunctionType()); assertSame(randomUUIDResult, actualBpmnUpgradeDto.getUuid()); } @@ -40,7 +40,7 @@ void testEquals() { BpmnUpgradeDto bpmnUpgradeDto = new BpmnUpgradeDto(); bpmnUpgradeDto.setFile(Paths.get(System.getProperty("java.io.tmpdir"), "test.txt").toFile()); bpmnUpgradeDto.setFilename("foo.txt"); - bpmnUpgradeDto.setFunctionType(FunctionTypeEnum.MENU); + bpmnUpgradeDto.setFunctionType(FunctionTypeEnum.MENU.name()); bpmnUpgradeDto.setUuid(UUID.randomUUID()); assertNotEquals(bpmnUpgradeDto, null); } diff --git a/src/test/java/it/gov/pagopa/atmlayer/service/model/entity/BpmnBankConfigTest.java b/src/test/java/it/gov/pagopa/atmlayer/service/model/entity/BpmnBankConfigTest.java index 16a26a47..187c5844 100644 --- a/src/test/java/it/gov/pagopa/atmlayer/service/model/entity/BpmnBankConfigTest.java +++ b/src/test/java/it/gov/pagopa/atmlayer/service/model/entity/BpmnBankConfigTest.java @@ -27,8 +27,8 @@ public void testGettersAndSetters() { assertEquals(bpmnBankConfigPK, bpmnBankConfig.getBpmnBankConfigPK()); FunctionTypeEnum functionType = FunctionTypeEnum.MENU; - bpmnBankConfig.setFunctionType(functionType); - assertEquals(functionType, bpmnBankConfig.getFunctionType()); + bpmnBankConfig.setFunctionType(functionType.name()); + assertEquals(functionType.name(), bpmnBankConfig.getFunctionType()); Timestamp createdAt = new Timestamp(System.currentTimeMillis()); bpmnBankConfig.setCreatedAt(createdAt); diff --git a/src/test/java/it/gov/pagopa/atmlayer/service/model/model/BpmnBankConfigDTOTest.java b/src/test/java/it/gov/pagopa/atmlayer/service/model/model/BpmnBankConfigDTOTest.java index c8b884b7..8b9b0ebc 100644 --- a/src/test/java/it/gov/pagopa/atmlayer/service/model/model/BpmnBankConfigDTOTest.java +++ b/src/test/java/it/gov/pagopa/atmlayer/service/model/model/BpmnBankConfigDTOTest.java @@ -21,7 +21,7 @@ public void testNoArgsConstructor() { public void testAllArgsConstructor() { BpmnBankConfigDTO dto = new BpmnBankConfigDTO( UUID.randomUUID(), 1L, "acquirer", "branch", "terminal", - FunctionTypeEnum.MENU, new Timestamp(System.currentTimeMillis()), + FunctionTypeEnum.MENU.name(), new Timestamp(System.currentTimeMillis()), new Timestamp(System.currentTimeMillis()), "creator", "updator"); assertNotNull(dto); } @@ -45,8 +45,8 @@ public void testGetterAndSetter() { dto.setTerminalId("terminal"); assertEquals(dto.getTerminalId(), "terminal"); - dto.setFunctionType(FunctionTypeEnum.MENU); - assertEquals(dto.getFunctionType(), FunctionTypeEnum.MENU); + dto.setFunctionType(FunctionTypeEnum.MENU.name()); + assertEquals(dto.getFunctionType(), FunctionTypeEnum.MENU.name()); Timestamp createdAt = new Timestamp(System.currentTimeMillis()); dto.setCreatedAt(createdAt); @@ -67,11 +67,11 @@ public void testGetterAndSetter() { public void testEqualsAndHashCode() { BpmnBankConfigDTO dto1 = new BpmnBankConfigDTO( UUID.randomUUID(), 1L, "acquirer", "branch", "terminal", - FunctionTypeEnum.MENU, new Timestamp(System.currentTimeMillis()), + FunctionTypeEnum.MENU.name(), new Timestamp(System.currentTimeMillis()), new Timestamp(System.currentTimeMillis()), "creator", "updator"); BpmnBankConfigDTO dto2 = new BpmnBankConfigDTO( UUID.randomUUID(), 1L, "acquirer", "branch", "terminal", - FunctionTypeEnum.MENU, new Timestamp(System.currentTimeMillis()), + FunctionTypeEnum.MENU.name(), new Timestamp(System.currentTimeMillis()), new Timestamp(System.currentTimeMillis()), "creator", "updator"); assertNotEquals(dto1, dto2); @@ -82,7 +82,7 @@ FunctionTypeEnum.MENU, new Timestamp(System.currentTimeMillis()), public void testToString() { BpmnBankConfigDTO dto = new BpmnBankConfigDTO( UUID.randomUUID(), 1L, "acquirer", "branch", "terminal", - FunctionTypeEnum.MENU, new Timestamp(System.currentTimeMillis()), + FunctionTypeEnum.MENU.name(), new Timestamp(System.currentTimeMillis()), new Timestamp(System.currentTimeMillis()), "creator", "updator"); String expectedToString = "BpmnBankConfigDTO(bpmnId=" + dto.getBpmnId() + diff --git a/src/test/java/it/gov/pagopa/atmlayer/service/model/model/BpmnDTOTest.java b/src/test/java/it/gov/pagopa/atmlayer/service/model/model/BpmnDTOTest.java index d49aa92b..fa7210d8 100644 --- a/src/test/java/it/gov/pagopa/atmlayer/service/model/model/BpmnDTOTest.java +++ b/src/test/java/it/gov/pagopa/atmlayer/service/model/model/BpmnDTOTest.java @@ -22,7 +22,7 @@ public void testGetterAndSetter() { bpmnDTO.setModelVersion(1L); bpmnDTO.setDeployedFileName("example.bpmn"); bpmnDTO.setDefinitionKey("process_key"); - bpmnDTO.setFunctionType(FunctionTypeEnum.MENU); + bpmnDTO.setFunctionType(FunctionTypeEnum.MENU.name()); bpmnDTO.setStatus(StatusEnum.CREATED); bpmnDTO.setSha256("hash123"); bpmnDTO.setDefinitionVersionCamunda(2); @@ -41,7 +41,7 @@ public void testGetterAndSetter() { assertEquals(bpmnDTO.getModelVersion(), 1L); assertEquals(bpmnDTO.getDeployedFileName(), "example.bpmn"); assertEquals(bpmnDTO.getDefinitionKey(), "process_key"); - assertEquals(bpmnDTO.getFunctionType(), FunctionTypeEnum.MENU); + assertEquals(bpmnDTO.getFunctionType(), FunctionTypeEnum.MENU.name()); assertEquals(bpmnDTO.getStatus(), StatusEnum.CREATED); assertEquals(bpmnDTO.getSha256(), "hash123"); assertEquals(bpmnDTO.getDefinitionVersionCamunda(), 2); @@ -67,7 +67,7 @@ public void testAllArgsConstructor() { UUID bpmnId = UUID.randomUUID(); Long modelVersion = 2L; BpmnDTO bpmnDTO = new BpmnDTO(bpmnId, modelVersion, "file.bpmn", "key123", - FunctionTypeEnum.SPONTANEOUS_PAYMENT, StatusEnum.DEPLOYED, "hash456", 3, + FunctionTypeEnum.SPONTANEOUS_PAYMENT.name(), StatusEnum.DEPLOYED, "hash456", 3, "camunda456", "BPMN Description", new ResourceFileDTO(), "Resource Content", UUID.randomUUID(), new Timestamp(System.currentTimeMillis()), new Timestamp(System.currentTimeMillis()), "User3", "User4"); @@ -83,7 +83,7 @@ public void testBuilder() { .modelVersion(3L) .deployedFileName("file3.bpmn") .definitionKey("key789") - .functionType(FunctionTypeEnum.SPONTANEOUS_PAYMENT) + .functionType(FunctionTypeEnum.SPONTANEOUS_PAYMENT.name()) .status(StatusEnum.CREATED) .sha256("hash789") .definitionVersionCamunda(4) @@ -108,7 +108,7 @@ public void testToString() { .modelVersion(4L) .deployedFileName("file4.bpmn") .definitionKey("key999") - .functionType(FunctionTypeEnum.MENU) + .functionType(FunctionTypeEnum.MENU.name()) .status(StatusEnum.CREATED) .sha256("hash999") .definitionVersionCamunda(5) @@ -138,13 +138,13 @@ public void testToString() { @Test public void testEqualsAndHashCode() { BpmnDTO bpmnDTO1 = new BpmnDTO(UUID.randomUUID(), 1L, "file1.bpmn", "key1", - FunctionTypeEnum.MENU, StatusEnum.CREATED, "hash1", 2, + FunctionTypeEnum.MENU.name(), StatusEnum.CREATED, "hash1", 2, "camunda1", "BPMN Description 1", new ResourceFileDTO(), "Resource Content 1", UUID.randomUUID(), new Timestamp(System.currentTimeMillis()), new Timestamp(System.currentTimeMillis()), "User1", "User2"); BpmnDTO bpmnDTO2 = new BpmnDTO(UUID.randomUUID(), 1L, "file1.bpmn", "key1", - FunctionTypeEnum.MENU, StatusEnum.CREATED, "hash1", 2, + FunctionTypeEnum.MENU.name(), StatusEnum.CREATED, "hash1", 2, "camunda1", "BPMN Description 1", new ResourceFileDTO(), "Resource Content 1", UUID.randomUUID(), new Timestamp(System.currentTimeMillis()), new Timestamp(System.currentTimeMillis()), "User1", "User2"); @@ -155,7 +155,7 @@ public void testEqualsAndHashCode() { assertNotEquals(bpmnDTO1, null); BpmnDTO bpmnDTO3 = new BpmnDTO(UUID.randomUUID(), 3L, "file3.bpmn", "key3", - FunctionTypeEnum.SPONTANEOUS_PAYMENT, StatusEnum.DEPLOYED, "hash3", 4, + FunctionTypeEnum.SPONTANEOUS_PAYMENT.name(), StatusEnum.DEPLOYED, "hash3", 4, "camunda3", "BPMN Description 3", new ResourceFileDTO(), "Resource Content 3", UUID.randomUUID(), new Timestamp(System.currentTimeMillis()), new Timestamp(System.currentTimeMillis()), "User3", "User4"); diff --git a/src/test/java/it/gov/pagopa/atmlayer/service/model/service/impl/BpmnBankConfigServiceImplTest.java b/src/test/java/it/gov/pagopa/atmlayer/service/model/service/impl/BpmnBankConfigServiceImplTest.java index 9921dd46..b4c76f74 100644 --- a/src/test/java/it/gov/pagopa/atmlayer/service/model/service/impl/BpmnBankConfigServiceImplTest.java +++ b/src/test/java/it/gov/pagopa/atmlayer/service/model/service/impl/BpmnBankConfigServiceImplTest.java @@ -57,10 +57,10 @@ public void testFindByAcquirerIdAndFunctionType() { List mockResult = Collections.singletonList(new BpmnBankConfig()); - when(bankConfigRepository.findByAcquirerIdAndFunctionType(acquirerId, functionType)) + when(bankConfigRepository.findByAcquirerIdAndFunctionType(acquirerId, functionType.name())) .thenReturn(Uni.createFrom().item(mockResult)); - Uni> result = bankConfigService.findByAcquirerIdAndFunctionType(acquirerId, functionType); + Uni> result = bankConfigService.findByAcquirerIdAndFunctionType(acquirerId, functionType.name()); assertNotNull(result); @@ -73,10 +73,10 @@ public void testDeleteByAcquirerIdAndFunctionType() { String acquirerId = "acquirer1"; FunctionTypeEnum functionType = FunctionTypeEnum.MENU; - when(bankConfigRepository.deleteByAcquirerIdAndFunctionType(acquirerId, functionType)) + when(bankConfigRepository.deleteByAcquirerIdAndFunctionType(acquirerId, functionType.name())) .thenReturn(Uni.createFrom().item(1L)); - Uni result = bankConfigService.deleteByAcquirerIdAndFunctionType(acquirerId, functionType); + Uni result = bankConfigService.deleteByAcquirerIdAndFunctionType(acquirerId, functionType.name()); assertNotNull(result); @@ -97,14 +97,14 @@ public void testFindByConfigurationsAndFunction() { bpmnBankConfigPK.setBranchId(branchId); bpmnBankConfigPK.setTerminalId(terminalId); bpmnBankConfig.setBpmnBankConfigPK(bpmnBankConfigPK); - bpmnBankConfig.setFunctionType(functionType); + bpmnBankConfig.setFunctionType(functionType.name()); List mockResult = Collections.singletonList(bpmnBankConfig); - when(bankConfigRepository.findByConfigAndFunctionType(acquirerId, branchId, terminalId, functionType)) + when(bankConfigRepository.findByConfigAndFunctionType(acquirerId, branchId, terminalId, functionType.name())) .thenReturn(Uni.createFrom().item(mockResult)); - Uni> result = bankConfigService.findByConfigurationsAndFunction(acquirerId, branchId, terminalId, functionType); + Uni> result = bankConfigService.findByConfigurationsAndFunction(acquirerId, branchId, terminalId, functionType.name()); assertNotNull(result); @@ -115,7 +115,7 @@ public void testFindByConfigurationsAndFunction() { assertEquals(acquirerId, retrievedConfig.getBpmnBankConfigPK().getAcquirerId()); assertEquals(branchId, retrievedConfig.getBpmnBankConfigPK().getBranchId()); assertEquals(terminalId, retrievedConfig.getBpmnBankConfigPK().getTerminalId()); - assertEquals(functionType, retrievedConfig.getFunctionType()); + assertEquals(functionType.name(), retrievedConfig.getFunctionType()); } @Test @@ -125,10 +125,10 @@ public void testFindByConfigurationsAndFunctionWithEmptyList() { String terminalId = "terminal1"; FunctionTypeEnum functionType = FunctionTypeEnum.MENU; - when(bankConfigRepository.findByConfigAndFunctionType(acquirerId, branchId, terminalId, functionType)) + when(bankConfigRepository.findByConfigAndFunctionType(acquirerId, branchId, terminalId, functionType.name())) .thenReturn(Uni.createFrom().item(Collections.emptyList())); - Uni> result = bankConfigService.findByConfigurationsAndFunction(acquirerId, branchId, terminalId, functionType); + Uni> result = bankConfigService.findByConfigurationsAndFunction(acquirerId, branchId, terminalId, functionType.name()); assertNotNull(result); @@ -147,12 +147,12 @@ public void testFindByConfigurationsAndFunctionWithMultipleResults() { BpmnBankConfig config2 = new BpmnBankConfig(); List mockResult = List.of(config1, config2); - when(bankConfigRepository.findByConfigAndFunctionType(acquirerId, branchId, terminalId, functionType)) + when(bankConfigRepository.findByConfigAndFunctionType(acquirerId, branchId, terminalId, functionType.name())) .thenReturn(Uni.createFrom().item(mockResult)); // Modifica il test per catturare l'eccezione AtmLayerException assertThrows(AtmLayerException.class, () -> { - bankConfigService.findByConfigurationsAndFunction(acquirerId, branchId, terminalId, functionType) + bankConfigService.findByConfigurationsAndFunction(acquirerId, branchId, terminalId, functionType.name()) .await().indefinitely(); }, "Multiple BPMN found for a single configuration."); } diff --git a/src/test/java/it/gov/pagopa/atmlayer/service/model/service/impl/BpmnVersionServiceImplTest.java b/src/test/java/it/gov/pagopa/atmlayer/service/model/service/impl/BpmnVersionServiceImplTest.java index 7ca1460d..1b889715 100644 --- a/src/test/java/it/gov/pagopa/atmlayer/service/model/service/impl/BpmnVersionServiceImplTest.java +++ b/src/test/java/it/gov/pagopa/atmlayer/service/model/service/impl/BpmnVersionServiceImplTest.java @@ -226,15 +226,15 @@ void testPutAssociationsWhenSuccessful() { String acquirerId = "testAcquirerId"; FunctionTypeEnum functionType = FunctionTypeEnum.MENU; List bpmnBankConfigs = new ArrayList<>(); - when(bpmnBankConfigServiceMock.deleteByAcquirerIdAndFunctionType(acquirerId, functionType)).thenReturn(Uni.createFrom().item(1L)); + when(bpmnBankConfigServiceMock.deleteByAcquirerIdAndFunctionType(acquirerId, functionType.name())).thenReturn(Uni.createFrom().item(1L)); when(bpmnBankConfigServiceMock.saveList(bpmnBankConfigs)).thenReturn(Uni.createFrom().voidItem()); - when(bpmnBankConfigServiceMock.findByAcquirerIdAndFunctionType(acquirerId, functionType)).thenReturn(Uni.createFrom().item(bpmnBankConfigs)); - bpmnVersionServiceImpl.putAssociations(acquirerId, functionType, bpmnBankConfigs) + when(bpmnBankConfigServiceMock.findByAcquirerIdAndFunctionType(acquirerId, functionType.name())).thenReturn(Uni.createFrom().item(bpmnBankConfigs)); + bpmnVersionServiceImpl.putAssociations(acquirerId, functionType.name(), bpmnBankConfigs) .subscribe().withSubscriber(UniAssertSubscriber.create()) .assertCompleted().assertItem(bpmnBankConfigs); - verify(bpmnBankConfigServiceMock, times(1)).deleteByAcquirerIdAndFunctionType(acquirerId, functionType); + verify(bpmnBankConfigServiceMock, times(1)).deleteByAcquirerIdAndFunctionType(acquirerId, functionType.name()); verify(bpmnBankConfigServiceMock, times(1)).saveList(bpmnBankConfigs); - verify(bpmnBankConfigServiceMock, times(1)).findByAcquirerIdAndFunctionType(acquirerId, functionType); + verify(bpmnBankConfigServiceMock, times(1)).findByAcquirerIdAndFunctionType(acquirerId, functionType.name()); } @Test @@ -570,21 +570,21 @@ void testGetLatestVersionOK(){ List bpmnList=new ArrayList(); bpmnList.add(bpmnVersion1); bpmnList.add(bpmnVersion2); - when(bpmnVersionRepoMock.findByIdAndFunction(any(UUID.class),any(FunctionTypeEnum.class))).thenReturn(Uni.createFrom().item(bpmnList)); - bpmnVersionServiceImpl.getLatestVersion(uuid,FunctionTypeEnum.MENU) + when(bpmnVersionRepoMock.findByIdAndFunction(any(UUID.class),any(String.class))).thenReturn(Uni.createFrom().item(bpmnList)); + bpmnVersionServiceImpl.getLatestVersion(uuid,FunctionTypeEnum.MENU.name()) .subscribe().withSubscriber(UniAssertSubscriber.create()) .assertCompleted().assertItem(bpmnVersion1); - verify(bpmnVersionRepoMock,times(1)).findByIdAndFunction(uuid,FunctionTypeEnum.MENU); + verify(bpmnVersionRepoMock,times(1)).findByIdAndFunction(uuid,FunctionTypeEnum.MENU.name()); } @Test void testGetLatestVersionFailure(){ UUID uuid=UUID.randomUUID(); - when(bpmnVersionRepoMock.findByIdAndFunction(any(UUID.class),any(FunctionTypeEnum.class))).thenReturn(Uni.createFrom().nullItem()); - bpmnVersionServiceImpl.getLatestVersion(uuid,FunctionTypeEnum.MENU) + when(bpmnVersionRepoMock.findByIdAndFunction(any(UUID.class),any(String.class))).thenReturn(Uni.createFrom().nullItem()); + bpmnVersionServiceImpl.getLatestVersion(uuid,FunctionTypeEnum.MENU.name()) .subscribe().withSubscriber(UniAssertSubscriber.create()) .assertFailedWith(AtmLayerException.class,"NO BPMN with given ID and functionType exists"); - verify(bpmnVersionRepoMock,times(1)).findByIdAndFunction(uuid,FunctionTypeEnum.MENU); + verify(bpmnVersionRepoMock,times(1)).findByIdAndFunction(uuid,FunctionTypeEnum.MENU.name()); } @Test @@ -593,12 +593,12 @@ void testUpgradeOK() throws NoSuchAlgorithmException, IOException { bpmnUpgradeDto.setUuid(UUID.randomUUID()); bpmnUpgradeDto.setFilename("filename"); bpmnUpgradeDto.setFile(new File("src/test/resources/Test.bpmn")); - bpmnUpgradeDto.setFunctionType(FunctionTypeEnum.MENU); + bpmnUpgradeDto.setFunctionType(FunctionTypeEnum.MENU.name()); BpmnVersion bpmnVersion=new BpmnVersion(); BpmnVersion bpmnVersion2=new BpmnVersion(); bpmnVersion.setBpmnId(UUID.randomUUID()); bpmnVersion.setModelVersion(1L); - bpmnVersion.setFunctionType(FunctionTypeEnum.MENU); + bpmnVersion.setFunctionType(FunctionTypeEnum.MENU.name()); bpmnVersion.setDefinitionKey("demo11_06"); bpmnVersion.setSha256("sha256"); List bpmnList=new ArrayList(); @@ -607,7 +607,7 @@ void testUpgradeOK() throws NoSuchAlgorithmException, IOException { ResourceFile resourceFile=new ResourceFile(); BpmnDTO bpmnDTO=new BpmnDTO(); bpmnDTO.setDeployedFileName("deployed file"); - when(bpmnVersionRepoMock.findByIdAndFunction(any(UUID.class),any(FunctionTypeEnum.class))).thenReturn(Uni.createFrom().item(bpmnList)); + when(bpmnVersionRepoMock.findByIdAndFunction(any(UUID.class),any(String.class))).thenReturn(Uni.createFrom().item(bpmnList)); when(bpmnVersionMapperMock.toEntityUpgrade(any(BpmnUpgradeDto.class),any(Long.class),any(String.class))).thenReturn(bpmnVersion2); when(bpmnVersionRepoMock.findBySHA256(any(String.class))).thenReturn(Uni.createFrom().nullItem()); when(bpmnVersionRepoMock.persist(any(BpmnVersion.class))).thenReturn(Uni.createFrom().item(bpmnVersion2)); @@ -625,17 +625,17 @@ void testUpgradeDifferentDefinitionKeys() throws NoSuchAlgorithmException, IOExc bpmnUpgradeDto.setUuid(UUID.randomUUID()); bpmnUpgradeDto.setFilename("filename"); bpmnUpgradeDto.setFile(new File("src/test/resources/Test.bpmn")); - bpmnUpgradeDto.setFunctionType(FunctionTypeEnum.MENU); + bpmnUpgradeDto.setFunctionType(FunctionTypeEnum.MENU.name()); BpmnVersion bpmnVersion=new BpmnVersion(); bpmnVersion.setDefinitionKey("different key"); bpmnVersion.setSha256("sha256"); List bpmnList=new ArrayList(); bpmnList.add(bpmnVersion); - when(bpmnVersionRepoMock.findByIdAndFunction(any(UUID.class),any(FunctionTypeEnum.class))).thenReturn(Uni.createFrom().item(bpmnList)); + when(bpmnVersionRepoMock.findByIdAndFunction(any(UUID.class),any(String.class))).thenReturn(Uni.createFrom().item(bpmnList)); bpmnVersionServiceImpl.upgrade(bpmnUpgradeDto) .subscribe().withSubscriber(UniAssertSubscriber.create()) .assertFailedWith(AtmLayerException.class,"Definition keys differ, BPMN upgrade refused"); - verify(bpmnVersionRepoMock,times(1)).findByIdAndFunction(bpmnUpgradeDto.getUuid(),FunctionTypeEnum.MENU); + verify(bpmnVersionRepoMock,times(1)).findByIdAndFunction(bpmnUpgradeDto.getUuid(),FunctionTypeEnum.MENU.name()); verify(bpmnVersionMapperMock,never()).toEntityUpgrade(any(BpmnUpgradeDto.class),any(Long.class),any(String.class)); verify(bpmnVersionMapperMock,never()).toDTO(any(BpmnVersion.class)); } @@ -646,18 +646,18 @@ void testUpgradeShaFailure() throws NoSuchAlgorithmException, IOException { bpmnUpgradeDto.setUuid(UUID.randomUUID()); bpmnUpgradeDto.setFilename("filename"); bpmnUpgradeDto.setFile(new File("src/test/resources/Test.bpmn")); - bpmnUpgradeDto.setFunctionType(FunctionTypeEnum.MENU); + bpmnUpgradeDto.setFunctionType(FunctionTypeEnum.MENU.name()); BpmnVersion bpmnVersion=new BpmnVersion(); bpmnVersion.setDefinitionKey("demo11_06"); bpmnVersion.setSha256("sha256"); List bpmnList=new ArrayList(); bpmnList.add(bpmnVersion); - when(bpmnVersionRepoMock.findByIdAndFunction(any(UUID.class),any(FunctionTypeEnum.class))).thenReturn(Uni.createFrom().item(bpmnList)); + when(bpmnVersionRepoMock.findByIdAndFunction(any(UUID.class),any(String.class))).thenReturn(Uni.createFrom().item(bpmnList)); when(bpmnVersionMapperMock.toEntityUpgrade(any(BpmnUpgradeDto.class),any(Long.class),any(String.class))).thenThrow(new RuntimeException()); bpmnVersionServiceImpl.upgrade(bpmnUpgradeDto) .subscribe().withSubscriber(UniAssertSubscriber.create()) .assertFailedWith(AtmLayerException.class,"Generic error calculating SHA256"); - verify(bpmnVersionRepoMock,times(1)).findByIdAndFunction(bpmnUpgradeDto.getUuid(),FunctionTypeEnum.MENU); + verify(bpmnVersionRepoMock,times(1)).findByIdAndFunction(bpmnUpgradeDto.getUuid(),FunctionTypeEnum.MENU.name()); verify(bpmnVersionMapperMock,times(1)).toEntityUpgrade(any(BpmnUpgradeDto.class),any(Long.class),any(String.class)); verify(bpmnVersionMapperMock,never()).toDTO(any(BpmnVersion.class)); } diff --git a/src/test/java/it/gov/pagopa/atmlayer/service/model/utils/BpmnUtilsTest.java b/src/test/java/it/gov/pagopa/atmlayer/service/model/utils/BpmnUtilsTest.java index ae832184..5fa77196 100644 --- a/src/test/java/it/gov/pagopa/atmlayer/service/model/utils/BpmnUtilsTest.java +++ b/src/test/java/it/gov/pagopa/atmlayer/service/model/utils/BpmnUtilsTest.java @@ -96,21 +96,21 @@ void testGetAcquirerConfigs() { String acquirerId = "acquirer1"; FunctionTypeEnum functionTypeEnum = FunctionTypeEnum.MENU; BpmnAssociationDto emptyBpmnAssociationDto = new BpmnAssociationDto(); - assertEquals(1, BpmnUtils.getAcquirerConfigs(emptyBpmnAssociationDto, acquirerId, functionTypeEnum).size()); + assertEquals(1, BpmnUtils.getAcquirerConfigs(emptyBpmnAssociationDto, acquirerId, functionTypeEnum.name()).size()); emptyBpmnAssociationDto.setDefaultTemplateId(uuid); emptyBpmnAssociationDto.setDefaultTemplateVersion(1L); - assertEquals(1, BpmnUtils.getAcquirerConfigs(emptyBpmnAssociationDto, acquirerId, functionTypeEnum).size()); + assertEquals(1, BpmnUtils.getAcquirerConfigs(emptyBpmnAssociationDto, acquirerId, functionTypeEnum.name()).size()); BranchConfigs branchConfig = new BranchConfigs(); branchConfig.setBranchDefaultTemplateId(uuid); branchConfig.setBranchDefaultTemplateVersion(1L); emptyBpmnAssociationDto.setBranchesConfigs(List.of(branchConfig)); - assertEquals(2, BpmnUtils.getAcquirerConfigs(emptyBpmnAssociationDto, acquirerId, functionTypeEnum).size()); + assertEquals(2, BpmnUtils.getAcquirerConfigs(emptyBpmnAssociationDto, acquirerId, functionTypeEnum.name()).size()); TerminalConfigs terminalConfig = new TerminalConfigs(); terminalConfig.setTemplateId(uuid); terminalConfig.setTemplateVersion(1L); terminalConfig.setTerminalIds(List.of("terminal1", "terminal2")); branchConfig.setTerminals(List.of(terminalConfig)); - assertEquals(4, BpmnUtils.getAcquirerConfigs(emptyBpmnAssociationDto, acquirerId, functionTypeEnum).size()); + assertEquals(4, BpmnUtils.getAcquirerConfigs(emptyBpmnAssociationDto, acquirerId, functionTypeEnum.name()).size()); }