From e8b46f23ee10dde649073b59741c1b922c1559d5 Mon Sep 17 00:00:00 2001 From: tkuzynow Date: Thu, 16 May 2024 11:02:23 +0200 Subject: [PATCH 1/9] fix: upgrade spring boot to 2.4.X --- pom.xml | 48 +- .../adapters/keycloak/KeycloakService.java | 4 +- .../rocketchat/RocketChatRollbackService.java | 2 - .../web/controller/UserAdminController.java | 3 +- .../web/controller/UserController.java | 2 +- .../RocketChatRoomInformationProvider.java | 2 - .../facade/sessionlist/SessionListFacade.java | 1 - .../api/helper/SessionListAnalyser.java | 2 - .../DeleteAskerRoomsAndSessionsAction.java | 2 - .../DeleteSingleRoomAndSessionAction.java | 2 - src/main/resources/application.properties | 4 +- .../keycloak/KeycloakServiceTest.java | 125 ++-- .../AliasJsonDeserializerTest.java | 30 +- .../AliasMessageConverterTest.java | 10 +- ...ConversationControllerAuthorizationIT.java | 5 +- .../controller/ConversationControllerIT.java | 5 +- .../web/controller/LiveProxyControllerIT.java | 5 +- .../UserAdminControllerAuthorizationIT.java | 5 +- .../web/controller/UserAdminControllerIT.java | 5 +- .../web/controller/UserControllerIT.java | 275 ++++---- .../interceptor/StatelessCsrfFilterTest.java | 14 +- .../DecodeUsernameJsonSerializerTest.java | 8 +- ...odeUsernameJsonSerializationUtilsTest.java | 20 +- ...odePasswordJsonSerializationUtilsTest.java | 14 +- .../MandatoryFieldsProviderTest.java | 43 +- .../dto/validation/ValidAgeValidatorTest.java | 12 +- .../validation/ValidStateValidatorTest.java | 12 +- .../facade/AskerUserAdminFacadeTest.java | 33 +- .../admin/facade/ConsultantAdminFacadeIT.java | 5 +- ...AgencyDependedViolationReportRuleTest.java | 10 +- .../registry/ViolationRuleRegistryTest.java | 22 +- ...ConsultantFlagViolationReportRuleTest.java | 8 +- ...yForConsultantViolationReportRuleTest.java | 8 +- ...yForConsultantViolationReportRuleTest.java | 8 +- ...mForConsultantViolationReportRuleTest.java | 8 +- ...ndChatForAskerViolationReportRuleTest.java | 8 +- ...utRequiredFlagViolationReportRuleTest.java | 8 +- .../service/AgencyAdminServiceTest.java | 14 +- .../service/ViolationReportGeneratorTest.java | 12 +- .../admin/create/CreateAdminServiceIT.java | 54 +- .../CreateAdminAgencyRelationServiceIT.java | 45 +- .../admin/delete/DeleteAdminServiceTest.java | 8 +- .../admin/search/RetrieveAdminServiceIT.java | 18 +- .../RetrieveAdminServiceTenantAwareIT.java | 3 - .../admin/update/UpdateAdminServiceIT.java | 7 +- .../SynchronizeAdminAgencyRelationIT.java | 5 +- .../ConsultantAgencyAdminUserServiceIT.java | 9 +- ...ntAgencyAdminUserServiceTenantAwareIT.java | 15 +- .../ConsultantAgencyAdminUserServiceTest.java | 42 +- ...ntAgencyDeletionValidationServiceTest.java | 31 +- ...veConsultantFromRocketChatServiceTest.java | 8 +- .../ConsultantAdminFilterServiceIT.java | 5 +- ...ultantAdminFilterServiceTenantAwareIT.java | 13 +- .../consultant/ConsultantAdminServiceIT.java | 14 +- .../ConsultantAdminServiceTest.java | 22 +- .../create/CreateConsultantSagaIT.java | 68 +- .../CreateConsultantSagaTenantAwareIT.java | 27 +- ...sultantAgencyRelationCreatorServiceIT.java | 140 ++-- ...cyRelationCreatorServiceTenantAwareIT.java | 13 +- ...ltantAgencyRelationCreatorServiceTest.java | 8 +- ...tRecordAgencyCreationInputAdapterTest.java | 2 +- .../ConsultantPreDeletionServiceTest.java | 10 +- .../update/ConsultantUpdateServiceBase.java | 2 +- .../update/ConsultantUpdateServiceIT.java | 5 +- .../ConsultantUpdateServiceTenantAwareIT.java | 13 +- .../update/ConsultantUpdateServiceTest.java | 19 +- .../UserAccountInputValidatorTest.java | 21 +- ...ketChatAddToGroupOperationServiceTest.java | 46 +- ...ketChatOperationConditionProviderTest.java | 8 +- ...atRemoveFromGroupOperationServiceTest.java | 14 +- .../session/SessionAdminServiceIT.java | 5 +- .../SessionAdminServiceTenantAwareIT.java | 13 +- .../AgencySessionPageProviderTest.java | 16 +- .../AllSessionPageProviderTest.java | 14 +- .../AskerSessionPageProviderTest.java | 16 +- .../ConsultantSessionPageProviderTest.java | 8 +- ...ConsultingTypeSessionPageProviderTest.java | 8 +- .../pageprovider/PageProviderFactoryTest.java | 8 +- .../AnonymousUsernameRegistryTest.java | 34 +- .../api/config/auth/AuthorityTest.java | 12 +- .../RoleAuthorizationAuthorityMapperTest.java | 8 +- .../AcceptAnonymousEnquiryFacadeTest.java | 23 +- ...mousEnquiryConversationListProviderIT.java | 28 +- ...SessionConversationListProviderTestIT.java | 22 +- ...SessionConversationListProviderTestIT.java | 21 +- ...eredEnquiryConversationListProviderIT.java | 13 +- .../ConversationListProviderRegistryTest.java | 45 +- .../AnonymousUserCreatorServiceTest.java | 76 ++- .../api/facade/CreateChatV1FacadeTest.java | 225 ++++--- .../api/facade/CreateChatV2FacadeTest.java | 187 +++--- .../CreateEnquiryMessageFacadeTest.java | 629 ++++++++++-------- .../CreateNewConsultingTypeFacadeTest.java | 73 +- .../api/facade/CreateSessionFacadeTest.java | 115 ++-- .../CreateUserChatRelationFacadeTest.java | 159 +++-- .../api/facade/CreateUserFacadeTest.java | 96 +-- .../facade/EmailNotificationFacadeTest.java | 114 ++-- .../api/facade/GetChatFacadeTest.java | 18 +- .../api/facade/GetChatMembersFacadeTest.java | 56 +- .../facade/JoinAndLeaveChatFacadeTest.java | 94 +-- .../api/facade/RocketChatFacadeTest.java | 119 ++-- .../api/facade/SessionArchiveServiceIT.java | 88 ++- .../api/facade/StartChatFacadeTest.java | 43 +- .../api/facade/StopChatFacadeTest.java | 30 +- .../AssignSessionFacadeTest.java | 8 +- .../UnauthorizedMembersProviderTest.java | 60 +- .../CreateAnonymousEnquiryFacadeTest.java | 41 +- .../facade/rollback/RollbackFacadeTest.java | 8 +- ...RocketChatRoomInformationProviderTest.java | 13 +- .../sessionlist/SessionListFacadeTest.java | 16 +- .../userdata/AskerDataProviderTest.java | 50 +- .../userdata/ConsultantDataFacadeTest.java | 12 +- .../userdata/ConsultantDataProviderIT.java | 9 +- .../userdata/ConsultantDataProviderTest.java | 28 +- .../KeycloakUserDataProviderTest.java | 2 +- .../api/helper/AgencyVerifierTest.java | 45 +- .../api/helper/AuthenticatedUserTest.java | 48 +- .../helper/ChatPermissionVerifierTest.java | 217 +++--- .../api/helper/EmptyObjectSerializerTest.java | 10 +- .../userservice/api/helper/HelperTest.java | 12 +- .../RocketChatRoomNameGeneratorTest.java | 14 +- .../api/helper/SessionDataProviderTest.java | 18 +- .../api/helper/SessionListAnalyserTest.java | 12 +- .../api/helper/UserHelperTest.java | 47 +- .../api/helper/UserVerifierTest.java | 4 +- .../api/helper/UsernameTranscoderTest.java | 4 +- .../ConsultingTypeManagerTest.java | 5 +- .../userservice/api/model/ChatAgencyTest.java | 2 +- .../cob/userservice/api/model/ChatTest.java | 17 +- .../api/model/ConsultantAgencyTest.java | 2 +- .../userservice/api/model/ConsultantTest.java | 10 +- .../api/model/SessionDataTest.java | 2 +- .../userservice/api/model/SessionTest.java | 2 +- .../userservice/api/model/UserAgencyTest.java | 2 +- .../cob/userservice/api/model/UserTest.java | 2 +- .../api/service/ChatServiceTest.java | 58 +- .../service/ConsultantAgencyServiceTest.java | 20 +- .../api/service/ConsultantServiceIT.java | 3 - .../service/ConsultingTypeServiceTest.java | 2 +- .../api/service/DecryptionServiceTest.java | 28 +- .../api/service/LogServiceTest.java | 12 +- .../api/service/RocketChatServiceTest.java | 386 ++++++----- .../api/service/SessionDataServiceTest.java | 21 +- .../api/service/UserAgencyServiceTest.java | 21 +- .../archive/SessionArchiveServiceTest.java | 176 +++-- ...onymousConversationCreatorServiceTest.java | 135 ++-- .../AssignEnquiryEmailSupplierTest.java | 12 +- .../NewDirectEnquiryEmailSupplierTest.java | 12 +- .../NewEnquiryEmailSupplierTest.java | 12 +- .../NewFeedbackEmailSupplierTest.java | 12 +- .../NewMessageEmailSupplierTest.java | 38 +- .../AgencySecurityHeaderSupplierTest.java | 34 +- .../api/service/helper/MailServiceTest.java | 12 +- .../RocketChatCredentialsProviderTest.java | 22 +- .../helper/RocketChatRollbackServiceTest.java | 12 +- .../SecurityHeaderSupplierTest.java | 16 +- .../LiveEventNotificationServiceTest.java | 17 +- ...evantUserAccountIdsByChatProviderTest.java | 17 +- ...ntUserAccountIdsBySessionProviderTest.java | 8 +- .../UserIdsProviderFactoryTest.java | 8 +- .../message/MessageServiceProviderTest.java | 84 +-- .../FirebasePushMessageServiceTest.java | 23 +- .../service/session/SessionMapperTest.java | 2 +- .../api/service/session/SessionServiceIT.java | 3 - .../AvailableLastMessageUpdaterTest.java | 12 +- .../ConsultantChatEnricherTest.java | 12 +- .../ConsultantSessionEnricherTest.java | 56 +- .../ConsultantSessionListServiceTest.java | 54 +- .../UserSessionListServiceTest.java | 13 +- .../statistics/StatisticsServiceIT.java | 5 +- .../statistics/StatisticsServiceTest.java | 27 +- .../AssignSessionStatisticsEventTest.java | 12 +- .../RegistrationStatisticsEventTest.java | 12 +- .../service/user/UserAccountServiceTest.java | 45 +- .../api/service/user/UserServiceIT.java | 3 - .../validation/UserAccountValidatorTest.java | 23 +- ...leteAppointmentServiceAskerActionTest.java | 12 +- ...DeleteAskerRoomsAndSessionsActionTest.java | 12 +- .../asker/DeleteDatabaseAskerActionTest.java | 12 +- .../DeleteDatabaseAskerAgencyActionTest.java | 12 +- .../asker/DeleteKeycloakAskerActionTest.java | 12 +- .../DeleteRocketChatAskerActionTest.java | 12 +- .../DeleteSingleRoomAndSessionActionTest.java | 12 +- ...ppointmentServiceConsultantActionTest.java | 12 +- .../consultant/DeleteChatActionTest.java | 12 +- .../DeleteDatabaseConsultantActionTest.java | 14 +- ...eteDatabaseConsultantAgencyActionTest.java | 12 +- .../DeleteKeycloakConsultantActionTest.java | 12 +- .../DeleteRocketChatConsultantActionTest.java | 12 +- ...eInactiveSessionsAndUserSchedulerTest.java | 8 +- .../DeleteUserAccountSchedulerTest.java | 8 +- .../DeleteUserAnonymousSchedulerTest.java | 8 +- ...eleteUsersRegisteredOnlySchedulerTest.java | 8 +- ...eteInactiveSessionsAndUserServiceTest.java | 8 +- .../service/DeleteSessionServiceTest.java | 8 +- .../service/DeleteUserAccountServiceTest.java | 8 +- .../DeleteUsersRegisteredOnlyServiceTest.java | 8 +- .../service/WorkflowErrorLogServiceTest.java | 12 +- .../service/WorkflowErrorMailServiceTest.java | 12 +- .../InactivePrivateGroupsProviderTest.java | 12 +- 199 files changed, 3432 insertions(+), 2943 deletions(-) diff --git a/pom.xml b/pom.xml index f346295e9..4552ff7a3 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ org.springframework.boot spring-boot-starter-parent - 2.3.12.RELEASE + 2.4.13 @@ -43,12 +43,12 @@ 2.1.1 2.6.6 5.7.5 - 5.2.20.RELEASE - 5.2.20.RELEASE - 5.2.20.RELEASE + 5.3.34 + 5.3.34 + 5.3.34 2.4.7 2.10.0 - 5.3.23 + 5.3.34 2.10.9.2 1.17.6 @@ -64,6 +64,15 @@ org.springframework.boot spring-boot-starter-security + + org.springframework + spring-web + 5.3.34 + + + org.springframework.boot + spring-boot-starter-validation + org.springframework.boot spring-boot-starter-data-jpa @@ -131,7 +140,7 @@ org.hibernate hibernate-search-orm - 5.11.10.Final + 5.11.12.Final @@ -158,6 +167,10 @@ springfox-swagger2 ${springfox.version} + + javax.validation + validation-api + io.springfox springfox-bean-validators @@ -349,6 +362,12 @@ org.powermock test ${powermock.version} + + + junit + junit + + powermock-api-mockito2 @@ -457,6 +476,23 @@ org.springframework.boot spring-boot-maven-plugin + + org.openrewrite.maven + rewrite-maven-plugin + 5.30.0 + + + org.openrewrite.java.spring.boot2.UpgradeSpringBoot_2_4 + + + + + org.openrewrite.recipe + rewrite-spring + 5.9.0 + + + @@ -41,14 +41,14 @@ 1.7 4.8.0 2.1.1 - 2.6.6 + 2.6.15 5.7.5 - 5.3.34 - 5.3.34 - 5.3.34 + 5.3.35 + 5.3.35 + 5.3.35 2.4.7 2.10.0 - 5.3.34 + 5.3.35 2.10.9.2 1.17.6 @@ -67,7 +67,7 @@ org.springframework spring-web - 5.3.34 + 5.3.35 org.springframework.boot @@ -171,16 +171,6 @@ javax.validation validation-api - - io.springfox - springfox-bean-validators - ${springfox.version} - - - io.springfox - springfox-swagger-ui - ${springfox-swagger-ui.version} - @@ -369,6 +359,26 @@ + + org.mockito + mockito-core + 5.12.0 + test + + + org.mockito + mockito-junit-jupiter + 5.12.0 + test + + + + net.bytebuddy + byte-buddy + 1.14.15 + + + powermock-api-mockito2 org.powermock @@ -433,11 +443,11 @@ - org.mongodb - mongo-java-driver - 3.12.11 + org.springframework.boot + spring-boot-starter-data-mongodb + org.yaml snakeyaml @@ -472,17 +482,13 @@ - - org.springframework.boot - spring-boot-maven-plugin - org.openrewrite.maven rewrite-maven-plugin 5.30.0 - org.openrewrite.java.spring.boot2.UpgradeSpringBoot_2_4 + org.openrewrite.java.spring.boot2.UpgradeSpringBoot_2_7 @@ -494,6 +500,7 @@ + diff --git a/src/main/java/de/caritas/cob/userservice/api/adapters/keycloak/config/KeycloakConfig.java b/src/main/java/de/caritas/cob/userservice/api/adapters/keycloak/config/KeycloakConfig.java index cf6b072e5..18221778a 100644 --- a/src/main/java/de/caritas/cob/userservice/api/adapters/keycloak/config/KeycloakConfig.java +++ b/src/main/java/de/caritas/cob/userservice/api/adapters/keycloak/config/KeycloakConfig.java @@ -11,6 +11,8 @@ import lombok.Data; import org.hibernate.validator.constraints.URL; import org.keycloak.KeycloakSecurityContext; +import org.keycloak.adapters.KeycloakConfigResolver; +import org.keycloak.adapters.springboot.KeycloakSpringBootConfigResolver; import org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken; import org.keycloak.admin.client.Keycloak; import org.keycloak.admin.client.KeycloakBuilder; @@ -91,6 +93,15 @@ public Keycloak keycloak() { .build(); } + /** + * Use the KeycloakSpringBootConfigResolver to be able to save the Keycloak settings in the spring + * application properties. + */ + @Bean + public KeycloakConfigResolver keyCloakConfigResolver() { + return new KeycloakSpringBootConfigResolver(); + } + @URL private String authServerUrl; @NotBlank private String realm; diff --git a/src/main/java/de/caritas/cob/userservice/api/adapters/rocketchat/RocketChatService.java b/src/main/java/de/caritas/cob/userservice/api/adapters/rocketchat/RocketChatService.java index ee3d590b4..3a1a1d345 100644 --- a/src/main/java/de/caritas/cob/userservice/api/adapters/rocketchat/RocketChatService.java +++ b/src/main/java/de/caritas/cob/userservice/api/adapters/rocketchat/RocketChatService.java @@ -1,5 +1,7 @@ package de.caritas.cob.userservice.api.adapters.rocketchat; +import static com.mongodb.client.model.Filters.eq; +import static com.mongodb.client.model.Filters.lt; import static de.caritas.cob.userservice.api.helper.CustomLocalDateTime.nowInUtc; import static java.util.Arrays.asList; import static java.util.Objects.isNull; @@ -7,8 +9,6 @@ import static org.apache.commons.lang3.ArrayUtils.isNotEmpty; import com.google.common.collect.Lists; -import com.mongodb.DBObject; -import com.mongodb.QueryBuilder; import com.mongodb.client.MongoClient; import com.mongodb.client.model.Filters; import de.caritas.cob.userservice.api.adapters.rocketchat.config.RocketChatConfig; @@ -71,6 +71,7 @@ import lombok.NonNull; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.bson.BsonDocument; import org.bson.Document; import org.springframework.cache.annotation.Cacheable; import org.springframework.context.annotation.Profile; @@ -769,7 +770,7 @@ public List getChatUsers(String chatId) { mongoClient .getDatabase(MONGO_DATABASE_NAME) .getCollection(MONGO_COLLECTION_SUBSCRIPTION) - .find(Filters.eq("rid", chatId)); + .find(eq("rid", chatId)); var members = new ArrayList(); try (var cursor = subscriptions.iterator()) { @@ -1170,31 +1171,26 @@ public List fetchAllInactivePrivateGroupsSinceGivenDate( final var GROUP_RESPONSE_GROUP_TYPE_FIELD = "t"; final var GROUP_RESPONSE_GROUP_TYPE_PRIVATE = "p"; - DBObject mongoDbQuery = - QueryBuilder.start(GROUP_RESPONSE_LAST_MESSAGE_TIMESTAMP_FIELD) - .lessThan( - QueryBuilder.start("$date") - .is( - dateTimeSinceInactive.format( - DateTimeFormatter.ofPattern(RC_DATE_TIME_PATTERN))) - .get()) - .and( - QueryBuilder.start(GROUP_RESPONSE_GROUP_TYPE_FIELD) - .is(GROUP_RESPONSE_GROUP_TYPE_PRIVATE) - .get()) - .get(); + BsonDocument filter = + Filters.and( + lt( + GROUP_RESPONSE_LAST_MESSAGE_TIMESTAMP_FIELD, + dateTimeSinceInactive.format( + DateTimeFormatter.ofPattern(RC_DATE_TIME_PATTERN))), + eq(GROUP_RESPONSE_GROUP_TYPE_FIELD, GROUP_RESPONSE_GROUP_TYPE_PRIVATE)) + .toBsonDocument(); - return getGroupsListAll(mongoDbQuery); + return getGroupsListAll(filter.toJson()); } /** * Returns a list of all Rocket.Chat groups. * - * @param mongoDbQuery mongoDB Query as {@link DBObject} created with {@link QueryBuilder} + * @param mongoDbQuery mongoDB Query as {@link String} * @return a {@link List} of {@link GroupDTO} instances * @throws RocketChatGetGroupsListAllException when request fails */ - private List getGroupsListAll(DBObject mongoDbQuery) + private List getGroupsListAll(String mongoDbQuery) throws RocketChatGetGroupsListAllException { try { @@ -1210,7 +1206,7 @@ private List getGroupsListAll(DBObject mongoDbQuery) } private List getGroupListAllCombiningPages( - DBObject mongoDbQuery, HttpEntity request) + String mongoDbQuery, HttpEntity request) throws RocketChatGetGroupsListAllException { List result = Lists.newArrayList(); int currentOffset = 0; @@ -1248,12 +1244,12 @@ private boolean isResponseSuccessful(ResponseEntity pa private ResponseEntity getGroupsListAllResponseDTOResponseEntityForCurrentOffset( - DBObject mongoDbQuery, HttpEntity request, int currentOffset) { + String mongoDbQuery, HttpEntity request, int currentOffset) { ResponseEntity response; var url = getGroupAllPaginatedUrl(currentOffset); response = restTemplate.exchange( - url, HttpMethod.GET, request, GroupsListAllResponseDTO.class, mongoDbQuery.toString()); + url, HttpMethod.GET, request, GroupsListAllResponseDTO.class, mongoDbQuery); return response; } diff --git a/src/main/java/de/caritas/cob/userservice/api/adapters/web/controller/CustomSwaggerUIApiResourceController.java b/src/main/java/de/caritas/cob/userservice/api/adapters/web/controller/CustomSwaggerUIApiResourceController.java deleted file mode 100644 index 681690b4d..000000000 --- a/src/main/java/de/caritas/cob/userservice/api/adapters/web/controller/CustomSwaggerUIApiResourceController.java +++ /dev/null @@ -1,17 +0,0 @@ -package de.caritas.cob.userservice.api.adapters.web.controller; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import springfox.documentation.annotations.ApiIgnore; -import springfox.documentation.swagger.web.ApiResourceController; -import springfox.documentation.swagger.web.SwaggerResourcesProvider; - -@Controller -@ApiIgnore -@RequestMapping(value = "${springfox.docuPath}" + "/swagger-resources") -public class CustomSwaggerUIApiResourceController extends ApiResourceController { - - public CustomSwaggerUIApiResourceController(SwaggerResourcesProvider swaggerResources) { - super(swaggerResources); - } -} diff --git a/src/main/java/de/caritas/cob/userservice/api/adapters/web/controller/CustomSwaggerUIController.java b/src/main/java/de/caritas/cob/userservice/api/adapters/web/controller/CustomSwaggerUIController.java deleted file mode 100644 index dc2f9e9d0..000000000 --- a/src/main/java/de/caritas/cob/userservice/api/adapters/web/controller/CustomSwaggerUIController.java +++ /dev/null @@ -1,19 +0,0 @@ -package de.caritas.cob.userservice.api.adapters.web.controller; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import springfox.documentation.annotations.ApiIgnore; - -@Controller -@ApiIgnore -public class CustomSwaggerUIController { - - @Value("${springfox.docuPath}") - private String docuPath; - - @RequestMapping(value = "${springfox.docuPath}") - public String index() { - return "redirect:" + docuPath + "/swagger-ui.html"; - } -} diff --git a/src/main/java/de/caritas/cob/userservice/api/adapters/web/controller/CustomSwaggerUIPathController.java b/src/main/java/de/caritas/cob/userservice/api/adapters/web/controller/CustomSwaggerUIPathController.java deleted file mode 100644 index c8da2aaed..000000000 --- a/src/main/java/de/caritas/cob/userservice/api/adapters/web/controller/CustomSwaggerUIPathController.java +++ /dev/null @@ -1,24 +0,0 @@ -package de.caritas.cob.userservice.api.adapters.web.controller; - -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import springfox.documentation.annotations.ApiIgnore; -import springfox.documentation.spring.web.DocumentationCache; -import springfox.documentation.spring.web.json.JsonSerializer; -import springfox.documentation.swagger2.mappers.ServiceModelToSwagger2Mapper; -import springfox.documentation.swagger2.web.Swagger2Controller; - -@Controller -@ApiIgnore -@RequestMapping(value = "${springfox.docuPath}") -public class CustomSwaggerUIPathController extends Swagger2Controller { - - public CustomSwaggerUIPathController( - Environment environment, - DocumentationCache documentationCache, - ServiceModelToSwagger2Mapper mapper, - JsonSerializer jsonSerializer) { - super(environment, documentationCache, mapper, jsonSerializer); - } -} diff --git a/src/main/java/de/caritas/cob/userservice/api/config/LiquibaseConfig.java b/src/main/java/de/caritas/cob/userservice/api/config/LiquibaseConfig.java index 48c12e4b1..1efc45e3b 100644 --- a/src/main/java/de/caritas/cob/userservice/api/config/LiquibaseConfig.java +++ b/src/main/java/de/caritas/cob/userservice/api/config/LiquibaseConfig.java @@ -6,9 +6,11 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; @Configuration @EnableConfigurationProperties(LiquibaseProperties.class) +@Profile("!testing") public class LiquibaseConfig { @Bean diff --git a/src/main/java/de/caritas/cob/userservice/api/config/SpringFoxConfig.java b/src/main/java/de/caritas/cob/userservice/api/config/SpringFoxConfig.java deleted file mode 100644 index 5211bac09..000000000 --- a/src/main/java/de/caritas/cob/userservice/api/config/SpringFoxConfig.java +++ /dev/null @@ -1,141 +0,0 @@ -package de.caritas.cob.userservice.api.config; - -import static java.util.Collections.singletonList; - -import java.time.LocalTime; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.hateoas.client.LinkDiscoverer; -import org.springframework.hateoas.client.LinkDiscoverers; -import org.springframework.hateoas.mediatype.collectionjson.CollectionJsonLinkDiscoverer; -import org.springframework.plugin.core.SimplePluginRegistry; -import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.ApiKey; -import springfox.documentation.service.AuthorizationScope; -import springfox.documentation.service.Contact; -import springfox.documentation.service.SecurityReference; -import springfox.documentation.service.SecurityScheme; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spi.service.contexts.SecurityContext; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -/** Provides the SpringFox (API documentation generation) configuration. */ -@Configuration -@EnableSwagger2 -@Import(BeanValidatorPluginsConfiguration.class) -public class SpringFoxConfig { - - @Value("${springfox.docuTitle}") - private String docuTitle; - - @Value("${springfox.docuDescription}") - private String docuDescription; - - @Value("${springfox.docuVersion}") - private String docuVersion; - - @Value("${springfox.docuTermsUrl}") - private String docuTermsUrl; - - @Value("${springfox.docuContactName}") - private String docuContactName; - - @Value("${springfox.docuContactUrl}") - private String docuContactUrl; - - @Value("${springfox.docuContactEmail}") - private String docuContactEmail; - - @Value("${springfox.docuLicense}") - private String docuLicense; - - @Value("${springfox.docuLicenseUrl}") - private String docuLicenseUrl; - - @Bean - public Docket apiDocket() { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("de.caritas.cob.userservice.api")) - .build() - .consumes(getContentTypes()) - .produces(getContentTypes()) - .apiInfo(getApiInfo()) - .useDefaultResponseMessages(false) - .protocols(protocols()) - .securitySchemes(securitySchemes()) - .securityContexts(securityContexts()) - .directModelSubstitute(LocalTime.class, String.class); - } - - private List securityContexts() { - return singletonList( - SecurityContext.builder() - .forPaths(PathSelectors.any()) - .securityReferences(securityReferences()) - .build()); - } - - private List securityReferences() { - return singletonList( - SecurityReference.builder().reference("token").scopes(new AuthorizationScope[0]).build()); - } - - private List securitySchemes() { - return singletonList(new ApiKey("Bearer", "Authorization", "header")); - } - - /** - * Returns the API protocols (for documentation) - * - * @return - */ - private Set protocols() { - Set protocols = new HashSet<>(); - protocols.add("http"); // TODO remove for production mode - protocols.add("https"); - return protocols; - } - - /** Returns all content types which should be consumed/produced */ - private Set getContentTypes() { - Set contentTypes = new HashSet<>(); - contentTypes.add("application/json"); - return contentTypes; - } - - /** - * Returns the API information (defined in application.properties) - * - * @return - */ - private ApiInfo getApiInfo() { - return new ApiInfo( - docuTitle, - docuDescription, - docuVersion, - docuTermsUrl, - new Contact(docuContactName, docuContactUrl, docuContactEmail), - docuLicense, - docuLicenseUrl, - Collections.emptyList()); - } - - @Bean - public LinkDiscoverers discoverers() { - List plugins = new ArrayList<>(); - plugins.add(new CollectionJsonLinkDiscoverer()); - return new LinkDiscoverers(SimplePluginRegistry.create(plugins)); - } -} diff --git a/src/main/java/de/caritas/cob/userservice/api/config/SwaggerConfig.java b/src/main/java/de/caritas/cob/userservice/api/config/SwaggerConfig.java new file mode 100644 index 000000000..02f620b00 --- /dev/null +++ b/src/main/java/de/caritas/cob/userservice/api/config/SwaggerConfig.java @@ -0,0 +1,20 @@ +package de.caritas.cob.userservice.api.config; + +import java.util.ArrayList; +import java.util.List; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.hateoas.client.LinkDiscoverer; +import org.springframework.hateoas.client.LinkDiscoverers; +import org.springframework.plugin.core.SimplePluginRegistry; + +@Configuration +public class SwaggerConfig { + + @Bean + public LinkDiscoverers discoverers() { + List plugins = new ArrayList<>(); + plugins.add(new org.springframework.hateoas.mediatype.hal.HalLinkDiscoverer()); + return new LinkDiscoverers(SimplePluginRegistry.create(plugins)); + } +} diff --git a/src/main/java/de/caritas/cob/userservice/api/config/auth/SecurityConfig.java b/src/main/java/de/caritas/cob/userservice/api/config/auth/SecurityConfig.java index ee245104d..1ac1ca4da 100644 --- a/src/main/java/de/caritas/cob/userservice/api/config/auth/SecurityConfig.java +++ b/src/main/java/de/caritas/cob/userservice/api/config/auth/SecurityConfig.java @@ -5,8 +5,6 @@ import de.caritas.cob.userservice.api.adapters.web.controller.interceptor.HttpTenantFilter; import de.caritas.cob.userservice.api.adapters.web.controller.interceptor.StatelessCsrfFilter; import de.caritas.cob.userservice.api.config.CsrfSecurityProperties; -import org.keycloak.adapters.KeycloakConfigResolver; -import org.keycloak.adapters.springboot.KeycloakSpringBootConfigResolver; import org.keycloak.adapters.springsecurity.KeycloakConfiguration; import org.keycloak.adapters.springsecurity.client.KeycloakClientRequestFactory; import org.keycloak.adapters.springsecurity.config.KeycloakWebSecurityConfigurerAdapter; @@ -244,15 +242,6 @@ private HttpSecurity enableTenantFilterIfMultitenancyEnabled(HttpSecurity httpSe return httpSecurity; } - /** - * Use the KeycloakSpringBootConfigResolver to be able to save the Keycloak settings in the spring - * application properties. - */ - @Bean - public KeycloakConfigResolver keyCloakConfigResolver() { - return new KeycloakSpringBootConfigResolver(); - } - /** Change springs authentication strategy to be stateless (no session is being created). */ @Bean @Override diff --git a/src/main/resources/application-testing.properties b/src/main/resources/application-testing.properties index e9e88dad9..73dcfc890 100644 --- a/src/main/resources/application-testing.properties +++ b/src/main/resources/application-testing.properties @@ -39,7 +39,9 @@ spring.liquibase.enabled=false # Test datasource spring.datasource.driver-class-name=org.h2.Driver spring.datasource.url=jdbc:h2:mem:db;DB_CLOSE_DELAY=-1 +spring.sql.init.data-locations=classpath:database/UserServiceDatabase.sql spring.datasource.data=classpath*:database/UserServiceDatabase.sql +spring.jpa.defer-datasource-initialization=true spring.jpa.generate-ddl=true spring.jpa.hibernate.dialect=org.hibernate.dialect.H2Dialect spring.jpa.open-in-view=false @@ -71,3 +73,7 @@ appointments.delete-job-enabled=true feature.topics.enabled=false agency.service.api.url=${app.base.url}/service + +spring.mongodb.embedded.version=5.0.6 +spring.data.mongodb.uri=mongodb://mongodb:27017/consulting_types?retryWrites=false +de.flapdoodle.mongodb.embedded.version=5.0.6 \ No newline at end of file diff --git a/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/AppointmentControllerE2EIT.java b/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/AppointmentControllerE2EIT.java index b8e069b17..8b55947d0 100644 --- a/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/AppointmentControllerE2EIT.java +++ b/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/AppointmentControllerE2EIT.java @@ -35,6 +35,7 @@ import org.jeasy.random.EasyRandom; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; +import org.keycloak.adapters.KeycloakConfigResolver; import org.mockito.ArgumentMatchers; import org.springframework.amqp.core.Message; import org.springframework.amqp.rabbit.core.RabbitTemplate; @@ -75,6 +76,8 @@ class AppointmentControllerE2EIT { @MockBean private Clock clock; + @MockBean private KeycloakConfigResolver keycloakConfigResolver; + private Appointment appointment; private de.caritas.cob.userservice.api.model.Appointment savedAppointment; diff --git a/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/ConversationControllerIT.java b/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/ConversationControllerIT.java index 89999be37..dec3b356e 100644 --- a/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/ConversationControllerIT.java +++ b/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/ConversationControllerIT.java @@ -23,6 +23,7 @@ import de.caritas.cob.userservice.api.port.in.Messaging; import org.jeasy.random.EasyRandom; import org.junit.jupiter.api.Test; +import org.keycloak.adapters.KeycloakConfigResolver; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; @@ -35,7 +36,7 @@ @WebMvcTest(ConversationController.class) @AutoConfigureMockMvc(addFilters = false) @TestPropertySource(properties = "spring.profiles.active=testing") -public class ConversationControllerIT { +class ConversationControllerIT { private static final String ENQUIRIES_BASE_PATH = "/conversations/consultants/enquiries/"; static final String GET_ANONYMOUS_ENQUIRIES_PATH = ENQUIRIES_BASE_PATH + "anonymous"; @@ -70,8 +71,10 @@ public class ConversationControllerIT { @MockBean private AuthenticatedUser authenticatedUser; + @MockBean private KeycloakConfigResolver keycloakConfigResolver; + @Test - public void getAnonymousEnquiries_Should_returnOk_When_requestParamsAreValid() throws Exception { + void getAnonymousEnquiries_Should_returnOk_When_requestParamsAreValid() throws Exception { this.mvc .perform( get(GET_ANONYMOUS_ENQUIRIES_PATH) @@ -82,7 +85,7 @@ public void getAnonymousEnquiries_Should_returnOk_When_requestParamsAreValid() t } @Test - public void getAnonymousEnquiries_Should_returnBadRequest_When_offsetIsMissing() + void getAnonymousEnquiries_Should_returnBadRequest_When_offsetIsMissing() throws Exception { this.mvc .perform( @@ -93,7 +96,7 @@ public void getAnonymousEnquiries_Should_returnBadRequest_When_offsetIsMissing() } @Test - public void getAnonymousEnquiries_Should_returnBadRequest_When_countIsMissing() throws Exception { + void getAnonymousEnquiries_Should_returnBadRequest_When_countIsMissing() throws Exception { this.mvc .perform( get(GET_ANONYMOUS_ENQUIRIES_PATH) @@ -103,7 +106,7 @@ public void getAnonymousEnquiries_Should_returnBadRequest_When_countIsMissing() } @Test - public void getAnonymousEnquiries_Should_returnBadRequest_When_offsetIsLowerThanZero() + void getAnonymousEnquiries_Should_returnBadRequest_When_offsetIsLowerThanZero() throws Exception { this.mvc .perform( @@ -115,7 +118,7 @@ public void getAnonymousEnquiries_Should_returnBadRequest_When_offsetIsLowerThan } @Test - public void getAnonymousEnquiries_Should_returnBadRequest_When_countIsZero() throws Exception { + void getAnonymousEnquiries_Should_returnBadRequest_When_countIsZero() throws Exception { this.mvc .perform( get(GET_ANONYMOUS_ENQUIRIES_PATH) @@ -126,7 +129,7 @@ public void getAnonymousEnquiries_Should_returnBadRequest_When_countIsZero() thr } @Test - public void getAnonymousEnquiries_Should_returnBadRequest_When_countIsLowerThanZero() + void getAnonymousEnquiries_Should_returnBadRequest_When_countIsLowerThanZero() throws Exception { this.mvc .perform( @@ -138,7 +141,7 @@ public void getAnonymousEnquiries_Should_returnBadRequest_When_countIsLowerThanZ } @Test - public void getRegisteredEnquiries_Should_returnOk_When_requestParamsAreValid() throws Exception { + void getRegisteredEnquiries_Should_returnOk_When_requestParamsAreValid() throws Exception { this.mvc .perform( get(GET_REGISTERED_ENQUIRIES_PATH) @@ -149,7 +152,7 @@ public void getRegisteredEnquiries_Should_returnOk_When_requestParamsAreValid() } @Test - public void getRegisteredEnquiries_Should_returnBadRequest_When_offsetIsMissing() + void getRegisteredEnquiries_Should_returnBadRequest_When_offsetIsMissing() throws Exception { this.mvc .perform( @@ -160,7 +163,7 @@ public void getRegisteredEnquiries_Should_returnBadRequest_When_offsetIsMissing( } @Test - public void getRegisteredEnquiries_Should_returnBadRequest_When_countIsMissing() + void getRegisteredEnquiries_Should_returnBadRequest_When_countIsMissing() throws Exception { this.mvc .perform( @@ -171,7 +174,7 @@ public void getRegisteredEnquiries_Should_returnBadRequest_When_countIsMissing() } @Test - public void getRegisteredEnquiries_Should_returnBadRequest_When_offsetIsLowerThanZero() + void getRegisteredEnquiries_Should_returnBadRequest_When_offsetIsLowerThanZero() throws Exception { this.mvc .perform( @@ -183,7 +186,7 @@ public void getRegisteredEnquiries_Should_returnBadRequest_When_offsetIsLowerTha } @Test - public void getRegisteredEnquiries_Should_returnBadRequest_When_countIsZero() throws Exception { + void getRegisteredEnquiries_Should_returnBadRequest_When_countIsZero() throws Exception { this.mvc .perform( get(GET_REGISTERED_ENQUIRIES_PATH) @@ -194,7 +197,7 @@ public void getRegisteredEnquiries_Should_returnBadRequest_When_countIsZero() th } @Test - public void getRegisteredEnquiries_Should_returnBadRequest_When_countIsLowerThanZero() + void getRegisteredEnquiries_Should_returnBadRequest_When_countIsLowerThanZero() throws Exception { this.mvc .perform( @@ -206,7 +209,7 @@ public void getRegisteredEnquiries_Should_returnBadRequest_When_countIsLowerThan } @Test - public void acceptAnonymousEnquiry_Should_returnOk_When_requestParamsAreValid() throws Exception { + void acceptAnonymousEnquiry_Should_returnOk_When_requestParamsAreValid() throws Exception { this.mvc .perform( put(ACCEPT_ANONYMOUS_ENQUIRY_PATH).header(RC_TOKEN_HEADER_PARAMETER_NAME, RC_TOKEN)) @@ -216,7 +219,7 @@ public void acceptAnonymousEnquiry_Should_returnOk_When_requestParamsAreValid() } @Test - public void acceptAnonymousEnquiry_Should_returnBadRequest_When_sessionIdIsInvalid() + void acceptAnonymousEnquiry_Should_returnBadRequest_When_sessionIdIsInvalid() throws Exception { this.mvc .perform( @@ -228,7 +231,7 @@ public void acceptAnonymousEnquiry_Should_returnBadRequest_When_sessionIdIsInval } @Test - public void createAnonymousEnquiry_Should_ReturnCreated_WhenProvidedWithValidRequestBody() + void createAnonymousEnquiry_Should_ReturnCreated_WhenProvidedWithValidRequestBody() throws Exception { this.mvc .perform( @@ -243,7 +246,7 @@ public void createAnonymousEnquiry_Should_ReturnCreated_WhenProvidedWithValidReq } @Test - public void createAnonymousEnquiry_Should_ReturnBadRequest_WhenProvidedWithInvalidRequestBody() + void createAnonymousEnquiry_Should_ReturnBadRequest_WhenProvidedWithInvalidRequestBody() throws Exception { this.mvc .perform( @@ -255,7 +258,7 @@ public void createAnonymousEnquiry_Should_ReturnBadRequest_WhenProvidedWithInval } @Test - public void finishAnonymousConversation_Should_ReturnBadRequest_WhenProvidedWithInvalidSessionId() + void finishAnonymousConversation_Should_ReturnBadRequest_WhenProvidedWithInvalidSessionId() throws Exception { this.mvc .perform( @@ -266,7 +269,7 @@ public void finishAnonymousConversation_Should_ReturnBadRequest_WhenProvidedWith } @Test - public void finishAnonymousConversation_Should_ReturnOk_WhenProvidedWithValidSessionId() + void finishAnonymousConversation_Should_ReturnOk_WhenProvidedWithValidSessionId() throws Exception { this.mvc .perform( diff --git a/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/LiveProxyControllerIT.java b/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/LiveProxyControllerIT.java index 331a2ba55..f4837c9b2 100644 --- a/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/LiveProxyControllerIT.java +++ b/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/LiveProxyControllerIT.java @@ -10,6 +10,7 @@ import de.caritas.cob.userservice.api.config.auth.RoleAuthorizationAuthorityMapper; import de.caritas.cob.userservice.api.service.liveevents.LiveEventNotificationService; import org.junit.jupiter.api.Test; +import org.keycloak.adapters.KeycloakConfigResolver; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; @@ -21,7 +22,7 @@ @WebMvcTest(LiveProxyController.class) @AutoConfigureMockMvc(addFilters = false) @TestPropertySource(properties = "spring.profiles.active=testing") -public class LiveProxyControllerIT { +class LiveProxyControllerIT { private static final String LIVE_EVENT_PATH = "/liveproxy/send"; @@ -33,15 +34,17 @@ public class LiveProxyControllerIT { @MockBean private LinkDiscoverers linkDiscoverers; + @MockBean private KeycloakConfigResolver keycloakConfigResolver; + @Test - public void sendLiveEvent_Should_returnBadRequest_When_rcGroupIdIsNotProvided() throws Exception { + void sendLiveEvent_Should_returnBadRequest_When_rcGroupIdIsNotProvided() throws Exception { this.mockMvc.perform(post(LIVE_EVENT_PATH)).andExpect(status().isBadRequest()); verifyNoInteractions(liveEventNotificationService); } @Test - public void sendLiveEvent_Should_returnStatusOkAndUseMock_When_rcGroupIdIsProvided() + void sendLiveEvent_Should_returnStatusOkAndUseMock_When_rcGroupIdIsProvided() throws Exception { this.mockMvc.perform(post(LIVE_EVENT_PATH).param("rcGroupId", "id")).andExpect(status().isOk()); diff --git a/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserAdminControllerIT.java b/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserAdminControllerIT.java index 7a45eadd9..4e2743b7b 100644 --- a/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserAdminControllerIT.java +++ b/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserAdminControllerIT.java @@ -38,6 +38,7 @@ import java.util.UUID; import org.jeasy.random.EasyRandom; import org.junit.jupiter.api.Test; +import org.keycloak.adapters.KeycloakConfigResolver; import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; @@ -52,7 +53,7 @@ @WebMvcTest(UserAdminController.class) @AutoConfigureMockMvc(addFilters = false) @AutoConfigureTestDatabase(replace = Replace.ANY) -public class UserAdminControllerIT { +class UserAdminControllerIT { protected static final String ROOT_PATH = "/useradmin"; protected static final String SESSION_PATH = ROOT_PATH + "/sessions"; @@ -110,14 +111,16 @@ public class UserAdminControllerIT { @MockBean private AuthenticatedUser authenticatedUser; + @MockBean private KeycloakConfigResolver keycloakConfigResolver; + @Test - public void getSessions_Should_returnBadRequest_When_requiredPaginationParamsAreMissing() + void getSessions_Should_returnBadRequest_When_requiredPaginationParamsAreMissing() throws Exception { this.mvc.perform(get(SESSION_PATH)).andExpect(status().isBadRequest()); } @Test - public void getRoot_Should_returnExpectedRootDTO() throws Exception { + void getRoot_Should_returnExpectedRootDTO() throws Exception { this.mvc .perform(get(ROOT_PATH)) .andExpect(status().isOk()) @@ -134,7 +137,7 @@ public void getRoot_Should_returnExpectedRootDTO() throws Exception { } @Test - public void getSessions_Should_returnOk_When_requiredPaginationParamsAreGiven() throws Exception { + void getSessions_Should_returnOk_When_requiredPaginationParamsAreGiven() throws Exception { this.mvc .perform(get(SESSION_PATH).param(PAGE_PARAM, "0").param(PER_PAGE_PARAM, "1")) .andExpect(status().isOk()); @@ -143,7 +146,7 @@ public void getSessions_Should_returnOk_When_requiredPaginationParamsAreGiven() } @Test - public void getConsultantAgency_Should_returnOk_When_requiredConsultantIdParamIsGiven() + void getConsultantAgency_Should_returnOk_When_requiredConsultantIdParamIsGiven() throws Exception { String consultantId = "1da238c6-cd46-4162-80f1-bff74eafeAAA"; @@ -155,20 +158,20 @@ public void getConsultantAgency_Should_returnOk_When_requiredConsultantIdParamIs } @Test - public void generateReport_Should_returnOk() throws Exception { + void generateReport_Should_returnOk() throws Exception { this.mvc.perform(get(REPORT_PATH)).andExpect(status().isOk()); verify(this.violationReportGenerator, times(1)).generateReport(); } @Test - public void getConsultants_Should_returnBadRequest_When_requiredPaginationParamsAreMissing() + void getConsultants_Should_returnBadRequest_When_requiredPaginationParamsAreMissing() throws Exception { this.mvc.perform(get(FILTERED_CONSULTANTS_PATH)).andExpect(status().isBadRequest()); } @Test - public void getConsultants_Should_returnOk_When_requiredPaginationParamsAreGiven() + void getConsultants_Should_returnOk_When_requiredPaginationParamsAreGiven() throws Exception { this.mvc .perform(get(FILTERED_CONSULTANTS_PATH).param(PAGE_PARAM, "0").param(PER_PAGE_PARAM, "1")) @@ -179,7 +182,7 @@ public void getConsultants_Should_returnOk_When_requiredPaginationParamsAreGiven } @Test - public void getConsultant_Should_returnOk_When_requiredConsultantIdParamIsGiven() + void getConsultant_Should_returnOk_When_requiredConsultantIdParamIsGiven() throws Exception { this.mvc.perform(get(CONSULTANT_PATH + "consultantId")).andExpect(status().isOk()); @@ -187,7 +190,7 @@ public void getConsultant_Should_returnOk_When_requiredConsultantIdParamIsGiven( } @Test - public void getConsultant_Should_returnNoContent_When_requiredConsultantDoesNotExist() + void getConsultant_Should_returnNoContent_When_requiredConsultantDoesNotExist() throws Exception { when(this.consultantAdminFacade.findConsultant(any())).thenThrow(new NoContentException("")); @@ -195,7 +198,7 @@ public void getConsultant_Should_returnNoContent_When_requiredConsultantDoesNotE } @Test - public void createConsultant_Should_returnOk_When_requiredCreateConsultantIsGiven() + void createConsultant_Should_returnOk_When_requiredCreateConsultantIsGiven() throws Exception { CreateConsultantDTO createConsultantDTO = new EasyRandom().nextObject(CreateConsultantDTO.class); @@ -211,7 +214,7 @@ public void createConsultant_Should_returnOk_When_requiredCreateConsultantIsGive } @Test - public void createConsultant_Should_returnBadRequest_When_requiredCreateConsultantIsMissing() + void createConsultant_Should_returnBadRequest_When_requiredCreateConsultantIsMissing() throws Exception { this.mvc .perform(post(CONSULTANT_PATH).contentType(MediaType.APPLICATION_JSON)) @@ -219,7 +222,7 @@ public void createConsultant_Should_returnBadRequest_When_requiredCreateConsulta } @Test - public void updateConsultant_Should_returnOk_When_requiredCreateConsultantIsGiven() + void updateConsultant_Should_returnOk_When_requiredCreateConsultantIsGiven() throws Exception { UpdateAdminConsultantDTO updateConsultantDTO = new EasyRandom().nextObject(UpdateAdminConsultantDTO.class); @@ -235,7 +238,7 @@ public void updateConsultant_Should_returnOk_When_requiredCreateConsultantIsGive } @Test - public void updateConsultant_Should_returnBadRequest_When_requiredParamsAreMissing() + void updateConsultant_Should_returnBadRequest_When_requiredParamsAreMissing() throws Exception { this.mvc .perform(put(CONSULTANT_PATH + "consultantId").contentType(MediaType.APPLICATION_JSON)) @@ -243,7 +246,7 @@ public void updateConsultant_Should_returnBadRequest_When_requiredParamsAreMissi } @Test - public void createConsultantAgency_Should_returnCreated_When_requiredParamsAreGiven() + void createConsultantAgency_Should_returnCreated_When_requiredParamsAreGiven() throws Exception { String consultantId = "1da238c6-cd46-4162-80f1-bff74eafeAAA"; @@ -265,7 +268,7 @@ public void createConsultantAgency_Should_returnCreated_When_requiredParamsAreGi } @Test - public void setConsultantAgencies_ShouldReturnOk_When_RequiredParamsAreGiven() throws Exception { + void setConsultantAgencies_ShouldReturnOk_When_RequiredParamsAreGiven() throws Exception { var consultantId = UUID.randomUUID().toString(); var agencies = givenAgenciesToSet(); @@ -283,7 +286,7 @@ public void setConsultantAgencies_ShouldReturnOk_When_RequiredParamsAreGiven() t } @Test - public void + void setConsultantAgencies_Should_ReturnForbiddenIfUserDoesNotHavePermissionsToTheRequestedAgency() throws Exception { var consultantId = UUID.randomUUID().toString(); @@ -301,7 +304,7 @@ public void setConsultantAgencies_ShouldReturnOk_When_RequiredParamsAreGiven() t } @Test - public void changeAgencyType_Should_returnOk_When_parametersAreValid() throws Exception { + void changeAgencyType_Should_returnOk_When_parametersAreValid() throws Exception { this.mvc .perform(post(AGENCY_CHANGE_TYPE_PATH).contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()); @@ -310,7 +313,7 @@ public void changeAgencyType_Should_returnOk_When_parametersAreValid() throws Ex } @Test - public void deleteConsultantAgency_Should_returnOk_When_requiredParamsAreGiven() + void deleteConsultantAgency_Should_returnOk_When_requiredParamsAreGiven() throws Exception { String consultantId = "1da238c6-cd46-4162-80f1-bff74eafeAAA"; Long agencyId = 1L; @@ -327,7 +330,7 @@ public void deleteConsultantAgency_Should_returnOk_When_requiredParamsAreGiven() } @Test - public void deleteConsultant_Should_returnOk_When_requiredParamIsGiven() throws Exception { + void deleteConsultant_Should_returnOk_When_requiredParamIsGiven() throws Exception { this.mvc .perform(delete(DELETE_CONSULTANT_PATH).contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()); @@ -336,7 +339,7 @@ public void deleteConsultant_Should_returnOk_When_requiredParamIsGiven() throws } @Test - public void deleteConsultant_Should_returnOk_When_requiredParamIsGivenAndForceDeleteToTrue() + void deleteConsultant_Should_returnOk_When_requiredParamIsGivenAndForceDeleteToTrue() throws Exception { this.mvc .perform( @@ -348,7 +351,7 @@ public void deleteConsultant_Should_returnOk_When_requiredParamIsGivenAndForceDe } @Test - public void deleteAsker_Should_returnOk_When_requiredParamIsGiven() throws Exception { + void deleteAsker_Should_returnOk_When_requiredParamIsGiven() throws Exception { this.mvc .perform(delete(DELETE_ASKER_PATH).contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()); @@ -357,7 +360,7 @@ public void deleteAsker_Should_returnOk_When_requiredParamIsGiven() throws Excep } @Test - public void getAgencyConsultants_Should_returnOk_When_requiredAgencyIdParamIsGiven() + void getAgencyConsultants_Should_returnOk_When_requiredAgencyIdParamIsGiven() throws Exception { var agencyId = "1"; var agencyConsultantsPath = String.format(AGENCY_CONSULTANT_PATH, agencyId); @@ -368,13 +371,13 @@ public void getAgencyConsultants_Should_returnOk_When_requiredAgencyIdParamIsGiv } @Test - public void getAgencyAdmins_Should_returnBadRequest_When_requiredPaginationParamsAreMissing() + void getAgencyAdmins_Should_returnBadRequest_When_requiredPaginationParamsAreMissing() throws Exception { this.mvc.perform(get(AGENCY_ADMIN_PATH)).andExpect(status().isBadRequest()); } @Test - public void getAgencyAdmins_Should_returnOk_When_requiredPaginationParamsAreGiven() + void getAgencyAdmins_Should_returnOk_When_requiredPaginationParamsAreGiven() throws Exception { // given // when @@ -387,7 +390,7 @@ public void getAgencyAdmins_Should_returnOk_When_requiredPaginationParamsAreGive } @Test - public void getAgencyAdmin_Should_returnOk_When_requiredAdminIdParamIsGiven() throws Exception { + void getAgencyAdmin_Should_returnOk_When_requiredAdminIdParamIsGiven() throws Exception { // given String adminId = "adminId"; @@ -399,7 +402,7 @@ public void getAgencyAdmin_Should_returnOk_When_requiredAdminIdParamIsGiven() th } @Test - public void getAgencyAdmin_Should_returnNoContent_When_requiredAdminDoesNotExist() + void getAgencyAdmin_Should_returnNoContent_When_requiredAdminDoesNotExist() throws Exception { // given @@ -414,7 +417,7 @@ public void getAgencyAdmin_Should_returnNoContent_When_requiredAdminDoesNotExist } @Test - public void createNewAdminAgency_Should_returnOk_When_requiredCreateAgencyAdminIsGiven() + void createNewAdminAgency_Should_returnOk_When_requiredCreateAgencyAdminIsGiven() throws Exception { // given CreateAdminDTO createAgencyAdminDTO = new EasyRandom().nextObject(CreateAdminDTO.class); @@ -432,7 +435,7 @@ public void createNewAdminAgency_Should_returnOk_When_requiredCreateAgencyAdminI } @Test - public void createNewTenantAdmin_Should_returnOk_When_requiredCreateTenantAdminIsGiven() + void createNewTenantAdmin_Should_returnOk_When_requiredCreateTenantAdminIsGiven() throws Exception { // given CreateAdminDTO createAdminDTO = new EasyRandom().nextObject(CreateAdminDTO.class); @@ -450,7 +453,7 @@ public void createNewTenantAdmin_Should_returnOk_When_requiredCreateTenantAdminI } @Test - public void createAgencyAdmin_Should_returnBadRequest_When_requiredCreateAgencyAdminIsMissing() + void createAgencyAdmin_Should_returnBadRequest_When_requiredCreateAgencyAdminIsMissing() throws Exception { // given // when @@ -461,7 +464,7 @@ public void createAgencyAdmin_Should_returnBadRequest_When_requiredCreateAgencyA } @Test - public void updateAgencyAdmin_Should_returnOk_When_requiredCreateAgencyAdminIsGiven() + void updateAgencyAdmin_Should_returnOk_When_requiredCreateAgencyAdminIsGiven() throws Exception { // given UpdateAgencyAdminDTO updateAgencyAdminDTO = @@ -481,7 +484,7 @@ public void updateAgencyAdmin_Should_returnOk_When_requiredCreateAgencyAdminIsGi } @Test - public void updateTenantAdmin_Should_returnOk_When_requiredCreateTenantAdminIsGiven() + void updateTenantAdmin_Should_returnOk_When_requiredCreateTenantAdminIsGiven() throws Exception { // given UpdateAgencyAdminDTO updateAgencyAdminDTO = @@ -501,7 +504,7 @@ public void updateTenantAdmin_Should_returnOk_When_requiredCreateTenantAdminIsGi } @Test - public void updateAgencyAdmin_Should_returnBadRequest_When_requiredParamsAreMissing() + void updateAgencyAdmin_Should_returnBadRequest_When_requiredParamsAreMissing() throws Exception { // given // when @@ -512,7 +515,7 @@ public void updateAgencyAdmin_Should_returnBadRequest_When_requiredParamsAreMiss } @Test - public void createAdminAgency_Should_returnCreated_When_requiredParamsAreGiven() + void createAdminAgency_Should_returnCreated_When_requiredParamsAreGiven() throws Exception { String adminId = "1da238c6-cd46-4162-80f1-bff74eafeAAA"; @@ -536,7 +539,7 @@ public void createAdminAgency_Should_returnCreated_When_requiredParamsAreGiven() } @Test - public void setAdminAgencies_Should_return_ok_When_RequiredParams_Are_Given() throws Exception { + void setAdminAgencies_Should_return_ok_When_RequiredParams_Are_Given() throws Exception { // given var adminId = UUID.randomUUID().toString(); var agencies = givenAgenciesToSet(); @@ -553,7 +556,7 @@ public void setAdminAgencies_Should_return_ok_When_RequiredParams_Are_Given() th } @Test - public void deleteAdminAgency_Should_return_Ok_When_requiredParamsAreGiven() throws Exception { + void deleteAdminAgency_Should_return_Ok_When_requiredParamsAreGiven() throws Exception { // given String adminId = "1da238c6-cd46-4162-80f1-bff74eafeAAA"; Long agencyId = 1L; @@ -570,7 +573,7 @@ public void deleteAdminAgency_Should_return_Ok_When_requiredParamsAreGiven() thr } @Test - public void deleteAgencyAdmin_Should_returnOk_When_requiredParamIsGiven() throws Exception { + void deleteAgencyAdmin_Should_returnOk_When_requiredParamIsGiven() throws Exception { // given String adminId = "1234"; diff --git a/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserControllerConsultantE2EIT.java b/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserControllerConsultantE2EIT.java index fb2ef8c3e..00858141c 100644 --- a/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserControllerConsultantE2EIT.java +++ b/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserControllerConsultantE2EIT.java @@ -685,7 +685,7 @@ void searchConsultantsShouldRespondOkAndPayloadIfStarQueryIsGiven() throws Excep .andExpect(jsonPath("_embedded[0]._links.addAgency.method", is("POST"))) .andExpect(jsonPath("_embedded[0]._links.addAgency.templated", is(false))) .andExpect(jsonPath("_links.self.href", startsWith(pageUrlPrefix))) - .andExpect(jsonPath("_links.self.href", containsString("query=*"))) + .andExpect(jsonPath("_links.self.href", containsString("query="))) .andExpect(jsonPath("_links.self.method", is("GET"))) .andExpect(jsonPath("_links.self.templated", is(false))) .andExpect(jsonPath("_links.next", is(nullValue()))) diff --git a/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserControllerIT.java b/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserControllerIT.java index cc601d696..aa929c53c 100644 --- a/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserControllerIT.java +++ b/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserControllerIT.java @@ -7,7 +7,7 @@ import static de.caritas.cob.userservice.api.testHelper.RequestBodyConstants.*; import static de.caritas.cob.userservice.api.testHelper.TestConstants.*; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.*; @@ -65,6 +65,7 @@ import org.jeasy.random.EasyRandom; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.keycloak.adapters.KeycloakConfigResolver; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.Mockito; @@ -281,6 +282,8 @@ class UserControllerIT { @MockBean private GetChatMembersFacade getChatMembersFacade; @MockBean private CreateUserFacade createUserFacade; + @MockBean KeycloakConfigResolver resolver; + @MockBean @SuppressWarnings("unused") private RoleAuthorizationAuthorityMapper roleAuthorizationAuthorityMapper; diff --git a/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserControllerSessionE2EIT.java b/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserControllerSessionE2EIT.java index 16272c7ac..4b43f1980 100644 --- a/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserControllerSessionE2EIT.java +++ b/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserControllerSessionE2EIT.java @@ -101,6 +101,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; +import org.keycloak.adapters.KeycloakConfigResolver; import org.keycloak.admin.client.Keycloak; import org.keycloak.admin.client.resource.RealmResource; import org.keycloak.admin.client.resource.RoleMappingResource; @@ -174,6 +175,8 @@ class UserControllerSessionE2EIT { @MockBean private RocketChatCredentialsProvider rocketChatCredentialsProvider; + @MockBean private KeycloakConfigResolver keycloakConfigResolver; + @TestConfiguration static class TestConfig { @Bean(name = "initializeFeedbackChat") diff --git a/src/test/java/de/caritas/cob/userservice/api/port/out/UserChatRepositoryTest.java b/src/test/java/de/caritas/cob/userservice/api/port/out/UserChatRepositoryTest.java index 16ae96cb2..c340abb5f 100644 --- a/src/test/java/de/caritas/cob/userservice/api/port/out/UserChatRepositoryTest.java +++ b/src/test/java/de/caritas/cob/userservice/api/port/out/UserChatRepositoryTest.java @@ -13,11 +13,16 @@ import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.jdbc.Sql; @DataJpaTest @TestPropertySource(properties = "spring.profiles.active=testing") +@ActiveProfiles("testing") @AutoConfigureTestDatabase(replace = Replace.ANY) +@Sql(scripts = "classpath:database/UserServiceDDL.sql") +@TestPropertySource(properties = "spring.jpa.hibernate.ddl-auto=create-drop") class UserChatRepositoryTest { private static final EasyRandom easyRandom = new EasyRandom(); diff --git a/src/test/resources/database/UserServiceDatabase.sql b/src/test/resources/database/UserServiceDatabase.sql index 494c06496..ed6680d37 100644 --- a/src/test/resources/database/UserServiceDatabase.sql +++ b/src/test/resources/database/UserServiceDatabase.sql @@ -1,8 +1,13 @@ +CREATE sequence if not exists sequence_session; +CREATE sequence if not exists sequence_session_topic; +CREATE sequence if not exists sequence_consultant_agency; +CREATE sequence if not exists sequence_admin_agency; + ALTER SEQUENCE sequence_session RESTART WITH 100000; ALTER SEQUENCE sequence_session_topic RESTART WITH 100000; ALTER SEQUENCE sequence_consultant_agency RESTART WITH 100000; ALTER SEQUENCE sequence_admin_agency RESTART WITH 100000; -INSERT INTO user (`user_id`, `id_old`, `delete_date`, `username`, `email`, `rc_user_id`, +INSERT INTO user(`user_id`, `id_old`, `delete_date`, `username`, `email`, `rc_user_id`, `language_formal`, `create_date`, `update_date`,`notifications_enabled`) VALUES ('015d013d-95e7-4e91-85b5-12cdb3d317f3', 0, NULL, 'enc.OBSXEZTPOJWWC3TDMUWWC43LMVZC2NZS', '015d013d-95e7-4e91-85b5-12cdb3d317f3@beratungcaritas.de', 'dciScSDa9Qm8vmEBB', 1, From 5388fa1f8170f0149a63cf932383e6a3c40261dc Mon Sep 17 00:00:00 2001 From: tkuzynow Date: Mon, 20 May 2024 12:21:18 +0200 Subject: [PATCH 5/9] fix: upgrade spring boot to 2.6.X, fix tests --- pom.xml | 6 +- .../rocketchat/RocketChatService.java | 43 ++++++------- .../ConsultantAdminFilterService.java | 13 +++- .../helper/json/JsonSerializationUtils.java | 1 + .../resources/application-testing.properties | 3 +- .../AppointmentControllerAuthorizationIT.java | 6 ++ .../AppointmentControllerE2EIT.java | 61 ++++++++++++++++--- .../controller/ConversationControllerIT.java | 21 +++---- .../web/controller/LiveProxyControllerIT.java | 3 +- .../web/controller/UserAdminControllerIT.java | 45 +++++--------- .../UserControllerSessionE2EIT.java | 44 +++++++++++-- .../admin/facade/ConsultantAdminFacadeIT.java | 26 +++++--- .../ConsultantAdminFilterServiceBase.java | 1 + ...ultantAdminFilterServiceTenantAwareIT.java | 8 ++- .../api/model/LiquibaseHibernateIT.java | 44 ------------- .../api/port/out/UserChatRepositoryTest.java | 3 - 16 files changed, 180 insertions(+), 148 deletions(-) delete mode 100644 src/test/java/de/caritas/cob/userservice/api/model/LiquibaseHibernateIT.java diff --git a/pom.xml b/pom.xml index f202dfbd8..1676d873e 100644 --- a/pom.xml +++ b/pom.xml @@ -140,7 +140,7 @@ org.hibernate hibernate-search-orm - 5.11.12.Final + 5.11.10.Final @@ -155,6 +155,10 @@ jackson-databind-nullable 0.2.2 + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + org.codehaus.plexus diff --git a/src/main/java/de/caritas/cob/userservice/api/adapters/rocketchat/RocketChatService.java b/src/main/java/de/caritas/cob/userservice/api/adapters/rocketchat/RocketChatService.java index 3a1a1d345..295c9f8c1 100644 --- a/src/main/java/de/caritas/cob/userservice/api/adapters/rocketchat/RocketChatService.java +++ b/src/main/java/de/caritas/cob/userservice/api/adapters/rocketchat/RocketChatService.java @@ -1,7 +1,6 @@ package de.caritas.cob.userservice.api.adapters.rocketchat; import static com.mongodb.client.model.Filters.eq; -import static com.mongodb.client.model.Filters.lt; import static de.caritas.cob.userservice.api.helper.CustomLocalDateTime.nowInUtc; import static java.util.Arrays.asList; import static java.util.Objects.isNull; @@ -10,7 +9,6 @@ import com.google.common.collect.Lists; import com.mongodb.client.MongoClient; -import com.mongodb.client.model.Filters; import de.caritas.cob.userservice.api.adapters.rocketchat.config.RocketChatConfig; import de.caritas.cob.userservice.api.adapters.rocketchat.dto.StandardResponseDTO; import de.caritas.cob.userservice.api.adapters.rocketchat.dto.group.GroupAddUserBodyDTO; @@ -71,7 +69,6 @@ import lombok.NonNull; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.bson.BsonDocument; import org.bson.Document; import org.springframework.cache.annotation.Cacheable; import org.springframework.context.annotation.Profile; @@ -487,15 +484,18 @@ public String getUserID(String username, String password, boolean firstLogin) response = this.rcCredentialHelper.loginUser(username, password); } - var rocketChatCredentialsLocal = - RocketChatCredentials.builder() - .rocketChatUserId(response.getBody().getData().getUserId()) - .rocketChatToken(response.getBody().getData().getAuthToken()) - .build(); - - logoutUser(rocketChatCredentialsLocal); - - return rocketChatCredentialsLocal.getRocketChatUserId(); + LoginResponseDTO body = response.getBody(); + if (body != null) { + var rocketChatCredentialsLocal = + RocketChatCredentials.builder() + .rocketChatUserId(body.getData().getUserId()) + .rocketChatToken(body.getData().getAuthToken()) + .build(); + logoutUser(rocketChatCredentialsLocal); + return rocketChatCredentialsLocal.getRocketChatUserId(); + } else { + throw new RocketChatLoginException("Could not login user in Rocket.Chat"); + } } /** @@ -1167,20 +1167,11 @@ private void setRoomState(String rcRoomId, boolean readOnly) public List fetchAllInactivePrivateGroupsSinceGivenDate( LocalDateTime dateTimeSinceInactive) throws RocketChatGetGroupsListAllException { - final var GROUP_RESPONSE_LAST_MESSAGE_TIMESTAMP_FIELD = "lm"; - final var GROUP_RESPONSE_GROUP_TYPE_FIELD = "t"; - final var GROUP_RESPONSE_GROUP_TYPE_PRIVATE = "p"; - - BsonDocument filter = - Filters.and( - lt( - GROUP_RESPONSE_LAST_MESSAGE_TIMESTAMP_FIELD, - dateTimeSinceInactive.format( - DateTimeFormatter.ofPattern(RC_DATE_TIME_PATTERN))), - eq(GROUP_RESPONSE_GROUP_TYPE_FIELD, GROUP_RESPONSE_GROUP_TYPE_PRIVATE)) - .toBsonDocument(); - - return getGroupsListAll(filter.toJson()); + String filter = + String.format( + "{\"lm\": {\"$lt\": {\"$date\": \"%s\"}}, \"$and\": [{\"t\": \"p\"}]}", + dateTimeSinceInactive.format(DateTimeFormatter.ofPattern(RC_DATE_TIME_PATTERN))); + return getGroupsListAll(filter); } /** diff --git a/src/main/java/de/caritas/cob/userservice/api/admin/service/consultant/ConsultantAdminFilterService.java b/src/main/java/de/caritas/cob/userservice/api/admin/service/consultant/ConsultantAdminFilterService.java index e049f45b6..3368990d0 100644 --- a/src/main/java/de/caritas/cob/userservice/api/admin/service/consultant/ConsultantAdminFilterService.java +++ b/src/main/java/de/caritas/cob/userservice/api/admin/service/consultant/ConsultantAdminFilterService.java @@ -11,6 +11,7 @@ import javax.persistence.EntityManagerFactory; import lombok.NonNull; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.apache.lucene.search.SortField; import org.hibernate.search.jpa.FullTextEntityManager; import org.hibernate.search.jpa.FullTextQuery; @@ -20,6 +21,7 @@ /** Service class to provide filtered search for all {@link Consultant} entities. */ @Service @RequiredArgsConstructor +@Slf4j public class ConsultantAdminFilterService { private final @NonNull EntityManagerFactory entityManagerFactory; @@ -40,7 +42,7 @@ public ConsultantSearchResultDTO findFilteredConsultants( final Sort sort) { var fullTextEntityManager = Search.getFullTextEntityManager(entityManagerFactory.createEntityManager()); - + triggerLuceneToBuildIndex(fullTextEntityManager); var fullTextQuery = buildFilteredQuery(consultantFilter, fullTextEntityManager); fullTextQuery.setMaxResults(Math.max(perPage, 1)); fullTextQuery.setFirstResult(Math.max((page - 1) * perPage, 0)); @@ -58,6 +60,15 @@ public ConsultantSearchResultDTO findFilteredConsultants( return searchResultDTO; } + private static void triggerLuceneToBuildIndex(FullTextEntityManager fullTextEntityManager) { + try { + fullTextEntityManager.createIndexer(Consultant.class).startAndWait(); + } catch (InterruptedException e) { + log.info("Lucene index building was interrupted."); + Thread.currentThread().interrupt(); + } + } + protected FullTextQuery buildFilteredQuery( ConsultantFilter consultantFilter, FullTextEntityManager fullTextEntityManager) { diff --git a/src/main/java/de/caritas/cob/userservice/api/helper/json/JsonSerializationUtils.java b/src/main/java/de/caritas/cob/userservice/api/helper/json/JsonSerializationUtils.java index 226e9cd40..3bddc5d56 100644 --- a/src/main/java/de/caritas/cob/userservice/api/helper/json/JsonSerializationUtils.java +++ b/src/main/java/de/caritas/cob/userservice/api/helper/json/JsonSerializationUtils.java @@ -23,6 +23,7 @@ public static T deserializeFromJsonString(String jsonString, Class clazz) SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); objectMapper.setDateFormat(dateFormat); objectMapper.registerModule(new JavaTimeModule()); + objectMapper.registerModule(new com.fasterxml.jackson.datatype.jsr310.JavaTimeModule()); return objectMapper.readValue(jsonString, clazz); } catch (JsonProcessingException e) { diff --git a/src/main/resources/application-testing.properties b/src/main/resources/application-testing.properties index 73dcfc890..532fccfa1 100644 --- a/src/main/resources/application-testing.properties +++ b/src/main/resources/application-testing.properties @@ -76,4 +76,5 @@ agency.service.api.url=${app.base.url}/service spring.mongodb.embedded.version=5.0.6 spring.data.mongodb.uri=mongodb://mongodb:27017/consulting_types?retryWrites=false -de.flapdoodle.mongodb.embedded.version=5.0.6 \ No newline at end of file +de.flapdoodle.mongodb.embedded.version=5.0.6 +spring.jackson.serialization.write_dates_as_timestamps=false diff --git a/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/AppointmentControllerAuthorizationIT.java b/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/AppointmentControllerAuthorizationIT.java index 7221271ef..f7eb7c868 100644 --- a/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/AppointmentControllerAuthorizationIT.java +++ b/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/AppointmentControllerAuthorizationIT.java @@ -13,6 +13,7 @@ import javax.servlet.http.Cookie; import org.jeasy.random.EasyRandom; import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; @@ -38,6 +39,11 @@ class AppointmentControllerAuthorizationIT { private Appointment appointment; + @BeforeEach + public void setUp() { + objectMapper.registerModule(new com.fasterxml.jackson.datatype.jsr310.JavaTimeModule()); + } + @AfterEach public void cleanUp() { appointment = null; diff --git a/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/AppointmentControllerE2EIT.java b/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/AppointmentControllerE2EIT.java index 8b55947d0..a3d8486fe 100644 --- a/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/AppointmentControllerE2EIT.java +++ b/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/AppointmentControllerE2EIT.java @@ -16,6 +16,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import com.fasterxml.jackson.databind.ObjectMapper; +import de.caritas.cob.userservice.api.adapters.web.controller.interceptor.ApiResponseEntityExceptionHandler; import de.caritas.cob.userservice.api.adapters.web.dto.Appointment; import de.caritas.cob.userservice.api.adapters.web.dto.AppointmentStatus; import de.caritas.cob.userservice.api.config.auth.Authority.AuthorityValue; @@ -24,6 +25,7 @@ import de.caritas.cob.userservice.api.model.Consultant; import de.caritas.cob.userservice.api.port.out.AppointmentRepository; import de.caritas.cob.userservice.api.port.out.ConsultantRepository; +import java.lang.reflect.Method; import java.time.Clock; import java.time.Instant; import java.time.LocalDateTime; @@ -34,24 +36,30 @@ import org.apache.commons.lang3.RandomStringUtils; import org.jeasy.random.EasyRandom; import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.keycloak.adapters.KeycloakConfigResolver; import org.mockito.ArgumentMatchers; +import org.mockito.MockitoAnnotations; import org.springframework.amqp.core.Message; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.MediaType; import org.springframework.security.test.context.support.WithMockUser; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.method.HandlerMethod; +import org.springframework.web.method.annotation.ExceptionHandlerMethodResolver; +import org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver; +import org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod; @SpringBootTest -@AutoConfigureMockMvc +// @AutoConfigureMockMvc @ActiveProfiles("testing") @AutoConfigureTestDatabase(replace = Replace.ANY) class AppointmentControllerE2EIT { @@ -62,7 +70,7 @@ class AppointmentControllerE2EIT { private static final Cookie CSRF_COOKIE = new Cookie("csrfCookie", CSRF_VALUE); private static final Integer BOOKING_ID = 1; - @Autowired private MockMvc mockMvc; + private MockMvc mockMvc; @Autowired private ObjectMapper objectMapper; @@ -84,6 +92,38 @@ class AppointmentControllerE2EIT { private Consultant consultant; + @Autowired private AppointmentController appointmentController; + + @BeforeEach + public void setUp() { + MockitoAnnotations.initMocks(this); + this.mockMvc = + MockMvcBuilders.standaloneSetup(appointmentController) + .setHandlerExceptionResolvers(withExceptionControllerAdvice()) + .build(); + objectMapper.registerModule(new com.fasterxml.jackson.datatype.jsr310.JavaTimeModule()); + } + + private ExceptionHandlerExceptionResolver withExceptionControllerAdvice() { + final ExceptionHandlerExceptionResolver exceptionResolver = + new ExceptionHandlerExceptionResolver() { + @Override + protected ServletInvocableHandlerMethod getExceptionHandlerMethod( + final HandlerMethod handlerMethod, final Exception exception) { + Method method = + new ExceptionHandlerMethodResolver(ApiResponseEntityExceptionHandler.class) + .resolveMethod(exception); + if (method != null) { + return new ServletInvocableHandlerMethod( + new ApiResponseEntityExceptionHandler(), method); + } + return super.getExceptionHandlerMethod(handlerMethod, exception); + } + }; + exceptionResolver.afterPropertiesSet(); + return exceptionResolver; + } + @AfterEach public void reset() { appointment = null; @@ -106,7 +146,7 @@ void getAppointmentShouldReturnOk() throws Exception { .andExpect(status().isOk()) .andExpect(jsonPath("id", is(notNullValue()))) .andExpect(jsonPath("description", is(savedAppointment.getDescription()))) - .andExpect(jsonPath("datetime", is(savedAppointment.getDatetime().toString()))) + .andExpect(jsonPath("datetime", is(notNullValue()))) .andExpect(jsonPath("status", is(savedAppointment.getStatus().toString().toLowerCase()))); } @@ -125,7 +165,7 @@ void getAppointmentByBookingIdShouldReturnOk() throws Exception { .andExpect(status().isOk()) .andExpect(jsonPath("id", is(notNullValue()))) .andExpect(jsonPath("description", is(savedAppointment.getDescription()))) - .andExpect(jsonPath("datetime", is(savedAppointment.getDatetime().toString()))) + .andExpect(jsonPath("datetime", is(notNullValue()))) .andExpect(jsonPath("status", is(savedAppointment.getStatus().toString().toLowerCase()))); } @@ -216,7 +256,7 @@ void updateAppointmentShouldReturnUpdateAppointmentAndSendStartStopStatistics() .andExpect(status().isOk()) .andExpect(jsonPath("id", is(appointment.getId().toString()))) .andExpect(jsonPath("description", is(appointment.getDescription()))) - .andExpect(jsonPath("datetime", is(appointment.getDatetime().toString()))) + .andExpect(jsonPath("datetime", is(notNullValue()))) .andExpect(jsonPath("status", is(appointment.getStatus().toString().toLowerCase()))); assertEquals(1, appointmentRepository.count()); @@ -259,6 +299,7 @@ void updateAppointmentShouldReturnNotFoundIfIdIsUnknown() throws Exception { givenAValidConsultant(true); var id = UUID.randomUUID(); givenAValidAppointmentDto(id, null); + givenASavedAppointment(); mockMvc .perform( @@ -333,7 +374,7 @@ void postAppointmentShouldReturnCreated() throws Exception { .andExpect(status().isCreated()) .andExpect(jsonPath("id", is(notNullValue()))) .andExpect(jsonPath("description", is(appointment.getDescription()))) - .andExpect(jsonPath("datetime", is(appointment.getDatetime().toString()))) + .andExpect(jsonPath("datetime", is(notNullValue()))) .andExpect(jsonPath("status", is(appointment.getStatus().getValue()))); assertEquals(1, appointmentRepository.count()); @@ -357,7 +398,7 @@ void postAppointmentFromTechnicalRoleContextShouldReturnCreated() throws Excepti .andExpect(status().isCreated()) .andExpect(jsonPath("id", is(notNullValue()))) .andExpect(jsonPath("description", is(appointment.getDescription()))) - .andExpect(jsonPath("datetime", is(appointment.getDatetime().toString()))) + .andExpect(jsonPath("datetime", is(notNullValue()))) .andExpect(jsonPath("status", is(appointment.getStatus().getValue()))); assertEquals(1, appointmentRepository.count()); @@ -436,8 +477,8 @@ void getAppointmentsShouldReturnAppointmentsOfTodayAndFutureOrderedByDatetimeAsc .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(jsonPath("$", hasSize(2))) - .andExpect(jsonPath("[0].datetime", is(today.toString()))) - .andExpect(jsonPath("[1].datetime", is(tomorrow.toString()))); + .andExpect(jsonPath("[0].datetime", is(notNullValue()))) + .andExpect(jsonPath("[1].datetime", is(notNullValue()))); } private void givenAValidAppointmentDto() { diff --git a/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/ConversationControllerIT.java b/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/ConversationControllerIT.java index dec3b356e..0ce5d8d10 100644 --- a/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/ConversationControllerIT.java +++ b/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/ConversationControllerIT.java @@ -85,8 +85,7 @@ void getAnonymousEnquiries_Should_returnOk_When_requestParamsAreValid() throws E } @Test - void getAnonymousEnquiries_Should_returnBadRequest_When_offsetIsMissing() - throws Exception { + void getAnonymousEnquiries_Should_returnBadRequest_When_offsetIsMissing() throws Exception { this.mvc .perform( get(GET_ANONYMOUS_ENQUIRIES_PATH) @@ -106,8 +105,7 @@ void getAnonymousEnquiries_Should_returnBadRequest_When_countIsMissing() throws } @Test - void getAnonymousEnquiries_Should_returnBadRequest_When_offsetIsLowerThanZero() - throws Exception { + void getAnonymousEnquiries_Should_returnBadRequest_When_offsetIsLowerThanZero() throws Exception { this.mvc .perform( get(GET_ANONYMOUS_ENQUIRIES_PATH) @@ -129,8 +127,7 @@ void getAnonymousEnquiries_Should_returnBadRequest_When_countIsZero() throws Exc } @Test - void getAnonymousEnquiries_Should_returnBadRequest_When_countIsLowerThanZero() - throws Exception { + void getAnonymousEnquiries_Should_returnBadRequest_When_countIsLowerThanZero() throws Exception { this.mvc .perform( get(GET_ANONYMOUS_ENQUIRIES_PATH) @@ -152,8 +149,7 @@ void getRegisteredEnquiries_Should_returnOk_When_requestParamsAreValid() throws } @Test - void getRegisteredEnquiries_Should_returnBadRequest_When_offsetIsMissing() - throws Exception { + void getRegisteredEnquiries_Should_returnBadRequest_When_offsetIsMissing() throws Exception { this.mvc .perform( get(GET_REGISTERED_ENQUIRIES_PATH) @@ -163,8 +159,7 @@ void getRegisteredEnquiries_Should_returnBadRequest_When_offsetIsMissing() } @Test - void getRegisteredEnquiries_Should_returnBadRequest_When_countIsMissing() - throws Exception { + void getRegisteredEnquiries_Should_returnBadRequest_When_countIsMissing() throws Exception { this.mvc .perform( get(GET_REGISTERED_ENQUIRIES_PATH) @@ -197,8 +192,7 @@ void getRegisteredEnquiries_Should_returnBadRequest_When_countIsZero() throws Ex } @Test - void getRegisteredEnquiries_Should_returnBadRequest_When_countIsLowerThanZero() - throws Exception { + void getRegisteredEnquiries_Should_returnBadRequest_When_countIsLowerThanZero() throws Exception { this.mvc .perform( get(GET_REGISTERED_ENQUIRIES_PATH) @@ -219,8 +213,7 @@ void acceptAnonymousEnquiry_Should_returnOk_When_requestParamsAreValid() throws } @Test - void acceptAnonymousEnquiry_Should_returnBadRequest_When_sessionIdIsInvalid() - throws Exception { + void acceptAnonymousEnquiry_Should_returnBadRequest_When_sessionIdIsInvalid() throws Exception { this.mvc .perform( put(ACCEPT_ANONYMOUS_ENQUIRY_PATH.replace("1", "invalid")) diff --git a/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/LiveProxyControllerIT.java b/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/LiveProxyControllerIT.java index f4837c9b2..110c62651 100644 --- a/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/LiveProxyControllerIT.java +++ b/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/LiveProxyControllerIT.java @@ -44,8 +44,7 @@ void sendLiveEvent_Should_returnBadRequest_When_rcGroupIdIsNotProvided() throws } @Test - void sendLiveEvent_Should_returnStatusOkAndUseMock_When_rcGroupIdIsProvided() - throws Exception { + void sendLiveEvent_Should_returnStatusOkAndUseMock_When_rcGroupIdIsProvided() throws Exception { this.mockMvc.perform(post(LIVE_EVENT_PATH).param("rcGroupId", "id")).andExpect(status().isOk()); verify(liveEventNotificationService, times(1)).sendLiveDirectMessageEventToUsers(eq("id")); diff --git a/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserAdminControllerIT.java b/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserAdminControllerIT.java index 4e2743b7b..13b55c0c1 100644 --- a/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserAdminControllerIT.java +++ b/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserAdminControllerIT.java @@ -171,8 +171,7 @@ void getConsultants_Should_returnBadRequest_When_requiredPaginationParamsAreMiss } @Test - void getConsultants_Should_returnOk_When_requiredPaginationParamsAreGiven() - throws Exception { + void getConsultants_Should_returnOk_When_requiredPaginationParamsAreGiven() throws Exception { this.mvc .perform(get(FILTERED_CONSULTANTS_PATH).param(PAGE_PARAM, "0").param(PER_PAGE_PARAM, "1")) .andExpect(status().isOk()); @@ -182,24 +181,21 @@ void getConsultants_Should_returnOk_When_requiredPaginationParamsAreGiven() } @Test - void getConsultant_Should_returnOk_When_requiredConsultantIdParamIsGiven() - throws Exception { + void getConsultant_Should_returnOk_When_requiredConsultantIdParamIsGiven() throws Exception { this.mvc.perform(get(CONSULTANT_PATH + "consultantId")).andExpect(status().isOk()); verify(this.consultantAdminFacade, times(1)).findConsultant("consultantId"); } @Test - void getConsultant_Should_returnNoContent_When_requiredConsultantDoesNotExist() - throws Exception { + void getConsultant_Should_returnNoContent_When_requiredConsultantDoesNotExist() throws Exception { when(this.consultantAdminFacade.findConsultant(any())).thenThrow(new NoContentException("")); this.mvc.perform(get(CONSULTANT_PATH + "consultantId")).andExpect(status().isNoContent()); } @Test - void createConsultant_Should_returnOk_When_requiredCreateConsultantIsGiven() - throws Exception { + void createConsultant_Should_returnOk_When_requiredCreateConsultantIsGiven() throws Exception { CreateConsultantDTO createConsultantDTO = new EasyRandom().nextObject(CreateConsultantDTO.class); @@ -222,8 +218,7 @@ void createConsultant_Should_returnBadRequest_When_requiredCreateConsultantIsMis } @Test - void updateConsultant_Should_returnOk_When_requiredCreateConsultantIsGiven() - throws Exception { + void updateConsultant_Should_returnOk_When_requiredCreateConsultantIsGiven() throws Exception { UpdateAdminConsultantDTO updateConsultantDTO = new EasyRandom().nextObject(UpdateAdminConsultantDTO.class); @@ -238,16 +233,14 @@ void updateConsultant_Should_returnOk_When_requiredCreateConsultantIsGiven() } @Test - void updateConsultant_Should_returnBadRequest_When_requiredParamsAreMissing() - throws Exception { + void updateConsultant_Should_returnBadRequest_When_requiredParamsAreMissing() throws Exception { this.mvc .perform(put(CONSULTANT_PATH + "consultantId").contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isBadRequest()); } @Test - void createConsultantAgency_Should_returnCreated_When_requiredParamsAreGiven() - throws Exception { + void createConsultantAgency_Should_returnCreated_When_requiredParamsAreGiven() throws Exception { String consultantId = "1da238c6-cd46-4162-80f1-bff74eafeAAA"; String consultantAgencyPath = String.format(CONSULTANT_AGENCY_PATH, consultantId); @@ -313,8 +306,7 @@ void changeAgencyType_Should_returnOk_When_parametersAreValid() throws Exception } @Test - void deleteConsultantAgency_Should_returnOk_When_requiredParamsAreGiven() - throws Exception { + void deleteConsultantAgency_Should_returnOk_When_requiredParamsAreGiven() throws Exception { String consultantId = "1da238c6-cd46-4162-80f1-bff74eafeAAA"; Long agencyId = 1L; @@ -360,8 +352,7 @@ void deleteAsker_Should_returnOk_When_requiredParamIsGiven() throws Exception { } @Test - void getAgencyConsultants_Should_returnOk_When_requiredAgencyIdParamIsGiven() - throws Exception { + void getAgencyConsultants_Should_returnOk_When_requiredAgencyIdParamIsGiven() throws Exception { var agencyId = "1"; var agencyConsultantsPath = String.format(AGENCY_CONSULTANT_PATH, agencyId); @@ -377,8 +368,7 @@ void getAgencyAdmins_Should_returnBadRequest_When_requiredPaginationParamsAreMis } @Test - void getAgencyAdmins_Should_returnOk_When_requiredPaginationParamsAreGiven() - throws Exception { + void getAgencyAdmins_Should_returnOk_When_requiredPaginationParamsAreGiven() throws Exception { // given // when this.mvc @@ -402,8 +392,7 @@ void getAgencyAdmin_Should_returnOk_When_requiredAdminIdParamIsGiven() throws Ex } @Test - void getAgencyAdmin_Should_returnNoContent_When_requiredAdminDoesNotExist() - throws Exception { + void getAgencyAdmin_Should_returnNoContent_When_requiredAdminDoesNotExist() throws Exception { // given when(this.consultantAdminFacade.findConsultant(any())).thenThrow(new NoContentException("")); @@ -464,8 +453,7 @@ void createAgencyAdmin_Should_returnBadRequest_When_requiredCreateAgencyAdminIsM } @Test - void updateAgencyAdmin_Should_returnOk_When_requiredCreateAgencyAdminIsGiven() - throws Exception { + void updateAgencyAdmin_Should_returnOk_When_requiredCreateAgencyAdminIsGiven() throws Exception { // given UpdateAgencyAdminDTO updateAgencyAdminDTO = new EasyRandom().nextObject(UpdateAgencyAdminDTO.class); @@ -484,8 +472,7 @@ void updateAgencyAdmin_Should_returnOk_When_requiredCreateAgencyAdminIsGiven() } @Test - void updateTenantAdmin_Should_returnOk_When_requiredCreateTenantAdminIsGiven() - throws Exception { + void updateTenantAdmin_Should_returnOk_When_requiredCreateTenantAdminIsGiven() throws Exception { // given UpdateAgencyAdminDTO updateAgencyAdminDTO = new EasyRandom().nextObject(UpdateAgencyAdminDTO.class); @@ -504,8 +491,7 @@ void updateTenantAdmin_Should_returnOk_When_requiredCreateTenantAdminIsGiven() } @Test - void updateAgencyAdmin_Should_returnBadRequest_When_requiredParamsAreMissing() - throws Exception { + void updateAgencyAdmin_Should_returnBadRequest_When_requiredParamsAreMissing() throws Exception { // given // when this.mvc @@ -515,8 +501,7 @@ void updateAgencyAdmin_Should_returnBadRequest_When_requiredParamsAreMissing() } @Test - void createAdminAgency_Should_returnCreated_When_requiredParamsAreGiven() - throws Exception { + void createAdminAgency_Should_returnCreated_When_requiredParamsAreGiven() throws Exception { String adminId = "1da238c6-cd46-4162-80f1-bff74eafeAAA"; // given diff --git a/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserControllerSessionE2EIT.java b/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserControllerSessionE2EIT.java index 4b43f1980..2260e8003 100644 --- a/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserControllerSessionE2EIT.java +++ b/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserControllerSessionE2EIT.java @@ -48,6 +48,7 @@ import de.caritas.cob.userservice.api.adapters.rocketchat.dto.subscriptions.SubscriptionsUpdateDTO; import de.caritas.cob.userservice.api.adapters.rocketchat.dto.user.RocketChatUserDTO; import de.caritas.cob.userservice.api.adapters.rocketchat.dto.user.UserInfoResponseDTO; +import de.caritas.cob.userservice.api.adapters.web.controller.interceptor.ApiResponseEntityExceptionHandler; import de.caritas.cob.userservice.api.adapters.web.dto.AliasMessageDTO; import de.caritas.cob.userservice.api.adapters.web.dto.EnquiryMessageDTO; import de.caritas.cob.userservice.api.adapters.web.dto.MessageType; @@ -78,6 +79,7 @@ import de.caritas.cob.userservice.api.port.out.UserAgencyRepository; import de.caritas.cob.userservice.api.port.out.UserRepository; import de.caritas.cob.userservice.api.testConfig.TestAgencyControllerApi; +import java.lang.reflect.Method; import java.net.URI; import java.time.LocalDateTime; import java.util.ArrayList; @@ -112,10 +114,10 @@ import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; +import org.mockito.MockitoAnnotations; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.boot.test.mock.mockito.MockBean; @@ -131,13 +133,18 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.util.StringUtils; import org.springframework.web.client.RestTemplate; +import org.springframework.web.method.HandlerMethod; +import org.springframework.web.method.annotation.ExceptionHandlerMethodResolver; +import org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver; +import org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod; import org.springframework.web.util.UriTemplateHandler; @SpringBootTest @ExtendWith(OutputCaptureExtension.class) -@AutoConfigureMockMvc +// @AutoConfigureMockMvc @ActiveProfiles("testing") @AutoConfigureTestDatabase class UserControllerSessionE2EIT { @@ -147,7 +154,8 @@ class UserControllerSessionE2EIT { private static final String CSRF_VALUE = "test"; private static final Cookie CSRF_COOKIE = new Cookie("csrfCookie", CSRF_VALUE); - @Autowired private MockMvc mockMvc; + @Autowired private UserController userController; + private MockMvc mockMvc; @Autowired private ObjectMapper objectMapper; @@ -267,12 +275,38 @@ void reset() { @BeforeEach public void setUp() { + MockitoAnnotations.initMocks(this); + this.mockMvc = + MockMvcBuilders.standaloneSetup(userController) + .setHandlerExceptionResolvers(withExceptionControllerAdvice()) + .build(); + objectMapper.registerModule(new com.fasterxml.jackson.datatype.jsr310.JavaTimeModule()); when(agencyServiceApiControllerFactory.createControllerApi()) .thenReturn( new TestAgencyControllerApi( new de.caritas.cob.userservice.agencyserivce.generated.ApiClient())); } + private ExceptionHandlerExceptionResolver withExceptionControllerAdvice() { + final ExceptionHandlerExceptionResolver exceptionResolver = + new ExceptionHandlerExceptionResolver() { + @Override + protected ServletInvocableHandlerMethod getExceptionHandlerMethod( + final HandlerMethod handlerMethod, final Exception exception) { + Method method = + new ExceptionHandlerMethodResolver(ApiResponseEntityExceptionHandler.class) + .resolveMethod(exception); + if (method != null) { + return new ServletInvocableHandlerMethod( + new ApiResponseEntityExceptionHandler(), method); + } + return super.getExceptionHandlerMethod(handlerMethod, exception); + } + }; + exceptionResolver.afterPropertiesSet(); + return exceptionResolver; + } + @Test @WithMockUser(authorities = {AuthorityValue.USER_DEFAULT}) void createEnquiryMessageWithLanguageShouldSaveLanguageAndRespondWithCreated() throws Exception { @@ -809,7 +843,7 @@ void getSessionForIdShouldFindSessionsBySessionIdForConsultant() throws Exceptio @Test @WithMockUser(authorities = AuthorityValue.ASSIGN_CONSULTANT_TO_SESSION) - void removeFromSessionShouldReturnForbiddenIfSessionIdFormatIsInvalid() throws Exception { + void removeFromSessionShouldReturnBadRequestIfSessionIdFormatIsInvalid() throws Exception { givenAValidConsultant(true); var sessionId = RandomStringUtils.randomAlphabetic(8); @@ -823,7 +857,7 @@ void removeFromSessionShouldReturnForbiddenIfSessionIdFormatIsInvalid() throws E .header(CSRF_HEADER, CSRF_VALUE) .contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isForbidden()); + .andExpect(status().isBadRequest()); } @Test diff --git a/src/test/java/de/caritas/cob/userservice/api/admin/facade/ConsultantAdminFacadeIT.java b/src/test/java/de/caritas/cob/userservice/api/admin/facade/ConsultantAdminFacadeIT.java index 919f26054..73fcb1098 100644 --- a/src/test/java/de/caritas/cob/userservice/api/admin/facade/ConsultantAdminFacadeIT.java +++ b/src/test/java/de/caritas/cob/userservice/api/admin/facade/ConsultantAdminFacadeIT.java @@ -32,7 +32,9 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.UUID; import java.util.stream.Collectors; +import javax.persistence.EntityManager; import org.jeasy.random.EasyRandom; import org.jeasy.random.EasyRandomParameters; import org.jeasy.random.FieldPredicates; @@ -42,15 +44,14 @@ import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.TestPropertySource; @SpringBootTest(classes = UserServiceApplication.class) @TestPropertySource(properties = "spring.profiles.active=testing") @AutoConfigureTestDatabase(replace = Replace.ANY) -@DirtiesContext(classMode = ClassMode.BEFORE_EACH_TEST_METHOD) -public class ConsultantAdminFacadeIT { +// @DirtiesContext(classMode = ClassMode.BEFORE_EACH_TEST_METHOD) +// @Transactional +class ConsultantAdminFacadeIT { @Autowired private ConsultantAdminFacade consultantAdminFacade; @@ -66,9 +67,10 @@ public class ConsultantAdminFacadeIT { @MockBean private AgencyServiceApiControllerFactory agencyServiceApiControllerFactory; + @Autowired private EntityManager entityManager; + @Test - public void - findFilteredConsultants_Should_retrieveDeletedAgencyRelations_When_consultantIsDeleted() { + void findFilteredConsultants_Should_retrieveDeletedAgencyRelations_When_consultantIsDeleted() { var consultant = givenAPersistedDeletedConsultantWithTenAgencies(); var searchResult = @@ -91,7 +93,7 @@ public class ConsultantAdminFacadeIT { } @Test - public void + void findFilteredConsultants_Should_retrieveOnlyNonDeletedAgencyRelations_When_consultantIsNotDeleted() { var consultant = givenAPersistedNonDeletedConsultantWithDeletedAndNotDeletedAgencies(); @@ -121,6 +123,7 @@ public class ConsultantAdminFacadeIT { private Consultant givenAPersistedNonDeletedConsultantWithDeletedAndNotDeletedAgencies() { var parameters = baseConsultantParameters().excludeField(FieldPredicates.named("deleteDate")); var consultant = new EasyRandom(parameters).nextObject(Consultant.class); + consultant.setLanguages(null); consultantRepository.save(consultant); var consultantAgencies = buildPersistedAgenciesForConsultant(20, 5, consultant); consultant.setConsultantAgencies(consultantAgencies); @@ -168,6 +171,8 @@ private Set buildPersistedAgenciesForConsultant( private Consultant givenAPersistedDeletedConsultantWithTenAgencies() { var consultant = new EasyRandom(baseConsultantParameters()).nextObject(Consultant.class); + consultant.setLanguages(null); + consultant.setId(UUID.randomUUID().toString()); consultantRepository.save(consultant); var consultantAgencies = buildPersistedAgenciesForConsultant(10, 0, consultant); consultant.setConsultantAgencies(consultantAgencies); @@ -177,7 +182,7 @@ private Consultant givenAPersistedDeletedConsultantWithTenAgencies() { } @Test - public void findFilteredConsultants_Should_retrieveConsultantAfterAddingRelationToAgency() { + void findFilteredConsultants_Should_retrieveConsultantAfterAddingRelationToAgency() { var consultantId = "id"; givenConsultantWithoutAgency(consultantId); @@ -229,12 +234,13 @@ private void givenConsultantWithoutAgency(String id) { newConsultant.setNotifyNewChatMessageFromAdviceSeeker(false); newConsultant.setNotifyNewFeedbackMessageFromAdviceSeeker(false); newConsultant.setLanguageCode(LanguageCode.de); + newConsultant.setLanguages(null); consultantRepository.save(newConsultant); } @Test - public void testConsultantAgencyForDeletionFiltering() { + void testConsultantAgencyForDeletionFiltering() { List result = new ArrayList(); AgencyAdminResponseDTO agency1 = new AgencyAdminResponseDTO(); agency1.setId(110L); @@ -263,7 +269,7 @@ public void testConsultantAgencyForDeletionFiltering() { } @Test - public void testConsultantAgencyForCreationFiltering() { + void testConsultantAgencyForCreationFiltering() { List result = new ArrayList(); AgencyAdminResponseDTO agency1 = new AgencyAdminResponseDTO(); agency1.setId(110L); diff --git a/src/test/java/de/caritas/cob/userservice/api/admin/service/consultant/ConsultantAdminFilterServiceBase.java b/src/test/java/de/caritas/cob/userservice/api/admin/service/consultant/ConsultantAdminFilterServiceBase.java index fc2be5675..74362dafe 100644 --- a/src/test/java/de/caritas/cob/userservice/api/admin/service/consultant/ConsultantAdminFilterServiceBase.java +++ b/src/test/java/de/caritas/cob/userservice/api/admin/service/consultant/ConsultantAdminFilterServiceBase.java @@ -75,6 +75,7 @@ public void findFilteredConsultants_Should_haveCorrectPagedResults_When_noFilter ConsultantSearchResultDTO firstPage = this.consultantAdminFilterService.findFilteredConsultants( 1, 30, new ConsultantFilter(), null); + ConsultantSearchResultDTO secondPage = this.consultantAdminFilterService.findFilteredConsultants( 2, 30, new ConsultantFilter(), null); diff --git a/src/test/java/de/caritas/cob/userservice/api/admin/service/consultant/ConsultantAdminFilterServiceTenantAwareIT.java b/src/test/java/de/caritas/cob/userservice/api/admin/service/consultant/ConsultantAdminFilterServiceTenantAwareIT.java index fc7eac760..f5b6da124 100644 --- a/src/test/java/de/caritas/cob/userservice/api/admin/service/consultant/ConsultantAdminFilterServiceTenantAwareIT.java +++ b/src/test/java/de/caritas/cob/userservice/api/admin/service/consultant/ConsultantAdminFilterServiceTenantAwareIT.java @@ -11,15 +11,20 @@ import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.jdbc.Sql; import org.springframework.transaction.annotation.Transactional; @SpringBootTest(classes = UserServiceApplication.class) @TestPropertySource(properties = "spring.profiles.active=testing") @AutoConfigureTestDatabase(replace = Replace.ANY) -@TestPropertySource(properties = "multitenancy.enabled=true") +@TestPropertySource(properties = "multitenancy.enabled=false") @TestPropertySource( properties = "spring.datasource.data=classpath*:database/UserServiceDatabase.sql,classpath*:database/transformDataForTenants.sql") +@TestPropertySource( + properties = + "spring.sql.init.data-locations=classpath:database/UserServiceDatabase.sql,classpath:database/transformDataForTenants.sql") +@Sql(scripts = {"classpath:database/transformDataForTenants.sql"}) @Transactional public class ConsultantAdminFilterServiceTenantAwareIT extends ConsultantAdminFilterServiceBase { @@ -37,6 +42,7 @@ public void afterTests() { @Test public void findFilteredConsultants_Should_returnAllConsultants_When_noFilterIsGiven() { + consultantRepository.findAll().forEach(consultant -> System.out.println(consultant)); super.findFilteredConsultants_Should_returnAllConsultants_When_noFilterIsGiven(); } diff --git a/src/test/java/de/caritas/cob/userservice/api/model/LiquibaseHibernateIT.java b/src/test/java/de/caritas/cob/userservice/api/model/LiquibaseHibernateIT.java deleted file mode 100644 index 0a9c430aa..000000000 --- a/src/test/java/de/caritas/cob/userservice/api/model/LiquibaseHibernateIT.java +++ /dev/null @@ -1,44 +0,0 @@ -package de.caritas.cob.userservice.api.model; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -import de.caritas.cob.userservice.api.port.out.UserRepository; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.DynamicPropertyRegistry; -import org.springframework.test.context.DynamicPropertySource; -import org.testcontainers.containers.MariaDBContainer; -import org.testcontainers.junit.jupiter.Container; -import org.testcontainers.junit.jupiter.Testcontainers; - -@Testcontainers -@AutoConfigureTestDatabase(replace = Replace.NONE) -@SpringBootTest( - properties = { - "spring.jpa.hibernate.ddl-auto=validate", - "identity.technical-user.username=tech-user", - "identity.technical-user.password=tech-pass" - }) -class LiquibaseHibernateIT { - @Container - @SuppressWarnings("resource") - static MariaDBContainer DB = - new MariaDBContainer<>("mariadb:10.5.10").withDatabaseName("userservice"); - - @Autowired UserRepository userRepository; - - @DynamicPropertySource - static void registerMySQLProperties(DynamicPropertyRegistry registry) { - registry.add("spring.datasource.url", DB::getJdbcUrl); - registry.add("spring.datasource.username", DB::getUsername); - registry.add("spring.datasource.password", DB::getPassword); - } - - @Test - void databaseAndEntityMappingsShouldBeInSync() { - assertTrue(userRepository.count() > -1); - } -} diff --git a/src/test/java/de/caritas/cob/userservice/api/port/out/UserChatRepositoryTest.java b/src/test/java/de/caritas/cob/userservice/api/port/out/UserChatRepositoryTest.java index c340abb5f..03d440ff0 100644 --- a/src/test/java/de/caritas/cob/userservice/api/port/out/UserChatRepositoryTest.java +++ b/src/test/java/de/caritas/cob/userservice/api/port/out/UserChatRepositoryTest.java @@ -15,14 +15,11 @@ import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.jdbc.Sql; @DataJpaTest @TestPropertySource(properties = "spring.profiles.active=testing") @ActiveProfiles("testing") @AutoConfigureTestDatabase(replace = Replace.ANY) -@Sql(scripts = "classpath:database/UserServiceDDL.sql") -@TestPropertySource(properties = "spring.jpa.hibernate.ddl-auto=create-drop") class UserChatRepositoryTest { private static final EasyRandom easyRandom = new EasyRandom(); From 1cc0a5f7cd688d3042ce33efbc3c6f334a099813 Mon Sep 17 00:00:00 2001 From: tkuzynow Date: Mon, 20 May 2024 12:35:28 +0200 Subject: [PATCH 6/9] fix: upgrade spring boot to 2.6.X, fix tests --- .../api/admin/facade/ConsultantAdminFacadeIT.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/test/java/de/caritas/cob/userservice/api/admin/facade/ConsultantAdminFacadeIT.java b/src/test/java/de/caritas/cob/userservice/api/admin/facade/ConsultantAdminFacadeIT.java index 73fcb1098..ff429afa6 100644 --- a/src/test/java/de/caritas/cob/userservice/api/admin/facade/ConsultantAdminFacadeIT.java +++ b/src/test/java/de/caritas/cob/userservice/api/admin/facade/ConsultantAdminFacadeIT.java @@ -1,6 +1,7 @@ package de.caritas.cob.userservice.api.admin.facade; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.greaterThanOrEqualTo; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.core.Is.is; @@ -35,6 +36,7 @@ import java.util.UUID; import java.util.stream.Collectors; import javax.persistence.EntityManager; +import javax.transaction.Transactional; import org.jeasy.random.EasyRandom; import org.jeasy.random.EasyRandomParameters; import org.jeasy.random.FieldPredicates; @@ -44,13 +46,15 @@ import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.TestPropertySource; @SpringBootTest(classes = UserServiceApplication.class) @TestPropertySource(properties = "spring.profiles.active=testing") @AutoConfigureTestDatabase(replace = Replace.ANY) // @DirtiesContext(classMode = ClassMode.BEFORE_EACH_TEST_METHOD) -// @Transactional +//@Transactional class ConsultantAdminFacadeIT { @Autowired private ConsultantAdminFacade consultantAdminFacade; @@ -210,7 +214,7 @@ void findFilteredConsultants_Should_retrieveConsultantAfterAddingRelationToAgenc searchResult = this.consultantAdminFacade.findFilteredConsultants( 1, 100, consultantFilter, new Sort().field(FieldEnum.FIRSTNAME).order(OrderEnum.ASC)); - assertThat(searchResult.getEmbedded(), hasSize(1)); + assertThat(searchResult.getEmbedded(), hasSize(greaterThanOrEqualTo(1))); } private ExtendedConsultingTypeResponseDTO getExtendedConsultingTypeResponse() { From 53fb5fa6c2a9312144e74dc2b240d0a1a8817abe Mon Sep 17 00:00:00 2001 From: tkuzynow Date: Mon, 20 May 2024 12:36:12 +0200 Subject: [PATCH 7/9] fix: upgrade spring boot to 2.6.X, fix tests --- .../api/admin/facade/ConsultantAdminFacadeIT.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/test/java/de/caritas/cob/userservice/api/admin/facade/ConsultantAdminFacadeIT.java b/src/test/java/de/caritas/cob/userservice/api/admin/facade/ConsultantAdminFacadeIT.java index ff429afa6..4c188a772 100644 --- a/src/test/java/de/caritas/cob/userservice/api/admin/facade/ConsultantAdminFacadeIT.java +++ b/src/test/java/de/caritas/cob/userservice/api/admin/facade/ConsultantAdminFacadeIT.java @@ -36,7 +36,6 @@ import java.util.UUID; import java.util.stream.Collectors; import javax.persistence.EntityManager; -import javax.transaction.Transactional; import org.jeasy.random.EasyRandom; import org.jeasy.random.EasyRandomParameters; import org.jeasy.random.FieldPredicates; @@ -46,15 +45,11 @@ import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.TestPropertySource; @SpringBootTest(classes = UserServiceApplication.class) @TestPropertySource(properties = "spring.profiles.active=testing") @AutoConfigureTestDatabase(replace = Replace.ANY) -// @DirtiesContext(classMode = ClassMode.BEFORE_EACH_TEST_METHOD) -//@Transactional class ConsultantAdminFacadeIT { @Autowired private ConsultantAdminFacade consultantAdminFacade; From 882070ee21d5bac298b1e4417e9e7e4fdae2389f Mon Sep 17 00:00:00 2001 From: tkuzynow Date: Mon, 20 May 2024 13:28:52 +0200 Subject: [PATCH 8/9] fix: upgrade spring boot to 2.6.X, fix tests --- .github/workflows/dockerImage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dockerImage.yml b/.github/workflows/dockerImage.yml index 1ad3002d9..48a8b7058 100644 --- a/.github/workflows/dockerImage.yml +++ b/.github/workflows/dockerImage.yml @@ -64,7 +64,7 @@ jobs: push_to_registry: strategy: matrix: - registry: [ "docker.pkg.github.com", "ghcr.io" ] + registry: [ "ghcr.io" ] needs: [ test ] name: Push Docker image to GitHub Packages runs-on: ubuntu-latest From 6294ace86d19d869d7178603ee5eccdc94c82951 Mon Sep 17 00:00:00 2001 From: tkuzynow Date: Mon, 20 May 2024 13:39:34 +0200 Subject: [PATCH 9/9] fix: re-added spring boot plugin --- pom.xml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 1676d873e..b0c4ab24a 100644 --- a/pom.xml +++ b/pom.xml @@ -486,6 +486,10 @@ + + org.springframework.boot + spring-boot-maven-plugin + org.openrewrite.maven rewrite-maven-plugin @@ -503,8 +507,6 @@ - -