Skip to content
Snippets Groups Projects
Commit 967a698e authored by OZGCloud's avatar OZGCloud
Browse files

OZG-2966 fix disabled test; tiny cleanup

parent 812f4834
Branches
Tags
No related merge requests found
...@@ -82,8 +82,6 @@ public class RootController { ...@@ -82,8 +82,6 @@ public class RootController {
linkTo(VorgangController.class).withRel(REL_VORGAENGE), linkTo(VorgangController.class).withRel(REL_VORGAENGE),
linkTo(DownloadTokenController.class).withRel(REL_DOWNLOAD_TOKEN), linkTo(DownloadTokenController.class).withRel(REL_DOWNLOAD_TOKEN),
Link.of(userManagerUrlProvider.getUserProfileSearchTemplate(), REL_SEARCH_USER)) Link.of(userManagerUrlProvider.getUserProfileSearchTemplate(), REL_SEARCH_USER))
// .ifMatch(this::hasRoleAndUserManagerIsConfigured)
// .addLink(() -> Link.of(userManagerUrlProvider.getUserProfileSearchTemplate(), REL_SEARCH_USER))
.ifMatch(this::hasRoleAndSearchServerAvailable).addLinks( .ifMatch(this::hasRoleAndSearchServerAvailable).addLinks(
buildVorgangListByPageLink(REL_SEARCH, Optional.empty())); buildVorgangListByPageLink(REL_SEARCH, Optional.empty()));
...@@ -101,10 +99,6 @@ public class RootController { ...@@ -101,10 +99,6 @@ public class RootController {
return model; return model;
} }
private boolean hasRoleAndUserManagerIsConfigured() {
return hasRole() && userManagerUrlProvider.isConfiguredForSearchUserProfile();
}
private boolean hasRoleAndSearchServerAvailable() { private boolean hasRoleAndSearchServerAvailable() {
return hasRole() && systemStatusService.isSearchServerAvailable(); return hasRole() && systemStatusService.isSearchServerAvailable();
} }
......
...@@ -34,7 +34,6 @@ import java.time.ZoneOffset; ...@@ -34,7 +34,6 @@ import java.time.ZoneOffset;
import java.util.Optional; import java.util.Optional;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
...@@ -49,6 +48,7 @@ import org.springframework.test.web.servlet.ResultActions; ...@@ -49,6 +48,7 @@ import org.springframework.test.web.servlet.ResultActions;
import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import de.itvsh.goofy.common.user.CurrentUserService; import de.itvsh.goofy.common.user.CurrentUserService;
import de.itvsh.goofy.common.user.UserId;
import de.itvsh.goofy.common.user.UserManagerUrlProvider; import de.itvsh.goofy.common.user.UserManagerUrlProvider;
import de.itvsh.goofy.common.user.UserProfileTestFactory; import de.itvsh.goofy.common.user.UserProfileTestFactory;
import de.itvsh.goofy.common.user.UserRemoteService; import de.itvsh.goofy.common.user.UserRemoteService;
...@@ -77,16 +77,16 @@ class RootControllerTest { ...@@ -77,16 +77,16 @@ class RootControllerTest {
void initTest() { void initTest() {
mockMvc = MockMvcBuilders.standaloneSetup(controller).build(); mockMvc = MockMvcBuilders.standaloneSetup(controller).build();
when(currentUserService.getUserId()).thenReturn(UserProfileTestFactory.ID); when(currentUserService.getUserId()).thenReturn(UserId.from("42"));
when(internalUserIdService.getUserId(any())).thenReturn(Optional.of(UserProfileTestFactory.ID)); when(internalUserIdService.getUserId(any())).thenReturn(Optional.empty());
when(userManagerUrlProvider.getUserProfileSearchTemplate()).thenReturn("UserProfileSearchTemplateDummy/$");
} }
@Disabled("FIXME")
@DisplayName("Links for user") @DisplayName("Links for user")
@Nested @Nested
class TestLinks { class TestLinks {
@DisplayName("with any verwaltung role") @DisplayName("with role " + UserRole.VERWALTUNG_USER)
@Nested @Nested
class TestWithVerwaltungRole { class TestWithVerwaltungRole {
...@@ -94,7 +94,6 @@ class RootControllerTest { ...@@ -94,7 +94,6 @@ class RootControllerTest {
void mockCurrentUserService() { void mockCurrentUserService() {
doReturn(true).when(controller).hasVerwaltungRole(); doReturn(true).when(controller).hasVerwaltungRole();
when(systemStatusService.isSearchServerAvailable()).thenReturn(true); when(systemStatusService.isSearchServerAvailable()).thenReturn(true);
when(userManagerUrlProvider.isConfiguredForSearchUserProfile()).thenReturn(false);
} }
@Test @Test
...@@ -120,15 +119,10 @@ class RootControllerTest { ...@@ -120,15 +119,10 @@ class RootControllerTest {
.extracting(Link::getHref).isEqualTo("/api/vorgangs?page=0{&searchBy,limit,assignedTo}"); .extracting(Link::getHref).isEqualTo("/api/vorgangs?page=0{&searchBy,limit,assignedTo}");
} }
@Test
void shouldNotHaveSearchUserLinkIfNotConfigured() {
var model = controller.getRootResource();
assertThat(model.getLink(RootController.REL_SEARCH_USER)).isNotPresent();
}
@Test @Test
void shouldHaveMyVorgaengeLink() { void shouldHaveMyVorgaengeLink() {
when(internalUserIdService.getUserId(any())).thenReturn(Optional.of(UserProfileTestFactory.ID));
var model = controller.getRootResource(); var model = controller.getRootResource();
assertThat(model.getLink(RootController.REL_MY_VORGAENGE)).isPresent().get().extracting(Link::getHref) assertThat(model.getLink(RootController.REL_MY_VORGAENGE)).isPresent().get().extracting(Link::getHref)
...@@ -137,6 +131,8 @@ class RootControllerTest { ...@@ -137,6 +131,8 @@ class RootControllerTest {
@Test @Test
void shouldHaveSearchMyVorgaengeLink() { void shouldHaveSearchMyVorgaengeLink() {
when(internalUserIdService.getUserId(any())).thenReturn(Optional.of(UserProfileTestFactory.ID));
var model = controller.getRootResource(); var model = controller.getRootResource();
assertThat(model.getLink(RootController.REL_SEARCH_MY_VORGAENGE)).isPresent().get().extracting(Link::getHref) assertThat(model.getLink(RootController.REL_SEARCH_MY_VORGAENGE)).isPresent().get().extracting(Link::getHref)
...@@ -151,29 +147,6 @@ class RootControllerTest { ...@@ -151,29 +147,6 @@ class RootControllerTest {
.isEqualTo("/api/downloadtoken"); .isEqualTo("/api/downloadtoken");
} }
@DisplayName("and userManager is configured")
@Nested
class TestAndUserManagerIsConfigured {
private String userProfileSearchTemplate = "UserProfileSearchTemplate";
@BeforeEach
void mockCurrentUserService() {
when(userManagerUrlProvider.getUserProfileSearchTemplate()).thenReturn(userProfileSearchTemplate);
}
@Test
void shouldHaveSearchUserLink() {
when(userManagerUrlProvider.isConfiguredForSearchUserProfile()).thenReturn(true);
var model = controller.getRootResource();
assertThat(model.getLink(RootController.REL_SEARCH_USER)).isPresent().get().extracting(Link::getHref)
.isEqualTo(userProfileSearchTemplate);
}
}
@DisplayName("search service not available") @DisplayName("search service not available")
@Nested @Nested
class TestWithoutSearchService { class TestWithoutSearchService {
...@@ -192,6 +165,8 @@ class RootControllerTest { ...@@ -192,6 +165,8 @@ class RootControllerTest {
@Test @Test
void shouldHaveMyVorgaengeLink() { void shouldHaveMyVorgaengeLink() {
when(internalUserIdService.getUserId(any())).thenReturn(Optional.of(UserProfileTestFactory.ID));
var model = controller.getRootResource(); var model = controller.getRootResource();
assertThat(model.getLink(RootController.REL_MY_VORGAENGE)).isPresent().get().extracting(Link::getHref) assertThat(model.getLink(RootController.REL_MY_VORGAENGE)).isPresent().get().extracting(Link::getHref)
...@@ -337,23 +312,31 @@ class RootControllerTest { ...@@ -337,23 +312,31 @@ class RootControllerTest {
} }
} }
@Disabled("FIXME") @DisplayName("Root resource")
@Nested
class TestRootResource {
@BeforeEach
void initTest() {
when(currentUserService.getUserId()).thenReturn(UserId.from("42"));
when(internalUserIdService.getUserId(any())).thenReturn(Optional.empty());
when(userManagerUrlProvider.getUserProfileSearchTemplate()).thenReturn("UserProfileSearchTemplateDummy/$");
}
@Test @Test
void shouldHaveJavaVersion() throws Exception { void shouldHaveJavaVersion() throws Exception {
callEndpoint().andExpect(jsonPath("$.javaVersion").exists()); callEndpoint().andExpect(jsonPath("$.javaVersion").exists());
} }
@Disabled("FIXME")
@Test @Test
void versionExists() throws Exception { void shouldHaveversion() throws Exception {
when(properties.getVersion()).thenReturn("42"); when(properties.getVersion()).thenReturn("42");
callEndpoint().andExpect(jsonPath("$.version").value("42")); callEndpoint().andExpect(jsonPath("$.version").value("42"));
} }
@Disabled("FIXME")
@Test @Test
void buildTimeExists() throws Exception { void shouldHavebuildTime() throws Exception {
when(properties.getTime()).thenReturn(LocalDateTime.parse("2021-04-01T10:30").toInstant(ZoneOffset.UTC)); when(properties.getTime()).thenReturn(LocalDateTime.parse("2021-04-01T10:30").toInstant(ZoneOffset.UTC));
callEndpoint().andExpect(jsonPath("$.buildTime").exists()); callEndpoint().andExpect(jsonPath("$.buildTime").exists());
...@@ -363,3 +346,4 @@ class RootControllerTest { ...@@ -363,3 +346,4 @@ class RootControllerTest {
return mockMvc.perform(get(RootController.PATH)).andExpect(status().isOk()); return mockMvc.perform(get(RootController.PATH)).andExpect(status().isOk());
} }
} }
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment