From adab4741b5d0cf16a1e8aed1e43d5100689a0535 Mon Sep 17 00:00:00 2001 From: Espen Waaga <36693523+espenwaaga@users.noreply.github.com> Date: Wed, 20 Mar 2024 14:54:30 +0100 Subject: [PATCH] TFP-5748: Legger til FPKALKULUS i FpApplications (#1350) --- .../integrasjon/rest/FpApplication.java | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/integrasjon/rest-klient/src/main/java/no/nav/vedtak/felles/integrasjon/rest/FpApplication.java b/integrasjon/rest-klient/src/main/java/no/nav/vedtak/felles/integrasjon/rest/FpApplication.java index 584142bb2..a1f9ef66f 100644 --- a/integrasjon/rest-klient/src/main/java/no/nav/vedtak/felles/integrasjon/rest/FpApplication.java +++ b/integrasjon/rest-klient/src/main/java/no/nav/vedtak/felles/integrasjon/rest/FpApplication.java @@ -1,6 +1,5 @@ package no.nav.vedtak.felles.integrasjon.rest; -import java.util.Map; import java.util.Optional; import java.util.Set; @@ -11,6 +10,7 @@ public enum FpApplication { FPSAK, FPABAKUS, + FPKALKULUS, FPFORMIDLING, FPRISK, FPABONNENT, @@ -28,22 +28,24 @@ public enum FpApplication { // FpApplication brukes til å kalle apps i namespace foreldrepenger - ikke riktig å bruke ENV/namespace private static final Namespace FORELDREPENGER = Namespace.foreldrepenger(); - /* - * Utelatt fpabonnent:8065 - */ - private static final Map LOCAL_PORTS = Map.ofEntries( - Map.entry(FpApplication.FPSAK, 8080), - Map.entry(FpApplication.FPABAKUS, 8015), - Map.entry(FpApplication.FPFORMIDLING, 8010), - Map.entry(FpApplication.FPRISK, 8075), - Map.entry(FpApplication.FPOPPDRAG, 8070), - Map.entry(FpApplication.FPTILBAKE, 8030), - Map.entry(FpApplication.FPFORDEL, 8090), - Map.entry(FpApplication.FPDOKGEN, 8291), - Map.entry(FpApplication.FPWSPROXY, 8292), - Map.entry(FpApplication.FPLOS, 8071), - Map.entry(FpApplication.FPOVERSIKT, 8889) - ); + private static Integer lokalPort(FpApplication application) { + return switch (application) { + case FPSAK -> 8080; + case FPABAKUS -> 8015; + case FPKALKULUS -> 8016; + case FPFORMIDLING -> 8010; + case FPRISK -> 8075; + case FPABONNENT -> 8065; + case FPFORDEL -> 8090; + case FPLOS -> 8071; + case FPOPPDRAG -> 8070; + case FPTILBAKE -> 8030; + case FPDOKGEN -> 8291; + case FPWSPROXY -> 8292; + case FPOVERSIKT -> 8889; + case NONFP -> throw new IllegalArgumentException("Utviklerfeil: angitt app er ikke i fp-familien"); + }; + } private static final Set GCP_APPS = Set.of(FPOVERSIKT); @@ -93,7 +95,7 @@ private static String urlForCommunicationBetweenDifferentClusters(FpApplication private static String urlForLocal(FpApplication application, Environment currentEnvironment, String appname) { return Optional.ofNullable(currentEnvironment.getProperty(application.name().toLowerCase() + ".override.url")) - .orElseGet(() -> String.format("http://localhost:%s/%s", LOCAL_PORTS.get(application), appname)); + .orElseGet(() -> String.format("http://localhost:%s/%s", lokalPort(application), appname)); } static String scopesFor(FpApplication application, Environment currentEnvironment) {