Skip to content
Snippets Groups Projects
Commit 0dd5c79d authored by OZGCloud's avatar OZGCloud
Browse files

Merge pull request 'OZG-2922 OZG-3989 add production info to root resource'...

Merge pull request 'OZG-2922 OZG-3989 add production info to root resource' (#257) from OZG-2922-non-produktion-hinweis into master

Reviewed-on: https://git.ozg-sh.de/mgm/goofy/pulls/257


Reviewed-by: default avatarOZGCloud <ozgcloud@mgm-tp.com>
parents 4758a01a 787040e3
Branches
Tags
No related merge requests found
......@@ -30,6 +30,7 @@ import java.util.List;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.info.BuildProperties;
import org.springframework.hateoas.EntityModel;
import org.springframework.hateoas.Link;
......@@ -67,6 +68,9 @@ public class RootController {
@Autowired
private UserManagerUrlProvider userManagerUrlProvider;
@Value("${ozgcloud.stage.production}")
private boolean production = true;
@GetMapping
public EntityModel<RootResource> getRootResource() {
var modelBuilder = ModelBuilder.fromEntity(new RootResource())
......@@ -260,5 +264,9 @@ public class RootController {
public String getJavaVersion() {
return System.getProperty("java.version");
}
public boolean getProduction() {
return production;
}
}
}
\ No newline at end of file
......@@ -187,19 +187,24 @@ class RootControllerTest {
}
@Test
void shouldHaveversion() throws Exception {
void shouldHaveVersion() throws Exception {
when(properties.getVersion()).thenReturn("42");
doRequest().andExpect(jsonPath("$.version").value("42"));
}
@Test
void shouldHavebuildTime() throws Exception {
void shouldHaveBuildTime() throws Exception {
when(properties.getTime()).thenReturn(LocalDateTime.parse("2021-04-01T10:30").toInstant(ZoneOffset.UTC));
doRequest().andExpect(jsonPath("$.buildTime").exists());
}
@Test
void shouldHavelProduction() throws Exception {
doRequest().andExpect(jsonPath("$.production").exists());
}
private ResultActions doRequest() throws Exception {
return mockMvc.perform(get(RootController.PATH)).andExpect(status().isOk());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment