From 9d5ba801bc37b344fb298bb7c202e940002b4e06 Mon Sep 17 00:00:00 2001 From: Sneha Date: Fri, 18 Oct 2024 09:36:31 +0200 Subject: [PATCH] =?UTF-8?q?Slettet=20fullmakt=20som=20var=20hentet=20fra?= =?UTF-8?q?=20pdl=20siden=20vi=20henter=20den=20fra=20repre=E2=80=A6=20(#3?= =?UTF-8?q?68)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Slettet fullmakt som var hentet fra pdl siden vi henter den fra representasjon nĂ¥ * Renamed file hentVergeOgFullmakt til hentVerge * Fikser codeql quality check feil --- .../veilarbperson/client/pdl/HentPerson.java | 16 ++---- .../veilarbperson/client/pdl/PdlClient.java | 3 +- .../client/pdl/PdlClientImpl.java | 10 ++-- .../controller/v2/PersonV2Controller.java | 4 +- .../controller/v3/PersonV3Controller.java | 4 +- ...ergeOgFullmaktData.java => VergeData.java} | 21 +------- .../service/PersonV2Service.java | 42 ++-------------- .../utils/VergeOgFullmaktDataMapper.java | 50 ++++++------------- ...{hentVergeOgFullmakt.gql => hentVerge.gql} | 7 --- .../client/PdlClientImplTest.java | 12 ++--- .../config/ClientTestConfig.java | 2 +- .../service/PersonV2ServiceTest.java | 38 ++------------ .../VergeOgFullmaktDataMapperTest.java | 30 ++++------- ...ponse.json => pdl-hentVerge-response.json} | 16 ------ 14 files changed, 50 insertions(+), 205 deletions(-) rename src/main/java/no/nav/veilarbperson/domain/{VergeOgFullmaktData.java => VergeData.java} (72%) rename src/main/resources/graphql/{hentVergeOgFullmakt.gql => hentVerge.gql} (75%) rename src/test/resources/{pdl-hentVergeOgFullmakt-response.json => pdl-hentVerge-response.json} (71%) diff --git a/src/main/java/no/nav/veilarbperson/client/pdl/HentPerson.java b/src/main/java/no/nav/veilarbperson/client/pdl/HentPerson.java index 02afc560..8d4cf848 100644 --- a/src/main/java/no/nav/veilarbperson/client/pdl/HentPerson.java +++ b/src/main/java/no/nav/veilarbperson/client/pdl/HentPerson.java @@ -227,23 +227,13 @@ public static class Folkeregistermetadata { } @Data - public static class Fullmakt { - private String motpartsPersonident; - private String motpartsRolle; - private List omraader; - private LocalDate gyldigFraOgMed; - private LocalDate gyldigTilOgMed; - } - - @Data - public static class VergeOgFullmakt { + public static class Verge { private List vergemaalEllerFremtidsfullmakt; - private List fullmakt; } @Data - public static class HentVergeOgFullmakt { - public VergeOgFullmakt hentPerson; + public static class HentVerge { + public Verge hentPerson; } @Data diff --git a/src/main/java/no/nav/veilarbperson/client/pdl/PdlClient.java b/src/main/java/no/nav/veilarbperson/client/pdl/PdlClient.java index c3b45c65..eb359cbd 100644 --- a/src/main/java/no/nav/veilarbperson/client/pdl/PdlClient.java +++ b/src/main/java/no/nav/veilarbperson/client/pdl/PdlClient.java @@ -3,14 +3,13 @@ import no.nav.common.health.HealthCheck; import no.nav.common.types.identer.Fnr; import no.nav.veilarbperson.client.pdl.domain.PdlRequest; -import no.nav.veilarbperson.domain.PersonFraPdlRequest; import java.util.List; public interface PdlClient extends HealthCheck { HentPerson.Person hentPerson(PdlRequest pdlRequest); - HentPerson.VergeOgFullmakt hentVergeOgFullmakt(PdlRequest pdlRequest); + HentPerson.Verge hentVerge(PdlRequest pdlRequest); HentPerson.PersonNavn hentPersonNavn(PdlRequest pdlRequest); diff --git a/src/main/java/no/nav/veilarbperson/client/pdl/PdlClientImpl.java b/src/main/java/no/nav/veilarbperson/client/pdl/PdlClientImpl.java index 48a4fe40..500403cc 100644 --- a/src/main/java/no/nav/veilarbperson/client/pdl/PdlClientImpl.java +++ b/src/main/java/no/nav/veilarbperson/client/pdl/PdlClientImpl.java @@ -40,7 +40,7 @@ public class PdlClientImpl implements PdlClient { private final String hentPersonQuery; - private final String hentVergeOgFullmaktQuery; + private final String hentVergeQuery; private final String hentPersonNavnQuery; @@ -61,7 +61,7 @@ public PdlClientImpl(String pdlUrl, Supplier userTokenProvider, Supplier this.hentPersonQuery = FileUtils.getResourceFileAsString("graphql/hentPerson.gql"); this.hentPersonBolkQuery = FileUtils.getResourceFileAsString("graphql/hentPersonBolk.gql"); this.hentPersonNavnQuery = FileUtils.getResourceFileAsString("graphql/hentPersonNavn.gql"); - this.hentVergeOgFullmaktQuery = FileUtils.getResourceFileAsString("graphql/hentVergeOgFullmakt.gql"); + this.hentVergeQuery = FileUtils.getResourceFileAsString("graphql/hentVerge.gql"); this.hentGeografiskTilknytningQuery = FileUtils.getResourceFileAsString("graphql/hentGeografiskTilknytning.gql"); this.hentTilrettelagtKommunikasjonQuery = FileUtils.getResourceFileAsString("graphql/hentTilrettelagtKommunikasjon.gql"); } @@ -73,9 +73,9 @@ public HentPerson.Person hentPerson(PdlRequest pdlRequest) { } @Override - public HentPerson.VergeOgFullmakt hentVergeOgFullmakt(PdlRequest pdlRequest) { - var request = new GqlRequest<>(hentVergeOgFullmaktQuery, new GqlVariables.HentPerson(pdlRequest.fnr(), false)); - return graphqlRequest(request, userTokenProvider.get(), pdlRequest.behandlingsnummer(), HentPerson.HentVergeOgFullmakt.class).hentPerson; + public HentPerson.Verge hentVerge(PdlRequest pdlRequest) { + var request = new GqlRequest<>(hentVergeQuery, new GqlVariables.HentPerson(pdlRequest.fnr(), false)); + return graphqlRequest(request, userTokenProvider.get(), pdlRequest.behandlingsnummer(), HentPerson.HentVerge.class).hentPerson; } @Override diff --git a/src/main/java/no/nav/veilarbperson/controller/v2/PersonV2Controller.java b/src/main/java/no/nav/veilarbperson/controller/v2/PersonV2Controller.java index c572fe0e..dd318c50 100644 --- a/src/main/java/no/nav/veilarbperson/controller/v2/PersonV2Controller.java +++ b/src/main/java/no/nav/veilarbperson/controller/v2/PersonV2Controller.java @@ -51,10 +51,10 @@ public Malform malform(@RequestParam("fnr") Fnr fnr) { @Deprecated @GetMapping("/vergeOgFullmakt") @Operation(summary = "Henter informasjon om verge og fullmakt for en person fra PDL") - public VergeOgFullmaktData hentVergemaalOgFullmakt(@RequestParam("fnr") Fnr fnr) throws IOException { + public VergeData hentVergemaal(@RequestParam("fnr") Fnr fnr) throws IOException { authService.stoppHvisEksternBruker(); authService.sjekkLesetilgang(fnr); - return personV2Service.hentVergeEllerFullmakt(new PersonFraPdlRequest(fnr, null)); + return personV2Service.hentVerge(new PersonFraPdlRequest(fnr, null)); } @Deprecated diff --git a/src/main/java/no/nav/veilarbperson/controller/v3/PersonV3Controller.java b/src/main/java/no/nav/veilarbperson/controller/v3/PersonV3Controller.java index e2aa5801..fd5f09cb 100644 --- a/src/main/java/no/nav/veilarbperson/controller/v3/PersonV3Controller.java +++ b/src/main/java/no/nav/veilarbperson/controller/v3/PersonV3Controller.java @@ -99,10 +99,10 @@ public Malform malform(@RequestBody PersonRequest personRequest) { @PostMapping("/person/hent-vergeOgFullmakt") @Operation(summary = "Henter informasjon om verge og fullmakt for en person fra PDL") - public VergeOgFullmaktData hentVergemaalOgFullmakt(@RequestBody PersonFraPdlRequest personFraPdlRequest) throws IOException { + public VergeData hentVergemaal(@RequestBody PersonFraPdlRequest personFraPdlRequest) throws IOException { authService.stoppHvisEksternBruker(); authService.sjekkLesetilgang(personFraPdlRequest.getFnr()); - return personV2Service.hentVergeEllerFullmakt(personFraPdlRequest); + return personV2Service.hentVerge(personFraPdlRequest); } @PostMapping("/person/hent-fullmakt") diff --git a/src/main/java/no/nav/veilarbperson/domain/VergeOgFullmaktData.java b/src/main/java/no/nav/veilarbperson/domain/VergeData.java similarity index 72% rename from src/main/java/no/nav/veilarbperson/domain/VergeOgFullmaktData.java rename to src/main/java/no/nav/veilarbperson/domain/VergeData.java index 3d49ad0d..fa6b606f 100644 --- a/src/main/java/no/nav/veilarbperson/domain/VergeOgFullmaktData.java +++ b/src/main/java/no/nav/veilarbperson/domain/VergeData.java @@ -4,16 +4,15 @@ import lombok.experimental.Accessors; import no.nav.veilarbperson.client.pdl.domain.VergemaalEllerFullmaktOmfangType; import no.nav.veilarbperson.client.pdl.domain.Vergetype; -import java.time.LocalDate; + import java.time.LocalDateTime; import java.util.List; @Data @Accessors(chain=true) -public class VergeOgFullmaktData { +public class VergeData { public List vergemaalEllerFremtidsfullmakt; - public List fullmakt; @Data public static class Navn { @@ -50,20 +49,4 @@ public static class Folkeregistermetadata { public LocalDateTime ajourholdstidspunkt; public LocalDateTime gyldighetstidspunkt; } - - @Data - public static class Omraade { - public String kode; - public String beskrivelse; - } - - @Data - public static class Fullmakt { - private String motpartsPersonident; - private Navn motpartsPersonNavn; - private String motpartsRolle; - private List omraader; - private LocalDate gyldigFraOgMed; - private LocalDate gyldigTilOgMed; - } } diff --git a/src/main/java/no/nav/veilarbperson/service/PersonV2Service.java b/src/main/java/no/nav/veilarbperson/service/PersonV2Service.java index c1bc4d87..acc2d22e 100644 --- a/src/main/java/no/nav/veilarbperson/service/PersonV2Service.java +++ b/src/main/java/no/nav/veilarbperson/service/PersonV2Service.java @@ -31,7 +31,6 @@ import static java.util.Optional.ofNullable; import static no.nav.veilarbperson.client.kontoregister.KontoregisterClientImpl.Mappers.fraNorg2Enhet; import static no.nav.veilarbperson.utils.PersonV2DataMapper.*; -import static no.nav.veilarbperson.utils.SecureLog.secureLog; import static no.nav.veilarbperson.utils.VergeOgFullmaktDataMapper.*; @Slf4j @@ -319,18 +318,9 @@ public TilrettelagtKommunikasjonData hentSpraakTolkInfo(PersonFraPdlRequest pers return new TilrettelagtKommunikasjonData().setTegnspraak(tegnSpraak).setTalespraak(taleSpraak); } - public VergeOgFullmaktData hentVergeEllerFullmakt(PersonFraPdlRequest personFraPdlRequest) throws IOException { - HentPerson.VergeOgFullmakt vergeOgFullmaktFraPdl = pdlClient.hentVergeOgFullmakt(new PdlRequest(personFraPdlRequest.getFnr(), personFraPdlRequest.getBehandlingsnummer())); - if (vergeOgFullmaktFraPdl.getVergemaalEllerFremtidsfullmakt().isEmpty() && vergeOgFullmaktFraPdl.getFullmakt().isEmpty()) { - throw new ResponseStatusException(HttpStatus.NO_CONTENT, "Person har ikke verge eller fullmakt i PDL"); - } - - VergeOgFullmaktData vergeOgFullmaktData = toVergeOgFullmaktData(vergeOgFullmaktFraPdl); - - flettMotpartsPersonNavnTilFullmakt(vergeOgFullmaktData, personFraPdlRequest.getBehandlingsnummer()); - flettBeskrivelseForFullmaktOmraader(vergeOgFullmaktData); - - return vergeOgFullmaktData; + public VergeData hentVerge(PersonFraPdlRequest personFraPdlRequest) { + HentPerson.Verge vergeOgFullmaktFraPdl = pdlClient.hentVerge(new PdlRequest(personFraPdlRequest.getFnr(), personFraPdlRequest.getBehandlingsnummer())); + return toVerge(vergeOgFullmaktFraPdl); } public FullmaktDTO hentFullmakt(PersonRequest personRequest) throws IOException { @@ -361,32 +351,6 @@ public void flettBeskrivelseTilFullmaktTema(FullmaktDTO fullmaktDto) { } } - public void flettBeskrivelseForFullmaktOmraader(VergeOgFullmaktData vergeOgFullmaktData) { - vergeOgFullmaktData.getFullmakt().forEach(fullmakt -> { - if (!fullmakt.getOmraader().isEmpty() && fullmakt.getOmraader().getFirst().getKode().equals("*")) { - fullmakt.getOmraader().getFirst().setBeskrivelse("alle ytelser"); - } else { - fullmakt.getOmraader().forEach(omraade -> - omraade.setBeskrivelse(kodeverkService.getBeskrivelseForTema(omraade.getKode())) - ); - } - } - ); - } - - public void flettMotpartsPersonNavnTilFullmakt(VergeOgFullmaktData vergeOgFullmaktData, String behandlingsnummer) { - vergeOgFullmaktData.getFullmakt().forEach(fullmakt -> { - HentPerson.PersonNavn fullmaktNavn = pdlClient.hentPersonNavn(new PdlRequest(Fnr.of(fullmakt.getMotpartsPersonident()), behandlingsnummer)); - - if (fullmaktNavn.getNavn().isEmpty()) { - throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Fant ikke motpartspersonnavn til fullmakt"); - } - - VergeOgFullmaktData.Navn personNavn = VergeOgFullmaktDataMapper.personNavnMapper(fullmaktNavn.getNavn()); - fullmakt.setMotpartsPersonNavn(personNavn); - }); - } - public String hentMalform(Fnr fnr) { try { DigdirKontaktinfo kontaktinfo = digdirClient.hentKontaktInfo(fnr); diff --git a/src/main/java/no/nav/veilarbperson/utils/VergeOgFullmaktDataMapper.java b/src/main/java/no/nav/veilarbperson/utils/VergeOgFullmaktDataMapper.java index f7c5c668..fb3257a2 100644 --- a/src/main/java/no/nav/veilarbperson/utils/VergeOgFullmaktDataMapper.java +++ b/src/main/java/no/nav/veilarbperson/utils/VergeOgFullmaktDataMapper.java @@ -3,18 +3,16 @@ import no.nav.veilarbperson.client.pdl.HentPerson; import no.nav.veilarbperson.client.representasjon.ReprFullmaktData; import no.nav.veilarbperson.domain.FullmaktDTO; -import no.nav.veilarbperson.domain.VergeOgFullmaktData; +import no.nav.veilarbperson.domain.VergeData; -import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; public class VergeOgFullmaktDataMapper { - public static VergeOgFullmaktData toVergeOgFullmaktData(HentPerson.VergeOgFullmakt vergeOgFullmaktFraPdl) { - return new VergeOgFullmaktData() - .setVergemaalEllerFremtidsfullmakt(vergemaalEllerFremtidsfullmaktMapper(vergeOgFullmaktFraPdl.getVergemaalEllerFremtidsfullmakt())) - .setFullmakt(fullmaktMapper(vergeOgFullmaktFraPdl.getFullmakt())); + public static VergeData toVerge(HentPerson.Verge vergeOgFullmaktFraPdl) { + return new VergeData() + .setVergemaalEllerFremtidsfullmakt(vergemaalEllerFremtidsfullmaktMapper(vergeOgFullmaktFraPdl.getVergemaalEllerFremtidsfullmakt())); } public static FullmaktDTO toFullmaktDTO(List fullmaktListe) { @@ -38,7 +36,7 @@ public static List representasjonFullmaktMapper(List omraadeMapper(List omraade) { - List omraadeMedHandlinger = omraade.stream().map(omraadeMedHandling -> { + return omraade.stream().map(omraadeMedHandling -> { List reprHandlingTyper = omraadeMedHandling.getHandling(); List fullmaktHandlingTyper = reprHandlingTyper.stream().map( @@ -50,13 +48,12 @@ public static List omraadeMapper(List vergemaalEllerFremtidsfullmaktMapper(List vergemaalEllerFremtidsfullmaktListe) { + public static List vergemaalEllerFremtidsfullmaktMapper(List vergemaalEllerFremtidsfullmaktListe) { return vergemaalEllerFremtidsfullmaktListe.stream() .map(vergemaalEllerFremtidsfullmakt -> - new VergeOgFullmaktData.VergemaalEllerFremtidsfullmakt() + new VergeData.VergemaalEllerFremtidsfullmakt() .setType(vergemaalEllerFremtidsfullmakt.getType()) .setEmbete(vergemaalEllerFremtidsfullmakt.getEmbete()) .setVergeEllerFullmektig(vergeEllerFullmektigMapper(vergemaalEllerFremtidsfullmakt.getVergeEllerFullmektig())) @@ -64,44 +61,27 @@ public static List vergemaal .collect(Collectors.toList()); } - public static VergeOgFullmaktData.VergeEllerFullmektig vergeEllerFullmektigMapper(HentPerson.VergeEllerFullmektig vergeEllerFullmektig) { - return new VergeOgFullmaktData.VergeEllerFullmektig() + public static VergeData.VergeEllerFullmektig vergeEllerFullmektigMapper(HentPerson.VergeEllerFullmektig vergeEllerFullmektig) { + return new VergeData.VergeEllerFullmektig() .setNavn(vergeNavnMapper(vergeEllerFullmektig.getNavn())) .setMotpartsPersonident(vergeEllerFullmektig.getMotpartsPersonident()) .setOmfang(vergeEllerFullmektig.getOmfang()); } - public static VergeOgFullmaktData.VergeNavn vergeNavnMapper(HentPerson.VergeNavn vergeNavn) { + public static VergeData.VergeNavn vergeNavnMapper(HentPerson.VergeNavn vergeNavn) { return (vergeNavn!=null) - ? new VergeOgFullmaktData.VergeNavn().setFornavn(vergeNavn.getFornavn()).setMellomnavn(vergeNavn.getMellomnavn()).setEtternavn(vergeNavn.getEtternavn()) + ? new VergeData.VergeNavn().setFornavn(vergeNavn.getFornavn()).setMellomnavn(vergeNavn.getMellomnavn()).setEtternavn(vergeNavn.getEtternavn()) : null; } - public static VergeOgFullmaktData.Navn personNavnMapper(List motpartspersonnavn) { + public static VergeData.Navn personNavnMapper(List motpartspersonnavn) { HentPerson.Navn navn = PersonV2DataMapper.getFirstElement(motpartspersonnavn); - return new VergeOgFullmaktData.Navn().setFornavn(navn.getFornavn()).setMellomnavn(navn.getMellomnavn()).setEtternavn(navn.getEtternavn()).setForkortetNavn(navn.getForkortetNavn()); + return new VergeData.Navn().setFornavn(navn.getFornavn()).setMellomnavn(navn.getMellomnavn()).setEtternavn(navn.getEtternavn()).setForkortetNavn(navn.getForkortetNavn()); } - public static VergeOgFullmaktData.Folkeregistermetadata folkeregisterMetadataMapper(HentPerson.Folkeregistermetadata folkeregistermetadata) { - return new VergeOgFullmaktData.Folkeregistermetadata() + public static VergeData.Folkeregistermetadata folkeregisterMetadataMapper(HentPerson.Folkeregistermetadata folkeregistermetadata) { + return new VergeData.Folkeregistermetadata() .setAjourholdstidspunkt(folkeregistermetadata.getAjourholdstidspunkt()) .setGyldighetstidspunkt(folkeregistermetadata.getGyldighetstidspunkt()); } - - public static List fullmaktMapper(List fullmaktListe) { - List fullmakter = new ArrayList<>(); - fullmaktListe.forEach(fullmakt -> { - ArrayList omraadeKodeListe = new ArrayList<>(); - fullmakt.getOmraader().forEach(omraade -> omraadeKodeListe.add(new VergeOgFullmaktData.Omraade().setKode(omraade))); - - fullmakter.add(new VergeOgFullmaktData.Fullmakt() - .setMotpartsPersonident(fullmakt.getMotpartsPersonident()) - .setMotpartsRolle(fullmakt.getMotpartsRolle()) - .setOmraader(omraadeKodeListe) - .setGyldigFraOgMed(fullmakt.getGyldigFraOgMed()) - .setGyldigTilOgMed(fullmakt.getGyldigTilOgMed())); - } - ); - return fullmakter; - } } diff --git a/src/main/resources/graphql/hentVergeOgFullmakt.gql b/src/main/resources/graphql/hentVerge.gql similarity index 75% rename from src/main/resources/graphql/hentVergeOgFullmakt.gql rename to src/main/resources/graphql/hentVerge.gql index c8576adf..773ee218 100644 --- a/src/main/resources/graphql/hentVergeOgFullmakt.gql +++ b/src/main/resources/graphql/hentVerge.gql @@ -17,13 +17,6 @@ query($ident: ID!, $historikk: Boolean!) { gyldighetstidspunkt } } - fullmakt(historikk:$historikk) { - motpartsPersonident - motpartsRolle - omraader - gyldigFraOgMed - gyldigTilOgMed - } } } diff --git a/src/test/java/no/nav/veilarbperson/client/PdlClientImplTest.java b/src/test/java/no/nav/veilarbperson/client/PdlClientImplTest.java index 38c56cbd..03c9e02c 100644 --- a/src/test/java/no/nav/veilarbperson/client/PdlClientImplTest.java +++ b/src/test/java/no/nav/veilarbperson/client/PdlClientImplTest.java @@ -161,7 +161,7 @@ public void hentePerson_skal_parse_request() { @Test public void henteVergeOgFullmakt_skal_parse_request() { - String hentVergeOgFullmaktResponseJson = TestUtils.readTestResourceFile("pdl-hentVergeOgFullmakt-response.json"); + String hentVergeOgFullmaktResponseJson = TestUtils.readTestResourceFile("pdl-hentVerge-response.json"); String apiUrl = "http://localhost:" + wireMockRule.port(); givenThat(post(anyUrl()) @@ -172,9 +172,9 @@ public void henteVergeOgFullmakt_skal_parse_request() { PdlClientImpl pdlClient = new PdlClientImpl(apiUrl, () -> PDL_AUTH, () -> PDL_AUTH); - HentPerson.VergeOgFullmakt vergeOgFullmakt = pdlClient.hentVergeOgFullmakt(new PdlRequest(FNR, null)); + HentPerson.Verge verge = pdlClient.hentVerge(new PdlRequest(FNR, null)); - HentPerson.VergemaalEllerFremtidsfullmakt vergemaal = vergeOgFullmakt.getVergemaalEllerFremtidsfullmakt().get(0); + HentPerson.VergemaalEllerFremtidsfullmakt vergemaal = verge.getVergemaalEllerFremtidsfullmakt().get(0); HentPerson.VergeEllerFullmektig vergeEllerFullmektig = vergemaal.getVergeEllerFullmektig(); assertEquals(Vergetype.MIDLERTIDIG_FOR_VOKSEN, vergemaal.getType()); @@ -182,12 +182,6 @@ public void henteVergeOgFullmakt_skal_parse_request() { assertEquals(VergemaalEllerFullmaktOmfangType.OEKONOMISKE_INTERESSER, vergeEllerFullmektig.getOmfang()); assertEquals("VergeMotpartsPersonident1", vergeEllerFullmektig.getMotpartsPersonident()); assertEquals("vergeEtternavn1", vergeEllerFullmektig.getNavn().getEtternavn()); - - HentPerson.Fullmakt fullmakt = vergeOgFullmakt.getFullmakt().get(0); - - assertEquals("motpartsPersonident1", fullmakt.getMotpartsPersonident()); - assertEquals("motpartsRolle1", fullmakt.getMotpartsRolle()); - assertEquals(2, fullmakt.getOmraader().size()); } @Test diff --git a/src/test/java/no/nav/veilarbperson/config/ClientTestConfig.java b/src/test/java/no/nav/veilarbperson/config/ClientTestConfig.java index d03da092..2456c635 100644 --- a/src/test/java/no/nav/veilarbperson/config/ClientTestConfig.java +++ b/src/test/java/no/nav/veilarbperson/config/ClientTestConfig.java @@ -224,7 +224,7 @@ public HentPerson.Person hentPerson(PdlRequest pdlRequest) { } @Override - public HentPerson.VergeOgFullmakt hentVergeOgFullmakt(PdlRequest pdlRequest) { + public HentPerson.Verge hentVerge(PdlRequest pdlRequest) { return null; } diff --git a/src/test/java/no/nav/veilarbperson/service/PersonV2ServiceTest.java b/src/test/java/no/nav/veilarbperson/service/PersonV2ServiceTest.java index 9b415f6a..4ac07a6a 100644 --- a/src/test/java/no/nav/veilarbperson/service/PersonV2ServiceTest.java +++ b/src/test/java/no/nav/veilarbperson/service/PersonV2ServiceTest.java @@ -91,9 +91,9 @@ public HentPerson.PersonNavn hentPersonNavn(PdlRequest pdlRequest) { return pdlClient.hentPersonNavn(pdlRequest); } - public HentPerson.VergeOgFullmakt hentVergeOgFullmakt(Fnr fnr) { - configurePdlResponse("pdl-hentVergeOgFullmakt-response.json", fnr.get()); - return pdlClient.hentVergeOgFullmakt(new PdlRequest(fnr, null)); + public HentPerson.Verge hentVerge(Fnr fnr) { + configurePdlResponse("pdl-hentVerge-response.json", fnr.get()); + return pdlClient.hentVerge(new PdlRequest(fnr, null)); } public HentPerson.GeografiskTilknytning hentGeografisktilknytning(PdlRequest pdlRequest) { @@ -486,39 +486,7 @@ public void flettBeskrivelseFraKodeverkTest() { assertEquals("LANDKODE", kontaktadresse.getUtenlandskAdresseIFrittFormat().getLandkode()); } - @Test - public void flettBeskrivelseForFullmaktOmraader() { - mockKodeverk(); - HentPerson.VergeOgFullmakt vergeOgFullmaktFraPdl = hentVergeOgFullmakt(FNR); - VergeOgFullmaktData vergeOgFullmaktData = VergeOgFullmaktDataMapper.toVergeOgFullmaktData(vergeOgFullmaktFraPdl); - personV2Service.flettBeskrivelseForFullmaktOmraader(vergeOgFullmaktData); - - List omraader = vergeOgFullmaktData.getFullmakt().get(0).getOmraader(); - - assertEquals("AAP", omraader.get(0).getKode()); - assertEquals("DAG", omraader.get(1).getKode()); - - assertEquals("Arbeidsavklaringpenger", omraader.get(0).getBeskrivelse()); - assertEquals("Dagpenger", omraader.get(1).getBeskrivelse()); - - List omraade = vergeOgFullmaktData.getFullmakt().get(1).getOmraader(); - assertEquals("*", omraade.get(0).getKode()); - assertEquals("alle ytelser", omraade.get(0).getBeskrivelse()); - } - - @Test - public void flettMotpartsPersonNavnTilFullmakt() { - configurePdlResponse("pdl-hentPersonNavn-response.json", "motpartsPersonident1"); - configurePdlResponse("pdl-hentPersonNavn-response.json", "motpartsPersonident2"); - HentPerson.VergeOgFullmakt vergeOgFullmaktFraPdl = hentVergeOgFullmakt(FNR); - VergeOgFullmaktData vergeOgFullmaktData = VergeOgFullmaktDataMapper.toVergeOgFullmaktData(vergeOgFullmaktFraPdl); - personV2Service.flettMotpartsPersonNavnTilFullmakt(vergeOgFullmaktData, null); - - List fullmaktListe = vergeOgFullmaktData.getFullmakt(); - - assertEquals("NORDMANN OLA", fullmaktListe.get(0).getMotpartsPersonNavn().getForkortetNavn()); - } @Test public void personNavnMapperTest() { diff --git a/src/test/java/no/nav/veilarbperson/utils/mappers/VergeOgFullmaktDataMapperTest.java b/src/test/java/no/nav/veilarbperson/utils/mappers/VergeOgFullmaktDataMapperTest.java index 245807f3..c75c8e48 100644 --- a/src/test/java/no/nav/veilarbperson/utils/mappers/VergeOgFullmaktDataMapperTest.java +++ b/src/test/java/no/nav/veilarbperson/utils/mappers/VergeOgFullmaktDataMapperTest.java @@ -6,8 +6,7 @@ import no.nav.veilarbperson.client.pdl.domain.VergemaalEllerFullmaktOmfangType; import no.nav.veilarbperson.client.pdl.domain.Vergetype; import no.nav.veilarbperson.config.PdlClientTestConfig; -import no.nav.veilarbperson.domain.PersonFraPdlRequest; -import no.nav.veilarbperson.domain.VergeOgFullmaktData; +import no.nav.veilarbperson.domain.VergeData; import no.nav.veilarbperson.utils.TestUtils; import no.nav.veilarbperson.utils.VergeOgFullmaktDataMapper; import org.junit.Test; @@ -24,14 +23,14 @@ public class VergeOgFullmaktDataMapperTest extends PdlClientTestConfig { private static Fnr FNR = TestUtils.fodselsnummerForDato("1980-01-01"); - public HentPerson.VergeOgFullmakt hentVergeOgFullmakt(Fnr fnr) { - configurePdlResponse("pdl-hentVergeOgFullmakt-response.json"); - return getPdlClient().hentVergeOgFullmakt(new PdlRequest(fnr, null)); + public HentPerson.Verge hentVerge(Fnr fnr) { + configurePdlResponse("pdl-hentVerge-response.json"); + return getPdlClient().hentVerge(new PdlRequest(fnr, null)); } @Test public void vergetypeOgOmfangEnumMapperTest() { - List vergemaal = hentVergeOgFullmakt(FNR).getVergemaalEllerFremtidsfullmakt(); + List vergemaal = hentVerge(FNR).getVergemaalEllerFremtidsfullmakt(); VergemaalEllerFullmaktOmfangType omfang1 = ofNullable(vergemaal.get(0).getVergeEllerFullmektig()).map(HentPerson.VergeEllerFullmektig::getOmfang).get(); VergemaalEllerFullmaktOmfangType omfang2 = ofNullable(vergemaal.get(1).getVergeEllerFullmektig()).map(HentPerson.VergeEllerFullmektig::getOmfang).get(); @@ -45,34 +44,25 @@ public void vergetypeOgOmfangEnumMapperTest() { @Test public void toVergeOgFullmaktDataTest() { - HentPerson.VergeOgFullmakt vergeOgFullmaktFraPdl = hentVergeOgFullmakt(FNR); - VergeOgFullmaktData vergeOgFullmaktData = VergeOgFullmaktDataMapper.toVergeOgFullmaktData(vergeOgFullmaktFraPdl); + HentPerson.Verge vergeOgFullmaktFraPdl = hentVerge(FNR); + VergeData vergeOgFullmaktData = VergeOgFullmaktDataMapper.toVerge(vergeOgFullmaktFraPdl); - List vergemaalEllerFremtidsfullmaktData = vergeOgFullmaktData.getVergemaalEllerFremtidsfullmakt(); + List vergemaalEllerFremtidsfullmaktData = vergeOgFullmaktData.getVergemaalEllerFremtidsfullmakt(); assertEquals(2, vergemaalEllerFremtidsfullmaktData.size()); assertEquals(Vergetype.MIDLERTIDIG_FOR_VOKSEN, vergemaalEllerFremtidsfullmaktData.get(0).getType()); assertEquals("VergemallEmbete", vergemaalEllerFremtidsfullmaktData.get(0).getEmbete()); - VergeOgFullmaktData.VergeEllerFullmektig vergeEllerFullmektigData = vergemaalEllerFremtidsfullmaktData.get(0).getVergeEllerFullmektig(); + VergeData.VergeEllerFullmektig vergeEllerFullmektigData = vergemaalEllerFremtidsfullmaktData.get(0).getVergeEllerFullmektig(); assertEquals("vergeFornavn1", vergeEllerFullmektigData.getNavn().getFornavn()); assertEquals("VergeMotpartsPersonident1", vergeEllerFullmektigData.getMotpartsPersonident()); assertEquals(VergemaalEllerFullmaktOmfangType.OEKONOMISKE_INTERESSER, vergeEllerFullmektigData.getOmfang()); - VergeOgFullmaktData.Folkeregistermetadata folkeregistermetadata = vergemaalEllerFremtidsfullmaktData.get(0).getFolkeregistermetadata(); + VergeData.Folkeregistermetadata folkeregistermetadata = vergemaalEllerFremtidsfullmaktData.get(0).getFolkeregistermetadata(); LocalDateTime localDateTime = LocalDateTime.of(LocalDate.of(2021, 03, 02), LocalTime.of(13, 00, 42)); assertEquals(localDateTime, folkeregistermetadata.getAjourholdstidspunkt()); assertEquals(localDateTime, folkeregistermetadata.getGyldighetstidspunkt()); - - List fullmakts = vergeOgFullmaktData.getFullmakt(); - - assertEquals(2, fullmakts.size()); - assertEquals("motpartsPersonident1", fullmakts.get(0).getMotpartsPersonident()); - assertEquals("motpartsRolle1", fullmakts.get(0).getMotpartsRolle()); - - assertEquals(LocalDate.of(2021, 01, 15), fullmakts.get(0).getGyldigFraOgMed()); - assertEquals(LocalDate.of(2021, 01, 15), fullmakts.get(0).getGyldigFraOgMed()); } } diff --git a/src/test/resources/pdl-hentVergeOgFullmakt-response.json b/src/test/resources/pdl-hentVerge-response.json similarity index 71% rename from src/test/resources/pdl-hentVergeOgFullmakt-response.json rename to src/test/resources/pdl-hentVerge-response.json index 2d892efc..56f2342d 100644 --- a/src/test/resources/pdl-hentVergeOgFullmakt-response.json +++ b/src/test/resources/pdl-hentVerge-response.json @@ -36,22 +36,6 @@ "gyldighetstidspunkt": "2021-03-02T13:00:42" } } - ], - "fullmakt": [ - { - "motpartsPersonident": "motpartsPersonident1", - "motpartsRolle": "motpartsRolle1", - "omraader": ["AAP", "DAG"], - "gyldigFraOgMed": "2021-01-15", - "gyldigTilOgMed": "2021-01-15" - }, - { - "motpartsPersonident": "motpartsPersonident2", - "motpartsRolle": "motpartsRolle2", - "omraader": ["*"], - "gyldigFraOgMed": "2021-01-15", - "gyldigTilOgMed": "2021-01-15" - } ] } }