-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/tabellvisning-nyansettelser
- Loading branch information
Showing
116 changed files
with
2,058 additions
and
1,205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
...ava/no/nav/dolly/bestilling/pensjonforvalter/command/LagreGenerertPoppInntektCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package no.nav.dolly.bestilling.pensjonforvalter.command; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import no.nav.dolly.bestilling.pensjonforvalter.domain.PensjonPoppGenerertInntektRequest; | ||
import no.nav.dolly.bestilling.pensjonforvalter.domain.PensjonforvalterResponse; | ||
import no.nav.testnav.libs.reactivecore.utils.WebClientFilter; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
import reactor.core.publisher.Flux; | ||
import reactor.core.publisher.Mono; | ||
import reactor.netty.http.client.HttpClientRequest; | ||
import reactor.util.retry.Retry; | ||
|
||
import java.time.Duration; | ||
import java.util.concurrent.Callable; | ||
|
||
import static no.nav.dolly.domain.CommonKeysAndUtils.CONSUMER; | ||
import static no.nav.dolly.domain.CommonKeysAndUtils.HEADER_NAV_CALL_ID; | ||
import static no.nav.dolly.domain.CommonKeysAndUtils.HEADER_NAV_CONSUMER_ID; | ||
import static no.nav.dolly.util.CallIdUtil.generateCallId; | ||
import static no.nav.dolly.util.RequestTimeout.REQUEST_DURATION; | ||
import static org.springframework.http.HttpHeaders.AUTHORIZATION; | ||
|
||
@Slf4j | ||
@RequiredArgsConstructor | ||
public class LagreGenerertPoppInntektCommand implements Callable<Flux<PensjonforvalterResponse>> { | ||
|
||
private static final String POPP_INNTEKTSKJEMA_URL = "/api/v1/inntektskjema"; | ||
|
||
private final WebClient webClient; | ||
private final String token; | ||
private final PensjonPoppGenerertInntektRequest pensjonPoppGenerertInntektRequest; | ||
|
||
public Flux<PensjonforvalterResponse> call() { | ||
|
||
var callId = generateCallId(); | ||
log.info("Popp lagre generert inntekt {}, callId: {}", pensjonPoppGenerertInntektRequest, callId); | ||
return webClient | ||
.post() | ||
.uri(uriBuilder -> uriBuilder | ||
.path(POPP_INNTEKTSKJEMA_URL) | ||
.build()) | ||
.httpRequest(httpRequest -> { | ||
HttpClientRequest reactorRequest = httpRequest.getNativeRequest(); | ||
reactorRequest.responseTimeout(Duration.ofSeconds(REQUEST_DURATION)); | ||
}) | ||
.header(AUTHORIZATION, "Bearer " + token) | ||
.header(HEADER_NAV_CALL_ID, callId) | ||
.header(HEADER_NAV_CONSUMER_ID, CONSUMER) | ||
.bodyValue(pensjonPoppGenerertInntektRequest) | ||
.retrieve() | ||
.bodyToFlux(PensjonforvalterResponse.class) | ||
.doOnError(WebClientFilter::logErrorMessage) | ||
.retryWhen(Retry.backoff(3, Duration.ofSeconds(5)) | ||
.filter(WebClientFilter::is5xxException)) | ||
.onErrorResume(error -> | ||
Mono.just(PensjonforvalterResponse.builder() | ||
.status(pensjonPoppGenerertInntektRequest.getMiljoer().stream() | ||
.map(miljoe -> PensjonforvalterResponse.ResponseEnvironment.builder() | ||
.miljo(miljoe) | ||
.response(PensjonforvalterResponse.Response.builder() | ||
.httpStatus(PensjonforvalterResponse.HttpStatus.builder() | ||
.status(WebClientFilter.getStatus(error).value()) | ||
.reasonPhrase(WebClientFilter.getStatus(error).getReasonPhrase()) | ||
.build()) | ||
.message(WebClientFilter.getMessage(error)) | ||
.path(POPP_INNTEKTSKJEMA_URL) | ||
.build()) | ||
.build()) | ||
.toList()) | ||
.build())); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...va/no/nav/dolly/bestilling/pensjonforvalter/domain/PensjonPoppGenerertInntektRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package no.nav.dolly.bestilling.pensjonforvalter.domain; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static java.util.Objects.isNull; | ||
|
||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class PensjonPoppGenerertInntektRequest { | ||
|
||
private String fnr; | ||
private List<PoppGenerertInntektRequest> inntekter; | ||
private List<String> miljoer; | ||
|
||
public List<String> getMiljoer() { | ||
|
||
if (isNull(miljoer)) { | ||
miljoer = new ArrayList<>(); | ||
} | ||
return miljoer; | ||
} | ||
|
||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class PoppGenerertInntektRequest { | ||
|
||
private Integer aar; | ||
private Integer inntekt; | ||
|
||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...o/nav/dolly/bestilling/pensjonforvalter/mapper/PensjonGenerertInntektMappingStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package no.nav.dolly.bestilling.pensjonforvalter.mapper; | ||
|
||
import ma.glasnost.orika.CustomMapper; | ||
import ma.glasnost.orika.MapperFactory; | ||
import ma.glasnost.orika.MappingContext; | ||
import no.nav.dolly.bestilling.pensjonforvalter.domain.PensjonPoppGenerertInntektRequest; | ||
import no.nav.dolly.domain.resultset.pensjon.PensjonData; | ||
import no.nav.dolly.mapper.MappingStrategy; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class PensjonGenerertInntektMappingStrategy implements MappingStrategy { | ||
|
||
@Override | ||
public void register(MapperFactory factory) { | ||
|
||
factory.classMap(PensjonData.PoppGenerertInntektWrapper.class, PensjonPoppGenerertInntektRequest.class) | ||
.customize(new CustomMapper<>() { | ||
@Override | ||
public void mapAtoB(PensjonData.PoppGenerertInntektWrapper generertInntektWrapper, PensjonPoppGenerertInntektRequest request, MappingContext context) { | ||
|
||
request.setInntekter(generertInntektWrapper.getInntekter().stream().map(inntekt -> | ||
PensjonPoppGenerertInntektRequest.PoppGenerertInntektRequest.builder() | ||
.aar(inntekt.getAr()) | ||
.inntekt(inntekt.getInntekt()) | ||
.build()).toList()); | ||
} | ||
}) | ||
.byDefault() | ||
.register(); | ||
|
||
} | ||
} |
Oops, something went wrong.