Skip to content

Commit

Permalink
Merge branch 'main' into inventory-upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
rajadilipkolli authored Nov 18, 2024
2 parents 522e2e7 + 72ff258 commit 4321409
Show file tree
Hide file tree
Showing 40 changed files with 177 additions and 161 deletions.
6 changes: 3 additions & 3 deletions api-gateway/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

<properties>
<java.version>21</java.version>
<spring-cloud.version>2024.0.0-M2</spring-cloud.version>
<spring-cloud.version>2024.0.0-RC1</spring-cloud.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<springdoc-openapi.version>2.6.0</springdoc-openapi.version>
<springdoc-openapi.version>2.7.0-RC1</springdoc-openapi.version>

<spotless.version>2.43.0</spotless.version>
<properties-maven-plugin.version>1.2.1</properties-maven-plugin.version>
Expand All @@ -34,7 +34,7 @@
<jacoco.itReportFile>${jacoco.itReportFolder}/integrationTest.exec</jacoco.itReportFile>
<junit.utReportFolder>${project.testresult.directory}/test</junit.utReportFolder>
<junit.itReportFolder>${project.testresult.directory}/integrationTest</junit.itReportFolder>
<dependency-check-maven.version>11.0.0</dependency-check-maven.version>
<dependency-check-maven.version>11.1.0</dependency-check-maven.version>

<CI_DOCKER_USERNAME/>
<CI_DOCKER_PASSWORD/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Licensed under MIT License Copyright (c) 2021-2022 Raja Kolli.
import org.springframework.stereotype.Component;

@Component
public class DataInitializer {
class DataInitializer {

private static final Logger log = LoggerFactory.getLogger(DataInitializer.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Licensed under MIT License Copyright (c) 2021-2022 Raja Kolli.
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ApiGatewayConfiguration {
@Configuration(proxyBeanMethods = false)
class ApiGatewayConfiguration {

@Bean
RouteLocator gatewayRouter(RouteLocatorBuilder builder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Licensed under MIT License Copyright (c) 2021-2022 Raja Kolli.
import reactor.core.publisher.Mono;

@Component
public class LoggingFilter implements GlobalFilter {
class LoggingFilter implements GlobalFilter {

private static final Logger log = LoggerFactory.getLogger(LoggingFilter.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Licensed under MIT License Copyright (c) 2023 Raja Kolli.
import reactor.core.publisher.Mono;

@Configuration(proxyBeanMethods = false)
public class RateLimiterConfiguration {
class RateLimiterConfiguration {

@Bean
KeyResolver userKeyResolver() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Licensed under MIT License Copyright (c) 2022-2023 Raja Kolli.
security = @SecurityRequirement(name = "Authorization"))
@SecurityScheme(type = SecuritySchemeType.HTTP, scheme = "basic", name = "Authorization")
@AutoConfigureBefore(MultipleOpenApiSupportConfiguration.class)
public class SwaggerConfig {
class SwaggerConfig {

@Bean
@Lazy(value = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Licensed under MIT License Copyright (c) 2023 Raja Kolli.
import org.springframework.web.reactive.function.client.WebClient;

@Configuration(proxyBeanMethods = false)
public class WebClientConfiguration {
class WebClientConfiguration {

@Bean
@LoadBalanced
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ Licensed under MIT License Copyright (c) 2023 Raja Kolli.
package com.example.api.gateway.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.lang.NonNull;
import org.springframework.web.reactive.config.CorsRegistry;
import org.springframework.web.reactive.config.WebFluxConfigurer;

@Configuration(proxyBeanMethods = false)
public class WebFluxConfig implements WebFluxConfigurer {
class WebFluxConfig implements WebFluxConfigurer {

@Override
public void addCorsMappings(CorsRegistry registry) {
public void addCorsMappings(@NonNull CorsRegistry registry) {
registry.addMapping("/**")
.allowedMethods("GET", "POST", "OPTIONS", "HEAD", "PUT")
.allowedHeaders("Access-Control-Allow-Origin")
Expand Down
2 changes: 1 addition & 1 deletion catalog-service/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ services:

kafka:
container_name: kafka
image: apache/kafka:3.8.1
image: apache/kafka:3.9.0
extra_hosts: [ 'host.docker.internal:host-gateway' ]
hostname: broker
ports:
Expand Down
23 changes: 10 additions & 13 deletions catalog-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.5</version>
<version>3.4.0-RC1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example.catalogservice</groupId>
Expand All @@ -20,20 +20,20 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<java.version>21</java.version>
<spring-cloud.version>2023.0.3</spring-cloud.version>
<springdoc-openapi.version>2.6.0</springdoc-openapi.version>
<spring-cloud.version>2024.0.0-RC1</spring-cloud.version>
<springdoc-openapi.version>2.7.0-RC1</springdoc-openapi.version>

<org.mapstruct.version>1.6.2</org.mapstruct.version>
<org.mapstruct.version>1.6.3</org.mapstruct.version>

<project.testresult.directory>${project.build.directory}/test-results</project.testresult.directory>
<maven-checkstyle-plugin.version>3.6.0</maven-checkstyle-plugin.version>
<spotless.version>2.43.0</spotless.version>
<maven-pmd-plugin.version>3.16.0</maven-pmd-plugin.version>

<dependency-check-maven.version>11.0.0</dependency-check-maven.version>
<dependency-check-maven.version>11.1.0</dependency-check-maven.version>

<properties-maven-plugin.version>1.2.1</properties-maven-plugin.version>
<sonar-maven-plugin.version>4.0.0.4121</sonar-maven-plugin.version>
<sonar-maven-plugin.version>5.0.0.4389</sonar-maven-plugin.version>
<jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version>
<jacoco.minimum.coverage>0.80</jacoco.minimum.coverage>
<jacoco.utReportFolder>${project.build.directory}/jacoco/test</jacoco.utReportFolder>
Expand Down Expand Up @@ -90,11 +90,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<scope>provided</scope>
</dependency>

<!-- To fix Spring Cloud LoadBalancer is currently working with the default
cache.
Expand Down Expand Up @@ -229,11 +224,13 @@
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.12.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>mockwebserver</artifactId>
<version>4.12.0</version>
<scope>test</scope>
<exclusions>
<exclusion>
Expand Down Expand Up @@ -393,7 +390,7 @@
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>10.19.0</version>
<version>10.20.1</version>
</dependency>
</dependencies>
<configuration>
Expand Down Expand Up @@ -507,7 +504,7 @@
<configuration>
<java>
<googleJavaFormat>
<version>1.22.0</version>
<version>1.24.0</version>
<style>AOSP</style>
</googleJavaFormat>
<licenseHeader> <!-- specify either content or file, but not both -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,17 @@ Licensed under MIT License Copyright (c) 2023-2024 Raja Kolli.

package com.example.catalogservice;

import com.example.catalogservice.common.ContainersConfig;
import com.example.catalogservice.common.SQLContainerConfig;
import com.example.catalogservice.utils.AppConstants;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
import org.springframework.context.annotation.Bean;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.KafkaContainer;
import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.utility.DockerImageName;

@TestConfiguration(proxyBeanMethods = false)
public class TestCatalogServiceApplication {

@Bean
@ServiceConnection(name = "openzipkin/zipkin")
GenericContainer<?> zipkinContainer() {
return new GenericContainer<>(DockerImageName.parse("openzipkin/zipkin:latest"))
.withExposedPorts(9411)
.withReuse(true);
}

@Bean
@ServiceConnection
PostgreSQLContainer<?> postgreSqlContainer() {
return new PostgreSQLContainer<>("postgres:17-alpine").withReuse(true);
}

@Bean
@ServiceConnection
KafkaContainer kafkaContainer(DynamicPropertyRegistry dynamicPropertyRegistry) {
KafkaContainer kafkaContainer =
new KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka").withTag("7.6.2"))
.withKraft()
.withReuse(true);
dynamicPropertyRegistry.add(
"spring.cloud.stream.kafka.binder.brokers", kafkaContainer::getBootstrapServers);
return kafkaContainer;
}

public static void main(String[] args) {
System.setProperty("spring.profiles.active", "test");
SpringApplication.from(CatalogServiceApplication::main)
.with(TestCatalogServiceApplication.class)
.with(ContainersConfig.class, SQLContainerConfig.class)
.withAdditionalProfiles(AppConstants.PROFILE_TEST)
.run(args);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/***
<p>
Licensed under MIT License Copyright (c) 2021-2023 Raja Kolli.
Licensed under MIT License Copyright (c) 2021-2024 Raja Kolli.
</p>
***/

Expand All @@ -9,7 +9,6 @@ Licensed under MIT License Copyright (c) 2021-2023 Raja Kolli.
import static com.example.catalogservice.utils.AppConstants.PROFILE_TEST;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;

import com.example.catalogservice.TestCatalogServiceApplication;
import com.example.catalogservice.config.TestKafkaListenerConfig;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.resilience4j.circuitbreaker.CircuitBreakerRegistry;
Expand All @@ -24,7 +23,7 @@ Licensed under MIT License Copyright (c) 2021-2023 Raja Kolli.
@SpringBootTest(
webEnvironment = RANDOM_PORT,
properties = {"spring.cloud.config.enabled=false"},
classes = {TestCatalogServiceApplication.class, TestKafkaListenerConfig.class})
classes = {SQLContainerConfig.class, TestKafkaListenerConfig.class, ContainersConfig.class})
@AutoConfigureWebTestClient
@AutoConfigureObservability(tracing = false)
public abstract class AbstractIntegrationTest {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/***
<p>
Licensed under MIT License Copyright (c) 2024 Raja Kolli.
</p>
***/

package com.example.catalogservice.common;

import org.springframework.boot.devtools.restart.RestartScope;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
import org.springframework.context.annotation.Bean;
import org.springframework.test.context.DynamicPropertyRegistrar;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.kafka.KafkaContainer;
import org.testcontainers.utility.DockerImageName;

@TestConfiguration(proxyBeanMethods = false)
public class ContainersConfig {

@Bean
@ServiceConnection
@RestartScope
KafkaContainer kafkaContainer() {
return new KafkaContainer(DockerImageName.parse("apache/kafka-native").withTag("3.8.1"))
.withReuse(true);
}

@Bean
@ServiceConnection(name = "openzipkin/zipkin")
GenericContainer<?> zipkinContainer() {
return new GenericContainer<>(DockerImageName.parse("openzipkin/zipkin:latest"))
.withExposedPorts(9411)
.withReuse(true);
}

@Bean
DynamicPropertyRegistrar kafkaProperties(KafkaContainer kafkaContainer) {
return props ->
props.add(
"spring.cloud.stream.kafka.binder.brokers",
kafkaContainer::getBootstrapServers);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/***
<p>
Licensed under MIT License Copyright (c) 2024 Raja Kolli.
</p>
***/

package com.example.catalogservice.common;

import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
import org.springframework.context.annotation.Bean;
import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.utility.DockerImageName;

@TestConfiguration(proxyBeanMethods = false)
public class SQLContainerConfig {

@Bean
@ServiceConnection
PostgreSQLContainer<?> postgreSQLContainer() {
return new PostgreSQLContainer<>(DockerImageName.parse("postgres").withTag("17.1-alpine"))
.withDatabaseName("catalog-service")
.withReuse(true);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/***
<p>
Licensed under MIT License Copyright (c) 2021-2023 Raja Kolli.
Licensed under MIT License Copyright (c) 2021-2024 Raja Kolli.
</p>
***/

Expand All @@ -25,11 +25,11 @@ Licensed under MIT License Copyright (c) 2021-2023 Raja Kolli.
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.http.MediaType;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.reactive.server.WebTestClient;
import reactor.core.publisher.Mono;

Expand All @@ -39,7 +39,7 @@ class ProductControllerTest {

@Autowired private WebTestClient webTestClient;

@MockBean private ProductService productService;
@MockitoBean private ProductService productService;

private List<ProductResponse> productResponseList;

Expand Down
8 changes: 4 additions & 4 deletions config-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.5</version>
<version>3.4.0-RC1</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.example.microservices</groupId>
Expand All @@ -18,10 +18,10 @@

<properties>
<java.version>21</java.version>
<spring-cloud.version>2023.0.3</spring-cloud.version>
<spring-cloud.version>2024.0.0-RC1</spring-cloud.version>
<spotless.version>2.43.0</spotless.version>
<properties-maven-plugin.version>1.2.1</properties-maven-plugin.version>
<sonar-maven-plugin.version>4.0.0.4121</sonar-maven-plugin.version>
<sonar-maven-plugin.version>5.0.0.4389</sonar-maven-plugin.version>
<CI_DOCKER_PASSWORD />
<CI_DOCKER_USERNAME />
</properties>
Expand Down Expand Up @@ -154,7 +154,7 @@
<configuration>
<java>
<googleJavaFormat>
<version>1.22.0</version>
<version>1.24.0</version>
<style>AOSP</style>
</googleJavaFormat>
<licenseHeader>
Expand Down
Loading

0 comments on commit 4321409

Please sign in to comment.