diff --git a/Dockerfile b/Dockerfile index dd42d12c..d20e5b8d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,12 +3,22 @@ ARG JAVA_VERSION=11 FROM mcr.microsoft.com/azure-functions/java:3.0-java$JAVA_VERSION-build AS installer-env COPY . /src/java-function-app +RUN echo $(ls -1 /src/java-function-app) +RUN chmod 777 /src/java-function-app/agent/config.yaml RUN cd /src/java-function-app && \ + wget https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.19.0/jmx_prometheus_javaagent-0.19.0.jar && \ + wget https://search.maven.org/remotecontent?filepath=co/elastic/apm/elastic-apm-agent/1.36.0/elastic-apm-agent-1.36.0.jar && \ mkdir -p /home/site/wwwroot && \ mvn clean package -Dmaven.test.skip=true && \ cd ./target/azure-functions/ && \ cd $(ls -d */|head -n 1) && \ - cp -a . /home/site/wwwroot + cp -a . /home/site/wwwroot && \ + cp /src/java-function-app/agent/config.yaml /home/site/wwwroot/config.yaml +RUN chmod 777 /src/java-function-app/jmx_prometheus_javaagent-0.19.0.jar && \ + cp /src/java-function-app/jmx_prometheus_javaagent-0.19.0.jar /home/site/wwwroot/jmx_prometheus_javaagent-0.19.0.jar + +RUN chmod 777 /src/java-function-app/elastic-apm-agent-1.36.0.jar && \ + cp /src/java-function-app/elastic-apm-agent-1.36.0.jar /home/site/wwwroot/elastic-apm-agent-1.36.0.jar # This image is ssh enabled #FROM mcr.microsoft.com/azure-functions/java:3.0-java$JAVA_VERSION-appservice @@ -19,4 +29,5 @@ ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ AzureFunctionsJobHost__Logging__Console__IsEnabled=true EXPOSE 80 +EXPOSE 12345 COPY --from=installer-env ["/home/site/wwwroot", "/home/site/wwwroot"] \ No newline at end of file diff --git a/agent/config.yaml b/agent/config.yaml new file mode 100644 index 00000000..cb19fee9 --- /dev/null +++ b/agent/config.yaml @@ -0,0 +1,2 @@ +rules: + - pattern: ".*" \ No newline at end of file diff --git a/helm/Chart.lock b/helm/Chart.lock deleted file mode 100644 index ec10db31..00000000 --- a/helm/Chart.lock +++ /dev/null @@ -1,6 +0,0 @@ -dependencies: -- name: microservice-chart - repository: https://pagopa.github.io/aks-microservice-chart-blueprint - version: 1.21.0 -digest: sha256:e3deccb7ac0b5d85af0c726f28316ebe7a3795cbf54522330c33474b0bae309a -generated: "2022-10-06T17:44:35.49088+02:00" diff --git a/helm/Chart.yaml b/helm/Chart.yaml index bda21967..ae655b0a 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,9 +2,9 @@ apiVersion: v2 name: pagopa-functions-template description: Microservice description type: application -version: 0.25.0 -appVersion: 1.4.3 +version: 0.33.0 +appVersion: 1.5.0-PRDP-64-feat-add-elk-apm-configurations dependencies: - name: microservice-chart - version: 1.21.0 + version: 2.4.0 repository: "https://pagopa.github.io/aks-microservice-chart-blueprint" diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 49781873..521afd46 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-pdf-engine - tag: "1.4.3" + tag: "1.5.0-PRDP-64-feat-add-elk-apm-configurations" pullPolicy: Always # https://github.com/Azure/azure-functions-host/blob/dev/src/WebJobs.Script.WebHost/Controllers/HostController.cs livenessProbe: @@ -23,14 +23,25 @@ microservice-chart: periodSeconds: 10 deployment: create: true - service: + serviceMonitor: create: true + endpoints: + - interval: 10s #jmx-exporter + targetPort: 12345 + path: /metrics + ports: + - 80 #http + - 12345 #jmx-exporter + service: type: ClusterIP - port: 80 + ports: + - 80 #http + - 12345 #jmx-exporter ingress: create: true host: "weudev.shared.internal.dev.platform.pagopa.it" path: /pagopa-pdf-engine/(.*) + servicePort: 80 serviceAccount: create: false annotations: {} @@ -64,8 +75,14 @@ microservice-chart: WEBSITE_SITE_NAME: "pagopapdfengine" # required to show cloud role name in application insights FUNCTIONS_WORKER_RUNTIME: "java" HTML_TEMPLATE_FILE_NAME: "template" + ELASTIC_APM_SERVICE_NAME: "pagopapdfengine" + ELASTIC_APM_APPLICATION_PACKAGES: "it.gov.pagopa.pdf.engine" + ELASTIC_APM_SERVER_URL: "http://quickstart-apm-http.elastic-system.svc:8200" + ELASTIC_APM_LOG_SENDING: 'true' + JAVA_TOOL_OPTIONS: "-javaagent:/home/site/wwwroot/jmx_prometheus_javaagent-0.19.0.jar=12345:/home/site/wwwroot/config.yaml -javaagent:/home/site/wwwroot/elastic-apm-agent-1.36.0.jar" envSecret: APPLICATIONINSIGHTS_CONNECTION_STRING: 'ai-d-connection-string' + ELASTIC_APM_SECRET_TOKEN: 'elastic-apm-secret-token' keyvault: name: "pagopa-d-shared-kv" tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d" @@ -95,7 +112,7 @@ microservice-chart: create: true image: repository: ghcr.io/pagopa/pagopa-pdf-engine - tag: "1.4.3" + tag: "1.5.0-PRDP-64-feat-add-elk-apm-configurations" pullPolicy: Always envConfig: envSecret: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index d2bb56e2..878d2825 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-pdf-engine - tag: "1.4.3" + tag: "1.5.0-PRDP-64-feat-add-elk-apm-configurations" pullPolicy: Always # https://github.com/Azure/azure-functions-host/blob/dev/src/WebJobs.Script.WebHost/Controllers/HostController.cs livenessProbe: @@ -23,14 +23,25 @@ microservice-chart: periodSeconds: 10 deployment: create: true - service: + serviceMonitor: create: true + endpoints: + - interval: 10s #jmx-exporter + targetPort: 12345 + path: /metrics + ports: + - 80 #http + - 12345 #jmx-exporter + service: type: ClusterIP - port: 80 + ports: + - 80 #http + - 12345 #jmx-exporter ingress: create: true host: "weuprod.shared.internal.platform.pagopa.it" path: /pagopa-pdf-engine/(.*) + servicePort: 80 serviceAccount: create: false annotations: {} @@ -64,8 +75,14 @@ microservice-chart: WEBSITE_SITE_NAME: "pagopapdfengine" # required to show cloud role name in application insights FUNCTIONS_WORKER_RUNTIME: "java" HTML_TEMPLATE_FILE_NAME: "template" + ELASTIC_APM_SERVICE_NAME: "pagopapdfengine" + ELASTIC_APM_APPLICATION_PACKAGES: "it.gov.pagopa.pdf.engine" + ELASTIC_APM_SERVER_URL: "http://quickstart-apm-http.elastic-system.svc:8200" + ELASTIC_APM_LOG_SENDING: "true" + JAVA_TOOL_OPTIONS: "-javaagent:/home/site/wwwroot/jmx_prometheus_javaagent-0.19.0.jar=12345:/home/site/wwwroot/config.yaml -javaagent:/home/site/wwwroot/elastic-apm-agent-1.36.0.jar" envSecret: APPLICATIONINSIGHTS_CONNECTION_STRING: 'ai-p-connection-string' + ELASTIC_APM_SECRET_TOKEN: 'elastic-apm-secret-token' keyvault: name: "pagopa-p-shared-kv" tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d" @@ -95,7 +112,7 @@ microservice-chart: create: true image: repository: ghcr.io/pagopa/pagopa-pdf-engine - tag: "1.4.3" + tag: "1.5.0-PRDP-64-feat-add-elk-apm-configurations" pullPolicy: Always envConfig: envSecret: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index e36afc02..a81cae4e 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-pdf-engine - tag: "1.4.3" + tag: "1.5.0-PRDP-64-feat-add-elk-apm-configurations" pullPolicy: Always # https://github.com/Azure/azure-functions-host/blob/dev/src/WebJobs.Script.WebHost/Controllers/HostController.cs livenessProbe: @@ -23,14 +23,25 @@ microservice-chart: periodSeconds: 10 deployment: create: true - service: + serviceMonitor: create: true + endpoints: + - interval: 10s #jmx-exporter + targetPort: 12345 + path: /metrics + ports: + - 80 #http + - 12345 #jmx-exporter + service: type: ClusterIP - port: 80 + ports: + - 80 #http + - 12345 #jmx-exporter ingress: create: true host: "weuuat.shared.internal.uat.platform.pagopa.it" path: /pagopa-pdf-engine/(.*) + servicePort: 80 serviceAccount: create: false annotations: {} @@ -64,8 +75,14 @@ microservice-chart: WEBSITE_SITE_NAME: "pagopapdfengine" # required to show cloud role name in application insights FUNCTIONS_WORKER_RUNTIME: "java" HTML_TEMPLATE_FILE_NAME: "template" + ELASTIC_APM_SERVICE_NAME: "pagopapdfengine" + ELASTIC_APM_APPLICATION_PACKAGES: "it.gov.pagopa.pdf.engine" + ELASTIC_APM_SERVER_URL: "http://quickstart-apm-http.elastic-system.svc:8200" + ELASTIC_APM_LOG_SENDING: "true" + JAVA_TOOL_OPTIONS: "-javaagent:/home/site/wwwroot/jmx_prometheus_javaagent-0.19.0.jar=12345:/home/site/wwwroot/config.yaml -javaagent:/home/site/wwwroot/elastic-apm-agent-1.36.0.jar" envSecret: APPLICATIONINSIGHTS_CONNECTION_STRING: 'ai-u-connection-string' + ELASTIC_APM_SECRET_TOKEN: 'elastic-apm-secret-token' keyvault: name: "pagopa-u-shared-kv" tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d" @@ -95,7 +112,7 @@ microservice-chart: create: true image: repository: ghcr.io/pagopa/pagopa-pdf-engine - tag: "1.4.3" + tag: "1.5.0-PRDP-64-feat-add-elk-apm-configurations" pullPolicy: Always envConfig: envSecret: diff --git a/openapi/openapi.json b/openapi/openapi.json index 2c4da231..75aa6c60 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -2,7 +2,7 @@ "openapi": "3.0.1", "info": { "title": "OpenAPI definition - PDF Engine", - "version": "1.4.3" + "version": "1.5.0-PRDP-64-feat-add-elk-apm-configurations" }, "servers": [ { diff --git a/pom.xml b/pom.xml index f2b30e0c..db84b12d 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ it.gov.pagopa pdf-engine - 1.4.3 + 1.5.0-PRDP-64-feat-add-elk-apm-configurations jar pagopa-pdf-engine diff --git a/src/main/java/it/gov/pagopa/project/HttpTriggerGeneratePDFFunction.java b/src/main/java/it/gov/pagopa/pdf/engine/HttpTriggerGeneratePDFFunction.java similarity index 87% rename from src/main/java/it/gov/pagopa/project/HttpTriggerGeneratePDFFunction.java rename to src/main/java/it/gov/pagopa/pdf/engine/HttpTriggerGeneratePDFFunction.java index 23090e98..eec581c6 100644 --- a/src/main/java/it/gov/pagopa/project/HttpTriggerGeneratePDFFunction.java +++ b/src/main/java/it/gov/pagopa/pdf/engine/HttpTriggerGeneratePDFFunction.java @@ -13,7 +13,7 @@ If not, see https://www.gnu.org/licenses/. */ -package it.gov.pagopa.project; +package it.gov.pagopa.pdf.engine; import com.fasterxml.jackson.databind.ObjectMapper; import com.github.jknack.handlebars.Handlebars; @@ -23,15 +23,15 @@ import com.microsoft.azure.functions.annotation.AuthorizationLevel; import com.microsoft.azure.functions.annotation.FunctionName; import com.microsoft.azure.functions.annotation.HttpTrigger; -import it.gov.pagopa.project.exception.PDFEngineException; -import it.gov.pagopa.project.model.AppErrorCodeEnum; -import it.gov.pagopa.project.model.ErrorMessage; -import it.gov.pagopa.project.model.ErrorResponse; -import it.gov.pagopa.project.model.GeneratePDFInput; -import it.gov.pagopa.project.service.GeneratePDFService; -import it.gov.pagopa.project.service.ParseRequestBodyService; -import it.gov.pagopa.project.service.impl.GeneratePDFServiceImpl; -import it.gov.pagopa.project.service.impl.ParseRequestBodyServiceImpl; +import it.gov.pagopa.pdf.engine.exception.PDFEngineException; +import it.gov.pagopa.pdf.engine.model.AppErrorCodeEnum; +import it.gov.pagopa.pdf.engine.model.ErrorMessage; +import it.gov.pagopa.pdf.engine.model.ErrorResponse; +import it.gov.pagopa.pdf.engine.model.GeneratePDFInput; +import it.gov.pagopa.pdf.engine.service.GeneratePDFService; +import it.gov.pagopa.pdf.engine.service.ParseRequestBodyService; +import it.gov.pagopa.pdf.engine.service.impl.GeneratePDFServiceImpl; +import it.gov.pagopa.pdf.engine.service.impl.ParseRequestBodyServiceImpl; import org.apache.commons.io.FileUtils; import java.io.BufferedInputStream; @@ -50,7 +50,6 @@ import static com.microsoft.azure.functions.HttpStatus.BAD_REQUEST; import static com.microsoft.azure.functions.HttpStatus.INTERNAL_SERVER_ERROR; -import static it.gov.pagopa.project.model.AppErrorCodeEnum.*; /** * Azure Functions with HTTP Trigger. @@ -98,7 +97,7 @@ public HttpResponseMessage run( logger.severe("Invalid request the payload is null"); return request .createResponseBuilder(BAD_REQUEST) - .body(buildResponseBody(BAD_REQUEST, PDFE_899, INVALID_REQUEST_MESSAGE)) + .body(buildResponseBody(BAD_REQUEST, AppErrorCodeEnum.PDFE_899, INVALID_REQUEST_MESSAGE)) .build(); } @@ -112,13 +111,13 @@ public HttpResponseMessage run( .format(Instant.now()) ); } catch (IOException e) { - logger.log(Level.SEVERE, PDFE_908.getErrorMessage(), e); + logger.log(Level.SEVERE, AppErrorCodeEnum.PDFE_908.getErrorMessage(), e); return request .createResponseBuilder(HttpStatus.INTERNAL_SERVER_ERROR) .body( buildResponseBody( INTERNAL_SERVER_ERROR, - PDFE_908, + AppErrorCodeEnum.PDFE_908, "An error occurred on processing the request")) .build(); } @@ -140,7 +139,7 @@ public HttpResponseMessage run( logger.severe("Invalid request, template HTML not provided"); return request .createResponseBuilder(BAD_REQUEST) - .body(buildResponseBody(BAD_REQUEST, PDFE_897, INVALID_REQUEST_MESSAGE)) + .body(buildResponseBody(BAD_REQUEST, AppErrorCodeEnum.PDFE_897, INVALID_REQUEST_MESSAGE)) .build(); } @@ -148,7 +147,7 @@ public HttpResponseMessage run( logger.severe("Invalid request the PDF document input data are null"); return request .createResponseBuilder(BAD_REQUEST) - .body(buildResponseBody(BAD_REQUEST, PDFE_898, INVALID_REQUEST_MESSAGE)) + .body(buildResponseBody(BAD_REQUEST, AppErrorCodeEnum.PDFE_898, INVALID_REQUEST_MESSAGE)) .build(); } @@ -178,7 +177,7 @@ public HttpResponseMessage run( .body( buildResponseBody( INTERNAL_SERVER_ERROR, - PDFE_907, + AppErrorCodeEnum.PDFE_907, ERROR_GENERATING_PDF_MESSAGE)) .build(); } finally { @@ -190,7 +189,7 @@ public HttpResponseMessage run( private static HttpStatus getHttpStatus(PDFEngineException e) { HttpStatus status; - if (e.getErrorCode().equals(PDFE_703) || e.getErrorCode().equals(PDFE_704) || e.getErrorCode().equals(PDFE_705)) { + if (e.getErrorCode().equals(AppErrorCodeEnum.PDFE_703) || e.getErrorCode().equals(AppErrorCodeEnum.PDFE_704) || e.getErrorCode().equals(AppErrorCodeEnum.PDFE_705)) { status = INTERNAL_SERVER_ERROR; } else { status = BAD_REQUEST; diff --git a/src/main/java/it/gov/pagopa/project/Info.java b/src/main/java/it/gov/pagopa/pdf/engine/Info.java similarity index 95% rename from src/main/java/it/gov/pagopa/project/Info.java rename to src/main/java/it/gov/pagopa/pdf/engine/Info.java index 635cd704..1be1c592 100644 --- a/src/main/java/it/gov/pagopa/project/Info.java +++ b/src/main/java/it/gov/pagopa/pdf/engine/Info.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.project; +package it.gov.pagopa.pdf.engine; import com.microsoft.azure.functions.*; import com.microsoft.azure.functions.annotation.AuthorizationLevel; diff --git a/src/main/java/it/gov/pagopa/project/exception/CompileTemplateException.java b/src/main/java/it/gov/pagopa/pdf/engine/exception/CompileTemplateException.java similarity index 93% rename from src/main/java/it/gov/pagopa/project/exception/CompileTemplateException.java rename to src/main/java/it/gov/pagopa/pdf/engine/exception/CompileTemplateException.java index 06b50e77..000b3db2 100644 --- a/src/main/java/it/gov/pagopa/project/exception/CompileTemplateException.java +++ b/src/main/java/it/gov/pagopa/pdf/engine/exception/CompileTemplateException.java @@ -13,9 +13,9 @@ If not, see https://www.gnu.org/licenses/. */ -package it.gov.pagopa.project.exception; +package it.gov.pagopa.pdf.engine.exception; -import it.gov.pagopa.project.model.AppErrorCodeEnum; +import it.gov.pagopa.pdf.engine.model.AppErrorCodeEnum; /** * Thrown in case of problems when compiling the HTML template diff --git a/src/main/java/it/gov/pagopa/project/exception/FillTemplateException.java b/src/main/java/it/gov/pagopa/pdf/engine/exception/FillTemplateException.java similarity index 93% rename from src/main/java/it/gov/pagopa/project/exception/FillTemplateException.java rename to src/main/java/it/gov/pagopa/pdf/engine/exception/FillTemplateException.java index 50910857..b9d60ad1 100644 --- a/src/main/java/it/gov/pagopa/project/exception/FillTemplateException.java +++ b/src/main/java/it/gov/pagopa/pdf/engine/exception/FillTemplateException.java @@ -13,9 +13,9 @@ If not, see https://www.gnu.org/licenses/. */ -package it.gov.pagopa.project.exception; +package it.gov.pagopa.pdf.engine.exception; -import it.gov.pagopa.project.model.AppErrorCodeEnum; +import it.gov.pagopa.pdf.engine.model.AppErrorCodeEnum; /** * Thrown in case of problems when filling the HTML template diff --git a/src/main/java/it/gov/pagopa/project/exception/GeneratePDFException.java b/src/main/java/it/gov/pagopa/pdf/engine/exception/GeneratePDFException.java similarity index 93% rename from src/main/java/it/gov/pagopa/project/exception/GeneratePDFException.java rename to src/main/java/it/gov/pagopa/pdf/engine/exception/GeneratePDFException.java index 37699efa..d8100d3e 100644 --- a/src/main/java/it/gov/pagopa/project/exception/GeneratePDFException.java +++ b/src/main/java/it/gov/pagopa/pdf/engine/exception/GeneratePDFException.java @@ -13,9 +13,9 @@ If not, see https://www.gnu.org/licenses/. */ -package it.gov.pagopa.project.exception; +package it.gov.pagopa.pdf.engine.exception; -import it.gov.pagopa.project.model.AppErrorCodeEnum; +import it.gov.pagopa.pdf.engine.model.AppErrorCodeEnum; /** * Thrown in case of problems when generating the PDFA/2a document diff --git a/src/main/java/it/gov/pagopa/project/exception/PDFEngineException.java b/src/main/java/it/gov/pagopa/pdf/engine/exception/PDFEngineException.java similarity index 94% rename from src/main/java/it/gov/pagopa/project/exception/PDFEngineException.java rename to src/main/java/it/gov/pagopa/pdf/engine/exception/PDFEngineException.java index e9c077ec..7ba9a14a 100644 --- a/src/main/java/it/gov/pagopa/project/exception/PDFEngineException.java +++ b/src/main/java/it/gov/pagopa/pdf/engine/exception/PDFEngineException.java @@ -13,9 +13,9 @@ If not, see https://www.gnu.org/licenses/. */ -package it.gov.pagopa.project.exception; +package it.gov.pagopa.pdf.engine.exception; -import it.gov.pagopa.project.model.AppErrorCodeEnum; +import it.gov.pagopa.pdf.engine.model.AppErrorCodeEnum; import java.util.Objects; diff --git a/src/main/java/it/gov/pagopa/project/exception/RequestBodyParseException.java b/src/main/java/it/gov/pagopa/pdf/engine/exception/RequestBodyParseException.java similarity index 93% rename from src/main/java/it/gov/pagopa/project/exception/RequestBodyParseException.java rename to src/main/java/it/gov/pagopa/pdf/engine/exception/RequestBodyParseException.java index 10222c19..9bfe8e77 100644 --- a/src/main/java/it/gov/pagopa/project/exception/RequestBodyParseException.java +++ b/src/main/java/it/gov/pagopa/pdf/engine/exception/RequestBodyParseException.java @@ -13,9 +13,9 @@ If not, see https://www.gnu.org/licenses/. */ -package it.gov.pagopa.project.exception; +package it.gov.pagopa.pdf.engine.exception; -import it.gov.pagopa.project.model.AppErrorCodeEnum; +import it.gov.pagopa.pdf.engine.model.AppErrorCodeEnum; /** * Thrown in case of problems when parsing request body diff --git a/src/main/java/it/gov/pagopa/project/exception/UnexpectedRequestBodyFieldException.java b/src/main/java/it/gov/pagopa/pdf/engine/exception/UnexpectedRequestBodyFieldException.java similarity index 93% rename from src/main/java/it/gov/pagopa/project/exception/UnexpectedRequestBodyFieldException.java rename to src/main/java/it/gov/pagopa/pdf/engine/exception/UnexpectedRequestBodyFieldException.java index b1b28447..0de6ef7c 100644 --- a/src/main/java/it/gov/pagopa/project/exception/UnexpectedRequestBodyFieldException.java +++ b/src/main/java/it/gov/pagopa/pdf/engine/exception/UnexpectedRequestBodyFieldException.java @@ -13,9 +13,9 @@ If not, see https://www.gnu.org/licenses/. */ -package it.gov.pagopa.project.exception; +package it.gov.pagopa.pdf.engine.exception; -import it.gov.pagopa.project.model.AppErrorCodeEnum; +import it.gov.pagopa.pdf.engine.model.AppErrorCodeEnum; /** * Thrown in case of unexpected field in the request body diff --git a/src/main/java/it/gov/pagopa/project/model/AppErrorCodeEnum.java b/src/main/java/it/gov/pagopa/pdf/engine/model/AppErrorCodeEnum.java similarity index 98% rename from src/main/java/it/gov/pagopa/project/model/AppErrorCodeEnum.java rename to src/main/java/it/gov/pagopa/pdf/engine/model/AppErrorCodeEnum.java index 02907cfa..ef6c451b 100644 --- a/src/main/java/it/gov/pagopa/project/model/AppErrorCodeEnum.java +++ b/src/main/java/it/gov/pagopa/pdf/engine/model/AppErrorCodeEnum.java @@ -13,7 +13,7 @@ If not, see https://www.gnu.org/licenses/. */ -package it.gov.pagopa.project.model; +package it.gov.pagopa.pdf.engine.model; import lombok.Getter; diff --git a/src/main/java/it/gov/pagopa/project/model/ErrorMessage.java b/src/main/java/it/gov/pagopa/pdf/engine/model/ErrorMessage.java similarity index 95% rename from src/main/java/it/gov/pagopa/project/model/ErrorMessage.java rename to src/main/java/it/gov/pagopa/pdf/engine/model/ErrorMessage.java index 3c7be476..3439e5bc 100644 --- a/src/main/java/it/gov/pagopa/project/model/ErrorMessage.java +++ b/src/main/java/it/gov/pagopa/pdf/engine/model/ErrorMessage.java @@ -13,7 +13,7 @@ If not, see https://www.gnu.org/licenses/. */ -package it.gov.pagopa.project.model; +package it.gov.pagopa.pdf.engine.model; import lombok.Builder; import lombok.Data; diff --git a/src/main/java/it/gov/pagopa/project/model/ErrorResponse.java b/src/main/java/it/gov/pagopa/pdf/engine/model/ErrorResponse.java similarity index 97% rename from src/main/java/it/gov/pagopa/project/model/ErrorResponse.java rename to src/main/java/it/gov/pagopa/pdf/engine/model/ErrorResponse.java index f886251c..7435422c 100644 --- a/src/main/java/it/gov/pagopa/project/model/ErrorResponse.java +++ b/src/main/java/it/gov/pagopa/pdf/engine/model/ErrorResponse.java @@ -13,7 +13,7 @@ If not, see https://www.gnu.org/licenses/. */ -package it.gov.pagopa.project.model; +package it.gov.pagopa.pdf.engine.model; import com.microsoft.azure.functions.HttpStatus; import lombok.Getter; diff --git a/src/main/java/it/gov/pagopa/project/model/GeneratePDFInput.java b/src/main/java/it/gov/pagopa/pdf/engine/model/GeneratePDFInput.java similarity index 95% rename from src/main/java/it/gov/pagopa/project/model/GeneratePDFInput.java rename to src/main/java/it/gov/pagopa/pdf/engine/model/GeneratePDFInput.java index 9613384b..b66f73cb 100644 --- a/src/main/java/it/gov/pagopa/project/model/GeneratePDFInput.java +++ b/src/main/java/it/gov/pagopa/pdf/engine/model/GeneratePDFInput.java @@ -13,7 +13,7 @@ If not, see https://www.gnu.org/licenses/. */ -package it.gov.pagopa.project.model; +package it.gov.pagopa.pdf.engine.model; import lombok.Data; diff --git a/src/main/java/it/gov/pagopa/project/service/GeneratePDFService.java b/src/main/java/it/gov/pagopa/pdf/engine/service/GeneratePDFService.java similarity index 85% rename from src/main/java/it/gov/pagopa/project/service/GeneratePDFService.java rename to src/main/java/it/gov/pagopa/pdf/engine/service/GeneratePDFService.java index 31e80b68..18391e11 100644 --- a/src/main/java/it/gov/pagopa/project/service/GeneratePDFService.java +++ b/src/main/java/it/gov/pagopa/pdf/engine/service/GeneratePDFService.java @@ -13,13 +13,13 @@ If not, see https://www.gnu.org/licenses/. */ -package it.gov.pagopa.project.service; +package it.gov.pagopa.pdf.engine.service; -import it.gov.pagopa.project.exception.CompileTemplateException; -import it.gov.pagopa.project.exception.FillTemplateException; -import it.gov.pagopa.project.exception.GeneratePDFException; -import it.gov.pagopa.project.model.GeneratePDFInput; +import it.gov.pagopa.pdf.engine.exception.CompileTemplateException; +import it.gov.pagopa.pdf.engine.exception.FillTemplateException; +import it.gov.pagopa.pdf.engine.exception.GeneratePDFException; +import it.gov.pagopa.pdf.engine.model.GeneratePDFInput; import java.io.BufferedInputStream; import java.io.ByteArrayOutputStream; diff --git a/src/main/java/it/gov/pagopa/project/service/ParseRequestBodyService.java b/src/main/java/it/gov/pagopa/pdf/engine/service/ParseRequestBodyService.java similarity index 86% rename from src/main/java/it/gov/pagopa/project/service/ParseRequestBodyService.java rename to src/main/java/it/gov/pagopa/pdf/engine/service/ParseRequestBodyService.java index 651d09ab..e590ffd0 100644 --- a/src/main/java/it/gov/pagopa/project/service/ParseRequestBodyService.java +++ b/src/main/java/it/gov/pagopa/pdf/engine/service/ParseRequestBodyService.java @@ -13,11 +13,11 @@ If not, see https://www.gnu.org/licenses/. */ -package it.gov.pagopa.project.service; +package it.gov.pagopa.pdf.engine.service; -import it.gov.pagopa.project.exception.RequestBodyParseException; -import it.gov.pagopa.project.exception.UnexpectedRequestBodyFieldException; -import it.gov.pagopa.project.model.GeneratePDFInput; +import it.gov.pagopa.pdf.engine.exception.RequestBodyParseException; +import it.gov.pagopa.pdf.engine.exception.UnexpectedRequestBodyFieldException; +import it.gov.pagopa.pdf.engine.model.GeneratePDFInput; import java.nio.file.Path; import java.util.Map; diff --git a/src/main/java/it/gov/pagopa/project/service/impl/GeneratePDFServiceImpl.java b/src/main/java/it/gov/pagopa/pdf/engine/service/impl/GeneratePDFServiceImpl.java similarity index 91% rename from src/main/java/it/gov/pagopa/project/service/impl/GeneratePDFServiceImpl.java rename to src/main/java/it/gov/pagopa/pdf/engine/service/impl/GeneratePDFServiceImpl.java index 1c478c95..3aaca776 100644 --- a/src/main/java/it/gov/pagopa/project/service/impl/GeneratePDFServiceImpl.java +++ b/src/main/java/it/gov/pagopa/pdf/engine/service/impl/GeneratePDFServiceImpl.java @@ -13,7 +13,7 @@ If not, see https://www.gnu.org/licenses/. */ -package it.gov.pagopa.project.service.impl; +package it.gov.pagopa.pdf.engine.service.impl; import com.github.jknack.handlebars.Handlebars; import com.github.jknack.handlebars.Template; @@ -26,12 +26,12 @@ import com.itextpdf.layout.Document; import com.itextpdf.layout.font.FontProvider; import com.itextpdf.pdfa.PdfADocument; -import it.gov.pagopa.project.exception.CompileTemplateException; -import it.gov.pagopa.project.exception.FillTemplateException; -import it.gov.pagopa.project.exception.GeneratePDFException; -import it.gov.pagopa.project.model.AppErrorCodeEnum; -import it.gov.pagopa.project.model.GeneratePDFInput; -import it.gov.pagopa.project.service.GeneratePDFService; +import it.gov.pagopa.pdf.engine.exception.CompileTemplateException; +import it.gov.pagopa.pdf.engine.exception.GeneratePDFException; +import it.gov.pagopa.pdf.engine.exception.FillTemplateException; +import it.gov.pagopa.pdf.engine.model.AppErrorCodeEnum; +import it.gov.pagopa.pdf.engine.model.GeneratePDFInput; +import it.gov.pagopa.pdf.engine.service.GeneratePDFService; import org.apache.commons.io.IOUtils; import java.io.*; @@ -41,8 +41,8 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; -import static it.gov.pagopa.project.model.AppErrorCodeEnum.*; -import static it.gov.pagopa.project.util.Constants.UNZIPPED_FILES_FOLDER; +import static it.gov.pagopa.pdf.engine.model.AppErrorCodeEnum.*; +import static it.gov.pagopa.pdf.engine.util.Constants.UNZIPPED_FILES_FOLDER; public class GeneratePDFServiceImpl implements GeneratePDFService { diff --git a/src/main/java/it/gov/pagopa/project/service/impl/ParseRequestBodyServiceImpl.java b/src/main/java/it/gov/pagopa/pdf/engine/service/impl/ParseRequestBodyServiceImpl.java similarity index 92% rename from src/main/java/it/gov/pagopa/project/service/impl/ParseRequestBodyServiceImpl.java rename to src/main/java/it/gov/pagopa/pdf/engine/service/impl/ParseRequestBodyServiceImpl.java index 3fd458de..20b69625 100644 --- a/src/main/java/it/gov/pagopa/project/service/impl/ParseRequestBodyServiceImpl.java +++ b/src/main/java/it/gov/pagopa/pdf/engine/service/impl/ParseRequestBodyServiceImpl.java @@ -13,17 +13,17 @@ If not, see https://www.gnu.org/licenses/. */ -package it.gov.pagopa.project.service.impl; +package it.gov.pagopa.pdf.engine.service.impl; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.annotations.VisibleForTesting; -import it.gov.pagopa.project.exception.RequestBodyParseException; -import it.gov.pagopa.project.exception.UnexpectedRequestBodyFieldException; -import it.gov.pagopa.project.model.AppErrorCodeEnum; -import it.gov.pagopa.project.model.GeneratePDFInput; -import it.gov.pagopa.project.service.ParseRequestBodyService; +import it.gov.pagopa.pdf.engine.exception.RequestBodyParseException; +import it.gov.pagopa.pdf.engine.exception.UnexpectedRequestBodyFieldException; +import it.gov.pagopa.pdf.engine.model.AppErrorCodeEnum; +import it.gov.pagopa.pdf.engine.model.GeneratePDFInput; +import it.gov.pagopa.pdf.engine.service.ParseRequestBodyService; import net.lingala.zip4j.ZipFile; import org.apache.commons.fileupload.FileUploadBase.FileUploadIOException; import org.apache.commons.fileupload.MultipartStream; @@ -32,9 +32,9 @@ import java.nio.file.Path; import java.util.Map; -import static it.gov.pagopa.project.model.AppErrorCodeEnum.*; -import static it.gov.pagopa.project.util.Constants.UNZIPPED_FILES_FOLDER; -import static it.gov.pagopa.project.util.Constants.ZIP_FILE_NAME; +import static it.gov.pagopa.pdf.engine.model.AppErrorCodeEnum.*; +import static it.gov.pagopa.pdf.engine.util.Constants.UNZIPPED_FILES_FOLDER; +import static it.gov.pagopa.pdf.engine.util.Constants.ZIP_FILE_NAME; public class ParseRequestBodyServiceImpl implements ParseRequestBodyService { diff --git a/src/main/java/it/gov/pagopa/project/util/Constants.java b/src/main/java/it/gov/pagopa/pdf/engine/util/Constants.java similarity index 82% rename from src/main/java/it/gov/pagopa/project/util/Constants.java rename to src/main/java/it/gov/pagopa/pdf/engine/util/Constants.java index faef277c..cee6bd09 100644 --- a/src/main/java/it/gov/pagopa/project/util/Constants.java +++ b/src/main/java/it/gov/pagopa/pdf/engine/util/Constants.java @@ -1,4 +1,4 @@ -package it.gov.pagopa.project.util; +package it.gov.pagopa.pdf.engine.util; public class Constants { diff --git a/src/test/java/it/gov/pagopa/project/HttpTriggerGeneratePDFFunctionTest.java b/src/test/java/it/gov/pagopa/pdf/engine/HttpTriggerGeneratePDFFunctionTest.java similarity index 88% rename from src/test/java/it/gov/pagopa/project/HttpTriggerGeneratePDFFunctionTest.java rename to src/test/java/it/gov/pagopa/pdf/engine/HttpTriggerGeneratePDFFunctionTest.java index d9d7ee7e..cf82e436 100644 --- a/src/test/java/it/gov/pagopa/project/HttpTriggerGeneratePDFFunctionTest.java +++ b/src/test/java/it/gov/pagopa/pdf/engine/HttpTriggerGeneratePDFFunctionTest.java @@ -13,24 +13,26 @@ If not, see https://www.gnu.org/licenses/. */ -package it.gov.pagopa.project; +package it.gov.pagopa.pdf.engine; import com.microsoft.azure.functions.ExecutionContext; import com.microsoft.azure.functions.HttpRequestMessage; import com.microsoft.azure.functions.HttpResponseMessage; import com.microsoft.azure.functions.HttpStatus; -import it.gov.pagopa.project.exception.CompileTemplateException; -import it.gov.pagopa.project.exception.RequestBodyParseException; -import it.gov.pagopa.project.model.AppErrorCodeEnum; -import it.gov.pagopa.project.model.ErrorResponse; -import it.gov.pagopa.project.model.GeneratePDFInput; -import it.gov.pagopa.project.service.GeneratePDFService; -import it.gov.pagopa.project.service.ParseRequestBodyService; -import it.gov.pagopa.project.util.HttpResponseMessageMock; +import it.gov.pagopa.pdf.engine.exception.CompileTemplateException; +import it.gov.pagopa.pdf.engine.exception.RequestBodyParseException; +import it.gov.pagopa.pdf.engine.model.AppErrorCodeEnum; +import it.gov.pagopa.pdf.engine.model.ErrorResponse; +import it.gov.pagopa.pdf.engine.model.GeneratePDFInput; +import it.gov.pagopa.pdf.engine.service.GeneratePDFService; +import it.gov.pagopa.pdf.engine.service.ParseRequestBodyService; +import it.gov.pagopa.pdf.engine.util.HttpResponseMessageMock; import lombok.SneakyThrows; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.MockedStatic; +import org.mockito.Mockito; import org.mockito.stubbing.Answer; import java.io.BufferedInputStream; @@ -42,7 +44,6 @@ import static com.microsoft.azure.functions.HttpStatus.BAD_REQUEST; import static com.microsoft.azure.functions.HttpStatus.INTERNAL_SERVER_ERROR; -import static it.gov.pagopa.project.model.AppErrorCodeEnum.*; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.*; @@ -143,7 +144,7 @@ void runFailOnInvalidInput() { Object body = response.getBody(); assertNotNull(body); assertTrue(body instanceof ErrorResponse); - assertEquals(AppErrorCodeEnum.PDFE_899, ((ErrorResponse) body).getAppErrorCode()); + Assertions.assertEquals(AppErrorCodeEnum.PDFE_899, ((ErrorResponse) body).getAppErrorCode()); } @Test @@ -169,7 +170,7 @@ void runFailOnCreateWorkingDirectory() { Object body = response.getBody(); assertNotNull(body); assertTrue(body instanceof ErrorResponse); - assertEquals(PDFE_908, ((ErrorResponse) body).getAppErrorCode()); + Assertions.assertEquals(AppErrorCodeEnum.PDFE_908, ((ErrorResponse) body).getAppErrorCode()); } } @@ -183,7 +184,7 @@ void runFailOnParseRequestBodyWith400() { doReturn(Logger.getGlobal()).when(executionContextMock).getLogger(); doReturn(Optional.of(new byte[2])).when(request).getBody(); - doThrow(new RequestBodyParseException(PDFE_700, "")).when(parseRequestBodyServiceMock).retrieveInputData(any(), anyMap(), any()); + Mockito.doThrow(new RequestBodyParseException(AppErrorCodeEnum.PDFE_700, "")).when(parseRequestBodyServiceMock).retrieveInputData(any(), anyMap(), any()); createHttpMessageBuilderSub(request); // Invoke @@ -194,7 +195,7 @@ void runFailOnParseRequestBodyWith400() { Object body = response.getBody(); assertNotNull(body); assertTrue(body instanceof ErrorResponse); - assertEquals(PDFE_700, ((ErrorResponse) body).getAppErrorCode()); + Assertions.assertEquals(AppErrorCodeEnum.PDFE_700, ((ErrorResponse) body).getAppErrorCode()); } @Test @@ -206,7 +207,7 @@ void runFailOnParseRequestBodyWith500() { doReturn(Logger.getGlobal()).when(executionContextMock).getLogger(); doReturn(Optional.of(new byte[2])).when(request).getBody(); - doThrow(new RequestBodyParseException(PDFE_704, "")).when(parseRequestBodyServiceMock).retrieveInputData(any(), anyMap(), any()); + doThrow(new RequestBodyParseException(AppErrorCodeEnum.PDFE_704, "")).when(parseRequestBodyServiceMock).retrieveInputData(any(), anyMap(), any()); createHttpMessageBuilderSub(request); // Invoke @@ -217,7 +218,7 @@ void runFailOnParseRequestBodyWith500() { Object body = response.getBody(); assertNotNull(body); assertTrue(body instanceof ErrorResponse); - assertEquals(PDFE_704, ((ErrorResponse) body).getAppErrorCode()); + Assertions.assertEquals(AppErrorCodeEnum.PDFE_704, ((ErrorResponse) body).getAppErrorCode()); } @Test @@ -243,7 +244,7 @@ void runFailOnInvalidTemplate() { Object body = response.getBody(); assertNotNull(body); assertTrue(body instanceof ErrorResponse); - assertEquals(PDFE_897, ((ErrorResponse) body).getAppErrorCode()); + Assertions.assertEquals(AppErrorCodeEnum.PDFE_897, ((ErrorResponse) body).getAppErrorCode()); } @Test @@ -269,7 +270,7 @@ void runFailOnInvalidData() { Object body = response.getBody(); assertNotNull(body); assertTrue(body instanceof ErrorResponse); - assertEquals(PDFE_898, ((ErrorResponse) body).getAppErrorCode()); + Assertions.assertEquals(AppErrorCodeEnum.PDFE_898, ((ErrorResponse) body).getAppErrorCode()); } @Test @@ -287,7 +288,7 @@ void runFailOnGeneratePDFForPDFEngineException() { doReturn(Logger.getGlobal()).when(executionContextMock).getLogger(); doReturn(Optional.of(new byte[2])).when(request).getBody(); doReturn(generatePDFInput).when(parseRequestBodyServiceMock).retrieveInputData(any(), anyMap(), any()); - doThrow(new CompileTemplateException(AppErrorCodeEnum.PDFE_901, "")).when(generatePDFServiceMock).generatePDF(any(), any()); + Mockito.doThrow(new CompileTemplateException(AppErrorCodeEnum.PDFE_901, "")).when(generatePDFServiceMock).generatePDF(any(), any()); createHttpMessageBuilderSub(request); // Invoke diff --git a/src/test/java/it/gov/pagopa/project/InfoTest.java b/src/test/java/it/gov/pagopa/pdf/engine/InfoTest.java similarity index 93% rename from src/test/java/it/gov/pagopa/project/InfoTest.java rename to src/test/java/it/gov/pagopa/pdf/engine/InfoTest.java index 9c9c3cd7..35e7be10 100644 --- a/src/test/java/it/gov/pagopa/project/InfoTest.java +++ b/src/test/java/it/gov/pagopa/pdf/engine/InfoTest.java @@ -1,10 +1,10 @@ -package it.gov.pagopa.project; +package it.gov.pagopa.pdf.engine; import com.microsoft.azure.functions.ExecutionContext; import com.microsoft.azure.functions.HttpRequestMessage; import com.microsoft.azure.functions.HttpResponseMessage; import com.microsoft.azure.functions.HttpStatus; -import it.gov.pagopa.project.util.HttpResponseMessageMock; +import it.gov.pagopa.pdf.engine.util.HttpResponseMessageMock; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; diff --git a/src/test/java/it/gov/pagopa/project/service/impl/GeneratePDFServiceImplTest.java b/src/test/java/it/gov/pagopa/pdf/engine/service/impl/GeneratePDFServiceImplTest.java similarity index 88% rename from src/test/java/it/gov/pagopa/project/service/impl/GeneratePDFServiceImplTest.java rename to src/test/java/it/gov/pagopa/pdf/engine/service/impl/GeneratePDFServiceImplTest.java index 98408794..647eae5b 100644 --- a/src/test/java/it/gov/pagopa/project/service/impl/GeneratePDFServiceImplTest.java +++ b/src/test/java/it/gov/pagopa/pdf/engine/service/impl/GeneratePDFServiceImplTest.java @@ -13,20 +13,21 @@ If not, see https://www.gnu.org/licenses/. */ -package it.gov.pagopa.project.service.impl; +package it.gov.pagopa.pdf.engine.service.impl; import com.github.jknack.handlebars.Handlebars; import com.github.jknack.handlebars.Template; import com.github.jknack.handlebars.helper.ConditionalHelpers; -import it.gov.pagopa.project.exception.CompileTemplateException; -import it.gov.pagopa.project.exception.FillTemplateException; -import it.gov.pagopa.project.model.AppErrorCodeEnum; -import it.gov.pagopa.project.model.GeneratePDFInput; -import it.gov.pagopa.project.service.GeneratePDFService; +import it.gov.pagopa.pdf.engine.exception.CompileTemplateException; +import it.gov.pagopa.pdf.engine.exception.FillTemplateException; +import it.gov.pagopa.pdf.engine.model.AppErrorCodeEnum; +import it.gov.pagopa.pdf.engine.model.GeneratePDFInput; +import it.gov.pagopa.pdf.engine.service.GeneratePDFService; import lombok.SneakyThrows; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -112,7 +113,7 @@ void generatePDFCompileTemplateException() { CompileTemplateException e = assertThrows(CompileTemplateException.class, () -> sut.generatePDF(pdfInput, workingPath)); - assertEquals(AppErrorCodeEnum.PDFE_901, e.getErrorCode()); + Assertions.assertEquals(AppErrorCodeEnum.PDFE_901, e.getErrorCode()); } @Test @@ -128,7 +129,7 @@ void generatePDFFillTemplateException() { FillTemplateException e = assertThrows(FillTemplateException.class, () -> sut.generatePDF(pdfInput, workingPath)); - assertEquals(AppErrorCodeEnum.PDFE_900, e.getErrorCode()); + Assertions.assertEquals(AppErrorCodeEnum.PDFE_900, e.getErrorCode()); } private Handlebars buildHandlebars() { diff --git a/src/test/java/it/gov/pagopa/project/service/impl/ParseRequestBodyServiceImplTest.java b/src/test/java/it/gov/pagopa/pdf/engine/service/impl/ParseRequestBodyServiceImplTest.java similarity index 89% rename from src/test/java/it/gov/pagopa/project/service/impl/ParseRequestBodyServiceImplTest.java rename to src/test/java/it/gov/pagopa/pdf/engine/service/impl/ParseRequestBodyServiceImplTest.java index af97fb4a..417dd441 100644 --- a/src/test/java/it/gov/pagopa/project/service/impl/ParseRequestBodyServiceImplTest.java +++ b/src/test/java/it/gov/pagopa/pdf/engine/service/impl/ParseRequestBodyServiceImplTest.java @@ -13,20 +13,21 @@ If not, see https://www.gnu.org/licenses/. */ -package it.gov.pagopa.project.service.impl; +package it.gov.pagopa.pdf.engine.service.impl; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import it.gov.pagopa.project.exception.RequestBodyParseException; -import it.gov.pagopa.project.exception.UnexpectedRequestBodyFieldException; -import it.gov.pagopa.project.model.AppErrorCodeEnum; -import it.gov.pagopa.project.model.GeneratePDFInput; +import it.gov.pagopa.pdf.engine.exception.RequestBodyParseException; +import it.gov.pagopa.pdf.engine.exception.UnexpectedRequestBodyFieldException; +import it.gov.pagopa.pdf.engine.model.AppErrorCodeEnum; +import it.gov.pagopa.pdf.engine.model.GeneratePDFInput; import lombok.SneakyThrows; import org.apache.commons.fileupload.FileUploadBase.FileUploadIOException; import org.apache.commons.fileupload.MultipartStream; import org.apache.commons.io.FileUtils; import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -91,7 +92,7 @@ void retrieveInputDataFailGetContentTypeHeaderIsNull() { () -> sut.retrieveInputData(new byte[2], Collections.emptyMap(), workingPath) ); - assertEquals(AppErrorCodeEnum.PDFE_711, e.getErrorCode()); + Assertions.assertEquals(AppErrorCodeEnum.PDFE_711, e.getErrorCode()); } @Test @@ -102,7 +103,7 @@ void retrieveInputDataFailGetContentTypeHeaderIsNotMultipart() { () -> sut.retrieveInputData(new byte[2], Collections.singletonMap(CONTENT_TYPE_HEADER, "application/json"), workingPath) ); - assertEquals(AppErrorCodeEnum.PDFE_712, e.getErrorCode()); + Assertions.assertEquals(AppErrorCodeEnum.PDFE_712, e.getErrorCode()); } @Test @@ -118,7 +119,7 @@ void retrieveInputDataFailSkipPreambleThrowsIOException() { () -> sut.retrieveInputData(new byte[2], Collections.singletonMap(CONTENT_TYPE_HEADER, CONTENT_TYPE_HEADER_VALUE), workingPath) ); - assertEquals(AppErrorCodeEnum.PDFE_700, e.getErrorCode()); + Assertions.assertEquals(AppErrorCodeEnum.PDFE_700, e.getErrorCode()); } @Test @@ -135,7 +136,7 @@ void retrieveInputDataFailReadHeaderThrowsFileUploadIOException() { () -> sut.retrieveInputData(new byte[2], Collections.singletonMap(CONTENT_TYPE_HEADER, CONTENT_TYPE_HEADER_VALUE), workingPath) ); - assertEquals(AppErrorCodeEnum.PDFE_701, e.getErrorCode()); + Assertions.assertEquals(AppErrorCodeEnum.PDFE_701, e.getErrorCode()); } @Test @@ -152,7 +153,7 @@ void retrieveInputDataFailReadHeaderThrowsMalformedStreamException() { () -> sut.retrieveInputData(new byte[2], Collections.singletonMap(CONTENT_TYPE_HEADER, CONTENT_TYPE_HEADER_VALUE), workingPath) ); - assertEquals(AppErrorCodeEnum.PDFE_702, e.getErrorCode()); + Assertions.assertEquals(AppErrorCodeEnum.PDFE_702, e.getErrorCode()); } @Test @@ -170,7 +171,7 @@ void retrieveInputDataFailReadTemplateThrowsFileNotFoundException() { () -> sut.retrieveInputData(new byte[2], Collections.singletonMap(CONTENT_TYPE_HEADER, CONTENT_TYPE_HEADER_VALUE), workingPath) ); - assertEquals(AppErrorCodeEnum.PDFE_703, e.getErrorCode()); + Assertions.assertEquals(AppErrorCodeEnum.PDFE_703, e.getErrorCode()); } @Test @@ -188,7 +189,7 @@ void retrieveInputDataFailReadTemplateThrowsIOException() { () -> sut.retrieveInputData(new byte[2], Collections.singletonMap(CONTENT_TYPE_HEADER, CONTENT_TYPE_HEADER_VALUE), workingPath) ); - assertEquals(AppErrorCodeEnum.PDFE_704, e.getErrorCode()); + Assertions.assertEquals(AppErrorCodeEnum.PDFE_704, e.getErrorCode()); } @Test @@ -206,7 +207,7 @@ void retrieveInputDataFailReadInputDataThrowsIOException() { () -> sut.retrieveInputData(new byte[2], Collections.singletonMap(CONTENT_TYPE_HEADER, CONTENT_TYPE_HEADER_VALUE), workingPath) ); - assertEquals(AppErrorCodeEnum.PDFE_706, e.getErrorCode()); + Assertions.assertEquals(AppErrorCodeEnum.PDFE_706, e.getErrorCode()); } @Test @@ -224,7 +225,7 @@ void retrieveInputDataFailMapInputDataThrowsJsonProcessingException() { () -> sut.retrieveInputData(new byte[2], Collections.singletonMap(CONTENT_TYPE_HEADER, CONTENT_TYPE_HEADER_VALUE), workingPath) ); - assertEquals(AppErrorCodeEnum.PDFE_707, e.getErrorCode()); + Assertions.assertEquals(AppErrorCodeEnum.PDFE_707, e.getErrorCode()); } @Test @@ -242,7 +243,7 @@ void retrieveInputDataFailReadApplySignatureThrowsIOException() { () -> sut.retrieveInputData(new byte[2], Collections.singletonMap(CONTENT_TYPE_HEADER, CONTENT_TYPE_HEADER_VALUE), workingPath) ); - assertEquals(AppErrorCodeEnum.PDFE_708, e.getErrorCode()); + Assertions.assertEquals(AppErrorCodeEnum.PDFE_708, e.getErrorCode()); } @Test @@ -259,7 +260,7 @@ void retrieveInputDataFailInvalidFieldThrowsUnexpectedRequestBodyFieldException( () -> sut.retrieveInputData(new byte[2], Collections.singletonMap(CONTENT_TYPE_HEADER, CONTENT_TYPE_HEADER_VALUE), workingPath) ); - assertEquals(AppErrorCodeEnum.PDFE_896, e.getErrorCode()); + Assertions.assertEquals(AppErrorCodeEnum.PDFE_896, e.getErrorCode()); } @Test @@ -277,7 +278,7 @@ void retrieveInputDataFailReadBoundaryThrowsFileUploadIOException() { () -> sut.retrieveInputData(new byte[2], Collections.singletonMap(CONTENT_TYPE_HEADER, CONTENT_TYPE_HEADER_VALUE), workingPath) ); - assertEquals(AppErrorCodeEnum.PDFE_709, e.getErrorCode()); + Assertions.assertEquals(AppErrorCodeEnum.PDFE_709, e.getErrorCode()); } @Test @@ -295,6 +296,6 @@ void retrieveInputDataFailReadBoundaryThrowsMalformedStreamException() { () -> sut.retrieveInputData(new byte[2], Collections.singletonMap(CONTENT_TYPE_HEADER, CONTENT_TYPE_HEADER_VALUE), workingPath) ); - assertEquals(AppErrorCodeEnum.PDFE_710, e.getErrorCode()); + Assertions.assertEquals(AppErrorCodeEnum.PDFE_710, e.getErrorCode()); } } \ No newline at end of file diff --git a/src/test/java/it/gov/pagopa/project/util/HttpResponseMessageMock.java b/src/test/java/it/gov/pagopa/pdf/engine/util/HttpResponseMessageMock.java similarity index 98% rename from src/test/java/it/gov/pagopa/project/util/HttpResponseMessageMock.java rename to src/test/java/it/gov/pagopa/pdf/engine/util/HttpResponseMessageMock.java index 33800c7d..8c938bcb 100644 --- a/src/test/java/it/gov/pagopa/project/util/HttpResponseMessageMock.java +++ b/src/test/java/it/gov/pagopa/pdf/engine/util/HttpResponseMessageMock.java @@ -13,7 +13,7 @@ If not, see https://www.gnu.org/licenses/. */ -package it.gov.pagopa.project.util; +package it.gov.pagopa.pdf.engine.util; import com.microsoft.azure.functions.*;