From c4ea40f1d8269eb586212a832ab126be6ba3c909 Mon Sep 17 00:00:00 2001 From: Joaquin Arturo Aragon Yauris Date: Thu, 29 Jan 2026 00:15:08 -0500 Subject: [PATCH 1/2] feat: init solution & mock antifraud --- antifraud/.gitattributes | 2 + antifraud/.gitignore | 33 ++ .../.mvn/wrapper/maven-wrapper.properties | 3 + antifraud/Dockerfile | 24 ++ antifraud/mvnw | 295 ++++++++++++++++++ antifraud/mvnw.cmd | 189 +++++++++++ antifraud/pom.xml | 73 +++++ .../antifraud/AntifraudApplication.java | 13 + .../antifraud/model/AntifraudResponse.java | 31 ++ .../antifraud/model/TransactionCode.java | 12 + .../antifraud/model/TransactionEvent.java | 20 ++ .../antifraud/model/TransactionStatus.java | 12 + .../antifraud/service/AntiFraudService.java | 57 ++++ .../com/jaragon/antifraud/util/Logger.java | 9 + antifraud/src/main/resources/application.yml | 22 ++ docker-compose.yml | 17 +- solution/.gitattributes | 2 + solution/.gitignore | 33 ++ .../.mvn/wrapper/maven-wrapper.properties | 3 + solution/mvnw | 295 ++++++++++++++++++ solution/mvnw.cmd | 189 +++++++++++ solution/pom.xml | 77 +++++ .../jaragon/solution/SolutionApplication.java | 13 + .../src/main/resources/application.properties | 1 + .../solution/SolutionApplicationTests.java | 13 + 25 files changed, 1436 insertions(+), 2 deletions(-) create mode 100644 antifraud/.gitattributes create mode 100644 antifraud/.gitignore create mode 100644 antifraud/.mvn/wrapper/maven-wrapper.properties create mode 100644 antifraud/Dockerfile create mode 100644 antifraud/mvnw create mode 100644 antifraud/mvnw.cmd create mode 100644 antifraud/pom.xml create mode 100644 antifraud/src/main/java/com/jaragon/antifraud/AntifraudApplication.java create mode 100644 antifraud/src/main/java/com/jaragon/antifraud/model/AntifraudResponse.java create mode 100644 antifraud/src/main/java/com/jaragon/antifraud/model/TransactionCode.java create mode 100644 antifraud/src/main/java/com/jaragon/antifraud/model/TransactionEvent.java create mode 100644 antifraud/src/main/java/com/jaragon/antifraud/model/TransactionStatus.java create mode 100644 antifraud/src/main/java/com/jaragon/antifraud/service/AntiFraudService.java create mode 100644 antifraud/src/main/java/com/jaragon/antifraud/util/Logger.java create mode 100644 antifraud/src/main/resources/application.yml create mode 100644 solution/.gitattributes create mode 100644 solution/.gitignore create mode 100644 solution/.mvn/wrapper/maven-wrapper.properties create mode 100644 solution/mvnw create mode 100644 solution/mvnw.cmd create mode 100644 solution/pom.xml create mode 100644 solution/src/main/java/com/jaragon/solution/SolutionApplication.java create mode 100644 solution/src/main/resources/application.properties create mode 100644 solution/src/test/java/com/jaragon/solution/SolutionApplicationTests.java diff --git a/antifraud/.gitattributes b/antifraud/.gitattributes new file mode 100644 index 0000000000..3b41682ac5 --- /dev/null +++ b/antifraud/.gitattributes @@ -0,0 +1,2 @@ +/mvnw text eol=lf +*.cmd text eol=crlf diff --git a/antifraud/.gitignore b/antifraud/.gitignore new file mode 100644 index 0000000000..667aaef0c8 --- /dev/null +++ b/antifraud/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/antifraud/.mvn/wrapper/maven-wrapper.properties b/antifraud/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000000..8dea6c227c --- /dev/null +++ b/antifraud/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,3 @@ +wrapperVersion=3.3.4 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.12/apache-maven-3.9.12-bin.zip diff --git a/antifraud/Dockerfile b/antifraud/Dockerfile new file mode 100644 index 0000000000..f7a81bf23c --- /dev/null +++ b/antifraud/Dockerfile @@ -0,0 +1,24 @@ +FROM maven:3.9.6-eclipse-temurin-21 AS build +WORKDIR /app + +# Copiamos el pom.xml y descargamos las dependencias (cache optimization) +COPY pom.xml . +RUN mvn dependency:go-offline + +# Copiamos el código fuente y generamos el archivo JAR +COPY src ./src +RUN mvn clean package -DskipTests + +# Etapa 2: Run (Ejecución) +# Usamos una imagen ligera de JRE 21 para correr la app +FROM eclipse-temurin:21-jre-jammy +WORKDIR /app + +# Copiamos el JAR generado en la etapa anterior +COPY --from=build /app/target/*.jar app.jar + +# Exponemos el puerto del microservicio +EXPOSE 8081 + +# Ejecutamos la aplicación +ENTRYPOINT ["java", "-jar", "app.jar"] \ No newline at end of file diff --git a/antifraud/mvnw b/antifraud/mvnw new file mode 100644 index 0000000000..bd8896bf22 --- /dev/null +++ b/antifraud/mvnw @@ -0,0 +1,295 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Apache Maven Wrapper startup batch script, version 3.3.4 +# +# Optional ENV vars +# ----------------- +# JAVA_HOME - location of a JDK home dir, required when download maven via java source +# MVNW_REPOURL - repo url base for downloading maven distribution +# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output +# ---------------------------------------------------------------------------- + +set -euf +[ "${MVNW_VERBOSE-}" != debug ] || set -x + +# OS specific support. +native_path() { printf %s\\n "$1"; } +case "$(uname)" in +CYGWIN* | MINGW*) + [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")" + native_path() { cygpath --path --windows "$1"; } + ;; +esac + +# set JAVACMD and JAVACCMD +set_java_home() { + # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched + if [ -n "${JAVA_HOME-}" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACCMD="$JAVA_HOME/jre/sh/javac" + else + JAVACMD="$JAVA_HOME/bin/java" + JAVACCMD="$JAVA_HOME/bin/javac" + + if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then + echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2 + echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2 + return 1 + fi + fi + else + JAVACMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v java + )" || : + JAVACCMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v javac + )" || : + + if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then + echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2 + return 1 + fi + fi +} + +# hash string like Java String::hashCode +hash_string() { + str="${1:-}" h=0 + while [ -n "$str" ]; do + char="${str%"${str#?}"}" + h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296)) + str="${str#?}" + done + printf %x\\n $h +} + +verbose() { :; } +[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; } + +die() { + printf %s\\n "$1" >&2 + exit 1 +} + +trim() { + # MWRAPPER-139: + # Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds. + # Needed for removing poorly interpreted newline sequences when running in more + # exotic environments such as mingw bash on Windows. + printf "%s" "${1}" | tr -d '[:space:]' +} + +scriptDir="$(dirname "$0")" +scriptName="$(basename "$0")" + +# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties +while IFS="=" read -r key value; do + case "${key-}" in + distributionUrl) distributionUrl=$(trim "${value-}") ;; + distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;; + esac +done <"$scriptDir/.mvn/wrapper/maven-wrapper.properties" +[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" + +case "${distributionUrl##*/}" in +maven-mvnd-*bin.*) + MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ + case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in + *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;; + :Darwin*x86_64) distributionPlatform=darwin-amd64 ;; + :Darwin*arm64) distributionPlatform=darwin-aarch64 ;; + :Linux*x86_64*) distributionPlatform=linux-amd64 ;; + *) + echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2 + distributionPlatform=linux-amd64 + ;; + esac + distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip" + ;; +maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;; +*) MVN_CMD="mvn${scriptName#mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; +esac + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}" +distributionUrlName="${distributionUrl##*/}" +distributionUrlNameMain="${distributionUrlName%.*}" +distributionUrlNameMain="${distributionUrlNameMain%-bin}" +MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}" +MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" + +exec_maven() { + unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || : + exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD" +} + +if [ -d "$MAVEN_HOME" ]; then + verbose "found existing MAVEN_HOME at $MAVEN_HOME" + exec_maven "$@" +fi + +case "${distributionUrl-}" in +*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;; +*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; +esac + +# prepare tmp dir +if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then + clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; } + trap clean HUP INT TERM EXIT +else + die "cannot create temp dir" +fi + +mkdir -p -- "${MAVEN_HOME%/*}" + +# Download and Install Apache Maven +verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +verbose "Downloading from: $distributionUrl" +verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +# select .zip or .tar.gz +if ! command -v unzip >/dev/null; then + distributionUrl="${distributionUrl%.zip}.tar.gz" + distributionUrlName="${distributionUrl##*/}" +fi + +# verbose opt +__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR='' +[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v + +# normalize http auth +case "${MVNW_PASSWORD:+has-password}" in +'') MVNW_USERNAME='' MVNW_PASSWORD='' ;; +has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;; +esac + +if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then + verbose "Found wget ... using wget" + wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl" +elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then + verbose "Found curl ... using curl" + curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl" +elif set_java_home; then + verbose "Falling back to use Java to download" + javaSource="$TMP_DOWNLOAD_DIR/Downloader.java" + targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName" + cat >"$javaSource" <<-END + public class Downloader extends java.net.Authenticator + { + protected java.net.PasswordAuthentication getPasswordAuthentication() + { + return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() ); + } + public static void main( String[] args ) throws Exception + { + setDefault( new Downloader() ); + java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); + } + } + END + # For Cygwin/MinGW, switch paths to Windows format before running javac and java + verbose " - Compiling Downloader.java ..." + "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java" + verbose " - Running Downloader.java ..." + "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")" +fi + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +if [ -n "${distributionSha256Sum-}" ]; then + distributionSha256Result=false + if [ "$MVN_CMD" = mvnd.sh ]; then + echo "Checksum validation is not supported for maven-mvnd." >&2 + echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + elif command -v sha256sum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c - >/dev/null 2>&1; then + distributionSha256Result=true + fi + elif command -v shasum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then + distributionSha256Result=true + fi + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 + echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + fi + if [ $distributionSha256Result = false ]; then + echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2 + echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2 + exit 1 + fi +fi + +# unzip and move +if command -v unzip >/dev/null; then + unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip" +else + tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" +fi + +# Find the actual extracted directory name (handles snapshots where filename != directory name) +actualDistributionDir="" + +# First try the expected directory name (for regular distributions) +if [ -d "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" ]; then + if [ -f "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/bin/$MVN_CMD" ]; then + actualDistributionDir="$distributionUrlNameMain" + fi +fi + +# If not found, search for any directory with the Maven executable (for snapshots) +if [ -z "$actualDistributionDir" ]; then + # enable globbing to iterate over items + set +f + for dir in "$TMP_DOWNLOAD_DIR"/*; do + if [ -d "$dir" ]; then + if [ -f "$dir/bin/$MVN_CMD" ]; then + actualDistributionDir="$(basename "$dir")" + break + fi + fi + done + set -f +fi + +if [ -z "$actualDistributionDir" ]; then + verbose "Contents of $TMP_DOWNLOAD_DIR:" + verbose "$(ls -la "$TMP_DOWNLOAD_DIR")" + die "Could not find Maven distribution directory in extracted archive" +fi + +verbose "Found extracted Maven distribution directory: $actualDistributionDir" +printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$actualDistributionDir/mvnw.url" +mv -- "$TMP_DOWNLOAD_DIR/$actualDistributionDir" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME" + +clean || : +exec_maven "$@" diff --git a/antifraud/mvnw.cmd b/antifraud/mvnw.cmd new file mode 100644 index 0000000000..92450f9327 --- /dev/null +++ b/antifraud/mvnw.cmd @@ -0,0 +1,189 @@ +<# : batch portion +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Apache Maven Wrapper startup batch script, version 3.3.4 +@REM +@REM Optional ENV vars +@REM MVNW_REPOURL - repo url base for downloading maven distribution +@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output +@REM ---------------------------------------------------------------------------- + +@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) +@SET __MVNW_CMD__= +@SET __MVNW_ERROR__= +@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% +@SET PSModulePath= +@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( + IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) +) +@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% +@SET __MVNW_PSMODULEP_SAVE= +@SET __MVNW_ARG0_NAME__= +@SET MVNW_USERNAME= +@SET MVNW_PASSWORD= +@IF NOT "%__MVNW_CMD__%"=="" ("%__MVNW_CMD__%" %*) +@echo Cannot start maven from wrapper >&2 && exit /b 1 +@GOTO :EOF +: end batch / begin powershell #> + +$ErrorActionPreference = "Stop" +if ($env:MVNW_VERBOSE -eq "true") { + $VerbosePreference = "Continue" +} + +# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties +$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl +if (!$distributionUrl) { + Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" +} + +switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { + "maven-mvnd-*" { + $USE_MVND = $true + $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" + $MVN_CMD = "mvnd.cmd" + break + } + default { + $USE_MVND = $false + $MVN_CMD = $script -replace '^mvnw','mvn' + break + } +} + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +if ($env:MVNW_REPOURL) { + $MVNW_REPO_PATTERN = if ($USE_MVND -eq $False) { "/org/apache/maven/" } else { "/maven/mvnd/" } + $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace "^.*$MVNW_REPO_PATTERN",'')" +} +$distributionUrlName = $distributionUrl -replace '^.*/','' +$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' + +$MAVEN_M2_PATH = "$HOME/.m2" +if ($env:MAVEN_USER_HOME) { + $MAVEN_M2_PATH = "$env:MAVEN_USER_HOME" +} + +if (-not (Test-Path -Path $MAVEN_M2_PATH)) { + New-Item -Path $MAVEN_M2_PATH -ItemType Directory | Out-Null +} + +$MAVEN_WRAPPER_DISTS = $null +if ((Get-Item $MAVEN_M2_PATH).Target[0] -eq $null) { + $MAVEN_WRAPPER_DISTS = "$MAVEN_M2_PATH/wrapper/dists" +} else { + $MAVEN_WRAPPER_DISTS = (Get-Item $MAVEN_M2_PATH).Target[0] + "/wrapper/dists" +} + +$MAVEN_HOME_PARENT = "$MAVEN_WRAPPER_DISTS/$distributionUrlNameMain" +$MAVEN_HOME_NAME = ([System.Security.Cryptography.SHA256]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' +$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" + +if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { + Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" + Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" + exit $? +} + +if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { + Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" +} + +# prepare tmp dir +$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile +$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" +$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null +trap { + if ($TMP_DOWNLOAD_DIR.Exists) { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } + } +} + +New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null + +# Download and Install Apache Maven +Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +Write-Verbose "Downloading from: $distributionUrl" +Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +$webclient = New-Object System.Net.WebClient +if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { + $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) +} +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum +if ($distributionSha256Sum) { + if ($USE_MVND) { + Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." + } + Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash + if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { + Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." + } +} + +# unzip and move +Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null + +# Find the actual extracted directory name (handles snapshots where filename != directory name) +$actualDistributionDir = "" + +# First try the expected directory name (for regular distributions) +$expectedPath = Join-Path "$TMP_DOWNLOAD_DIR" "$distributionUrlNameMain" +$expectedMvnPath = Join-Path "$expectedPath" "bin/$MVN_CMD" +if ((Test-Path -Path $expectedPath -PathType Container) -and (Test-Path -Path $expectedMvnPath -PathType Leaf)) { + $actualDistributionDir = $distributionUrlNameMain +} + +# If not found, search for any directory with the Maven executable (for snapshots) +if (!$actualDistributionDir) { + Get-ChildItem -Path "$TMP_DOWNLOAD_DIR" -Directory | ForEach-Object { + $testPath = Join-Path $_.FullName "bin/$MVN_CMD" + if (Test-Path -Path $testPath -PathType Leaf) { + $actualDistributionDir = $_.Name + } + } +} + +if (!$actualDistributionDir) { + Write-Error "Could not find Maven distribution directory in extracted archive" +} + +Write-Verbose "Found extracted Maven distribution directory: $actualDistributionDir" +Rename-Item -Path "$TMP_DOWNLOAD_DIR/$actualDistributionDir" -NewName $MAVEN_HOME_NAME | Out-Null +try { + Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null +} catch { + if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { + Write-Error "fail to move MAVEN_HOME" + } +} finally { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } +} + +Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" diff --git a/antifraud/pom.xml b/antifraud/pom.xml new file mode 100644 index 0000000000..681ab347c4 --- /dev/null +++ b/antifraud/pom.xml @@ -0,0 +1,73 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 4.0.2 + + + com.jaragon + antifraud + 0.0.1-SNAPSHOT + antifraud + Yape Challenge, antifraud mock + + + + + + + + + + + + + + + 21 + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-json + + + + org.springframework.boot + spring-boot-starter-kafka + + + + com.fasterxml.jackson.core + jackson-core + + + + com.fasterxml.jackson.core + jackson-databind + + + + com.fasterxml.jackson.core + jackson-annotations + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/antifraud/src/main/java/com/jaragon/antifraud/AntifraudApplication.java b/antifraud/src/main/java/com/jaragon/antifraud/AntifraudApplication.java new file mode 100644 index 0000000000..bbfaa4ea1b --- /dev/null +++ b/antifraud/src/main/java/com/jaragon/antifraud/AntifraudApplication.java @@ -0,0 +1,13 @@ +package com.jaragon.antifraud; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class AntifraudApplication { + + public static void main(String[] args) { + SpringApplication.run(AntifraudApplication.class, args); + } + +} diff --git a/antifraud/src/main/java/com/jaragon/antifraud/model/AntifraudResponse.java b/antifraud/src/main/java/com/jaragon/antifraud/model/AntifraudResponse.java new file mode 100644 index 0000000000..0e9af90b3a --- /dev/null +++ b/antifraud/src/main/java/com/jaragon/antifraud/model/AntifraudResponse.java @@ -0,0 +1,31 @@ +package com.jaragon.antifraud.model; + +import java.util.UUID; + +public class AntifraudResponse { + private UUID transactionExternalId; + private String status; + private String code; + + public AntifraudResponse() {} + + public AntifraudResponse(UUID transactionExternalId, TransactionStatus status, TransactionCode code) { + this.transactionExternalId = transactionExternalId; + this.status = status.getValue(); + this.code = code.getValue(); + } + + public UUID getTransactionExternalId() { return transactionExternalId; } + public void setTransactionExternalId(UUID transactionExternalId) { this.transactionExternalId = transactionExternalId; } + public String getStatus() { return status; } + public void setStatus(String status) { this.status = status; } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + +} diff --git a/antifraud/src/main/java/com/jaragon/antifraud/model/TransactionCode.java b/antifraud/src/main/java/com/jaragon/antifraud/model/TransactionCode.java new file mode 100644 index 0000000000..49aeee2538 --- /dev/null +++ b/antifraud/src/main/java/com/jaragon/antifraud/model/TransactionCode.java @@ -0,0 +1,12 @@ +package com.jaragon.antifraud.model; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum TransactionCode { + OK("OK"), + ERROR("ERROR"); + private final String value; + TransactionCode(String value) { this.value = value; } + @JsonValue + public String getValue() { return value; } +} diff --git a/antifraud/src/main/java/com/jaragon/antifraud/model/TransactionEvent.java b/antifraud/src/main/java/com/jaragon/antifraud/model/TransactionEvent.java new file mode 100644 index 0000000000..9fea9efbe3 --- /dev/null +++ b/antifraud/src/main/java/com/jaragon/antifraud/model/TransactionEvent.java @@ -0,0 +1,20 @@ +package com.jaragon.antifraud.model; + +import java.util.UUID; + +public class TransactionEvent { + private UUID transactionExternalId; + private Double value; + + public TransactionEvent() {} + + public TransactionEvent(UUID transactionExternalId, Double value) { + this.transactionExternalId = transactionExternalId; + this.value = value; + } + + public UUID getTransactionExternalId() { return transactionExternalId; } + public void setTransactionExternalId(UUID transactionExternalId) { this.transactionExternalId = transactionExternalId; } + public Double getValue() { return value; } + public void setValue(Double value) { this.value = value; } +} diff --git a/antifraud/src/main/java/com/jaragon/antifraud/model/TransactionStatus.java b/antifraud/src/main/java/com/jaragon/antifraud/model/TransactionStatus.java new file mode 100644 index 0000000000..b28781ccc6 --- /dev/null +++ b/antifraud/src/main/java/com/jaragon/antifraud/model/TransactionStatus.java @@ -0,0 +1,12 @@ +package com.jaragon.antifraud.model; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum TransactionStatus { + APPROVED("approved"), + REJECTED("rejected"); + private final String value; + TransactionStatus(String value) { this.value = value; } + @JsonValue + public String getValue() { return value; } +} diff --git a/antifraud/src/main/java/com/jaragon/antifraud/service/AntiFraudService.java b/antifraud/src/main/java/com/jaragon/antifraud/service/AntiFraudService.java new file mode 100644 index 0000000000..6a202abe7a --- /dev/null +++ b/antifraud/src/main/java/com/jaragon/antifraud/service/AntiFraudService.java @@ -0,0 +1,57 @@ +package com.jaragon.antifraud.service; + +import com.jaragon.antifraud.model.AntifraudResponse; +import com.jaragon.antifraud.model.TransactionCode; +import com.jaragon.antifraud.model.TransactionEvent; +import com.jaragon.antifraud.model.TransactionStatus; +import com.jaragon.antifraud.util.Logger; +import java.util.UUID; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.kafka.annotation.KafkaListener; +import org.springframework.kafka.core.KafkaTemplate; +import org.springframework.stereotype.Service; + +@Service +public class AntiFraudService { + + private final KafkaTemplate kafkaTemplate; + private final Double maxApprovedValue; + + public AntiFraudService(KafkaTemplate kafkaTemplate, + @Value("${antifraud.max-approved-value}") Double maxApprovedValue) { + this.kafkaTemplate = kafkaTemplate; + this.maxApprovedValue = maxApprovedValue; + } + + @KafkaListener(topics = "transactions-to-validate", groupId = "antifraud-group") + public void consume(TransactionEvent event) { + + UUID transactionExternalId = event.getTransactionExternalId(); + Logger.info("Validando transacción: " + transactionExternalId); + AntifraudResponse response; + + try{ + TransactionStatus finalStatus = getStatus(event.getValue()); + response = createOkResponse(transactionExternalId,finalStatus); + }catch (Exception e){ + Logger.info("Hubo un problema al procesar la transaccion : " + transactionExternalId); + response = createBadResponse(transactionExternalId); + } + + kafkaTemplate.send("transactions-validated", response); + Logger.info("Resultado enviado: " + response.getStatus()); + } + + private TransactionStatus getStatus(Double value){ + return (value > maxApprovedValue) ? TransactionStatus.REJECTED : TransactionStatus.APPROVED; + } + + private AntifraudResponse createOkResponse(UUID transactionExternalId, TransactionStatus status){ + return new AntifraudResponse(transactionExternalId, status, TransactionCode.OK); + } + + private AntifraudResponse createBadResponse(UUID transactionExternalId){ + return new AntifraudResponse(transactionExternalId, TransactionStatus.REJECTED, TransactionCode.ERROR); + } + +} \ No newline at end of file diff --git a/antifraud/src/main/java/com/jaragon/antifraud/util/Logger.java b/antifraud/src/main/java/com/jaragon/antifraud/util/Logger.java new file mode 100644 index 0000000000..7c41af0b6a --- /dev/null +++ b/antifraud/src/main/java/com/jaragon/antifraud/util/Logger.java @@ -0,0 +1,9 @@ +package com.jaragon.antifraud.util; + +public class Logger { + + public static void info(String message){ + System.out.println(message); + } + +} diff --git a/antifraud/src/main/resources/application.yml b/antifraud/src/main/resources/application.yml new file mode 100644 index 0000000000..591a8fcade --- /dev/null +++ b/antifraud/src/main/resources/application.yml @@ -0,0 +1,22 @@ +server: + port: 8581 # Puerto diferente al microservicio principal + +spring: + application: + name: antifraud + kafka: + bootstrap-servers: localhost:9592 + consumer: + group-id: antifraud-group + auto-offset-reset: earliest + key-deserializer: org.apache.kafka.common.serialization.StringDeserializer + value-deserializer: org.springframework.kafka.support.serializer.JsonDeserializer + properties: + spring.json.trusted.packages: "*" + spring.json.value.default.type: com.jaragon.antifraud.model.TransactionEvent + producer: + key-serializer: org.apache.kafka.common.serialization.StringSerializer + value-serializer: org.springframework.kafka.support.serializer.JsonSerializer + +antifraud: + max-approved-value: ${ANTIFRAUD_MAX_VALUE:1000} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 0e8807f21c..ef14221ac5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,10 +16,23 @@ services: depends_on: [zookeeper] environment: KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181" - KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9092 + KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9592 KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT KAFKA_BROKER_ID: 1 KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 KAFKA_JMX_PORT: 9991 ports: - - 9092:9092 + - 9592:9592 + + antifraud: + build: + context: ./antifraud + dockerfile: Dockerfile + container_name: antifraud-ms + ports: + - "8581:8581" + environment: + - SPRING_KAFKA_BOOTSTRAP_SERVERS=kafka:29092 + - ANTIFRAUD_MAX_VALUE=1000 + depends_on: + - kafka diff --git a/solution/.gitattributes b/solution/.gitattributes new file mode 100644 index 0000000000..3b41682ac5 --- /dev/null +++ b/solution/.gitattributes @@ -0,0 +1,2 @@ +/mvnw text eol=lf +*.cmd text eol=crlf diff --git a/solution/.gitignore b/solution/.gitignore new file mode 100644 index 0000000000..667aaef0c8 --- /dev/null +++ b/solution/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/solution/.mvn/wrapper/maven-wrapper.properties b/solution/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000000..8dea6c227c --- /dev/null +++ b/solution/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,3 @@ +wrapperVersion=3.3.4 +distributionType=only-script +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.12/apache-maven-3.9.12-bin.zip diff --git a/solution/mvnw b/solution/mvnw new file mode 100644 index 0000000000..bd8896bf22 --- /dev/null +++ b/solution/mvnw @@ -0,0 +1,295 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Apache Maven Wrapper startup batch script, version 3.3.4 +# +# Optional ENV vars +# ----------------- +# JAVA_HOME - location of a JDK home dir, required when download maven via java source +# MVNW_REPOURL - repo url base for downloading maven distribution +# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output +# ---------------------------------------------------------------------------- + +set -euf +[ "${MVNW_VERBOSE-}" != debug ] || set -x + +# OS specific support. +native_path() { printf %s\\n "$1"; } +case "$(uname)" in +CYGWIN* | MINGW*) + [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")" + native_path() { cygpath --path --windows "$1"; } + ;; +esac + +# set JAVACMD and JAVACCMD +set_java_home() { + # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched + if [ -n "${JAVA_HOME-}" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACCMD="$JAVA_HOME/jre/sh/javac" + else + JAVACMD="$JAVA_HOME/bin/java" + JAVACCMD="$JAVA_HOME/bin/javac" + + if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then + echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2 + echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2 + return 1 + fi + fi + else + JAVACMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v java + )" || : + JAVACCMD="$( + 'set' +e + 'unset' -f command 2>/dev/null + 'command' -v javac + )" || : + + if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then + echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2 + return 1 + fi + fi +} + +# hash string like Java String::hashCode +hash_string() { + str="${1:-}" h=0 + while [ -n "$str" ]; do + char="${str%"${str#?}"}" + h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296)) + str="${str#?}" + done + printf %x\\n $h +} + +verbose() { :; } +[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; } + +die() { + printf %s\\n "$1" >&2 + exit 1 +} + +trim() { + # MWRAPPER-139: + # Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds. + # Needed for removing poorly interpreted newline sequences when running in more + # exotic environments such as mingw bash on Windows. + printf "%s" "${1}" | tr -d '[:space:]' +} + +scriptDir="$(dirname "$0")" +scriptName="$(basename "$0")" + +# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties +while IFS="=" read -r key value; do + case "${key-}" in + distributionUrl) distributionUrl=$(trim "${value-}") ;; + distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;; + esac +done <"$scriptDir/.mvn/wrapper/maven-wrapper.properties" +[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" + +case "${distributionUrl##*/}" in +maven-mvnd-*bin.*) + MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ + case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in + *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;; + :Darwin*x86_64) distributionPlatform=darwin-amd64 ;; + :Darwin*arm64) distributionPlatform=darwin-aarch64 ;; + :Linux*x86_64*) distributionPlatform=linux-amd64 ;; + *) + echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2 + distributionPlatform=linux-amd64 + ;; + esac + distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip" + ;; +maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;; +*) MVN_CMD="mvn${scriptName#mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; +esac + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}" +distributionUrlName="${distributionUrl##*/}" +distributionUrlNameMain="${distributionUrlName%.*}" +distributionUrlNameMain="${distributionUrlNameMain%-bin}" +MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}" +MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" + +exec_maven() { + unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || : + exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD" +} + +if [ -d "$MAVEN_HOME" ]; then + verbose "found existing MAVEN_HOME at $MAVEN_HOME" + exec_maven "$@" +fi + +case "${distributionUrl-}" in +*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;; +*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; +esac + +# prepare tmp dir +if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then + clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; } + trap clean HUP INT TERM EXIT +else + die "cannot create temp dir" +fi + +mkdir -p -- "${MAVEN_HOME%/*}" + +# Download and Install Apache Maven +verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +verbose "Downloading from: $distributionUrl" +verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +# select .zip or .tar.gz +if ! command -v unzip >/dev/null; then + distributionUrl="${distributionUrl%.zip}.tar.gz" + distributionUrlName="${distributionUrl##*/}" +fi + +# verbose opt +__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR='' +[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v + +# normalize http auth +case "${MVNW_PASSWORD:+has-password}" in +'') MVNW_USERNAME='' MVNW_PASSWORD='' ;; +has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;; +esac + +if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then + verbose "Found wget ... using wget" + wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl" +elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then + verbose "Found curl ... using curl" + curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl" +elif set_java_home; then + verbose "Falling back to use Java to download" + javaSource="$TMP_DOWNLOAD_DIR/Downloader.java" + targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName" + cat >"$javaSource" <<-END + public class Downloader extends java.net.Authenticator + { + protected java.net.PasswordAuthentication getPasswordAuthentication() + { + return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() ); + } + public static void main( String[] args ) throws Exception + { + setDefault( new Downloader() ); + java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); + } + } + END + # For Cygwin/MinGW, switch paths to Windows format before running javac and java + verbose " - Compiling Downloader.java ..." + "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java" + verbose " - Running Downloader.java ..." + "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")" +fi + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +if [ -n "${distributionSha256Sum-}" ]; then + distributionSha256Result=false + if [ "$MVN_CMD" = mvnd.sh ]; then + echo "Checksum validation is not supported for maven-mvnd." >&2 + echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + elif command -v sha256sum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c - >/dev/null 2>&1; then + distributionSha256Result=true + fi + elif command -v shasum >/dev/null; then + if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then + distributionSha256Result=true + fi + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 + echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + fi + if [ $distributionSha256Result = false ]; then + echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2 + echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2 + exit 1 + fi +fi + +# unzip and move +if command -v unzip >/dev/null; then + unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip" +else + tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" +fi + +# Find the actual extracted directory name (handles snapshots where filename != directory name) +actualDistributionDir="" + +# First try the expected directory name (for regular distributions) +if [ -d "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" ]; then + if [ -f "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/bin/$MVN_CMD" ]; then + actualDistributionDir="$distributionUrlNameMain" + fi +fi + +# If not found, search for any directory with the Maven executable (for snapshots) +if [ -z "$actualDistributionDir" ]; then + # enable globbing to iterate over items + set +f + for dir in "$TMP_DOWNLOAD_DIR"/*; do + if [ -d "$dir" ]; then + if [ -f "$dir/bin/$MVN_CMD" ]; then + actualDistributionDir="$(basename "$dir")" + break + fi + fi + done + set -f +fi + +if [ -z "$actualDistributionDir" ]; then + verbose "Contents of $TMP_DOWNLOAD_DIR:" + verbose "$(ls -la "$TMP_DOWNLOAD_DIR")" + die "Could not find Maven distribution directory in extracted archive" +fi + +verbose "Found extracted Maven distribution directory: $actualDistributionDir" +printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$actualDistributionDir/mvnw.url" +mv -- "$TMP_DOWNLOAD_DIR/$actualDistributionDir" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME" + +clean || : +exec_maven "$@" diff --git a/solution/mvnw.cmd b/solution/mvnw.cmd new file mode 100644 index 0000000000..92450f9327 --- /dev/null +++ b/solution/mvnw.cmd @@ -0,0 +1,189 @@ +<# : batch portion +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Apache Maven Wrapper startup batch script, version 3.3.4 +@REM +@REM Optional ENV vars +@REM MVNW_REPOURL - repo url base for downloading maven distribution +@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven +@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output +@REM ---------------------------------------------------------------------------- + +@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) +@SET __MVNW_CMD__= +@SET __MVNW_ERROR__= +@SET __MVNW_PSMODULEP_SAVE=%PSModulePath% +@SET PSModulePath= +@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( + IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) +) +@SET PSModulePath=%__MVNW_PSMODULEP_SAVE% +@SET __MVNW_PSMODULEP_SAVE= +@SET __MVNW_ARG0_NAME__= +@SET MVNW_USERNAME= +@SET MVNW_PASSWORD= +@IF NOT "%__MVNW_CMD__%"=="" ("%__MVNW_CMD__%" %*) +@echo Cannot start maven from wrapper >&2 && exit /b 1 +@GOTO :EOF +: end batch / begin powershell #> + +$ErrorActionPreference = "Stop" +if ($env:MVNW_VERBOSE -eq "true") { + $VerbosePreference = "Continue" +} + +# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties +$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl +if (!$distributionUrl) { + Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" +} + +switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { + "maven-mvnd-*" { + $USE_MVND = $true + $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" + $MVN_CMD = "mvnd.cmd" + break + } + default { + $USE_MVND = $false + $MVN_CMD = $script -replace '^mvnw','mvn' + break + } +} + +# apply MVNW_REPOURL and calculate MAVEN_HOME +# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ +if ($env:MVNW_REPOURL) { + $MVNW_REPO_PATTERN = if ($USE_MVND -eq $False) { "/org/apache/maven/" } else { "/maven/mvnd/" } + $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace "^.*$MVNW_REPO_PATTERN",'')" +} +$distributionUrlName = $distributionUrl -replace '^.*/','' +$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' + +$MAVEN_M2_PATH = "$HOME/.m2" +if ($env:MAVEN_USER_HOME) { + $MAVEN_M2_PATH = "$env:MAVEN_USER_HOME" +} + +if (-not (Test-Path -Path $MAVEN_M2_PATH)) { + New-Item -Path $MAVEN_M2_PATH -ItemType Directory | Out-Null +} + +$MAVEN_WRAPPER_DISTS = $null +if ((Get-Item $MAVEN_M2_PATH).Target[0] -eq $null) { + $MAVEN_WRAPPER_DISTS = "$MAVEN_M2_PATH/wrapper/dists" +} else { + $MAVEN_WRAPPER_DISTS = (Get-Item $MAVEN_M2_PATH).Target[0] + "/wrapper/dists" +} + +$MAVEN_HOME_PARENT = "$MAVEN_WRAPPER_DISTS/$distributionUrlNameMain" +$MAVEN_HOME_NAME = ([System.Security.Cryptography.SHA256]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' +$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" + +if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { + Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" + Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" + exit $? +} + +if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { + Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" +} + +# prepare tmp dir +$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile +$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" +$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null +trap { + if ($TMP_DOWNLOAD_DIR.Exists) { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } + } +} + +New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null + +# Download and Install Apache Maven +Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." +Write-Verbose "Downloading from: $distributionUrl" +Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" + +$webclient = New-Object System.Net.WebClient +if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { + $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) +} +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null + +# If specified, validate the SHA-256 sum of the Maven distribution zip file +$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum +if ($distributionSha256Sum) { + if ($USE_MVND) { + Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." + } + Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash + if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { + Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." + } +} + +# unzip and move +Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null + +# Find the actual extracted directory name (handles snapshots where filename != directory name) +$actualDistributionDir = "" + +# First try the expected directory name (for regular distributions) +$expectedPath = Join-Path "$TMP_DOWNLOAD_DIR" "$distributionUrlNameMain" +$expectedMvnPath = Join-Path "$expectedPath" "bin/$MVN_CMD" +if ((Test-Path -Path $expectedPath -PathType Container) -and (Test-Path -Path $expectedMvnPath -PathType Leaf)) { + $actualDistributionDir = $distributionUrlNameMain +} + +# If not found, search for any directory with the Maven executable (for snapshots) +if (!$actualDistributionDir) { + Get-ChildItem -Path "$TMP_DOWNLOAD_DIR" -Directory | ForEach-Object { + $testPath = Join-Path $_.FullName "bin/$MVN_CMD" + if (Test-Path -Path $testPath -PathType Leaf) { + $actualDistributionDir = $_.Name + } + } +} + +if (!$actualDistributionDir) { + Write-Error "Could not find Maven distribution directory in extracted archive" +} + +Write-Verbose "Found extracted Maven distribution directory: $actualDistributionDir" +Rename-Item -Path "$TMP_DOWNLOAD_DIR/$actualDistributionDir" -NewName $MAVEN_HOME_NAME | Out-Null +try { + Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null +} catch { + if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { + Write-Error "fail to move MAVEN_HOME" + } +} finally { + try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } + catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } +} + +Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" diff --git a/solution/pom.xml b/solution/pom.xml new file mode 100644 index 0000000000..afcdbddc86 --- /dev/null +++ b/solution/pom.xml @@ -0,0 +1,77 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 4.0.2 + + + com.jaragon + solution + 0.0.1-SNAPSHOT + solution + Yape Challenge + + + + + + + + + + + + + + + 21 + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-kafka + + + org.springframework.boot + spring-boot-starter-webmvc + + + + org.postgresql + postgresql + runtime + + + org.springframework.boot + spring-boot-starter-data-jpa-test + test + + + org.springframework.boot + spring-boot-starter-kafka-test + test + + + org.springframework.boot + spring-boot-starter-webmvc-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/solution/src/main/java/com/jaragon/solution/SolutionApplication.java b/solution/src/main/java/com/jaragon/solution/SolutionApplication.java new file mode 100644 index 0000000000..6cefa6bdef --- /dev/null +++ b/solution/src/main/java/com/jaragon/solution/SolutionApplication.java @@ -0,0 +1,13 @@ +package com.jaragon.solution; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SolutionApplication { + + public static void main(String[] args) { + SpringApplication.run(SolutionApplication.class, args); + } + +} diff --git a/solution/src/main/resources/application.properties b/solution/src/main/resources/application.properties new file mode 100644 index 0000000000..b5adbfb3f2 --- /dev/null +++ b/solution/src/main/resources/application.properties @@ -0,0 +1 @@ +spring.application.name=solution diff --git a/solution/src/test/java/com/jaragon/solution/SolutionApplicationTests.java b/solution/src/test/java/com/jaragon/solution/SolutionApplicationTests.java new file mode 100644 index 0000000000..71eb670ee2 --- /dev/null +++ b/solution/src/test/java/com/jaragon/solution/SolutionApplicationTests.java @@ -0,0 +1,13 @@ +package com.jaragon.solution; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class SolutionApplicationTests { + + @Test + void contextLoads() { + } + +} From be103c4145b2fb06b247c4e6179634ab25cfc1b8 Mon Sep 17 00:00:00 2001 From: Joaquin Arturo Aragon Yauris Date: Thu, 29 Jan 2026 17:13:30 -0500 Subject: [PATCH 2/2] feat: solution & fix in antifraud --- Curl-example.text | 9 ++ antifraud/Dockerfile | 3 - antifraud/src/main/resources/application.yml | 1 + docker-compose.yml | 16 +++ solution/Dockerfile | 24 ++++ solution/pom.xml | 18 +-- .../controller/TransactionController.java | 43 ++++++++ .../solution/model/AntifraudResponse.java | 32 ++++++ .../model/CreateTransactionRequestDTO.java | 54 +++++++++ .../solution/model/TransactionEvent.java | 20 ++++ .../model/TransactionResponseDTO.java | 65 +++++++++++ .../solution/model/TransactionStatus.java | 10 ++ .../solution/model/TransactionStatusDTO.java | 21 ++++ .../solution/model/TransactionType.java | 9 ++ .../solution/model/TransactionTypeDTO.java | 20 ++++ .../model/entity/TransactionEntity.java | 104 ++++++++++++++++++ .../model/mappers/TransactionMapper.java | 49 +++++++++ .../repository/TransactionRepository.java | 11 ++ .../solution/service/TransactionService.java | 65 +++++++++++ .../com/jaragon/solution/util/Logger.java | 8 ++ .../src/main/resources/application.properties | 1 - solution/src/main/resources/application.yml | 40 +++++++ .../solution/SolutionApplicationTests.java | 13 --- 23 files changed, 610 insertions(+), 26 deletions(-) create mode 100644 Curl-example.text create mode 100644 solution/Dockerfile create mode 100644 solution/src/main/java/com/jaragon/solution/controller/TransactionController.java create mode 100644 solution/src/main/java/com/jaragon/solution/model/AntifraudResponse.java create mode 100644 solution/src/main/java/com/jaragon/solution/model/CreateTransactionRequestDTO.java create mode 100644 solution/src/main/java/com/jaragon/solution/model/TransactionEvent.java create mode 100644 solution/src/main/java/com/jaragon/solution/model/TransactionResponseDTO.java create mode 100644 solution/src/main/java/com/jaragon/solution/model/TransactionStatus.java create mode 100644 solution/src/main/java/com/jaragon/solution/model/TransactionStatusDTO.java create mode 100644 solution/src/main/java/com/jaragon/solution/model/TransactionType.java create mode 100644 solution/src/main/java/com/jaragon/solution/model/TransactionTypeDTO.java create mode 100644 solution/src/main/java/com/jaragon/solution/model/entity/TransactionEntity.java create mode 100644 solution/src/main/java/com/jaragon/solution/model/mappers/TransactionMapper.java create mode 100644 solution/src/main/java/com/jaragon/solution/repository/TransactionRepository.java create mode 100644 solution/src/main/java/com/jaragon/solution/service/TransactionService.java create mode 100644 solution/src/main/java/com/jaragon/solution/util/Logger.java delete mode 100644 solution/src/main/resources/application.properties create mode 100644 solution/src/main/resources/application.yml delete mode 100644 solution/src/test/java/com/jaragon/solution/SolutionApplicationTests.java diff --git a/Curl-example.text b/Curl-example.text new file mode 100644 index 0000000000..fdeb62f198 --- /dev/null +++ b/Curl-example.text @@ -0,0 +1,9 @@ +curl --request POST \ + --url http://localhost:8580/transaction \ + --header 'content-type: application/json' \ + --data '{ + "accountExternalIdDebit": "c2b1e1f1-6a0d-4c61-9a47-2c4e91b8a123", + "accountExternalIdCredit": "b7a2d0c9-9b12-4d38-8e13-2d1a7b9c4567", + "tranferTypeId": 1, + "value": 1200 +}' \ No newline at end of file diff --git a/antifraud/Dockerfile b/antifraud/Dockerfile index f7a81bf23c..d809661404 100644 --- a/antifraud/Dockerfile +++ b/antifraud/Dockerfile @@ -17,8 +17,5 @@ WORKDIR /app # Copiamos el JAR generado en la etapa anterior COPY --from=build /app/target/*.jar app.jar -# Exponemos el puerto del microservicio -EXPOSE 8081 - # Ejecutamos la aplicación ENTRYPOINT ["java", "-jar", "app.jar"] \ No newline at end of file diff --git a/antifraud/src/main/resources/application.yml b/antifraud/src/main/resources/application.yml index 591a8fcade..64cce50230 100644 --- a/antifraud/src/main/resources/application.yml +++ b/antifraud/src/main/resources/application.yml @@ -14,6 +14,7 @@ spring: properties: spring.json.trusted.packages: "*" spring.json.value.default.type: com.jaragon.antifraud.model.TransactionEvent + spring.json.type.mapping: com.jaragon.solution.model.TransactionEvent:com.jaragon.antifraud.model.TransactionEvent producer: key-serializer: org.apache.kafka.common.serialization.StringSerializer value-serializer: org.springframework.kafka.support.serializer.JsonSerializer diff --git a/docker-compose.yml b/docker-compose.yml index ef14221ac5..f25eb09a36 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,6 +2,7 @@ version: "3.7" services: postgres: image: postgres:14 + container_name: database ports: - "5432:5432" environment: @@ -9,10 +10,12 @@ services: - POSTGRES_PASSWORD=postgres zookeeper: image: confluentinc/cp-zookeeper:5.5.3 + container_name: zookeeper environment: ZOOKEEPER_CLIENT_PORT: 2181 kafka: image: confluentinc/cp-enterprise-kafka:5.5.3 + container_name: kafka depends_on: [zookeeper] environment: KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181" @@ -36,3 +39,16 @@ services: - ANTIFRAUD_MAX_VALUE=1000 depends_on: - kafka + + solution: + build: + context: ./solution + dockerfile: Dockerfile + container_name: solution-ms + ports: + - "8580:8580" + environment: + - SPRING_KAFKA_BOOTSTRAP_SERVERS=kafka:29092 + depends_on: + - kafka + - postgres diff --git a/solution/Dockerfile b/solution/Dockerfile new file mode 100644 index 0000000000..1b8374f540 --- /dev/null +++ b/solution/Dockerfile @@ -0,0 +1,24 @@ +FROM maven:3.9.6-eclipse-temurin-21 AS build +WORKDIR /app + +# Copiamos el pom.xml y descargamos las dependencias (cache optimization) +COPY pom.xml . +RUN mvn dependency:go-offline + +# Copiamos el código fuente y generamos el archivo JAR +COPY src ./src +RUN mvn clean package -DskipTests + +# Etapa 2: Run (Ejecución) +# Usamos una imagen ligera de JRE 21 para correr la app +FROM eclipse-temurin:21-jre-jammy +WORKDIR /app + +# Copiamos el JAR generado en la etapa anterior +COPY --from=build /app/target/*.jar app.jar + +# Exponemos el puerto del microservicio +EXPOSE 8081 + +# Ejecutamos la aplicación +ENTRYPOINT ["java", "-jar", "app.jar"] \ No newline at end of file diff --git a/solution/pom.xml b/solution/pom.xml index afcdbddc86..68298922bf 100644 --- a/solution/pom.xml +++ b/solution/pom.xml @@ -48,20 +48,20 @@ postgresql runtime + - org.springframework.boot - spring-boot-starter-data-jpa-test - test + com.fasterxml.jackson.core + jackson-core + - org.springframework.boot - spring-boot-starter-kafka-test - test + com.fasterxml.jackson.core + jackson-databind + - org.springframework.boot - spring-boot-starter-webmvc-test - test + com.fasterxml.jackson.core + jackson-annotations diff --git a/solution/src/main/java/com/jaragon/solution/controller/TransactionController.java b/solution/src/main/java/com/jaragon/solution/controller/TransactionController.java new file mode 100644 index 0000000000..f95e355b48 --- /dev/null +++ b/solution/src/main/java/com/jaragon/solution/controller/TransactionController.java @@ -0,0 +1,43 @@ +package com.jaragon.solution.controller; + +import com.jaragon.solution.model.CreateTransactionRequestDTO; +import com.jaragon.solution.model.TransactionResponseDTO; +import com.jaragon.solution.service.TransactionService; +import java.util.UUID; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/transaction") +public class TransactionController { + + private final TransactionService transactionService; + + public TransactionController(TransactionService transactionService) { + this.transactionService = transactionService; + } + + @PostMapping() + public ResponseEntity createTransaction( + @RequestBody CreateTransactionRequestDTO request) { + + TransactionResponseDTO response = transactionService.createTransaction(request); + + return ResponseEntity.status(HttpStatus.CREATED).body(response); + } + + @GetMapping("/{transactionExternalId}") + public ResponseEntity retrieveTransaction( + @PathVariable UUID transactionExternalId) { + + TransactionResponseDTO response = transactionService.getTransaction(transactionExternalId); + + return ResponseEntity.ok(response); + } +} diff --git a/solution/src/main/java/com/jaragon/solution/model/AntifraudResponse.java b/solution/src/main/java/com/jaragon/solution/model/AntifraudResponse.java new file mode 100644 index 0000000000..15d9863a8e --- /dev/null +++ b/solution/src/main/java/com/jaragon/solution/model/AntifraudResponse.java @@ -0,0 +1,32 @@ +package com.jaragon.solution.model; + +import java.util.UUID; + +public class AntifraudResponse { + private UUID transactionExternalId; + private String status; + private String code; + + public AntifraudResponse() {} + + public AntifraudResponse(UUID transactionExternalId, String status, String code) { + this.transactionExternalId = transactionExternalId; + this.status = status; + this.code = code; + } + + public UUID getTransactionExternalId() { return transactionExternalId; } + public void setTransactionExternalId(UUID transactionExternalId) { this.transactionExternalId = transactionExternalId; } + public String getStatus() { return status; } + public void setStatus(String status) { this.status = status; } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + +} + diff --git a/solution/src/main/java/com/jaragon/solution/model/CreateTransactionRequestDTO.java b/solution/src/main/java/com/jaragon/solution/model/CreateTransactionRequestDTO.java new file mode 100644 index 0000000000..f89c5f58b4 --- /dev/null +++ b/solution/src/main/java/com/jaragon/solution/model/CreateTransactionRequestDTO.java @@ -0,0 +1,54 @@ +package com.jaragon.solution.model; + +import java.util.UUID; + +public class CreateTransactionRequestDTO { + + private UUID accountExternalIdDebit; + private UUID accountExternalIdCredit; + private Integer tranferTypeId; + private Double value; + + public CreateTransactionRequestDTO(){ + + } + + public CreateTransactionRequestDTO(UUID accountExternalIdDebit, UUID accountExternalIdCredit, Integer tranferTypeId, Double value) { + this.accountExternalIdDebit = accountExternalIdDebit; + this.accountExternalIdCredit = accountExternalIdCredit; + this.tranferTypeId = tranferTypeId; + this.value = value; + } + + public UUID getAccountExternalIdDebit() { + return accountExternalIdDebit; + } + + public void setAccountExternalIdDebit(UUID accountExternalIdDebit) { + this.accountExternalIdDebit = accountExternalIdDebit; + } + + public UUID getAccountExternalIdCredit() { + return accountExternalIdCredit; + } + + public void setAccountExternalIdCredit(UUID accountExternalIdCredit) { + this.accountExternalIdCredit = accountExternalIdCredit; + } + + public Integer getTranferTypeId() { + return tranferTypeId; + } + + public void setTranferTypeId(Integer tranferTypeId) { + this.tranferTypeId = tranferTypeId; + } + + public Double getValue() { + return value; + } + + public void setValue(Double value) { + this.value = value; + } +} diff --git a/solution/src/main/java/com/jaragon/solution/model/TransactionEvent.java b/solution/src/main/java/com/jaragon/solution/model/TransactionEvent.java new file mode 100644 index 0000000000..f59ce6f170 --- /dev/null +++ b/solution/src/main/java/com/jaragon/solution/model/TransactionEvent.java @@ -0,0 +1,20 @@ +package com.jaragon.solution.model; + +import java.util.UUID; + +public class TransactionEvent { + private UUID transactionExternalId; + private Double value; + + public TransactionEvent() {} + + public TransactionEvent(UUID transactionExternalId, Double value) { + this.transactionExternalId = transactionExternalId; + this.value = value; + } + + public UUID getTransactionExternalId() { return transactionExternalId; } + public void setTransactionExternalId(UUID transactionExternalId) { this.transactionExternalId = transactionExternalId; } + public Double getValue() { return value; } + public void setValue(Double value) { this.value = value; } +} diff --git a/solution/src/main/java/com/jaragon/solution/model/TransactionResponseDTO.java b/solution/src/main/java/com/jaragon/solution/model/TransactionResponseDTO.java new file mode 100644 index 0000000000..bf9d02c741 --- /dev/null +++ b/solution/src/main/java/com/jaragon/solution/model/TransactionResponseDTO.java @@ -0,0 +1,65 @@ +package com.jaragon.solution.model; + +import java.time.LocalDateTime; +import java.util.UUID; + +public class TransactionResponseDTO { + + private UUID transactionExternalId; + private TransactionTypeDTO transactionType; + private TransactionStatusDTO transactionStatus; + private Double value; + private LocalDateTime createdAt; + + public TransactionResponseDTO(){ + + } + + public TransactionResponseDTO(UUID transactionExternalId, TransactionTypeDTO transactionType, TransactionStatusDTO transactionStatus, Double value, LocalDateTime createdAt) { + this.transactionExternalId = transactionExternalId; + this.transactionType = transactionType; + this.transactionStatus = transactionStatus; + this.value = value; + this.createdAt = createdAt; + } + + public UUID getTransactionExternalId() { + return transactionExternalId; + } + + public void setTransactionExternalId(UUID transactionExternalId) { + this.transactionExternalId = transactionExternalId; + } + + public TransactionTypeDTO getTransactionType() { + return transactionType; + } + + public void setTransactionType(TransactionTypeDTO transactionType) { + this.transactionType = transactionType; + } + + public TransactionStatusDTO getTransactionStatus() { + return transactionStatus; + } + + public void setTransactionStatus(TransactionStatusDTO transactionStatus) { + this.transactionStatus = transactionStatus; + } + + public Double getValue() { + return value; + } + + public void setValue(Double value) { + this.value = value; + } + + public LocalDateTime getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(LocalDateTime createdAt) { + this.createdAt = createdAt; + } +} diff --git a/solution/src/main/java/com/jaragon/solution/model/TransactionStatus.java b/solution/src/main/java/com/jaragon/solution/model/TransactionStatus.java new file mode 100644 index 0000000000..ae4bb93e20 --- /dev/null +++ b/solution/src/main/java/com/jaragon/solution/model/TransactionStatus.java @@ -0,0 +1,10 @@ +package com.jaragon.solution.model; + +public enum TransactionStatus { + APPROVED("approved"), + REJECTED("rejected"), + PENDING("pending"); + private final String value; + TransactionStatus(String value) { this.value = value; } + public String getValue() { return value; } +} diff --git a/solution/src/main/java/com/jaragon/solution/model/TransactionStatusDTO.java b/solution/src/main/java/com/jaragon/solution/model/TransactionStatusDTO.java new file mode 100644 index 0000000000..8959f07ee1 --- /dev/null +++ b/solution/src/main/java/com/jaragon/solution/model/TransactionStatusDTO.java @@ -0,0 +1,21 @@ +package com.jaragon.solution.model; + +public class TransactionStatusDTO { + + private String name; + + public TransactionStatusDTO(){ + + } + public TransactionStatusDTO(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/solution/src/main/java/com/jaragon/solution/model/TransactionType.java b/solution/src/main/java/com/jaragon/solution/model/TransactionType.java new file mode 100644 index 0000000000..94b0d134c4 --- /dev/null +++ b/solution/src/main/java/com/jaragon/solution/model/TransactionType.java @@ -0,0 +1,9 @@ +package com.jaragon.solution.model; + +public enum TransactionType { + DEBIT("DEBIT"), + CREDIT("CREDIT"); + private final String value; + TransactionType(String value) { this.value = value; } + public String getValue() { return value; } +} diff --git a/solution/src/main/java/com/jaragon/solution/model/TransactionTypeDTO.java b/solution/src/main/java/com/jaragon/solution/model/TransactionTypeDTO.java new file mode 100644 index 0000000000..3997cad92e --- /dev/null +++ b/solution/src/main/java/com/jaragon/solution/model/TransactionTypeDTO.java @@ -0,0 +1,20 @@ +package com.jaragon.solution.model; + +public class TransactionTypeDTO { + private String name; + + public TransactionTypeDTO(){ + + } + public TransactionTypeDTO(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/solution/src/main/java/com/jaragon/solution/model/entity/TransactionEntity.java b/solution/src/main/java/com/jaragon/solution/model/entity/TransactionEntity.java new file mode 100644 index 0000000000..c27a3a8218 --- /dev/null +++ b/solution/src/main/java/com/jaragon/solution/model/entity/TransactionEntity.java @@ -0,0 +1,104 @@ +package com.jaragon.solution.model.entity; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import java.time.LocalDateTime; +import java.util.UUID; + +@Entity +@Table(name = "transactions") +public class TransactionEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "transaction_external_id", nullable = false, unique = true) + private UUID transactionExternalId; + + @Column(name = "account_external_id_debit", nullable = false) + private UUID accountExternalIdDebit; + + @Column(name = "account_external_id_credit", nullable = false) + private UUID accountExternalIdCredit; + + @Column(name = "transaction_type", nullable = false) + private String transactionType; + + @Column(name = "transaction_status", nullable = false) + private String transactionStatus; + + @Column(nullable = false) + private Double value; + + @Column(name = "created_at", nullable = false) + private LocalDateTime createdAt; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public UUID getTransactionExternalId() { + return transactionExternalId; + } + + public void setTransactionExternalId(UUID transactionExternalId) { + this.transactionExternalId = transactionExternalId; + } + + public String getTransactionType() { + return transactionType; + } + + public void setTransactionType(String transactionType) { + this.transactionType = transactionType; + } + + public String getTransactionStatus() { + return transactionStatus; + } + + public void setTransactionStatus(String transactionStatus) { + this.transactionStatus = transactionStatus; + } + + public Double getValue() { + return value; + } + + public void setValue(Double value) { + this.value = value; + } + + public LocalDateTime getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(LocalDateTime createdAt) { + this.createdAt = createdAt; + } + + public UUID getAccountExternalIdDebit() { + return accountExternalIdDebit; + } + + public void setAccountExternalIdDebit(UUID accountExternalIdDebit) { + this.accountExternalIdDebit = accountExternalIdDebit; + } + + public UUID getAccountExternalIdCredit() { + return accountExternalIdCredit; + } + + public void setAccountExternalIdCredit(UUID accountExternalIdCredit) { + this.accountExternalIdCredit = accountExternalIdCredit; + } +} diff --git a/solution/src/main/java/com/jaragon/solution/model/mappers/TransactionMapper.java b/solution/src/main/java/com/jaragon/solution/model/mappers/TransactionMapper.java new file mode 100644 index 0000000000..6cf28951dc --- /dev/null +++ b/solution/src/main/java/com/jaragon/solution/model/mappers/TransactionMapper.java @@ -0,0 +1,49 @@ +package com.jaragon.solution.model.mappers; + +import com.jaragon.solution.model.CreateTransactionRequestDTO; +import com.jaragon.solution.model.TransactionEvent; +import com.jaragon.solution.model.TransactionResponseDTO; +import com.jaragon.solution.model.TransactionStatus; +import com.jaragon.solution.model.TransactionStatusDTO; +import com.jaragon.solution.model.TransactionTypeDTO; +import com.jaragon.solution.model.entity.TransactionEntity; +import java.time.LocalDateTime; +import java.util.UUID; + +public class TransactionMapper { + + public static TransactionResponseDTO toDTO(TransactionEntity entity) { + TransactionResponseDTO dto = new TransactionResponseDTO(); + + dto.setTransactionExternalId(entity.getTransactionExternalId()); + dto.setValue(entity.getValue()); + dto.setCreatedAt(entity.getCreatedAt()); + + TransactionTypeDTO typeDTO = new TransactionTypeDTO(); + typeDTO.setName(entity.getTransactionType()); + dto.setTransactionType(typeDTO); + + TransactionStatusDTO statusDTO = new TransactionStatusDTO(); + statusDTO.setName(entity.getTransactionStatus()); + dto.setTransactionStatus(statusDTO); + + return dto; + } + + public static TransactionEntity toEntity(CreateTransactionRequestDTO createTransactionRequestDTO){ + TransactionEntity transactionEntity = new TransactionEntity(); + + transactionEntity.setTransactionExternalId(UUID.randomUUID()); + transactionEntity.setAccountExternalIdCredit(createTransactionRequestDTO.getAccountExternalIdCredit()); + transactionEntity.setAccountExternalIdDebit(createTransactionRequestDTO.getAccountExternalIdDebit()); + transactionEntity.setTransactionType(String.valueOf(createTransactionRequestDTO.getTranferTypeId())); + transactionEntity.setTransactionStatus(TransactionStatus.PENDING.getValue()); + transactionEntity.setValue(createTransactionRequestDTO.getValue()); + transactionEntity.setCreatedAt(LocalDateTime.now()); + return transactionEntity; + } + + public static TransactionEvent toTransactionEvent(TransactionEntity transactionEntity){ + return new TransactionEvent(transactionEntity.getTransactionExternalId(), transactionEntity.getValue()); + } +} diff --git a/solution/src/main/java/com/jaragon/solution/repository/TransactionRepository.java b/solution/src/main/java/com/jaragon/solution/repository/TransactionRepository.java new file mode 100644 index 0000000000..bc150180d0 --- /dev/null +++ b/solution/src/main/java/com/jaragon/solution/repository/TransactionRepository.java @@ -0,0 +1,11 @@ +package com.jaragon.solution.repository; + +import com.jaragon.solution.model.entity.TransactionEntity; +import java.util.Optional; +import java.util.UUID; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface TransactionRepository extends JpaRepository { + + Optional findByTransactionExternalId(UUID transactionExternalId); +} diff --git a/solution/src/main/java/com/jaragon/solution/service/TransactionService.java b/solution/src/main/java/com/jaragon/solution/service/TransactionService.java new file mode 100644 index 0000000000..195765464c --- /dev/null +++ b/solution/src/main/java/com/jaragon/solution/service/TransactionService.java @@ -0,0 +1,65 @@ +package com.jaragon.solution.service; + +import com.jaragon.solution.model.AntifraudResponse; +import com.jaragon.solution.model.CreateTransactionRequestDTO; +import com.jaragon.solution.model.TransactionResponseDTO; +import com.jaragon.solution.model.entity.TransactionEntity; +import com.jaragon.solution.model.mappers.TransactionMapper; +import com.jaragon.solution.repository.TransactionRepository; +import com.jaragon.solution.util.Logger; +import jakarta.transaction.Transactional; +import java.util.Optional; +import java.util.UUID; +import org.springframework.kafka.annotation.KafkaListener; +import org.springframework.kafka.core.KafkaTemplate; +import org.springframework.stereotype.Service; + +@Service +@Transactional +public class TransactionService { + + private final KafkaTemplate kafkaTemplate; + private final TransactionRepository transactionRepository; + + public TransactionService(KafkaTemplate kafkaTemplate, TransactionRepository transactionRepository) { + this.kafkaTemplate = kafkaTemplate; + this.transactionRepository = transactionRepository; + } + + + public TransactionResponseDTO createTransaction(CreateTransactionRequestDTO createTransactionRequestDTO){ + + Logger.info("Creating transaction"); + TransactionEntity transactionEntity = TransactionMapper.toEntity(createTransactionRequestDTO); + + transactionRepository.save(transactionEntity); + + kafkaTemplate.send("transactions-to-validate", TransactionMapper.toTransactionEvent(transactionEntity)); + + return TransactionMapper.toDTO(transactionEntity); + } + + public TransactionResponseDTO getTransaction(UUID transactionExternalId){ + + Logger.info("Retrieving transaction"); + Optional optionalTransactionEntity = transactionRepository.findByTransactionExternalId(transactionExternalId); + + if(optionalTransactionEntity.isPresent()) return TransactionMapper.toDTO(optionalTransactionEntity.get()); + // Se podria manejar una excepcion personalizada + throw new RuntimeException(); + } + + @KafkaListener(topics = "transactions-validated", groupId = "transaction-group") + public void consume(AntifraudResponse antifraudResponse) { + + Optional optionalTransactionEntity = transactionRepository.findByTransactionExternalId(antifraudResponse.getTransactionExternalId()); + + if(optionalTransactionEntity.isPresent()){ + Logger.info("Updating transaction"); + TransactionEntity transactionEntity = optionalTransactionEntity.get(); + transactionEntity.setTransactionStatus(antifraudResponse.getStatus()); + transactionRepository.save(transactionEntity); + } + } + +} diff --git a/solution/src/main/java/com/jaragon/solution/util/Logger.java b/solution/src/main/java/com/jaragon/solution/util/Logger.java new file mode 100644 index 0000000000..5dbb9a6e18 --- /dev/null +++ b/solution/src/main/java/com/jaragon/solution/util/Logger.java @@ -0,0 +1,8 @@ +package com.jaragon.solution.util; + +public class Logger { + + public static void info(String message){ + System.out.println(message); + } +} diff --git a/solution/src/main/resources/application.properties b/solution/src/main/resources/application.properties deleted file mode 100644 index b5adbfb3f2..0000000000 --- a/solution/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -spring.application.name=solution diff --git a/solution/src/main/resources/application.yml b/solution/src/main/resources/application.yml new file mode 100644 index 0000000000..c3686a8952 --- /dev/null +++ b/solution/src/main/resources/application.yml @@ -0,0 +1,40 @@ +server: + port: 8580 + +spring: + application: + name: solution + + datasource: + url: jdbc:postgresql://postgres:5432/postgres + username: postgres + password: postgres + driver-class-name: org.postgresql.Driver + + jpa: + database-platform: org.hibernate.dialect.PostgreSQLDialect + hibernate: + ddl-auto: update + show-sql: false + properties: + hibernate: + format_sql: true + + sql: + init: + mode: never + + kafka: + bootstrap-servers: localhost:9592 + consumer: + group-id: transaction-group + auto-offset-reset: earliest + key-deserializer: org.apache.kafka.common.serialization.StringDeserializer + value-deserializer: org.springframework.kafka.support.serializer.JsonDeserializer + properties: + spring.json.trusted.packages: "*" + spring.json.value.default.type: com.jaragon.solution.model.AntifraudResponse + spring.json.type.mapping: com.jaragon.antifraud.model.AntifraudResponse:com.jaragon.solution.model.AntifraudResponse + producer: + key-serializer: org.apache.kafka.common.serialization.StringSerializer + value-serializer: org.springframework.kafka.support.serializer.JsonSerializer diff --git a/solution/src/test/java/com/jaragon/solution/SolutionApplicationTests.java b/solution/src/test/java/com/jaragon/solution/SolutionApplicationTests.java deleted file mode 100644 index 71eb670ee2..0000000000 --- a/solution/src/test/java/com/jaragon/solution/SolutionApplicationTests.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.jaragon.solution; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -class SolutionApplicationTests { - - @Test - void contextLoads() { - } - -}