diff --git a/README.md b/README.md index 029d479f..3dc7d622 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,11 @@ Before you can run the project, you will need the following applications: docker-compose up -d ``` -4. Go to local database ([localhost:5432](http://localhost:5432)) with the following credentials and execute the SQL command: +4. Go to local database ([localhost:5432](http://localhost:5432)) with the following credentials and execute the SQL + command: - - **Username:** postgres - - **Password:** postgres + - **Username:** postgres + - **Password:** postgres ```sql CREATE SCHEMA IF NOT EXISTS "kodemy-auth"; @@ -39,11 +40,11 @@ Before you can run the project, you will need the following applications: 5. Run individual services in IntelliJ with the following settings for `Active profiles`: - - `KodemyAuthApplication`: `local` - - `KodemyBackendApplication`: `local` - - `KodemyGatewayApplication`: `local` - - ~~`KodemyNotificationApplication`: `local`~~ - - `KodemySearchApplication`: `local` + - `KodemyAuthApplication`: `local` + - `KodemyBackendApplication`: `local` + - `KodemyGatewayApplication`: `local` + - ~~`KodemyNotificationApplication`: `local`~~ + - `KodemySearchApplication`: `local` 6. Once the project is running, you can access the API documentation (OpenAPI v3) for almost all microservices: @@ -54,7 +55,8 @@ Before you can run the project, you will need the following applications: ### RabbitMQ -To access the RabbitMQ management UI, go to [http://localhost:15672](http://localhost:15672) with the following credentials: +To access the RabbitMQ management UI, go to [http://localhost:15672](http://localhost:15672) with the following +credentials: - **Username:** rabbitmq - **Password:** rabbitmq diff --git a/commons/src/main/java/pl/sknikod/kodemycommons/exception/content/ExceptionUtil.java b/commons/src/main/java/pl/sknikod/kodemycommons/exception/content/ExceptionUtil.java index 517bb436..04dad1cd 100644 --- a/commons/src/main/java/pl/sknikod/kodemycommons/exception/content/ExceptionUtil.java +++ b/commons/src/main/java/pl/sknikod/kodemycommons/exception/content/ExceptionUtil.java @@ -12,7 +12,7 @@ public static RuntimeException throwIfFailure(Throwable throwable) { return getRuntimeOrDefault(throwable, new InternalError500Exception()); } - public static RuntimeException throwIfFailure(Throwable throwable, String pattern, Object ...args) { + public static RuntimeException throwIfFailure(Throwable throwable, String pattern, Object... args) { return getRuntimeOrDefault(throwable, new InternalError500Exception(pattern, args)); } } diff --git a/commons/src/main/java/pl/sknikod/kodemycommons/security/AuthFacade.java b/commons/src/main/java/pl/sknikod/kodemycommons/security/AuthFacade.java index e60300e2..fa4e6c7c 100644 --- a/commons/src/main/java/pl/sknikod/kodemycommons/security/AuthFacade.java +++ b/commons/src/main/java/pl/sknikod/kodemycommons/security/AuthFacade.java @@ -10,13 +10,12 @@ import java.security.Principal; import java.util.Arrays; -import java.util.HashSet; import java.util.List; import java.util.Optional; @NoArgsConstructor(access = AccessLevel.PRIVATE) public class AuthFacade { - private static SecurityContext getContext(){ + private static SecurityContext getContext() { return SecurityContextHolder.getContext(); } @@ -60,7 +59,7 @@ public static Authentication setAuthentication(Authentication authentication) { return setAuthentication(authentication, false); } - public static boolean hasAnyAuthority(String... authorities){ + public static boolean hasAnyAuthority(String... authorities) { List authorityList = Arrays.asList(authorities); return getAuthentication() .map(Authentication::getAuthorities) @@ -70,7 +69,7 @@ public static boolean hasAnyAuthority(String... authorities){ .isPresent(); } - public static boolean hasAuthority(String authority){ + public static boolean hasAuthority(String authority) { return hasAnyAuthority(authority); } } \ No newline at end of file diff --git a/config/opensearch-security/config.yml b/config/opensearch-security/config.yml index 03a8de17..cd46078a 100644 --- a/config/opensearch-security/config.yml +++ b/config/opensearch-security/config.yml @@ -75,7 +75,7 @@ config: #internalProxies: '.*' # trust all internal proxies, regex pattern #remoteIpHeader: 'x-forwarded-for' authc: - basic_internal_auth_domain: # <- Settings for Basic authentication + basic_internal_auth_domain: # <- Settings for Basic authentication description: "Authenticate via HTTP Basic against internal users database" http_enabled: true transport_enabled: true diff --git a/config/opensearch.yml b/config/opensearch.yml index 12c9272c..22a64214 100644 --- a/config/opensearch.yml +++ b/config/opensearch.yml @@ -5,7 +5,7 @@ cluster.name: kodemy-os-cluster node.name: kodemy-os-n1 # Comma-separated list of hostnames or IP addresses of nodes in the cluster -discovery.seed_hosts: ["kodemy-os-n1"] +discovery.seed_hosts: [ "kodemy-os-n1" ] # Discovery type for single-node configuration discovery.type: single-node diff --git a/kodemy-api-gateway/src/main/resources/application-local.yml b/kodemy-api-gateway/src/main/resources/application-local.yml index 98c601d8..706061eb 100644 --- a/kodemy-api-gateway/src/main/resources/application-local.yml +++ b/kodemy-api-gateway/src/main/resources/application-local.yml @@ -17,7 +17,7 @@ app: cors: allowed-origins: - ${network.route.front} - + eureka: client: service-url: diff --git a/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/configuration/LogbookConfiguration.java b/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/configuration/LogbookConfiguration.java index 2ea823b0..108eb31b 100644 --- a/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/configuration/LogbookConfiguration.java +++ b/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/configuration/LogbookConfiguration.java @@ -7,7 +7,7 @@ @Configuration public class LogbookConfiguration { @Bean - public Logbook logbook(){ + public Logbook logbook() { return Logbook.create(); } } diff --git a/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/configuration/WebConfiguration.java b/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/configuration/WebConfiguration.java index a7e781d5..7158bca8 100644 --- a/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/configuration/WebConfiguration.java +++ b/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/configuration/WebConfiguration.java @@ -2,21 +2,14 @@ import lombok.Getter; import lombok.NoArgsConstructor; -import lombok.NonNull; import lombok.Setter; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.cloud.client.loadbalancer.LoadBalanced; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.http.converter.FormHttpMessageConverter; import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; -import org.springframework.web.servlet.config.annotation.CorsRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - -import java.util.ArrayList; -import java.util.List; @Configuration @Slf4j diff --git a/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/infrastructure/dao/RefreshTokenDao.java b/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/infrastructure/dao/RefreshTokenDao.java index b5d73eee..e579c923 100644 --- a/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/infrastructure/dao/RefreshTokenDao.java +++ b/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/infrastructure/dao/RefreshTokenDao.java @@ -6,8 +6,8 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import pl.sknikod.kodemyauth.infrastructure.database.RefreshToken; -import pl.sknikod.kodemyauth.infrastructure.database.User; import pl.sknikod.kodemyauth.infrastructure.database.RefreshTokenRepository; +import pl.sknikod.kodemyauth.infrastructure.database.User; import pl.sknikod.kodemyauth.infrastructure.database.UserRepository; import pl.sknikod.kodemycommons.exception.InternalError500Exception; import pl.sknikod.kodemycommons.exception.NotFound404Exception; diff --git a/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/infrastructure/dao/UserDao.java b/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/infrastructure/dao/UserDao.java index edc0100c..d39993ec 100644 --- a/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/infrastructure/dao/UserDao.java +++ b/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/infrastructure/dao/UserDao.java @@ -8,11 +8,7 @@ import org.springframework.data.domain.PageRequest; import org.springframework.stereotype.Component; import pl.sknikod.kodemyauth.configuration.SecurityConfiguration; -import pl.sknikod.kodemyauth.infrastructure.database.Provider; -import pl.sknikod.kodemyauth.infrastructure.database.Role; -import pl.sknikod.kodemyauth.infrastructure.database.User; -import pl.sknikod.kodemyauth.infrastructure.database.RoleRepository; -import pl.sknikod.kodemyauth.infrastructure.database.UserRepository; +import pl.sknikod.kodemyauth.infrastructure.database.*; import pl.sknikod.kodemyauth.infrastructure.module.oauth2.provider.OAuth2Provider; import pl.sknikod.kodemycommons.exception.InternalError500Exception; import pl.sknikod.kodemycommons.exception.NotFound404Exception; diff --git a/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/infrastructure/database/PermissionRepository.java b/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/infrastructure/database/PermissionRepository.java index 58b29c4e..d438f75f 100644 --- a/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/infrastructure/database/PermissionRepository.java +++ b/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/infrastructure/database/PermissionRepository.java @@ -3,4 +3,4 @@ import org.springframework.data.jpa.repository.JpaRepository; public interface PermissionRepository extends JpaRepository { - } \ No newline at end of file +} \ No newline at end of file diff --git a/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/infrastructure/module/auth/RefreshTokensService.java b/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/infrastructure/module/auth/RefreshTokensService.java index a93070f6..7e0dc1d3 100644 --- a/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/infrastructure/module/auth/RefreshTokensService.java +++ b/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/infrastructure/module/auth/RefreshTokensService.java @@ -8,11 +8,11 @@ import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.stereotype.Component; import pl.sknikod.kodemyauth.configuration.SecurityConfiguration; +import pl.sknikod.kodemyauth.infrastructure.dao.RefreshTokenDao; import pl.sknikod.kodemyauth.infrastructure.database.RefreshToken; import pl.sknikod.kodemyauth.infrastructure.database.Role; import pl.sknikod.kodemyauth.infrastructure.database.RoleRepository; import pl.sknikod.kodemyauth.infrastructure.database.User; -import pl.sknikod.kodemyauth.infrastructure.dao.RefreshTokenDao; import pl.sknikod.kodemyauth.infrastructure.module.auth.model.RefreshTokensResponse; import pl.sknikod.kodemycommons.exception.InternalError500Exception; import pl.sknikod.kodemycommons.security.JwtProvider; diff --git a/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/infrastructure/module/oauth2/OAuth2ProviderService.java b/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/infrastructure/module/oauth2/OAuth2ProviderService.java index 75410da3..9f37ee53 100644 --- a/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/infrastructure/module/oauth2/OAuth2ProviderService.java +++ b/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/infrastructure/module/oauth2/OAuth2ProviderService.java @@ -1,8 +1,6 @@ package pl.sknikod.kodemyauth.infrastructure.module.oauth2; import lombok.RequiredArgsConstructor; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; import pl.sknikod.kodemyauth.infrastructure.module.oauth2.provider.OAuth2Provider; import java.util.List; diff --git a/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/infrastructure/module/oauth2/OAuth2Service.java b/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/infrastructure/module/oauth2/OAuth2Service.java index 5f61e6d3..baecfd97 100644 --- a/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/infrastructure/module/oauth2/OAuth2Service.java +++ b/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/infrastructure/module/oauth2/OAuth2Service.java @@ -11,11 +11,11 @@ import org.springframework.security.oauth2.core.OAuth2AuthenticationException; import org.springframework.security.oauth2.core.user.OAuth2User; import org.springframework.web.client.RestTemplate; +import pl.sknikod.kodemyauth.infrastructure.dao.UserDao; import pl.sknikod.kodemyauth.infrastructure.database.Permission; import pl.sknikod.kodemyauth.infrastructure.database.Role; import pl.sknikod.kodemyauth.infrastructure.database.RoleRepository; import pl.sknikod.kodemyauth.infrastructure.database.User; -import pl.sknikod.kodemyauth.infrastructure.dao.UserDao; import pl.sknikod.kodemyauth.infrastructure.module.oauth2.provider.OAuth2Provider; import pl.sknikod.kodemyauth.infrastructure.module.oauth2.util.OAuth2UserPrincipal; diff --git a/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/infrastructure/module/oauth2/handler/OAuth2LoginSuccessHandler.java b/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/infrastructure/module/oauth2/handler/OAuth2LoginSuccessHandler.java index 2e73b7a5..83244ea0 100644 --- a/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/infrastructure/module/oauth2/handler/OAuth2LoginSuccessHandler.java +++ b/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/infrastructure/module/oauth2/handler/OAuth2LoginSuccessHandler.java @@ -9,8 +9,8 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.security.core.Authentication; import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler; -import pl.sknikod.kodemyauth.infrastructure.database.RefreshToken; import pl.sknikod.kodemyauth.infrastructure.dao.RefreshTokenDao; +import pl.sknikod.kodemyauth.infrastructure.database.RefreshToken; import pl.sknikod.kodemyauth.util.route.RouteRedirectStrategy; import pl.sknikod.kodemycommons.exception.InternalError500Exception; import pl.sknikod.kodemycommons.security.AuthFacade; diff --git a/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/infrastructure/module/user/ChangeUserRoleService.java b/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/infrastructure/module/user/ChangeUserRoleService.java index eb7c2496..fae9fb53 100644 --- a/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/infrastructure/module/user/ChangeUserRoleService.java +++ b/kodemy-auth/src/main/java/pl/sknikod/kodemyauth/infrastructure/module/user/ChangeUserRoleService.java @@ -2,8 +2,8 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; -import pl.sknikod.kodemyauth.infrastructure.database.User; import pl.sknikod.kodemyauth.infrastructure.dao.UserDao; +import pl.sknikod.kodemyauth.infrastructure.database.User; import pl.sknikod.kodemycommons.exception.InternalError500Exception; import pl.sknikod.kodemycommons.exception.content.ExceptionMsgPattern; import pl.sknikod.kodemycommons.exception.content.ExceptionUtil; diff --git a/kodemy-auth/src/main/resources/application-local.yml b/kodemy-auth/src/main/resources/application-local.yml index 5b9ca28c..55195eb7 100644 --- a/kodemy-auth/src/main/resources/application-local.yml +++ b/kodemy-auth/src/main/resources/application-local.yml @@ -30,7 +30,7 @@ app: route: front: http://localhost:3000 gateway: ${network.route.gateway} - + eureka: client: serviceUrl: diff --git a/kodemy-auth/src/main/resources/application.yml b/kodemy-auth/src/main/resources/application.yml index b33d247b..734cb1a8 100644 --- a/kodemy-auth/src/main/resources/application.yml +++ b/kodemy-auth/src/main/resources/application.yml @@ -30,7 +30,7 @@ spring: clientId: Ov23liqWT50Vtt0A0uIg clientSecret: 8d3b1c72e34f2077e433c46f0aea4b980c15226b redirect-uri: ${app.security.oauth2.route.gateway}${app.security.oauth2.endpoints.callback}/github - scope: ['user:email', 'read:user'] + scope: [ 'user:email', 'read:user' ] management: endpoints: diff --git a/kodemy-auth/src/main/resources/db/changelog/0001_create_primary_schema.xml b/kodemy-auth/src/main/resources/db/changelog/0001_create_primary_schema.xml index f42192c0..db994843 100644 --- a/kodemy-auth/src/main/resources/db/changelog/0001_create_primary_schema.xml +++ b/kodemy-auth/src/main/resources/db/changelog/0001_create_primary_schema.xml @@ -27,7 +27,8 @@ - + @@ -84,7 +85,7 @@ (2, 'ROLE_MODERATOR'), (3, 'ROLE_ADMIN'), (4, 'ROLE_SUPERADMIN'); - ]]> + ]]> + ]]> diff --git a/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/configuration/TestSecurityConfig.java b/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/configuration/TestSecurityConfig.java index e7cfd7b3..d93ad279 100644 --- a/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/configuration/TestSecurityConfig.java +++ b/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/configuration/TestSecurityConfig.java @@ -40,7 +40,7 @@ public OAuth2AuthorizationRequestRepository oAuth2SessionAuthRequestRepository() } @Bean - public OAuth2LoginSuccessHandler oAuth2SuccessProcessHandler(){ + public OAuth2LoginSuccessHandler oAuth2SuccessProcessHandler() { return Mockito.mock(OAuth2LoginSuccessHandler.class); } diff --git a/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/factory/OAuth2Factory.java b/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/factory/OAuth2Factory.java index 709b2540..cd00123a 100644 --- a/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/factory/OAuth2Factory.java +++ b/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/factory/OAuth2Factory.java @@ -6,11 +6,11 @@ import java.util.Map; public class OAuth2Factory { - private OAuth2Factory(){ + private OAuth2Factory() { } - public static OAuth2Provider.User oAuth2GithubUser(){ + public static OAuth2Provider.User oAuth2GithubUser() { return new GithubOAuth2Provider.GithubUser(Map.of( "id", 1L, "login", "username", diff --git a/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/factory/ProviderFactory.java b/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/factory/ProviderFactory.java index 2721cc2c..741d28d3 100644 --- a/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/factory/ProviderFactory.java +++ b/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/factory/ProviderFactory.java @@ -3,10 +3,10 @@ import pl.sknikod.kodemyauth.infrastructure.database.Provider; public class ProviderFactory { - private ProviderFactory(){ + private ProviderFactory() { } - public static Provider provider(String providerType){ + public static Provider provider(String providerType) { var provider = new Provider(); provider.setId(1L); provider.setProviderType(providerType); diff --git a/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/factory/RoleFactory.java b/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/factory/RoleFactory.java index 705ccf55..d3d71e72 100644 --- a/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/factory/RoleFactory.java +++ b/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/factory/RoleFactory.java @@ -9,7 +9,7 @@ private RoleFactory() { public static Role roleUser = role("ROLE_USER"); public static Role roleAdmin = role("ROLE_ADMIN"); - public static Role role(String roleName){ + public static Role role(String roleName) { Role role = new Role(); role.setId(1L); role.setName(roleName); diff --git a/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/factory/TokenFactory.java b/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/factory/TokenFactory.java index 39a82519..ec938693 100644 --- a/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/factory/TokenFactory.java +++ b/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/factory/TokenFactory.java @@ -8,7 +8,8 @@ import java.util.UUID; public class TokenFactory { - private TokenFactory() {} + private TokenFactory() { + } public static RefreshToken refreshToken = refreshToken(); public static JwtProvider.Token jwtProviderToken = jwtProviderToken(); diff --git a/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/infrastructure/database/handler/RefreshTokenDaoTest.java b/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/infrastructure/database/handler/RefreshTokenDaoTest.java index b038600e..33603f72 100644 --- a/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/infrastructure/database/handler/RefreshTokenDaoTest.java +++ b/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/infrastructure/database/handler/RefreshTokenDaoTest.java @@ -5,13 +5,13 @@ import org.junit.jupiter.api.Test; import org.mockito.Mock; import org.springframework.dao.OptimisticLockingFailureException; +import pl.sknikod.kodemyauth.BaseTest; import pl.sknikod.kodemyauth.factory.TokenFactory; import pl.sknikod.kodemyauth.factory.UserFactory; +import pl.sknikod.kodemyauth.infrastructure.dao.RefreshTokenDao; import pl.sknikod.kodemyauth.infrastructure.database.RefreshToken; import pl.sknikod.kodemyauth.infrastructure.database.RefreshTokenRepository; import pl.sknikod.kodemyauth.infrastructure.database.UserRepository; -import pl.sknikod.kodemyauth.BaseTest; -import pl.sknikod.kodemyauth.infrastructure.dao.RefreshTokenDao; import pl.sknikod.kodemycommons.exception.InternalError500Exception; import java.util.Optional; diff --git a/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/infrastructure/database/handler/RoleDaoTest.java b/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/infrastructure/database/handler/RoleDaoTest.java index 5d1c9bb3..adb117c6 100644 --- a/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/infrastructure/database/handler/RoleDaoTest.java +++ b/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/infrastructure/database/handler/RoleDaoTest.java @@ -4,11 +4,11 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mock; +import pl.sknikod.kodemyauth.BaseTest; import pl.sknikod.kodemyauth.factory.RoleFactory; +import pl.sknikod.kodemyauth.infrastructure.dao.RoleDao; import pl.sknikod.kodemyauth.infrastructure.database.Role; import pl.sknikod.kodemyauth.infrastructure.database.RoleRepository; -import pl.sknikod.kodemyauth.BaseTest; -import pl.sknikod.kodemyauth.infrastructure.dao.RoleDao; import pl.sknikod.kodemycommons.exception.NotFound404Exception; import java.util.Optional; diff --git a/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/infrastructure/database/handler/UserDaoTest.java b/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/infrastructure/database/handler/UserDaoTest.java index 9d6b0272..7170fec5 100644 --- a/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/infrastructure/database/handler/UserDaoTest.java +++ b/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/infrastructure/database/handler/UserDaoTest.java @@ -8,15 +8,15 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; +import pl.sknikod.kodemyauth.BaseTest; import pl.sknikod.kodemyauth.configuration.SecurityConfiguration; import pl.sknikod.kodemyauth.factory.OAuth2Factory; import pl.sknikod.kodemyauth.factory.RoleFactory; import pl.sknikod.kodemyauth.factory.UserFactory; -import pl.sknikod.kodemyauth.infrastructure.database.User; +import pl.sknikod.kodemyauth.infrastructure.dao.UserDao; import pl.sknikod.kodemyauth.infrastructure.database.RoleRepository; +import pl.sknikod.kodemyauth.infrastructure.database.User; import pl.sknikod.kodemyauth.infrastructure.database.UserRepository; -import pl.sknikod.kodemyauth.BaseTest; -import pl.sknikod.kodemyauth.infrastructure.dao.UserDao; import pl.sknikod.kodemycommons.exception.InternalError500Exception; import pl.sknikod.kodemycommons.exception.NotFound404Exception; diff --git a/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/infrastructure/module/RefreshTokensServiceTest.java b/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/infrastructure/module/RefreshTokensServiceTest.java index 37a1942d..942a3640 100644 --- a/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/infrastructure/module/RefreshTokensServiceTest.java +++ b/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/infrastructure/module/RefreshTokensServiceTest.java @@ -4,17 +4,17 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mockito; +import pl.sknikod.kodemyauth.BaseTest; import pl.sknikod.kodemyauth.configuration.SecurityConfiguration; import pl.sknikod.kodemyauth.factory.TokenFactory; import pl.sknikod.kodemyauth.infrastructure.dao.RefreshTokenDao; -import pl.sknikod.kodemyauth.BaseTest; import pl.sknikod.kodemyauth.infrastructure.database.RoleRepository; import pl.sknikod.kodemyauth.infrastructure.module.auth.RefreshTokensService; import pl.sknikod.kodemycommons.security.JwtProvider; import java.util.UUID; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.*; class RefreshTokensServiceTest extends BaseTest { diff --git a/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/infrastructure/module/oauth2/handler/OAuth2LoginFailureHandlerTest.java b/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/infrastructure/module/oauth2/handler/OAuth2LoginFailureHandlerTest.java index a1e92785..0fddeb9b 100644 --- a/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/infrastructure/module/oauth2/handler/OAuth2LoginFailureHandlerTest.java +++ b/kodemy-auth/src/test/java/pl/sknikod/kodemyauth/infrastructure/module/oauth2/handler/OAuth2LoginFailureHandlerTest.java @@ -14,7 +14,7 @@ import java.util.Map; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.*; class OAuth2LoginFailureHandlerTest extends BaseTest { diff --git a/kodemy-backend/build.gradle b/kodemy-backend/build.gradle index fc84ea2c..b04b3d3f 100644 --- a/kodemy-backend/build.gradle +++ b/kodemy-backend/build.gradle @@ -58,7 +58,7 @@ dependencies { implementation 'io.jsonwebtoken:jjwt-api:0.12.6' implementation 'io.jsonwebtoken:jjwt-impl:0.12.6' implementation 'io.jsonwebtoken:jjwt-jackson:0.12.6' - + implementation("pl.sknikod:commons") implementation 'io.micrometer:micrometer-registry-prometheus' diff --git a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/configuration/LogbookConfiguration.java b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/configuration/LogbookConfiguration.java index 1459fa9b..bda5d6ff 100644 --- a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/configuration/LogbookConfiguration.java +++ b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/configuration/LogbookConfiguration.java @@ -7,7 +7,7 @@ @Configuration public class LogbookConfiguration { @Bean - public Logbook logbook(){ + public Logbook logbook() { return Logbook.create(); } } diff --git a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/configuration/SecurityConfiguration.java b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/configuration/SecurityConfiguration.java index 05f832ff..5ea2845a 100644 --- a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/configuration/SecurityConfiguration.java +++ b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/configuration/SecurityConfiguration.java @@ -63,7 +63,7 @@ public JwtConfiguration.JwtProperties jwtProperties() { } @Bean - public JwtProvider jwtProvider(JwtConfiguration.JwtProperties jwtProperties){ + public JwtProvider jwtProvider(JwtConfiguration.JwtProperties jwtProperties) { return new JwtProvider(jwtProperties); } diff --git a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/common/mapper/GradeMapper.java b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/common/mapper/GradeMapper.java index f17a9909..50b6e70a 100644 --- a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/common/mapper/GradeMapper.java +++ b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/common/mapper/GradeMapper.java @@ -10,7 +10,7 @@ @Mapper(componentModel = MappingConstants.ComponentModel.SPRING) public interface GradeMapper { - default MaterialGradeService.GradePageable map(Grade grade, String username){ + default MaterialGradeService.GradePageable map(Grade grade, String username) { return new MaterialGradeService.GradePageable( grade.getId(), grade.getValue(), diff --git a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/dao/GradeDao.java b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/dao/GradeDao.java index a64f6837..b6331e36 100644 --- a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/dao/GradeDao.java +++ b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/dao/GradeDao.java @@ -45,7 +45,7 @@ public Try> findGradesByMaterialInDateRange( ) { LocalDateTime fromDateTime = minDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); LocalDateTime toDateTime = maxDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); - + return Try.of(() -> gradeRepository.findGradesByMaterialInDateRange( materialId, fromDateTime, toDateTime, diff --git a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/database/GradeRepository.java b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/database/GradeRepository.java index 92b363f1..daa09974 100644 --- a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/database/GradeRepository.java +++ b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/database/GradeRepository.java @@ -14,30 +14,30 @@ @Repository public interface GradeRepository extends JpaRepository { - Date DATE_MIN = Date.from(LocalDateTime.of(2023, 1, 1, 0, 0, 0) - .atZone(ZoneId.systemDefault()).toInstant()); - Date DATE_MAX = Date.from(LocalDateTime.of(9999, 12, 31, 23, 59, 59) - .atZone(ZoneId.systemDefault()).toInstant() - ); + Date DATE_MIN = Date.from(LocalDateTime.of(2023, 1, 1, 0, 0, 0) + .atZone(ZoneId.systemDefault()).toInstant()); + Date DATE_MAX = Date.from(LocalDateTime.of(9999, 12, 31, 23, 59, 59) + .atZone(ZoneId.systemDefault()).toInstant() + ); - List findAllByMaterialId(Long id); + List findAllByMaterialId(Long id); - Long countAllByMaterialIdAndValue(Long id, Double value); + Long countAllByMaterialIdAndValue(Long id, Double value); - @Query("SELECT COALESCE(AVG(g.value), 0.00) FROM Grade g WHERE g.material.id = :materialId") - Double findAvgGradeByMaterialId(Long materialId); + @Query("SELECT COALESCE(AVG(g.value), 0.00) FROM Grade g WHERE g.material.id = :materialId") + Double findAvgGradeByMaterialId(Long materialId); - @Query( - value = "SELECT COALESCE(AVG(g.value), 0.00) FROM Grade g " + - "WHERE g.material.id IN :materialIds GROUP BY g.material.id") - List findAvgGradesByMaterialIdIn(List materialIds); + @Query( + value = "SELECT COALESCE(AVG(g.value), 0.00) FROM Grade g " + + "WHERE g.material.id IN :materialIds GROUP BY g.material.id") + List findAvgGradesByMaterialIdIn(List materialIds); - @Query("SELECT g.material.id, COALESCE(AVG(g.value), 0.00) " + - "FROM Grade g " + - "WHERE g.material.id IN :materialIds " + - "GROUP BY g.material.id") - Set findAverageGradeByMaterialsIds(List materialIds); + @Query("SELECT g.material.id, COALESCE(AVG(g.value), 0.00) " + + "FROM Grade g " + + "WHERE g.material.id IN :materialIds " + + "GROUP BY g.material.id") + Set findAverageGradeByMaterialsIds(List materialIds); - @Query("SELECT g FROM Grade g WHERE g.material.id = :materialId AND g.createdDate BETWEEN :from AND :to") - Page findGradesByMaterialInDateRange(Long materialId, LocalDateTime from, LocalDateTime to, Pageable pageable); + @Query("SELECT g FROM Grade g WHERE g.material.id = :materialId AND g.createdDate BETWEEN :from AND :to") + Page findGradesByMaterialInDateRange(Long materialId, LocalDateTime from, LocalDateTime to, Pageable pageable); } diff --git a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/database/MaterialRepository.java b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/database/MaterialRepository.java index 3bbe0f65..380b8250 100644 --- a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/database/MaterialRepository.java +++ b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/database/MaterialRepository.java @@ -21,7 +21,7 @@ public interface MaterialRepository extends JpaRepository { "LEFT JOIN Grade g ON m.id = g.material.id " + "WHERE (:userId IS NULL OR m.userId = :userId) " + "AND (:id IS NULL OR m.id = :id) " + - "AND (:phrase IS NULL OR m.title LIKE CONCAT('%', CAST(:phrase as string ), '%'))"+ + "AND (:phrase IS NULL OR m.title LIKE CONCAT('%', CAST(:phrase as string ), '%'))" + "AND ((:statuses) IS NULL OR m.status IN (:statuses)) " + "AND (:createdBy IS NULL OR m.createdBy = :createdBy) " + "AND (:sectionId IS NULL OR m.category.id IN (" + diff --git a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/ModuleBeanConfiguration.java b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/ModuleBeanConfiguration.java index 67e10ff4..292b28fa 100644 --- a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/ModuleBeanConfiguration.java +++ b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/ModuleBeanConfiguration.java @@ -12,15 +12,11 @@ import pl.sknikod.kodemybackend.infrastructure.database.MaterialRepository; import pl.sknikod.kodemybackend.infrastructure.module.category.CategoryService; import pl.sknikod.kodemybackend.infrastructure.module.grade.MaterialGradeService; -import pl.sknikod.kodemybackend.infrastructure.module.material.MaterialCreateService; +import pl.sknikod.kodemybackend.infrastructure.module.material.*; import pl.sknikod.kodemybackend.infrastructure.module.material.producer.MaterialCreatedProducer; import pl.sknikod.kodemybackend.infrastructure.module.material.producer.MaterialStatusUpdatedProducer; import pl.sknikod.kodemybackend.infrastructure.module.material.producer.MaterialUpdatedProducer; import pl.sknikod.kodemybackend.infrastructure.module.material_by_user.MaterialGetByUserService; -import pl.sknikod.kodemybackend.infrastructure.module.material.MaterialGetByIdService; -import pl.sknikod.kodemybackend.infrastructure.module.material.MaterialIndexService; -import pl.sknikod.kodemybackend.infrastructure.module.material.MaterialStatusService; -import pl.sknikod.kodemybackend.infrastructure.module.material.MaterialUpdateService; import pl.sknikod.kodemybackend.infrastructure.module.section.SectionService; import pl.sknikod.kodemybackend.infrastructure.module.tag.TagService; import pl.sknikod.kodemybackend.infrastructure.module.type.TypeService; diff --git a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/grade/MaterialGradeService.java b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/grade/MaterialGradeService.java index ddec2d87..15563b16 100644 --- a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/grade/MaterialGradeService.java +++ b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/grade/MaterialGradeService.java @@ -12,11 +12,11 @@ import pl.sknikod.kodemybackend.infrastructure.common.lan.LanNetworkHandler; import pl.sknikod.kodemybackend.infrastructure.common.mapper.GradeMapper; import pl.sknikod.kodemybackend.infrastructure.common.model.UserDetails; -import pl.sknikod.kodemybackend.infrastructure.database.Grade; -import pl.sknikod.kodemybackend.infrastructure.database.Material; import pl.sknikod.kodemybackend.infrastructure.dao.GradeDao; import pl.sknikod.kodemybackend.infrastructure.dao.MaterialDao; +import pl.sknikod.kodemybackend.infrastructure.database.Grade; import pl.sknikod.kodemybackend.infrastructure.database.GradeRepository; +import pl.sknikod.kodemybackend.infrastructure.database.Material; import pl.sknikod.kodemybackend.infrastructure.module.grade.model.GradeMaterialFilterSearchParams; import pl.sknikod.kodemycommons.exception.InternalError500Exception; import pl.sknikod.kodemycommons.exception.content.ExceptionUtil; @@ -61,7 +61,7 @@ public Page showGrades(PageRequest pageRequest, GradeMaterialFilt .map(page -> { var list = page.getContent() .stream() - .map(g->{ + .map(g -> { var username = lanNetworkHandler.getUser(g.getUserId()) .getOrElseThrow(ExceptionUtil::throwIfFailure); return gradeMapper.map(g, username); diff --git a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/material/MaterialCreateService.java b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/material/MaterialCreateService.java index d3e21889..284f0bc7 100644 --- a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/material/MaterialCreateService.java +++ b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/material/MaterialCreateService.java @@ -15,14 +15,14 @@ import org.mapstruct.Mapper; import org.mapstruct.MappingConstants; import org.springframework.security.core.authority.SimpleGrantedAuthority; -import pl.sknikod.kodemybackend.infrastructure.database.Category; -import pl.sknikod.kodemybackend.infrastructure.database.Material; -import pl.sknikod.kodemybackend.infrastructure.database.Tag; -import pl.sknikod.kodemybackend.infrastructure.database.Type; import pl.sknikod.kodemybackend.infrastructure.dao.CategoryDao; import pl.sknikod.kodemybackend.infrastructure.dao.MaterialDao; import pl.sknikod.kodemybackend.infrastructure.dao.TagDao; import pl.sknikod.kodemybackend.infrastructure.dao.TypeDao; +import pl.sknikod.kodemybackend.infrastructure.database.Category; +import pl.sknikod.kodemybackend.infrastructure.database.Material; +import pl.sknikod.kodemybackend.infrastructure.database.Tag; +import pl.sknikod.kodemybackend.infrastructure.database.Type; import pl.sknikod.kodemybackend.infrastructure.module.material.producer.MaterialCreatedProducer; import pl.sknikod.kodemycommons.exception.InternalError500Exception; import pl.sknikod.kodemycommons.exception.content.ExceptionUtil; diff --git a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/material/MaterialStatusService.java b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/material/MaterialStatusService.java index 31929d9a..9d948ff4 100644 --- a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/material/MaterialStatusService.java +++ b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/material/MaterialStatusService.java @@ -2,10 +2,9 @@ import lombok.AllArgsConstructor; import org.springframework.security.core.authority.SimpleGrantedAuthority; -import pl.sknikod.kodemybackend.infrastructure.database.Material; import pl.sknikod.kodemybackend.infrastructure.dao.MaterialDao; +import pl.sknikod.kodemybackend.infrastructure.database.Material; import pl.sknikod.kodemybackend.infrastructure.module.material.producer.MaterialStatusUpdatedProducer; -import pl.sknikod.kodemybackend.infrastructure.module.material.producer.MaterialUpdatedProducer; import pl.sknikod.kodemycommons.exception.InternalError500Exception; import pl.sknikod.kodemycommons.exception.Validation400Exception; import pl.sknikod.kodemycommons.exception.content.ExceptionUtil; diff --git a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/material/MaterialUpdateService.java b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/material/MaterialUpdateService.java index c90bdbd9..0036024e 100644 --- a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/material/MaterialUpdateService.java +++ b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/material/MaterialUpdateService.java @@ -22,12 +22,8 @@ import pl.sknikod.kodemycommons.security.AuthFacade; import pl.sknikod.kodemycommons.security.UserPrincipal; -import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Set; -import java.util.function.Function; -import java.util.stream.Collectors; import static pl.sknikod.kodemybackend.infrastructure.database.Material.MaterialStatus.APPROVED; import static pl.sknikod.kodemybackend.infrastructure.database.Material.MaterialStatus.PENDING; diff --git a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/material/producer/MaterialStatusUpdatedProducer.java b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/material/producer/MaterialStatusUpdatedProducer.java index b56780b0..662c5196 100644 --- a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/material/producer/MaterialStatusUpdatedProducer.java +++ b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/material/producer/MaterialStatusUpdatedProducer.java @@ -1,6 +1,8 @@ package pl.sknikod.kodemybackend.infrastructure.module.material.producer; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.RequiredArgsConstructor; +import lombok.Value; import lombok.extern.slf4j.Slf4j; import org.springframework.cloud.stream.function.StreamBridge; import org.springframework.stereotype.Component; diff --git a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/material/producer/MaterialUpdatedProducer.java b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/material/producer/MaterialUpdatedProducer.java index 5a298381..ec2cdf96 100644 --- a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/material/producer/MaterialUpdatedProducer.java +++ b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/material/producer/MaterialUpdatedProducer.java @@ -1,6 +1,5 @@ package pl.sknikod.kodemybackend.infrastructure.module.material.producer; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.*; import lombok.extern.slf4j.Slf4j; import org.springframework.cloud.stream.function.StreamBridge; @@ -8,7 +7,6 @@ import pl.sknikod.kodemybackend.infrastructure.database.Material; import java.time.Instant; -import java.time.LocalDateTime; import java.time.ZoneId; import java.util.List; diff --git a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/material_by_user/MaterialGetByUserService.java b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/material_by_user/MaterialGetByUserService.java index 9045a32e..0f74a627 100644 --- a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/material_by_user/MaterialGetByUserService.java +++ b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/material_by_user/MaterialGetByUserService.java @@ -11,10 +11,10 @@ import org.springframework.data.domain.PageRequest; import org.springframework.security.core.authority.SimpleGrantedAuthority; import pl.sknikod.kodemybackend.infrastructure.common.lan.LanNetworkHandler; -import pl.sknikod.kodemybackend.infrastructure.database.Material; import pl.sknikod.kodemybackend.infrastructure.dao.MaterialDao; -import pl.sknikod.kodemybackend.infrastructure.module.material.model.MaterialPageable; +import pl.sknikod.kodemybackend.infrastructure.database.Material; import pl.sknikod.kodemybackend.infrastructure.module.material.model.FilterSearchParams; +import pl.sknikod.kodemybackend.infrastructure.module.material.model.MaterialPageable; import pl.sknikod.kodemycommons.exception.InternalError500Exception; import pl.sknikod.kodemycommons.exception.content.ExceptionUtil; import pl.sknikod.kodemycommons.security.AuthFacade; diff --git a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/material_by_user/UserController.java b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/material_by_user/UserController.java index 268a6fbd..8d41e8f4 100644 --- a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/material_by_user/UserController.java +++ b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/material_by_user/UserController.java @@ -7,9 +7,9 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RestController; +import pl.sknikod.kodemybackend.infrastructure.module.material.model.FilterSearchParams; import pl.sknikod.kodemybackend.infrastructure.module.material.model.MaterialPageable; import pl.sknikod.kodemybackend.infrastructure.module.material.model.MaterialSortField; -import pl.sknikod.kodemybackend.infrastructure.module.material.model.FilterSearchParams; import pl.sknikod.kodemybackend.infrastructure.rest.UserControllerDefinition; import java.util.Objects; diff --git a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/tag/TagController.java b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/tag/TagController.java index 0150a699..0ee9e0a8 100644 --- a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/tag/TagController.java +++ b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/module/tag/TagController.java @@ -11,6 +11,7 @@ import java.net.URI; import java.util.List; + @Controller @AllArgsConstructor public class TagController implements TagControllerDefinition { diff --git a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/rest/MaterialControllerDefinition.java b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/rest/MaterialControllerDefinition.java index 2ad6fd49..930dbb64 100644 --- a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/rest/MaterialControllerDefinition.java +++ b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/rest/MaterialControllerDefinition.java @@ -10,8 +10,8 @@ import org.springframework.web.bind.annotation.*; import pl.sknikod.kodemybackend.infrastructure.database.Material; import pl.sknikod.kodemybackend.infrastructure.module.material.MaterialCreateService; -import pl.sknikod.kodemybackend.infrastructure.module.material.model.SingleMaterialResponse; import pl.sknikod.kodemybackend.infrastructure.module.material.MaterialUpdateService; +import pl.sknikod.kodemybackend.infrastructure.module.material.model.SingleMaterialResponse; import pl.sknikod.kodemycommons.doc.SwaggerResponse; import java.time.Instant; diff --git a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/rest/UserControllerDefinition.java b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/rest/UserControllerDefinition.java index fe92b188..e074b3c1 100644 --- a/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/rest/UserControllerDefinition.java +++ b/kodemy-backend/src/main/java/pl/sknikod/kodemybackend/infrastructure/rest/UserControllerDefinition.java @@ -6,10 +6,13 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.Sort; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import pl.sknikod.kodemybackend.infrastructure.module.material.model.FilterSearchParams; import pl.sknikod.kodemybackend.infrastructure.module.material.model.MaterialPageable; import pl.sknikod.kodemybackend.infrastructure.module.material.model.MaterialSortField; -import pl.sknikod.kodemybackend.infrastructure.module.material.model.FilterSearchParams; import pl.sknikod.kodemycommons.doc.SwaggerResponse; @RequestMapping("/api/users") diff --git a/kodemy-backend/src/main/resources/application-local.yml b/kodemy-backend/src/main/resources/application-local.yml index 03bcffb0..7ea88986 100644 --- a/kodemy-backend/src/main/resources/application-local.yml +++ b/kodemy-backend/src/main/resources/application-local.yml @@ -20,7 +20,7 @@ network: jwt: expiration-mins: 60 - + eureka: client: serviceUrl: diff --git a/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/factory/MaterialFactory.java b/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/factory/MaterialFactory.java index 3329e9b5..d0060f5f 100644 --- a/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/factory/MaterialFactory.java +++ b/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/factory/MaterialFactory.java @@ -3,14 +3,14 @@ import pl.sknikod.kodemybackend.infrastructure.database.Material; public class MaterialFactory { - public static Material material(){ + public static Material material() { var material = new Material(); material.setId(1L); material.setStatus(Material.MaterialStatus.PENDING); return material; } - public static Material material(Long id, Material.MaterialStatus status){ + public static Material material(Long id, Material.MaterialStatus status) { var material = new Material(); material.setId(id); material.setStatus(status); diff --git a/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/factory/TokenFactory.java b/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/factory/TokenFactory.java index 94bc3ae7..64c18509 100644 --- a/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/factory/TokenFactory.java +++ b/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/factory/TokenFactory.java @@ -7,7 +7,8 @@ import java.util.UUID; public class TokenFactory { - private TokenFactory() {} + private TokenFactory() { + } public static JwtProvider.Token jwtServiceToken = jwtServiceToken(); public static JwtProvider.Token.Deserialize jwtServiceTokenDeserialize = jwtServiceTokenDeserialize(); diff --git a/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/factory/TypeFactory.java b/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/factory/TypeFactory.java index 3e4f2f5d..f773ee18 100644 --- a/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/factory/TypeFactory.java +++ b/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/factory/TypeFactory.java @@ -6,7 +6,7 @@ public class TypeFactory { private TypeFactory() { } - public static Type type(){ + public static Type type() { var type = new Type(); type.setId(1L); return type; diff --git a/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/factory/UserFactory.java b/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/factory/UserFactory.java index 74c875f2..86aadd63 100644 --- a/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/factory/UserFactory.java +++ b/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/factory/UserFactory.java @@ -4,7 +4,6 @@ import pl.sknikod.kodemycommons.security.UserPrincipal; import java.util.Collections; -import java.util.List; import java.util.Set; public class UserFactory { diff --git a/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/database/handler/CategoryDaoTest.java b/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/database/handler/CategoryDaoTest.java index e9616640..e8e19792 100644 --- a/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/database/handler/CategoryDaoTest.java +++ b/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/database/handler/CategoryDaoTest.java @@ -3,11 +3,11 @@ import io.vavr.control.Try; import org.junit.jupiter.api.Test; import org.mockito.Mockito; +import pl.sknikod.kodemybackend.BaseTest; import pl.sknikod.kodemybackend.factory.CategoryFactory; import pl.sknikod.kodemybackend.infrastructure.dao.CategoryDao; import pl.sknikod.kodemybackend.infrastructure.database.Category; import pl.sknikod.kodemybackend.infrastructure.database.CategoryRepository; -import pl.sknikod.kodemybackend.BaseTest; import pl.sknikod.kodemycommons.exception.NotFound404Exception; import java.util.Optional; diff --git a/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/database/handler/GradeDaoTest.java b/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/database/handler/GradeDaoTest.java index e8c09b1d..88dabd65 100644 --- a/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/database/handler/GradeDaoTest.java +++ b/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/database/handler/GradeDaoTest.java @@ -2,10 +2,10 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; +import pl.sknikod.kodemybackend.BaseTest; import pl.sknikod.kodemybackend.factory.CategoryFactory; import pl.sknikod.kodemybackend.infrastructure.dao.GradeDao; import pl.sknikod.kodemybackend.infrastructure.database.GradeRepository; -import pl.sknikod.kodemybackend.BaseTest; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; diff --git a/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/database/handler/MaterialDaoTest.java b/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/database/handler/MaterialDaoTest.java index 00564b44..568fa869 100644 --- a/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/database/handler/MaterialDaoTest.java +++ b/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/database/handler/MaterialDaoTest.java @@ -3,10 +3,10 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.dao.OptimisticLockingFailureException; +import pl.sknikod.kodemybackend.BaseTest; import pl.sknikod.kodemybackend.factory.MaterialFactory; import pl.sknikod.kodemybackend.infrastructure.dao.MaterialDao; import pl.sknikod.kodemybackend.infrastructure.database.MaterialRepository; -import pl.sknikod.kodemybackend.BaseTest; import pl.sknikod.kodemycommons.exception.NotFound404Exception; import java.util.Optional; diff --git a/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/database/handler/SectionDaoTest.java b/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/database/handler/SectionDaoTest.java index 4500318b..1e28660b 100644 --- a/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/database/handler/SectionDaoTest.java +++ b/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/database/handler/SectionDaoTest.java @@ -2,13 +2,14 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; +import pl.sknikod.kodemybackend.BaseTest; import pl.sknikod.kodemybackend.infrastructure.dao.SectionDao; import pl.sknikod.kodemybackend.infrastructure.database.SectionRepository; -import pl.sknikod.kodemybackend.BaseTest; import java.util.Collections; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.when; class SectionDaoTest extends BaseTest { diff --git a/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/database/handler/TagDaoTest.java b/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/database/handler/TagDaoTest.java index 22f4c1a0..9afd7c43 100644 --- a/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/database/handler/TagDaoTest.java +++ b/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/database/handler/TagDaoTest.java @@ -3,11 +3,11 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.dao.OptimisticLockingFailureException; +import pl.sknikod.kodemybackend.BaseTest; import pl.sknikod.kodemybackend.factory.TagFactory; import pl.sknikod.kodemybackend.infrastructure.dao.TagDao; import pl.sknikod.kodemybackend.infrastructure.database.Tag; import pl.sknikod.kodemybackend.infrastructure.database.TagRepository; -import pl.sknikod.kodemybackend.BaseTest; import pl.sknikod.kodemycommons.exception.AlreadyExists409Exception; import pl.sknikod.kodemycommons.exception.NotFound404Exception; @@ -26,7 +26,7 @@ class TagDaoTest extends BaseTest { new TagDao(tagRepository); @Test - void findAllByIdIn_shouldSucceed(){ + void findAllByIdIn_shouldSucceed() { // given when(tagRepository.findTagsByIdIn(any())) .thenReturn(Set.of(new Tag())); @@ -38,7 +38,7 @@ void findAllByIdIn_shouldSucceed(){ } @Test - void findAllByIdIn_shouldFailure_whenAnyTagNotFound(){ + void findAllByIdIn_shouldFailure_whenAnyTagNotFound() { // given when(tagRepository.findTagsByIdIn(any())) .thenReturn(Collections.emptySet()); diff --git a/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/database/handler/TypeDaoTest.java b/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/database/handler/TypeDaoTest.java index 48eee315..3fd3ec0c 100644 --- a/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/database/handler/TypeDaoTest.java +++ b/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/database/handler/TypeDaoTest.java @@ -2,10 +2,10 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; +import pl.sknikod.kodemybackend.BaseTest; import pl.sknikod.kodemybackend.factory.TypeFactory; import pl.sknikod.kodemybackend.infrastructure.dao.TypeDao; import pl.sknikod.kodemybackend.infrastructure.database.TypeRepository; -import pl.sknikod.kodemybackend.BaseTest; import pl.sknikod.kodemycommons.exception.NotFound404Exception; import java.util.Collections; diff --git a/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/module/category/CategoryServiceTest.java b/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/module/category/CategoryServiceTest.java index 1c73c839..4baeb0bd 100644 --- a/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/module/category/CategoryServiceTest.java +++ b/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/module/category/CategoryServiceTest.java @@ -2,12 +2,12 @@ import io.vavr.control.Try; import org.junit.jupiter.api.Test; +import pl.sknikod.kodemybackend.BaseTest; import pl.sknikod.kodemybackend.factory.CategoryFactory; import pl.sknikod.kodemybackend.infrastructure.common.mapper.CategoryMapper; -import pl.sknikod.kodemybackend.infrastructure.database.Category; import pl.sknikod.kodemybackend.infrastructure.dao.CategoryDao; +import pl.sknikod.kodemybackend.infrastructure.database.Category; import pl.sknikod.kodemybackend.infrastructure.module.category.model.SingleCategoryResponse; -import pl.sknikod.kodemybackend.BaseTest; import pl.sknikod.kodemycommons.exception.NotFound404Exception; import static org.junit.jupiter.api.Assertions.*; diff --git a/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/module/grade/MaterialGradeServiceTest.java b/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/module/grade/MaterialGradeServiceTest.java index b3fdf387..e14c8ab2 100644 --- a/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/module/grade/MaterialGradeServiceTest.java +++ b/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/module/grade/MaterialGradeServiceTest.java @@ -6,16 +6,16 @@ import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; +import pl.sknikod.kodemybackend.BaseTest; +import pl.sknikod.kodemybackend.WithUserPrincipal; import pl.sknikod.kodemybackend.factory.GradeFactory; import pl.sknikod.kodemybackend.factory.MaterialFactory; import pl.sknikod.kodemybackend.infrastructure.common.mapper.GradeMapper; -import pl.sknikod.kodemybackend.infrastructure.database.Grade; -import pl.sknikod.kodemybackend.infrastructure.database.Material; import pl.sknikod.kodemybackend.infrastructure.dao.GradeDao; import pl.sknikod.kodemybackend.infrastructure.dao.MaterialDao; +import pl.sknikod.kodemybackend.infrastructure.database.Grade; +import pl.sknikod.kodemybackend.infrastructure.database.Material; import pl.sknikod.kodemybackend.infrastructure.module.grade.model.GradeMaterialFilterSearchParams; -import pl.sknikod.kodemybackend.BaseTest; -import pl.sknikod.kodemybackend.WithUserPrincipal; import pl.sknikod.kodemycommons.exception.InternalError500Exception; import pl.sknikod.kodemycommons.exception.NotFound404Exception; @@ -71,22 +71,22 @@ void addGrade_shouldThrowException_whenSaveFails() { // when & then assertThrows(RuntimeException.class, () -> materialGradeService.addGrade(3L, request)); } - + @Test - void showGrades_shouldSuccess(){ + void showGrades_shouldSuccess() { //given //when - var result = materialGradeService.showGrades(PageRequest.of(1,1), new GradeMaterialFilterSearchParams(), 1L); + var result = materialGradeService.showGrades(PageRequest.of(1, 1), new GradeMaterialFilterSearchParams(), 1L); //then assertNotNull(result); assertEquals(1, result.getContent().size()); } @Test - void showGrades_shouldThrowException_whenRepoError(){ + void showGrades_shouldThrowException_whenRepoError() { //given //when & then - assertThrows(RuntimeException.class, () -> materialGradeService.showGrades(PageRequest.of(1,1), new GradeMaterialFilterSearchParams(), 2L)); + assertThrows(RuntimeException.class, () -> materialGradeService.showGrades(PageRequest.of(1, 1), new GradeMaterialFilterSearchParams(), 2L)); } static class TestGradeDao extends GradeDao { diff --git a/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/module/material/add/MaterialCreateServiceTest.java b/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/module/material/add/MaterialCreateServiceTest.java index f62af964..d610777c 100644 --- a/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/module/material/add/MaterialCreateServiceTest.java +++ b/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/module/material/add/MaterialCreateServiceTest.java @@ -3,25 +3,29 @@ import io.vavr.control.Try; import org.junit.jupiter.api.Test; import org.mockito.Mockito; -import pl.sknikod.kodemybackend.factory.*; -import pl.sknikod.kodemybackend.infrastructure.database.Material; +import pl.sknikod.kodemybackend.BaseTest; +import pl.sknikod.kodemybackend.WithUserPrincipal; +import pl.sknikod.kodemybackend.factory.CategoryFactory; +import pl.sknikod.kodemybackend.factory.MaterialFactory; +import pl.sknikod.kodemybackend.factory.TagFactory; +import pl.sknikod.kodemybackend.factory.TypeFactory; import pl.sknikod.kodemybackend.infrastructure.dao.CategoryDao; import pl.sknikod.kodemybackend.infrastructure.dao.MaterialDao; import pl.sknikod.kodemybackend.infrastructure.dao.TagDao; import pl.sknikod.kodemybackend.infrastructure.dao.TypeDao; +import pl.sknikod.kodemybackend.infrastructure.database.Material; import pl.sknikod.kodemybackend.infrastructure.module.material.MaterialCreateService; import pl.sknikod.kodemybackend.infrastructure.module.material.MaterialRabbitProducer; import pl.sknikod.kodemybackend.infrastructure.module.material.MaterialRabbitProducerTest; -import pl.sknikod.kodemybackend.BaseTest; -import pl.sknikod.kodemybackend.WithUserPrincipal; import pl.sknikod.kodemycommons.exception.InternalError500Exception; import pl.sknikod.kodemycommons.exception.NotFound404Exception; import java.util.Set; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.when; class MaterialCreateServiceTest extends BaseTest { private final MaterialDao materialDao = diff --git a/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/module/material/update/MaterialUpdateServiceTest.java b/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/module/material/update/MaterialUpdateServiceTest.java index 0d08d920..19ca9d53 100644 --- a/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/module/material/update/MaterialUpdateServiceTest.java +++ b/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/module/material/update/MaterialUpdateServiceTest.java @@ -3,17 +3,17 @@ import io.vavr.control.Try; import org.junit.jupiter.api.Test; import org.mockito.Mockito; +import pl.sknikod.kodemybackend.BaseTest; +import pl.sknikod.kodemybackend.WithUserPrincipal; import pl.sknikod.kodemybackend.factory.CategoryFactory; import pl.sknikod.kodemybackend.factory.MaterialFactory; import pl.sknikod.kodemybackend.factory.TagFactory; import pl.sknikod.kodemybackend.factory.TypeFactory; import pl.sknikod.kodemybackend.infrastructure.dao.*; -import pl.sknikod.kodemybackend.infrastructure.database.dao.*; import pl.sknikod.kodemybackend.infrastructure.database.Material; +import pl.sknikod.kodemybackend.infrastructure.database.dao.*; import pl.sknikod.kodemybackend.infrastructure.module.material.MaterialRabbitProducer; import pl.sknikod.kodemybackend.infrastructure.module.material.MaterialRabbitProducerTest; -import pl.sknikod.kodemybackend.BaseTest; -import pl.sknikod.kodemybackend.WithUserPrincipal; import pl.sknikod.kodemybackend.infrastructure.module.material.MaterialUpdateService; import pl.sknikod.kodemycommons.exception.InternalError500Exception; import pl.sknikod.kodemycommons.exception.NotFound404Exception; @@ -62,7 +62,7 @@ class MaterialUpdateServiceTest extends BaseTest { void update_shouldSucceed() { // given var response = new MaterialUpdateService.MaterialUpdateResponse( - MATERIAL.getId(), null, null, null,null,null,null + MATERIAL.getId(), null, null, null, null, null, null ); when(materialDao.findById(any())) .thenReturn(Try.success(MATERIAL)); diff --git a/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/module/section/SectionUseCaseTest.java b/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/module/section/SectionUseCaseTest.java index f4eeb2cd..715a3a7f 100644 --- a/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/module/section/SectionUseCaseTest.java +++ b/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/module/section/SectionUseCaseTest.java @@ -3,11 +3,11 @@ import io.vavr.control.Try; import org.junit.jupiter.api.Test; import org.mockito.Mockito; +import pl.sknikod.kodemybackend.BaseTest; import pl.sknikod.kodemybackend.factory.SectionFactory; import pl.sknikod.kodemybackend.infrastructure.common.mapper.SectionMapper; import pl.sknikod.kodemybackend.infrastructure.dao.SectionDao; import pl.sknikod.kodemybackend.infrastructure.module.section.model.SingleSectionResponse; -import pl.sknikod.kodemybackend.BaseTest; import pl.sknikod.kodemycommons.exception.InternalError500Exception; import pl.sknikod.kodemycommons.exception.NotFound404Exception; diff --git a/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/module/tag/TagUseCaseTest.java b/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/module/tag/TagUseCaseTest.java index e28cea06..d2a26b39 100644 --- a/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/module/tag/TagUseCaseTest.java +++ b/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/module/tag/TagUseCaseTest.java @@ -3,13 +3,13 @@ import io.vavr.control.Try; import org.junit.jupiter.api.Test; import org.mockito.Mockito; +import pl.sknikod.kodemybackend.BaseTest; import pl.sknikod.kodemybackend.factory.TagFactory; import pl.sknikod.kodemybackend.infrastructure.common.mapper.TagMapper; -import pl.sknikod.kodemybackend.infrastructure.database.Tag; import pl.sknikod.kodemybackend.infrastructure.dao.TagDao; +import pl.sknikod.kodemybackend.infrastructure.database.Tag; import pl.sknikod.kodemybackend.infrastructure.module.tag.model.TagAddRequest; import pl.sknikod.kodemybackend.infrastructure.module.tag.model.TagAddResponse; -import pl.sknikod.kodemybackend.BaseTest; import java.util.Collection; import java.util.List; @@ -24,6 +24,7 @@ class TagServiceTest extends BaseTest { final TagService tagService = new TagService(tagDao, new TagMapperImpl()); static final TagAddRequest request = new TagAddRequest(); + static { request.setName("name"); } diff --git a/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/module/type/TypeUseCaseTest.java b/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/module/type/TypeUseCaseTest.java index d6362877..b6816100 100644 --- a/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/module/type/TypeUseCaseTest.java +++ b/kodemy-backend/src/test/java/pl/sknikod/kodemybackend/infrastructure/module/type/TypeUseCaseTest.java @@ -3,15 +3,16 @@ import io.vavr.control.Try; import org.junit.jupiter.api.Test; import org.mockito.Mockito; +import pl.sknikod.kodemybackend.BaseTest; import pl.sknikod.kodemybackend.factory.TypeFactory; import pl.sknikod.kodemybackend.infrastructure.common.mapper.TypeMapper; import pl.sknikod.kodemybackend.infrastructure.dao.TypeDao; import pl.sknikod.kodemybackend.infrastructure.module.type.model.SingleTypeResponse; -import pl.sknikod.kodemybackend.BaseTest; import java.util.List; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.ArgumentMatchers.anyList; import static org.mockito.Mockito.when; diff --git a/kodemy-notification/src/main/resources/application-local.yml b/kodemy-notification/src/main/resources/application-local.yml index 638d994b..1b19cf73 100644 --- a/kodemy-notification/src/main/resources/application-local.yml +++ b/kodemy-notification/src/main/resources/application-local.yml @@ -10,7 +10,7 @@ logging.level: jwt: expiration-mins: 60 - + eureka: client: serviceUrl: diff --git a/kodemy-search/src/main/java/pl/sknikod/kodemysearch/configuration/LogbookConfiguration.java b/kodemy-search/src/main/java/pl/sknikod/kodemysearch/configuration/LogbookConfiguration.java index 5ac80eef..b568626e 100755 --- a/kodemy-search/src/main/java/pl/sknikod/kodemysearch/configuration/LogbookConfiguration.java +++ b/kodemy-search/src/main/java/pl/sknikod/kodemysearch/configuration/LogbookConfiguration.java @@ -7,7 +7,7 @@ @Configuration public class LogbookConfiguration { @Bean - public Logbook logbook(){ + public Logbook logbook() { return Logbook.create(); } } diff --git a/kodemy-search/src/main/java/pl/sknikod/kodemysearch/configuration/OpenSearchConfiguration.java b/kodemy-search/src/main/java/pl/sknikod/kodemysearch/configuration/OpenSearchConfiguration.java index 6a12692d..f9014f21 100644 --- a/kodemy-search/src/main/java/pl/sknikod/kodemysearch/configuration/OpenSearchConfiguration.java +++ b/kodemy-search/src/main/java/pl/sknikod/kodemysearch/configuration/OpenSearchConfiguration.java @@ -9,7 +9,6 @@ import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.impl.client.BasicCredentialsProvider; import org.opensearch.client.RestClient; -import org.opensearch.client.json.jackson.JacksonJsonpMapper; import org.opensearch.client.json.jsonb.JsonbJsonpMapper; import org.opensearch.client.opensearch.OpenSearchClient; import org.opensearch.client.transport.rest_client.RestClientTransport; diff --git a/kodemy-search/src/main/java/pl/sknikod/kodemysearch/configuration/SecurityConfiguration.java b/kodemy-search/src/main/java/pl/sknikod/kodemysearch/configuration/SecurityConfiguration.java index 1c05c657..c23ad098 100644 --- a/kodemy-search/src/main/java/pl/sknikod/kodemysearch/configuration/SecurityConfiguration.java +++ b/kodemy-search/src/main/java/pl/sknikod/kodemysearch/configuration/SecurityConfiguration.java @@ -62,7 +62,7 @@ public JwtConfiguration.JwtProperties jwtProperties() { } @Bean - public JwtProvider jwtProvider(JwtConfiguration.JwtProperties jwtProperties){ + public JwtProvider jwtProvider(JwtConfiguration.JwtProperties jwtProperties) { return new JwtProvider(jwtProperties); } diff --git a/kodemy-search/src/main/java/pl/sknikod/kodemysearch/infrastructure/dao/MaterialSearchDao.java b/kodemy-search/src/main/java/pl/sknikod/kodemysearch/infrastructure/dao/MaterialSearchDao.java index 0943f708..4f21aaa3 100644 --- a/kodemy-search/src/main/java/pl/sknikod/kodemysearch/infrastructure/dao/MaterialSearchDao.java +++ b/kodemy-search/src/main/java/pl/sknikod/kodemysearch/infrastructure/dao/MaterialSearchDao.java @@ -4,7 +4,10 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.opensearch.client.opensearch.OpenSearchClient; -import org.opensearch.client.opensearch.core.*; +import org.opensearch.client.opensearch.core.IndexRequest; +import org.opensearch.client.opensearch.core.IndexResponse; +import org.opensearch.client.opensearch.core.UpdateRequest; +import org.opensearch.client.opensearch.core.UpdateResponse; import org.opensearch.client.opensearch.core.search.Hit; import org.springframework.data.domain.PageImpl; import org.springframework.stereotype.Component; @@ -69,8 +72,8 @@ public Try> update(Long materialId, Set> search(SearchCriteria criteria) { return Try.of(() -> openSearchClient.search( - SearchRequestBuilder.from(criteria).toSearchRequest(INDEX), MaterialIndexData.class - )) + SearchRequestBuilder.from(criteria).toSearchRequest(INDEX), MaterialIndexData.class + )) .mapTry(response -> { final var hits = response.hits(); return new PageImpl( diff --git a/kodemy-search/src/main/java/pl/sknikod/kodemysearch/infrastructure/module/material/MaterialSearchService.java b/kodemy-search/src/main/java/pl/sknikod/kodemysearch/infrastructure/module/material/MaterialSearchService.java index 8a5bc1d1..b34dddad 100644 --- a/kodemy-search/src/main/java/pl/sknikod/kodemysearch/infrastructure/module/material/MaterialSearchService.java +++ b/kodemy-search/src/main/java/pl/sknikod/kodemysearch/infrastructure/module/material/MaterialSearchService.java @@ -1,7 +1,9 @@ package pl.sknikod.kodemysearch.infrastructure.module.material; import com.fasterxml.jackson.annotation.JsonFormat; -import lombok.*; +import lombok.Getter; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.mapstruct.Mapper; @@ -12,8 +14,8 @@ import org.springframework.data.domain.Pageable; import pl.sknikod.kodemycommons.exception.content.ExceptionUtil; import pl.sknikod.kodemysearch.infrastructure.dao.MaterialSearchDao; -import pl.sknikod.kodemysearch.infrastructure.module.material.model.MaterialIndexData; import pl.sknikod.kodemysearch.infrastructure.module.material.model.MaterialFilterSearchParams; +import pl.sknikod.kodemysearch.infrastructure.module.material.model.MaterialIndexData; import java.util.Date; import java.util.List; diff --git a/kodemy-search/src/main/java/pl/sknikod/kodemysearch/infrastructure/module/material/MaterialUpdateStatusService.java b/kodemy-search/src/main/java/pl/sknikod/kodemysearch/infrastructure/module/material/MaterialUpdateStatusService.java index 833f3293..9a02ccf3 100644 --- a/kodemy-search/src/main/java/pl/sknikod/kodemysearch/infrastructure/module/material/MaterialUpdateStatusService.java +++ b/kodemy-search/src/main/java/pl/sknikod/kodemysearch/infrastructure/module/material/MaterialUpdateStatusService.java @@ -16,18 +16,18 @@ @RequiredArgsConstructor @DependsOn("rabbitConfiguration") public class MaterialUpdateStatusService { - private final MaterialSearchDao materialSearchDao; - private final ObjectMapper objectMapper; + private final MaterialSearchDao materialSearchDao; + private final ObjectMapper objectMapper; - private Try mapToMaterialStatusChangeData(String msg) { - return Try.of(() -> objectMapper.readValue(msg, MaterialStatusChangeData.class)) - .onFailure(ex -> log.error("Status change failed due to an exception: {}", ex.getMessage(), ex)); - } - - public String updateStatus(String msg){ - return mapToMaterialStatusChangeData(msg) - .flatMap(d->materialSearchDao.update(d.getId(), d.getStatus())) - .map(WriteResponseBase::id) - .getOrElseThrow(ExceptionUtil::throwIfFailure); - } + private Try mapToMaterialStatusChangeData(String msg) { + return Try.of(() -> objectMapper.readValue(msg, MaterialStatusChangeData.class)) + .onFailure(ex -> log.error("Status change failed due to an exception: {}", ex.getMessage(), ex)); + } + + public String updateStatus(String msg) { + return mapToMaterialStatusChangeData(msg) + .flatMap(d -> materialSearchDao.update(d.getId(), d.getStatus())) + .map(WriteResponseBase::id) + .getOrElseThrow(ExceptionUtil::throwIfFailure); + } } diff --git a/kodemy-search/src/main/java/pl/sknikod/kodemysearch/infrastructure/module/material/SearchCriteria.java b/kodemy-search/src/main/java/pl/sknikod/kodemysearch/infrastructure/module/material/SearchCriteria.java index a3c82796..58aa9db2 100644 --- a/kodemy-search/src/main/java/pl/sknikod/kodemysearch/infrastructure/module/material/SearchCriteria.java +++ b/kodemy-search/src/main/java/pl/sknikod/kodemysearch/infrastructure/module/material/SearchCriteria.java @@ -1,6 +1,7 @@ package pl.sknikod.kodemysearch.infrastructure.module.material; -import lombok.*; +import lombok.AccessLevel; +import lombok.Getter; import lombok.experimental.FieldDefaults; import org.springframework.data.domain.Pageable; import org.springframework.lang.NonNull; diff --git a/kodemy-search/src/main/java/pl/sknikod/kodemysearch/infrastructure/module/material/consumer/MaterialStatusUpdatedConsumer.java b/kodemy-search/src/main/java/pl/sknikod/kodemysearch/infrastructure/module/material/consumer/MaterialStatusUpdatedConsumer.java index a04308f8..8b3e95df 100644 --- a/kodemy-search/src/main/java/pl/sknikod/kodemysearch/infrastructure/module/material/consumer/MaterialStatusUpdatedConsumer.java +++ b/kodemy-search/src/main/java/pl/sknikod/kodemysearch/infrastructure/module/material/consumer/MaterialStatusUpdatedConsumer.java @@ -12,7 +12,7 @@ @RequiredArgsConstructor public class MaterialStatusUpdatedConsumer implements Consumer { private final MaterialUpdateStatusService materialUpdateStatusService; - + @Override public void accept(String msg) { log.info("Consuming message from materialStatusUpdated"); diff --git a/kodemy-search/src/main/java/pl/sknikod/kodemysearch/infrastructure/module/material/consumer/MaterialTagsUpdatedConsumer.java b/kodemy-search/src/main/java/pl/sknikod/kodemysearch/infrastructure/module/material/consumer/MaterialTagsUpdatedConsumer.java index 069850fe..bcd17af8 100644 --- a/kodemy-search/src/main/java/pl/sknikod/kodemysearch/infrastructure/module/material/consumer/MaterialTagsUpdatedConsumer.java +++ b/kodemy-search/src/main/java/pl/sknikod/kodemysearch/infrastructure/module/material/consumer/MaterialTagsUpdatedConsumer.java @@ -10,7 +10,7 @@ @Component("materialTagsUpdated") @RequiredArgsConstructor public class MaterialTagsUpdatedConsumer implements Consumer { - + @Override public void accept(String msg) { log.info("Consuming message from materialTagsUpdated"); diff --git a/kodemy-search/src/main/java/pl/sknikod/kodemysearch/infrastructure/module/material/model/MaterialStatusChangeData.java b/kodemy-search/src/main/java/pl/sknikod/kodemysearch/infrastructure/module/material/model/MaterialStatusChangeData.java index e89bd73e..ab3171a7 100644 --- a/kodemy-search/src/main/java/pl/sknikod/kodemysearch/infrastructure/module/material/model/MaterialStatusChangeData.java +++ b/kodemy-search/src/main/java/pl/sknikod/kodemysearch/infrastructure/module/material/model/MaterialStatusChangeData.java @@ -4,6 +4,6 @@ @Data public class MaterialStatusChangeData { - private Long id; - private MaterialStatus status; + private Long id; + private MaterialStatus status; } diff --git a/kodemy-search/src/main/java/pl/sknikod/kodemysearch/infrastructure/rest/MaterialControllerDefinition.java b/kodemy-search/src/main/java/pl/sknikod/kodemysearch/infrastructure/rest/MaterialControllerDefinition.java index 7208b4ed..8bce4cc3 100644 --- a/kodemy-search/src/main/java/pl/sknikod/kodemysearch/infrastructure/rest/MaterialControllerDefinition.java +++ b/kodemy-search/src/main/java/pl/sknikod/kodemysearch/infrastructure/rest/MaterialControllerDefinition.java @@ -3,9 +3,6 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; import org.springframework.data.domain.Page; import org.springframework.data.domain.Sort; import org.springframework.http.ResponseEntity; diff --git a/kodemy-search/src/test/java/pl/sknikod/kodemysearch/configuration/TestSecurityConfig.java b/kodemy-search/src/test/java/pl/sknikod/kodemysearch/configuration/TestSecurityConfig.java index e3b35d2e..5dad008f 100644 --- a/kodemy-search/src/test/java/pl/sknikod/kodemysearch/configuration/TestSecurityConfig.java +++ b/kodemy-search/src/test/java/pl/sknikod/kodemysearch/configuration/TestSecurityConfig.java @@ -21,7 +21,7 @@ public JwtAuthorizationFilter jwtAuthorizationFilter( } @Bean - public JwtProvider jwtProvider(){ + public JwtProvider jwtProvider() { return Mockito.mock(JwtProvider.class); } } diff --git a/kodemy-search/src/test/java/pl/sknikod/kodemysearch/factory/TokenFactory.java b/kodemy-search/src/test/java/pl/sknikod/kodemysearch/factory/TokenFactory.java index 3b700dba..77295c66 100644 --- a/kodemy-search/src/test/java/pl/sknikod/kodemysearch/factory/TokenFactory.java +++ b/kodemy-search/src/test/java/pl/sknikod/kodemysearch/factory/TokenFactory.java @@ -1,4 +1,3 @@ - package pl.sknikod.kodemysearch.factory; import pl.sknikod.kodemycommons.security.JwtProvider; @@ -8,7 +7,8 @@ import java.util.UUID; public class TokenFactory { - private TokenFactory() {} + private TokenFactory() { + } public static JwtProvider.Token jwtServiceToken = jwtServiceToken(); public static JwtProvider.Token.Deserialize jwtServiceTokenDeserialize = jwtServiceTokenDeserialize(); diff --git a/kodemy-service-registry/src/main/java/pl/sknikod/kodemyserviceregistry/KodemyServiceRegistryApplication.java b/kodemy-service-registry/src/main/java/pl/sknikod/kodemyserviceregistry/KodemyServiceRegistryApplication.java index c7bd6287..9d148d77 100644 --- a/kodemy-service-registry/src/main/java/pl/sknikod/kodemyserviceregistry/KodemyServiceRegistryApplication.java +++ b/kodemy-service-registry/src/main/java/pl/sknikod/kodemyserviceregistry/KodemyServiceRegistryApplication.java @@ -8,8 +8,8 @@ @EnableEurekaServer public class KodemyServiceRegistryApplication { - public static void main(String[] args) { - SpringApplication.run(KodemyServiceRegistryApplication.class, args); - } + public static void main(String[] args) { + SpringApplication.run(KodemyServiceRegistryApplication.class, args); + } }