diff --git a/felles/feil/src/test/java/no/nav/vedtak/feil/AbstractFeilTestIT.java b/felles/feil/src/test/java/no/nav/vedtak/feil/AbstractFeilTestIT.java index c69b782d1..0b531c730 100644 --- a/felles/feil/src/test/java/no/nav/vedtak/feil/AbstractFeilTestIT.java +++ b/felles/feil/src/test/java/no/nav/vedtak/feil/AbstractFeilTestIT.java @@ -20,7 +20,7 @@ import no.nav.vedtak.feil.deklarasjon.ManglerTilgangFeil; import no.nav.vedtak.feil.deklarasjon.TekniskFeil; -public abstract class AbstractFeilTestIT { +abstract class AbstractFeilTestIT { private static List> deklarerteFeil = FeilUtil.finnAlleDeklarerteFeil(); @@ -35,7 +35,7 @@ public abstract class AbstractFeilTestIT { protected abstract List getForventedePrefix(); @Test - public void skal_ha_at_alle_metoder_i_interface_med_deklarerte_feil_har_nøyaktig_én_feilannotering() throws Exception { + void skal_ha_at_alle_metoder_i_interface_med_deklarerte_feil_har_nøyaktig_én_feilannotering() throws Exception { StringBuilder error = new StringBuilder(); for (Class deklareringsinterface : deklarerteFeil) { @@ -60,7 +60,7 @@ public abstract class AbstractFeilTestIT { } @Test - public void skal_ha_at_feilkoder_følger_mønster_slik_at_de_er_gjenkjennbare_og_unike_på_tvers_av_applikasjoner() throws Exception { + void skal_ha_at_feilkoder_følger_mønster_slik_at_de_er_gjenkjennbare_og_unike_på_tvers_av_applikasjoner() throws Exception { String prefixMønster = "(" + String.join("|", getForventedePrefix()) + ")"; String tallMønster = "\\d{6}"; Pattern mønster = Pattern.compile("^" + prefixMønster + "-" + tallMønster + "$"); @@ -81,7 +81,7 @@ public abstract class AbstractFeilTestIT { } @Test - public void skal_ha_unike_feilkoder_for_alle_deklarerte_feil() throws Exception { + void skal_ha_unike_feilkoder_for_alle_deklarerte_feil() throws Exception { Map> feilPrFeilkode = new TreeMap<>(); for (Class deklareringsinterface : deklarerteFeil) { @@ -117,7 +117,7 @@ public void skal_ha_unike_feilkoder_for_alle_deklarerte_feil() throws Exception } @Test - public void skal_ha_pattern_for_alle_parametre_som_er_oppgitt() throws Exception { + void skal_ha_pattern_for_alle_parametre_som_er_oppgitt() throws Exception { StringBuilder error = new StringBuilder(); for (Class deklareringsinterface : deklarerteFeil) { for (Method method : deklareringsinterface.getDeclaredMethods()) { diff --git a/felles/feil/src/test/java/no/nav/vedtak/feil/FeilFactoryTest.java b/felles/feil/src/test/java/no/nav/vedtak/feil/FeilFactoryTest.java index ad55ea9a6..5e3d6a988 100644 --- a/felles/feil/src/test/java/no/nav/vedtak/feil/FeilFactoryTest.java +++ b/felles/feil/src/test/java/no/nav/vedtak/feil/FeilFactoryTest.java @@ -12,10 +12,10 @@ import no.nav.vedtak.feil.deklarasjon.ManglerTilgangFeil; import no.nav.vedtak.feil.deklarasjon.TekniskFeil; -public class FeilFactoryTest { +class FeilFactoryTest { @Test - public void skal_generere_teknisk_feil_basert_på_annoteringer_og_parametre_og_exception() throws Exception { + void skal_generere_teknisk_feil_basert_på_annoteringer_og_parametre_og_exception() throws Exception { Exception cause = new IOException("Klarte ikke å mounte filsystem"); Feil feil = FeilFactory.create(TestFeil.class).kritiskOppstartsfeil("foo", cause); assertThat(feil.getKode()).isEqualTo("TestFeil-1"); @@ -25,7 +25,7 @@ public class FeilFactoryTest { } @Test - public void skal_generere_integrasjonfeil_basert_på_annoteringer_og_parametre() throws Exception { + void skal_generere_integrasjonfeil_basert_på_annoteringer_og_parametre() throws Exception { Feil feil = FeilFactory.create(TestFeil.class).tpsTimeout(30); assertThat(feil.getKode()).isEqualTo("TestFeil-3"); assertThat(feil.getLogLevel()).isEqualTo(Level.WARN); @@ -33,7 +33,7 @@ public class FeilFactoryTest { } @Test - public void skal_generere_ikkeTilgangFeil() throws Exception { + void skal_generere_ikkeTilgangFeil() throws Exception { Feil feil = FeilFactory.create(TestFeil.class).ikkeTilgang(); assertThat(feil.getKode()).isEqualTo("TestFeil-6"); assertThat(feil.getLogLevel()).isEqualTo(Level.INFO); @@ -41,7 +41,7 @@ public void skal_generere_ikkeTilgangFeil() throws Exception { } @Test - public void skal_generere_funksjonell_feil_basert_på_annoteringer_og_parametre() throws Exception { + void skal_generere_funksjonell_feil_basert_på_annoteringer_og_parametre() throws Exception { Feil feil = FeilFactory.create(TestFeil.class).manglerFødselsvilkår(1337); assertThat(feil.getKode()).isEqualTo("TestFeil-2"); assertThat(feil.getLogLevel()).isEqualTo(Level.WARN); @@ -52,7 +52,7 @@ public void skal_generere_ikkeTilgangFeil() throws Exception { } @Test - public void skal_ta_med_parameter_som_cause_når_det_bare_er_ett_parameter_og_det_er_en_exception() throws Exception { + void skal_ta_med_parameter_som_cause_når_det_bare_er_ett_parameter_og_det_er_en_exception() throws Exception { IllegalArgumentException cause = new IllegalArgumentException("#5235"); Feil feil = FeilFactory.create(TestFeil.class).feilArgument(cause); assertThat(feil.getCause()).isEqualTo(cause); diff --git a/felles/feil/src/test/java/no/nav/vedtak/feil/FeilTest.java b/felles/feil/src/test/java/no/nav/vedtak/feil/FeilTest.java index e04a25418..249576456 100644 --- a/felles/feil/src/test/java/no/nav/vedtak/feil/FeilTest.java +++ b/felles/feil/src/test/java/no/nav/vedtak/feil/FeilTest.java @@ -14,13 +14,13 @@ import no.nav.vedtak.exception.TekniskException; import no.nav.vedtak.exception.VLException; -public class FeilTest { +class FeilTest { private static final Logger logger = LoggerFactory.getLogger(FeilTest.class); private static final String FEIL_KODE = "DUMMY_FEIL_KODE"; @Test - public void skal_kunne_konvertere_feil_til_exception() { + void skal_kunne_konvertere_feil_til_exception() { Feil feil = new Feil(FEIL_KODE, "noe gikk galt", LogLevel.ERROR, TekniskException.class, null); VLException exception = feil.toException(); assertThat(exception.getMessage()).isEqualTo(feil.toLogString()); @@ -28,7 +28,7 @@ public void skal_kunne_konvertere_feil_til_exception() { } @Test - public void skal_kunne_konvertere_feil_til_exception_og_ta_med_cause() { + void skal_kunne_konvertere_feil_til_exception_og_ta_med_cause() { RuntimeException cause = new RuntimeException("Væææ!"); Feil feil = new Feil(FEIL_KODE, "noe gikk galt", LogLevel.ERROR, TekniskException.class, cause); VLException exception = feil.toException(); @@ -38,7 +38,7 @@ public void skal_kunne_konvertere_feil_til_exception_og_ta_med_cause() { } @Test - public void skal_kunne_konvertere_funksjonell_feil_til_funksjonell_exception() { + void skal_kunne_konvertere_funksjonell_feil_til_funksjonell_exception() { RuntimeException cause = new RuntimeException("Væææ!"); Feil feil = new FunksjonellFeil(FEIL_KODE, "funksjonellFeil", "test", LogLevel.WARN, FunksjonellException.class, cause); assertThat(feil.getLogLevel()).isSameAs(Level.WARN); @@ -51,14 +51,14 @@ public void skal_kunne_konvertere_funksjonell_feil_til_funksjonell_exception() { } @Test - public void skal_ikke_kunne_konvertere_feil_til_funksjonell_exception() { + void skal_ikke_kunne_konvertere_feil_til_funksjonell_exception() { RuntimeException cause = new RuntimeException("Væææ!"); Feil feil = new Feil(FEIL_KODE, "funksjonellFeil", LogLevel.WARN, FunksjonellException.class, cause); assertThrows(IllegalStateException.class, () -> feil.toException()); } @Test - public void skal_støtte_feil_med_loglevel_INFO() { + void skal_støtte_feil_med_loglevel_INFO() { RuntimeException cause = new RuntimeException("Væææ!"); Feil feil = new Feil(FEIL_KODE, "integrasjonFeil", LogLevel.INFO, IntegrasjonException.class, cause); assertThat(feil.getLogLevel()).isSameAs(Level.INFO); @@ -71,7 +71,7 @@ public void skal_ikke_kunne_konvertere_feil_til_funksjonell_exception() { } @Test - public void skal_kunne_konvertere_feil_til_mangler_tilgang_exception() { + void skal_kunne_konvertere_feil_til_mangler_tilgang_exception() { RuntimeException cause = new RuntimeException("Væææ!"); Feil feil = new Feil(FEIL_KODE, "manglerTilgangFeil", LogLevel.ERROR, ManglerTilgangException.class, cause); assertThat(feil.getLogLevel()).isSameAs(Level.ERROR); diff --git a/felles/feil/src/test/java/no/nav/vedtak/feil/FeilUtil.java b/felles/feil/src/test/java/no/nav/vedtak/feil/FeilUtil.java index ef85e2e67..6a93c3b66 100644 --- a/felles/feil/src/test/java/no/nav/vedtak/feil/FeilUtil.java +++ b/felles/feil/src/test/java/no/nav/vedtak/feil/FeilUtil.java @@ -11,15 +11,16 @@ import no.nav.vedtak.feil.deklarasjon.ManglerTilgangFeil; import no.nav.vedtak.feil.deklarasjon.TekniskFeil; -public class FeilUtil { +class FeilUtil { @SuppressWarnings("unchecked") - public static List> finnAlleDeklarerteFeil() { + static List> finnAlleDeklarerteFeil() { List> deklarerteFeil = new ArrayList<>(); try (var scanResult = new ClassGraph().enableClassInfo().ignoreClassVisibility().scan();) { - scanResult.getSubclasses(DeklarerteFeil.class.getName()).forEach(c -> deklarerteFeil.add((Class) c.loadClass())); + scanResult.getSubclasses(DeklarerteFeil.class.getName()) + .forEach(c -> deklarerteFeil.add((Class) c.loadClass())); } - + // ikke noen grunn til å ta med feil som er deklarert i test-scope i denne // modulen deklarerteFeil.remove(FeilFactoryTest.TestFeil.class); @@ -27,7 +28,7 @@ public static List> finnAlleDeklarerteFeil() { return deklarerteFeil; } - public static String feilkode(Method method) { + static String feilkode(Method method) { TekniskFeil t = method.getAnnotation(TekniskFeil.class); FunksjonellFeil f = method.getAnnotation(FunksjonellFeil.class); IntegrasjonFeil i = method.getAnnotation(IntegrasjonFeil.class); @@ -47,7 +48,7 @@ public static String feilkode(Method method) { return null; } - public static LogLevel logLevel(Method method) { + static LogLevel logLevel(Method method) { TekniskFeil t = method.getAnnotation(TekniskFeil.class); FunksjonellFeil f = method.getAnnotation(FunksjonellFeil.class); IntegrasjonFeil i = method.getAnnotation(IntegrasjonFeil.class); @@ -67,7 +68,7 @@ public static LogLevel logLevel(Method method) { return null; } - public static String type(Method method) { + static String type(Method method) { TekniskFeil t = method.getAnnotation(TekniskFeil.class); FunksjonellFeil f = method.getAnnotation(FunksjonellFeil.class); IntegrasjonFeil i = method.getAnnotation(IntegrasjonFeil.class); @@ -87,7 +88,7 @@ public static String type(Method method) { return null; } - public static String feilmelding(Method method) { + static String feilmelding(Method method) { TekniskFeil t = method.getAnnotation(TekniskFeil.class); FunksjonellFeil f = method.getAnnotation(FunksjonellFeil.class); IntegrasjonFeil i = method.getAnnotation(IntegrasjonFeil.class); @@ -107,7 +108,7 @@ public static String feilmelding(Method method) { return null; } - public static String løsningsforslag(Method method) { + static String løsningsforslag(Method method) { FunksjonellFeil f = method.getAnnotation(FunksjonellFeil.class); if (f != null) { return f.løsningsforslag(); @@ -115,17 +116,17 @@ public static String feilmelding(Method method) { return null; } - public static boolean harMedCause(Method method) { + static boolean harMedCause(Method method) { return method.getParameterCount() > 0 - && Throwable.class.isAssignableFrom(method.getParameterTypes()[method.getParameterCount() - 1]); + && Throwable.class.isAssignableFrom(method.getParameterTypes()[method.getParameterCount() - 1]); } - public static int tellParametreUtenomCause(Method method) { + static int tellParametreUtenomCause(Method method) { return harMedCause(method) ? method.getParameterCount() - 1 : method.getParameterCount(); } @SuppressWarnings("unchecked") - public static Class deklarertCause(Method method) { + static Class deklarertCause(Method method) { return (Class) method.getParameters()[method.getParameterCount() - 1].getType(); } } diff --git a/felles/log/src/test/java/no/nav/vedtak/log/sporingslogg/SporingsdataTest.java b/felles/log/src/test/java/no/nav/vedtak/log/sporingslogg/SporingsdataTest.java index f3b31dfa9..fdb987136 100644 --- a/felles/log/src/test/java/no/nav/vedtak/log/sporingslogg/SporingsdataTest.java +++ b/felles/log/src/test/java/no/nav/vedtak/log/sporingslogg/SporingsdataTest.java @@ -4,15 +4,15 @@ import org.junit.jupiter.api.Test; -public class SporingsdataTest { +class SporingsdataTest { @Test - public void skalInitialisereForMedGyldigeArgs() { + void skalInitialisereForMedGyldigeArgs() { assertThat(Sporingsdata.opprett("login").keySet()).isEmpty(); } @Test - public void skalHuskeIder() { + void skalHuskeIder() { Sporingsdata sporingsdata = Sporingsdata.opprett("login"); sporingsdata.leggTilId(StandardSporingsloggId.AKTOR_ID, "1001"); assertThat(sporingsdata.getVerdi(StandardSporingsloggId.AKTOR_ID)).isEqualTo("1001"); diff --git a/felles/log/src/test/java/no/nav/vedtak/log/util/LoggerUtilsTest.java b/felles/log/src/test/java/no/nav/vedtak/log/util/LoggerUtilsTest.java index fe602a360..956480bde 100644 --- a/felles/log/src/test/java/no/nav/vedtak/log/util/LoggerUtilsTest.java +++ b/felles/log/src/test/java/no/nav/vedtak/log/util/LoggerUtilsTest.java @@ -4,26 +4,26 @@ import org.junit.jupiter.api.Test; -public class LoggerUtilsTest { +class LoggerUtilsTest { @Test - public void removeLineBreaksSkalFjerneCR() { + void removeLineBreaksSkalFjerneCR() { - assertThat(LoggerUtils.removeLineBreaks("\r")).isEqualTo(""); + assertThat(LoggerUtils.removeLineBreaks("\r")).isEmpty(); assertThat(LoggerUtils.removeLineBreaks("a\rb")).isEqualTo("ab"); assertThat(LoggerUtils.removeLineBreaks("\ra\rb")).isEqualTo("ab"); } @Test - public void removeLineBreaksSkalFjerneLF() { + void removeLineBreaksSkalFjerneLF() { - assertThat(LoggerUtils.removeLineBreaks("\n")).isEqualTo(""); + assertThat(LoggerUtils.removeLineBreaks("\n")).isEmpty(); assertThat(LoggerUtils.removeLineBreaks("a\nb")).isEqualTo("ab"); assertThat(LoggerUtils.removeLineBreaks("\na\n\nb")).isEqualTo("ab"); } @Test - public void removeLineBreaksSkalTakleNull() { + void removeLineBreaksSkalTakleNull() { assertThat(LoggerUtils.removeLineBreaks(null)).isNull(); } } diff --git a/felles/log/src/test/java/no/nav/vedtak/log/util/MdcExtendedLogContextTest.java b/felles/log/src/test/java/no/nav/vedtak/log/util/MdcExtendedLogContextTest.java index 688db5f77..b0582d186 100644 --- a/felles/log/src/test/java/no/nav/vedtak/log/util/MdcExtendedLogContextTest.java +++ b/felles/log/src/test/java/no/nav/vedtak/log/util/MdcExtendedLogContextTest.java @@ -9,17 +9,17 @@ import no.nav.vedtak.log.mdc.MdcExtendedLogContext; -public class MdcExtendedLogContextTest { +class MdcExtendedLogContextTest { private MdcExtendedLogContext context = MdcExtendedLogContext.getContext("prosess"); @AfterEach - public void clear() { + void clear() { MDC.clear(); } @Test - public void skal_legge_til_ny_verdi() throws Exception { + void skal_legge_til_ny_verdi() throws Exception { context.add("behandling", 1L); assertThat(context.getFullText()).isEqualTo("prosess[behandling=1]"); @@ -32,7 +32,7 @@ public void skal_legge_til_ny_verdi() throws Exception { } @Test - public void skal_hente_key_part() throws Exception { + void skal_hente_key_part() throws Exception { context.add("behandling", 1L); context.add("fagsak", 2L); context.add("prosess", 3L); @@ -40,7 +40,7 @@ public void skal_hente_key_part() throws Exception { } @Test - public void skal_fjerne_verdi() throws Exception { + void skal_fjerne_verdi() throws Exception { context.add("behandling", 1L); context.add("fagsak", 2L); context.add("prosess", 3L); @@ -59,7 +59,7 @@ public void skal_fjerne_verdi() throws Exception { } @Test - public void skal_fjerne_verdi_i_midten() throws Exception { + void skal_fjerne_verdi_i_midten() throws Exception { context.add("behandling", 1L); context.add("fagsak", 2L); context.add("prosess", 3L); @@ -78,17 +78,17 @@ public void skal_fjerne_verdi_i_midten() throws Exception { } @Test - public void skal_sjekke_ugyldig_key_left_bracket() { + void skal_sjekke_ugyldig_key_left_bracket() { assertThrows(IllegalArgumentException.class, () -> context.add("fdss[", 1L)); } @Test - public void skal_sjekke_ugyldig_key_right_bracket() { + void skal_sjekke_ugyldig_key_right_bracket() { assertThrows(IllegalArgumentException.class, () -> context.add("fd]ss", 1L)); } @Test - public void skal_sjekke_ugyldig_key_semicolon() { + void skal_sjekke_ugyldig_key_semicolon() { assertThrows(IllegalArgumentException.class, () -> context.add("fdss;", 1L)); } } diff --git a/felles/util/src/main/java/no/nav/vedtak/util/Tuple.java b/felles/util/src/main/java/no/nav/vedtak/util/Tuple.java index 81180a18b..16c78b3e9 100644 --- a/felles/util/src/main/java/no/nav/vedtak/util/Tuple.java +++ b/felles/util/src/main/java/no/nav/vedtak/util/Tuple.java @@ -4,6 +4,10 @@ public class Tuple { private final X element1; private final Y element2; + public static Tuple of(X element1, Y element2) { + return new Tuple<>(element1, element2); + } + public Tuple(X element1, Y element2) { java.util.Objects.requireNonNull(element1); java.util.Objects.requireNonNull(element2); @@ -22,8 +26,10 @@ public Y getElement2() { @Override public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof Tuple)) return false; + if (this == o) + return true; + if (!(o instanceof Tuple)) + return false; Tuple tuple = (Tuple) o; diff --git a/felles/util/src/test/java/no/nav/vedtak/konfig/KonfigVerdiTest.java b/felles/util/src/test/java/no/nav/vedtak/konfig/KonfigVerdiTest.java index 9ef420742..edf1d69ec 100644 --- a/felles/util/src/test/java/no/nav/vedtak/konfig/KonfigVerdiTest.java +++ b/felles/util/src/test/java/no/nav/vedtak/konfig/KonfigVerdiTest.java @@ -11,7 +11,7 @@ import no.nav.vedtak.util.env.Environment; -public class KonfigVerdiTest { +class KonfigVerdiTest { private static final String NAV = "http://www.nav.no"; private static final String KEY = "my.test.property"; @@ -55,7 +55,7 @@ public static void setupSystemPropertyForTest() { @Test @EnabledIfEnvironmentVariable(named = "mvn", matches = "true") - public void propertyFil() throws Exception { + void propertyFil() throws Exception { assertThat(propFraFil).isEqualTo(42); assertThat(propFraFilOverride).isEqualTo(200); assertThat(systemVinner).isEqualTo(50); @@ -64,36 +64,36 @@ public void propertyFil() throws Exception { } @Test - public void defaultVerdier() throws Exception { - assertThat(defaultNotUsed).isEqualTo(0); + void defaultVerdier() throws Exception { + assertThat(defaultNotUsed).isZero(); assertThat(stringProperty).isEqualTo("42"); - assertThat(booleanDefaultProperty).isEqualTo(true); + assertThat(booleanDefaultProperty).isTrue(); assertThat(intDefaultProperty).isEqualTo(42); assertThat(uriDefaultProperty).isEqualTo(URI.create(NAV)); } @Test - public void skal_injisere_konfig() throws Exception { + void skal_injisere_konfig() throws Exception { assertThat(javaHome).isNotNull(); } @Test - public void skal_injisere_verdi_fra_systemproperties() throws Exception { + void skal_injisere_verdi_fra_systemproperties() throws Exception { assertThat(myProperty).isEqualTo(VALUE); } @Test - public void skal_injisere_integer_fra_systemproperties() throws Exception { + void skal_injisere_integer_fra_systemproperties() throws Exception { assertThat(myIntegerPropertyValue).isEqualTo(39); } @Test - public void skal_injisere_boolean_fra_systemproperties() throws Exception { - assertThat(myBooleanPropertyValue).isEqualTo(false); + void skal_injisere_boolean_fra_systemproperties() throws Exception { + assertThat(myBooleanPropertyValue).isFalse(); } @Test - public void skal_injisere_local_date_fra_systemproperties() throws Exception { + void skal_injisere_local_date_fra_systemproperties() throws Exception { assertThat(myLocalDateValue).isEqualTo(LocalDate.of(1989, 9, 29)); } } diff --git a/felles/util/src/test/java/no/nav/vedtak/konfig/doc/DummyKonfigVerdi.java b/felles/util/src/test/java/no/nav/vedtak/konfig/doc/DummyKonfigVerdi.java deleted file mode 100644 index add40e892..000000000 --- a/felles/util/src/test/java/no/nav/vedtak/konfig/doc/DummyKonfigVerdi.java +++ /dev/null @@ -1,18 +0,0 @@ -package no.nav.vedtak.konfig.doc; - -import no.nav.vedtak.konfig.KonfigVerdi; - -@SuppressWarnings("unused") -public class DummyKonfigVerdi { - - @KonfigVerdi("test.felt") - private String konfigVerdi; - - private String ikkeKonfigVerdi; - - public DummyKonfigVerdi() { - } - - public DummyKonfigVerdi(@KonfigVerdi("test.ctor") String annenKonfigVerdi) { - } -} diff --git a/felles/util/src/test/java/no/nav/vedtak/konfig/doc/KonfigverdiDocletTest.java b/felles/util/src/test/java/no/nav/vedtak/konfig/doc/KonfigverdiDocletTest.java deleted file mode 100644 index d3bee92fb..000000000 --- a/felles/util/src/test/java/no/nav/vedtak/konfig/doc/KonfigverdiDocletTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package no.nav.vedtak.konfig.doc; - -import java.io.File; - -import javax.tools.DiagnosticCollector; -import javax.tools.DocumentationTool; -import javax.tools.DocumentationTool.DocumentationTask; -import javax.tools.JavaCompiler; -import javax.tools.JavaFileObject; -import javax.tools.StandardJavaFileManager; -import javax.tools.ToolProvider; - -import org.junit.jupiter.api.Test; - -public class KonfigverdiDocletTest { - @Test - public void test_generer_javadoc_for_WebService() throws Exception { - DocumentationTool documentationTool = ToolProvider.getSystemDocumentationTool(); - JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); - DiagnosticCollector diagnostics = new DiagnosticCollector<>(); - - try (StandardJavaFileManager fm = compiler.getStandardFileManager(diagnostics, null, null)) { - Iterable javaFileObjects = fm - .getJavaFileObjects(new File("src/test/java/no/nav/vedtak/konfig/doc/DummyKonfigVerdi.java")); - DocumentationTask task = documentationTool.getTask(null, fm, null, KonfigverdiDoclet.class, null, javaFileObjects); - - task.call(); - } - } -} diff --git a/felles/util/src/test/java/no/nav/vedtak/util/LRUCacheTest.java b/felles/util/src/test/java/no/nav/vedtak/util/LRUCacheTest.java index f59d7558d..c12501001 100644 --- a/felles/util/src/test/java/no/nav/vedtak/util/LRUCacheTest.java +++ b/felles/util/src/test/java/no/nav/vedtak/util/LRUCacheTest.java @@ -6,7 +6,7 @@ import org.junit.jupiter.api.Test; -public class LRUCacheTest { +class LRUCacheTest { private static final int CACHE_STØRRELSE = 2; private static final Long GYLDIGHET_I_MS = TimeUnit.MICROSECONDS.convert(1, TimeUnit.HOURS); @@ -18,12 +18,12 @@ public LRUCacheTest() { } @Test - public void skal_returnere_null_når_cache_er_tom() { + void skal_returnere_null_når_cache_er_tom() { assertThat(cache.get(1L)).isNull(); } @Test - public void skal_legge_til_nye_innslag() { + void skal_legge_til_nye_innslag() { cache.put(1L, "1"); assertThat(cache.get(1L)).isEqualTo("1"); assertThat(cache.get(2L)).isNull(); @@ -33,7 +33,7 @@ public void skal_legge_til_nye_innslag() { } @Test - public void skal_slette_eldste_innslag_når_kapasiteten_er_nådd() { + void skal_slette_eldste_innslag_når_kapasiteten_er_nådd() { cache.put(1L, "1"); cache.put(2L, "4"); cache.put(3L, "9"); @@ -44,7 +44,7 @@ public void skal_legge_til_nye_innslag() { } @Test - public void skal_fornye_innslag() { + void skal_fornye_innslag() { cache.put(1L, "1"); cache.put(2L, "4"); assertThat(cache.get(1L)).isEqualTo("1"); @@ -55,7 +55,7 @@ public void skal_fornye_innslag() { } @Test - public void cache_innslag_skal_expire() throws Exception { + void cache_innslag_skal_expire() throws Exception { this.cache = new LRUCache<>(CACHE_STØRRELSE, 2L); cache.put(1L, "1"); Thread.sleep(4L); // NOSONAR @@ -63,7 +63,7 @@ public void cache_innslag_skal_expire() throws Exception { } @Test - public void skal_legge_til_og_slette_key() throws Exception { + void skal_legge_til_og_slette_key() throws Exception { cache.put(1L, "1"); assertThat(cache.get(1L)).isNotNull(); cache.remove(1L); @@ -71,12 +71,12 @@ public void skal_legge_til_og_slette_key() throws Exception { } @Test - public void skal_slette_key_som_ikke_eksister() throws Exception { + void skal_slette_key_som_ikke_eksister() throws Exception { cache.remove(1L); } @Test - public void skal_oppdatere_eksisterende_key() throws Exception { + void skal_oppdatere_eksisterende_key() throws Exception { cache.put(1L, "1"); cache.put(1L, "2"); assertThat(cache.get(1L)).isEqualTo("2"); diff --git a/felles/util/src/test/java/no/nav/vedtak/util/StringUtilsTest.java b/felles/util/src/test/java/no/nav/vedtak/util/StringUtilsTest.java index ce4b17055..dfc8885c3 100644 --- a/felles/util/src/test/java/no/nav/vedtak/util/StringUtilsTest.java +++ b/felles/util/src/test/java/no/nav/vedtak/util/StringUtilsTest.java @@ -4,10 +4,10 @@ import org.junit.jupiter.api.Test; -public class StringUtilsTest { +class StringUtilsTest { @Test - public void skal_gjennkjenne_blankStreng() { + void skal_gjennkjenne_blankStreng() { assertThat(StringUtils.isBlank(null)).isTrue(); assertThat(StringUtils.isBlank("")).isTrue(); @@ -22,7 +22,7 @@ public void skal_gjennkjenne_blankStreng() { } @Test - public void skal_gjennkjenne_nullEllerTomStreng() { + void skal_gjennkjenne_nullEllerTomStreng() { assertThat(StringUtils.nullOrEmpty(null)).isTrue(); assertThat(StringUtils.nullOrEmpty("")).isTrue(); diff --git a/felles/util/src/test/java/no/nav/vedtak/util/TupleTest.java b/felles/util/src/test/java/no/nav/vedtak/util/TupleTest.java index 1f1b47924..e096ee9bd 100644 --- a/felles/util/src/test/java/no/nav/vedtak/util/TupleTest.java +++ b/felles/util/src/test/java/no/nav/vedtak/util/TupleTest.java @@ -4,74 +4,59 @@ import org.junit.jupiter.api.Test; -public class TupleTest { +class TupleTest { @Test - public void test_ctor_og_getters() { - - Tuple tuple = new Tuple<>("ab", 3); - + void test_ctor_og_getters() { + var tuple = Tuple.of("ab", 3); assertThat(tuple.getElement1()).isEqualTo("ab"); assertThat(tuple.getElement2()).isEqualTo(3); } @Test - public void test_equals_felter() { - - Tuple tuple1 = new Tuple<>("ab", 3); - Tuple tuple2 = new Tuple<>("ab", 3); - Tuple tuple3 = new Tuple<>("ab", 100); - Tuple tuple4 = new Tuple<>("c", 3); - - assertThat(tuple1.equals(tuple2)).isTrue(); - assertThat(tuple1.hashCode()).isEqualTo(tuple2.hashCode()); - assertThat(tuple1.equals(tuple3)).isFalse(); - assertThat(tuple1.equals(tuple4)).isFalse(); + void test_equals_felter() { + var tuple1 = Tuple.of("ab", 3); + var tuple2 = Tuple.of("ab", 3); + var tuple3 = Tuple.of("ab", 100); + var tuple4 = Tuple.of("c", 3); + assertThat(tuple1).isEqualTo(tuple2) + .hasSameHashCodeAs(tuple2) + .isNotEqualTo(tuple3) + .isNotEqualTo(tuple4); } @Test - public void test_equals_reflexive() { - - Tuple tuple = new Tuple<>("ab", 3); - - assertThat(tuple.equals(tuple)).isTrue(); + void test_equals_reflexive() { + var tuple = Tuple.of("ab", 3); + assertThat(tuple).isEqualTo(tuple); } @Test - public void test_equals_symmetric() { - - Tuple tuple1 = new Tuple<>("ab", 3); - Tuple tuple2 = new Tuple<>("ab", 3); - - assertThat(tuple1.equals(tuple2)).isTrue(); - assertThat(tuple2.equals(tuple1)).isTrue(); - - Tuple tuple3 = new Tuple<>("c", 3); - - assertThat(tuple1.equals(tuple3)).isFalse(); - assertThat(tuple3.equals(tuple1)).isFalse(); + void test_equals_symmetric() { + var tuple1 = Tuple.of("ab", 3); + var tuple2 = Tuple.of("ab", 3); + assertThat(tuple1).isEqualTo(tuple2); } @Test - public void test_equals_transitive() { + void test_equals_transitive() { - Tuple tuple1 = new Tuple<>("ab", 3); - Tuple tuple2 = new Tuple<>("ab", 3); - Tuple tuple3 = new Tuple<>("ab", 3); + var tuple1 = Tuple.of("ab", 3); + var tuple2 = Tuple.of("ab", 3); + var tuple3 = Tuple.of("ab", 3); - assertThat(tuple1.equals(tuple2)).isTrue(); - assertThat(tuple1.hashCode()).isEqualTo(tuple2.hashCode()); - assertThat(tuple2.equals(tuple3)).isTrue(); - assertThat(tuple2.hashCode()).isEqualTo(tuple3.hashCode()); - assertThat(tuple1.equals(tuple3)).isTrue(); - assertThat(tuple1.hashCode()).isEqualTo(tuple3.hashCode()); + assertThat(tuple1).isEqualTo(tuple2) + .hasSameHashCodeAs(tuple2) + .isEqualTo(tuple3) + .hasSameHashCodeAs(tuple3); + + assertThat(tuple2).isEqualTo(tuple3) + .hasSameHashCodeAs(tuple3); } @Test - public void test_equals_null() { - - Tuple tuple1 = new Tuple<>("ab", 3); - - assertThat(tuple1.equals(null)).isFalse(); + void test_equals_null() { + var tuple1 = Tuple.of("ab", 3); + assertThat(tuple1).isNotEqualTo(null); } } \ No newline at end of file diff --git a/felles/util/src/test/java/no/nav/vedtak/util/env/EnvironmentTest.java b/felles/util/src/test/java/no/nav/vedtak/util/env/EnvironmentTest.java index 139ffed0f..3a5618c26 100644 --- a/felles/util/src/test/java/no/nav/vedtak/util/env/EnvironmentTest.java +++ b/felles/util/src/test/java/no/nav/vedtak/util/env/EnvironmentTest.java @@ -1,7 +1,6 @@ package no.nav.vedtak.util.env; import static no.nav.vedtak.util.env.Cluster.PROD_FSS; -import static no.nav.vedtak.util.env.ConfidentialMarkerFilter.CONFIDENTIAL; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -14,51 +13,42 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import no.nav.vedtak.konfig.StandardPropertySource; import no.nav.vedtak.konfig.Tid; -public class EnvironmentTest { +class EnvironmentTest { private static final Logger LOG = LoggerFactory.getLogger(EnvironmentTest.class); private static Environment ENV = Environment.current(); private static PrintStream SYSOUT = System.out; @AfterEach - public void after() throws Exception { - // reset + void after() throws Exception { System.setOut(SYSOUT); } @Test - // Denne testen må kjøres fra maven, ettersom vi ikke enkelt kan sette env - // properties i kode. - public void testEnvironment() { - assertEquals(ENV.getCluster(), PROD_FSS); + @EnabledIfEnvironmentVariable(named = "mvn", matches = "true") + void testEnvironment() { + assertEquals(PROD_FSS, ENV.getCluster()); assertEquals("jalla", ENV.namespace()); assertTrue(ENV.isProd()); } - public void testURI() { + void testURI() { assertEquals(ENV.getRequiredProperty("VG", URI.class), URI.create("http://www.vg.no")); } - public void testUppercase() { + void testUppercase() { assertEquals(PROD_FSS.clusterName(), ENV.getProperty("nais.cluster.name")); } - // @Test - public void testTurboFilterMedMarkerIProd() { - var stdout = new ByteArrayOutputStream(); - System.setOut(new PrintStream(stdout)); - LOG.info(CONFIDENTIAL, "Dette er konfidensielt, OK i dev men ikke i prod, denne testen kjører i pseudo-prod"); - assertEquals(0, stdout.size()); - } - @Test - public void testTurboFilterUtenMarkerIProd() { + void testTurboFilterUtenMarkerIProd() { var stdout = new ByteArrayOutputStream(); System.setOut(new PrintStream(stdout)); LOG.info("Dette er ikke konfidensielt"); @@ -66,38 +56,38 @@ public void testTurboFilterUtenMarkerIProd() { } @Test - public void testDuration() { + void testDuration() { assertEquals(Duration.ofDays(42), ENV.getProperty("duration.property", Duration.class)); assertEquals(Duration.ofDays(2), ENV.getProperty("ikke.funnet", Duration.class, Duration.ofDays(2))); } @Test - public void testString() { + void testString() { assertEquals("42", ENV.getProperty("finnes.ikke", "42")); assertNull(ENV.getProperty("finnes.ikke")); } @Test - public void testBoolean() { + void testBoolean() { assertTrue(ENV.getProperty("test4.boolean", boolean.class)); assertTrue(ENV.getProperty("test4.boolean", Boolean.class)); } @Test - public void testInt() { + void testInt() { LOG.info("Application property verdier {}", ENV.getProperties(StandardPropertySource.APP_PROPERTIES)); assertEquals(Integer.valueOf(10), ENV.getProperty("test2.intproperty", Integer.class)); assertEquals(Integer.valueOf(10), ENV.getProperty("test2.intproperty", int.class)); } @Test - public void testPropertiesFraEnvUkjentConverter() { + void testPropertiesFraEnvUkjentConverter() { assertThrows(IllegalArgumentException.class, () -> ENV.getProperty("finnes.ikke", Tid.class)); } @Test - public void testPropertiesIkkeFunnet() { + void testPropertiesIkkeFunnet() { assertThrows(IllegalStateException.class, () -> ENV.getRequiredProperty("finnes.ikke")); } diff --git a/integrasjon/infotrygd-grunnlag-klient/src/main/java/no/nav/vedtak/felles/integrasjon/infotrygd/grunnlag/v1/InfotrygdGrunnlagConsumer.java b/integrasjon/infotrygd-grunnlag-klient/src/main/java/no/nav/vedtak/felles/integrasjon/infotrygd/grunnlag/v1/InfotrygdGrunnlagConsumer.java deleted file mode 100644 index e121a9141..000000000 --- a/integrasjon/infotrygd-grunnlag-klient/src/main/java/no/nav/vedtak/felles/integrasjon/infotrygd/grunnlag/v1/InfotrygdGrunnlagConsumer.java +++ /dev/null @@ -1,52 +0,0 @@ -package no.nav.vedtak.felles.integrasjon.infotrygd.grunnlag.v1; - -import java.net.URI; -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import java.util.Arrays; -import java.util.List; -import java.util.Objects; - -import org.apache.http.client.utils.URIBuilder; - -import no.nav.vedtak.felles.integrasjon.infotrygd.grunnlag.v1.respons.Grunnlag; -import no.nav.vedtak.felles.integrasjon.rest.OidcRestClient; - -@Deprecated(since = "3.0.x", forRemoval = true) -public abstract class InfotrygdGrunnlagConsumer { - - private OidcRestClient restClient; - private URI uri; - - public InfotrygdGrunnlagConsumer(OidcRestClient restClient, URI uri) { - this.restClient = restClient; - this.uri = uri; - } - - public InfotrygdGrunnlagConsumer() { - } - - public List getGrunnlag(String fnr, LocalDate fom) throws Exception { - return getGrunnlag(fnr, fom, LocalDate.now()); - } - - public List getGrunnlag(String fnr, LocalDate fom, LocalDate tom) throws Exception { - Objects.requireNonNull(fnr); - var request = new URIBuilder(uri) - .addParameter("fnr", fnr) - .addParameter("fom", konverter(fom)) - .addParameter("tom", konverter(tom)).build(); - var grunnlag = restClient.get(request, Grunnlag[].class); - - return Arrays.asList(grunnlag); - } - - private static String konverter(LocalDate dato) { - return dato.format(DateTimeFormatter.ISO_LOCAL_DATE); - } - - @Override - public String toString() { - return getClass().getSimpleName() + "[restClient=" + restClient + ", uri=" + uri + "]"; - } -} diff --git a/integrasjon/infotrygd-saker-klient/src/main/java/no/nav/vedtak/felles/integrasjon/infotrygd/saker/v1/InfotrygdSakerConsumer.java b/integrasjon/infotrygd-saker-klient/src/main/java/no/nav/vedtak/felles/integrasjon/infotrygd/saker/v1/InfotrygdSakerConsumer.java deleted file mode 100644 index c3b782da2..000000000 --- a/integrasjon/infotrygd-saker-klient/src/main/java/no/nav/vedtak/felles/integrasjon/infotrygd/saker/v1/InfotrygdSakerConsumer.java +++ /dev/null @@ -1,52 +0,0 @@ -package no.nav.vedtak.felles.integrasjon.infotrygd.saker.v1; - -import java.net.URI; -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import java.util.Objects; - -import org.apache.http.client.utils.URIBuilder; - -import no.nav.vedtak.felles.integrasjon.infotrygd.saker.v1.respons.Saker; -import no.nav.vedtak.felles.integrasjon.rest.OidcRestClient; - -/** - * - * @deprecated * @deprecated Bruk {@link InfotrygdSakerJerseyConsumer} - * - */ -@Deprecated -public abstract class InfotrygdSakerConsumer implements InfotrygdSaker { - - private OidcRestClient restClient; - private URI uri; - - public InfotrygdSakerConsumer(OidcRestClient restClient, URI uri) { - this.restClient = restClient; - this.uri = uri; - } - - public InfotrygdSakerConsumer() { - // Tja, nødvendig her? - } - - @Override - public Saker getSaker(String fnr, LocalDate fom) throws Exception { - Objects.requireNonNull(fnr); - var request = new URIBuilder(uri) - .addParameter("fnr", fnr) - .addParameter("fom", fom(fom)) - .build(); - return restClient.get(request, Saker.class); - } - - private static String fom(LocalDate fom) { - return DateTimeFormatter.ISO_LOCAL_DATE.format(fom); - } - - @Override - public String toString() { - return getClass().getSimpleName() + "[restClient=" + restClient + ", uri=" + uri + "]"; - } - -} diff --git a/integrasjon/infotrygd-saker-klient/src/main/java/no/nav/vedtak/felles/integrasjon/infotrygd/saker/v1/InfotrygdSakerJerseyConsumer.java b/integrasjon/infotrygd-saker-klient/src/main/java/no/nav/vedtak/felles/integrasjon/infotrygd/saker/v1/InfotrygdSakerJerseyConsumer.java deleted file mode 100644 index 08c0b9d5b..000000000 --- a/integrasjon/infotrygd-saker-klient/src/main/java/no/nav/vedtak/felles/integrasjon/infotrygd/saker/v1/InfotrygdSakerJerseyConsumer.java +++ /dev/null @@ -1,38 +0,0 @@ -package no.nav.vedtak.felles.integrasjon.infotrygd.saker.v1; - -import static java.time.format.DateTimeFormatter.ISO_LOCAL_DATE; -import static javax.ws.rs.core.MediaType.APPLICATION_JSON; - -import java.net.URI; -import java.time.LocalDate; - -import no.nav.vedtak.felles.integrasjon.infotrygd.saker.v1.respons.Saker; -import no.nav.vedtak.felles.integrasjon.rest.jersey.AbstractJerseyOidcRestClient; - -public abstract class InfotrygdSakerJerseyConsumer extends AbstractJerseyOidcRestClient implements InfotrygdSaker { - - private final URI uri; - - public InfotrygdSakerJerseyConsumer(URI uri) { - this.uri = uri; - } - - @Override - public Saker getSaker(String fnr, LocalDate fom) throws Exception { - return client.target(uri) - .queryParam("fnr", fnr) // TODO bli kvitt fnr i URL - .queryParam("fom", fom(fom)) - .request(APPLICATION_JSON) - .get(Saker.class); - } - - private static String fom(LocalDate fom) { - return ISO_LOCAL_DATE.format(fom); - } - - @Override - public String toString() { - return getClass().getSimpleName() + "[uri=" + uri + ", uri=" + uri + "]"; - } - -} diff --git a/integrasjon/pdl-klient/src/main/java/no/nav/vedtak/felles/integrasjon/pdl/JerseyPdlKlient.java b/integrasjon/pdl-klient/src/main/java/no/nav/vedtak/felles/integrasjon/pdl/JerseyPdlKlient.java index 5d89f79e0..9811cc7c9 100644 --- a/integrasjon/pdl-klient/src/main/java/no/nav/vedtak/felles/integrasjon/pdl/JerseyPdlKlient.java +++ b/integrasjon/pdl-klient/src/main/java/no/nav/vedtak/felles/integrasjon/pdl/JerseyPdlKlient.java @@ -137,7 +137,7 @@ private > T query(GraphQLRequest req, Class clazz) LOG.trace("Hentet resultat for {} fra {} OK", clazz.getName(), endpoint); return res; } catch (ProcessingException e) { - if (e.getCause() != null && e.getCause() instanceof VLException) { + if (e.getCause() instanceof VLException) { throw VLException.class.cast(e.getCause()); } throw e; diff --git a/integrasjon/pdl-klient/src/test/java/no/nav/vedtak/felles/integrasjon/pdl/PdlKlientTest.java b/integrasjon/pdl-klient/src/test/java/no/nav/vedtak/felles/integrasjon/pdl/PdlKlientTest.java index ff5d1b05b..9ba946264 100644 --- a/integrasjon/pdl-klient/src/test/java/no/nav/vedtak/felles/integrasjon/pdl/PdlKlientTest.java +++ b/integrasjon/pdl-klient/src/test/java/no/nav/vedtak/felles/integrasjon/pdl/PdlKlientTest.java @@ -33,7 +33,7 @@ import no.nav.vedtak.felles.integrasjon.rest.SystemConsumerStsRestClient; @ExtendWith(MockitoExtension.class) -public class PdlKlientTest { +class PdlKlientTest { private Pdl pdlKlient; @@ -45,7 +45,7 @@ public class PdlKlientTest { private HttpEntity httpEntity; @BeforeEach - public void setUp() throws IOException { + void setUp() throws IOException { when(restClient.execute(any(HttpPost.class))).thenReturn(response); when(response.getEntity()).thenReturn(httpEntity); @@ -57,7 +57,7 @@ public void setUp() throws IOException { } @Test - public void skal_returnere_person() throws IOException { + void skal_returnere_person() throws IOException { // query-eksempel: dokumentoversiktFagsak(fagsak: {fagsakId: "2019186111", // fagsaksystem: "AO01"}, foerste: 5) when(httpEntity.getContent()).thenReturn(getClass().getClassLoader().getResourceAsStream("pdl/personResponse.json")); @@ -107,13 +107,10 @@ void skal_returnere_bolk_med_identer() throws IOException { assertThat( identer.stream() .flatMap(r -> r.getIdenter().stream()) - .map(IdentInformasjon::getIdent) - // .collect(Collectors.toList()) - ) - .containsExactlyInAnyOrder("16047439276", "9916047439276", "25017312345", "9925017312345"); + .map(IdentInformasjon::getIdent)) + .containsExactlyInAnyOrder("16047439276", "9916047439276", "25017312345", "9925017312345"); } - @SuppressWarnings("resource") @Test void skal_returnere_ikke_funnet() throws IOException { when(httpEntity.getContent()).thenReturn(getClass().getClassLoader().getResourceAsStream("pdl/errorResponse.json")); diff --git a/integrasjon/pdl-klient/src/test/java/no/nav/vedtak/felles/integrasjon/pdl/TestJerseyPdlClient.java b/integrasjon/pdl-klient/src/test/java/no/nav/vedtak/felles/integrasjon/pdl/TestJerseyPdlClient.java index 903f48d0e..4a669bf62 100644 --- a/integrasjon/pdl-klient/src/test/java/no/nav/vedtak/felles/integrasjon/pdl/TestJerseyPdlClient.java +++ b/integrasjon/pdl-klient/src/test/java/no/nav/vedtak/felles/integrasjon/pdl/TestJerseyPdlClient.java @@ -74,7 +74,7 @@ @ExtendWith(MockitoExtension.class) @MockitoSettings(strictness = Strictness.LENIENT) -public class TestJerseyPdlClient { +class TestJerseyPdlClient { private static final Logger LOG = LoggerFactory.getLogger(TestJerseyPdlClient.class); private static final String FOR = Tema.FOR.name(); @@ -95,7 +95,7 @@ public class TestJerseyPdlClient { private final LoadingCache cache = cache(1, Duration.ofSeconds(1)); @BeforeAll - public static void startServer() throws Exception { + static void startServer() throws Exception { server = new WireMockServer(0); server.start(); configureFor(server.port()); @@ -104,19 +104,19 @@ public static void startServer() throws Exception { } @AfterAll - public static void stopServer() { + static void stopServer() { server.stop(); } @BeforeEach - public void beforeEach() throws Exception { + void beforeEach() throws Exception { when(sts.getUsername()).thenReturn(USERNAME); client = new JerseyPdlKlient(URI, new StsAccessTokenClientRequestFilter(sts, FOR, cache)); } @Test @DisplayName("Test error handler") - public void testErrorHandler() throws Exception { + void testErrorHandler() throws Exception { var handler = new PdlDefaultErrorHandler(); var error = new GraphQLError(); error.setExtensions(Map.of("code", FORBUDT, "details", @@ -131,7 +131,7 @@ public void testErrorHandler() throws Exception { @Test @DisplayName("Test at Authorization, Nav-Consumer-Id, Nav-Consumer-Token, Nav-Consumer-Id og Tema alle blir satt tester også cache") - public void testPersonAuthWithUserToken() throws Exception { + void testPersonAuthWithUserToken() throws Exception { when(sts.accessToken()).thenReturn(SYSTEMTOKEN); doReturn(BRUKERTOKEN).when(subjectHandler).getInternSsoToken(); try (var s = mockStatic(SubjectHandler.class)) { @@ -163,7 +163,7 @@ public void testPersonAuthWithUserToken() throws Exception { @Test @DisplayName("Test at Authorization blir satt til system token når vi ikke har et internt oidc token") - public void testPersonAuthWithSystemToken() throws Exception { + void testPersonAuthWithSystemToken() throws Exception { when(sts.accessToken()).thenReturn(SYSTEMTOKEN); doReturn(saml).when(subjectHandler).getSamlToken(); try (var s = mockStatic(SubjectHandler.class)) { @@ -187,7 +187,7 @@ public void testPersonAuthWithSystemToken() throws Exception { @Test @DisplayName("Test at exception kastes når vi ikke har tokens") - public void testPersonNoTokens() throws Exception { + void testPersonNoTokens() throws Exception { try (var s = mockStatic(SubjectHandler.class)) { s.when(SubjectHandler::getSubjectHandler).thenReturn(subjectHandler); stubFor(post(urlPathEqualTo(GRAPHQL))); diff --git a/integrasjon/rest-klient/src/main/java/no/nav/vedtak/felles/integrasjon/rest/Legacy.java b/integrasjon/rest-klient/src/main/java/no/nav/vedtak/felles/integrasjon/rest/Legacy.java new file mode 100644 index 000000000..5e113ff6f --- /dev/null +++ b/integrasjon/rest-klient/src/main/java/no/nav/vedtak/felles/integrasjon/rest/Legacy.java @@ -0,0 +1,19 @@ +package no.nav.vedtak.felles.integrasjon.rest; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +@Qualifier +@Retention(RUNTIME) +@Target({ METHOD, FIELD, PARAMETER, TYPE }) +public @interface Legacy { + String value() default "legacy"; +} diff --git a/integrasjon/rest-klient/src/main/java/no/nav/vedtak/felles/integrasjon/rest/jersey/AbstractJerseyOidcRestClient.java b/integrasjon/rest-klient/src/main/java/no/nav/vedtak/felles/integrasjon/rest/jersey/AbstractJerseyOidcRestClient.java index 1a96b9dcc..8fc6b4db1 100644 --- a/integrasjon/rest-klient/src/main/java/no/nav/vedtak/felles/integrasjon/rest/jersey/AbstractJerseyOidcRestClient.java +++ b/integrasjon/rest-klient/src/main/java/no/nav/vedtak/felles/integrasjon/rest/jersey/AbstractJerseyOidcRestClient.java @@ -32,7 +32,7 @@ public abstract class AbstractJerseyOidcRestClient extends AbstractJerseyRestCli private static final OidcTokenRequestFilter REQUIRED_FILTER = new OidcTokenRequestFilter(); - public AbstractJerseyOidcRestClient() { + protected AbstractJerseyOidcRestClient() { super(REQUIRED_FILTER); } diff --git a/integrasjon/rest-klient/src/test/java/no/nav/vedtak/felles/integrasjon/TestCache.java b/integrasjon/rest-klient/src/test/java/no/nav/vedtak/felles/integrasjon/TestCache.java deleted file mode 100644 index e89d3bb1c..000000000 --- a/integrasjon/rest-klient/src/test/java/no/nav/vedtak/felles/integrasjon/TestCache.java +++ /dev/null @@ -1,5 +0,0 @@ -package no.nav.vedtak.felles.integrasjon; - -public class TestCache { - -}