diff --git a/.gitignore b/.gitignore index 2eef251..5a03bc3 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ Thumbs.db build/ target/ out/ +.micronaut/ .idea *.iml *.ipr @@ -11,3 +12,4 @@ out/ .project .settings .classpath +.factorypath diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar index 08ebbb6..bf82ff0 100644 Binary files a/.mvn/wrapper/maven-wrapper.jar and b/.mvn/wrapper/maven-wrapper.jar differ diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 42fa4da..b252b8d 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -1 +1,18 @@ -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.3/apache-maven-3.5.3-bin.zip \ No newline at end of file +# 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 +# +# https://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. +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar diff --git a/Dockerfile b/Dockerfile index f51698f..51b7fca 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,6 @@ COPY . . RUN mvn --batch-mode package FROM openjdk:17-alpine -COPY --from=build target/dev.amatos.restcountries-*.jar dev.amatos.restcountries.jar +COPY --from=build target/com.restcountries-*.jar com.restcountries.jar EXPOSE 8080 -CMD ["java", "-Dcom.sun.management.jmxremote", "-Xmx128m", "-jar", "dev.amatos.restcountries.jar"] \ No newline at end of file +CMD ["java", "-Dcom.sun.management.jmxremote", "-Xmx128m", "-jar", "com.restcountries.jar"] \ No newline at end of file diff --git a/aot-jar.properties b/aot-jar.properties new file mode 100644 index 0000000..3820d55 --- /dev/null +++ b/aot-jar.properties @@ -0,0 +1,37 @@ +# AOT configuration properties for jar packaging +# Please review carefully the optimizations enabled below +# Check https://micronaut-projects.github.io/micronaut-aot/latest/guide/ for more details + +# Caches environment property values: environment properties will be deemed immutable after application startup. +cached.environment.enabled=true + +# Precomputes Micronaut configuration property keys from the current environment variables +precompute.environment.properties.enabled=true + +# Replaces logback.xml with a pure Java configuration +logback.xml.to.java.enabled=true + +# Converts YAML configuration files to Java configuration +yaml.to.java.config.enabled=true + +# Scans for service types ahead-of-time, avoiding classpath scanning at startup +serviceloading.jit.enabled=true + +# Scans reactive types at build time instead of runtime +scan.reactive.types.enabled=true + +# Deduces the environment at build time instead of runtime +deduce.environment.enabled=true + +# Checks for the existence of some types at build time instead of runtime +known.missing.types.enabled=true + +# Precomputes property sources at build time +sealed.property.source.enabled=true + +# The list of service types to be scanned (comma separated) +service.types=io.micronaut.context.env.PropertySourceLoader,io.micronaut.inject.BeanConfiguration,io.micronaut.inject.BeanDefinitionReference,io.micronaut.http.HttpRequestFactory,io.micronaut.http.HttpResponseFactory,io.micronaut.core.beans.BeanIntrospectionReference,io.micronaut.core.convert.TypeConverterRegistrar,io.micronaut.context.env.PropertyExpressionResolver + +# A list of types that the AOT analyzer needs to check for existence (comma separated) +known.missing.types.list=io.reactivex.Observable,reactor.core.publisher.Flux,kotlinx.coroutines.flow.Flow,io.reactivex.rxjava3.core.Flowable,io.reactivex.rxjava3.core.Observable,io.reactivex.Single,reactor.core.publisher.Mono,io.reactivex.Maybe,io.reactivex.rxjava3.core.Single,io.reactivex.rxjava3.core.Maybe,io.reactivex.Completable,io.reactivex.rxjava3.core.Completable,io.methvin.watchservice.MacOSXListeningWatchService,io.micronaut.core.async.publisher.CompletableFuturePublisher,io.micronaut.core.async.publisher.Publishers.JustPublisher,io.micronaut.core.async.subscriber.Completable + diff --git a/micronaut-cli.yml b/micronaut-cli.yml index d452560..882a2f3 100644 --- a/micronaut-cli.yml +++ b/micronaut-cli.yml @@ -1,6 +1,6 @@ applicationType: default -defaultPackage: dev.amatos.restcountries +defaultPackage: com.restcountries testFramework: junit sourceLanguage: java buildTool: maven -features: [app-name, docker, file-watch, http-client, java, java-application, junit, logback, maven, netty-server, readme, shade, yaml] +features: [app-name, http-client, java, java-application, junit, logback, maven, maven-enforcer-plugin, micronaut-aot, micronaut-http-validation, netty-server, properties, readme, serialization-jackson, shade, static-resources, validation] diff --git a/mvnw b/mvnw index 961a825..8822887 100755 --- a/mvnw +++ b/mvnw @@ -8,7 +8,7 @@ # "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 +# https://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 @@ -19,7 +19,7 @@ # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# Maven2 Start Up Batch script +# Apache Maven Wrapper startup batch script, version 3.1.1 # # Required ENV vars: # ------------------ @@ -27,7 +27,6 @@ # # Optional ENV vars # ----------------- -# M2_HOME - location of maven2's installed home dir # MAVEN_OPTS - parameters passed to the Java VM when running Maven # e.g. to debug Maven itself, use # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 @@ -36,6 +35,10 @@ if [ -z "$MAVEN_SKIP_RC" ] ; then + if [ -f /usr/local/etc/mavenrc ] ; then + . /usr/local/etc/mavenrc + fi + if [ -f /etc/mavenrc ] ; then . /etc/mavenrc fi @@ -58,9 +61,9 @@ case "`uname`" in # See https://developer.apple.com/library/mac/qa/qa1170/_index.html if [ -z "$JAVA_HOME" ]; then if [ -x "/usr/libexec/java_home" ]; then - export JAVA_HOME="`/usr/libexec/java_home`" + JAVA_HOME="`/usr/libexec/java_home`"; export JAVA_HOME else - export JAVA_HOME="/Library/Java/Home" + JAVA_HOME="/Library/Java/Home"; export JAVA_HOME fi fi ;; @@ -72,36 +75,8 @@ if [ -z "$JAVA_HOME" ] ; then fi fi -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" - - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi - done - - saveddir=`pwd` - - M2_HOME=`dirname "$PRG"`/.. - - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` - - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi - # For Cygwin, ensure paths are in UNIX format before anything is touched if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` [ -n "$CLASSPATH" ] && @@ -110,11 +85,8 @@ fi # For Mingw, ensure paths are in UNIX format before anything is touched if $mingw ; then - [ -n "$M2_HOME" ] && - M2_HOME="`(cd "$M2_HOME"; pwd)`" [ -n "$JAVA_HOME" ] && JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" - # TODO classpath? fi if [ -z "$JAVA_HOME" ]; then @@ -146,7 +118,7 @@ if [ -z "$JAVACMD" ] ; then JAVACMD="$JAVA_HOME/bin/java" fi else - JAVACMD="`which java`" + JAVACMD="`\\unset -f command; \\command -v java`" fi fi @@ -160,12 +132,9 @@ if [ -z "$JAVA_HOME" ] ; then echo "Warning: JAVA_HOME environment variable is not set." fi -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher - # traverses directory structure from process work directory to filesystem root # first directory with .mvn subdirectory is considered project base directory find_maven_basedir() { - if [ -z "$1" ] then echo "Path not specified to find_maven_basedir" @@ -185,7 +154,7 @@ find_maven_basedir() { fi # end of workaround done - echo "${basedir}" + printf '%s' "$(cd "$basedir"; pwd)" } # concatenates all lines of a file @@ -195,11 +164,16 @@ concat_lines() { fi } -BASE_DIR=`find_maven_basedir "$(pwd)"` +BASE_DIR=$(find_maven_basedir "$(dirname $0)") if [ -z "$BASE_DIR" ]; then exit 1; fi +MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi + ########################################################################################## # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central # This allows using the maven wrapper in projects that prohibit checking in binary data. @@ -212,40 +186,67 @@ else if [ "$MVNW_VERBOSE" = true ]; then echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." fi - jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.0/maven-wrapper-0.4.0.jar" + if [ -n "$MVNW_REPOURL" ]; then + wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar" + else + wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar" + fi while IFS="=" read key value; do - case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + case "$key" in (wrapperUrl) wrapperUrl="$value"; break ;; esac done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" if [ "$MVNW_VERBOSE" = true ]; then - echo "Downloading from: $jarUrl" + echo "Downloading from: $wrapperUrl" fi wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi if command -v wget > /dev/null; then + QUIET="--quiet" if [ "$MVNW_VERBOSE" = true ]; then echo "Found wget ... using wget" + QUIET="" fi - wget "$jarUrl" -O "$wrapperJarPath" + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" + else + wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" + fi + [ $? -eq 0 ] || rm -f "$wrapperJarPath" elif command -v curl > /dev/null; then + QUIET="--silent" if [ "$MVNW_VERBOSE" = true ]; then echo "Found curl ... using curl" + QUIET="" fi - curl -o "$wrapperJarPath" "$jarUrl" + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L + else + curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L + fi + [ $? -eq 0 ] || rm -f "$wrapperJarPath" else if [ "$MVNW_VERBOSE" = true ]; then echo "Falling back to using Java to download" fi - javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" - if [ -e "$javaClass" ]; then - if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + javaSource="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaSource=`cygpath --path --windows "$javaSource"` + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaSource" ]; then + if [ ! -e "$javaClass" ]; then if [ "$MVNW_VERBOSE" = true ]; then echo " - Compiling MavenWrapperDownloader.java ..." fi # Compiling the Java class - ("$JAVA_HOME/bin/javac" "$javaClass") + ("$JAVA_HOME/bin/javac" "$javaSource") fi - if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ -e "$javaClass" ]; then # Running the downloader if [ "$MVNW_VERBOSE" = true ]; then echo " - Running MavenWrapperDownloader.java ..." @@ -259,16 +260,10 @@ fi # End of extension ########################################################################################## -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} -if [ "$MVNW_VERBOSE" = true ]; then - echo $MAVEN_PROJECTBASEDIR -fi MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" # For Cygwin, switch paths to Windows format before running java if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` [ -n "$CLASSPATH" ] && @@ -277,10 +272,16 @@ if $cygwin; then MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` fi +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain exec "$JAVACMD" \ $MAVEN_OPTS \ + $MAVEN_DEBUG_OPTS \ -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/mvnw.bat b/mvnw.bat old mode 100755 new mode 100644 index 03d90e9..1d7c59b --- a/mvnw.bat +++ b/mvnw.bat @@ -1,161 +1,187 @@ -@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 Maven2 Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir -@REM -@REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files -@REM ---------------------------------------------------------------------------- - -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.0/maven-wrapper-0.4.0.jar" -FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - echo Found %WRAPPER_JAR% -) else ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" - echo Finished downloading %WRAPPER_JAR% -) -@REM End of extension - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% +@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 https://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.1.1 +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* +if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar" + +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %WRAPPER_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% ^ + %JVM_CONFIG_MAVEN_PROPS% ^ + %MAVEN_OPTS% ^ + %MAVEN_DEBUG_OPTS% ^ + -classpath %WRAPPER_JAR% ^ + "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ + %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" +if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%"=="on" pause + +if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% + +cmd /C exit /B %ERROR_CODE% diff --git a/pom.xml b/pom.xml index 06db1ea..d85c4c6 100644 --- a/pom.xml +++ b/pom.xml @@ -1,45 +1,39 @@ - + 4.0.0 - dev.amatos.restcountries - dev.amatos.restcountries - 1 + com.restcountries + restcountries + 2025.04.20 + ${packaging} - io.micronaut + io.micronaut.platform micronaut-parent - 2.0.1 + 4.7.6 - + jar 17 - 17 - 2.0.1 - 2.0.0 - dev.amatos.restcountries.Application - 17 + 4.7.6 + netty + false + com.restcountries.aot.generated + com.restcountries.Application - jcenter.bintray.com - https://jcenter.bintray.com + central + https://repo.maven.apache.org/maven2 - io.micronaut - micronaut-inject - compile - - - io.micronaut - micronaut-validation + micronaut-http-client compile @@ -48,13 +42,18 @@ compile - io.micronaut - micronaut-http-client + io.micronaut.serde + micronaut-serde-jackson compile - io.micronaut - micronaut-runtime + io.micronaut.validation + micronaut-validation + compile + + + jakarta.validation + jakarta.validation-api compile @@ -62,6 +61,11 @@ logback-classic runtime + + io.micronaut.test + micronaut-test-junit5 + test + org.junit.jupiter junit-jupiter-api @@ -72,24 +76,14 @@ junit-jupiter-engine test - - io.micronaut.test - micronaut-test-junit5 - test - - - io.micronaut - micronaut-management - com.google.code.gson gson - 2.9.0 + 2.10.1 - org.apache.logging.log4j - log4j-core - 2.17.2 + io.swagger.core.v3 + swagger-annotations org.jboss.spec.javax.ws.rs @@ -97,87 +91,77 @@ 1.0.1.Final - org.glassfish.jersey.core - jersey-common - 3.0.4 + jakarta.ws.rs + jakarta.ws.rs-api + 4.0.0 - org.jboss.resteasy - resteasy-client - 6.0.1.Final + org.apache.logging.log4j + log4j-core + 2.17.2 - io.swagger.core.v3 - swagger-annotations + org.yaml + snakeyaml + runtime - - io.micronaut.build + io.micronaut.maven micronaut-maven-plugin + + aot-${packaging}.properties + org.apache.maven.plugins - maven-shade-plugin - - - org.apache.maven.plugins - maven-failsafe-plugin + maven-enforcer-plugin org.apache.maven.plugins maven-compiler-plugin - 3.8.1 - + + + + io.micronaut - micronaut-inject-java - ${micronaut.version} + micronaut-http-validation + ${micronaut.core.version} - io.micronaut - micronaut-validation - ${micronaut.version} + io.micronaut.serde + micronaut-serde-processor + ${micronaut.serialization.version} + + + io.micronaut + micronaut-inject + + - io.micronaut.openapi - micronaut-openapi - ${micronautopenapi.version} + io.micronaut.validation + micronaut-validation-processor + ${micronaut.validation.version} + + + io.micronaut + micronaut-inject + + - -Amicronaut.processing.group=dev.amatos.restcountries - -Amicronaut.processing.module=dev.amatos.restcountries + -Amicronaut.processing.group=com.restcountries + -Amicronaut.processing.module=restcountries - - - test-compile - - testCompile - - - - - io.micronaut - micronaut-inject-java - ${micronaut.version} - - - io.micronaut - micronaut-validation - ${micronaut.version} - - - - - - diff --git a/src/main/java/com/restcountries/Application.java b/src/main/java/com/restcountries/Application.java new file mode 100644 index 0000000..c7f72d4 --- /dev/null +++ b/src/main/java/com/restcountries/Application.java @@ -0,0 +1,10 @@ +package com.restcountries; + +import io.micronaut.runtime.Micronaut; + +public class Application { + + public static void main(String[] args) { + Micronaut.run(Application.class, args); + } +} \ No newline at end of file diff --git a/src/main/java/dev/amatos/restcountries/controller/ControllerHelper.java b/src/main/java/com/restcountries/controller/ControllerHelper.java similarity index 90% rename from src/main/java/dev/amatos/restcountries/controller/ControllerHelper.java rename to src/main/java/com/restcountries/controller/ControllerHelper.java index db53e18..37470a1 100644 --- a/src/main/java/dev/amatos/restcountries/controller/ControllerHelper.java +++ b/src/main/java/com/restcountries/controller/ControllerHelper.java @@ -1,12 +1,12 @@ -package dev.amatos.restcountries.controller; +package com.restcountries.controller; -import static dev.amatos.restcountries.utils.Constants.CACHE_CONTROL_VALUE; -import static io.micronaut.http.HttpHeaders.CACHE_CONTROL; - -import dev.amatos.restcountries.domain.ResponseEntity; +import com.restcountries.domain.ResponseEntity; import io.micronaut.http.HttpResponse; import jakarta.ws.rs.core.Response; +import static com.restcountries.utils.Constants.CACHE_CONTROL_VALUE; +import static io.micronaut.http.HttpHeaders.CACHE_CONTROL; + public class ControllerHelper { protected static final String[] COUNTRY_FIELDS_V2 = new String[]{ diff --git a/src/main/java/dev/amatos/restcountries/controller/ControllerV3Helper.java b/src/main/java/com/restcountries/controller/ControllerV3Helper.java similarity index 79% rename from src/main/java/dev/amatos/restcountries/controller/ControllerV3Helper.java rename to src/main/java/com/restcountries/controller/ControllerV3Helper.java index d0d82a6..599c54d 100644 --- a/src/main/java/dev/amatos/restcountries/controller/ControllerV3Helper.java +++ b/src/main/java/com/restcountries/controller/ControllerV3Helper.java @@ -1,21 +1,18 @@ -package dev.amatos.restcountries.controller; +package com.restcountries.controller; import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonParser; -import dev.amatos.restcountries.domain.ICountryRestSymbols; -import dev.amatos.restcountries.domain.base.BaseCountry; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; -import java.util.Set; +import com.restcountries.domain.ICountryRestSymbols; +import com.restcountries.domain.base.BaseCountry; + +import java.util.*; public class ControllerV3Helper { protected Object checkFieldsAndParseCountries(Optional fields, - Set countries) { + Set countries) { if (fields.isPresent()) { return parsedCountries(countries, fields.get()); } else { @@ -23,7 +20,7 @@ public class ControllerV3Helper { } } - protected Object checkFieldsAndParseCountry(Set countries, Optional fields) { + protected Object checkFieldsAndParseCountry(Set countries, Optional fields) { if (fields.isPresent()) { return parsedCountry(countries, fields.get()); } else { @@ -31,7 +28,7 @@ public class ControllerV3Helper { } } - protected Object parsedCountries(Set countries, String excludedFields) { + protected Object parsedCountries(Set countries, String excludedFields) { if (excludedFields == null || excludedFields.isEmpty()) { return countries; } else { @@ -60,7 +57,7 @@ public class ControllerV3Helper { return jsonObject.toString(); } - private String getCountriesJson(Set countries, List fields) { + private String getCountriesJson(Set countries, List fields) { var gson = new Gson(); var jsonArray = JsonParser.parseString(gson.toJson(countries)).getAsJsonArray(); var resultArray = new JsonArray(); diff --git a/src/main/java/dev/amatos/restcountries/controller/CountryControllerV2.java b/src/main/java/com/restcountries/controller/CountryControllerV2.java similarity index 97% rename from src/main/java/dev/amatos/restcountries/controller/CountryControllerV2.java rename to src/main/java/com/restcountries/controller/CountryControllerV2.java index 160bf3b..619afd3 100644 --- a/src/main/java/dev/amatos/restcountries/controller/CountryControllerV2.java +++ b/src/main/java/com/restcountries/controller/CountryControllerV2.java @@ -1,12 +1,12 @@ -package dev.amatos.restcountries.controller; +package com.restcountries.controller; import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonParser; -import dev.amatos.restcountries.domain.ICountryRestSymbols; -import dev.amatos.restcountries.domain.v2.Country; -import dev.amatos.restcountries.service.v2.CountryServiceV2; +import com.restcountries.domain.ICountryRestSymbols; +import com.restcountries.domain.v2.Country; +import com.restcountries.service.v2.CountryServiceV2; import io.micronaut.http.HttpResponse; import io.micronaut.http.MediaType; import io.micronaut.http.annotation.Controller; @@ -14,11 +14,12 @@ import io.micronaut.http.annotation.Get; import io.micronaut.http.annotation.PathVariable; import io.micronaut.http.annotation.QueryValue; import io.swagger.v3.oas.annotations.Hidden; + +import javax.ws.rs.QueryParam; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Optional; -import javax.ws.rs.QueryParam; @Hidden @Controller("/v2/") diff --git a/src/main/java/dev/amatos/restcountries/controller/CountryControllerV3.java b/src/main/java/com/restcountries/controller/CountryControllerV3.java similarity index 98% rename from src/main/java/dev/amatos/restcountries/controller/CountryControllerV3.java rename to src/main/java/com/restcountries/controller/CountryControllerV3.java index eeb88b7..2b0f2ab 100644 --- a/src/main/java/dev/amatos/restcountries/controller/CountryControllerV3.java +++ b/src/main/java/com/restcountries/controller/CountryControllerV3.java @@ -1,6 +1,6 @@ -package dev.amatos.restcountries.controller; +package com.restcountries.controller; -import dev.amatos.restcountries.service.v3.CountryServiceV3; +import com.restcountries.service.v3.CountryServiceV3; import io.micronaut.http.HttpResponse; import io.micronaut.http.MediaType; import io.micronaut.http.annotation.Controller; @@ -8,8 +8,9 @@ import io.micronaut.http.annotation.Get; import io.micronaut.http.annotation.PathVariable; import io.micronaut.http.annotation.QueryValue; import io.swagger.v3.oas.annotations.Hidden; -import java.util.Optional; + import javax.ws.rs.QueryParam; +import java.util.Optional; @Hidden @Controller("/v3/") diff --git a/src/main/java/dev/amatos/restcountries/controller/CountryControllerV31.java b/src/main/java/com/restcountries/controller/CountryControllerV31.java similarity index 98% rename from src/main/java/dev/amatos/restcountries/controller/CountryControllerV31.java rename to src/main/java/com/restcountries/controller/CountryControllerV31.java index 6a6da33..79b52bc 100644 --- a/src/main/java/dev/amatos/restcountries/controller/CountryControllerV31.java +++ b/src/main/java/com/restcountries/controller/CountryControllerV31.java @@ -1,6 +1,6 @@ -package dev.amatos.restcountries.controller; +package com.restcountries.controller; -import dev.amatos.restcountries.service.v3.v31.CountryServiceV31; +import com.restcountries.service.v3.v31.CountryServiceV31; import io.micronaut.http.HttpResponse; import io.micronaut.http.MediaType; import io.micronaut.http.annotation.Controller; @@ -8,9 +8,10 @@ import io.micronaut.http.annotation.Get; import io.micronaut.http.annotation.PathVariable; import io.micronaut.http.annotation.QueryValue; import io.swagger.v3.oas.annotations.media.Schema; -import java.util.Optional; + import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; +import java.util.Optional; @Controller("/v3.1/") public class CountryControllerV31 extends ControllerV3Helper { diff --git a/src/main/java/dev/amatos/restcountries/domain/BaseCountry.java b/src/main/java/com/restcountries/domain/BaseCountry.java similarity index 94% rename from src/main/java/dev/amatos/restcountries/domain/BaseCountry.java rename to src/main/java/com/restcountries/domain/BaseCountry.java index 42976a6..a90242a 100644 --- a/src/main/java/dev/amatos/restcountries/domain/BaseCountry.java +++ b/src/main/java/com/restcountries/domain/BaseCountry.java @@ -1,8 +1,11 @@ -package dev.amatos.restcountries.domain; +package com.restcountries.domain; + +import io.micronaut.serde.annotation.Serdeable; import java.util.List; import java.util.Map; +@Serdeable.Serializable public class BaseCountry { protected String name; diff --git a/src/main/java/dev/amatos/restcountries/domain/ICountryRestSymbols.java b/src/main/java/com/restcountries/domain/ICountryRestSymbols.java similarity index 86% rename from src/main/java/dev/amatos/restcountries/domain/ICountryRestSymbols.java rename to src/main/java/com/restcountries/domain/ICountryRestSymbols.java index e335b14..a458735 100644 --- a/src/main/java/dev/amatos/restcountries/domain/ICountryRestSymbols.java +++ b/src/main/java/com/restcountries/domain/ICountryRestSymbols.java @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -package dev.amatos.restcountries.domain; +package com.restcountries.domain; public interface ICountryRestSymbols { String COLON = ","; diff --git a/src/main/java/dev/amatos/restcountries/domain/ResponseEntity.java b/src/main/java/com/restcountries/domain/ResponseEntity.java similarity index 92% rename from src/main/java/dev/amatos/restcountries/domain/ResponseEntity.java rename to src/main/java/com/restcountries/domain/ResponseEntity.java index 7ce3af4..19126dc 100644 --- a/src/main/java/dev/amatos/restcountries/domain/ResponseEntity.java +++ b/src/main/java/com/restcountries/domain/ResponseEntity.java @@ -1,7 +1,7 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -package dev.amatos.restcountries.domain; +package com.restcountries.domain; public class ResponseEntity { diff --git a/src/main/java/dev/amatos/restcountries/domain/base/BaseCountry.java b/src/main/java/com/restcountries/domain/base/BaseCountry.java similarity index 98% rename from src/main/java/dev/amatos/restcountries/domain/base/BaseCountry.java rename to src/main/java/com/restcountries/domain/base/BaseCountry.java index 5a2dd3b..ac338a3 100644 --- a/src/main/java/dev/amatos/restcountries/domain/base/BaseCountry.java +++ b/src/main/java/com/restcountries/domain/base/BaseCountry.java @@ -1,8 +1,11 @@ -package dev.amatos.restcountries.domain.base; +package com.restcountries.domain.base; + +import io.micronaut.serde.annotation.Serdeable; import java.util.List; import java.util.Map; +@Serdeable.Serializable public class BaseCountry { private Name name; diff --git a/src/main/java/dev/amatos/restcountries/domain/base/Car.java b/src/main/java/com/restcountries/domain/base/Car.java similarity index 75% rename from src/main/java/dev/amatos/restcountries/domain/base/Car.java rename to src/main/java/com/restcountries/domain/base/Car.java index 1d771b4..ab5ae53 100644 --- a/src/main/java/dev/amatos/restcountries/domain/base/Car.java +++ b/src/main/java/com/restcountries/domain/base/Car.java @@ -1,7 +1,10 @@ -package dev.amatos.restcountries.domain.base; +package com.restcountries.domain.base; + +import io.micronaut.serde.annotation.Serdeable; import java.util.List; +@Serdeable.Serializable public class Car { private List signs; private String side; diff --git a/src/main/java/dev/amatos/restcountries/domain/base/Currency.java b/src/main/java/com/restcountries/domain/base/Currency.java similarity index 73% rename from src/main/java/dev/amatos/restcountries/domain/base/Currency.java rename to src/main/java/com/restcountries/domain/base/Currency.java index 9af7fc9..fd1b424 100644 --- a/src/main/java/dev/amatos/restcountries/domain/base/Currency.java +++ b/src/main/java/com/restcountries/domain/base/Currency.java @@ -1,5 +1,8 @@ -package dev.amatos.restcountries.domain.base; +package com.restcountries.domain.base; +import io.micronaut.serde.annotation.Serdeable; + +@Serdeable.Serializable public class Currency { private String name; private String symbol; diff --git a/src/main/java/dev/amatos/restcountries/domain/base/Idd.java b/src/main/java/com/restcountries/domain/base/Idd.java similarity index 76% rename from src/main/java/dev/amatos/restcountries/domain/base/Idd.java rename to src/main/java/com/restcountries/domain/base/Idd.java index 2fe9c24..9ad5114 100644 --- a/src/main/java/dev/amatos/restcountries/domain/base/Idd.java +++ b/src/main/java/com/restcountries/domain/base/Idd.java @@ -1,7 +1,10 @@ -package dev.amatos.restcountries.domain.base; +package com.restcountries.domain.base; + +import io.micronaut.serde.annotation.Serdeable; import java.util.List; +@Serdeable.Serializable public class Idd { private String root; private List suffixes; diff --git a/src/main/java/dev/amatos/restcountries/domain/base/Name.java b/src/main/java/com/restcountries/domain/base/Name.java similarity index 88% rename from src/main/java/dev/amatos/restcountries/domain/base/Name.java rename to src/main/java/com/restcountries/domain/base/Name.java index a6b09ca..6214710 100644 --- a/src/main/java/dev/amatos/restcountries/domain/base/Name.java +++ b/src/main/java/com/restcountries/domain/base/Name.java @@ -1,8 +1,11 @@ -package dev.amatos.restcountries.domain.base; +package com.restcountries.domain.base; + +import io.micronaut.serde.annotation.Serdeable; import java.util.List; import java.util.Map; +@Serdeable.Serializable public class Name { private String common; private String official; diff --git a/src/main/java/dev/amatos/restcountries/domain/base/NativeName.java b/src/main/java/com/restcountries/domain/base/NativeName.java similarity index 75% rename from src/main/java/dev/amatos/restcountries/domain/base/NativeName.java rename to src/main/java/com/restcountries/domain/base/NativeName.java index 74ebe09..ad6e8ce 100644 --- a/src/main/java/dev/amatos/restcountries/domain/base/NativeName.java +++ b/src/main/java/com/restcountries/domain/base/NativeName.java @@ -1,5 +1,8 @@ -package dev.amatos.restcountries.domain.base; +package com.restcountries.domain.base; +import io.micronaut.serde.annotation.Serdeable; + +@Serdeable.Serializable public class NativeName { private String official; private String common; diff --git a/src/main/java/dev/amatos/restcountries/domain/v2/Contribution.java b/src/main/java/com/restcountries/domain/v2/Contribution.java similarity index 89% rename from src/main/java/dev/amatos/restcountries/domain/v2/Contribution.java rename to src/main/java/com/restcountries/domain/v2/Contribution.java index 32d4967..e6d6c00 100644 --- a/src/main/java/dev/amatos/restcountries/domain/v2/Contribution.java +++ b/src/main/java/com/restcountries/domain/v2/Contribution.java @@ -1,4 +1,4 @@ -package dev.amatos.restcountries.domain.v2; +package com.restcountries.domain.v2; /** * Created by fayder on 24/02/2017. diff --git a/src/main/java/dev/amatos/restcountries/domain/v2/Country.java b/src/main/java/com/restcountries/domain/v2/Country.java similarity index 86% rename from src/main/java/dev/amatos/restcountries/domain/v2/Country.java rename to src/main/java/com/restcountries/domain/v2/Country.java index abb4f39..3b0ebac 100644 --- a/src/main/java/dev/amatos/restcountries/domain/v2/Country.java +++ b/src/main/java/com/restcountries/domain/v2/Country.java @@ -1,12 +1,14 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -package dev.amatos.restcountries.domain.v2; +package com.restcountries.domain.v2; -import dev.amatos.restcountries.domain.BaseCountry; +import com.restcountries.domain.BaseCountry; +import io.micronaut.serde.annotation.Serdeable; import java.util.List; +@Serdeable.Serializable public class Country extends BaseCountry { private List currencies; diff --git a/src/main/java/dev/amatos/restcountries/domain/v2/Currency.java b/src/main/java/com/restcountries/domain/v2/Currency.java similarity index 86% rename from src/main/java/dev/amatos/restcountries/domain/v2/Currency.java rename to src/main/java/com/restcountries/domain/v2/Currency.java index d3f336a..ee489a6 100644 --- a/src/main/java/dev/amatos/restcountries/domain/v2/Currency.java +++ b/src/main/java/com/restcountries/domain/v2/Currency.java @@ -1,8 +1,11 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -package dev.amatos.restcountries.domain.v2; +package com.restcountries.domain.v2; +import io.micronaut.serde.annotation.Serdeable; + +@Serdeable.Serializable public class Currency { private String code; diff --git a/src/main/java/dev/amatos/restcountries/domain/v2/Flag.java b/src/main/java/com/restcountries/domain/v2/Flag.java similarity index 72% rename from src/main/java/dev/amatos/restcountries/domain/v2/Flag.java rename to src/main/java/com/restcountries/domain/v2/Flag.java index f5d4e74..0316da0 100644 --- a/src/main/java/dev/amatos/restcountries/domain/v2/Flag.java +++ b/src/main/java/com/restcountries/domain/v2/Flag.java @@ -1,5 +1,8 @@ -package dev.amatos.restcountries.domain.v2; +package com.restcountries.domain.v2; +import io.micronaut.serde.annotation.Serdeable; + +@Serdeable.Serializable public class Flag { private String svg; private String png; diff --git a/src/main/java/dev/amatos/restcountries/domain/v2/Language.java b/src/main/java/com/restcountries/domain/v2/Language.java similarity index 89% rename from src/main/java/dev/amatos/restcountries/domain/v2/Language.java rename to src/main/java/com/restcountries/domain/v2/Language.java index 062ea22..9efe306 100644 --- a/src/main/java/dev/amatos/restcountries/domain/v2/Language.java +++ b/src/main/java/com/restcountries/domain/v2/Language.java @@ -1,8 +1,11 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -package dev.amatos.restcountries.domain.v2; +package com.restcountries.domain.v2; +import io.micronaut.serde.annotation.Serdeable; + +@Serdeable.Serializable public class Language { private String iso639_1; diff --git a/src/main/java/dev/amatos/restcountries/domain/v2/Maps.java b/src/main/java/com/restcountries/domain/v2/Maps.java similarity index 78% rename from src/main/java/dev/amatos/restcountries/domain/v2/Maps.java rename to src/main/java/com/restcountries/domain/v2/Maps.java index 8a64f0f..c6f85dc 100644 --- a/src/main/java/dev/amatos/restcountries/domain/v2/Maps.java +++ b/src/main/java/com/restcountries/domain/v2/Maps.java @@ -1,5 +1,8 @@ -package dev.amatos.restcountries.domain.v2; +package com.restcountries.domain.v2; +import io.micronaut.serde.annotation.Serdeable; + +@Serdeable.Serializable public class Maps { private String gmaps; private String openstreetmap; diff --git a/src/main/java/dev/amatos/restcountries/domain/v2/RegionalBloc.java b/src/main/java/com/restcountries/domain/v2/RegionalBloc.java similarity index 86% rename from src/main/java/dev/amatos/restcountries/domain/v2/RegionalBloc.java rename to src/main/java/com/restcountries/domain/v2/RegionalBloc.java index 524b99b..6268fc6 100644 --- a/src/main/java/dev/amatos/restcountries/domain/v2/RegionalBloc.java +++ b/src/main/java/com/restcountries/domain/v2/RegionalBloc.java @@ -1,4 +1,6 @@ -package dev.amatos.restcountries.domain.v2; +package com.restcountries.domain.v2; + +import io.micronaut.serde.annotation.Serdeable; import java.util.ArrayList; import java.util.List; @@ -6,6 +8,7 @@ import java.util.List; /** * Created by fayder on 30/04/2017. */ +@Serdeable.Serializable public class RegionalBloc { private String acronym; diff --git a/src/main/java/dev/amatos/restcountries/domain/v2/Translations.java b/src/main/java/com/restcountries/domain/v2/Translations.java similarity index 92% rename from src/main/java/dev/amatos/restcountries/domain/v2/Translations.java rename to src/main/java/com/restcountries/domain/v2/Translations.java index 0300cd5..287c1d8 100644 --- a/src/main/java/dev/amatos/restcountries/domain/v2/Translations.java +++ b/src/main/java/com/restcountries/domain/v2/Translations.java @@ -1,9 +1,12 @@ -package dev.amatos.restcountries.domain.v2; +package com.restcountries.domain.v2; +import io.micronaut.serde.annotation.Serdeable; + /** * Created by fayder on 05/03/2017. */ +@Serdeable.Serializable public class Translations { private String br; diff --git a/src/main/java/dev/amatos/restcountries/domain/v3/Country.java b/src/main/java/com/restcountries/domain/v3/Country.java similarity index 59% rename from src/main/java/dev/amatos/restcountries/domain/v3/Country.java rename to src/main/java/com/restcountries/domain/v3/Country.java index ad12ea4..cc3c110 100644 --- a/src/main/java/dev/amatos/restcountries/domain/v3/Country.java +++ b/src/main/java/com/restcountries/domain/v3/Country.java @@ -1,8 +1,11 @@ -package dev.amatos.restcountries.domain.v3; +package com.restcountries.domain.v3; + +import com.restcountries.domain.base.BaseCountry; +import io.micronaut.serde.annotation.Serdeable; -import dev.amatos.restcountries.domain.base.BaseCountry; import java.util.List; +@Serdeable.Serializable public class Country extends BaseCountry { private List flags; diff --git a/src/main/java/dev/amatos/restcountries/domain/v3/v31/CapitalInformation.java b/src/main/java/com/restcountries/domain/v3/v31/CapitalInformation.java similarity index 66% rename from src/main/java/dev/amatos/restcountries/domain/v3/v31/CapitalInformation.java rename to src/main/java/com/restcountries/domain/v3/v31/CapitalInformation.java index 325dba1..c3704be 100644 --- a/src/main/java/dev/amatos/restcountries/domain/v3/v31/CapitalInformation.java +++ b/src/main/java/com/restcountries/domain/v3/v31/CapitalInformation.java @@ -1,7 +1,10 @@ -package dev.amatos.restcountries.domain.v3.v31; +package com.restcountries.domain.v3.v31; + +import io.micronaut.serde.annotation.Serdeable; import java.util.List; +@Serdeable.Serializable public class CapitalInformation { private List latlng; diff --git a/src/main/java/dev/amatos/restcountries/domain/v3/v31/Country.java b/src/main/java/com/restcountries/domain/v3/v31/Country.java similarity index 85% rename from src/main/java/dev/amatos/restcountries/domain/v3/v31/Country.java rename to src/main/java/com/restcountries/domain/v3/v31/Country.java index 2baa0c1..e54cf1c 100644 --- a/src/main/java/dev/amatos/restcountries/domain/v3/v31/Country.java +++ b/src/main/java/com/restcountries/domain/v3/v31/Country.java @@ -1,8 +1,11 @@ -package dev.amatos.restcountries.domain.v3.v31; +package com.restcountries.domain.v3.v31; + +import com.restcountries.domain.base.BaseCountry; +import io.micronaut.serde.annotation.Serdeable; -import dev.amatos.restcountries.domain.base.BaseCountry; import java.util.Map; +@Serdeable.Serializable public class Country extends BaseCountry { private Flag flags; private Flag coatOfArms; diff --git a/src/main/java/dev/amatos/restcountries/domain/v3/v31/Flag.java b/src/main/java/com/restcountries/domain/v3/v31/Flag.java similarity index 78% rename from src/main/java/dev/amatos/restcountries/domain/v3/v31/Flag.java rename to src/main/java/com/restcountries/domain/v3/v31/Flag.java index 42d542a..48b3220 100644 --- a/src/main/java/dev/amatos/restcountries/domain/v3/v31/Flag.java +++ b/src/main/java/com/restcountries/domain/v3/v31/Flag.java @@ -1,5 +1,8 @@ -package dev.amatos.restcountries.domain.v3.v31; +package com.restcountries.domain.v3.v31; +import io.micronaut.serde.annotation.Serdeable; + +@Serdeable.Serializable public class Flag { private String png; private String svg; diff --git a/src/main/java/dev/amatos/restcountries/service/v2/CountryServiceBaseV2.java b/src/main/java/com/restcountries/service/v2/CountryServiceBaseV2.java similarity index 94% rename from src/main/java/dev/amatos/restcountries/service/v2/CountryServiceBaseV2.java rename to src/main/java/com/restcountries/service/v2/CountryServiceBaseV2.java index 02f0a7e..6781870 100644 --- a/src/main/java/dev/amatos/restcountries/service/v2/CountryServiceBaseV2.java +++ b/src/main/java/com/restcountries/service/v2/CountryServiceBaseV2.java @@ -1,12 +1,14 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -package dev.amatos.restcountries.service.v2; +package com.restcountries.service.v2; import com.google.gson.Gson; import com.google.gson.stream.JsonReader; -import dev.amatos.restcountries.domain.BaseCountry; -import dev.amatos.restcountries.domain.ICountryRestSymbols; +import com.restcountries.domain.BaseCountry; +import com.restcountries.domain.ICountryRestSymbols; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.io.InputStream; import java.io.InputStreamReader; @@ -14,12 +16,9 @@ import java.nio.charset.StandardCharsets; import java.text.Normalizer; import java.util.ArrayList; import java.util.List; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; public class CountryServiceBaseV2 { - private static final Logger logger = LogManager.getLogger(CountryServiceBaseV2.class); protected T getByAlpha(String alpha, List countries) { int alphaLength = alpha.length(); @@ -155,7 +154,6 @@ public class CountryServiceBaseV2 { protected List loadJson(String filename, Class clazz) { - logger.info("Loading JSON {}", filename); List countries = new ArrayList<>(); InputStream is = CountryServiceBaseV2.class.getClassLoader().getResourceAsStream(filename); var gson = new Gson(); @@ -170,7 +168,6 @@ public class CountryServiceBaseV2 { } } catch (Exception e) { e.printStackTrace(); - logger.error("Could not load JSON {}", filename); } return countries; } diff --git a/src/main/java/dev/amatos/restcountries/service/v2/CountryServiceV2.java b/src/main/java/com/restcountries/service/v2/CountryServiceV2.java similarity index 95% rename from src/main/java/dev/amatos/restcountries/service/v2/CountryServiceV2.java rename to src/main/java/com/restcountries/service/v2/CountryServiceV2.java index dd121e6..8a74438 100644 --- a/src/main/java/dev/amatos/restcountries/service/v2/CountryServiceV2.java +++ b/src/main/java/com/restcountries/service/v2/CountryServiceV2.java @@ -1,11 +1,11 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -package dev.amatos.restcountries.service.v2; +package com.restcountries.service.v2; -import dev.amatos.restcountries.domain.v2.Country; -import dev.amatos.restcountries.domain.v2.Currency; -import dev.amatos.restcountries.domain.v2.RegionalBloc; +import com.restcountries.domain.v2.Country; +import com.restcountries.domain.v2.Currency; +import com.restcountries.domain.v2.RegionalBloc; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/dev/amatos/restcountries/service/v3/CountryServiceBaseV3.java b/src/main/java/com/restcountries/service/v3/CountryServiceBaseV3.java similarity index 97% rename from src/main/java/dev/amatos/restcountries/service/v3/CountryServiceBaseV3.java rename to src/main/java/com/restcountries/service/v3/CountryServiceBaseV3.java index 8204da9..4c9b725 100644 --- a/src/main/java/dev/amatos/restcountries/service/v3/CountryServiceBaseV3.java +++ b/src/main/java/com/restcountries/service/v3/CountryServiceBaseV3.java @@ -1,12 +1,13 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -package dev.amatos.restcountries.service.v3; +package com.restcountries.service.v3; import com.google.gson.Gson; import com.google.gson.stream.JsonReader; -import dev.amatos.restcountries.domain.ICountryRestSymbols; -import dev.amatos.restcountries.domain.base.BaseCountry; +import com.restcountries.domain.ICountryRestSymbols; +import com.restcountries.domain.base.BaseCountry; + import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; diff --git a/src/main/java/dev/amatos/restcountries/service/v3/CountryServiceV3.java b/src/main/java/com/restcountries/service/v3/CountryServiceV3.java similarity index 91% rename from src/main/java/dev/amatos/restcountries/service/v3/CountryServiceV3.java rename to src/main/java/com/restcountries/service/v3/CountryServiceV3.java index f9d1e12..6ea6814 100644 --- a/src/main/java/dev/amatos/restcountries/service/v3/CountryServiceV3.java +++ b/src/main/java/com/restcountries/service/v3/CountryServiceV3.java @@ -1,9 +1,10 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -package dev.amatos.restcountries.service.v3; +package com.restcountries.service.v3; + +import com.restcountries.domain.v3.Country; -import dev.amatos.restcountries.domain.v3.Country; import java.text.Normalizer; import java.util.HashSet; import java.util.Set; @@ -22,7 +23,7 @@ public class CountryServiceV3 extends CountryServiceBaseV3 { } public static CountryServiceV3 getInstance() { - return CountryServiceV3.InstanceHolder.INSTANCE; + return InstanceHolder.INSTANCE; } public Set getAll() { @@ -84,6 +85,7 @@ public class CountryServiceV3 extends CountryServiceBaseV3 { } private void initialize() { - countries = (Set) super.loadJson("countriesV3.json", Country.class); + var c = (Set) super.loadJson("countriesV3.json", Country.class); + countries = c; } } diff --git a/src/main/java/dev/amatos/restcountries/service/v3/v31/CountryServiceV31.java b/src/main/java/com/restcountries/service/v3/v31/CountryServiceV31.java similarity index 91% rename from src/main/java/dev/amatos/restcountries/service/v3/v31/CountryServiceV31.java rename to src/main/java/com/restcountries/service/v3/v31/CountryServiceV31.java index d88586f..479163d 100644 --- a/src/main/java/dev/amatos/restcountries/service/v3/v31/CountryServiceV31.java +++ b/src/main/java/com/restcountries/service/v3/v31/CountryServiceV31.java @@ -1,13 +1,13 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -package dev.amatos.restcountries.service.v3.v31; +package com.restcountries.service.v3.v31; + +import com.restcountries.domain.v3.v31.Country; +import com.restcountries.service.v3.CountryServiceBaseV3; -import dev.amatos.restcountries.domain.v3.v31.Country; -import dev.amatos.restcountries.service.v3.CountryServiceBaseV3; import java.text.Normalizer; import java.util.HashSet; -import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; @@ -25,7 +25,7 @@ public class CountryServiceV31 extends CountryServiceBaseV3 { } public static CountryServiceV31 getInstance() { - return CountryServiceV31.InstanceHolder.INSTANCE; + return InstanceHolder.INSTANCE; } public Set getAll() { diff --git a/src/main/java/dev/amatos/restcountries/utils/Constants.java b/src/main/java/com/restcountries/utils/Constants.java similarity index 74% rename from src/main/java/dev/amatos/restcountries/utils/Constants.java rename to src/main/java/com/restcountries/utils/Constants.java index bc4ec95..3f9e54a 100644 --- a/src/main/java/dev/amatos/restcountries/utils/Constants.java +++ b/src/main/java/com/restcountries/utils/Constants.java @@ -1,4 +1,4 @@ -package dev.amatos.restcountries.utils; +package com.restcountries.utils; public class Constants { public static final String CACHE_CONTROL_VALUE="public, immutable, max-age=31556926"; diff --git a/src/main/java/dev/amatos/restcountries/Application.java b/src/main/java/dev/amatos/restcountries/Application.java deleted file mode 100644 index ffd1823..0000000 --- a/src/main/java/dev/amatos/restcountries/Application.java +++ /dev/null @@ -1,25 +0,0 @@ -package dev.amatos.restcountries; - -import io.micronaut.runtime.Micronaut; - -import io.swagger.v3.oas.annotations.OpenAPIDefinition; -import io.swagger.v3.oas.annotations.info.Contact; -import io.swagger.v3.oas.annotations.info.Info; -import io.swagger.v3.oas.annotations.info.License; -import io.swagger.v3.oas.annotations.servers.Server; - - -@OpenAPIDefinition( - info = @Info( - title = "rest-countries", - version = "3.1", - description = "Get information about countries via a RESTful API", - license = @License(name = "Mozilla Public License MPL 2.0", url = "https://www.mozilla.org/en-US/MPL/2.0/"), - contact = @Contact(url = "https://restcountries.com", name = "Alejandro Matos") - ) -) -public class Application { - public static void main(String[] args) { - Micronaut.run(Application.class, args); - } -} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 422561e..1d0f290 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,22 +1,18 @@ +#Wed Mar 12 15:11:47 UTC 2025 micronaut: application: - name: dev.amatos.restcountries + name=restcountries router.static-resources.default: enabled: true paths: classpath:static mapping: "/**" - router: - static-resources: - swagger: - paths: classpath:META-INF/swagger - mapping: /openapi/** server: cors: enabled: true configurations: web: allowedMethods: - - GET + - GET caches: rate-limiter: expire-after-access: 10m \ No newline at end of file diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index 8221870..2d77bda 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -1,7 +1,6 @@ - false diff --git a/src/test/java/dev/amatos/restcountries/RestCountriesV2Test.java b/src/test/java/com/restcountries/RestCountriesV2Test.java similarity index 94% rename from src/test/java/dev/amatos/restcountries/RestCountriesV2Test.java rename to src/test/java/com/restcountries/RestCountriesV2Test.java index ddd3192..f5f01c6 100644 --- a/src/test/java/dev/amatos/restcountries/RestCountriesV2Test.java +++ b/src/test/java/com/restcountries/RestCountriesV2Test.java @@ -1,16 +1,13 @@ -package dev.amatos.restcountries; +package com.restcountries; -import dev.amatos.restcountries.domain.v2.Country; -import dev.amatos.restcountries.domain.v2.Currency; -import dev.amatos.restcountries.domain.v2.Language; -import dev.amatos.restcountries.domain.v2.RegionalBloc; -import dev.amatos.restcountries.domain.v2.Translations; -import dev.amatos.restcountries.service.v2.CountryServiceV2; -import io.micronaut.test.annotation.MicronautTest; -import java.util.List; +import com.restcountries.domain.v2.*; +import com.restcountries.service.v2.CountryServiceV2; +import io.micronaut.test.extensions.junit5.annotation.MicronautTest; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import java.util.List; + @MicronautTest class RestCountriesV2Test { diff --git a/src/test/java/dev/amatos/restcountries/RestCountriesV31Test.java b/src/test/java/com/restcountries/RestCountriesV31Test.java similarity index 89% rename from src/test/java/dev/amatos/restcountries/RestCountriesV31Test.java rename to src/test/java/com/restcountries/RestCountriesV31Test.java index 1b5c4e1..7b2651a 100644 --- a/src/test/java/dev/amatos/restcountries/RestCountriesV31Test.java +++ b/src/test/java/com/restcountries/RestCountriesV31Test.java @@ -1,29 +1,16 @@ -package dev.amatos.restcountries; +package com.restcountries; - -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import dev.amatos.restcountries.domain.v3.v31.Country; -import dev.amatos.restcountries.service.v3.v31.CountryServiceV31; -import io.micronaut.http.client.RxHttpClient; -import io.micronaut.http.client.annotation.Client; -import io.micronaut.test.annotation.MicronautTest; -import java.security.spec.ECField; -import java.util.ArrayList; -import java.util.stream.Collectors; -import javax.inject.Inject; +import com.restcountries.service.v3.v31.CountryServiceV31; +import io.micronaut.test.extensions.junit5.annotation.MicronautTest; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + @MicronautTest class RestCountriesV31Test { - @Inject - @Client("/") - RxHttpClient rxHttpClient; - @Test void getAll() { var countries = CountryServiceV31.getInstance().getAll(); diff --git a/src/test/java/dev/amatos/restcountries/RestCountriesV3Test.java b/src/test/java/com/restcountries/RestCountriesV3Test.java similarity index 96% rename from src/test/java/dev/amatos/restcountries/RestCountriesV3Test.java rename to src/test/java/com/restcountries/RestCountriesV3Test.java index cd70255..afc9c73 100644 --- a/src/test/java/dev/amatos/restcountries/RestCountriesV3Test.java +++ b/src/test/java/com/restcountries/RestCountriesV3Test.java @@ -1,7 +1,7 @@ -package dev.amatos.restcountries; +package com.restcountries; -import dev.amatos.restcountries.service.v3.CountryServiceV3; -import io.micronaut.test.annotation.MicronautTest; +import com.restcountries.service.v3.CountryServiceV3; +import io.micronaut.test.extensions.junit5.annotation.MicronautTest; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; diff --git a/src/test/java/com/restcountries/RestcountriesTest.java b/src/test/java/com/restcountries/RestcountriesTest.java new file mode 100644 index 0000000..ef430b0 --- /dev/null +++ b/src/test/java/com/restcountries/RestcountriesTest.java @@ -0,0 +1,21 @@ +package com.restcountries; + +import io.micronaut.runtime.EmbeddedApplication; +import io.micronaut.test.extensions.junit5.annotation.MicronautTest; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Assertions; + +import jakarta.inject.Inject; + +@MicronautTest +class RestcountriesTest { + + @Inject + EmbeddedApplication application; + + @Test + void testItWorks() { + Assertions.assertTrue(application.isRunning()); + } + +}