Implemented BankFinder REST API
This commit is contained in:
parent
93155ed2ef
commit
5195f2d0c3
|
@ -83,6 +83,11 @@ ext {
|
|||
javaFxUtilsVersion = '1.0.8-SNAPSHOT'
|
||||
|
||||
|
||||
/* REST APIs */
|
||||
|
||||
quarkusVersion="1.8.1.Final"
|
||||
|
||||
|
||||
/* Test */
|
||||
|
||||
junitVersion = '4.12'
|
||||
|
|
|
@ -4,4 +4,9 @@ kotlin.code.style=official
|
|||
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx3072m
|
||||
org.gradle.jvmargs=-Xmx3072m
|
||||
|
||||
|
||||
quarkusVersion=1.8.1.Final
|
||||
|
||||
#kotlin.js.compiler=ir
|
|
@ -0,0 +1,5 @@
|
|||
*
|
||||
!build/*-runner
|
||||
!build/*-runner.jar
|
||||
!build/lib/*
|
||||
!build/quarkus-app/*
|
|
@ -0,0 +1,66 @@
|
|||
plugins {
|
||||
id 'org.jetbrains.kotlin.jvm'
|
||||
id "org.jetbrains.kotlin.plugin.allopen" version "1.3.72"
|
||||
id 'io.quarkus'
|
||||
}
|
||||
|
||||
apply plugin: 'java-library'
|
||||
apply plugin: 'kotlin'
|
||||
|
||||
|
||||
|
||||
dependencies {
|
||||
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
|
||||
|
||||
// TODO: why can't Gradle find BankFinder project? .jars have temporarily to be copied to libs folder - which are not committed to repo of course - till this issue is fixed
|
||||
// implementation project(path: ":common", configuration: 'jvmDefault')
|
||||
// implementation project(path: ":BankFinder", configuration: 'jvmDefault')
|
||||
// implementation "net.dankito.banking:BankFinder-jvm:$version"
|
||||
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
|
||||
implementation "net.dankito.utils:java-utils:$javaUtilsVersion"
|
||||
|
||||
implementation enforcedPlatform("io.quarkus:quarkus-universe-bom:$quarkusVersion")
|
||||
implementation 'io.quarkus:quarkus-kotlin'
|
||||
implementation 'io.quarkus:quarkus-resteasy'
|
||||
implementation 'io.quarkus:quarkus-resteasy-jackson'
|
||||
|
||||
testImplementation 'io.quarkus:quarkus-junit5'
|
||||
testImplementation 'io.rest-assured:kotlin-extensions'
|
||||
}
|
||||
|
||||
|
||||
quarkus {
|
||||
setOutputDirectory("$projectDir/build/classes/kotlin/main")
|
||||
}
|
||||
|
||||
quarkusDev {
|
||||
setSourceDir("$projectDir/src/main/kotlin")
|
||||
}
|
||||
|
||||
allOpen {
|
||||
annotation("javax.ws.rs.Path")
|
||||
annotation("javax.enterprise.context.ApplicationScoped")
|
||||
annotation("io.quarkus.test.junit.QuarkusTest")
|
||||
}
|
||||
|
||||
|
||||
def javaVersion = JavaVersion.VERSION_11
|
||||
|
||||
java {
|
||||
sourceCompatibility = javaVersion
|
||||
targetCompatibility = javaVersion
|
||||
}
|
||||
|
||||
compileKotlin {
|
||||
kotlinOptions.jvmTarget = javaVersion
|
||||
kotlinOptions.javaParameters = true
|
||||
}
|
||||
|
||||
compileTestKotlin {
|
||||
kotlinOptions.jvmTarget = javaVersion
|
||||
}
|
||||
test {
|
||||
systemProperty "java.util.logging.manager", "org.jboss.logmanager.LogManager"
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
####
|
||||
# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
|
||||
#
|
||||
# Before building the container image run:
|
||||
#
|
||||
# mvn package -Dquarkus.package.type=fast-jar
|
||||
#
|
||||
# Then, build the image with:
|
||||
#
|
||||
# docker build -f src/main/docker/Dockerfile.fast-jar -t codinux/bank-finder-fast-jar .
|
||||
#
|
||||
# Then run the container using:
|
||||
#
|
||||
# docker run -i --rm -p 8080:8080 codinux/bank-finder-fast-jar
|
||||
#
|
||||
# If you want to include the debug port into your docker image
|
||||
# you will have to expose the debug port (default 5005) like this : EXPOSE 8080 5050
|
||||
#
|
||||
# Then run the container using :
|
||||
#
|
||||
# docker run -i --rm -p 8080:8080 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" codinux/bank-finder-fast-jar
|
||||
#
|
||||
###
|
||||
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.1
|
||||
|
||||
ARG JAVA_PACKAGE=java-11-openjdk-headless
|
||||
ARG RUN_JAVA_VERSION=1.3.8
|
||||
|
||||
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'
|
||||
|
||||
# Install java and the run-java script
|
||||
# Also set up permissions for user `1001`
|
||||
RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \
|
||||
&& microdnf update \
|
||||
&& microdnf clean all \
|
||||
&& mkdir /deployments \
|
||||
&& chown 1001 /deployments \
|
||||
&& chmod "g+rwX" /deployments \
|
||||
&& chown 1001:root /deployments \
|
||||
&& curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \
|
||||
&& chown 1001 /deployments/run-java.sh \
|
||||
&& chmod 540 /deployments/run-java.sh \
|
||||
&& echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/lib/security/java.security
|
||||
|
||||
# Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size.
|
||||
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
|
||||
|
||||
# We make four distinct layers so if there are application changes the library layers can be re-used
|
||||
COPY --chown=1001 build/quarkus-app/lib/ /deployments/lib/
|
||||
COPY --chown=1001 build/quarkus-app/*.jar /deployments/
|
||||
COPY --chown=1001 build/quarkus-app/app/ /deployments/app/
|
||||
COPY --chown=1001 build/quarkus-app/quarkus/ /deployments/quarkus/
|
||||
|
||||
EXPOSE 8080
|
||||
USER 1001
|
||||
|
||||
ENTRYPOINT [ "/deployments/run-java.sh" ]
|
|
@ -0,0 +1,54 @@
|
|||
####
|
||||
# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
|
||||
#
|
||||
# Before building the container image run:
|
||||
#
|
||||
# mvn package
|
||||
#
|
||||
# Then, build the image with:
|
||||
#
|
||||
# docker build -f src/main/docker/Dockerfile.jvm -t codinux/bank-finder-jvm .
|
||||
#
|
||||
# Then run the container using:
|
||||
#
|
||||
# docker run -i --rm -p 8080:8080 codinux/bank-finder-jvm
|
||||
#
|
||||
# If you want to include the debug port into your docker image
|
||||
# you will have to expose the debug port (default 5005) like this : EXPOSE 8080 5050
|
||||
#
|
||||
# Then run the container using :
|
||||
#
|
||||
# docker run -i --rm -p 8080:8080 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" codinux/bank-finder-jvm
|
||||
#
|
||||
###
|
||||
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.1
|
||||
|
||||
ARG JAVA_PACKAGE=java-11-openjdk-headless
|
||||
ARG RUN_JAVA_VERSION=1.3.8
|
||||
|
||||
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'
|
||||
|
||||
# Install java and the run-java script
|
||||
# Also set up permissions for user `1001`
|
||||
RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \
|
||||
&& microdnf update \
|
||||
&& microdnf clean all \
|
||||
&& mkdir /deployments \
|
||||
&& chown 1001 /deployments \
|
||||
&& chmod "g+rwX" /deployments \
|
||||
&& chown 1001:root /deployments \
|
||||
&& curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \
|
||||
&& chown 1001 /deployments/run-java.sh \
|
||||
&& chmod 540 /deployments/run-java.sh \
|
||||
&& echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/lib/security/java.security
|
||||
|
||||
# Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size.
|
||||
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
|
||||
|
||||
COPY build/lib/* /deployments/lib/
|
||||
COPY build/*-runner.jar /deployments/app.jar
|
||||
|
||||
EXPOSE 8080
|
||||
USER 1001
|
||||
|
||||
ENTRYPOINT [ "/deployments/run-java.sh" ]
|
|
@ -0,0 +1,27 @@
|
|||
####
|
||||
# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode
|
||||
#
|
||||
# Before building the container image run:
|
||||
#
|
||||
# mvn package -Pnative -Dquarkus.native.container-build=true
|
||||
#
|
||||
# Then, build the image with:
|
||||
#
|
||||
# docker build -f src/main/docker/Dockerfile.native -t codinux/bank-finder .
|
||||
#
|
||||
# Then run the container using:
|
||||
#
|
||||
# docker run -i --rm -p 8080:8080 codinux/bank-finder
|
||||
#
|
||||
###
|
||||
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.1
|
||||
WORKDIR /work/
|
||||
RUN chown 1001 /work \
|
||||
&& chmod "g+rwX" /work \
|
||||
&& chown 1001:root /work
|
||||
COPY --chown=1001:root build/*-runner /work/application
|
||||
|
||||
EXPOSE 8080
|
||||
USER 1001
|
||||
|
||||
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]
|
|
@ -0,0 +1,25 @@
|
|||
package net.dankito.banking.bankfinder.rest
|
||||
|
||||
import net.dankito.banking.bankfinder.BankInfo
|
||||
import net.dankito.banking.bankfinder.InMemoryBankFinder
|
||||
import org.jboss.resteasy.annotations.jaxrs.PathParam
|
||||
import javax.ws.rs.GET
|
||||
import javax.ws.rs.Path
|
||||
import javax.ws.rs.Produces
|
||||
import javax.ws.rs.core.MediaType
|
||||
|
||||
|
||||
@Path("/bankfinder")
|
||||
class BankFinderResource {
|
||||
|
||||
protected var bankFinder = InMemoryBankFinder()
|
||||
|
||||
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("{query}")
|
||||
fun findBank(@PathParam query: String): List<BankInfo> {
|
||||
return bankFinder.findBankByNameBankCodeOrCity(query)
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
quarkus.http.port=5666
|
|
@ -0,0 +1,6 @@
|
|||
package net.dankito.banking.bankfinder.rest
|
||||
|
||||
import io.quarkus.test.junit.NativeImageTest
|
||||
|
||||
@NativeImageTest
|
||||
class NativeBankFinderResourceIT : ExampleResourceTest()
|
|
@ -0,0 +1,22 @@
|
|||
package net.dankito.banking.bankfinder.rest
|
||||
|
||||
import io.quarkus.test.junit.QuarkusTest
|
||||
import io.restassured.RestAssured.given
|
||||
import org.hamcrest.CoreMatchers.containsString
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
|
||||
@QuarkusTest
|
||||
class BankFinderResourceTest {
|
||||
|
||||
@Test
|
||||
fun testSparkasse() {
|
||||
given()
|
||||
.`when`().get("/bankfinder/Sparkasse")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("Berliner Sparkasse"))
|
||||
.body(containsString("\"bankCode\":\"10050000\""))
|
||||
}
|
||||
|
||||
}
|
|
@ -1,3 +1,14 @@
|
|||
pluginManagement {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
plugins {
|
||||
id 'io.quarkus' version "$quarkusVersion"
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = 'fints4kProject'
|
||||
|
||||
enableFeaturePreview('GRADLE_METADATA')
|
||||
|
@ -45,6 +56,13 @@ project(':LuceneBankingPersistence').projectDir = "$rootDir/persistence/LuceneBa
|
|||
project(':RoomBankingPersistence').projectDir = "$rootDir/persistence/database/RoomBankingPersistence/" as File
|
||||
|
||||
|
||||
/* REST APIs */
|
||||
|
||||
include ':BankFinderRest'
|
||||
|
||||
project(':BankFinderRest').projectDir = "$rootDir/rest/BankFinderRest/" as File
|
||||
|
||||
|
||||
|
||||
/* Tools */
|
||||
|
||||
|
|
Loading…
Reference in New Issue