Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/yas 1234 #1239

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.yas.cart.viewmodel.CartItemPutVm;
import com.yas.commonlibrary.exception.ApiExceptionHandler;
import java.util.List;
import javax.ws.rs.core.MediaType;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
Expand All @@ -30,6 +30,7 @@
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,9 @@
import com.yas.commonlibrary.exception.WrongEmailFormatException;
import com.yas.customer.config.KeycloakPropsConfig;
import com.yas.customer.utils.Constants;
import com.yas.customer.viewmodel.customer.CustomerAdminVm;
import com.yas.customer.viewmodel.customer.CustomerListVm;
import com.yas.customer.viewmodel.customer.CustomerPostVm;
import com.yas.customer.viewmodel.customer.CustomerProfileRequestVm;
import com.yas.customer.viewmodel.customer.CustomerVm;
import com.yas.customer.viewmodel.customer.GuestUserVm;
import java.security.SecureRandom;
import java.util.Base64;
import java.util.Collections;
import java.util.List;
import javax.ws.rs.ForbiddenException;
import javax.ws.rs.core.Response;
import com.yas.customer.viewmodel.customer.*;

Check warning on line 9 in customer/src/main/java/com/yas/customer/service/CustomerService.java

View workflow job for this annotation

GitHub Actions / Checkstyle

com.puppycrawl.tools.checkstyle.checks.imports.AvoidStarImportCheck

Using the '.*' form of import should be avoided - com.yas.customer.viewmodel.customer.*.
import jakarta.ws.rs.ForbiddenException;
import jakarta.ws.rs.core.Response;
import org.apache.commons.validator.routines.EmailValidator;
import org.keycloak.admin.client.CreatedResponseUtil;
import org.keycloak.admin.client.Keycloak;
Expand All @@ -29,6 +20,11 @@
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

import java.security.SecureRandom;

Check warning on line 23 in customer/src/main/java/com/yas/customer/service/CustomerService.java

View workflow job for this annotation

GitHub Actions / Checkstyle

com.puppycrawl.tools.checkstyle.checks.imports.CustomImportOrderCheck

Extra separation in import group before 'java.security.SecureRandom'

Check warning on line 23 in customer/src/main/java/com/yas/customer/service/CustomerService.java

View workflow job for this annotation

GitHub Actions / Checkstyle

com.puppycrawl.tools.checkstyle.checks.imports.CustomImportOrderCheck

Wrong lexicographical order for 'java.security.SecureRandom' import. Should be before 'org.springframework.stereotype.Service'.
import java.util.Base64;

Check warning on line 24 in customer/src/main/java/com/yas/customer/service/CustomerService.java

View workflow job for this annotation

GitHub Actions / Checkstyle

com.puppycrawl.tools.checkstyle.checks.imports.CustomImportOrderCheck

Wrong lexicographical order for 'java.util.Base64' import. Should be before 'org.springframework.stereotype.Service'.
import java.util.Collections;

Check warning on line 25 in customer/src/main/java/com/yas/customer/service/CustomerService.java

View workflow job for this annotation

GitHub Actions / Checkstyle

com.puppycrawl.tools.checkstyle.checks.imports.CustomImportOrderCheck

Wrong lexicographical order for 'java.util.Collections' import. Should be before 'org.springframework.stereotype.Service'.
import java.util.List;

Check warning on line 26 in customer/src/main/java/com/yas/customer/service/CustomerService.java

View workflow job for this annotation

GitHub Actions / Checkstyle

com.puppycrawl.tools.checkstyle.checks.imports.CustomImportOrderCheck

Wrong lexicographical order for 'java.util.List' import. Should be before 'org.springframework.stereotype.Service'.

@Service
public class CustomerService {

Expand Down Expand Up @@ -90,7 +86,7 @@
if (searchResult.isEmpty()) {
throw new NotFoundException(Constants.ErrorCode.USER_WITH_EMAIL_NOT_FOUND, email);
}
return CustomerAdminVm.fromUserRepresentation(searchResult.get(0));
return CustomerAdminVm.fromUserRepresentation(searchResult.getFirst());
} else {
throw new WrongEmailFormatException(Constants.ErrorCode.WRONG_EMAIL_FORMAT, email);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,48 +1,33 @@
package com.yas.customer.service;

import static com.yas.customer.util.SecurityContextUtils.setUpSecurityContext;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import com.yas.commonlibrary.exception.AccessDeniedException;
import com.yas.commonlibrary.exception.DuplicatedException;
import com.yas.commonlibrary.exception.NotFoundException;
import com.yas.customer.config.KeycloakPropsConfig;
import com.yas.commonlibrary.exception.AccessDeniedException;
import com.yas.commonlibrary.exception.WrongEmailFormatException;
import com.yas.customer.viewmodel.customer.CustomerAdminVm;
import com.yas.customer.viewmodel.customer.CustomerListVm;
import com.yas.customer.viewmodel.customer.CustomerPostVm;
import com.yas.customer.viewmodel.customer.CustomerProfileRequestVm;
import com.yas.customer.viewmodel.customer.CustomerVm;
import com.yas.customer.viewmodel.customer.GuestUserVm;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import javax.ws.rs.core.Response;
import com.yas.customer.config.KeycloakPropsConfig;
import com.yas.customer.viewmodel.customer.*;
import jakarta.ws.rs.core.Response;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.keycloak.admin.client.Keycloak;
import org.keycloak.admin.client.resource.RealmResource;
import org.keycloak.admin.client.resource.RoleMappingResource;
import org.keycloak.admin.client.resource.RoleResource;
import org.keycloak.admin.client.resource.RoleScopeResource;
import org.keycloak.admin.client.resource.RolesResource;
import org.keycloak.admin.client.resource.UserResource;
import org.keycloak.admin.client.resource.UsersResource;
import org.keycloak.admin.client.resource.*;
import org.keycloak.representations.idm.RoleRepresentation;
import org.keycloak.representations.idm.UserRepresentation;
import org.mockito.ArgumentCaptor;

import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import static com.yas.customer.util.SecurityContextUtils.setUpSecurityContext;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.*;

class CustomerServiceTest {

private UsersResource usersResource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
import java.io.IOException;
import java.io.InputStream;
import javax.imageio.ImageIO;
import javax.ws.rs.core.MediaType;

import jakarta.ws.rs.core.MediaType;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down
31 changes: 16 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.2</version>
<version>3.3.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.yas</groupId>
Expand Down Expand Up @@ -49,22 +49,23 @@
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.projectKey>nashtech-garage_yas-yas-parent</sonar.projectKey>
<springdoc-openapi-starter-webmvc-ui.version>2.0.2</springdoc-openapi-starter-webmvc-ui.version>
<org.mapstruct.version>1.4.1.Final</org.mapstruct.version>
<org.lombok.version>1.18.30</org.lombok.version>
<org.mapstruct.version> 1.6.2</org.mapstruct.version>
<org.lombok.version>1.18.34</org.lombok.version>
<lombok-mapstruct-binding.version>0.2.0</lombok-mapstruct-binding.version>
<logstash-logback-encoder.version>7.4</logstash-logback-encoder.version>
<opentelemetry-logback.vesion>1.30.0-alpha</opentelemetry-logback.vesion>
<logstash-logback-encoder.version>8.0</logstash-logback-encoder.version>
<opentelemetry-logback.vesion>2.9.0-alpha</opentelemetry-logback.vesion>
<spring-cloud.version>2023.0.3</spring-cloud.version>
<springdoc-openapi-starter-webmvc-ui.version>2.0.2</springdoc-openapi-starter-webmvc-ui.version>
<keycloak-spring-security-adapter.version>21.0.2</keycloak-spring-security-adapter.version>
<org.keycloak.version>16.1.0</org.keycloak.version>
<commons-validator.version>1.7</commons-validator.version>
<org.elasticsearch.version>8.14.0</org.elasticsearch.version>
<springdoc-openapi-starter-webmvc-ui.version>2.6.0</springdoc-openapi-starter-webmvc-ui.version>
<keycloak-spring-security-adapter.version>25.0.3</keycloak-spring-security-adapter.version>
<org.keycloak.version>26.0.1</org.keycloak.version>
<keycloak-spring-boot-starter.version>25.0.3</keycloak-spring-boot-starter.version>
<commons-validator.version>1.9.0</commons-validator.version>
<org.elasticsearch.version>8.15.3</org.elasticsearch.version>
<paypal-checkout-sdk.version>2.0.0</paypal-checkout-sdk.version>
<testcontainers-keycloak.version>3.3.0</testcontainers-keycloak.version>
<rest-assured.version>5.4.0</rest-assured.version>
<instancio-junit.version>4.8.1</instancio-junit.version>
<opencsv.version>5.7.1</opencsv.version>
<testcontainers-keycloak.version>3.4.0</testcontainers-keycloak.version>
<rest-assured.version>5.5.0</rest-assured.version>
<instancio-junit.version>5.0.2</instancio-junit.version>
<opencsv.version>5.9</opencsv.version>
</properties>
<dependencyManagement>
<dependencies>
Expand Down Expand Up @@ -108,7 +109,7 @@
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-spring-boot-starter</artifactId>
<version>${org.keycloak.version}</version>
<version>${keycloak-spring-boot-starter.version}</version>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
Expand Down
Loading