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
No related branches found
No related tags found
No related merge requests found
......@@ -82,8 +82,6 @@ public class RootController {
linkTo(VorgangController.class).withRel(REL_VORGAENGE),
linkTo(DownloadTokenController.class).withRel(REL_DOWNLOAD_TOKEN),
Link.of(userManagerUrlProvider.getUserProfileSearchTemplate(), REL_SEARCH_USER))
// .ifMatch(this::hasRoleAndUserManagerIsConfigured)
// .addLink(() -> Link.of(userManagerUrlProvider.getUserProfileSearchTemplate(), REL_SEARCH_USER))
.ifMatch(this::hasRoleAndSearchServerAvailable).addLinks(
buildVorgangListByPageLink(REL_SEARCH, Optional.empty()));
......@@ -101,10 +99,6 @@ public class RootController {
return model;
}
private boolean hasRoleAndUserManagerIsConfigured() {
return hasRole() && userManagerUrlProvider.isConfiguredForSearchUserProfile();
}
private boolean hasRoleAndSearchServerAvailable() {
return hasRole() && systemStatusService.isSearchServerAvailable();
}
......
......@@ -34,7 +34,6 @@ import java.time.ZoneOffset;
import java.util.Optional;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
......@@ -49,6 +48,7 @@ import org.springframework.test.web.servlet.ResultActions;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
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.UserProfileTestFactory;
import de.itvsh.goofy.common.user.UserRemoteService;
......@@ -77,16 +77,16 @@ class RootControllerTest {
void initTest() {
mockMvc = MockMvcBuilders.standaloneSetup(controller).build();
when(currentUserService.getUserId()).thenReturn(UserProfileTestFactory.ID);
when(internalUserIdService.getUserId(any())).thenReturn(Optional.of(UserProfileTestFactory.ID));
when(currentUserService.getUserId()).thenReturn(UserId.from("42"));
when(internalUserIdService.getUserId(any())).thenReturn(Optional.empty());
when(userManagerUrlProvider.getUserProfileSearchTemplate()).thenReturn("UserProfileSearchTemplateDummy/$");
}
@Disabled("FIXME")
@DisplayName("Links for user")
@Nested
class TestLinks {
@DisplayName("with any verwaltung role")
@DisplayName("with role " + UserRole.VERWALTUNG_USER)
@Nested
class TestWithVerwaltungRole {
......@@ -94,7 +94,6 @@ class RootControllerTest {
void mockCurrentUserService() {
doReturn(true).when(controller).hasVerwaltungRole();
when(systemStatusService.isSearchServerAvailable()).thenReturn(true);
when(userManagerUrlProvider.isConfiguredForSearchUserProfile()).thenReturn(false);
}
@Test
......@@ -120,15 +119,10 @@ class RootControllerTest {
.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
void shouldHaveMyVorgaengeLink() {
when(internalUserIdService.getUserId(any())).thenReturn(Optional.of(UserProfileTestFactory.ID));
var model = controller.getRootResource();
assertThat(model.getLink(RootController.REL_MY_VORGAENGE)).isPresent().get().extracting(Link::getHref)
......@@ -137,6 +131,8 @@ class RootControllerTest {
@Test
void shouldHaveSearchMyVorgaengeLink() {
when(internalUserIdService.getUserId(any())).thenReturn(Optional.of(UserProfileTestFactory.ID));
var model = controller.getRootResource();
assertThat(model.getLink(RootController.REL_SEARCH_MY_VORGAENGE)).isPresent().get().extracting(Link::getHref)
......@@ -151,29 +147,6 @@ class RootControllerTest {
.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")
@Nested
class TestWithoutSearchService {
......@@ -192,6 +165,8 @@ class RootControllerTest {
@Test
void shouldHaveMyVorgaengeLink() {
when(internalUserIdService.getUserId(any())).thenReturn(Optional.of(UserProfileTestFactory.ID));
var model = controller.getRootResource();
assertThat(model.getLink(RootController.REL_MY_VORGAENGE)).isPresent().get().extracting(Link::getHref)
......@@ -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
void shouldHaveJavaVersion() throws Exception {
callEndpoint().andExpect(jsonPath("$.javaVersion").exists());
}
@Disabled("FIXME")
@Test
void versionExists() throws Exception {
void shouldHaveversion() throws Exception {
when(properties.getVersion()).thenReturn("42");
callEndpoint().andExpect(jsonPath("$.version").value("42"));
}
@Disabled("FIXME")
@Test
void buildTimeExists() throws Exception {
void shouldHavebuildTime() throws Exception {
when(properties.getTime()).thenReturn(LocalDateTime.parse("2021-04-01T10:30").toInstant(ZoneOffset.UTC));
callEndpoint().andExpect(jsonPath("$.buildTime").exists());
......@@ -363,3 +346,4 @@ class RootControllerTest {
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