Skip to content
Open
Show file tree
Hide file tree
Changes from 13 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
10 changes: 7 additions & 3 deletions backoffice-bff/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@
<sonar.projectKey>nashtech-garage_yas-backoffice-bff</sonar.projectKey>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
<artifactId>spring-cloud-starter-gateway-server-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
<artifactId>spring-boot-starter-security-oauth2-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -41,4 +45,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,13 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpHeaders;
import org.springframework.http.server.reactive.ServerHttpRequestDecorator;
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebFilter;


@SpringBootApplication
@EnableWebFluxSecurity
public class Application {

// TODO remove this bean after https://github.com/spring-projects/spring-security/issues/15989#issuecomment-2442660753 is fixed
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
WebFilter writeableHeaders() {
return (exchange, chain) -> {
HttpHeaders writeableHeaders = HttpHeaders.writableHttpHeaders(
exchange.getRequest().getHeaders());
ServerHttpRequestDecorator writeableRequest = new ServerHttpRequestDecorator(
exchange.getRequest()) {
@Override
public HttpHeaders getHeaders() {
return writeableHeaders;
}
};
ServerWebExchange writeableExchange = exchange.mutate()
.request(writeableRequest)
.build();
return chain.filter(writeableExchange);
};
}

public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
Expand Down
27 changes: 27 additions & 0 deletions backoffice-bff/src/main/resources/application-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
spring:
cloud:
gateway:
server:
webflux:
default-filters:
- SaveSession
routes:
# Changes for your local development should not be committed
- id: api_servicename_local
uri: http://localhost:8085
predicates:
- Path=/api/servicename/**
filters:
- RewritePath=/api/(?<segment>.*), /$\{segment}
- TokenRelay=
- id: api
uri: http://api.yas.local
predicates:
- Path=/api/**
filters:
- RewritePath=/api/(?<segment>.*), /$\{segment}
- TokenRelay=
- id: nextjs
uri: http://localhost:3000
predicates:
- Path=/**
20 changes: 20 additions & 0 deletions backoffice-bff/src/main/resources/application-prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
spring:
cloud:
gateway:
server:
webflux:
default-filters:
- SaveSession
routes:
- id: api
uri: http://nginx
predicates:
- Path=/api/**
filters:
- DedupeResponseHeader=Origin Access-Control-Request-Method Access-Control-Request-Headers
- TokenRelay=
- StripPrefix=1
- id: nextjs
uri: http://backoffice-nextjs:3000
predicates:
- Path=/**
53 changes: 1 addition & 52 deletions backoffice-bff/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,55 +40,4 @@ management:
application: ${spring.application.name}
logging:
pattern:
level: "%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]"
---
spring:
config:
activate:
on-profile: "dev"
cloud:
gateway:
default-filters:
- SaveSession
routes:
# Changes for your local development should not be committed
- id: api_servicename_local
uri: http://localhost:8085
predicates:
- Path=/api/servicename/**
filters:
- RewritePath=/api/(?<segment>.*), /$\{segment}
- TokenRelay=
- id: api
uri: http://api.yas.local
predicates:
- Path=/api/**
filters:
- RewritePath=/api/(?<segment>.*), /$\{segment}
- TokenRelay=
- id: nextjs
uri: http://localhost:3000
predicates:
- Path=/**
---
spring:
config:
activate:
on-profile: "prod"
cloud:
gateway:
default-filters:
- SaveSession
routes:
- id: api
uri: http://nginx
predicates:
- Path=/api/**
filters:
- DedupeResponseHeader=Origin Access-Control-Request-Method Access-Control-Request-Headers
- TokenRelay=
- StripPrefix=1
- id: nextjs
uri: http://backoffice-nextjs:3000
predicates:
- Path=/**
level: "%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]"
18 changes: 14 additions & 4 deletions cart/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<artifactId>spring-boot-starter-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
<artifactId>spring-boot-starter-security-oauth2-resource-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -46,8 +46,18 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-liquibase</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.yas</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,19 @@
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.context.annotation.Import;
import org.springframework.http.HttpStatus;

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@Import(IntegrationTestConfiguration.class)
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
class CartItemControllerIT extends AbstractControllerIT {

@Autowired
private CartItemRepository cartItemRepository;

@MockBean
@MockitoBean
private ProductService productService;

private ProductThumbnailVm existingProduct;
Expand Down
4 changes: 2 additions & 2 deletions cart/src/it/java/com/yas/cart/service/ProductServiceIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.test.context.bean.override.mockito.MockitoSpyBean;
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
import org.springframework.context.annotation.ComponentScan;
import org.testcontainers.containers.PostgreSQLContainer;
Expand All @@ -25,7 +25,7 @@ class ProductServiceIT {
@Container
@ServiceConnection
static PostgreSQLContainer<?> postgresContainer = new PostgreSQLContainer<>("postgres:16");
@SpyBean
@MockitoSpyBean
private ProductService productService;
@Autowired
private CircuitBreakerRegistry circuitBreakerRegistry;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.yas.cart.config;

import java.util.Optional;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.persistence.autoconfigure.EntityScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.domain.AuditorAware;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class ProductService extends AbstractCircuitBreakFallbackHandler {
@CircuitBreaker(name = "restCircuitBreaker", fallbackMethod = "handleProductThumbnailFallback")
public List<ProductThumbnailVm> getProducts(List<Long> ids) {
final URI url = UriComponentsBuilder
.fromHttpUrl(serviceUrlConfig.product())
.fromUriString(serviceUrlConfig.product())
.path("/storefront/products/list-featured")
.queryParam("productId", ids)
.build()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
package com.yas.cart.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import tools.jackson.databind.ObjectMapper;
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tools.jackson.databind.ObjectMapper is imported here, but the repo doesn't define a tools.jackson package. This will not compile and also won't match Spring's com.fasterxml.jackson.databind.ObjectMapper bean; switch the import back to the real Jackson package.

Suggested change
import tools.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectMapper;

Copilot uses AI. Check for mistakes.
import org.springframework.boot.security.oauth2.server.resource.autoconfigure.servlet.OAuth2ResourceServerAutoConfiguration;
import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest;
import org.springframework.test.context.ContextConfiguration;
import com.yas.cart.service.CartItemService;
import com.yas.cart.viewmodel.CartItemDeleteVm;
import com.yas.cart.viewmodel.CartItemGetVm;
import com.yas.cart.viewmodel.CartItemPostVm;
import com.yas.cart.viewmodel.CartItemPutVm;
import com.yas.commonlibrary.exception.ApiExceptionHandler;
import jakarta.ws.rs.core.MediaType;
import org.springframework.http.MediaType;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;

Expand All @@ -29,9 +28,11 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@ExtendWith(SpringExtension.class)
@WebMvcTest
@ContextConfiguration(classes = {CartItemController.class, ApiExceptionHandler.class})
@WebMvcTest(excludeAutoConfiguration = OAuth2ResourceServerAutoConfiguration.class)
@ContextConfiguration(classes = {
CartItemController.class,
ApiExceptionHandler.class
})
@AutoConfigureMockMvc(addFilters = false)
class CartItemControllerTest {

Expand All @@ -44,7 +45,7 @@ class CartItemControllerTest {
@Autowired
private ObjectMapper objectMapper;

@MockBean
@MockitoBean
private CartItemService cartItemService;

@Nested
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void getProducts_NormalCase_ReturnProductThumbnailVms() {

List<Long> ids = List.of(1L, 2L, 3L);
URI url = UriComponentsBuilder
.fromHttpUrl("http://api.yas.local/media")
.fromUriString("http://api.yas.local/media")
.path("/storefront/products/list-featured")
.queryParam("productId", ids)
.build()
Expand Down
16 changes: 10 additions & 6 deletions common-library/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-authorization-server</artifactId>
<artifactId>spring-boot-starter-security-oauth2-authorization-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<artifactId>spring-boot-starter-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
<artifactId>spring-boot-starter-aspectj</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -41,11 +41,15 @@
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.retry</groupId>
<artifactId>spring-retry</artifactId>
</dependency>

<!-- Kafka Dependencies -->
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-kafka</artifactId>
</dependency>
<dependency>
<groupId>com.opencsv</groupId>
Expand All @@ -56,7 +60,7 @@
<!-- Test Dependency -->
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>kafka</artifactId>
<artifactId>testcontainers-kafka</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Loading
Loading