From c7e299841d3ee8fe8c3a8698a3261974c70dafe2 Mon Sep 17 00:00:00 2001 From: Felix Reichenbach <felix.reichenbach@mgm-tp.com> Date: Thu, 23 Jan 2025 10:36:47 +0100 Subject: [PATCH] OZG-7161 add impressum link to root --- .../src/main/java/de/ozgcloud/alfa/Root.java | 5 +++++ .../java/de/ozgcloud/alfa/RootController.java | 1 + .../java/de/ozgcloud/alfa/RootProperties.java | 8 +++++++- .../de/ozgcloud/alfa/RootControllerTest.java | 16 ++++++++++++++++ .../java/de/ozgcloud/alfa/RootTestFactory.java | 3 +++ 5 files changed, 32 insertions(+), 1 deletion(-) diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/Root.java b/alfa-service/src/main/java/de/ozgcloud/alfa/Root.java index 297a9b071e..2b115dc293 100644 --- a/alfa-service/src/main/java/de/ozgcloud/alfa/Root.java +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/Root.java @@ -28,6 +28,8 @@ import java.util.Objects; import org.springframework.boot.info.BuildProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; @@ -40,6 +42,9 @@ public class Root { private boolean production; @Getter private String barrierefreiheitUrl; + @Getter + @JsonInclude(JsonInclude.Include.NON_NULL) + private String impressumUrl; public String getVersion() { return Objects.isNull(buildProperties) ? "--" : buildProperties.getVersion(); diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/RootController.java b/alfa-service/src/main/java/de/ozgcloud/alfa/RootController.java index a748d74394..b23b0bc15e 100644 --- a/alfa-service/src/main/java/de/ozgcloud/alfa/RootController.java +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/RootController.java @@ -57,6 +57,7 @@ public class RootController { .buildProperties(buildProperties) .production(production) .barrierefreiheitUrl(rootProperties.getBarrierefreiheitUrl()) + .impressumUrl(rootProperties.getImpressumUrl()) .build(); } } \ No newline at end of file diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/RootProperties.java b/alfa-service/src/main/java/de/ozgcloud/alfa/RootProperties.java index f7ee39c56b..d339fc0032 100644 --- a/alfa-service/src/main/java/de/ozgcloud/alfa/RootProperties.java +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/RootProperties.java @@ -13,8 +13,14 @@ import lombok.Setter; class RootProperties { /** - * URL pointing to the site with information about accessibility (Barrierefreiheit). + * URL pointing to the site with information about accessibility + * (Barrierefreiheit). */ private String barrierefreiheitUrl; + /** + * URL pointing to the impressum. + */ + private String impressumUrl; + } diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/RootControllerTest.java b/alfa-service/src/test/java/de/ozgcloud/alfa/RootControllerTest.java index d5a33f0934..61f01af21e 100644 --- a/alfa-service/src/test/java/de/ozgcloud/alfa/RootControllerTest.java +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/RootControllerTest.java @@ -106,6 +106,22 @@ class RootControllerTest { doRequest().andExpect(jsonPath("$.barrierefreiheitUrl").value(RootTestFactory.BARRIEREFREIHEIT_URL)); } + @SneakyThrows + @Test + void shouldHaveImpressumUrl() { + when(rootProperties.getImpressumUrl()).thenReturn(RootTestFactory.IMPRESSUM_URL); + + doRequest().andExpect(jsonPath("$.impressumUrl").value(RootTestFactory.IMPRESSUM_URL)); + } + + @SneakyThrows + @Test + void shouldNotHaveImpressumUrl() { + when(rootProperties.getImpressumUrl()).thenReturn(null); + + doRequest().andExpect(jsonPath("$.impressumUrl").doesNotHaveJsonPath()); + } + private ResultActions doRequest() throws Exception { return mockMvc.perform(get(RootController.PATH)).andExpect(status().isOk()); } diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/RootTestFactory.java b/alfa-service/src/test/java/de/ozgcloud/alfa/RootTestFactory.java index 858aa28e9c..bd8f69db2d 100644 --- a/alfa-service/src/test/java/de/ozgcloud/alfa/RootTestFactory.java +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/RootTestFactory.java @@ -23,9 +23,12 @@ */ package de.ozgcloud.alfa; +import com.thedeanda.lorem.LoremIpsum; + public class RootTestFactory { public static final String BARRIEREFREIHEIT_URL = "https://barrierefreiheit.de/"; + public static final String IMPRESSUM_URL = LoremIpsum.getInstance().getUrl(); public static Root create() { return createBuilder().build(); -- GitLab