diff --git a/apps/backend/src/main/java/no/nav/data/integration/behandling/BehandlingService.java b/apps/backend/src/main/java/no/nav/data/integration/behandling/BehandlingService.java index 2df5298c5..24170a390 100644 --- a/apps/backend/src/main/java/no/nav/data/integration/behandling/BehandlingService.java +++ b/apps/backend/src/main/java/no/nav/data/integration/behandling/BehandlingService.java @@ -24,6 +24,19 @@ public class BehandlingService { private final BkatClient bkatClient; + private List getDatabehandlerForBehandling(BkatProcess process) { + List dataBehandlerList = new ArrayList<>(); + if(!process.getDataProcessing().getProcessors().isEmpty()) { + process.getDataProcessing().getProcessors().forEach(databehandlerId -> { + DataBehandler databehandler = getDataBehandler(databehandlerId); + if(databehandler != null) { + dataBehandlerList.add(databehandler); + } + }); + } + return dataBehandlerList; + } + public Behandling getBehandling(String id) { BkatProcess process = bkatClient.getProcess(id); if (process == null) { @@ -31,15 +44,8 @@ public Behandling getBehandling(String id) { } Behandling behandling = process.convertToBehandling(); - List dataBehandlerList = new ArrayList<>(); - if(!process.getDataProcessing().getProcessors().isEmpty()) { - process.getDataProcessing().getProcessors().forEach(databehandlerId -> { - DataBehandler databehandler = getDataBehandler(databehandlerId); - dataBehandlerList.add(databehandler); - }); - } + List dataBehandlerList = getDatabehandlerForBehandling(process); behandling.setDataBehandlerList(dataBehandlerList); - return behandling; } diff --git a/apps/backend/src/main/java/no/nav/data/integration/behandling/dto/BkatProcess.java b/apps/backend/src/main/java/no/nav/data/integration/behandling/dto/BkatProcess.java index 8efbb9897..55fa8a1f5 100644 --- a/apps/backend/src/main/java/no/nav/data/integration/behandling/dto/BkatProcess.java +++ b/apps/backend/src/main/java/no/nav/data/integration/behandling/dto/BkatProcess.java @@ -48,6 +48,7 @@ public Behandling convertToBehandling() { .policies(policies.stream().map(BkatPolicy::convertToPolyResponse).toList()) .automatiskBehandling(automaticProcessing) .profilering(profiling) + .dataBehandlerList(List.of()) .build(); } } diff --git a/apps/backend/src/test/java/no/nav/data/etterlevelse/behandling/BehandlingControllerIT.java b/apps/backend/src/test/java/no/nav/data/etterlevelse/behandling/BehandlingControllerIT.java index 092a92269..69cc7982c 100644 --- a/apps/backend/src/test/java/no/nav/data/etterlevelse/behandling/BehandlingControllerIT.java +++ b/apps/backend/src/test/java/no/nav/data/etterlevelse/behandling/BehandlingControllerIT.java @@ -4,7 +4,7 @@ import no.nav.data.etterlevelse.common.domain.ExternalCode; import no.nav.data.integration.behandling.BehandlingController.BehandlingPage; import no.nav.data.integration.behandling.dto.Behandling; -import no.nav.data.integration.behandling.dto.DataProsessering; +import no.nav.data.integration.behandling.dto.DataBehandler; import no.nav.data.integration.behandling.dto.PolicyResponse; import org.junit.jupiter.api.Test; import org.springframework.http.HttpStatus; @@ -22,7 +22,7 @@ void getBehandling() { .getForEntity("/behandling/{Id}", Behandling.class, "74288ec1-c45d-4b9f-b799-33539981a690"); assertThat(behandling.getBody()).isNotNull(); assertThat(behandling.getStatusCode()).isEqualTo(HttpStatus.OK); - assertResponse(behandling.getBody()); + assertResponse(behandling.getBody(),false); } @Test @@ -32,11 +32,11 @@ void searchBehandling() { assertThat(behandlinger.getBody()).isNotNull(); assertThat(behandlinger.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(behandlinger.getBody().getContent()).hasSize(1); - assertResponse(behandlinger.getBody().getContent().get(0)); + assertResponse(behandlinger.getBody().getContent().get(0),true); } - private void assertResponse(Behandling behandling) { - assertThat(behandling).isEqualTo(Behandling.builder() + private void assertResponse(Behandling behandling, boolean searchResponse) { + Behandling behandlingToCompare = Behandling.builder() .id("74288ec1-c45d-4b9f-b799-33539981a690") .navn("process name") .nummer(101) @@ -46,15 +46,21 @@ private void assertResponse(Behandling behandling) { .linje(ExternalCode.builder().list("LINJE").code("LIN").shortName("Lin").description("desc").external(true).build()) .system(ExternalCode.builder().list("SYSTEM").code("SYS").shortName("Sys").description("desc").external(true).build()) .team("team") + .dataBehandlerList(List.of()) .policies(List.of(PolicyResponse.builder() - .id("test policy") - .opplysningsTypeId("test information type") - .opplysningsTypeNavn("test information type") - .sensitivity(ExternalCode.builder().list("SENSITIVITY").code("POL").shortName("pol").description("desc").external(true).build()) - .behandlingId(behandling.getId()) - .personKategorier(List.of(ExternalCode.builder().list("SUBJECT_CATEGORY").code("BRUKER").shortName("Bruker").description("desc").external(true).build())) - .build())) - .dataProsessering(DataProsessering.builder().benyttesDataBehandlere(true).dataBehandlerIds(List.of("processor_1")).build()) - .build()); + .id("test policy") + .opplysningsTypeId("test information type") + .opplysningsTypeNavn("test information type") + .sensitivity(ExternalCode.builder().list("SENSITIVITY").code("POL").shortName("pol").description("desc").external(true).build()) + .behandlingId(behandling.getId()) + .personKategorier(List.of(ExternalCode.builder().list("SUBJECT_CATEGORY").code("BRUKER").shortName("Bruker").description("desc").external(true).build())) + .build())) + .build(); + + if(!searchResponse) { + behandlingToCompare.setDataBehandlerList(List.of(DataBehandler.builder().id("processor_1").navn("processor_1").build())); + } + + assertThat(behandling).isEqualTo(behandlingToCompare); } -} \ No newline at end of file +} diff --git a/apps/backend/src/test/java/no/nav/data/integration/behandling/BkatMocks.java b/apps/backend/src/test/java/no/nav/data/integration/behandling/BkatMocks.java index 59fa146bb..78091fdc3 100644 --- a/apps/backend/src/test/java/no/nav/data/integration/behandling/BkatMocks.java +++ b/apps/backend/src/test/java/no/nav/data/integration/behandling/BkatMocks.java @@ -7,6 +7,7 @@ import no.nav.data.integration.behandling.dto.BkatInformationTypeShort; import no.nav.data.integration.behandling.dto.BkatPolicy; import no.nav.data.integration.behandling.dto.BkatProcess; +import no.nav.data.integration.behandling.dto.BkatProcessor; import java.util.List; @@ -20,6 +21,7 @@ public class BkatMocks { public static void mock() { stubFor(get("/bkat/process/74288ec1-c45d-4b9f-b799-33539981a690").willReturn(okJson(toJson(processMockResponse())))); + stubFor(get("/bkat/processor/processor_1").willReturn(okJson(toJson(processorMockResponse())))); stubFor(get("/bkat/process?pageNumber=0&pageSize=20").willReturn(okJson(toJson(new RestResponsePage<>(List.of(processMockResponse())))))); stubFor(post("/bkat/process/shortbyid").willReturn(okJson(toJson(new RestResponsePage<>(List.of(processMockResponse())))))); stubFor(get("/bkat/process/search/name?includePurpose=true").willReturn(okJson(toJson(new RestResponsePage<>(List.of(processMockResponse())))))); @@ -29,6 +31,13 @@ public static BkatProcess processMockResponse() { return processMockResponse("74288ec1-c45d-4b9f-b799-33539981a690", 101); } + public static BkatProcessor processorMockResponse () { + return BkatProcessor.builder() + .id("processor_1") + .name("processor_1") + .build(); + } + public static BkatProcess stubProcess(String id, int num) { var resp = processMockResponse(id, num); stubFor(get("/bkat/process/%s".formatted(id)).willReturn(okJson(toJson(resp))));