Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
feat: Poc requirements (#1)
Browse files Browse the repository at this point in the history
Co-authored-by: fabrizio.guerrini <[email protected]>
  • Loading branch information
fabrizioacn and fabrizio.guerrini authored May 17, 2023
1 parent ec1edb6 commit 979d6a4
Show file tree
Hide file tree
Showing 49 changed files with 3,508 additions and 61 deletions.
69 changes: 66 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>

<groupId>it.gov.pagopa.swclient.mil</groupId>
<groupId>it.pagopa.swclient.mil</groupId>
<artifactId>wallet</artifactId>
<version>1.0.1-SNAPSHOT</version>

Expand All @@ -23,11 +23,11 @@

<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
<quarkus.platform.version>2.14.3.Final</quarkus.platform.version>
<quarkus.platform.version>3.0.2.Final</quarkus.platform.version>

<skipITs>true</skipITs>

<common.version>1.0.3</common.version>
<common.version>2.0.1</common.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -63,6 +63,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-reactive</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client-reactive</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
Expand All @@ -78,6 +82,34 @@
<artifactId>quarkus-junit5-mockito</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>it.pagopa.swclient.mil</groupId>
<artifactId>common</artifactId>
<version>${common.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jacoco</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.6</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-container-image-docker</artifactId>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client-reactive-jackson</artifactId>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -192,5 +224,36 @@
<quarkus.package.type>native</quarkus.package.type>
</properties>
</profile>
<profile>
<id>coverage</id>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.8</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<goals>
<goal>report</goal>
</goals>
<configuration>
<formats>
<format>XML</format>
</formats>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
10 changes: 6 additions & 4 deletions src/main/docker/Dockerfile.jvm
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@
#
# Then, build the image with:
#
# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/__service_name__-jvm .
# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/code-with-quarkus-jvm .
#
# Then run the container using:
#
# docker run -i --rm -p 8080:8080 quarkus/__service_name__-jvm
# docker run -i --rm -p 8080:8080 quarkus/code-with-quarkus-jvm
#
# If you want to include the debug port into your docker image
# you will have to expose the debug port (default 5005) like this : EXPOSE 8080 5005
# you will have to expose the debug port (default 5005 being the default) like this : EXPOSE 8080 5005.
# Additionally you will have to set -e JAVA_DEBUG=true and -e JAVA_DEBUG_PORT=*:5005
# when running the container
#
# Then run the container using :
#
# docker run -i --rm -p 8080:8080 quarkus/__service_name__-jvm
# docker run -i --rm -p 8080:8080 quarkus/code-with-quarkus-jvm
#
# This image uses the `run-java.sh` script to run the application.
# This scripts computes the command line to execute your Java application, and
Expand Down
10 changes: 6 additions & 4 deletions src/main/docker/Dockerfile.legacy-jar
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@
#
# Then, build the image with:
#
# docker build -f src/main/docker/Dockerfile.legacy-jar -t quarkus/__service_name__-legacy-jar .
# docker build -f src/main/docker/Dockerfile.legacy-jar -t quarkus/code-with-quarkus-legacy-jar .
#
# Then run the container using:
#
# docker run -i --rm -p 8080:8080 quarkus/__service_name__-legacy-jar
# docker run -i --rm -p 8080:8080 quarkus/code-with-quarkus-legacy-jar
#
# If you want to include the debug port into your docker image
# you will have to expose the debug port (default 5005) like this : EXPOSE 8080 5005
# you will have to expose the debug port (default 5005 being the default) like this : EXPOSE 8080 5005.
# Additionally you will have to set -e JAVA_DEBUG=true and -e JAVA_DEBUG_PORT=*:5005
# when running the container
#
# Then run the container using :
#
# docker run -i --rm -p 8080:8080 quarkus/__service_name__-legacy-jar
# docker run -i --rm -p 8080:8080 quarkus/code-with-quarkus-legacy-jar
#
# This image uses the `run-java.sh` script to run the application.
# This scripts computes the command line to execute your Java application, and
Expand Down
4 changes: 2 additions & 2 deletions src/main/docker/Dockerfile.native
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
#
# Then, build the image with:
#
# docker build -f src/main/docker/Dockerfile.native -t quarkus/__service_name__ .
# docker build -f src/main/docker/Dockerfile.native -t quarkus/code-with-quarkus .
#
# Then run the container using:
#
# docker run -i --rm -p 8080:8080 quarkus/__service_name__
# docker run -i --rm -p 8080:8080 quarkus/code-with-quarkus
#
###
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.6
Expand Down
4 changes: 2 additions & 2 deletions src/main/docker/Dockerfile.native-micro
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
#
# Then, build the image with:
#
# docker build -f src/main/docker/Dockerfile.native-micro -t quarkus/__service_name__ .
# docker build -f src/main/docker/Dockerfile.native-micro -t quarkus/code-with-quarkus .
#
# Then run the container using:
#
# docker run -i --rm -p 8080:8080 quarkus/__service_name__
# docker run -i --rm -p 8080:8080 quarkus/code-with-quarkus
#
###
FROM quay.io/quarkus/quarkus-micro-image:2.0
Expand Down
18 changes: 0 additions & 18 deletions src/main/java/it/gov/pagopa/swclient/mil/wallet/ErrorCode.java

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

29 changes: 29 additions & 0 deletions src/main/java/it/pagopa/swclient/mil/wallet/ErrorCode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* ErrorCode.java
*
* 12 dec 2022
*/

package it.pagopa.swclient.mil.wallet;

/**
*
* @author Antonio Tarricone
*/
public final class ErrorCode {
public static final String MODULE_ID = "003";
public static final String PAN_TOKEN_MUST_NOT_BE_NULL = MODULE_ID + "000001";
public static final String PAN_TOKEN_MUST_MATCH_REGEXP = MODULE_ID + "000002";
public static final String SESSION_ID_MUST_NOT_BE_NULL = MODULE_ID + "000003";
public static final String SESSION_ID_MUST_MATCH_REGEXP = MODULE_ID + "000004";
public static final String SESSION_NOT_FOUND_ERROR = MODULE_ID + "000005";
public static final String ERROR_CALLING_SESSION_SERVICE = MODULE_ID + "000006";
public static final String ERROR_CALLING_PM_WALLET_SERVICE = MODULE_ID + "000007";
public static final String TC_NOT_YET_ACCEPTED_ERROR = MODULE_ID + "000008";
public static final String SAVE_CARD_NOT_ACTIVE_ERROR = MODULE_ID + "000009";
public static final String GENERIC_ERROR_CALLING_PM_WALLET_SERVICE = MODULE_ID + "00000A";


private ErrorCode() {
}
}
7 changes: 7 additions & 0 deletions src/main/java/it/pagopa/swclient/mil/wallet/bean/Outcome.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package it.pagopa.swclient.mil.wallet.bean;

public enum Outcome {
OK,
TERMS_AND_CONDITIONS_NOT_YET_ACCEPTED,
PAIR_WITH_IO
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package it.pagopa.swclient.mil.wallet.bean;

import it.pagopa.swclient.mil.bean.CommonHeader;
import it.pagopa.swclient.mil.wallet.ErrorCode;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jakarta.ws.rs.HeaderParam;

public class WalletHeaderParams extends CommonHeader{

/*
* Session ID
*/
@HeaderParam("id")
@NotNull(message = "[" + ErrorCode.SESSION_ID_MUST_NOT_BE_NULL + "] id must not be null")
@Pattern(regexp = "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", message = "[" + ErrorCode.SESSION_ID_MUST_MATCH_REGEXP + "] id must match \"{regexp}\"")
private String sessionId;

/**
* @return the sessionId
*/
public String getSessionId() {
return sessionId;
}

/**
* @param sessionId the sessionId to set
*/
public void setSessionId(String sessionId) {
this.sessionId = sessionId;
}

@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("WalletHeaderParams [sessionId=");
builder.append(sessionId);
builder.append("]");
return builder.toString();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package it.pagopa.swclient.mil.wallet.bean;

import it.pagopa.swclient.mil.wallet.ErrorCode;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;


public class WalletRequest {

/*
* The token of the PAN
*/
@NotNull(message = "[" + ErrorCode.PAN_TOKEN_MUST_NOT_BE_NULL + "] panToken must not be null")
@Pattern(regexp = "^[a-zA-Z0-9]{1,32}$", message = "[" + ErrorCode.PAN_TOKEN_MUST_MATCH_REGEXP + "] panToken must match \"{regexp}\"")
private String panToken;

/**
* @return the panToken
*/
public String getPanToken() {
return panToken;
}

/**
* @param panToken the panToken to set
*/
public void setPanToken(String panToken) {
this.panToken = panToken;
}

@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("WalletRequest [panToken=");
builder.append(panToken);
builder.append("]");
return builder.toString();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package it.pagopa.swclient.mil.wallet.client;

import org.eclipse.microprofile.rest.client.annotation.ClientHeaderParam;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;

import io.smallrye.mutiny.Uni;
import it.pagopa.swclient.mil.wallet.client.bean.PmWalletCardsRequest;
import jakarta.ws.rs.HeaderParam;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.core.Response;

/**
* Reactive rest client for the REST APIs exposed by the PM-Wallet service
*/
@RegisterRestClient(configKey = "pmwallet-api")
public interface PmWalletService {

/**
* Pre-save a payment card in the Wallet
* @param version of the API
* @param body containing the token of the PAN and the Tax code of the payment card owner
* @return the 204 Ack status
*/
@POST
@Path("/cards")
@ClientHeaderParam(name = "Ocp-Apim-Subscription-Key", value = "${ocp.apim.subscription}", required = false)
Uni<Response> cards(@HeaderParam("Version") String version, PmWalletCardsRequest body);

}
Loading

0 comments on commit 979d6a4

Please sign in to comment.