Skip to content

Commit

Permalink
Merge branch 'master' into feature/tabellvisning-nyansettelser
Browse files Browse the repository at this point in the history
  • Loading branch information
betsytraran authored Aug 21, 2024
2 parents 066f5e3 + a4b2313 commit 0c2d70d
Show file tree
Hide file tree
Showing 116 changed files with 2,058 additions and 1,205 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/common.integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
run: ./gradlew assemble --scan
- name: "Start docker containers"
run: |
JWK=$(cat ./mocks/jwk.json) docker-compose up -d --build
JWK=$(cat ./mocks/jwk.json) docker compose up --build --detach
- name: "Health check"
timeout-minutes: 5
run: |
Expand All @@ -52,4 +52,4 @@ jobs:
run: ./gradlew iTest --scan
- name: "Stop docker containers"
run: |
docker-compose down -v --remove-orphans
docker compose down --remove-orphans --volumes
1 change: 0 additions & 1 deletion .github/workflows/common.workflow.backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ jobs:
team: dolly
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
dockerfile: ${{ inputs.working-directory }}/Dockerfile
docker_context: ${{ inputs.working-directory }}
image_suffix: ${{ inputs.image-suffix }}
outputs:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/common.workflow.frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ jobs:
team: dolly
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
dockerfile: ${{ inputs.working-directory }}/Dockerfile
docker_context: ${{ inputs.working-directory }}
image_suffix: ${{ inputs.image-suffix }}
outputs:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Eller kjør:
Kjør kommandoen:

```
JWK=$(cat ./mocks/jwk.json) docker-compose up --build
JWK=$(cat ./mocks/jwk.json) docker compose up --build
```

Deretter kan itegrasjonstester kjøres med kommandoen:
Expand Down
1 change: 1 addition & 0 deletions apps/app-tilgang-analyse-service/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ spec:
gcp:
sqlInstances:
- type: POSTGRES_12
tier: db-custom-1-3840
databases:
- name: testnav-app-tilgang-analyse-service-db
liveness:
Expand Down
1 change: 1 addition & 0 deletions apps/bruker-service/config.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ spec:
gcp:
sqlInstances:
- type: POSTGRES_12
tier: db-custom-1-3840
databases:
- name: testnav-bruker-service-dev-db
resources:
Expand Down
1 change: 1 addition & 0 deletions apps/bruker-service/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ spec:
gcp:
sqlInstances:
- type: POSTGRES_12
tier: db-custom-1-3840
databases:
- name: testnav-bruker-service-db
envFrom:
Expand Down
1 change: 1 addition & 0 deletions apps/dolly-backend/config.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ spec:
gcp:
sqlInstances:
- type: POSTGRES_14
tier: db-custom-1-3840
name: testnav-dolly-backend-dev
databases:
- name: testnav-dolly-backend-dev
Expand Down
2 changes: 1 addition & 1 deletion apps/dolly-backend/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ spec:
gcp:
sqlInstances:
- type: POSTGRES_14
tier: db-custom-2-7680
name: testnav-dolly-backend
databases:
- name: testnav-dolly-backend
tier: db-custom-2-3840
autoBackupHour: 2
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ public static void main(String[] args) {

SpringApplication.run(DollyBackendApplicationStarter.class, args);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ public Flux<ClientFuture> gjenopprett(RsDollyUtvidetBestilling bestilling, Dolly
return Flux.empty();
}

@Override
public void release(List<String> identer) {

// Sletting av arbeidsforhold er pt ikke støttet
}

private ClientFuture futurePersist(BestillingProgress progress, String status) {

return () -> {
Expand All @@ -97,12 +103,6 @@ private ClientFuture futurePersist(BestillingProgress progress, String status) {
};
}

@Override
public void release(List<String> identer) {

// Sletting av arbeidsforhold er pt ikke støttet
}

private Mono<String> sendArbeidsforhold(RsDollyUtvidetBestilling bestilling, DollyPerson dollyPerson,
Set<String> miljoer, boolean isOpprettEndre) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import no.nav.dolly.bestilling.pensjonforvalter.domain.AlderspensjonSoknadRequest;
import no.nav.dolly.bestilling.pensjonforvalter.domain.AlderspensjonVedtakRequest;
import no.nav.dolly.bestilling.pensjonforvalter.domain.PensjonPersonRequest;
import no.nav.dolly.bestilling.pensjonforvalter.domain.PensjonPoppGenerertInntektRequest;
import no.nav.dolly.bestilling.pensjonforvalter.domain.PensjonPoppInntektRequest;
import no.nav.dolly.bestilling.pensjonforvalter.domain.PensjonSamboerRequest;
import no.nav.dolly.bestilling.pensjonforvalter.domain.PensjonSamboerResponse;
Expand Down Expand Up @@ -155,6 +156,10 @@ public Flux<ClientFuture> gjenopprett(RsDollyUtvidetBestilling bestilling, Dolly
dollyPerson.getIdent(), bestilteMiljoer.get())
.map(response -> POPP_INNTEKTSREGISTER + decodeStatus(response, dollyPerson.getIdent())),

lagreGenerertInntekt(pensjon,
dollyPerson.getIdent(), bestilteMiljoer.get())
.map(response -> POPP_INNTEKTSREGISTER + decodeStatus(response, dollyPerson.getIdent())),

lagreTpForhold(pensjon, dollyPerson.getIdent(), bestilteMiljoer.get())
.map(response -> TP_FORHOLD + decodeStatus(response, dollyPerson.getIdent())),

Expand Down Expand Up @@ -464,6 +469,22 @@ private Flux<PensjonforvalterResponse> lagreInntekt(PensjonData pensjonData, Str
}));
}

private Flux<PensjonforvalterResponse> lagreGenerertInntekt(PensjonData pensjonData, String ident,
Set<String> miljoer) {

return Flux.just(pensjonData)
.filter(PensjonData::hasGenerertInntekt)
.map(PensjonData::getGenerertInntekt)
.flatMap(generertInntekt -> Flux.fromIterable(miljoer)
.flatMap(miljoe -> {

var request = mapperFacade.map(generertInntekt, PensjonPoppGenerertInntektRequest.class);
request.setFnr(ident);
request.setMiljoer(List.of(miljoe));
return pensjonforvalterConsumer.lagreGenererteInntekter(request);
}));
}

private Mono<PensjonforvalterResponse> lagreTpForhold(PensjonData pensjonData, String
ident, Set<String> miljoer) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import no.nav.dolly.bestilling.pensjonforvalter.command.HentMiljoerCommand;
import no.nav.dolly.bestilling.pensjonforvalter.command.HentSamboerCommand;
import no.nav.dolly.bestilling.pensjonforvalter.command.LagreAlderspensjonCommand;
import no.nav.dolly.bestilling.pensjonforvalter.command.LagreGenerertPoppInntektCommand;
import no.nav.dolly.bestilling.pensjonforvalter.command.LagrePensjonsavtaleCommand;
import no.nav.dolly.bestilling.pensjonforvalter.command.LagrePoppInntektCommand;
import no.nav.dolly.bestilling.pensjonforvalter.command.LagreSamboerCommand;
Expand All @@ -18,6 +19,7 @@
import no.nav.dolly.bestilling.pensjonforvalter.command.SletteTpForholdCommand;
import no.nav.dolly.bestilling.pensjonforvalter.domain.AlderspensjonRequest;
import no.nav.dolly.bestilling.pensjonforvalter.domain.PensjonPersonRequest;
import no.nav.dolly.bestilling.pensjonforvalter.domain.PensjonPoppGenerertInntektRequest;
import no.nav.dolly.bestilling.pensjonforvalter.domain.PensjonPoppInntektRequest;
import no.nav.dolly.bestilling.pensjonforvalter.domain.PensjonSamboerRequest;
import no.nav.dolly.bestilling.pensjonforvalter.domain.PensjonSamboerResponse;
Expand Down Expand Up @@ -77,6 +79,14 @@ public Flux<PensjonforvalterResponse> lagreInntekter(PensjonPoppInntektRequest p
pensjonPoppInntektRequest).call());
}

@Timed(name = "providers", tags = { "operation", "popp_lagreGenerertInntekt" })
public Flux<PensjonforvalterResponse> lagreGenererteInntekter(PensjonPoppGenerertInntektRequest pensjonPoppGenerertInntektRequest) {

return tokenService.exchange(serverProperties)
.flatMapMany(token -> new LagreGenerertPoppInntektCommand(webClient, token.getTokenValue(),
pensjonPoppGenerertInntektRequest).call());
}

@Timed(name = "providers", tags = { "operation", "pen_opprettPerson" })
public Flux<PensjonforvalterResponse> opprettPerson(PensjonPersonRequest pensjonPersonRequest,
Set<String> miljoer) {
Expand Down
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()));
}
}
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;

}
}
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();

}
}
Loading

0 comments on commit 0c2d70d

Please sign in to comment.