From e0cf5079d330ee62447f25a23a6a96a81e844ea3 Mon Sep 17 00:00:00 2001 From: Dragutin Vujovic Date: Thu, 7 Mar 2024 18:04:56 +0100 Subject: [PATCH] Small fixes in graphql requests --- .../client/dokarkiv/JournalpostData.java | 10 ++++++++++ .../client/dokarkiv/SafClient.java | 2 +- .../client/dokarkiv/SafClientImpl.java | 7 ++----- .../veilarbvedtaksstotte/service/VedtakService.java | 10 +++++----- .../veilarbvedtaksstotte/config/ClientTestConfig.java | 2 +- 5 files changed, 19 insertions(+), 12 deletions(-) create mode 100644 src/main/java/no/nav/veilarbvedtaksstotte/client/dokarkiv/JournalpostData.java diff --git a/src/main/java/no/nav/veilarbvedtaksstotte/client/dokarkiv/JournalpostData.java b/src/main/java/no/nav/veilarbvedtaksstotte/client/dokarkiv/JournalpostData.java new file mode 100644 index 00000000..66499637 --- /dev/null +++ b/src/main/java/no/nav/veilarbvedtaksstotte/client/dokarkiv/JournalpostData.java @@ -0,0 +1,10 @@ +package no.nav.veilarbvedtaksstotte.client.dokarkiv; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class JournalpostData { + + public Journalpost data; + +} diff --git a/src/main/java/no/nav/veilarbvedtaksstotte/client/dokarkiv/SafClient.java b/src/main/java/no/nav/veilarbvedtaksstotte/client/dokarkiv/SafClient.java index f9496e82..76805c22 100644 --- a/src/main/java/no/nav/veilarbvedtaksstotte/client/dokarkiv/SafClient.java +++ b/src/main/java/no/nav/veilarbvedtaksstotte/client/dokarkiv/SafClient.java @@ -11,6 +11,6 @@ public interface SafClient extends HealthCheck { List hentJournalposter(Fnr fnr); - Journalpost hentJournalpost(String journalpostId); + JournalpostData hentJournalpost(String journalpostId); } diff --git a/src/main/java/no/nav/veilarbvedtaksstotte/client/dokarkiv/SafClientImpl.java b/src/main/java/no/nav/veilarbvedtaksstotte/client/dokarkiv/SafClientImpl.java index 5ae44143..7a5eaab9 100644 --- a/src/main/java/no/nav/veilarbvedtaksstotte/client/dokarkiv/SafClientImpl.java +++ b/src/main/java/no/nav/veilarbvedtaksstotte/client/dokarkiv/SafClientImpl.java @@ -70,7 +70,7 @@ public List hentJournalposter(Fnr fnr) { } @SneakyThrows - public Journalpost hentJournalpost(String journalpostId) { + public JournalpostData hentJournalpost(String journalpostId) { GraphqlRequest graphqlRequest = new GraphqlRequest<>(createJournalpostGqlStr(), new QueryVariables(journalpostId)); Request request = new Request.Builder() @@ -81,10 +81,7 @@ public Journalpost hentJournalpost(String journalpostId) { try (Response response = RestClient.baseClient().newCall(request).execute()) { RestUtils.throwIfNotSuccessful(response); - assert response.body() != null; - Response body = response; - log.info(body.body().string()); - return RestUtils.parseJsonResponseOrThrow(body, Journalpost.class); + return RestUtils.parseJsonResponseOrThrow(response, JournalpostData.class); } } diff --git a/src/main/java/no/nav/veilarbvedtaksstotte/service/VedtakService.java b/src/main/java/no/nav/veilarbvedtaksstotte/service/VedtakService.java index 6c6638b0..ccbc1b32 100644 --- a/src/main/java/no/nav/veilarbvedtaksstotte/service/VedtakService.java +++ b/src/main/java/no/nav/veilarbvedtaksstotte/service/VedtakService.java @@ -6,7 +6,7 @@ import lombok.extern.slf4j.Slf4j; import no.nav.common.types.identer.AktorId; import no.nav.common.types.identer.Fnr; -import no.nav.veilarbvedtaksstotte.client.dokarkiv.Journalpost; +import no.nav.veilarbvedtaksstotte.client.dokarkiv.JournalpostData; import no.nav.veilarbvedtaksstotte.client.dokarkiv.OpprettetJournalpostDTO; import no.nav.veilarbvedtaksstotte.client.dokarkiv.SafClient; import no.nav.veilarbvedtaksstotte.client.veilederogenhet.Veileder; @@ -190,12 +190,12 @@ public void oppdaterUtkast(long vedtakId, OppdaterUtkastDTO vedtakDTO) { private void oppdatereDokumentIdforJournalfortOyeblikksbilde(String journalpostId) { try { - Journalpost journalpost = safClient.hentJournalpost(journalpostId); + JournalpostData journalpost = safClient.hentJournalpost(journalpostId); log.info("JOURNALPOST: " + new ObjectMapper().writeValueAsString(journalpost)); log.info("JOURNALPOST: " + journalpostId); - Arrays.stream(journalpost.dokumenter).forEach(x -> log.info(x.brevkode)); - Arrays.stream(journalpost.dokumenter).forEach(x -> log.info(x.tittel)); - Arrays.stream(journalpost.dokumenter).forEach(x -> log.info(x.dokumentInfoId)); + Arrays.stream(journalpost.data.dokumenter).forEach(x -> log.info(x.brevkode)); + Arrays.stream(journalpost.data.dokumenter).forEach(x -> log.info(x.tittel)); + Arrays.stream(journalpost.data.dokumenter).forEach(x -> log.info(x.dokumentInfoId)); } catch (Exception e) { log.error("Error oppdatereDokumentIdforJournalfortOyeblikksbilde " + e, e); } diff --git a/src/test/java/no/nav/veilarbvedtaksstotte/config/ClientTestConfig.java b/src/test/java/no/nav/veilarbvedtaksstotte/config/ClientTestConfig.java index 3df65383..6cf69a54 100644 --- a/src/test/java/no/nav/veilarbvedtaksstotte/config/ClientTestConfig.java +++ b/src/test/java/no/nav/veilarbvedtaksstotte/config/ClientTestConfig.java @@ -286,7 +286,7 @@ public List hentJournalposter(Fnr fnr) { } @Override - public Journalpost hentJournalpost(String journalpostId) { + public JournalpostData hentJournalpost(String journalpostId) { return null; }