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 297a9b071ea87d278e7d1070d0d3485351d11180..2b115dc2939e728aa9478fbf9253890c511e6327 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 a748d74394fca5db9c12005a0736d1df44ca0113..b23b0bc15e89ec5db0035a2464dbc2c2634bba1d 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 f7ee39c56bf930751ee50c5dbce7244f6c00da03..d339fc00329168ff35b4278df716f6e817c4448d 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 d5a33f093432974751ff02c0b0803b5e6cec00dd..61f01af21ec8cc4f5748e60790b36e15211c10b4 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 858aa28e9cbf3cf9991ee5e687eec0a0caef9d39..bd8f69db2d3b69a6462967aaa571c6e52ba94bb9 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();