From 1b0b25ae026ab52b267be83a7ed576e5f4cdcb4e Mon Sep 17 00:00:00 2001 From: kristenhaerum Date: Mon, 12 Feb 2024 08:04:58 +0100 Subject: [PATCH] Remove TPS person status related services and tests The commit removes TPS person status related services and tests including "BestillingTpsPersonStatusMapper", "TpsPersonService" along with their associated tests. This removal is reflected in "BestillingStatusMappingStrategy" and "OpprettPersonerByKriterierService". The changes aim to streamline and simplify the codebase. --- .../PensjonforvalterClient.java | 85 ++--- .../service/DollyBestillingService.java | 2 - .../service/GjenopprettBestillingService.java | 5 - .../service/GjenopprettGruppeService.java | 5 - .../service/GjenopprettIdentService.java | 6 - .../ImportAvPersonerFraPdlService.java | 6 - .../service/LeggTilPaaGruppeService.java | 6 - .../service/OppdaterPersonService.java | 6 - .../OpprettPersonerByKriterierService.java | 6 - ...PersonerFraIdenterMedKriterierService.java | 6 - .../service/TpsPersonService.java | 191 ----------- .../dolly/domain/jpa/BestillingProgress.java | 21 -- .../dolly/domain/resultset/SystemTyper.java | 1 - .../BestillingTpsPersonStatusMapper.java | 54 ---- .../BestillingStatusMappingStrategy.java | 2 - .../V1.7.22__AlterTableBestillingProgress.sql | 6 + .../service/TpsPersonServiceTest.java | 302 ------------------ 17 files changed, 37 insertions(+), 673 deletions(-) delete mode 100644 apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/tpsmessagingservice/service/TpsPersonService.java delete mode 100644 apps/dolly-backend/src/main/java/no/nav/dolly/mapper/BestillingTpsPersonStatusMapper.java create mode 100644 apps/dolly-backend/src/main/resources/db/migration/V1.7.22__AlterTableBestillingProgress.sql delete mode 100644 apps/dolly-backend/src/test/java/no/nav/dolly/bestilling/tpsmessagingservice/service/TpsPersonServiceTest.java diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/pensjonforvalter/PensjonforvalterClient.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/pensjonforvalter/PensjonforvalterClient.java index 10902a9aa71..844d4495105 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/pensjonforvalter/PensjonforvalterClient.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/pensjonforvalter/PensjonforvalterClient.java @@ -84,7 +84,6 @@ public class PensjonforvalterClient implements ClientRegister { private static final String PEN_ALDERSPENSJON = "AP#"; private static final String PEN_UFORETRYGD = "Ufoer#"; private static final String PERIODE = "/periode/"; - private static final String TPS_NOT_READY = "Oppretting ikke utført da TPS mangler persondata."; private final PensjonforvalterConsumer pensjonforvalterConsumer; private final MapperFacade mapperFacade; @@ -173,8 +172,7 @@ public Flux gjenopprett(RsDollyUtvidetBestilling bestilling, Dolly .flatMap(pensjon -> Flux.merge( lagreInntekt(pensjon, - dollyPerson.getIdent(), bestilteMiljoer.get(), - progress.getIsTpsSyncEnv()) + dollyPerson.getIdent(), bestilteMiljoer.get()) .map(response -> POPP_INNTEKTSREGISTER + decodeStatus(response, dollyPerson.getIdent())), lagreTpForhold(pensjon, dollyPerson.getIdent(), bestilteMiljoer.get()) @@ -192,8 +190,7 @@ public Flux gjenopprett(RsDollyUtvidetBestilling bestilling, Dolly dollyPerson.getIdent(), bestilteMiljoer.get(), isOpprettEndre, - bestillingId, - progress.getIsTpsSyncEnv()) + bestillingId) .map(response -> PEN_ALDERSPENSJON + decodeStatus(response, dollyPerson.getIdent())), lagreUforetrygd( @@ -202,8 +199,7 @@ public Flux gjenopprett(RsDollyUtvidetBestilling bestilling, Dolly dollyPerson.getIdent(), bestilteMiljoer.get(), isOpprettEndre, - bestillingId, - progress.getIsTpsSyncEnv()) + bestillingId) .map(response -> PEN_UFORETRYGD + decodeStatus(response, dollyPerson.getIdent())) ) .collectList() @@ -368,8 +364,7 @@ private Flux opprettPersoner(String hovedperson, Set lagreAlderspensjon(PensjonData pensjonData, Tuple2, String> utvidetPersondata, String ident, Set miljoer, - boolean isOpprettEndre, Long bestillingId, - List isTpsSyncEnv) { + boolean isOpprettEndre, Long bestillingId) { return Flux.just(pensjonData) .filter(PensjonData::hasAlderspensjon) @@ -379,38 +374,32 @@ private Flux lagreAlderspensjon(PensjonData pensjonDat if (isOpprettEndre || !transaksjonMappingService.existAlready(PEN_AP, ident, miljoe, null)) { - if (isTpsSyncEnv.contains(miljoe)) { + AlderspensjonRequest pensjonRequest; + var context = new MappingContext.Factory().getContext(); + context.setProperty(IDENT, ident); + context.setProperty(MILJOER, List.of(miljoe)); - AlderspensjonRequest pensjonRequest; - var context = new MappingContext.Factory().getContext(); - context.setProperty(IDENT, ident); - context.setProperty(MILJOER, List.of(miljoe)); - - if (isTrue(alderspensjon.getSoknad())) { - context.setProperty("relasjoner", utvidetPersondata.getT1()); - pensjonRequest = mapperFacade.map(alderspensjon, AlderspensjonSoknadRequest.class, context); - - } else { - context.setProperty(NAV_ENHET, utvidetPersondata.getT2()); - pensjonRequest = mapperFacade.map(alderspensjon, AlderspensjonVedtakRequest.class, context); - } - - var finalPensjonRequest = new AtomicReference<>(pensjonRequest); - return pensjonforvalterConsumer.lagreAlderspensjon(pensjonRequest) - .map(response -> { - response.getStatus().forEach(status -> { - if (status.getResponse().isResponse2xx()) { - saveAPTransaksjonId(ident, status.getMiljo(), bestillingId, - PEN_AP, finalPensjonRequest); - } - }); - return response; - }); + if (isTrue(alderspensjon.getSoknad())) { + context.setProperty("relasjoner", utvidetPersondata.getT1()); + pensjonRequest = mapperFacade.map(alderspensjon, AlderspensjonSoknadRequest.class, context); } else { - return getStatus(miljoe, 503, TPS_NOT_READY); + context.setProperty(NAV_ENHET, utvidetPersondata.getT2()); + pensjonRequest = mapperFacade.map(alderspensjon, AlderspensjonVedtakRequest.class, context); } + var finalPensjonRequest = new AtomicReference<>(pensjonRequest); + return pensjonforvalterConsumer.lagreAlderspensjon(pensjonRequest) + .map(response -> { + response.getStatus().forEach(status -> { + if (status.getResponse().isResponse2xx()) { + saveAPTransaksjonId(ident, status.getMiljo(), bestillingId, + PEN_AP, finalPensjonRequest); + } + }); + return response; + }); + } else { return getStatus(miljoe, 200, "OK"); } @@ -419,7 +408,7 @@ private Flux lagreAlderspensjon(PensjonData pensjonDat private Flux lagreUforetrygd(PensjonData pensjondata, String navEnhetNr, String ident, Set miljoer, boolean isOpprettEndre, - Long bestillingId, List isTpsSyncEnv) { + Long bestillingId) { return Flux.just(pensjondata) .filter(PensjonData::hasUforetrygd) @@ -429,8 +418,6 @@ private Flux lagreUforetrygd(PensjonData pensjondata, if (isOpprettEndre || !transaksjonMappingService.existAlready(PEN_UT, ident, miljoe, null)) { - if (isTpsSyncEnv.contains(miljoe)) { - var context = MappingContextUtils.getMappingContext(); context.setProperty(IDENT, ident); context.setProperty(MILJOER, List.of(miljoe)); @@ -446,10 +433,6 @@ private Flux lagreUforetrygd(PensjonData pensjondata, return response; })); - } else { - return getStatus(miljoe, 503, TPS_NOT_READY); - } - } else { return getStatus(miljoe, 200, "OK"); } @@ -490,7 +473,7 @@ private void saveAPTransaksjonId(String ident, String miljoe, Long bestillingId, } private Flux lagreInntekt(PensjonData pensjonData, String ident, - Set miljoer, List isTpsSyncEnv) { + Set miljoer) { return Flux.just(pensjonData) .filter(PensjonData::hasInntekt) @@ -498,16 +481,10 @@ private Flux lagreInntekt(PensjonData pensjonData, Str .flatMap(inntekt -> Flux.fromIterable(miljoer) .flatMap(miljoe -> { - if (isTpsSyncEnv.stream().anyMatch(sync -> sync.equals(miljoe))) { - - var request = mapperFacade.map(inntekt, PensjonPoppInntektRequest.class); - request.setFnr(ident); - request.setMiljoer(List.of(miljoe)); - return pensjonforvalterConsumer.lagreInntekter(request); - - } else { - return getStatus(miljoe, 503, TPS_NOT_READY); - } + var request = mapperFacade.map(inntekt, PensjonPoppInntektRequest.class); + request.setFnr(ident); + request.setMiljoer(List.of(miljoe)); + return pensjonforvalterConsumer.lagreInntekter(request); })); } diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/DollyBestillingService.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/DollyBestillingService.java index 077ce0429aa..8e7638230b9 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/DollyBestillingService.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/DollyBestillingService.java @@ -13,7 +13,6 @@ import no.nav.dolly.bestilling.pdldata.dto.PdlResponse; import no.nav.dolly.bestilling.pensjonforvalter.PensjonforvalterClient; import no.nav.dolly.bestilling.tagshendelseslager.TagsHendelseslagerClient; -import no.nav.dolly.bestilling.tpsmessagingservice.service.TpsPersonService; import no.nav.dolly.domain.jpa.Bestilling; import no.nav.dolly.domain.jpa.BestillingProgress; import no.nav.dolly.domain.jpa.Bruker; @@ -63,7 +62,6 @@ public class DollyBestillingService { protected final PdlDataConsumer pdlDataConsumer; protected final ErrorStatusDecoder errorStatusDecoder; protected final TransactionHelperService transactionHelperService; - protected final TpsPersonService tpsPersonService; protected final BestillingElasticRepository bestillingElasticRepository; public static Set getEnvironments(String miljoer) { diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/GjenopprettBestillingService.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/GjenopprettBestillingService.java index 704da340cf2..9df72604556 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/GjenopprettBestillingService.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/GjenopprettBestillingService.java @@ -8,7 +8,6 @@ import no.nav.dolly.bestilling.pdldata.PdlDataConsumer; import no.nav.dolly.bestilling.pdldata.dto.PdlResponse; import no.nav.dolly.bestilling.personservice.PersonServiceClient; -import no.nav.dolly.bestilling.tpsmessagingservice.service.TpsPersonService; import no.nav.dolly.domain.jpa.Bestilling; import no.nav.dolly.domain.jpa.BestillingProgress; import no.nav.dolly.elastic.BestillingElasticRepository; @@ -52,7 +51,6 @@ public GjenopprettBestillingService( PdlDataConsumer pdlDataConsumer, TransactionHelperService transactionHelperService, PersonServiceClient personServiceClient, - TpsPersonService tpsPersonService, BestillingElasticRepository bestillingElasticRepository ) { super( @@ -65,7 +63,6 @@ public GjenopprettBestillingService( pdlDataConsumer, errorStatusDecoder, transactionHelperService, - tpsPersonService, bestillingElasticRepository ); this.bestillingProgressService = bestillingProgressService; @@ -101,8 +98,6 @@ public void executeAsync(Bestilling bestilling) { .filter(BestillingProgress::isPdlSync) .flatMap(pdlSync -> createBestilling(bestilling, gmlProgress.getBestilling())) .flatMap(cobestilling -> Flux.concat( - tpsPersonService.syncPerson(dollyPerson, cobestilling, progress) - .map(ClientFuture::get), gjenopprettKlienter(dollyPerson, cobestilling, fase2Klienter(), progress, false), diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/GjenopprettGruppeService.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/GjenopprettGruppeService.java index 2d282ddadf6..6bef4f0373b 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/GjenopprettGruppeService.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/GjenopprettGruppeService.java @@ -8,7 +8,6 @@ import no.nav.dolly.bestilling.pdldata.PdlDataConsumer; import no.nav.dolly.bestilling.pdldata.dto.PdlResponse; import no.nav.dolly.bestilling.personservice.PersonServiceClient; -import no.nav.dolly.bestilling.tpsmessagingservice.service.TpsPersonService; import no.nav.dolly.domain.jpa.Bestilling; import no.nav.dolly.domain.jpa.BestillingProgress; import no.nav.dolly.elastic.BestillingElasticRepository; @@ -51,7 +50,6 @@ public GjenopprettGruppeService( PdlDataConsumer pdlDataConsumer, TransactionHelperService transactionHelperService, PersonServiceClient personServiceClient, - TpsPersonService tpsPersonService, BestillingElasticRepository bestillingElasticRepository ) { super( @@ -64,7 +62,6 @@ public GjenopprettGruppeService( pdlDataConsumer, errorStatusDecoder, transactionHelperService, - tpsPersonService, bestillingElasticRepository ); this.personServiceClient = personServiceClient; @@ -110,8 +107,6 @@ public void executeAsync(Bestilling bestilling) { .doOnNext(request -> log.info("Startet gjenopprett bestilling {} for ident: {}", request.getId(), testident.getIdent())) .flatMapSequential(bestillingRequest -> Flux.concat( - tpsPersonService.syncPerson(dollyPerson, bestillingRequest, progress) - .map(ClientFuture::get), gjenopprettKlienter(dollyPerson, bestillingRequest, fase2Klienter(), progress, false), diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/GjenopprettIdentService.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/GjenopprettIdentService.java index 1be07918e11..9d312403ae4 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/GjenopprettIdentService.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/GjenopprettIdentService.java @@ -8,7 +8,6 @@ import no.nav.dolly.bestilling.pdldata.PdlDataConsumer; import no.nav.dolly.bestilling.pdldata.dto.PdlResponse; import no.nav.dolly.bestilling.personservice.PersonServiceClient; -import no.nav.dolly.bestilling.tpsmessagingservice.service.TpsPersonService; import no.nav.dolly.domain.jpa.Bestilling; import no.nav.dolly.domain.jpa.BestillingProgress; import no.nav.dolly.domain.resultset.RsDollyBestillingRequest; @@ -53,7 +52,6 @@ public GjenopprettIdentService( PdlDataConsumer pdlDataConsumer, TransactionHelperService transactionHelperService, PersonServiceClient personServiceClient, - TpsPersonService tpsPersonService, BestillingElasticRepository bestillingElasticRepository ) { super( @@ -66,7 +64,6 @@ public GjenopprettIdentService( pdlDataConsumer, errorStatusDecoder, transactionHelperService, - tpsPersonService, bestillingElasticRepository ); this.personServiceClient = personServiceClient; @@ -116,9 +113,6 @@ public void executeAsync(Bestilling bestilling) { log.info("Startet gjenopprett bestilling {} for ident: {}", request.getId(), testident.getIdent())) .flatMap(bestillingRequest -> Flux.concat( - tpsPersonService.syncPerson(dollyPerson, bestillingRequest, - progress) - .map(ClientFuture::get), gjenopprettKlienter(dollyPerson, bestillingRequest, fase2Klienter(), progress, false), diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/ImportAvPersonerFraPdlService.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/ImportAvPersonerFraPdlService.java index 58a353ab24f..e7cd67e1e5e 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/ImportAvPersonerFraPdlService.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/ImportAvPersonerFraPdlService.java @@ -7,7 +7,6 @@ import no.nav.dolly.bestilling.ClientRegister; import no.nav.dolly.bestilling.pdldata.PdlDataConsumer; import no.nav.dolly.bestilling.personservice.PersonServiceClient; -import no.nav.dolly.bestilling.tpsmessagingservice.service.TpsPersonService; import no.nav.dolly.domain.jpa.Bestilling; import no.nav.dolly.domain.jpa.BestillingProgress; import no.nav.dolly.domain.resultset.RsDollyBestillingRequest; @@ -48,7 +47,6 @@ public ImportAvPersonerFraPdlService(IdentService identService, PdlDataConsumer pdlDataConsumer, TransactionHelperService transactionHelperService, PersonServiceClient personServiceClient, - TpsPersonService tpsPersonService, BestillingElasticRepository bestillingElasticRepository) { super( identService, @@ -60,7 +58,6 @@ public ImportAvPersonerFraPdlService(IdentService identService, pdlDataConsumer, errorStatusDecoder, transactionHelperService, - tpsPersonService, bestillingElasticRepository ); this.personServiceClient = personServiceClient; @@ -91,9 +88,6 @@ public void executeAsync(Bestilling bestilling) { .filter(BestillingProgress::isPdlSync) .flatMap(pdlSync -> Flux.concat( - tpsPersonService.syncPerson(dollyPerson, bestKriterier, - progress) - .map(ClientFuture::get), gjenopprettKlienter(dollyPerson, bestKriterier, fase2Klienter(), progress, true), diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/LeggTilPaaGruppeService.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/LeggTilPaaGruppeService.java index 08d207ed6e9..1e81902f92e 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/LeggTilPaaGruppeService.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/LeggTilPaaGruppeService.java @@ -8,7 +8,6 @@ import no.nav.dolly.bestilling.pdldata.PdlDataConsumer; import no.nav.dolly.bestilling.pdldata.dto.PdlResponse; import no.nav.dolly.bestilling.personservice.PersonServiceClient; -import no.nav.dolly.bestilling.tpsmessagingservice.service.TpsPersonService; import no.nav.dolly.domain.jpa.Bestilling; import no.nav.dolly.domain.jpa.BestillingProgress; import no.nav.dolly.domain.resultset.RsDollyBestillingRequest; @@ -55,7 +54,6 @@ public LeggTilPaaGruppeService( PdlDataConsumer pdlDataConsumer, TransactionHelperService transactionHelperService, PersonServiceClient personServiceClient, - TpsPersonService tpsPersonService, BestillingElasticRepository bestillingElasticRepository) { super( identService, @@ -67,7 +65,6 @@ public LeggTilPaaGruppeService( pdlDataConsumer, errorStatusDecoder, transactionHelperService, - tpsPersonService, bestillingElasticRepository ); this.personServiceClient = personServiceClient; @@ -105,9 +102,6 @@ public void executeAsync(Bestilling bestilling) { .filter(BestillingProgress::isPdlSync) .flatMap(pdlSync -> Flux.concat( - tpsPersonService.syncPerson(dollyPerson, bestKriterier, - progress) - .map(ClientFuture::get), gjenopprettKlienter(dollyPerson, bestKriterier, fase2Klienter(), progress, true), diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/OppdaterPersonService.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/OppdaterPersonService.java index 2848ee1a9ef..ccadf0e05f2 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/OppdaterPersonService.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/OppdaterPersonService.java @@ -8,7 +8,6 @@ import no.nav.dolly.bestilling.pdldata.PdlDataConsumer; import no.nav.dolly.bestilling.pdldata.dto.PdlResponse; import no.nav.dolly.bestilling.personservice.PersonServiceClient; -import no.nav.dolly.bestilling.tpsmessagingservice.service.TpsPersonService; import no.nav.dolly.domain.jpa.Bestilling; import no.nav.dolly.domain.jpa.BestillingProgress; import no.nav.dolly.domain.resultset.RsDollyUpdateRequest; @@ -52,7 +51,6 @@ public OppdaterPersonService( PdlDataConsumer pdlDataConsumer, TransactionHelperService transactionHelperService, PersonServiceClient personServiceClient, - TpsPersonService tpsPersonService, BestillingElasticRepository bestillingElasticRepository) { super( identService, @@ -64,7 +62,6 @@ public OppdaterPersonService( pdlDataConsumer, errorStatusDecoder, transactionHelperService, - tpsPersonService, bestillingElasticRepository ); this.personServiceClient = personServiceClient; @@ -99,9 +96,6 @@ public void oppdaterPersonAsync(RsDollyUpdateRequest request, Bestilling bestill .filter(BestillingProgress::isPdlSync) .flatMap(pdlSync -> Flux.concat( - tpsPersonService.syncPerson(dollyPerson, request, - progress) - .map(ClientFuture::get), gjenopprettKlienter(dollyPerson, request, fase2Klienter(), progress, true), diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/OpprettPersonerByKriterierService.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/OpprettPersonerByKriterierService.java index 8649dcc50b0..3550addf54e 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/OpprettPersonerByKriterierService.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/OpprettPersonerByKriterierService.java @@ -7,7 +7,6 @@ import no.nav.dolly.bestilling.ClientRegister; import no.nav.dolly.bestilling.pdldata.PdlDataConsumer; import no.nav.dolly.bestilling.personservice.PersonServiceClient; -import no.nav.dolly.bestilling.tpsmessagingservice.service.TpsPersonService; import no.nav.dolly.domain.jpa.Bestilling; import no.nav.dolly.domain.jpa.BestillingProgress; import no.nav.dolly.elastic.BestillingElasticRepository; @@ -49,7 +48,6 @@ public OpprettPersonerByKriterierService( PdlDataConsumer pdlDataConsumer, TransactionHelperService transactionHelperService, PersonServiceClient personServiceClient, - TpsPersonService tpsPersonService, BestillingElasticRepository bestillingElasticRepository) { super( identService, @@ -61,7 +59,6 @@ public OpprettPersonerByKriterierService( pdlDataConsumer, errorStatusDecoder, transactionHelperService, - tpsPersonService, bestillingElasticRepository ); this.personServiceClient = personServiceClient; @@ -96,9 +93,6 @@ public void executeAsync(Bestilling bestilling) { .map(ClientFuture::get) .filter(BestillingProgress::isPdlSync) .flatMap(pdlSync -> Flux.concat( - tpsPersonService.syncPerson(dollyPerson, bestKriterier, - progress) - .map(ClientFuture::get), gjenopprettKlienter(dollyPerson, bestKriterier, fase2Klienter(), progress, true), diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/OpprettPersonerFraIdenterMedKriterierService.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/OpprettPersonerFraIdenterMedKriterierService.java index 12ed355c9b0..2116d6fe12c 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/OpprettPersonerFraIdenterMedKriterierService.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/service/OpprettPersonerFraIdenterMedKriterierService.java @@ -7,7 +7,6 @@ import no.nav.dolly.bestilling.ClientRegister; import no.nav.dolly.bestilling.pdldata.PdlDataConsumer; import no.nav.dolly.bestilling.personservice.PersonServiceClient; -import no.nav.dolly.bestilling.tpsmessagingservice.service.TpsPersonService; import no.nav.dolly.domain.jpa.Bestilling; import no.nav.dolly.domain.jpa.BestillingProgress; import no.nav.dolly.domain.resultset.RsDollyBestillingRequest; @@ -50,7 +49,6 @@ public OpprettPersonerFraIdenterMedKriterierService( PdlDataConsumer pdlDataConsumer, TransactionHelperService transactionHelperService, PersonServiceClient personServiceClient, - TpsPersonService tpsPersonService, BestillingElasticRepository bestillingElasticRepository) { super( identService, @@ -62,7 +60,6 @@ public OpprettPersonerFraIdenterMedKriterierService( pdlDataConsumer, errorStatusDecoder, transactionHelperService, - tpsPersonService, bestillingElasticRepository ); this.personServiceClient = personServiceClient; @@ -99,9 +96,6 @@ public void executeAsync(Bestilling bestilling) { .map(ClientFuture::get) .filter(BestillingProgress::isPdlSync) .flatMap(pdlSync -> Flux.concat( - tpsPersonService.syncPerson(dollyPerson, bestKriterier, - progress) - .map(ClientFuture::get), gjenopprettKlienter(dollyPerson, bestKriterier, fase2Klienter(), progress, true), diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/tpsmessagingservice/service/TpsPersonService.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/tpsmessagingservice/service/TpsPersonService.java deleted file mode 100644 index a3a2d4ee62c..00000000000 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/tpsmessagingservice/service/TpsPersonService.java +++ /dev/null @@ -1,191 +0,0 @@ -package no.nav.dolly.bestilling.tpsmessagingservice.service; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import no.nav.dolly.bestilling.ClientFuture; -import no.nav.dolly.bestilling.personservice.PersonServiceConsumer; -import no.nav.dolly.bestilling.tpsmessagingservice.TpsMessagingConsumer; -import no.nav.dolly.domain.PdlPerson; -import no.nav.dolly.domain.PdlPersonBolk; -import no.nav.dolly.domain.jpa.BestillingProgress; -import no.nav.dolly.domain.resultset.RsDollyUtvidetBestilling; -import no.nav.dolly.domain.resultset.SystemTyper; -import no.nav.dolly.domain.resultset.dolly.DollyPerson; -import no.nav.dolly.service.TransaksjonMappingService; -import no.nav.dolly.util.TransactionHelperService; -import no.nav.testnav.libs.data.tpsmessagingservice.v1.PersonMiljoeDTO; -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Service; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.time.Duration; -import java.util.Collections; -import java.util.List; -import java.util.Objects; -import java.util.Set; -import java.util.function.Function; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static java.util.Objects.isNull; -import static java.util.Objects.nonNull; -import static no.nav.dolly.errorhandling.ErrorStatusDecoder.encodeStatus; -import static no.nav.dolly.util.DollyTextUtil.getSyncTextSystem; -import static org.apache.commons.lang3.StringUtils.trimToEmpty; - -@Slf4j -@Service -@RequiredArgsConstructor -public class TpsPersonService { - - private static final List PENSJON_MILJOER = List.of("q1", "q2"); - private static final long TIMEOUT_MILLIES = 839; - - @Value("${tps.person.service.wait}") - private long awaitMaxMillies; - - private final TpsMessagingConsumer tpsMessagingConsumer; - private final TransactionHelperService transactionHelperService; - private final TransaksjonMappingService transaksjonMappingService; - private final PersonServiceConsumer personServiceConsumer; - - public Flux syncPerson(DollyPerson dollyPerson, RsDollyUtvidetBestilling bestilling, BestillingProgress progress) { - - long startTime = System.currentTimeMillis(); - - return Flux.fromIterable(bestilling.getEnvironments()) - .filter(PENSJON_MILJOER::contains) - .collectList() - .filter(penMiljoer -> !penMiljoer.isEmpty()) - .filter(penMiljoer -> isRelevantBestilling(bestilling) && - (nonNull(bestilling.getPensjonforvalter().getInntekt()) || - !isTransaksjonMapping(dollyPerson.getIdent(), bestilling, penMiljoer))) - .flatMapMany(penMiljoer -> - getRelasjoner(dollyPerson.getIdent()) - .flatMap(relasjon -> Flux.from(getTpsPerson(startTime, dollyPerson.getIdent(), - penMiljoer, Collections.emptyList(), progress) - .map(status -> prepareResult(relasjon, status, bestilling.getEnvironments(), startTime))))) - .collectList() - .flatMapIterable(Function.identity()) - .map(status -> futurePersist(progress, dollyPerson.getIdent(), status)); - } - - private Flux getRelasjoner(String ident) { - - return personServiceConsumer.getPdlPersoner(List.of(ident)) - .filter(pdlPersonBolk -> nonNull(pdlPersonBolk.getData())) - .map(PdlPersonBolk::getData) - .map(PdlPersonBolk.Data::getHentPersonBolk) - .flatMap(Flux::fromIterable) - .filter(personBolk -> nonNull(personBolk.getPerson())) - .flatMap(person -> Flux.fromStream(Stream.of( - Stream.of(ident), - person.getPerson().getSivilstand().stream() - .map(PdlPerson.Sivilstand::getRelatertVedSivilstand) - .filter(Objects::nonNull), - person.getPerson().getForelderBarnRelasjon().stream() - .map(PdlPerson.ForelderBarnRelasjon::getRelatertPersonsIdent) - .filter(Objects::nonNull)) - .flatMap(Function.identity()))) - .distinct(); - } - - private boolean isRelevantBestilling(RsDollyUtvidetBestilling bestilling) { - - return nonNull(bestilling.getPensjonforvalter()) && - (nonNull(bestilling.getPensjonforvalter().getInntekt()) || - nonNull(bestilling.getPensjonforvalter().getAlderspensjon()) || - nonNull(bestilling.getPensjonforvalter().getUforetrygd())); - } - - private boolean isTransaksjonMapping(String ident, RsDollyUtvidetBestilling bestilling, List miljoer) { - - var transaksjoner = transaksjonMappingService.getTransaksjonMapping(ident); - - return (isNull(bestilling.getPensjonforvalter().getAlderspensjon()) || - miljoer.stream() - .allMatch(miljoe -> transaksjoner.stream() - .anyMatch(transaksjon -> miljoe.equals(transaksjon.getMiljoe()) && - SystemTyper.PEN_AP.name().equals(transaksjon.getSystem())))) && - - (isNull(bestilling.getPensjonforvalter().getUforetrygd()) || - miljoer.stream() - .allMatch(miljoe -> transaksjoner.stream() - .anyMatch(transaksjon -> miljoe.equals(transaksjon.getMiljoe()) && - SystemTyper.PEN_UT.name().equals(transaksjon.getSystem())))); - } - - private Mono> getTpsPerson(Long starttid, String ident, List miljoer, - List status, BestillingProgress progress) { - - if (System.currentTimeMillis() - (starttid + awaitMaxMillies) > 0 || - (status.size() == miljoer.size() && - status.stream().allMatch(PersonMiljoeDTO::isOk))) { - return Mono.just(status); - - } else { - - transactionHelperService.persisterDynamicProgress(progress, - BestillingProgress::getTpsSyncStatus, - BestillingProgress::setTpsSyncStatus, - miljoer.stream() - .map(miljoe -> "%s:%s".formatted(miljoe, encodeStatus(getSyncTextSystem("TPS", - System.currentTimeMillis() - starttid)))) - .collect(Collectors.joining(","))); - - return Flux.just(1) - .delayElements(Duration.ofMillis(TIMEOUT_MILLIES)) - .flatMap(delayed -> tpsMessagingConsumer.getPerson(ident, miljoer)) - .collectList() - .flatMap(resultat -> getTpsPerson(starttid, ident, miljoer, resultat, progress)); - } - } - - private List prepareResult(String ident, List status, Set miljoer, long startTime) { - - if (status.size() == miljoer.size()) { - log.info("Synkronisering mot TPS for {} tok {} ms.", ident, System.currentTimeMillis() - startTime); - - } else { - log.warn("Synkronisering mot TPS for {} gitt opp etter {} ms.", ident, System.currentTimeMillis() - startTime); - } - - return Stream.of(status.stream() - .filter(status1 -> StringUtils.isNotBlank(status1.getMiljoe())), - miljoer.stream() - .filter(miljoe -> status.stream().noneMatch(status1 -> miljoe.equals(status1.getMiljoe()))) - .map(miljoe -> PersonMiljoeDTO.builder() - .ident(ident) - .miljoe(miljoe) - .status("NOK") - .utfyllendeMelding(String.format("Synkronisering mot TPS gitt opp etter %d sekunder.", awaitMaxMillies / 1000)) - .build())) - .flatMap(Function.identity()) - .toList(); - } - - private ClientFuture futurePersist(BestillingProgress progress, String ident, List status) { - - return () -> { - - progress.setIsTpsSyncEnv(status.stream() - .filter(status1 -> ident.equals(status1.getIdent())) - .filter(PersonMiljoeDTO::isOk) - .map(PersonMiljoeDTO::getMiljoe) - .toList()); - - transactionHelperService.persisterDynamicProgress(progress, - BestillingProgress::getTpsSyncStatus, - BestillingProgress::setTpsSyncStatus, - status.stream() - .filter(detalj -> ident.equals(detalj.getIdent())) - .map(detalj -> "%s:%s".formatted(detalj.getMiljoe(), - encodeStatus(detalj.isOk() ? detalj.getStatus() : - trimToEmpty("Feil: %s".formatted(detalj.getUtfyllendeMelding()))))) - .collect(Collectors.joining(","))); - return progress; - }; - } -} diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/domain/jpa/BestillingProgress.java b/apps/dolly-backend/src/main/java/no/nav/dolly/domain/jpa/BestillingProgress.java index 4c31701ae5e..57498aa2ac0 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/domain/jpa/BestillingProgress.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/domain/jpa/BestillingProgress.java @@ -24,10 +24,7 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; -import static java.util.Objects.isNull; import static org.apache.logging.log4j.util.Strings.isNotBlank; @Entity @@ -118,9 +115,6 @@ public class BestillingProgress implements Serializable { @Column(name = "PDL_PERSON_STATUS") private String pdlPersonStatus; - @Column(name = "TPS_SYNC_STATUS") - private String tpsSyncStatus; - @Column(name = "ARBEIDSPLASSENCV_STATUS") private String arbeidsplassenCVStatus; @@ -131,17 +125,6 @@ public class BestillingProgress implements Serializable { @Transient private boolean isPdlSync; - @Transient - private List isTpsSyncEnv; - - public List getIsTpsSyncEnv() { - - if (isNull(isTpsSyncEnv)) { - isTpsSyncEnv = new ArrayList<>(); - } - return isTpsSyncEnv; - } - private String feil; public BestillingProgress(Bestilling bestilling, String ident, Master master) { @@ -204,7 +187,6 @@ public boolean equals(Object o) { .append(getPdlOrdreStatus(), that.getPdlOrdreStatus()) .append(getKontoregisterStatus(), that.getKontoregisterStatus()) .append(getPdlPersonStatus(), that.getPdlPersonStatus()) - .append(getTpsSyncStatus(), that.getTpsSyncStatus()) .append(getArbeidsplassenCVStatus(), that.getArbeidsplassenCVStatus()) .append(getMaster(), that.getMaster()) .append(getFeil(), that.getFeil()) @@ -239,7 +221,6 @@ public int hashCode() { .append(getPdlOrdreStatus()) .append(getKontoregisterStatus()) .append(getPdlPersonStatus()) - .append(getTpsSyncStatus()) .append(getArbeidsplassenCVStatus()) .append(getMaster()) .append(getFeil()) @@ -274,11 +255,9 @@ public String toString() { ", pdlOrdreStatus='" + pdlOrdreStatus + '\'' + ", kontoregisterStatus='" + kontoregisterStatus + '\'' + ", pdlPersonStatus='" + pdlPersonStatus + '\'' + - ", tpsSyncStatus='" + tpsSyncStatus + '\'' + ", arbeidsplassenCVStatus='" + arbeidsplassenCVStatus + '\'' + ", master=" + master + ", isPdlSync=" + isPdlSync + - ", isTpsSyncEnv=" + isTpsSyncEnv + ", feil='" + feil + '\'' + '}'; } diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/domain/resultset/SystemTyper.java b/apps/dolly-backend/src/main/java/no/nav/dolly/domain/resultset/SystemTyper.java index 93f50ad8a63..6fecc63b7ea 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/domain/resultset/SystemTyper.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/domain/resultset/SystemTyper.java @@ -40,7 +40,6 @@ public enum SystemTyper { PDL_ORDRE("Ordre til PDL"), KONTOREGISTER("Bankkontoregister"), PDL_PERSONSTATUS("Person finnes i PDL"), - TPS_STATUS("Person finnes i TPS"), ANNEN_FEIL("Annen Feil"), ARBEIDSPLASSENCV("Arbeidsplassen CV"); diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/mapper/BestillingTpsPersonStatusMapper.java b/apps/dolly-backend/src/main/java/no/nav/dolly/mapper/BestillingTpsPersonStatusMapper.java deleted file mode 100644 index 8a30d0e85da..00000000000 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/mapper/BestillingTpsPersonStatusMapper.java +++ /dev/null @@ -1,54 +0,0 @@ -package no.nav.dolly.mapper; - -import lombok.AccessLevel; -import lombok.NoArgsConstructor; -import no.nav.dolly.domain.jpa.BestillingProgress; -import no.nav.dolly.domain.resultset.RsStatusRapport; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static java.util.Collections.emptyList; -import static java.util.Collections.singletonList; -import static no.nav.dolly.domain.resultset.SystemTyper.TPS_STATUS; -import static no.nav.dolly.mapper.AbstractRsStatusMiljoeIdentForhold.checkAndUpdateStatus; -import static no.nav.dolly.mapper.AbstractRsStatusMiljoeIdentForhold.decodeMsg; -import static org.apache.commons.lang3.StringUtils.isNotBlank; - -@NoArgsConstructor(access = AccessLevel.PRIVATE) -public final class BestillingTpsPersonStatusMapper { - - public static List buildTpsPersonStatusMap(List progressList) { - - // status miljø ident - Map>> statusEnvIdents = new HashMap<>(); - - progressList.forEach(progress -> { - if (isNotBlank(progress.getTpsSyncStatus())) { - List.of(progress.getTpsSyncStatus().split(",")).forEach(status -> { - var environErrMsg = status.split(":", 2); - var environ = environErrMsg[0]; - if (environErrMsg.length > 1 && isNotBlank(environErrMsg[1]) && isNotBlank(progress.getIdent())) { - var errMsg = decodeMsg(environErrMsg[1]); - checkAndUpdateStatus(statusEnvIdents, progress.getIdent(), environ, errMsg); - } - }); - } - }); - - return statusEnvIdents.isEmpty() ? emptyList() : - singletonList(RsStatusRapport.builder().id(TPS_STATUS).navn(TPS_STATUS.getBeskrivelse()) - .statuser(statusEnvIdents.entrySet().stream().map(status -> RsStatusRapport.Status.builder() - .melding(status.getKey()) - .detaljert(status.getValue().entrySet().stream().map(envIdent -> RsStatusRapport.Detaljert.builder() - .miljo(envIdent.getKey()) - .identer(envIdent.getValue()) - .build()) - .toList()) - .build()) - .toList()) - .build()); - } -} diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/mapper/strategy/BestillingStatusMappingStrategy.java b/apps/dolly-backend/src/main/java/no/nav/dolly/mapper/strategy/BestillingStatusMappingStrategy.java index f06db0581d9..e7b03e9a9f3 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/mapper/strategy/BestillingStatusMappingStrategy.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/mapper/strategy/BestillingStatusMappingStrategy.java @@ -42,7 +42,6 @@ import static no.nav.dolly.mapper.BestillingSkjermingsRegisterStatusMapper.buildSkjermingsRegisterStatusMap; import static no.nav.dolly.mapper.BestillingSykemeldingStatusMapper.buildSykemeldingStatusMap; import static no.nav.dolly.mapper.BestillingTpsMessagingStatusMapper.buildTpsMessagingStatusMap; -import static no.nav.dolly.mapper.BestillingTpsPersonStatusMapper.buildTpsPersonStatusMap; import static no.nav.dolly.mapper.BestillingUdiStubStatusMapper.buildUdiStubStatusMap; import static org.apache.commons.lang3.StringUtils.isBlank; import static org.apache.commons.lang3.StringUtils.isNotBlank; @@ -79,7 +78,6 @@ public void mapAtoB(Bestilling bestilling, RsBestillingStatus bestillingStatus, bestillingStatus.getStatus().addAll(buildPdlOrdreStatusMap(progresser, objectMapper)); bestillingStatus.getStatus().addAll(buildImportFraPdlStatusMap(progresser)); bestillingStatus.getStatus().addAll(buildPdlPersonStatusMap(progresser)); - bestillingStatus.getStatus().addAll(buildTpsPersonStatusMap(progresser)); bestillingStatus.getStatus().addAll(buildPensjonforvalterStatusMap(progresser)); bestillingStatus.getStatus().addAll(buildInntektstubStatusMap(progresser)); bestillingStatus.getStatus().addAll(buildTpsMessagingStatusMap(progresser)); diff --git a/apps/dolly-backend/src/main/resources/db/migration/V1.7.22__AlterTableBestillingProgress.sql b/apps/dolly-backend/src/main/resources/db/migration/V1.7.22__AlterTableBestillingProgress.sql new file mode 100644 index 00000000000..06bf4c6b072 --- /dev/null +++ b/apps/dolly-backend/src/main/resources/db/migration/V1.7.22__AlterTableBestillingProgress.sql @@ -0,0 +1,6 @@ +----------------------------- +-- A L T E R T A B L E S -- +----------------------------- + +alter table transaksjon_mapping +alter column transaksjon_id type varchar(2000); \ No newline at end of file diff --git a/apps/dolly-backend/src/test/java/no/nav/dolly/bestilling/tpsmessagingservice/service/TpsPersonServiceTest.java b/apps/dolly-backend/src/test/java/no/nav/dolly/bestilling/tpsmessagingservice/service/TpsPersonServiceTest.java deleted file mode 100644 index 739d350b1d9..00000000000 --- a/apps/dolly-backend/src/test/java/no/nav/dolly/bestilling/tpsmessagingservice/service/TpsPersonServiceTest.java +++ /dev/null @@ -1,302 +0,0 @@ -package no.nav.dolly.bestilling.tpsmessagingservice.service; - -import no.nav.dolly.bestilling.ClientFuture; -import no.nav.dolly.bestilling.personservice.PersonServiceConsumer; -import no.nav.dolly.bestilling.tpsmessagingservice.TpsMessagingConsumer; -import no.nav.dolly.domain.PdlPerson; -import no.nav.dolly.domain.PdlPersonBolk; -import no.nav.dolly.domain.jpa.BestillingProgress; -import no.nav.dolly.domain.resultset.RsDollyUtvidetBestilling; -import no.nav.dolly.domain.resultset.dolly.DollyPerson; -import no.nav.dolly.domain.resultset.pensjon.PensjonData; -import no.nav.dolly.service.RsTransaksjonMapping; -import no.nav.dolly.service.TransaksjonMappingService; -import no.nav.dolly.util.TransactionHelperService; -import no.nav.testnav.libs.data.tpsmessagingservice.v1.PersonMiljoeDTO; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.CsvSource; -import org.mockito.ArgumentCaptor; -import org.mockito.Captor; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.junit.jupiter.MockitoExtension; -import org.springframework.test.util.ReflectionTestUtils; -import reactor.core.publisher.Flux; -import reactor.test.StepVerifier; - -import java.util.List; -import java.util.Set; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.contains; -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.empty; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.not; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyList; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -@ExtendWith(MockitoExtension.class) -class TpsPersonServiceTest { - - private static final String AP = "PEN_AP"; - private static final String UT = "PEN_UT"; - private static final Set ENVS = Set.of("q1", "q2"); - private static final String IDENT = "11111111111"; - - @Mock - private TpsMessagingConsumer tpsMessagingConsumer; - @Mock - private TransactionHelperService transactionHelperService; - @Mock - private TransaksjonMappingService transaksjonMappingService; - - @Mock - private PersonServiceConsumer personServiceConsumer; - @InjectMocks - private TpsPersonService tpsPersonService; - - @Captor - ArgumentCaptor statusCaptor; - - @BeforeEach - void setup() { - statusCaptor = ArgumentCaptor.forClass(String.class); - ReflectionTestUtils.setField(tpsPersonService, "awaitMaxMillies", 1000); - } - - @Test - void syncPerson_TPS_OK() { - - when(personServiceConsumer.getPdlPersoner(anyList())).thenReturn(Flux.just(PdlPersonBolk.builder() - .data(PdlPersonBolk.Data.builder() - .hentPersonBolk(List.of(PdlPersonBolk.PersonBolk.builder() - .person(PdlPerson.Person.builder() - .build()) - .build())) - .build()) - .build())); - when(tpsMessagingConsumer.getPerson(IDENT, ENVS.stream().toList())).thenReturn(Flux.just( - PersonMiljoeDTO.builder().miljoe("q1").ident(IDENT).status("OK").build(), - PersonMiljoeDTO.builder().miljoe("q2").ident(IDENT).status("OK").build())); - - var progress = getProgress(); - - StepVerifier.create(tpsPersonService.syncPerson(getDollyPerson(), getBestilling(null), progress) - .map(ClientFuture::get)) - .assertNext(status -> { - verify(transactionHelperService, times(2)) - .persisterDynamicProgress(any(BestillingProgress.class), any(), any(), statusCaptor.capture()); - assertThat(statusCaptor.getAllValues().get(0), containsString("q1:Info= Synkronisering mot TPS startet ...")); - assertThat(statusCaptor.getAllValues().get(0), containsString("q2:Info= Synkronisering mot TPS startet ...")); - assertThat(statusCaptor.getAllValues().get(1), containsString("q1:OK")); - assertThat(statusCaptor.getAllValues().get(1), containsString("q2:OK")); - assertThat(progress.getIsTpsSyncEnv(), contains("q1", "q2")); - }) - .verifyComplete(); - } - - @ParameterizedTest - @CsvSource({ - "PEN_AP", - "PEN_UT"}) - void syncPerson_pensjon_TPS_OK(String pensjonType) { - - when(transaksjonMappingService.getTransaksjonMapping(getDollyPerson().getIdent())) - .thenReturn(List.of( - RsTransaksjonMapping.builder().ident(IDENT).system(pensjonType).miljoe("q1").build(), - RsTransaksjonMapping.builder().ident(IDENT).system(pensjonType).miljoe("q2").build())); - - var progress = getProgress(); - - StepVerifier.create(tpsPersonService.syncPerson(getDollyPerson(), getBestilling(pensjonType), progress) - .map(ClientFuture::get)) - .expectNextCount(0) - .verifyComplete(); - } - - @ParameterizedTest - @CsvSource({ - "PEN_AP,q1", - "PEN_AP,q2", - "PEN_UT,q1", - "PEN_UT,q2"}) - void syncPerson_pensjon_med_en_TPS_OK(String pensjonType, String miljoe) { - - when(personServiceConsumer.getPdlPersoner(anyList())).thenReturn(Flux.just(PdlPersonBolk.builder() - .data(PdlPersonBolk.Data.builder() - .hentPersonBolk(List.of(PdlPersonBolk.PersonBolk.builder() - .person(PdlPerson.Person.builder() - .build()) - .build())) - .build()) - .build())); - when(tpsMessagingConsumer.getPerson(eq(IDENT), anyList())).thenReturn(Flux.just( - PersonMiljoeDTO.builder().miljoe(miljoe).ident(IDENT).status("OK").build())); - - var progress = getProgress(); - - StepVerifier.create(tpsPersonService.syncPerson(getDollyPerson(), getBestilling(pensjonType, miljoe), progress) - .map(ClientFuture::get)) - .assertNext(status -> { - verify(transactionHelperService, times(2)) - .persisterDynamicProgress(any(BestillingProgress.class), any(), any(), statusCaptor.capture()); - assertThat(statusCaptor.getAllValues().get(0), containsString(miljoe + ":Info= Synkronisering mot TPS startet ...")); - assertThat(statusCaptor.getAllValues().get(1), containsString(miljoe + ":OK")); - assertThat(progress.getIsTpsSyncEnv(), contains(miljoe)); - }) - .verifyComplete(); - } - - @Test - void syncPerson_TPS_svarer_ikke() { - - when(personServiceConsumer.getPdlPersoner(anyList())).thenReturn(Flux.just(PdlPersonBolk.builder() - .data(PdlPersonBolk.Data.builder() - .hentPersonBolk(List.of(PdlPersonBolk.PersonBolk.builder() - .person(PdlPerson.Person.builder() - .build()) - .build())) - .build()) - .build())); - when(tpsMessagingConsumer.getPerson(IDENT, ENVS.stream().toList())).thenReturn(Flux.empty()); - - var progress = getProgress(); - - StepVerifier.create(tpsPersonService.syncPerson(getDollyPerson(), getBestilling(null), progress) - .map(ClientFuture::get)) - .assertNext(status -> { - verify(transactionHelperService, Mockito.atLeastOnce()) - .persisterDynamicProgress(any(BestillingProgress.class), any(), any(), statusCaptor.capture()); - assertThat(statusCaptor.getAllValues().get(0), containsString("q1:Info= Synkronisering mot TPS startet ...")); - assertThat(statusCaptor.getAllValues().get(0), containsString("q2:Info= Synkronisering mot TPS startet ...")); - assertThat(statusCaptor.getAllValues().get(statusCaptor.getAllValues().size() - 1), containsString("q1:Feil= Synkronisering mot TPS gitt opp")); - assertThat(statusCaptor.getAllValues().get(statusCaptor.getAllValues().size() - 1), containsString("q2:Feil= Synkronisering mot TPS gitt opp")); - assertThat(progress.getIsTpsSyncEnv(), is(empty())); - }) - .verifyComplete(); - } - - @ParameterizedTest - @CsvSource({ - "q1,q2", - "q2,q1"}) - void syncPerson_en_TPS_svarer_ikke(String miljoeSomSvarer, String miljoeSomIkkeSvarer) { - - when(personServiceConsumer.getPdlPersoner(anyList())).thenReturn(Flux.just(PdlPersonBolk.builder() - .data(PdlPersonBolk.Data.builder() - .hentPersonBolk(List.of(PdlPersonBolk.PersonBolk.builder() - .person(PdlPerson.Person.builder() - .build()) - .build())) - .build()) - .build())); - when(tpsMessagingConsumer.getPerson(IDENT, ENVS.stream().toList())).thenReturn(Flux.just( - PersonMiljoeDTO.builder().miljoe(miljoeSomSvarer).ident(IDENT).status("OK").build())); - - var progress = getProgress(); - - StepVerifier.create(tpsPersonService.syncPerson(getDollyPerson(), getBestilling(null), progress) - .map(ClientFuture::get)) - .assertNext(status -> { - verify(transactionHelperService, Mockito.atLeastOnce()) - .persisterDynamicProgress(any(BestillingProgress.class), any(), any(), statusCaptor.capture()); - assertThat(statusCaptor.getAllValues().get(0), containsString("q1:Info= Synkronisering mot TPS startet ...")); - assertThat(statusCaptor.getAllValues().get(0), containsString("q2:Info= Synkronisering mot TPS startet ...")); - assertThat(statusCaptor.getAllValues().get(statusCaptor.getAllValues().size() - 1), containsString(miljoeSomSvarer + ":OK")); - assertThat(statusCaptor.getAllValues().get(statusCaptor.getAllValues().size() - 1), containsString(miljoeSomIkkeSvarer + ":Feil= Synkronisering mot TPS gitt opp")); - assertThat(progress.getIsTpsSyncEnv(), contains(miljoeSomSvarer)); - assertThat(progress.getIsTpsSyncEnv(), contains(not(miljoeSomIkkeSvarer))); - }) - .verifyComplete(); - } - - @ParameterizedTest - @CsvSource({ - "q1,q2", - "q2,q1"}) - void syncPerson_en_TPS_har_ikke_data(String miljoeSomHarData, String miljoeSomIkkeHarData) { - - when(personServiceConsumer.getPdlPersoner(anyList())).thenReturn(Flux.just(PdlPersonBolk.builder() - .data(PdlPersonBolk.Data.builder() - .hentPersonBolk(List.of(PdlPersonBolk.PersonBolk.builder() - .person(PdlPerson.Person.builder() - .build()) - .build())) - .build()) - .build())); - when(tpsMessagingConsumer.getPerson(IDENT, ENVS.stream().toList())).thenReturn(Flux.just( - PersonMiljoeDTO.builder().miljoe(miljoeSomHarData).ident(IDENT).status("OK").build(), - PersonMiljoeDTO.builder().miljoe(miljoeSomIkkeHarData).ident(IDENT).status("Feil").utfyllendeMelding("Personen finnes ikke").build())); - - var progress = getProgress(); - - StepVerifier.create(tpsPersonService.syncPerson(getDollyPerson(), getBestilling(null), progress) - .map(ClientFuture::get)) - .assertNext(status -> { - verify(transactionHelperService, Mockito.atLeastOnce()) - .persisterDynamicProgress(any(BestillingProgress.class), any(), any(), statusCaptor.capture()); - assertThat(statusCaptor.getAllValues().get(0), containsString("q1:Info= Synkronisering mot TPS startet ...")); - assertThat(statusCaptor.getAllValues().get(0), containsString("q2:Info= Synkronisering mot TPS startet ...")); - assertThat(statusCaptor.getAllValues().get(statusCaptor.getAllValues().size() - 1), containsString(miljoeSomHarData + ":OK")); - assertThat(statusCaptor.getAllValues().get(statusCaptor.getAllValues().size() - 1), containsString(miljoeSomIkkeHarData + ":Feil= Personen finnes ikke")); - assertThat(progress.getIsTpsSyncEnv(), contains(miljoeSomHarData)); - assertThat(progress.getIsTpsSyncEnv(), contains(not(miljoeSomIkkeHarData))); - }) - .verifyComplete(); - } - - private BestillingProgress getProgress() { - - return BestillingProgress.builder() - .ident(IDENT) - .build(); - } - - private DollyPerson getDollyPerson() { - - return DollyPerson.builder() - .ident(IDENT) - .build(); - } - - private RsDollyUtvidetBestilling getBestilling(String pensjon) { - - return getBestilling(pensjon, ENVS); - } - - private RsDollyUtvidetBestilling getBestilling(String pensjon, String miljoe) { - - return getBestilling(pensjon, Set.of(miljoe)); - } - - private RsDollyUtvidetBestilling getBestilling(String pensjon, Set miljoe) { - - var dollyBestilling = new RsDollyUtvidetBestilling(); - dollyBestilling.setEnvironments(miljoe); - dollyBestilling.setPensjonforvalter(new PensjonData()); - - if (AP.equals(pensjon)) { - dollyBestilling.getPensjonforvalter() - .setAlderspensjon(new PensjonData.Alderspensjon()); - - } else if (UT.equals(pensjon)) { - dollyBestilling.getPensjonforvalter() - .setUforetrygd(new PensjonData.Uforetrygd()); - - } else { - dollyBestilling.getPensjonforvalter() - .setInntekt(new PensjonData.PoppInntekt()); - } - - return dollyBestilling; - } -} \ No newline at end of file