Skip to content

Commit

Permalink
bump(spring-boot): bump to 3.3.2 (#515)
Browse files Browse the repository at this point in the history
* bump(spring-boot): bump to 3.3.2

* bump(spring-boot): fix unit test
  • Loading branch information
dtrouillet authored Aug 1, 2024
1 parent d3dd8c7 commit b9b96ac
Show file tree
Hide file tree
Showing 21 changed files with 72 additions and 58 deletions.
27 changes: 9 additions & 18 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>spring-boot-starter-parent</artifactId>
<groupId>org.springframework.boot</groupId>
<version>3.0.0</version>
<version>3.3.2</version>
<relativePath />
</parent>
<licenses>
Expand Down Expand Up @@ -41,7 +41,6 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<assertj-core.version>1.0.0m1</assertj-core.version>
<awaitility.version>1.7.0</awaitility.version>
<commons-io.version>2.16.1</commons-io.version>
<commons-lang.version>3.15.0</commons-lang.version>
<gatling-maven-plugin.version>2.2.4</gatling-maven-plugin.version>
Expand Down Expand Up @@ -126,7 +125,7 @@
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-hibernate5</artifactId>
<artifactId>jackson-datatype-hibernate6</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
Expand All @@ -147,14 +146,6 @@
<scope>runtime</scope>
<version>2.3.230</version>
</dependency>

<dependency>
<groupId>com.jayway.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>${awaitility.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.sshd</groupId>
<artifactId>sshd-core</artifactId>
Expand Down Expand Up @@ -222,17 +213,17 @@
<dependency>
<groupId> org.hibernate.orm</groupId>
<artifactId>hibernate-jcache</artifactId>
<version>6.1.5.Final</version>
<version>6.5.2.Final</version>
</dependency>
<dependency>
<groupId>org.ehcache</groupId>
<artifactId>ehcache-transactions</artifactId>
<version>3.10.6</version>
<version>3.10.8</version>
</dependency>
<dependency>
<groupId> org.hibernate.orm</groupId>
<artifactId>hibernate-envers</artifactId>
<version>6.1.5.Final</version>
<version>6.5.2.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
Expand All @@ -242,7 +233,7 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.6.12.Final</version>
<version>5.6.15.Final</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -319,7 +310,7 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
<version>3.0.6</version>
<version>3.3.2</version>
</dependency>


Expand Down Expand Up @@ -403,7 +394,7 @@
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>3.0.0</version>
<version>3.3.2</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
Expand Down Expand Up @@ -502,7 +493,7 @@
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>2.7.5</version>
<version>3.3.2</version>
</dependency>
</dependencies>
</dependencyManagement>
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/fr/icdc/ebad/EbadApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,22 @@
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.core.env.Environment;
import org.springframework.data.web.config.EnableSpringDataWebSupport;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Arrays;

import static org.springframework.data.web.config.EnableSpringDataWebSupport.PageSerializationMode.VIA_DTO;

@SpringBootApplication
@ComponentScan(excludeFilters={@ComponentScan.Filter(type= FilterType.ASSIGNABLE_TYPE, value=SpringDocDataRestConfiguration.class)})
@EnableConfigurationProperties(EbadProperties.class)
@EnableAsync
@EnableScheduling
@EnableSpringDataWebSupport(pageSerializationMode = VIA_DTO)
public class EbadApplication {
private static final Logger APPLICATION_LOGGER = LoggerFactory.getLogger(EbadApplication.class);

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/fr/icdc/ebad/config/DatabaseConfiguration.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fr.icdc.ebad.config;

import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module;
import com.fasterxml.jackson.datatype.hibernate6.Hibernate6Module;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
Expand All @@ -14,7 +14,7 @@
@EnableTransactionManagement
public class DatabaseConfiguration {
@Bean
public Hibernate5Module hibernate5Module() {
return new Hibernate5Module();
public Hibernate6Module hibernate5Module() {
return new Hibernate6Module();
}
}
4 changes: 2 additions & 2 deletions src/main/java/fr/icdc/ebad/domain/GlobalSetting.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class GlobalSetting {
@Id
@Column(name = "key")
@Column(name = "`key`")
private String key;

@Column(name = "value", nullable = false)
@Column(name = "`value`", nullable = false)
private String value;

@Column(name = "label", nullable = false)
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/fr/icdc/ebad/repository/UserRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ default void customize(QuerydslBindings bindings, QUser root) {
@Query("select user from User user left join user.usageApplications usageApplication left join usageApplication.application application left join application.environnements environnement left join environnement.batchs batch where batch.id = :batch and user.login = :login and usageApplication.canManage = true")
User findManagerFromBatch(@Param("batch") Long batch, @Param("login") String login);

@Query("select user from User user left join user.usageApplications usageApplication on user.id = usageApplication.user left join usageApplication.application application where application.id = :application and user.login = :login and usageApplication.canUse = true")
@Query("select user from User user left join user.usageApplications usageApplication on user.id = usageApplication.user.id left join usageApplication.application application where application.id = :application and user.login = :login and usageApplication.canUse = true")
User findUserFromApplication(@Param("application") Long application, @Param("login") String login);

@Query("select user from User user left join user.usageApplications usageApplication on user.id = usageApplication.user left join usageApplication.application application where application.id = :application and user.login = :login and usageApplication.canManage = true")
@Query("select user from User user left join user.usageApplications usageApplication on user.id = usageApplication.user.id left join usageApplication.application application where application.id = :application and user.login = :login and usageApplication.canManage = true")
User findManagerFromApplication(@Param("application") Long application, @Param("login") String login);

@Query("select user from User user left join user.usageApplications usageApplication left join usageApplication.application application left join application.environnements environnement where environnement.id = :env and user.login = :login and usageApplication.canUse = true")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
Expand Down Expand Up @@ -196,7 +197,7 @@ public void getAllAccreditationRequestToAnswerAdmin() {
accreditationRequestList.add(accreditationRequest2);
PageRequest pageRequest = PageRequest.of(0, 10);

when(accreditationRequestRepository.findAll(any(Predicate.class), eq(pageRequest))).thenReturn(new PageImpl<>(accreditationRequestList));
when(accreditationRequestRepository.findAll(any(Predicate.class), eq(pageRequest))).thenReturn(new PageImpl<>(accreditationRequestList, Pageable.ofSize(accreditationRequestList.size()), accreditationRequestList.size()));

Page<AccreditationRequest> result = accreditationRequestService.getAllAccreditationRequestToAnswer(pageRequest);

Expand All @@ -221,7 +222,7 @@ public void getAllAccreditationRequestToAnswer() {
application2.setId(2L);
applications.add(application2);

PageImpl<Application> applicationPage = new PageImpl<>(applications);
PageImpl<Application> applicationPage = new PageImpl<>(applications, Pageable.ofSize(applications.size()), applications.size());
when(applicationRepository.findAllManagedByUser(any(), any())).thenReturn(applicationPage);


Expand All @@ -248,7 +249,7 @@ public void getAllAccreditationRequestToAnswer() {
accreditationRequestList.add(accreditationRequest2);
PageRequest pageRequest = PageRequest.of(0, 10);

when(accreditationRequestRepository.findAll(any(Predicate.class), eq(pageRequest))).thenReturn(new PageImpl<>(accreditationRequestList));
when(accreditationRequestRepository.findAll(any(Predicate.class), eq(pageRequest))).thenReturn(new PageImpl<>(accreditationRequestList, Pageable.ofSize(accreditationRequestList.size()), accreditationRequestList.size()));

Page<AccreditationRequest> result = accreditationRequestService.getAllAccreditationRequestToAnswer(pageRequest);

Expand Down Expand Up @@ -286,7 +287,7 @@ public void getMyAccreditationRequest() {
accreditationRequestList.add(accreditationRequest2);
PageRequest pageRequest = PageRequest.of(0, 10);

when(accreditationRequestRepository.findAll(any(Predicate.class), eq(pageRequest))).thenReturn(new PageImpl<>(accreditationRequestList));
when(accreditationRequestRepository.findAll(any(Predicate.class), eq(pageRequest))).thenReturn(new PageImpl<>(accreditationRequestList, Pageable.ofSize(accreditationRequestList.size()), accreditationRequestList.size()));

Page<AccreditationRequest> result = accreditationRequestService.getMyAccreditationRequest(pageRequest);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void findTokenByUser() {
ApiToken apiToken2 = ApiToken.builder().id(2L).build();
apiTokens.add(apiToken1);
apiTokens.add(apiToken2);
Page<ApiToken> apiTokenPage = new PageImpl<>(apiTokens);
Page<ApiToken> apiTokenPage = new PageImpl<>(apiTokens, Pageable.ofSize(apiTokens.size()), apiTokens.size());
when(apiTokenRepository.findAllByUserLogin(eq("myLogin"), eq(pageable))).thenReturn(apiTokenPage);

Page<ApiToken> results = apiTokenService.findTokenByUser("myLogin", pageable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import fr.icdc.ebad.service.AccreditationRequestService;
import fr.icdc.ebad.web.rest.dto.CreationAccreditationRequestDto;
import fr.icdc.ebad.web.rest.dto.ResponseAccreditationRequestDto;
import fr.icdc.ebad.web.rest.errors.ExceptionTranslator;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -18,6 +19,7 @@
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
import org.springframework.http.MediaType;
import org.springframework.security.test.context.support.WithMockUser;
Expand All @@ -38,6 +40,7 @@
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

Expand All @@ -53,6 +56,9 @@ public class AccreditationRequestResourceTest {
@Autowired
private AccreditationRequestResource accreditationRequestResource;

@Autowired
private ExceptionTranslator exceptionTranslator;

@Autowired
private WebApplicationContext context;

Expand All @@ -64,6 +70,7 @@ public void setup() {
this.restMvc = MockMvcBuilders
.standaloneSetup(accreditationRequestResource)
.setCustomArgumentResolvers(new PageableHandlerMethodArgumentResolver())
.setControllerAdvice(exceptionTranslator)
.build();
objectMapper.registerModule(new JavaTimeModule());
}
Expand Down Expand Up @@ -93,12 +100,13 @@ public void findAll() throws Exception {
accreditationRequestList.add(accreditationRequest1);
accreditationRequestList.add(accreditationRequest2);

Page<AccreditationRequest> accreditationRequestPage = new PageImpl<>(accreditationRequestList);
Page<AccreditationRequest> accreditationRequestPage = new PageImpl<>(accreditationRequestList, Pageable.ofSize(2), 2);


when(accreditationRequestService.getAllAccreditationRequestToAnswer(any())).thenReturn(accreditationRequestPage);

MockHttpServletRequestBuilder builder = MockMvcRequestBuilders.get("/accreditation-requests/need-answer");
restMvc.perform(builder)
restMvc.perform(builder).andDo(print())
.andExpect(status().isOk())
.andExpect(jsonPath("$.content").isArray())
.andExpect(jsonPath("$.content", hasSize(2)))
Expand Down Expand Up @@ -139,7 +147,7 @@ public void findAllMyRequest() throws Exception {
accreditationRequestList.add(accreditationRequest1);
accreditationRequestList.add(accreditationRequest2);

Page<AccreditationRequest> accreditationRequestPage = new PageImpl<>(accreditationRequestList);
Page<AccreditationRequest> accreditationRequestPage = new PageImpl<>(accreditationRequestList, Pageable.ofSize(accreditationRequestList.size()), accreditationRequestList.size());

when(accreditationRequestService.getMyAccreditationRequest(any())).thenReturn(accreditationRequestPage);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void findToken() throws Exception {
ApiToken apiToken2 = ApiToken.builder().id(2L).build();
apiTokens.add(apiToken1);
apiTokens.add(apiToken2);
Page<ApiToken> apiTokenPage = new PageImpl<>(apiTokens);
Page<ApiToken> apiTokenPage = new PageImpl<>(apiTokens, Pageable.ofSize(apiTokens.size()), apiTokens.size());
when(apiTokenService.findTokenByUser(eq("user"), ArgumentMatchers.any(Pageable.class))).thenReturn(apiTokenPage);

restMvc.perform(builder)
Expand Down
10 changes: 6 additions & 4 deletions src/test/java/fr/icdc/ebad/web/rest/ApplicationResourceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
import org.springframework.data.web.querydsl.QuerydslPredicateArgumentResolver;
import org.springframework.http.MediaType;
Expand Down Expand Up @@ -103,7 +104,7 @@ public void findApplication() throws Exception {
Application application2 = new Application();
application2.setId(2L);
applications.add(application2);
PageImpl<Application> applicationPage = new PageImpl<>(applications);
PageImpl<Application> applicationPage = new PageImpl<>(applications, Pageable.ofSize(applications.size()), applications.size());

when(applicationService.findApplication(any(), any())).thenReturn(applicationPage);

Expand Down Expand Up @@ -131,7 +132,7 @@ public void getAll() throws Exception {
Application application2 = new Application();
application2.setId(2L);
applications.add(application2);
PageImpl<Application> applicationPage = new PageImpl<>(applications);
PageImpl<Application> applicationPage = new PageImpl<>(applications, Pageable.ofSize(applications.size()), applications.size());

when(applicationService.getAllApplicationsUsed(any(), eq("user"))).thenReturn(applicationPage);
when(userRepository.findUserFromApplication(anyLong(), anyString())).thenReturn(new User());
Expand Down Expand Up @@ -160,7 +161,8 @@ public void getAllWrite() throws Exception {
application2.setId(2L);
applications.add(application2);

PageImpl<Application> applicationPage = new PageImpl<>(applications);
PageImpl<Application> applicationPage = new PageImpl<>(applications, Pageable.ofSize(applications.size()), applications.size());


when(applicationService.getAllApplicationsManaged(any(), eq("dtrouillet"))).thenReturn(applicationPage);
when(userRepository.findManagerFromApplication(eq(1L), eq("dtrouillet"))).thenReturn(new User());
Expand Down Expand Up @@ -188,7 +190,7 @@ public void getAllManage() throws Exception {
application2.setId(2L);
applications.add(application2);

PageImpl<Application> applicationPage = new PageImpl<>(applications);
PageImpl<Application> applicationPage = new PageImpl<>(applications, Pageable.ofSize(applications.size()), applications.size());

when(applicationService.getAllApplications(any(), any())).thenReturn(applicationPage);
restMvc.perform(builder)
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/fr/icdc/ebad/web/rest/ChaineResourceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
import org.springframework.data.web.querydsl.QuerydslPredicateArgumentResolver;
import org.springframework.http.MediaType;
Expand Down Expand Up @@ -96,7 +97,7 @@ public void getAllFromEnv() throws Exception {
chaines.add(chaine1);
chaines.add(chaine2);

Page<Chaine> chainePage = new PageImpl<>(chaines);
Page<Chaine> chainePage = new PageImpl<>(chaines, Pageable.ofSize(chaines.size()), chaines.size());

when(chaineService.getAllChaineFromEnvironmentWithPageable(any(), any(), argThat((environnement -> environnement.getId().equals(1L))))).thenReturn(chainePage);
when(permissionEnvironnement.canRead(eq(1L), any())).thenReturn(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
import org.springframework.data.web.querydsl.QuerydslPredicateArgumentResolver;
import org.springframework.security.core.userdetails.UserDetails;
Expand Down Expand Up @@ -100,7 +101,7 @@ public void getAllFromEnv() throws Exception {
Directory directory2 = Directory.builder().id(3L).name("directory2").build();
directoryList.add(directory1);
directoryList.add(directory2);
Page<Directory> directoryPage = new PageImpl<>(directoryList);
Page<Directory> directoryPage = new PageImpl<>(directoryList, Pageable.ofSize(directoryList.size()), directoryList.size());

when(directoryService.findDirectoryFromEnvironnement(any(), any(), eq(1L))).thenReturn(directoryPage);
when(permissionEnvironnement.canRead(eq(1L), any())).thenReturn(true);
Expand Down
Loading

0 comments on commit b9b96ac

Please sign in to comment.