From b7520a42c611498a80e1d0f321b31ac378f42afd Mon Sep 17 00:00:00 2001 From: Cato Olsen Date: Thu, 26 Oct 2023 11:16:24 +0200 Subject: [PATCH] Fjernet boilerplate fra synt-sykemelding-api sin bruk av ServerProperties. --- .../syntsykemeldingapi/config/Consumers.java | 34 +++++++++++++++++++ .../ArbeidsforholdServiceProperties.java | 12 ------- .../HelsepersonellServiceProperties.java | 12 ------- .../OrganisasjonServiceProperties.java | 13 ------- .../credentials/PdlProxyProperties.java | 11 ------ .../credentials/SykemeldingProperties.java | 11 ------ .../SyntSykemeldingProperties.java | 11 ------ .../consumer/ArbeidsforholdConsumer.java | 14 ++++---- .../consumer/HelsepersonellConsumer.java | 14 ++++---- .../consumer/OrganisasjonConsumer.java | 14 ++++---- .../consumer/PdlProxyConsumer.java | 19 ++++++----- .../consumer/SykemeldingConsumer.java | 16 ++++----- .../consumer/SyntElsamConsumer.java | 19 ++++++----- .../consumer/ArbeidsforholdConsumerTest.java | 4 +-- .../consumer/HelsepersonellConsumerTest.java | 4 +-- .../consumer/OrganisasjonConsumerTest.java | 4 +-- .../consumer/PdlProxyConsumerTest.java | 4 +-- .../consumer/SykemeldingConsumerTest.java | 4 +-- .../consumer/SyntElsamConsumerTest.java | 4 +-- 19 files changed, 95 insertions(+), 129 deletions(-) create mode 100644 apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/config/Consumers.java delete mode 100644 apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/config/credentials/ArbeidsforholdServiceProperties.java delete mode 100644 apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/config/credentials/HelsepersonellServiceProperties.java delete mode 100644 apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/config/credentials/OrganisasjonServiceProperties.java delete mode 100644 apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/config/credentials/PdlProxyProperties.java delete mode 100644 apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/config/credentials/SykemeldingProperties.java delete mode 100644 apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/config/credentials/SyntSykemeldingProperties.java diff --git a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/config/Consumers.java b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/config/Consumers.java new file mode 100644 index 00000000000..a66743fa4f9 --- /dev/null +++ b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/config/Consumers.java @@ -0,0 +1,34 @@ +package no.nav.testnav.apps.syntsykemeldingapi.config; + +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import no.nav.testnav.libs.securitycore.domain.ServerProperties; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +import static lombok.AccessLevel.PACKAGE; + +/** + * Samler alle placeholders for ulike {@code consumers.*}-konfigurasjon her, dvs. subklasser av {@code ServerProperties}. + *

+ * Husk at Spring Boot bruker relaxed binding + * mellom configuration properties og field names. + * + * @see ServerProperties + */ +@Configuration +@ConfigurationProperties(prefix = "consumers") +@NoArgsConstructor(access = PACKAGE) +@Getter +@Setter(PACKAGE) +public class Consumers { + + private ServerProperties testnavArbeidsforholdService; + private ServerProperties testnavHelsepersonellService; + private ServerProperties testnavOrganisasjonService; + private ServerProperties testnavPdlProxy; + private ServerProperties sykemeldingApi; + private ServerProperties syntSykemelding; + +} diff --git a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/config/credentials/ArbeidsforholdServiceProperties.java b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/config/credentials/ArbeidsforholdServiceProperties.java deleted file mode 100644 index 77e65c96583..00000000000 --- a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/config/credentials/ArbeidsforholdServiceProperties.java +++ /dev/null @@ -1,12 +0,0 @@ -package no.nav.testnav.apps.syntsykemeldingapi.config.credentials; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Configuration; - -import no.nav.testnav.libs.securitycore.domain.ServerProperties; - - -@Configuration -@ConfigurationProperties(prefix = "consumers.testnav-arbeidsforhold-service") -public class ArbeidsforholdServiceProperties extends ServerProperties { -} \ No newline at end of file diff --git a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/config/credentials/HelsepersonellServiceProperties.java b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/config/credentials/HelsepersonellServiceProperties.java deleted file mode 100644 index 40f56ee83a8..00000000000 --- a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/config/credentials/HelsepersonellServiceProperties.java +++ /dev/null @@ -1,12 +0,0 @@ -package no.nav.testnav.apps.syntsykemeldingapi.config.credentials; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Configuration; - -import no.nav.testnav.libs.securitycore.domain.ServerProperties; - - -@Configuration -@ConfigurationProperties(prefix = "consumers.testnav-helsepersonell-service") -public class HelsepersonellServiceProperties extends ServerProperties { -} \ No newline at end of file diff --git a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/config/credentials/OrganisasjonServiceProperties.java b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/config/credentials/OrganisasjonServiceProperties.java deleted file mode 100644 index 30b9bbef27b..00000000000 --- a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/config/credentials/OrganisasjonServiceProperties.java +++ /dev/null @@ -1,13 +0,0 @@ -package no.nav.testnav.apps.syntsykemeldingapi.config.credentials; - - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Configuration; - -import no.nav.testnav.libs.securitycore.domain.ServerProperties; - -@Configuration -@ConfigurationProperties(prefix = "consumers.testnav-organisasjon-service") -public class OrganisasjonServiceProperties extends ServerProperties { - -} diff --git a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/config/credentials/PdlProxyProperties.java b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/config/credentials/PdlProxyProperties.java deleted file mode 100644 index de8361fd207..00000000000 --- a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/config/credentials/PdlProxyProperties.java +++ /dev/null @@ -1,11 +0,0 @@ -package no.nav.testnav.apps.syntsykemeldingapi.config.credentials; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Configuration; - -import no.nav.testnav.libs.securitycore.domain.ServerProperties; - -@Configuration -@ConfigurationProperties(prefix = "consumers.testnav-pdl-proxy") -public class PdlProxyProperties extends ServerProperties { -} diff --git a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/config/credentials/SykemeldingProperties.java b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/config/credentials/SykemeldingProperties.java deleted file mode 100644 index 5569d93a0b5..00000000000 --- a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/config/credentials/SykemeldingProperties.java +++ /dev/null @@ -1,11 +0,0 @@ -package no.nav.testnav.apps.syntsykemeldingapi.config.credentials; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Configuration; - -import no.nav.testnav.libs.securitycore.domain.ServerProperties; - -@Configuration -@ConfigurationProperties(prefix = "consumers.sykemelding-api") -public class SykemeldingProperties extends ServerProperties { -} diff --git a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/config/credentials/SyntSykemeldingProperties.java b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/config/credentials/SyntSykemeldingProperties.java deleted file mode 100644 index 25c0f68c241..00000000000 --- a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/config/credentials/SyntSykemeldingProperties.java +++ /dev/null @@ -1,11 +0,0 @@ -package no.nav.testnav.apps.syntsykemeldingapi.config.credentials; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Configuration; - -import no.nav.testnav.libs.securitycore.domain.ServerProperties; - -@Configuration -@ConfigurationProperties(prefix = "consumers.synt-sykemelding") -public class SyntSykemeldingProperties extends ServerProperties { -} diff --git a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/ArbeidsforholdConsumer.java b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/ArbeidsforholdConsumer.java index 8c0e780199f..dab75aeb371 100644 --- a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/ArbeidsforholdConsumer.java +++ b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/ArbeidsforholdConsumer.java @@ -2,9 +2,10 @@ import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; -import no.nav.testnav.apps.syntsykemeldingapi.config.credentials.ArbeidsforholdServiceProperties; +import no.nav.testnav.apps.syntsykemeldingapi.config.Consumers; import no.nav.testnav.apps.syntsykemeldingapi.consumer.command.GetArbeidsforholdCommand; import no.nav.testnav.libs.dto.oppsummeringsdokumentservice.v1.ArbeidsforholdDTO; +import no.nav.testnav.libs.securitycore.domain.ServerProperties; import no.nav.testnav.libs.servletsecurity.exchange.TokenExchange; import org.springframework.stereotype.Component; @@ -15,24 +16,23 @@ public class ArbeidsforholdConsumer { private final TokenExchange tokenExchange; private final WebClient webClient; - private final ArbeidsforholdServiceProperties serviceProperties; + private final ServerProperties serverProperties; public ArbeidsforholdConsumer( TokenExchange tokenExchange, - ArbeidsforholdServiceProperties serviceProperties) { - + Consumers consumers) { this.tokenExchange = tokenExchange; - this.serviceProperties = serviceProperties; + serverProperties = consumers.getTestnavArbeidsforholdService(); this.webClient = WebClient .builder() - .baseUrl(serviceProperties.getUrl()) + .baseUrl(serverProperties.getUrl()) .build(); } @SneakyThrows public ArbeidsforholdDTO getArbeidsforhold(String ident, String orgnummer, String arbeidsforholdId) { log.info("Henter arbeidsforhold for {} i org {} med id {}", ident, orgnummer, arbeidsforholdId); - var response = tokenExchange.exchange(serviceProperties) + var response = tokenExchange.exchange(serverProperties) .flatMap(accessToken -> new GetArbeidsforholdCommand( webClient, accessToken.getTokenValue(), diff --git a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/HelsepersonellConsumer.java b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/HelsepersonellConsumer.java index d3b7d3b598a..764ecafc324 100644 --- a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/HelsepersonellConsumer.java +++ b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/HelsepersonellConsumer.java @@ -2,10 +2,11 @@ import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; -import no.nav.testnav.apps.syntsykemeldingapi.config.credentials.HelsepersonellServiceProperties; +import no.nav.testnav.apps.syntsykemeldingapi.config.Consumers; import no.nav.testnav.apps.syntsykemeldingapi.consumer.command.GetHelsepersonellCommand; import no.nav.testnav.apps.syntsykemeldingapi.domain.HelsepersonellListe; import no.nav.testnav.apps.syntsykemeldingapi.exception.HelsepersonellNotFoundException; +import no.nav.testnav.libs.securitycore.domain.ServerProperties; import no.nav.testnav.libs.servletsecurity.exchange.TokenExchange; import org.springframework.stereotype.Component; @@ -19,24 +20,23 @@ public class HelsepersonellConsumer { private final TokenExchange tokenExchange; private final WebClient webClient; - private final HelsepersonellServiceProperties serviceProperties; + private final ServerProperties serverProperties; public HelsepersonellConsumer( TokenExchange tokenExchange, - HelsepersonellServiceProperties serviceProperties) { - + Consumers consumers) { this.tokenExchange = tokenExchange; - this.serviceProperties = serviceProperties; + serverProperties = consumers.getTestnavHelsepersonellService(); this.webClient = WebClient .builder() - .baseUrl(serviceProperties.getUrl()) + .baseUrl(serverProperties.getUrl()) .build(); } @SneakyThrows public HelsepersonellListe hentHelsepersonell() { log.info("Henter helsepersonell..."); - var response = tokenExchange.exchange(serviceProperties) + var response = tokenExchange.exchange(serverProperties) .flatMap(accessToken -> new GetHelsepersonellCommand(webClient, accessToken.getTokenValue()).call()) .block(); diff --git a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/OrganisasjonConsumer.java b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/OrganisasjonConsumer.java index e0e0429c22a..9ec63bd3238 100644 --- a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/OrganisasjonConsumer.java +++ b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/OrganisasjonConsumer.java @@ -1,34 +1,34 @@ package no.nav.testnav.apps.syntsykemeldingapi.consumer; -import no.nav.testnav.apps.syntsykemeldingapi.config.credentials.OrganisasjonServiceProperties; +import no.nav.testnav.apps.syntsykemeldingapi.config.Consumers; import no.nav.testnav.apps.syntsykemeldingapi.consumer.command.GetOrganisasjonCommand; import no.nav.testnav.libs.dto.organisasjon.v1.OrganisasjonDTO; +import no.nav.testnav.libs.securitycore.domain.ServerProperties; import no.nav.testnav.libs.servletsecurity.exchange.TokenExchange; import org.springframework.stereotype.Component; import org.springframework.web.reactive.function.client.WebClient; @Component public class OrganisasjonConsumer { - private final OrganisasjonServiceProperties serviceProperties; + private final ServerProperties serverProperties; private final TokenExchange tokenExchange; private final WebClient webClient; private static final String MILJOE = "q1"; public OrganisasjonConsumer( - OrganisasjonServiceProperties serviceProperties, + Consumers consumers, TokenExchange tokenExchange) { - - this.serviceProperties = serviceProperties; + serverProperties = consumers.getTestnavOrganisasjonService(); this.tokenExchange = tokenExchange; this.webClient = WebClient .builder() - .baseUrl(serviceProperties.getUrl()) + .baseUrl(serverProperties.getUrl()) .build(); } public OrganisasjonDTO getOrganisasjon(String orgnummer) { - return tokenExchange.exchange(serviceProperties).flatMap(accessToken -> + return tokenExchange.exchange(serverProperties).flatMap(accessToken -> new GetOrganisasjonCommand(webClient, accessToken.getTokenValue(), orgnummer, MILJOE).call()) .block(); } diff --git a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/PdlProxyConsumer.java b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/PdlProxyConsumer.java index 9d4cf703f59..2b718ea5212 100644 --- a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/PdlProxyConsumer.java +++ b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/PdlProxyConsumer.java @@ -1,7 +1,7 @@ package no.nav.testnav.apps.syntsykemeldingapi.consumer; import lombok.extern.slf4j.Slf4j; -import no.nav.testnav.apps.syntsykemeldingapi.config.credentials.PdlProxyProperties; +import no.nav.testnav.apps.syntsykemeldingapi.config.Consumers; import no.nav.testnav.apps.syntsykemeldingapi.consumer.command.GetPdlPersonCommand; import no.nav.testnav.apps.syntsykemeldingapi.domain.pdl.PdlPerson; import no.nav.testnav.apps.syntsykemeldingapi.exception.PdlPersonException; @@ -26,24 +26,25 @@ @Component public class PdlProxyConsumer { private final TokenExchange tokenExchange; - private final ServerProperties serviceProperties; + private final ServerProperties serverProperties; private final WebClient webClient; private static final String SINGLE_PERSON_QUERY = "pdlperson/pdlquery.graphql"; public PdlProxyConsumer( - PdlProxyProperties pdlProxyProperties, + Consumers consumers, TokenExchange tokenExchange) { - - this.serviceProperties = pdlProxyProperties; + serverProperties = consumers.getTestnavPdlProxy(); this.tokenExchange = tokenExchange; - this.webClient = WebClient.builder() - .exchangeStrategies(ExchangeStrategies.builder() + this.webClient = WebClient + .builder() + .exchangeStrategies(ExchangeStrategies + .builder() .codecs(configurer -> configurer .defaultCodecs() .maxInMemorySize(16 * 1024 * 1024)) .build()) - .baseUrl(pdlProxyProperties.getUrl()) + .baseUrl(serverProperties.getUrl()) .build(); } @@ -53,7 +54,7 @@ public PdlPerson getPdlPerson(String ident) { } try { var query = getQueryFromFile(SINGLE_PERSON_QUERY); - var response = tokenExchange.exchange(serviceProperties) + var response = tokenExchange.exchange(serverProperties) .flatMap(accessToken -> new GetPdlPersonCommand(ident, query, accessToken.getTokenValue(), webClient).call()) .block(); if (nonNull(response) && !response.getErrors().isEmpty()) { diff --git a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SykemeldingConsumer.java b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SykemeldingConsumer.java index 32b3a715ef4..ebdbb06776e 100644 --- a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SykemeldingConsumer.java +++ b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SykemeldingConsumer.java @@ -1,7 +1,7 @@ package no.nav.testnav.apps.syntsykemeldingapi.consumer; import lombok.extern.slf4j.Slf4j; -import no.nav.testnav.apps.syntsykemeldingapi.config.credentials.SykemeldingProperties; +import no.nav.testnav.apps.syntsykemeldingapi.config.Consumers; import no.nav.testnav.apps.syntsykemeldingapi.consumer.command.PostSykemeldingCommand; import no.nav.testnav.libs.dto.sykemelding.v1.SykemeldingDTO; import no.nav.testnav.libs.securitycore.domain.ServerProperties; @@ -15,22 +15,22 @@ public class SykemeldingConsumer { private final TokenExchange tokenExchange; - private final ServerProperties serviceProperties; + private final ServerProperties serverProperties; private final WebClient webClient; public SykemeldingConsumer( - SykemeldingProperties serviceProperties, + Consumers consumers, TokenExchange tokenExchange) { - - this.serviceProperties = serviceProperties; + serverProperties = consumers.getSykemeldingApi(); this.tokenExchange = tokenExchange; - this.webClient = WebClient.builder() - .baseUrl(serviceProperties.getUrl()) + this.webClient = WebClient + .builder() + .baseUrl(serverProperties.getUrl()) .build(); } public void opprettSykemelding(SykemeldingDTO sykemelding) { - tokenExchange.exchange(serviceProperties).flatMap(accessToken -> + tokenExchange.exchange(serverProperties).flatMap(accessToken -> new PostSykemeldingCommand(webClient, accessToken.getTokenValue(), sykemelding).call()) .block(); } diff --git a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SyntElsamConsumer.java b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SyntElsamConsumer.java index a8a49528784..b24c6224954 100644 --- a/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SyntElsamConsumer.java +++ b/apps/synt-sykemelding-api/src/main/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SyntElsamConsumer.java @@ -2,7 +2,7 @@ import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; -import no.nav.testnav.apps.syntsykemeldingapi.config.credentials.SyntSykemeldingProperties; +import no.nav.testnav.apps.syntsykemeldingapi.config.Consumers; import no.nav.testnav.apps.syntsykemeldingapi.consumer.command.PostSyntSykemeldingCommand; import no.nav.testnav.apps.syntsykemeldingapi.consumer.dto.SyntSykemeldingHistorikkDTO; import no.nav.testnav.apps.syntsykemeldingapi.exception.GenererSykemeldingerException; @@ -22,22 +22,23 @@ public class SyntElsamConsumer { private final TokenExchange tokenExchange; - private final ServerProperties serviceProperties; + private final ServerProperties serverProperties; private final WebClient webClient; public SyntElsamConsumer( - SyntSykemeldingProperties syntProperties, + Consumers consumers, TokenExchange tokenExchange) { - - this.serviceProperties = syntProperties; + serverProperties = consumers.getSyntSykemelding(); this.tokenExchange = tokenExchange; - this.webClient = WebClient.builder() - .exchangeStrategies(ExchangeStrategies.builder() + this.webClient = WebClient + .builder() + .exchangeStrategies(ExchangeStrategies + .builder() .codecs(configurer -> configurer .defaultCodecs() .maxInMemorySize(16 * 1024 * 1024)) .build()) - .baseUrl(syntProperties.getUrl()) + .baseUrl(serverProperties.getUrl()) .build(); } @@ -47,7 +48,7 @@ public SyntSykemeldingHistorikkDTO genererSykemeldinger(String ident, LocalDate var request = Map.of(ident, startDato.toString()); - var response = tokenExchange.exchange(serviceProperties).flatMap(accessToken -> + var response = tokenExchange.exchange(serverProperties).flatMap(accessToken -> new PostSyntSykemeldingCommand(request, accessToken.getTokenValue(), webClient).call()) .block(); diff --git a/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/ArbeidsforholdConsumerTest.java b/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/ArbeidsforholdConsumerTest.java index 9dd5270ee0c..da2d3262e83 100644 --- a/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/ArbeidsforholdConsumerTest.java +++ b/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/ArbeidsforholdConsumerTest.java @@ -3,9 +3,9 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.github.tomakehurst.wiremock.client.WireMock; -import no.nav.testnav.apps.syntsykemeldingapi.config.credentials.ArbeidsforholdServiceProperties; import no.nav.testnav.libs.dto.oppsummeringsdokumentservice.v1.ArbeidsforholdDTO; import no.nav.testnav.libs.securitycore.domain.AccessToken; +import no.nav.testnav.libs.securitycore.domain.ServerProperties; import no.nav.testnav.libs.servletsecurity.exchange.TokenExchange; import org.junit.Before; import org.junit.Test; @@ -58,7 +58,7 @@ public class ArbeidsforholdConsumerTest { @Before public void before() { WireMock.reset(); - when(tokenService.exchange(ArgumentMatchers.any(ArbeidsforholdServiceProperties.class))).thenReturn(Mono.just(new AccessToken("token"))); + when(tokenService.exchange(ArgumentMatchers.any(ServerProperties.class))).thenReturn(Mono.just(new AccessToken("token"))); arbeidsforholdResponse = getTestArbeidsforholdDTO(arbeidsforholdId, orgnr); } diff --git a/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/HelsepersonellConsumerTest.java b/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/HelsepersonellConsumerTest.java index 943c714ddcb..06e4636c8d3 100644 --- a/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/HelsepersonellConsumerTest.java +++ b/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/HelsepersonellConsumerTest.java @@ -3,9 +3,9 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.github.tomakehurst.wiremock.client.WireMock; -import no.nav.testnav.apps.syntsykemeldingapi.config.credentials.HelsepersonellServiceProperties; import no.nav.testnav.libs.dto.helsepersonell.v1.HelsepersonellListeDTO; import no.nav.testnav.libs.securitycore.domain.AccessToken; +import no.nav.testnav.libs.securitycore.domain.ServerProperties; import no.nav.testnav.libs.servletsecurity.exchange.TokenExchange; import org.junit.Before; import org.junit.Test; @@ -55,7 +55,7 @@ public class HelsepersonellConsumerTest { @Before public void before() { WireMock.reset(); - when(tokenService.exchange(ArgumentMatchers.any(HelsepersonellServiceProperties.class))).thenReturn(Mono.just(new AccessToken("token"))); + when(tokenService.exchange(ArgumentMatchers.any(ServerProperties.class))).thenReturn(Mono.just(new AccessToken("token"))); helsepersonellResponse = getTestLegeListeDTO(); } diff --git a/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/OrganisasjonConsumerTest.java b/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/OrganisasjonConsumerTest.java index dd218e07728..c4d5863f604 100644 --- a/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/OrganisasjonConsumerTest.java +++ b/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/OrganisasjonConsumerTest.java @@ -3,9 +3,9 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.github.tomakehurst.wiremock.client.WireMock; -import no.nav.testnav.apps.syntsykemeldingapi.config.credentials.OrganisasjonServiceProperties; import no.nav.testnav.libs.dto.organisasjon.v1.OrganisasjonDTO; import no.nav.testnav.libs.securitycore.domain.AccessToken; +import no.nav.testnav.libs.securitycore.domain.ServerProperties; import no.nav.testnav.libs.servletsecurity.exchange.TokenExchange; import org.junit.Before; import org.junit.Test; @@ -55,7 +55,7 @@ public class OrganisasjonConsumerTest { @Before public void before() { WireMock.reset(); - when(tokenService.exchange(ArgumentMatchers.any(OrganisasjonServiceProperties.class))).thenReturn(Mono.just(new AccessToken("token"))); + when(tokenService.exchange(ArgumentMatchers.any(ServerProperties.class))).thenReturn(Mono.just(new AccessToken("token"))); organisasjonResponse = getTestOrganisasjonDTO(orgnr); } diff --git a/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/PdlProxyConsumerTest.java b/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/PdlProxyConsumerTest.java index 808df3a2895..e41ca52e23e 100644 --- a/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/PdlProxyConsumerTest.java +++ b/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/PdlProxyConsumerTest.java @@ -3,9 +3,9 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.github.tomakehurst.wiremock.client.WireMock; -import no.nav.testnav.apps.syntsykemeldingapi.config.credentials.PdlProxyProperties; import no.nav.testnav.apps.syntsykemeldingapi.domain.pdl.PdlPerson; import no.nav.testnav.libs.securitycore.domain.AccessToken; +import no.nav.testnav.libs.securitycore.domain.ServerProperties; import no.nav.testnav.libs.servletsecurity.exchange.TokenExchange; import org.junit.Before; import org.junit.Test; @@ -55,7 +55,7 @@ public class PdlProxyConsumerTest { @Before public void before() { WireMock.reset(); - when(tokenService.exchange(ArgumentMatchers.any(PdlProxyProperties.class))).thenReturn(Mono.just(new AccessToken("token"))); + when(tokenService.exchange(ArgumentMatchers.any(ServerProperties.class))).thenReturn(Mono.just(new AccessToken("token"))); pdlResponse = getTestPdlPerson(ident); } diff --git a/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SykemeldingConsumerTest.java b/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SykemeldingConsumerTest.java index 28aa0b7c631..79c2b3dea2a 100644 --- a/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SykemeldingConsumerTest.java +++ b/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SykemeldingConsumerTest.java @@ -2,7 +2,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.github.tomakehurst.wiremock.client.WireMock; -import no.nav.testnav.apps.syntsykemeldingapi.config.credentials.SykemeldingProperties; import no.nav.testnav.apps.syntsykemeldingapi.consumer.dto.SyntSykemeldingHistorikkDTO; import no.nav.testnav.apps.syntsykemeldingapi.domain.Arbeidsforhold; import no.nav.testnav.apps.syntsykemeldingapi.domain.Helsepersonell; @@ -16,6 +15,7 @@ import no.nav.testnav.libs.dto.sykemelding.v1.SykemeldingDTO; import no.nav.testnav.libs.dto.synt.sykemelding.v1.SyntSykemeldingDTO; import no.nav.testnav.libs.securitycore.domain.AccessToken; +import no.nav.testnav.libs.securitycore.domain.ServerProperties; import no.nav.testnav.libs.servletsecurity.exchange.TokenExchange; import org.junit.Before; import org.junit.Test; @@ -83,7 +83,7 @@ public class SykemeldingConsumerTest { @Before public void setUp() { - when(tokenService.exchange(ArgumentMatchers.any(SykemeldingProperties.class))).thenReturn(Mono.just(new AccessToken("token"))); + when(tokenService.exchange(ArgumentMatchers.any(ServerProperties.class))).thenReturn(Mono.just(new AccessToken("token"))); dto = SyntSykemeldingDTO.builder() .arbeidsforholdId(arbeidsforholdId) diff --git a/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SyntElsamConsumerTest.java b/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SyntElsamConsumerTest.java index d84d0738e36..e568818dcc9 100644 --- a/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SyntElsamConsumerTest.java +++ b/apps/synt-sykemelding-api/src/test/java/no/nav/testnav/apps/syntsykemeldingapi/consumer/SyntElsamConsumerTest.java @@ -3,9 +3,9 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.github.tomakehurst.wiremock.client.WireMock; -import no.nav.testnav.apps.syntsykemeldingapi.config.credentials.SyntSykemeldingProperties; import no.nav.testnav.apps.syntsykemeldingapi.consumer.dto.SyntSykemeldingHistorikkDTO; import no.nav.testnav.libs.securitycore.domain.AccessToken; +import no.nav.testnav.libs.securitycore.domain.ServerProperties; import no.nav.testnav.libs.servletsecurity.exchange.TokenExchange; import org.junit.Before; import org.junit.Test; @@ -58,7 +58,7 @@ public class SyntElsamConsumerTest { @Before public void before() { WireMock.reset(); - when(tokenService.exchange(ArgumentMatchers.any(SyntSykemeldingProperties.class))).thenReturn(Mono.just(new AccessToken("token"))); + when(tokenService.exchange(ArgumentMatchers.any(ServerProperties.class))).thenReturn(Mono.just(new AccessToken("token"))); syntResponse = getTestHistorikk(ident); }