Skip to content

Commit 8c4dc7e

Browse files
authoredApr 4, 2024··
Feature/kodeverk service (#3449)
Ny tjeneste kodeverk-service som kaller sentralt kodeverk
1 parent 301c3da commit 8c4dc7e

32 files changed

+1309
-67
lines changed
 
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: kodeverk-service
2+
3+
on:
4+
push:
5+
paths:
6+
- libs/security-core
7+
- libs/reactive-core
8+
- libs/reactive-security
9+
- libs/data-transfer-objects
10+
- apps/kodeverk-service/**
11+
- .github/workflows/app.kodeverk-service.yml
12+
13+
jobs:
14+
workflow:
15+
uses: ./.github/workflows/common.workflow.backend.yml
16+
with:
17+
working-directory: "apps/kodeverk-service"
18+
deploy-tag: "#deploy-kodeverk-service"
19+
permissions:
20+
contents: read
21+
id-token: write
22+
secrets: inherit

‎apps/kodeverk-service/Dockerfile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM ghcr.io/navikt/baseimages/temurin:21
2+
LABEL maintainer="Team Dolly"
3+
4+
ENV JAVA_OPTS="-Dspring.profiles.active=prod"
5+
6+
ADD build/libs/app.jar /app/app.jar
7+
8+
EXPOSE 8080

‎apps/kodeverk-service/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Testnav-Kodeverk-Service
2+
Henter, formatterer, og cacher data fra felles kodeverk.
3+
4+
## Swagger
5+
Swagger finnes under [/swagger](https://testnav-kodeverk-service.intern.dev.nav.no/swagger-ui.html) -endepunktet til
6+
applikasjonen.
7+
8+
## Lokal kjøring
9+
Sett profile til dev

‎apps/kodeverk-service/build.gradle

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
plugins {
2+
id 'java'
3+
id "org.sonarqube" version "4.4.1.3373"
4+
id 'org.springframework.boot' version "3.2.1"
5+
id 'io.spring.dependency-management' version "1.1.4"
6+
id "jacoco"
7+
}
8+
9+
test {
10+
useJUnitPlatform()
11+
}
12+
13+
sonarqube {
14+
properties {
15+
property "sonar.dynamicAnalysis", "reuseReports"
16+
property "sonar.host.url", "https://sonarcloud.io"
17+
property "sonar.java.coveragePlugin", "jacoco"
18+
property "sonar.language", "java"
19+
property "sonar.token", System.getenv("SONAR_TOKEN")
20+
property "sonar.organization", "navikt"
21+
property "sonar.project.monorepo.enabled", true
22+
property "sonar.projectKey", "testnav-kodeverk-service"
23+
property "sonar.projectName", "testnav-kodeverk-service"
24+
property "sonar.sourceEncoding", "UTF-8"
25+
}
26+
}
27+
bootJar {
28+
archiveFileName = "app.jar"
29+
}
30+
31+
dependencyManagement {
32+
applyMavenExclusions = false
33+
imports {
34+
mavenBom 'org.springframework.cloud:spring-cloud-dependencies:2023.0.0'
35+
}
36+
}
37+
38+
repositories {
39+
mavenCentral()
40+
mavenLocal()
41+
}
42+
43+
dependencies {
44+
45+
implementation 'no.nav.testnav.libs:security-core'
46+
implementation 'no.nav.testnav.libs:reactive-core'
47+
implementation 'no.nav.testnav.libs:reactive-security'
48+
implementation 'no.nav.testnav.libs:data-transfer-objects'
49+
50+
implementation 'org.springframework.boot:spring-boot-starter-webflux'
51+
implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server'
52+
53+
implementation 'org.springframework.cloud:spring-cloud-starter-vault-config'
54+
implementation 'org.springframework.boot:spring-boot-starter-cache'
55+
56+
implementation 'io.micrometer:micrometer-registry-prometheus'
57+
implementation 'org.springdoc:springdoc-openapi-starter-webflux-ui:2.3.0'
58+
implementation 'io.swagger.core.v3:swagger-annotations-jakarta:2.2.20'
59+
60+
implementation 'net.logstash.logback:logstash-logback-encoder:7.4'
61+
implementation 'org.hibernate.validator:hibernate-validator'
62+
63+
implementation 'com.github.ben-manes.caffeine:caffeine'
64+
implementation 'org.projectlombok:lombok'
65+
annotationProcessor 'org.projectlombok:lombok'
66+
testAnnotationProcessor 'org.projectlombok:lombok'
67+
68+
testImplementation 'org.springframework.boot:spring-boot-starter-test'
69+
}
70+
71+
description = 'kodeverk-service'
72+
java {
73+
toolchain {
74+
languageVersion = JavaLanguageVersion.of(21)
75+
}
76+
}

‎apps/kodeverk-service/config.yml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
apiVersion: "nais.io/v1alpha1"
2+
kind: "Application"
3+
metadata:
4+
name: testnav-kodeverk-service
5+
namespace: dolly
6+
labels:
7+
team: dolly
8+
spec:
9+
image: "{{image}}"
10+
port: 8080
11+
accessPolicy:
12+
inbound:
13+
rules:
14+
- application: app-1
15+
namespace: plattformsikkerhet
16+
- application: dolly-backend
17+
- application: dolly-backend-dev
18+
- application: dolly-frontend
19+
- application: dolly-frontend-dev
20+
- application: dolly-idporten
21+
- application: team-dolly-lokal-app
22+
- application: testnav-oversikt-frontend
23+
- application: testnav-pdl-forvalter
24+
- application: testnav-pdl-forvalter-dev
25+
outbound:
26+
external:
27+
- host: kodeverk-api.nav.no
28+
tokenx:
29+
enabled: true
30+
azure:
31+
application:
32+
allowAllUsers: true
33+
enabled: true
34+
tenant: nav.no
35+
liveness:
36+
path: /internal/isAlive
37+
initialDelay: 4
38+
periodSeconds: 5
39+
failureThreshold: 10
40+
readiness:
41+
path: /internal/isReady
42+
initialDelay: 4
43+
periodSeconds: 5
44+
failureThreshold: 10
45+
prometheus:
46+
enabled: true
47+
path: /internal/metrics
48+
replicas:
49+
min: 1
50+
max: 1
51+
resources:
52+
requests:
53+
cpu: 200m
54+
memory: 2048Mi
55+
limits:
56+
memory: 2048Mi
57+
ingresses:
58+
- "https://testnav-kodeverk-service.intern.dev.nav.no"
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

‎apps/kodeverk-service/gradlew

+234
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
#!/bin/sh
2+
3+
#
4+
# Copyright ? 2015-2021 the original authors.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# https://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
19+
##############################################################################
20+
#
21+
# Gradle start up script for POSIX generated by Gradle.
22+
#
23+
# Important for running:
24+
#
25+
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
26+
# noncompliant, but you have some other compliant shell such as ksh or
27+
# bash, then to run this script, type that shell name before the whole
28+
# command line, like:
29+
#
30+
# ksh Gradle
31+
#
32+
# Busybox and similar reduced shells will NOT work, because this script
33+
# requires all of these POSIX shell features:
34+
# * functions;
35+
# * expansions ?$var?, ?${var}?, ?${var:-default}?, ?${var+SET}?,
36+
# ?${var#prefix}?, ?${var%suffix}?, and ?$( cmd )?;
37+
# * compound commands having a testable exit status, especially ?case?;
38+
# * various built-in commands including ?command?, ?set?, and ?ulimit?.
39+
#
40+
# Important for patching:
41+
#
42+
# (2) This script targets any POSIX shell, so it avoids extensions provided
43+
# by Bash, Ksh, etc; in particular arrays are avoided.
44+
#
45+
# The "traditional" practice of packing multiple parameters into a
46+
# space-separated string is a well documented source of bugs and security
47+
# problems, so this is (mostly) avoided, by progressively accumulating
48+
# options in "$@", and eventually passing that to Java.
49+
#
50+
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
51+
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
52+
# see the in-line comments for details.
53+
#
54+
# There are tweaks for specific operating systems such as AIX, CygWin,
55+
# Darwin, MinGW, and NonStop.
56+
#
57+
# (3) This script is generated from the Groovy template
58+
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59+
# within the Gradle project.
60+
#
61+
# You can find Gradle at https://github.com/gradle/gradle/.
62+
#
63+
##############################################################################
64+
65+
# Attempt to set APP_HOME
66+
67+
# Resolve links: $0 may be a link
68+
app_path=$0
69+
70+
# Need this for daisy-chained symlinks.
71+
while
72+
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
73+
[ -h "$app_path" ]
74+
do
75+
ls=$( ls -ld "$app_path" )
76+
link=${ls#*' -> '}
77+
case $link in #(
78+
/*) app_path=$link ;; #(
79+
*) app_path=$APP_HOME$link ;;
80+
esac
81+
done
82+
83+
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84+
85+
APP_NAME="Gradle"
86+
APP_BASE_NAME=${0##*/}
87+
88+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
90+
91+
# Use the maximum available, or set MAX_FD != -1 to use that value.
92+
MAX_FD=maximum
93+
94+
warn () {
95+
echo "$*"
96+
} >&2
97+
98+
die () {
99+
echo
100+
echo "$*"
101+
echo
102+
exit 1
103+
} >&2
104+
105+
# OS specific support (must be 'true' or 'false').
106+
cygwin=false
107+
msys=false
108+
darwin=false
109+
nonstop=false
110+
case "$( uname )" in #(
111+
CYGWIN* ) cygwin=true ;; #(
112+
Darwin* ) darwin=true ;; #(
113+
MSYS* | MINGW* ) msys=true ;; #(
114+
NONSTOP* ) nonstop=true ;;
115+
esac
116+
117+
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
118+
119+
120+
# Determine the Java command to use to start the JVM.
121+
if [ -n "$JAVA_HOME" ] ; then
122+
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123+
# IBM's JDK on AIX uses strange locations for the executables
124+
JAVACMD=$JAVA_HOME/jre/sh/java
125+
else
126+
JAVACMD=$JAVA_HOME/bin/java
127+
fi
128+
if [ ! -x "$JAVACMD" ] ; then
129+
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130+
131+
Please set the JAVA_HOME variable in your environment to match the
132+
location of your Java installation."
133+
fi
134+
else
135+
JAVACMD=java
136+
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137+
138+
Please set the JAVA_HOME variable in your environment to match the
139+
location of your Java installation."
140+
fi
141+
142+
# Increase the maximum file descriptors if we can.
143+
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144+
case $MAX_FD in #(
145+
max*)
146+
MAX_FD=$( ulimit -H -n ) ||
147+
warn "Could not query maximum file descriptor limit"
148+
esac
149+
case $MAX_FD in #(
150+
'' | soft) :;; #(
151+
*)
152+
ulimit -n "$MAX_FD" ||
153+
warn "Could not set maximum file descriptor limit to $MAX_FD"
154+
esac
155+
fi
156+
157+
# Collect all arguments for the java command, stacking in reverse order:
158+
# * args from the command line
159+
# * the main class name
160+
# * -classpath
161+
# * -D...appname settings
162+
# * --module-path (only if needed)
163+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
164+
165+
# For Cygwin or MSYS, switch paths to Windows format before running java
166+
if "$cygwin" || "$msys" ; then
167+
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
168+
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
169+
170+
JAVACMD=$( cygpath --unix "$JAVACMD" )
171+
172+
# Now convert the arguments - kludge to limit ourselves to /bin/sh
173+
for arg do
174+
if
175+
case $arg in #(
176+
-*) false ;; # don't mess with options #(
177+
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
178+
[ -e "$t" ] ;; #(
179+
*) false ;;
180+
esac
181+
then
182+
arg=$( cygpath --path --ignore --mixed "$arg" )
183+
fi
184+
# Roll the args list around exactly as many times as the number of
185+
# args, so each arg winds up back in the position where it started, but
186+
# possibly modified.
187+
#
188+
# NB: a `for` loop captures its iteration list before it begins, so
189+
# changing the positional parameters here affects neither the number of
190+
# iterations, nor the values presented in `arg`.
191+
shift # remove old arg
192+
set -- "$@" "$arg" # push replacement arg
193+
done
194+
fi
195+
196+
# Collect all arguments for the java command;
197+
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
198+
# shell script including quotes and variable substitutions, so put them in
199+
# double quotes to make sure that they get re-expanded; and
200+
# * put everything else in single quotes, so that it's not re-expanded.
201+
202+
set -- \
203+
"-Dorg.gradle.appname=$APP_BASE_NAME" \
204+
-classpath "$CLASSPATH" \
205+
org.gradle.wrapper.GradleWrapperMain \
206+
"$@"
207+
208+
# Use "xargs" to parse quoted args.
209+
#
210+
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
211+
#
212+
# In Bash we could simply go:
213+
#
214+
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
215+
# set -- "${ARGS[@]}" "$@"
216+
#
217+
# but POSIX shell has neither arrays nor command substitution, so instead we
218+
# post-process each arg (as a line of input to sed) to backslash-escape any
219+
# character that might be a shell metacharacter, then use eval to reverse
220+
# that process (while maintaining the separation between arguments), and wrap
221+
# the whole thing up as a single "set" statement.
222+
#
223+
# This will of course break if any of these variables contains a newline or
224+
# an unmatched quote.
225+
#
226+
227+
eval "set -- $(
228+
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
229+
xargs -n1 |
230+
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
231+
tr '\n' ' '
232+
)" '"$@"'
233+
234+
exec "$JAVACMD" "$@"

‎apps/kodeverk-service/gradlew.bat

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
@rem
2+
@rem Copyright 2015 the original author or authors.
3+
@rem
4+
@rem Licensed under the Apache License, Version 2.0 (the "License");
5+
@rem you may not use this file except in compliance with the License.
6+
@rem You may obtain a copy of the License at
7+
@rem
8+
@rem https://www.apache.org/licenses/LICENSE-2.0
9+
@rem
10+
@rem Unless required by applicable law or agreed to in writing, software
11+
@rem distributed under the License is distributed on an "AS IS" BASIS,
12+
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
@rem See the License for the specific language governing permissions and
14+
@rem limitations under the License.
15+
@rem
16+
17+
@if "%DEBUG%" == "" @echo off
18+
@rem ##########################################################################
19+
@rem
20+
@rem Gradle startup script for Windows
21+
@rem
22+
@rem ##########################################################################
23+
24+
@rem Set local scope for the variables with windows NT shell
25+
if "%OS%"=="Windows_NT" setlocal
26+
27+
set DIRNAME=%~dp0
28+
if "%DIRNAME%" == "" set DIRNAME=.
29+
set APP_BASE_NAME=%~n0
30+
set APP_HOME=%DIRNAME%
31+
32+
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
33+
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34+
35+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36+
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37+
38+
@rem Find java.exe
39+
if defined JAVA_HOME goto findJavaFromJavaHome
40+
41+
set JAVA_EXE=java.exe
42+
%JAVA_EXE% -version >NUL 2>&1
43+
if "%ERRORLEVEL%" == "0" goto execute
44+
45+
echo.
46+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47+
echo.
48+
echo Please set the JAVA_HOME variable in your environment to match the
49+
echo location of your Java installation.
50+
51+
goto fail
52+
53+
:findJavaFromJavaHome
54+
set JAVA_HOME=%JAVA_HOME:"=%
55+
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56+
57+
if exist "%JAVA_EXE%" goto execute
58+
59+
echo.
60+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61+
echo.
62+
echo Please set the JAVA_HOME variable in your environment to match the
63+
echo location of your Java installation.
64+
65+
goto fail
66+
67+
:execute
68+
@rem Setup the command line
69+
70+
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71+
72+
73+
@rem Execute Gradle
74+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75+
76+
:end
77+
@rem End local scope for the variables with windows NT shell
78+
if "%ERRORLEVEL%"=="0" goto mainEnd
79+
80+
:fail
81+
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82+
rem the _cmd.exe /c_ return code!
83+
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84+
exit /b 1
85+
86+
:mainEnd
87+
if "%OS%"=="Windows_NT" endlocal
88+
89+
:omega
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
gradle wrapper

‎apps/kodeverk-service/settings.gradle

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
plugins {
2+
id "com.gradle.enterprise" version "3.12.3"
3+
}
4+
5+
rootProject.name = 'kodeverk-service'
6+
7+
includeBuild '../../libs/security-core'
8+
includeBuild '../../libs/reactive-core'
9+
includeBuild '../../libs/reactive-security'
10+
includeBuild '../../libs/data-transfer-objects'
11+
12+
gradleEnterprise {
13+
buildScan {
14+
termsOfServiceUrl = "https://gradle.com/terms-of-service"
15+
termsOfServiceAgree = "yes"
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package no.nav.testnav.kodeverkservice;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
@SpringBootApplication
7+
public class KodeverkServiceApplicationStarter {
8+
public static void main(String[] args) {
9+
SpringApplication.run(KodeverkServiceApplicationStarter.class, args);
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package no.nav.testnav.kodeverkservice.config;
2+
3+
import no.nav.testnav.libs.reactivecore.config.CoreConfig;
4+
import no.nav.testnav.libs.reactivesecurity.config.SecureOAuth2ServerToServerConfiguration;
5+
import org.springframework.context.annotation.Configuration;
6+
import org.springframework.context.annotation.Import;
7+
8+
@Configuration
9+
@Import({
10+
CoreConfig.class,
11+
SecureOAuth2ServerToServerConfiguration.class
12+
})
13+
public class AppConfig {
14+
}
15+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package no.nav.testnav.kodeverkservice.config;
2+
3+
import com.github.benmanes.caffeine.cache.Caffeine;
4+
import org.springframework.cache.CacheManager;
5+
import org.springframework.cache.annotation.EnableCaching;
6+
import org.springframework.cache.caffeine.CaffeineCacheManager;
7+
import org.springframework.cache.support.NoOpCacheManager;
8+
import org.springframework.context.annotation.Bean;
9+
import org.springframework.context.annotation.Configuration;
10+
import org.springframework.context.annotation.Profile;
11+
12+
import java.util.concurrent.TimeUnit;
13+
14+
@Configuration(enforceUniqueMethods = false)
15+
@EnableCaching
16+
public class CacheConfig {
17+
18+
public static final String CACHE_KODEVERK = "kodeverk";
19+
public static final String CACHE_KODEVERK_2 = "kodeverk-2";
20+
21+
@Bean
22+
@Profile("prod")
23+
public CacheManager cacheManager(Caffeine caffeine) {
24+
25+
var caffeineCacheManager = new CaffeineCacheManager(CACHE_KODEVERK,
26+
CACHE_KODEVERK_2);
27+
caffeineCacheManager.setCaffeine(caffeine);
28+
caffeineCacheManager.setAsyncCacheMode(true);
29+
return caffeineCacheManager;
30+
}
31+
32+
@Bean
33+
@Profile("dev")
34+
public CacheManager getNoOpCacheManager() {
35+
36+
return new NoOpCacheManager();
37+
}
38+
39+
@Bean
40+
public Caffeine<Object, Object> caffeineConfig() {
41+
42+
return Caffeine.newBuilder().expireAfterWrite(12, TimeUnit.HOURS);
43+
}
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package no.nav.testnav.kodeverkservice.config;
2+
3+
import lombok.Getter;
4+
import lombok.NoArgsConstructor;
5+
import lombok.Setter;
6+
import no.nav.testnav.libs.securitycore.domain.ServerProperties;
7+
import org.springframework.boot.context.properties.ConfigurationProperties;
8+
import org.springframework.context.annotation.Configuration;
9+
10+
import static lombok.AccessLevel.PACKAGE;
11+
12+
@Configuration
13+
@ConfigurationProperties(prefix = "consumers")
14+
@NoArgsConstructor(access = PACKAGE)
15+
@Getter
16+
@Setter(PACKAGE)
17+
public class Consumers {
18+
19+
private ServerProperties kodeverkApi;
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package no.nav.testnav.kodeverkservice.config;
2+
3+
import org.springframework.context.annotation.Configuration;
4+
import org.springframework.context.annotation.Profile;
5+
import org.springframework.vault.annotation.VaultPropertySource;
6+
import org.springframework.vault.authentication.ClientAuthentication;
7+
import org.springframework.vault.authentication.TokenAuthentication;
8+
import org.springframework.vault.client.VaultEndpoint;
9+
import org.springframework.vault.config.AbstractVaultConfiguration;
10+
11+
import static io.micrometer.common.util.StringUtils.isBlank;
12+
13+
@Configuration
14+
@Profile("dev")
15+
@VaultPropertySource(value = "secret/dolly/lokal", ignoreSecretNotFound = false)
16+
public class DevConfig extends AbstractVaultConfiguration {
17+
18+
private static final String VAULT_TOKEN = "spring.cloud.vault.token";
19+
20+
@Override
21+
public VaultEndpoint vaultEndpoint() {
22+
return VaultEndpoint.create("vault.adeo.no", 443);
23+
}
24+
25+
@Override
26+
public ClientAuthentication clientAuthentication() {
27+
if (System.getenv().containsKey("VAULT_TOKEN")) {
28+
System.setProperty(VAULT_TOKEN, System.getenv("VAULT_TOKEN"));
29+
}
30+
var token = System.getProperty(VAULT_TOKEN);
31+
if (isBlank(token)) {
32+
throw new IllegalArgumentException("Påkrevet property 'spring.cloud.vault.token' er ikke satt.");
33+
}
34+
return new TokenAuthentication(System.getProperty(VAULT_TOKEN));
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package no.nav.testnav.kodeverkservice.config;
2+
3+
import io.swagger.v3.oas.models.Components;
4+
import io.swagger.v3.oas.models.OpenAPI;
5+
import io.swagger.v3.oas.models.info.Contact;
6+
import io.swagger.v3.oas.models.info.Info;
7+
import io.swagger.v3.oas.models.info.License;
8+
import io.swagger.v3.oas.models.security.SecurityRequirement;
9+
import io.swagger.v3.oas.models.security.SecurityScheme;
10+
import no.nav.testnav.libs.reactivecore.config.ApplicationProperties;
11+
import org.springframework.context.annotation.Bean;
12+
import org.springframework.context.annotation.Configuration;
13+
import org.springframework.http.HttpHeaders;
14+
import org.springframework.web.server.ServerWebExchange;
15+
import org.springframework.web.server.WebFilter;
16+
import org.springframework.web.server.WebFilterChain;
17+
import reactor.core.publisher.Mono;
18+
19+
import java.util.Arrays;
20+
21+
@Configuration
22+
public class OpenApiConfig implements WebFilter {
23+
24+
@Bean
25+
public OpenAPI openApi(ApplicationProperties applicationProperties) {
26+
return new OpenAPI()
27+
.components(new Components().addSecuritySchemes("bearer-jwt", new SecurityScheme()
28+
.type(SecurityScheme.Type.HTTP)
29+
.scheme("bearer")
30+
.bearerFormat("JWT")
31+
.in(SecurityScheme.In.HEADER)
32+
.name(HttpHeaders.AUTHORIZATION)
33+
))
34+
.addSecurityItem(
35+
new SecurityRequirement().addList("bearer-jwt", Arrays.asList("read", "write")))
36+
.info(new Info()
37+
.title(applicationProperties.getName())
38+
.version(applicationProperties.getVersion())
39+
.description(applicationProperties.getDescription())
40+
.termsOfService("https://nav.no")
41+
.contact(new Contact()
42+
.url("https://nav-it.slack.com/archives/CA3P9NGA2")
43+
.email("dolly@nav.no")
44+
.name("Team Dolly")
45+
)
46+
.license(new License()
47+
.name("MIT License")
48+
.url("https://opensource.org/licenses/MIT")
49+
)
50+
);
51+
}
52+
53+
@Override
54+
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
55+
if (exchange.getRequest().getURI().getPath().equals("/swagger")) {
56+
return chain
57+
.filter(exchange.mutate()
58+
.request(exchange.getRequest()
59+
.mutate().path("/swagger-ui.html").build())
60+
.build());
61+
}
62+
63+
return chain.filter(exchange);
64+
}
65+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package no.nav.testnav.kodeverkservice.config;
2+
3+
import lombok.RequiredArgsConstructor;
4+
import lombok.extern.slf4j.Slf4j;
5+
import no.nav.testnav.libs.reactivesecurity.manager.JwtReactiveAuthenticationManager;
6+
import org.springframework.context.annotation.Bean;
7+
import org.springframework.context.annotation.Configuration;
8+
import org.springframework.security.config.annotation.method.configuration.EnableReactiveMethodSecurity;
9+
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
10+
import org.springframework.security.config.web.server.ServerHttpSecurity;
11+
import org.springframework.security.web.server.SecurityWebFilterChain;
12+
13+
@Slf4j
14+
@Configuration
15+
@EnableWebFluxSecurity
16+
@EnableReactiveMethodSecurity
17+
@RequiredArgsConstructor
18+
public class SecurityConfig {
19+
20+
private final JwtReactiveAuthenticationManager jwtReactiveAuthenticationManager;
21+
22+
@Bean
23+
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity httpSecurity) {
24+
return httpSecurity
25+
.csrf(ServerHttpSecurity.CsrfSpec::disable)
26+
.authorizeExchange(authorizeConfig -> authorizeConfig.pathMatchers(
27+
"/internal/**",
28+
"/webjars/**",
29+
"/v3/api-docs/**",
30+
"/swagger-ui/**",
31+
"/swagger",
32+
"/error",
33+
"/swagger-ui.html"
34+
).permitAll().anyExchange().authenticated())
35+
.oauth2ResourceServer(oauth2RSConfig -> oauth2RSConfig.jwt(jwtSpec -> jwtSpec.authenticationManager(jwtReactiveAuthenticationManager)))
36+
.build();
37+
}
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package no.nav.testnav.kodeverkservice.consumer;
2+
3+
import no.nav.testnav.kodeverkservice.config.Consumers;
4+
import no.nav.testnav.kodeverkservice.consumer.command.KodeverkGetCommand;
5+
import no.nav.testnav.kodeverkservice.dto.KodeverkBetydningerResponse;
6+
import no.nav.testnav.libs.reactivesecurity.exchange.TokenExchange;
7+
import no.nav.testnav.libs.securitycore.domain.ServerProperties;
8+
import org.springframework.stereotype.Service;
9+
import org.springframework.web.reactive.function.client.ExchangeStrategies;
10+
import org.springframework.web.reactive.function.client.WebClient;
11+
import reactor.core.publisher.Mono;
12+
13+
@Service
14+
public class KodeverkConsumer {
15+
16+
private final TokenExchange tokenService;
17+
private final WebClient webClient;
18+
private final ServerProperties serverProperties;
19+
20+
public KodeverkConsumer(
21+
TokenExchange tokenService,
22+
Consumers consumers,
23+
WebClient.Builder webClientBuilder
24+
) {
25+
this.tokenService = tokenService;
26+
serverProperties = consumers.getKodeverkApi();
27+
this.webClient = webClientBuilder
28+
.exchangeStrategies(
29+
ExchangeStrategies
30+
.builder()
31+
.codecs(configurer -> configurer
32+
.defaultCodecs()
33+
.maxInMemorySize(32 * 1024 * 1024))
34+
.build())
35+
.baseUrl(serverProperties.getUrl())
36+
.build();
37+
}
38+
39+
public Mono<KodeverkBetydningerResponse> getKodeverk(String kodeverk) {
40+
41+
return tokenService.exchange(serverProperties)
42+
.flatMap(token -> new KodeverkGetCommand(webClient, kodeverk, token.getTokenValue()).call());
43+
}
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package no.nav.testnav.kodeverkservice.consumer.command;
2+
3+
import lombok.RequiredArgsConstructor;
4+
import no.nav.testnav.kodeverkservice.dto.KodeverkBetydningerResponse;
5+
import no.nav.testnav.libs.reactivecore.utils.WebClientFilter;
6+
import org.springframework.http.HttpHeaders;
7+
import org.springframework.web.reactive.function.client.WebClient;
8+
import reactor.core.publisher.Mono;
9+
import reactor.util.retry.Retry;
10+
11+
import java.time.Duration;
12+
import java.util.concurrent.Callable;
13+
14+
import static no.nav.testnav.kodeverkservice.utility.CallIdUtil.generateCallId;
15+
import static no.nav.testnav.kodeverkservice.utility.CommonKeysAndUtils.CONSUMER;
16+
import static no.nav.testnav.kodeverkservice.utility.CommonKeysAndUtils.HEADER_NAV_CALL_ID;
17+
import static no.nav.testnav.kodeverkservice.utility.CommonKeysAndUtils.HEADER_NAV_CONSUMER_ID;
18+
19+
@RequiredArgsConstructor
20+
public class KodeverkGetCommand implements Callable<Mono<KodeverkBetydningerResponse>> {
21+
22+
private static final String KODEVERK_URL_BEGINNING = "/api/v1/kodeverk";
23+
private static final String KODEVERK_URL_KODER = "koder";
24+
private static final String KODEVERK_URL_BETYDNINGER = "betydninger";
25+
26+
private final WebClient webClient;
27+
private final String kodeverk;
28+
private final String token;
29+
30+
@Override
31+
public Mono<KodeverkBetydningerResponse> call() {
32+
33+
return webClient
34+
.get()
35+
.uri(uriBuilder -> uriBuilder
36+
.path(KODEVERK_URL_BEGINNING)
37+
.pathSegment(kodeverk)
38+
.pathSegment(KODEVERK_URL_KODER)
39+
.pathSegment(KODEVERK_URL_BETYDNINGER)
40+
.queryParam("ekskluderUgyldige", true)
41+
.queryParam("spraak", "nb")
42+
.build())
43+
.header(HttpHeaders.AUTHORIZATION, "Bearer " + token)
44+
.header(HEADER_NAV_CONSUMER_ID, CONSUMER)
45+
.header(HEADER_NAV_CALL_ID, generateCallId())
46+
.retrieve()
47+
.bodyToMono(KodeverkBetydningerResponse.class)
48+
.retryWhen(Retry.backoff(3, Duration.ofSeconds(5))
49+
.filter(WebClientFilter::is5xxException));
50+
}
51+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package no.nav.testnav.kodeverkservice.dto;
2+
3+
import static java.util.Objects.isNull;
4+
5+
import java.time.LocalDate;
6+
import java.util.HashMap;
7+
import java.util.List;
8+
import java.util.Map;
9+
10+
import lombok.AllArgsConstructor;
11+
import lombok.Builder;
12+
import lombok.Data;
13+
import lombok.NoArgsConstructor;
14+
15+
@Data
16+
@Builder
17+
@NoArgsConstructor
18+
@AllArgsConstructor
19+
public class KodeverkBetydningerResponse {
20+
21+
private Map<String, List<Betydning>> betydninger;
22+
23+
public Map<String, List<Betydning>> getBetydninger() {
24+
25+
if (isNull(betydninger)) {
26+
betydninger = new HashMap<>();
27+
}
28+
return this.betydninger;
29+
}
30+
31+
@Data
32+
@Builder
33+
@NoArgsConstructor
34+
@AllArgsConstructor
35+
public static class Betydning {
36+
37+
private LocalDate gyldigFra;
38+
private LocalDate gyldigTil;
39+
private Map<String, Beskrivelse> beskrivelser;
40+
41+
public Map<String, Beskrivelse> getBeskrivelser() {
42+
if (isNull(beskrivelser)) {
43+
beskrivelser = new HashMap<>();
44+
}
45+
return beskrivelser;
46+
}
47+
}
48+
49+
@Data
50+
@Builder
51+
@NoArgsConstructor
52+
@AllArgsConstructor
53+
public static class Beskrivelse {
54+
55+
private String term;
56+
private String tekst;
57+
}
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package no.nav.testnav.kodeverkservice.provider;
2+
3+
import io.swagger.v3.oas.annotations.Operation;
4+
import lombok.RequiredArgsConstructor;
5+
import no.nav.testnav.kodeverkservice.service.KodeverkService;
6+
import no.nav.testnav.libs.dto.kodeverkservice.v1.KodeverkAdjustedDTO;
7+
import no.nav.testnav.libs.dto.kodeverkservice.v1.KodeverkDTO;
8+
import org.springframework.cache.annotation.Cacheable;
9+
import org.springframework.validation.annotation.Validated;
10+
import org.springframework.web.bind.annotation.GetMapping;
11+
import org.springframework.web.bind.annotation.PathVariable;
12+
import org.springframework.web.bind.annotation.RequestMapping;
13+
import org.springframework.web.bind.annotation.RequestParam;
14+
import org.springframework.web.bind.annotation.RestController;
15+
import reactor.core.publisher.Mono;
16+
17+
import static no.nav.testnav.kodeverkservice.config.CacheConfig.CACHE_KODEVERK;
18+
import static no.nav.testnav.kodeverkservice.config.CacheConfig.CACHE_KODEVERK_2;
19+
20+
@RestController
21+
@RequestMapping("/api/v1/kodeverk")
22+
@Validated
23+
@RequiredArgsConstructor
24+
public class KodeverkController {
25+
26+
private final KodeverkService kodeverkService;
27+
28+
@Cacheable(value = CACHE_KODEVERK, unless = "#result.kodeverk?.size() == 0")
29+
@GetMapping
30+
@Operation(description = "Hent kodeverk, returnerer map")
31+
public Mono<KodeverkDTO> fetchKodeverk(@RequestParam String kodeverk) {
32+
33+
return kodeverkService.getKodeverkMap(kodeverk);
34+
}
35+
36+
@Cacheable(value = CACHE_KODEVERK_2, unless = "#result.koder?.size() == 0")
37+
@GetMapping("/{kodeverkNavn}")
38+
@Operation(description = "Hent kodeverk etter kodeverkNavn")
39+
public Mono<KodeverkAdjustedDTO> getKodeverkByName(@PathVariable("kodeverkNavn") String kodeverkNavn) {
40+
41+
return kodeverkService.getKodeverkByName(kodeverkNavn);
42+
}
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package no.nav.testnav.kodeverkservice.service;
2+
3+
import lombok.RequiredArgsConstructor;
4+
import lombok.extern.slf4j.Slf4j;
5+
import no.nav.testnav.kodeverkservice.consumer.KodeverkConsumer;
6+
import no.nav.testnav.kodeverkservice.dto.KodeverkBetydningerResponse;
7+
import no.nav.testnav.libs.dto.kodeverkservice.v1.KodeverkAdjustedDTO;
8+
import no.nav.testnav.libs.dto.kodeverkservice.v1.KodeverkAdjustedDTO.KodeAdjusted;
9+
import no.nav.testnav.libs.dto.kodeverkservice.v1.KodeverkDTO;
10+
import org.springframework.stereotype.Service;
11+
import reactor.core.publisher.Mono;
12+
13+
import java.time.LocalDate;
14+
import java.util.Comparator;
15+
import java.util.List;
16+
import java.util.Map;
17+
import java.util.stream.Collectors;
18+
19+
import static java.util.Objects.nonNull;
20+
21+
@Slf4j
22+
@Service
23+
@RequiredArgsConstructor
24+
public class KodeverkService {
25+
26+
private final KodeverkConsumer kodeverkConsumer;
27+
28+
public Mono<KodeverkAdjustedDTO> getKodeverkByName(String kodeverknavn) {
29+
30+
return kodeverkConsumer.getKodeverk(kodeverknavn)
31+
.map(kodeverk -> kodeverk.getBetydninger().entrySet())
32+
.map(betydninger -> KodeverkAdjustedDTO.builder()
33+
.name(kodeverknavn)
34+
.koder(betydninger.stream()
35+
.filter(entry -> nonNull(entry.getValue()) && !entry.getValue().isEmpty())
36+
.map(KodeverkService::getKodeAdjusted)
37+
.sorted(Comparator.comparing(KodeverkAdjustedDTO.KodeAdjusted::getLabel))
38+
.toList())
39+
.build());
40+
}
41+
42+
public Mono<KodeverkDTO> getKodeverkMap(String kodeverknavn) {
43+
44+
return kodeverkConsumer.getKodeverk(kodeverknavn)
45+
.map(kodeverk -> kodeverk.getBetydninger().entrySet().stream()
46+
.filter(entry -> nonNull(entry.getValue()) && !entry.getValue().isEmpty())
47+
.filter(entry -> LocalDate.now().isAfter(getBetydning(entry).getGyldigFra()) &&
48+
LocalDate.now().isBefore(getBetydning(entry).getGyldigTil()))
49+
.collect(Collectors.toMap(Map.Entry::getKey, KodeverkService::getNorskBokmaal)))
50+
.map(resultat -> KodeverkDTO.builder()
51+
.kodeverknavn(kodeverknavn)
52+
.kodeverk(resultat)
53+
.build());
54+
}
55+
56+
private static KodeAdjusted getKodeAdjusted(Map.Entry<String, List<KodeverkBetydningerResponse.Betydning>> entry) {
57+
58+
return KodeAdjusted.builder()
59+
.label(getNorskBokmaal(entry))
60+
.gyldigFra(getBetydning(entry).getGyldigFra())
61+
.gyldigTil(getBetydning(entry).getGyldigTil())
62+
.value(entry.getKey())
63+
.build();
64+
}
65+
66+
private static KodeverkBetydningerResponse.Betydning getBetydning(Map.Entry<String, List<KodeverkBetydningerResponse.Betydning>> entry) {
67+
68+
return entry.getValue().getFirst();
69+
}
70+
71+
private static String getNorskBokmaal(Map.Entry<String, List<KodeverkBetydningerResponse.Betydning>> entry) {
72+
73+
return getBetydning(entry).getBeskrivelser().get("nb").getTerm();
74+
}
75+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package no.nav.testnav.kodeverkservice.utility;
2+
3+
import lombok.experimental.UtilityClass;
4+
5+
import java.util.UUID;
6+
7+
import static java.lang.String.format;
8+
import static no.nav.testnav.kodeverkservice.utility.CommonKeysAndUtils.CONSUMER;
9+
10+
@UtilityClass
11+
public final class CallIdUtil {
12+
13+
public static String generateCallId() {
14+
return format("%s-%s", CONSUMER, UUID.randomUUID());
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package no.nav.testnav.kodeverkservice.utility;
2+
3+
import lombok.experimental.UtilityClass;
4+
5+
@UtilityClass
6+
public final class CommonKeysAndUtils {
7+
8+
public static final String HEADER_NAV_CONSUMER_ID = "Nav-Consumer-Id";
9+
public static final String HEADER_NAV_CALL_ID = "Nav-Call-Id";
10+
public static final String CONSUMER = "Dolly";
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
spring:
3+
security:
4+
oauth2:
5+
resourceserver:
6+
tokenx:
7+
issuer-uri: ${TOKEN_X_ISSUER}
8+
jwk-set-uri: ${TOKEN_X_JWKS_URI}
9+
accepted-audience: ${TOKEN_X_CLIENT_ID}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b
2+
3+
spring:
4+
application:
5+
name: testnav-kodeverk-service
6+
description: Tjeneste for å hente fra felles kodeverk
7+
security:
8+
oauth2:
9+
resourceserver:
10+
aad:
11+
issuer-uri: ${AAD_ISSUER_URI}/v2.0
12+
jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys
13+
accepted-audience: ${azure.app.client.id}, api://${azure.app.client.id}
14+
cloud:
15+
vault:
16+
enabled: false
17+
18+
springdoc:
19+
swagger-ui:
20+
disable-swagger-default-url: true
21+
url: /v3/api-docs
22+
23+
management:
24+
endpoints:
25+
enabled-by-default: true
26+
web:
27+
base-path: /internal
28+
exposure.include: prometheus,heapdump,health
29+
path-mapping:
30+
prometheus: metrics
31+
endpoint:
32+
prometheus.enabled: true
33+
heapdump.enabled: true
34+
prometheus:
35+
metrics:
36+
export:
37+
enabled: true
38+
server:
39+
servlet:
40+
encoding:
41+
charset: UTF-8
42+
error:
43+
include-message: always
44+
45+
consumers:
46+
kodeverk-api:
47+
name: kodeverk-api
48+
namespace: team-rocket
49+
url: https://kodeverk-api.nav.no
50+
cluster: prod-gcp
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<configuration>
3+
<springProfile name="prod">
4+
<appender name="stdout_json" class="ch.qos.logback.core.ConsoleAppender">
5+
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
6+
<throwableConverter class="net.logstash.logback.stacktrace.ShortenedThrowableConverter">
7+
<rootCauseFirst>true</rootCauseFirst>
8+
<maxDepthPerThrowable>256</maxDepthPerThrowable>
9+
<maxLength>10280</maxLength>
10+
<shortenedClassNameLength>20</shortenedClassNameLength>
11+
<exclude>^sun\.reflect\..*\.invoke</exclude>
12+
<exclude>^net\.sf\.cglib\.proxy\.MethodProxy\.invoke</exclude>
13+
<exclude>java\.util\.concurrent\..*</exclude>
14+
<exclude>org\.apache\.catalina\..*</exclude>
15+
<exclude>org\.apache\.coyote\..*</exclude>
16+
<exclude>org\.apache\.tomcat\..*</exclude>
17+
</throwableConverter>
18+
</encoder>
19+
</appender>
20+
<root level="INFO">
21+
<appender-ref ref="stdout_json"/>
22+
</root>
23+
</springProfile>
24+
25+
<springProfile name="dev">
26+
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
27+
<encoder>
28+
<pattern>
29+
%d{HH:mm:ss.SSS} | %5p | %logger{25} | %m%n
30+
</pattern>
31+
<charset>utf8</charset>
32+
</encoder>
33+
</appender>
34+
<root level="INFO">
35+
<appender-ref ref="CONSOLE"/>
36+
</root>
37+
</springProfile>
38+
39+
<logger level="TRACE" name="no.nav.testnav.libs.servletcore.logging.LogRequestInterceptor" />
40+
</configuration>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package no.nav.testnav.kodeverkservice;
2+
3+
import org.junit.jupiter.api.DisplayName;
4+
import org.junit.jupiter.api.Test;
5+
import org.springframework.boot.test.context.SpringBootTest;
6+
import org.springframework.boot.test.mock.mockito.MockBean;
7+
import org.springframework.security.oauth2.jwt.JwtDecoder;
8+
import org.springframework.test.context.ActiveProfiles;
9+
10+
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
11+
12+
@SpringBootTest
13+
@ActiveProfiles("test")
14+
public class ApplicationContextTest {
15+
16+
@MockBean
17+
public JwtDecoder jwtDecoder;
18+
19+
@Test
20+
@DisplayName("Application context should load")
21+
void load_app_context() {
22+
assertThat(true).isTrue();
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package no.nav.testnav.libs.dto.kodeverkservice.v1;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Builder;
5+
import lombok.Data;
6+
import lombok.NoArgsConstructor;
7+
8+
import java.time.LocalDate;
9+
import java.util.ArrayList;
10+
import java.util.List;
11+
12+
import static java.util.Objects.isNull;
13+
14+
@Data
15+
@Builder
16+
@NoArgsConstructor
17+
@AllArgsConstructor
18+
public class KodeverkAdjustedDTO {
19+
20+
private String name;
21+
private List<KodeAdjusted> koder;
22+
23+
public List<KodeAdjusted> getKoder() {
24+
if (isNull(koder)) {
25+
koder = new ArrayList<>();
26+
}
27+
return koder;
28+
}
29+
30+
@Data
31+
@Builder
32+
@NoArgsConstructor
33+
@AllArgsConstructor
34+
public static class KodeAdjusted {
35+
36+
private String label;
37+
private String value;
38+
private LocalDate gyldigFra;
39+
private LocalDate gyldigTil;
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package no.nav.testnav.libs.dto.kodeverkservice.v1;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Builder;
5+
import lombok.Data;
6+
import lombok.NoArgsConstructor;
7+
8+
import java.util.HashMap;
9+
import java.util.Map;
10+
11+
import static java.util.Objects.isNull;
12+
13+
@Data
14+
@Builder
15+
@NoArgsConstructor
16+
@AllArgsConstructor
17+
public class KodeverkDTO {
18+
19+
private String kodeverknavn;
20+
private Map<String, String> kodeverk;
21+
22+
public Map<String, String> getKodeverk() {
23+
24+
if (isNull(kodeverk)) {
25+
kodeverk = new HashMap<>();
26+
}
27+
return kodeverk;
28+
}
29+
}

‎settings.gradle

+68-67
Original file line numberDiff line numberDiff line change
@@ -21,106 +21,107 @@ gradleEnterprise {
2121
}
2222
}
2323

24-
includeBuild './proxies/udistub-proxy'
25-
includeBuild './proxies/skjermingsregister-proxy'
24+
includeBuild './proxies/aareg-proxy'
25+
includeBuild './proxies/aareg-synt-services-proxy'
26+
includeBuild './proxies/arbeidsplassencv-proxy'
27+
includeBuild './proxies/arena-forvalteren-proxy'
2628
includeBuild './proxies/batch-adeo-proxy'
27-
includeBuild './proxies/saf-proxy'
28-
includeBuild './proxies/modapp-ereg-proxy'
29+
includeBuild './proxies/brregstub-proxy'
2930
includeBuild './proxies/dokarkiv-proxy'
30-
includeBuild './proxies/tps-forvalteren-proxy'
31-
includeBuild './proxies/aareg-synt-services-proxy'
32-
includeBuild './proxies/pdl-proxy'
3331
includeBuild './proxies/ereg-proxy'
32+
includeBuild './proxies/histark-proxy'
3433
includeBuild './proxies/inntektstub-proxy'
35-
includeBuild './proxies/brregstub-proxy'
36-
includeBuild './proxies/arena-forvalteren-proxy'
34+
includeBuild './proxies/inst-proxy'
35+
includeBuild './proxies/kontoregister-person-proxy'
3736
includeBuild './proxies/krrstub-proxy'
3837
includeBuild './proxies/medl-proxy'
39-
includeBuild './proxies/sigrunstub-proxy'
40-
includeBuild './proxies/pensjon-testdata-facade-proxy'
38+
includeBuild './proxies/modapp-ereg-proxy'
4139
includeBuild './proxies/norg2-proxy'
40+
includeBuild './proxies/pdl-proxy'
41+
includeBuild './proxies/pensjon-testdata-facade-proxy'
42+
includeBuild './proxies/saf-proxy'
43+
includeBuild './proxies/sigrunstub-proxy'
44+
includeBuild './proxies/skjermingsregister-proxy'
4245
includeBuild './proxies/synthdata-meldekort-proxy'
43-
includeBuild './proxies/kontoregister-person-proxy'
44-
includeBuild './proxies/inst-proxy'
45-
includeBuild './proxies/aareg-proxy'
46-
includeBuild './proxies/histark-proxy'
47-
includeBuild './proxies/arbeidsplassencv-proxy'
46+
includeBuild './proxies/tps-forvalteren-proxy'
47+
includeBuild './proxies/udistub-proxy'
4848

49-
includeBuild './libs/security-token-service'
50-
includeBuild './libs/data-transfer-objects'
51-
includeBuild './libs/data-transfer-search-objects'
52-
includeBuild './libs/reactive-proxy'
53-
includeBuild './libs/reactive-core'
54-
includeBuild './libs/servlet-core'
55-
includeBuild './libs/servlet-security'
56-
includeBuild './libs/reactive-security'
57-
includeBuild './libs/reactive-frontend'
58-
includeBuild './libs/testing'
59-
includeBuild './libs/commands'
60-
includeBuild './libs/kafka-config'
61-
includeBuild './libs/kafka-producers'
6249
includeBuild './libs/avro-schema'
50+
includeBuild './libs/commands'
6351
includeBuild './libs/csv-converter'
52+
includeBuild './libs/data-transfer-objects'
53+
includeBuild './libs/data-transfer-search-objects'
6454
includeBuild './libs/database'
6555
includeBuild './libs/domain'
66-
includeBuild './libs/slack'
56+
includeBuild './libs/integration-test'
57+
includeBuild './libs/kafka-config'
58+
includeBuild './libs/kafka-producers'
59+
includeBuild './libs/reactive-core'
60+
includeBuild './libs/reactive-frontend'
61+
includeBuild './libs/reactive-proxy'
62+
includeBuild './libs/reactive-security'
6763
includeBuild './libs/reactive-session-security'
6864
includeBuild './libs/security-core'
65+
includeBuild './libs/security-token-service'
66+
includeBuild './libs/servlet-core'
6967
includeBuild './libs/servlet-insecure-security'
70-
includeBuild './libs/integration-test'
68+
includeBuild './libs/servlet-security'
69+
includeBuild './libs/slack'
70+
includeBuild './libs/testing'
7171

72-
includeBuild './apps/person-service'
73-
includeBuild './apps/profil-api'
74-
includeBuild './apps/faste-data-frontend'
75-
includeBuild './apps/oversikt-frontend'
76-
includeBuild './apps/endringsmelding-frontend'
77-
includeBuild './apps/endringsmelding-service'
7872
includeBuild './apps/adresse-service'
79-
includeBuild './apps/pdl-forvalter'
8073
includeBuild './apps/amelding-service'
74+
includeBuild './apps/app-tilgang-analyse-service'
8175
includeBuild './apps/arbeidsforhold-service'
82-
includeBuild './apps/varslinger-service'
83-
includeBuild './apps/dolly-frontend'
76+
includeBuild './apps/batch-bestilling-service'
77+
includeBuild './apps/brreg-stub'
78+
includeBuild './apps/bruker-service'
8479
includeBuild './apps/budpro-service'
8580
includeBuild './apps/dolly-backend'
86-
includeBuild './apps/synt-sykemelding-api'
87-
includeBuild './apps/jenkins-batch-status-service'
88-
includeBuild './apps/organisasjon-bestilling-service'
89-
includeBuild './apps/geografiske-kodeverk-service'
90-
includeBuild './apps/udi-stub'
91-
includeBuild './apps/app-tilgang-analyse-service'
92-
includeBuild './apps/organisasjon-forvalter'
93-
includeBuild './apps/organisasjon-tilgang-service'
94-
includeBuild './apps/person-organisasjon-tilgang-service'
95-
includeBuild './apps/bruker-service'
96-
includeBuild './apps/testnorge-statisk-data-forvalter'
97-
includeBuild './apps/generer-arbeidsforhold-populasjon-service'
98-
includeBuild './apps/brreg-stub'
81+
includeBuild './apps/dolly-frontend'
82+
includeBuild './apps/dollystatus'
83+
includeBuild './apps/endringsmelding-frontend'
84+
includeBuild './apps/endringsmelding-service'
9985
includeBuild './apps/ereg-batch-status-service'
86+
includeBuild './apps/faste-data-frontend'
87+
includeBuild './apps/generer-arbeidsforhold-populasjon-service'
10088
includeBuild './apps/generer-navn-service'
10189
includeBuild './apps/generer-organisasjon-populasjon-service'
10290
includeBuild './apps/generer-synt-amelding-service'
91+
includeBuild './apps/geografiske-kodeverk-service'
10392
includeBuild './apps/helsepersonell-service'
104-
includeBuild './apps/miljoer-service'
105-
includeBuild './apps/batch-bestilling-service'
106-
includeBuild './apps/joark-dokument-service'
107-
includeBuild './apps/inntektsmelding-service'
10893
includeBuild './apps/inntektsmelding-generator-service'
109-
includeBuild './apps/orgnummer-service'
110-
includeBuild './apps/organisasjon-mottak-service'
111-
includeBuild './apps/organisasjon-faste-data-service'
94+
includeBuild './apps/inntektsmelding-service'
95+
includeBuild './apps/jenkins-batch-status-service'
96+
includeBuild './apps/joark-dokument-service'
97+
includeBuild './apps/kodeverk-service'
98+
includeBuild './apps/miljoer-service'
11299
includeBuild './apps/oppsummeringsdokument-service'
113-
includeBuild './apps/sykemelding-api'
114-
includeBuild './apps/person-search-service'
115-
includeBuild './apps/person-faste-data-service'
100+
includeBuild './apps/organisasjon-bestilling-service'
101+
includeBuild './apps/organisasjon-faste-data-service'
102+
includeBuild './apps/organisasjon-forvalter'
103+
includeBuild './apps/organisasjon-mottak-service'
116104
includeBuild './apps/organisasjon-service'
117-
includeBuild './apps/tilbakemelding-api'
118-
includeBuild './apps/tps-messaging-service'
119105
includeBuild './apps/organisasjon-tilgang-frontend'
106+
includeBuild './apps/organisasjon-tilgang-service'
107+
includeBuild './apps/orgnummer-service'
108+
includeBuild './apps/oversikt-frontend'
109+
includeBuild './apps/pdl-forvalter'
110+
includeBuild './apps/person-faste-data-service'
111+
includeBuild './apps/person-organisasjon-tilgang-service'
112+
includeBuild './apps/person-search-service'
113+
includeBuild './apps/person-service'
114+
includeBuild './apps/profil-api'
115+
includeBuild './apps/sykemelding-api'
116+
includeBuild './apps/synt-sykemelding-api'
120117
includeBuild './apps/synt-vedtakshistorikk-service'
121-
includeBuild './apps/testnav-ident-pool'
122118
includeBuild './apps/tenor-search-service'
123-
includeBuild './apps/dollystatus'
119+
includeBuild './apps/testnav-ident-pool'
120+
includeBuild './apps/testnorge-statisk-data-forvalter'
121+
includeBuild './apps/tilbakemelding-api'
122+
includeBuild './apps/tps-messaging-service'
123+
includeBuild './apps/udi-stub'
124+
includeBuild './apps/varslinger-service'
124125

125126
includeBuild './xsd/arbeidsforhold-xsd'
126127

0 commit comments

Comments
 (0)
Please sign in to comment.