Skip to content

Commit

Permalink
feat: upgrade to spring boot 3.0.X
Browse files Browse the repository at this point in the history
  • Loading branch information
tkuzynow committed Dec 27, 2024
1 parent 9996377 commit 1f1803f
Show file tree
Hide file tree
Showing 27 changed files with 100 additions and 157 deletions.
26 changes: 22 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,27 @@
</dependency>

<dependency>
<groupId>net.minidev</groupId>
<artifactId>json-smart</artifactId>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-core</artifactId>
<version>6.2.4.Final</version>
</dependency>

<!-- Search dependency -->

<dependency>
<groupId>org.hibernate.search</groupId>
<artifactId>hibernate-search-mapper-orm</artifactId>
<version>6.1.7.Final</version>
<version>6.2.4.Final</version>
<exclusions>
<exclusion>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>net.minidev</groupId>
<artifactId>json-smart</artifactId>
</dependency>

<!-- Swagger/OpenAPI dependencies -->
Expand Down Expand Up @@ -235,6 +247,12 @@
<artifactId>commons-lang3</artifactId>
</dependency>

<!-- httpclient -->
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
</dependency>

<!-- Apache Commons Text -->
<dependency>
<groupId>org.apache.commons</groupId>
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/de/caritas/cob/userservice/api/model/Admin.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@
@ToString
@Builder
@EntityListeners(AuditingEntityListener.class)
@FilterDef(
name = "tenantFilter",
parameters = {@ParamDef(name = "tenantId", type = Long.class)})
@Filter(name = "tenantFilter", condition = "tenant_id = :tenantId")
public class Admin implements TenantAware {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@
@Setter
@Builder
@Indexed
@FilterDef(
name = "tenantFilter",
parameters = {@ParamDef(name = "tenantId", type = Long.class)})
@Filter(name = "tenantFilter", condition = "tenant_id = :tenantId")
public class Consultant implements TenantAware, NotificationsAware {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
@Builder
@Getter
@Setter
@FilterDef(
name = "tenantFilter",
parameters = {@ParamDef(name = "tenantId", type = Long.class)})
@Filter(name = "tenantFilter", condition = "tenant_id = :tenantId")
public class ConsultantAgency implements TenantAware {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@
@Getter
@Setter
@ToString
@FilterDef(
name = "tenantFilter",
parameters = {@ParamDef(name = "tenantId", type = Long.class)})
@Filter(name = "tenantFilter", condition = "tenant_id = :tenantId")
public class Session implements TenantAware {

Expand Down
3 changes: 0 additions & 3 deletions src/main/java/de/caritas/cob/userservice/api/model/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@
@Setter
@ToString
@EntityListeners(AuditingEntityListener.class)
@FilterDef(
name = "tenantFilter",
parameters = {@ParamDef(name = "tenantId", type = Long.class)})
@Filter(name = "tenantFilter", condition = "tenant_id = :tenantId")
public class User implements TenantAware, NotificationsAware {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@FilterDefs({
@FilterDef(
name = "tenantFilter",
parameters = {@ParamDef(name = "tenantId", type = Long.class)}
)
})
package de.caritas.cob.userservice.api.model;

import org.hibernate.annotations.FilterDef;
import org.hibernate.annotations.FilterDefs;
import org.hibernate.annotations.ParamDef;
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import de.caritas.cob.userservice.api.service.httpheader.SecurityHeaderSupplier;
import de.caritas.cob.userservice.api.service.httpheader.TenantHeaderSupplier;
import de.caritas.cob.userservice.consultingtypeservice.generated.web.model.ExtendedConsultingTypeResponseDTO;
import de.caritas.cob.userservice.messageservice.generated.ApiClient;
import de.caritas.cob.userservice.messageservice.generated.web.MessageControllerApi;
import de.caritas.cob.userservice.messageservice.generated.web.model.AliasMessageDTO;
import de.caritas.cob.userservice.messageservice.generated.web.model.AliasOnlyMessageDTO;
Expand Down Expand Up @@ -181,7 +180,8 @@ private void postAliasOnlyMessage(
}
}

private void addDefaultHeaders(ApiClient apiClient) {
private void addDefaultHeaders(
de.caritas.cob.userservice.messageservice.generated.ApiClient apiClient) {
var headers = this.securityHeaderSupplier.getKeycloakAndCsrfHttpHeaders();
tenantHeaderSupplier.addTenantHeader(headers);
headers.forEach((key, value) -> apiClient.addDefaultHeader(key, value.iterator().next()));
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/hibernate.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
hibernate.search.default.directory_provider=local-heap
hibernate.search.backend.type=lucene
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
import de.caritas.cob.userservice.api.port.out.IdentityClientConfig;
import de.caritas.cob.userservice.api.tenant.TenantContext;
import jakarta.ws.rs.BadRequestException;
import jakarta.ws.rs.core.Response;
import java.util.HashMap;
import java.util.List;
import javax.ws.rs.core.Response;
import org.apache.commons.lang3.RandomStringUtils;
import org.jeasy.random.EasyRandom;
import org.junit.jupiter.api.Assertions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@
import de.caritas.cob.userservice.api.port.out.UserRepository;
import de.caritas.cob.userservice.consultingtypeservice.generated.web.ConsultingTypeControllerApi;
import de.caritas.cob.userservice.topicservice.generated.web.TopicControllerApi;
import jakarta.servlet.http.Cookie;
import java.net.URI;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import javax.servlet.http.Cookie;
import lombok.NonNull;
import lombok.SneakyThrows;
import org.apache.commons.lang3.RandomStringUtils;
Expand Down Expand Up @@ -399,7 +399,7 @@ private void givenAValidRocketChatSystemUser() throws RocketChatUserNotInitializ
}

private void givenConsultingTypeServiceResponse(Integer consultingTypeId) {
consultingTypeControllerApi.getApiClient().setBasePath("https://www.google.de/");

when(restTemplate.getUriTemplateHandler())
.thenReturn(
new UriTemplateHandler() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
import de.caritas.cob.userservice.topicservice.generated.ApiClient;
import de.caritas.cob.userservice.topicservice.generated.web.TopicControllerApi;
import de.caritas.cob.userservice.topicservice.generated.web.model.TopicDTO;
import jakarta.servlet.http.Cookie;
import java.net.URI;
import java.time.LocalDate;
import java.util.ArrayList;
Expand All @@ -105,7 +106,6 @@
import java.util.Set;
import java.util.UUID;
import java.util.stream.StreamSupport;
import javax.servlet.http.Cookie;
import lombok.NonNull;
import lombok.SneakyThrows;
import org.apache.commons.lang3.RandomStringUtils;
Expand Down Expand Up @@ -1989,7 +1989,6 @@ private void givenAValidUser() {
}

private void givenConsultingTypeServiceResponse(Integer consultingTypeId) {
consultingTypeControllerApi.getApiClient().setBasePath("https://www.google.de/");
when(restTemplate.getUriTemplateHandler())
.thenReturn(
new UriTemplateHandler() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ void getSessionsForAuthenticatedConsultantShouldReturnSessionsLastMessageTypeE2e
givenAValidUser();
givenAValidConsultant(true);
givenASessionInProgress();
givenAValidRocketChatGetRoomsResponse(session.getGroupId(), MessageType.E2EE_ACTIVATED, null);
givenAValidRocketChatGetRoomsResponse(session.getGroupId(), MessageType.E2_EE_ACTIVATED, null);
givenAnEmptyRocketChatGetSubscriptionsResponse();

mockMvc
Expand Down Expand Up @@ -461,7 +461,7 @@ void getSessionsForAuthenticatedConsultantShouldReturnInformationAboutDeletedUse
givenADeletedUser(false);
givenAValidConsultant(true);
givenASessionInProgress();
givenAValidRocketChatGetRoomsResponse(session.getGroupId(), MessageType.E2EE_ACTIVATED, null);
givenAValidRocketChatGetRoomsResponse(session.getGroupId(), MessageType.E2_EE_ACTIVATED, null);
givenAnEmptyRocketChatGetSubscriptionsResponse();

mockMvc
Expand Down Expand Up @@ -545,7 +545,7 @@ void getSessionsForAuthenticatedUserShouldReturnSessionsLastMessageTypeE2eeActiv
givenAValidConsultant();
givenASessionInProgress();
givenAValidRocketChatSystemUser();
givenAValidRocketChatGetRoomsResponse(session.getGroupId(), MessageType.E2EE_ACTIVATED, null);
givenAValidRocketChatGetRoomsResponse(session.getGroupId(), MessageType.E2_EE_ACTIVATED, null);
givenAnEmptyRocketChatGetSubscriptionsResponse();
user.getSessions()
.forEach(session -> givenAValidRocketChatInfoUserResponse(session.getConsultant()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class ConsultantAdminFacadeIT {
1,
100,
new ConsultantFilter(),
new Sort().field(FieldEnum.FIRSTNAME).order(OrderEnum.ASC));
new Sort().field(FieldEnum.FIRST_NAME).order(OrderEnum.ASC));
var resultConsultant =
searchResult.getEmbedded().stream()
.filter(
Expand All @@ -102,7 +102,7 @@ class ConsultantAdminFacadeIT {
1,
100,
new ConsultantFilter(),
new Sort().field(FieldEnum.FIRSTNAME).order(OrderEnum.ASC));
new Sort().field(FieldEnum.FIRST_NAME).order(OrderEnum.ASC));
var resultConsultant =
searchResult.getEmbedded().stream()
.filter(
Expand Down Expand Up @@ -201,15 +201,15 @@ void findFilteredConsultants_Should_retrieveConsultantAfterAddingRelationToAgenc

var searchResult =
this.consultantAdminFacade.findFilteredConsultants(
1, 100, consultantFilter, new Sort().field(FieldEnum.FIRSTNAME).order(OrderEnum.ASC));
1, 100, consultantFilter, new Sort().field(FieldEnum.FIRST_NAME).order(OrderEnum.ASC));

assertThat(searchResult.getEmbedded(), hasSize(0));

consultantAdminFacade.createNewConsultantAgency(consultantId, consultantAgencyDto);

searchResult =
this.consultantAdminFacade.findFilteredConsultants(
1, 100, consultantFilter, new Sort().field(FieldEnum.FIRSTNAME).order(OrderEnum.ASC));
1, 100, consultantFilter, new Sort().field(FieldEnum.FIRST_NAME).order(OrderEnum.ASC));
assertThat(searchResult.getEmbedded(), hasSize(greaterThanOrEqualTo(1)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public void findFilteredConsultants_Should_returnResultWithoutPreviousLink_When_

public void
findFilteredConsultants_Should_orderResultByFirstNameDESC_When_sortParameterIsGiven() {
var sort = new Sort().field(FieldEnum.FIRSTNAME).order(OrderEnum.DESC);
var sort = new Sort().field(FieldEnum.FIRST_NAME).order(OrderEnum.DESC);

var result =
this.consultantAdminFilterService.findFilteredConsultants(
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.hibernate.search.util.impl.CollectionHelper.asSet;
import static org.hibernate.validator.internal.util.CollectionHelper.asSet;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.ArgumentMatchers.any;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.hibernate.search.util.impl.CollectionHelper.asSet;
import static org.hibernate.validator.internal.util.CollectionHelper.asSet;

import org.junit.jupiter.api.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import de.caritas.cob.userservice.api.service.agency.AgencyService;
import de.caritas.cob.userservice.api.service.user.UserAccountService;
import de.caritas.cob.userservice.api.testConfig.ConsultingTypeManagerTestConfig;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.collections4.iterators.PeekingIterator;
Expand Down Expand Up @@ -120,7 +121,9 @@ void buildConversations_Should_returnElementsInExpectedOrder() {
ConsultantSessionResponseDTO current = peeker.next();
ConsultantSessionResponseDTO next = peeker.peek();
if (nonNull(next)) {
assertThat(next.getLatestMessage(), greaterThanOrEqualTo(current.getLatestMessage()));
assertThat(
(Date) next.getLatestMessage(),
greaterThanOrEqualTo((Date) current.getLatestMessage()));
}
}
}
Expand Down
Loading

0 comments on commit 1f1803f

Please sign in to comment.