Skip to content

Commit

Permalink
Fix Saturn tests and build deprecation warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
ewelinagr committed Feb 26, 2025
1 parent de99c4e commit 27dbceb
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public void getUserURI_shouldReturnUserUriFromJwt() {
@Test
public void getUserURI_shouldReturnNullWhenNoJwt() {
SecurityContextHolder.clearContext();
RequestContext.clear();
assertNull(RequestContext.getUserURI());
}

Expand All @@ -49,6 +50,6 @@ public void getClaims_shouldReturnClaimsFromJwt() {
public void getClaims_shouldReturnEmptyClaimsWhenNoJwt() {
SecurityContextHolder.clearContext();
RequestContext.SaturnClaims claims = RequestContext.getClaims();
assertTrue(claims.getSubject().isEmpty());
assertNull(claims.getSubject());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import org.springframework.boot.autoconfigure.security.oauth2.resource.servlet.OAuth2ResourceServerAutoConfiguration;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.bean.override.mockito.MockitoBean;

import io.fairspace.saturn.auth.JwtAuthConverterProperties;
import io.fairspace.saturn.services.IRIModule;
Expand All @@ -16,7 +16,7 @@
@Import(BaseControllerTest.CustomObjectMapperConfig.class)
public class BaseControllerTest {

@MockBean
@MockitoBean
private JwtAuthConverterProperties jwtAuthConverterProperties;

@TestConfiguration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc;

import io.fairspace.saturn.config.enums.Feature;
Expand All @@ -23,7 +23,7 @@ class FeaturesControllerTest extends BaseControllerTest {
@Autowired
private MockMvc mockMvc;

@MockBean
@MockitoBean
private FeatureProperties featureProperties;

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc;

import io.fairspace.saturn.services.maintenance.MaintenanceService;

import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
Expand All @@ -23,7 +21,7 @@ class MaintenanceControllerTest extends BaseControllerTest {
@Autowired
private MockMvc mockMvc;

@MockBean
@MockitoBean
private MaintenanceService maintenanceService;

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc;

import io.fairspace.saturn.services.metadata.MetadataService;
Expand All @@ -16,21 +16,16 @@
import static org.hamcrest.Matchers.containsString;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;

@WebMvcTest(MetadataController.class)
public class MetadataControllerTest extends BaseControllerTest {

@Autowired
private MockMvc mockMvc;

@MockBean
@MockitoBean
private MetadataService metadataService;

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc;

import io.fairspace.saturn.controller.dto.SearchResultDto;
Expand All @@ -28,10 +28,10 @@ class SearchControllerTest extends BaseControllerTest {
@Autowired
private MockMvc mockMvc;

@MockBean
@MockitoBean
private SearchService searchService;

@MockBean
@MockitoBean
private FileSearchService fileSearchService;

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc;

import io.fairspace.saturn.services.users.User;
Expand All @@ -26,7 +26,7 @@ class UserControllerTest extends BaseControllerTest {
@Autowired
private MockMvc mockMvc;

@MockBean
@MockitoBean
private UserService service;

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc;

import io.fairspace.saturn.config.properties.ViewsProperties;
Expand Down Expand Up @@ -37,10 +37,10 @@ public class ViewControllerTest extends BaseControllerTest {
@Autowired
private MockMvc mockMvc;

@MockBean
@MockitoBean
private ViewService viewService;

@MockBean(name = "queryService")
@MockitoBean(name = "queryService")
private QueryService queryService;

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc;

import io.fairspace.saturn.services.workspaces.Workspace;
Expand All @@ -36,7 +36,7 @@ class WorkspaceControllerTest extends BaseControllerTest {
@Autowired
private MockMvc mockMvc;

@MockBean
@MockitoBean
private WorkspaceService workspaceService;

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc;

import io.fairspace.saturn.controller.BaseControllerTest;
Expand All @@ -29,7 +29,7 @@ public class GlobalExceptionHandlerTest extends BaseControllerTest {
@Autowired
private MockMvc mockMvc;

@MockBean
@MockitoBean
private TestController.TestInnerClass testInnerClass;

@Test
Expand Down

0 comments on commit 27dbceb

Please sign in to comment.