From 99cdb70b99de3b4460296d5098f0787c8b2ee927 Mon Sep 17 00:00:00 2001 From: JordenReuter <149687553+JordenReuter@users.noreply.github.com> Date: Fri, 17 May 2024 12:14:28 +0200 Subject: [PATCH] feat: handle null value and adjusted test (#27) --- .../tkit/onecx/shell/bff/rs/mappers/WorkspaceConfigMapper.java | 2 ++ .../onecx/shell/bff/rs/WorkspaceConfigRestControllerTest.java | 1 + 2 files changed, 3 insertions(+) diff --git a/src/main/java/org/tkit/onecx/shell/bff/rs/mappers/WorkspaceConfigMapper.java b/src/main/java/org/tkit/onecx/shell/bff/rs/mappers/WorkspaceConfigMapper.java index 597cc88..244cea7 100644 --- a/src/main/java/org/tkit/onecx/shell/bff/rs/mappers/WorkspaceConfigMapper.java +++ b/src/main/java/org/tkit/onecx/shell/bff/rs/mappers/WorkspaceConfigMapper.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.stream.Collectors; import org.mapstruct.AfterMapping; @@ -110,6 +111,7 @@ default SlotDTO createSlot(WorkspaceWrapperSlot slot) { SlotDTO result = new SlotDTO().name(slot.getName()); if (slot.getComponents() != null) { + slot.getComponents().removeIf(Objects::isNull); slot.getComponents() .forEach(c -> result.addComponentsItem(componentName(c.getProductName(), c.getAppId(), c.getName()))); } diff --git a/src/test/java/org/tkit/onecx/shell/bff/rs/WorkspaceConfigRestControllerTest.java b/src/test/java/org/tkit/onecx/shell/bff/rs/WorkspaceConfigRestControllerTest.java index ed093f8..544303a 100644 --- a/src/test/java/org/tkit/onecx/shell/bff/rs/WorkspaceConfigRestControllerTest.java +++ b/src/test/java/org/tkit/onecx/shell/bff/rs/WorkspaceConfigRestControllerTest.java @@ -234,6 +234,7 @@ void loadWorkspaceConfigByBaseUrlTest() { .addMicrofrontendsItem(new Microfrontend().basePath("/app1").mfeId("app1"))) .addSlotsItem( new WorkspaceWrapperSlot().name("slot1") + .addComponentsItem(null) .addComponentsItem( new WorkspaceWrapperComponent().productName("product1").appId("app1") .name("App1Component"))