Skip to content

Commit 6a0304f

Browse files
committed
added create order post request endpoint, added migrations for create order, added the repository, service and controller layer dor creating an order, added global exceptions like ordernotfound, invalid payload, created models, added mock security
1 parent 4c8c3de commit 6a0304f

32 files changed

Lines changed: 707 additions & 6 deletions
Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,52 @@
1-
name: order-service.yml
1+
name: Order Service
22
on:
3+
push:
4+
paths:
5+
- order-service/**
6+
branches:
7+
- "**"
8+
pull_request:
9+
paths:
10+
- order-service/**
311

412
jobs:
13+
build:
14+
name: Build
15+
runs-on: ubuntu-latest
16+
env:
17+
working-directory: ./order-service
18+
defaults:
19+
run:
20+
working-directory: ${{env.working-directory}}
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Setup Java 21
25+
uses: actions/setup-java@v4
26+
with:
27+
distribution: 'temurin'
28+
java-version: '21'
29+
cache: 'maven'
30+
31+
- name: Make Maven wrapper executable
32+
run: chmod +x ./mvnw
33+
34+
- name: Applying Spotless Plugin
35+
run: ./mvnw spotless:apply
36+
37+
- name: Build with Maven
38+
run: ./mvnw -ntp verify
39+
40+
- if: ${{github.ref=='refs/heads/main'}}
41+
name: Login to Docker hub
42+
uses: docker/login-action@v3
43+
with:
44+
username: ${{secrets.DOCKERHUB_USERNAME}}
45+
password: ${{secrets.DOCKERHUB_TOKEN}}
46+
47+
- if: ${{github.ref=='refs/heads/main'}}
48+
name: Build and Publish Docker Image
49+
run: |
50+
./mvnw spring-boot:build-image -DskipTests
51+
echo "Pushing the image $DOCKER_IMAGE_NAME to Docker hub...."
52+
docker push ${{secrets.DOCKERHUB_USERNAME}}/bookstore-order-service

.idea/dataSources.xml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/data_source_mapping.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/encodings.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/sqldialects.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

catalog-service/src/main/java/com/eyepatch/works/catalogservice/domain/ProductNotFoundException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.eyepatch.works.catalogservice.domain;
22

3-
public class ProductNotFoundException extends RuntimeException{
3+
public class ProductNotFoundException extends RuntimeException{
44
public ProductNotFoundException(String message){
55
super(message);
66
}

catalog-service/src/main/java/com/eyepatch/works/catalogservice/web/exception/GlobalExceptionHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
1111

1212
@RestControllerAdvice
13-
public class GlobalException extends ResponseEntityExceptionHandler {
13+
public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
1414
private static final URI NOT_FOUND_TYPE = URI.create("https://api.bookstore.com/errors/not-found");
1515
private static final URI ISE_FOUND_TYPE = URI.create("https://api.bookstore.com/errors/server-error");
1616
static final String SERVICE_NAME = "catalog-service";

catalog-service/src/test/java/com/eyepatch/works/catalogservice/domain/ProductRepositoryTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ public class ProductRepositoryTest {
2121
@Autowired
2222
private ProductRepository productRepository;
2323

24+
@Test
25+
void shouldGetAllProducts() {
26+
List<ProductEntity> productList = productRepository.findAll();
27+
assertThat(productList).hasSize(15);
28+
}
2429

2530
@Test
2631
void shouldGetProductByCode() {

deployment/docker-compose/infra.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,44 @@ services:
1515
interval: 10s
1616
timeout: 5s
1717
retries: 5
18+
deploy:
19+
resources:
20+
limits:
21+
memory: 500m
22+
23+
order-db:
24+
image: postgres:16-alpine
25+
container_name: order-db
26+
environment:
27+
- POSTGRES_USER=postgres
28+
- POSTGRES_PASSWORD=postgres
29+
- POSTGRES_DB=postgres
30+
ports:
31+
- "25432:5432"
32+
healthcheck:
33+
test: [ 'CMD-SHELL','pg_isready -U postgres' ]
34+
interval: 10s
35+
timeout: 5s
36+
retries: 5
37+
deploy:
38+
resources:
39+
limits:
40+
memory: 500m
41+
42+
bookstore-rabbitmq:
43+
image: rabbitmq:3.12.11-management
44+
container_name: bookstore-rabbitmq
45+
environment:
46+
- RABBITMQ_DEFAULT_USER=guest
47+
- RABBITMQ_DEFAULT_PASS=guest
48+
ports:
49+
- "5672:5672"
50+
- "15672:15672"
51+
healthcheck:
52+
test: rabbitmq-diagnostics check_port_connectivity
53+
interval: 30s
54+
timeout: 30s
55+
retries: 10
1856
deploy:
1957
resources:
2058
limits:

0 commit comments

Comments
 (0)