Skip to content
Open
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
162 changes: 89 additions & 73 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,80 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>4.0.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.CSO2</groupId>
<artifactId>product-catalogue-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>product-catalogue-service</name>
<description>product-catalogue-service of CSO2</description>
<properties>
<java.version>17</java.version>
<lombok.version>1.18.42</lombok.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.5</version> <relativePath/>
</parent>
<groupId>com.CSO2</groupId>
<artifactId>product-catalogue-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>product-catalogue-service</name>
<description>product-catalogue-service of CSO2</description>

<properties>
<java.version>17</java.version>
<lombok.version>1.18.42</lombok.version>
<spring-cloud.version>2023.0.0</spring-cloud.version> </properties>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-vault-config</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
4 changes: 3 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
spring.application.name=product-catalogue-service
server.port=${SERVER_PORT:8082}

# MongoDB Configuration (override via env vars in production)
# MongoDB Configuration
# URI is injected at runtime from HashiCorp Vault (secret/cso2/services/product-catalogue-service-mongo)
# In K8s: DATABASE_PASSWORD env var is populated from Vault, then MONGODB_URI is constructed
spring.data.mongodb.uri=${MONGODB_URI:mongodb://localhost:27017/CSO2_product_catalogue_service}
29 changes: 29 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# --- Product Catalogue Service ---
spring:
application:
name: product-catalogue-service

# 1. Load Vault
config:
import: "optional:vault://"

# 2. Vault Config
cloud:
vault:
enabled: true
uri: http://localhost:8200
token: my-root-token
kv:
enabled: true
backend: kv
default-context: cs02-app
authentication: TOKEN

# 3. MongoDB Config (Using a unique key for this service)
data:
mongodb:
uri: ${product_mongodb_uri:mongodb://localhost:27017/CSO2_product_catalogue_service}

# --- Server Port ---
server:
port: 8082
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.CSO2.product_catalogue_service.dto.request.CompatibilityCheckRequest;
import com.CSO2.product_catalogue_service.dto.response.BuilderSuggestionDTO;
import com.CSO2.product_catalogue_service.service.BuilderService;
import tools.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.CSO2.product_catalogue_service.model.Category;
import com.CSO2.product_catalogue_service.service.CategoryService;
import tools.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import com.CSO2.product_catalogue_service.dto.response.ProductListDTO;
import com.CSO2.product_catalogue_service.model.Product;
import com.CSO2.product_catalogue_service.service.ProductService;
import tools.jackson.databind.ObjectMapper;
// ✅ FIXED: Using the standard Jackson library
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand Down Expand Up @@ -130,8 +131,8 @@ void createProduct_ShouldReturnCreatedProduct() throws Exception {
when(productService.createProduct(any(ProductCreateRequest.class))).thenReturn(product);

mockMvc.perform(post("/api/products")
.contentType(MediaType.APPLICATION_JSON)
.content(objectMapper.writeValueAsString(request)))
.contentType(MediaType.APPLICATION_JSON)
.content(objectMapper.writeValueAsString(request)))
.andExpect(status().isOk())
.andExpect(jsonPath("$.id").value("1"))
.andExpect(jsonPath("$.name").value("New Product"));
Expand Down Expand Up @@ -162,4 +163,4 @@ protected void writeInternal(Object o, HttpOutputMessage outputMessage)
objectMapper.writeValue(outputMessage.getBody(), o);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.CSO2.product_catalogue_service.model.Review;
import com.CSO2.product_catalogue_service.repository.ReviewRepository;
import com.CSO2.product_catalogue_service.service.ReviewService;
import tools.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand Down