Application revamp
This commit is contained in:
31
.github/ISSUE_TEMPLATE/bug_report.md
vendored
31
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -1,31 +0,0 @@
|
||||
---
|
||||
name: Bug report 🐛
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Desktop (please complete the following information):**
|
||||
- OS: [e.g. Ubuntu 21.04]
|
||||
- Docker version: [e.g. Docker version 20.10.12]
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
5
.github/ISSUE_TEMPLATE/config.yml
vendored
5
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -1,5 +0,0 @@
|
||||
blank_issues_enabled: true
|
||||
contact_links:
|
||||
- name: Ask a question ❓
|
||||
url: https://github.com/Rviewer-Challenges/skeleton-java-spring-rest/discussions/new
|
||||
about: Ask a question or request support for using this skeleton
|
||||
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@@ -1,20 +0,0 @@
|
||||
---
|
||||
name: Feature request ✨
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
BIN
.github/rviewer_logo--dark.png
vendored
BIN
.github/rviewer_logo--dark.png
vendored
Binary file not shown.
|
Before Width: | Height: | Size: 42 KiB |
70
.github/workflows/sonarqube-scanner.yaml
vendored
70
.github/workflows/sonarqube-scanner.yaml
vendored
@@ -1,70 +0,0 @@
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- devel
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- reopened
|
||||
- synchronize
|
||||
branches:
|
||||
- main
|
||||
- devel
|
||||
|
||||
jobs:
|
||||
secrets-gate:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
ok: ${{ steps.check-secrets.outputs.ok }}
|
||||
steps:
|
||||
- name: check for secrets needed to run SonarQube
|
||||
id: check-secrets
|
||||
run: |
|
||||
if [ ! -z "${{ secrets.SONAR_TOKEN }}" ] && [ ! -z "${{ secrets.SONAR_HOST_URL }}" ]; then
|
||||
echo "::set-output name=ok::true"
|
||||
fi
|
||||
|
||||
sonarqube:
|
||||
needs:
|
||||
- secrets-gate
|
||||
if: ${{ needs.secrets-gate.outputs.ok == 'true' }}
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
postgres-skeleton-db:
|
||||
image: postgres
|
||||
env:
|
||||
POSTGRES_DB: postgres_rv_database
|
||||
POSTGRES_USER: rv_user
|
||||
POSTGRES_PASSWORD: rv_password
|
||||
options: >-
|
||||
--health-cmd pg_isready
|
||||
--health-interval 10s
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
ports:
|
||||
- 5432:5432
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 17
|
||||
|
||||
- uses: gradle/gradle-build-action@v2
|
||||
with:
|
||||
gradle-version: 7.4.2
|
||||
|
||||
- name: Gradle execute tests
|
||||
run: gradle clean build
|
||||
|
||||
- name: SonarQube Scan
|
||||
uses: sonarsource/sonarqube-scan-action@master
|
||||
with:
|
||||
args: >
|
||||
-Dsonar.projectKey=${{ github.event.repository.name }}
|
||||
env:
|
||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
|
||||
@@ -1,77 +0,0 @@
|
||||
<img align="left" width="150" height="150" src=".github/rviewer_logo--dark.png" />
|
||||
|
||||
## Rviewer skeleton: Java, Spring & PostgreSQL
|
||||
|
||||
[](https://twitter.com/Rviewer_/)
|
||||
|
||||
[](https://discord.gg/VVN4ur8FaQ)
|
||||
|
||||
<br/>
|
||||
|
||||
This repository is a Java skeleton with Spring & PostgreSQL designed for quickly getting started developing an API.
|
||||
Check the [Getting Started](#getting-started) for full details.
|
||||
|
||||
## Technologies
|
||||
|
||||
* [Java 18](https://openjdk.java.net/projects/jdk/18/)
|
||||
* [Gradle 7](https://docs.gradle.org/7.0/release-notes.html)
|
||||
* [Spring boot](https://spring.io/projects/spring-boot)
|
||||
* [Lombok](https://projectlombok.org/)
|
||||
* [Junit](https://junit.org/junit5/)
|
||||
* [JaCoCo](https://docs.gradle.org/current/userguide/jacoco_plugin.html)
|
||||
* [Docker](https://www.docker.com/)
|
||||
* [Make](https://www.gnu.org/software/make/manual/make.html)
|
||||
|
||||
## Getting Started
|
||||
|
||||
Within the [Makefile](Makefile) you can handle the entire flow to get everything up & running:
|
||||
|
||||
1. Install `make` on your computer, if you do not already have it.
|
||||
2. Start the application: `make up`
|
||||
3. Run the application tests: `make test`
|
||||
|
||||
As you could see on the [Makefile](Makefile) script and the [Docker-Compose File](docker-compose.yml), the whole API
|
||||
is containerized with Docker and the API is using the internal DNS to connect with the PostgreSQL instance.
|
||||
|
||||
Go to `http://127.0.0.1:8080/ping` to see that everything is up & running!
|
||||
|
||||
## Overview
|
||||
|
||||
This skeleton is based on
|
||||
a [Clean Architecture](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html) approach, so you
|
||||
could find the first basic layers:
|
||||
|
||||
> You could find here two amazing articles ([here](https://www.educative.io/blog/clean-architecture-tutorial)
|
||||
> and [here](https://www.freecodecamp.org/news/modern-clean-architecture/)) explaining the Clean Architecture with Java!
|
||||
> (credits to [@bertilMuth](https://twitter.com/BertilMuth) and [@ryanthelin](https://dev.to/ryanthelin)).
|
||||
|
||||
### Infrastructure
|
||||
|
||||
Here you will find the different files to interact with the outside. In this folder you there are two different folders:
|
||||
|
||||
* `controllers`: Here you will have the classes that handle the REST endpoints and the Request/Response
|
||||
* `persistence`: Here it is the persistence layer, which interact with the PostgreSQL database, decoupling the rest of
|
||||
the application
|
||||
|
||||
You can use this as a starting point to continue with this architecture, or adapt it to your preferences.
|
||||
|
||||
### Domain
|
||||
|
||||
Any of your domain Entities, or Services, that models your business logic. These classes should be completely isolated
|
||||
of any external dependency or framework, but interact with them. This layer should follow the Dependency Inversion
|
||||
principle.
|
||||
|
||||
## Support
|
||||
|
||||
If you are having problems or need anything else, please let us know by
|
||||
[raising a new issue](https://github.com/Rviewer-Challenges/skeleton-java-spring-rest/issues/new/choose).
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed with the [MIT license](LICENSE).
|
||||
|
||||
---
|
||||
|
||||
<p align="center">
|
||||
Made with ❤️ by <a href="https://rviewer.io">Rviewer</a>
|
||||
</p>
|
||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 Rviewer
|
||||
Copyright (c) 2022 droideparanoico
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
4
Makefile
4
Makefile
@@ -4,9 +4,9 @@ down:
|
||||
docker-compose down
|
||||
|
||||
up:
|
||||
docker-compose run -d -p "8080:8080" java-skeleton-api gradle clean build bootRun -x test
|
||||
docker-compose run -d -p "8080:8080" java-cartchain-api gradle clean build bootRun -x test
|
||||
|
||||
test:
|
||||
docker-compose run --rm --no-deps -p "8080:8080" java-skeleton-api gradle test
|
||||
docker-compose run --rm --no-deps -p "8080:8080" java-cartchain-api gradle test
|
||||
|
||||
coverage: test
|
||||
|
||||
76
README.md
Normal file
76
README.md
Normal file
@@ -0,0 +1,76 @@
|
||||
# CartChain
|
||||
|
||||
Proof of concept for an e-commerce API implementing blockchain technology by using a simple private chain (no mining)
|
||||
|
||||
## How it works?
|
||||
|
||||
The aim of this API is to manage a shopping cart of an ecommerce website. So, through it, the client will be
|
||||
able to request and create, update or delete any item in the current cart.
|
||||
|
||||
Every action of the API will generate a new _Block_ on the _Blockchain_ in order to create a history and persist the
|
||||
information, so we can retrieve it later, but also keeps a history of which items have the user added to the cart.
|
||||
|
||||
### Workflow
|
||||
|
||||
The workflow of this API is as follows:
|
||||
|
||||
* Create
|
||||
|
||||
1. Create request is received
|
||||
2. Check if the `id` for a Cart is not already used
|
||||
1. If it has been used we return error
|
||||
2. If it has not been used, we create the cart with the given item and generates a new Block to add to the
|
||||
Blockchain
|
||||
3. Add the new _Block_ to the _Blockchain_ with the current information of this Cart
|
||||
|
||||
* Update
|
||||
|
||||
1. Update request is received
|
||||
2. Check if the `id` for a Cart exists
|
||||
1. If not exists return error
|
||||
2. If exist retrieve it
|
||||
3. Update the items in the cart and generate a new Block with the information
|
||||
4. Add the new _Block_ to the _Blockchain_
|
||||
|
||||
* Delete
|
||||
|
||||
1. Delete request is received
|
||||
2. Check if the `id` for a Cart exists
|
||||
1. If not exists return error
|
||||
2. If exist retrieve it
|
||||
3. Remove cart information and create a new _Block_
|
||||
4. Add the new _Block_ to the _Blockchain_
|
||||
|
||||
## Technical Considerations
|
||||
|
||||
### Stack
|
||||
* [Java 17](https://openjdk.java.net/projects/jdk/17/)
|
||||
* [Gradle 7](https://docs.gradle.org/7.0/release-notes.html)
|
||||
* [Spring boot](https://spring.io/projects/spring-boot)
|
||||
* [Lombok](https://projectlombok.org/)
|
||||
* [Junit](https://junit.org/junit5/)
|
||||
* [JaCoCo](https://docs.gradle.org/current/userguide/jacoco_plugin.html)
|
||||
* [Docker](https://www.docker.com/)
|
||||
* [Make](https://www.gnu.org/software/make/manual/make.html)
|
||||
|
||||
### Architecture
|
||||
|
||||
This app is implemented using hexagonal architecture (ports & adapters) and DDD approach.
|
||||
|
||||
The architecture helps to have a decoupled code and being easy to modify or extend it. Following diagram hints how this is achieved:
|
||||
|
||||

|
||||
|
||||
More info at [Hexagonal Architecture](https://alistair.cockburn.us/hexagonal-architecture/)
|
||||
### Getting Started
|
||||
|
||||
Within the [Makefile](Makefile) you can handle the entire flow to get everything up & running:
|
||||
|
||||
1. Install `make` on your computer, if you do not already have it.
|
||||
2. Start the application: `make up`
|
||||
3. Run the application tests: `make test`
|
||||
|
||||
Go to [localhost:8080/swagger-ui/index.html](http://localhost:8080/swagger-ui/index.html) to see the API description.
|
||||
|
||||
As you can see on the [Makefile](Makefile) script and the [docker-Compose File](docker-compose.yml), the whole API
|
||||
is containerized with docker and the API is using the internal DNS to connect with the PostgreSQL instance.
|
||||
175
api.spec.yaml
175
api.spec.yaml
@@ -1,175 +0,0 @@
|
||||
openapi: 3.0.0
|
||||
info:
|
||||
title: Shopping Cart API
|
||||
description: |
|
||||
Shopping Cart API is a REST API responsible for manage the shopping car for an e-commerce with a Blockchain storage
|
||||
system, where the users could create, update and delete their cart.
|
||||
version: 1.0.0
|
||||
paths:
|
||||
/carts/{id}:
|
||||
get:
|
||||
summary: |
|
||||
This endpoint returns a cart for the given id.
|
||||
parameters:
|
||||
- name: id
|
||||
description: The id of the cart.
|
||||
required: true
|
||||
in: path
|
||||
schema:
|
||||
type: string
|
||||
format: uuid
|
||||
responses:
|
||||
'200':
|
||||
description: created
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/CreateCartRes'
|
||||
'404':
|
||||
description: Cart not found
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
error:
|
||||
type: string
|
||||
example: Cart not found for the given ID
|
||||
post:
|
||||
summary: |
|
||||
This endpoint creates a cart for the given id.
|
||||
parameters:
|
||||
- name: id
|
||||
description: The id of the cart.
|
||||
required: true
|
||||
in: path
|
||||
schema:
|
||||
type: string
|
||||
format: uuid
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/CreateCartReq'
|
||||
responses:
|
||||
'201':
|
||||
description: created
|
||||
'409':
|
||||
description: Already exists
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
error:
|
||||
type: string
|
||||
example: Invalid identifier.
|
||||
'400':
|
||||
description: Invalid body provided
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
error:
|
||||
type: string
|
||||
example: Invalid body provided, check the payload.
|
||||
patch:
|
||||
summary: |
|
||||
This endpoint updates totally or partially a cart for the given id.
|
||||
parameters:
|
||||
- name: id
|
||||
description: The id of the cart.
|
||||
required: true
|
||||
in: path
|
||||
schema:
|
||||
type: string
|
||||
format: uuid
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/UpdateCartReq'
|
||||
responses:
|
||||
'200':
|
||||
description: created
|
||||
'404':
|
||||
description: Not found
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
error:
|
||||
type: string
|
||||
example: Cart not found for the given id
|
||||
'400':
|
||||
description: Invalid body provided
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
error:
|
||||
type: string
|
||||
example: Invalid body provided, check the payload.
|
||||
delete:
|
||||
summary: |
|
||||
This endpoint deletes a cart for the given id.
|
||||
parameters:
|
||||
- name: id
|
||||
description: The id of the cart.
|
||||
required: true
|
||||
in: path
|
||||
schema:
|
||||
type: string
|
||||
format: uuid
|
||||
responses:
|
||||
'200':
|
||||
description: deleted
|
||||
'404':
|
||||
description: Cart not found
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
error:
|
||||
type: string
|
||||
example: Cart not found for the given ID
|
||||
components:
|
||||
schemas:
|
||||
CartItem:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
format: uuid
|
||||
name:
|
||||
type: string
|
||||
quantity:
|
||||
type: number
|
||||
price:
|
||||
type: number
|
||||
CartItems:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/CartItem'
|
||||
CreateCartReq:
|
||||
type: object
|
||||
properties:
|
||||
items:
|
||||
$ref: '#/components/schemas/CartItems'
|
||||
UpdateCartReq:
|
||||
properties:
|
||||
items:
|
||||
$ref: '#/components/schemas/CartItems'
|
||||
CreateCartRes:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
format: uuid
|
||||
items:
|
||||
$ref: '#/components/schemas/CartItems'
|
||||
|
||||
@@ -5,7 +5,7 @@ plugins {
|
||||
id 'jacoco'
|
||||
}
|
||||
|
||||
group = 'com.rviewer.skeletons'
|
||||
group = 'com.cartchain'
|
||||
version = '1.0.0'
|
||||
sourceCompatibility = '17'
|
||||
|
||||
@@ -25,9 +25,10 @@ dependencies {
|
||||
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-validation'
|
||||
implementation 'org.springdoc:springdoc-openapi-ui:1.6.11'
|
||||
compileOnly 'org.projectlombok:lombok'
|
||||
developmentOnly 'org.springframework.boot:spring-boot-devtools'
|
||||
testImplementation 'com.h2database:h2:2.1.212'
|
||||
testImplementation 'com.h2database:h2:2.1.214'
|
||||
runtimeOnly 'org.postgresql:postgresql'
|
||||
annotationProcessor 'org.projectlombok:lombok'
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||
|
||||
@@ -1,37 +1,40 @@
|
||||
version: '3.9'
|
||||
|
||||
services:
|
||||
java-skeleton-api:
|
||||
container_name: java-skeleton-api
|
||||
image: gradle:latest # this is due to some Mac M1 issues with Docker :_
|
||||
depends_on:
|
||||
- postgres-skeleton-db
|
||||
volumes:
|
||||
- "${PWD}:/home/gradle/project"
|
||||
- "rv-gradle-cache:/home/gradle/.gradle"
|
||||
working_dir: "/home/gradle/project"
|
||||
ports:
|
||||
- "8080:8080"
|
||||
networks:
|
||||
internal-net:
|
||||
java-cartchain-api:
|
||||
container_name: java-cartchain-api
|
||||
image: gradle:latest # this is due to some Mac M1 issues with Docker :_
|
||||
depends_on:
|
||||
- postgres-cartchain-db
|
||||
volumes:
|
||||
- "${PWD}:/home/gradle/project"
|
||||
- "gradle-cache:/home/gradle/.gradle"
|
||||
working_dir: "/home/gradle/project"
|
||||
ports:
|
||||
- "8080:8080"
|
||||
networks:
|
||||
internal-net:
|
||||
|
||||
postgres-skeleton-db:
|
||||
container_name: postgres-skeleton-db
|
||||
image: postgres:13.4-alpine
|
||||
restart: on-failure
|
||||
volumes:
|
||||
- rv-volume:/var/lib/postgresql/data
|
||||
ports:
|
||||
- "5432:5432"
|
||||
env_file:
|
||||
- postgres.dev.env
|
||||
networks:
|
||||
internal-net:
|
||||
postgres-cartchain-db:
|
||||
container_name: postgres-cartchain-db
|
||||
image: postgres:13.4-alpine
|
||||
restart: on-failure
|
||||
volumes:
|
||||
- volume:/var/lib/postgresql/data
|
||||
ports:
|
||||
- "5432:5432"
|
||||
environment:
|
||||
- POSTGRES_NAME=postgres-cartchain-db
|
||||
- POSTGRES_DB=postgres_database
|
||||
- POSTGRES_USER=user
|
||||
- POSTGRES_PASSWORD=password
|
||||
networks:
|
||||
internal-net:
|
||||
|
||||
volumes:
|
||||
rv-volume:
|
||||
rv-gradle-cache:
|
||||
volume:
|
||||
gradle-cache:
|
||||
|
||||
networks:
|
||||
internal-net:
|
||||
name: rv-skeleton-net
|
||||
internal-net:
|
||||
name: cartchain-net
|
||||
|
||||
234
gradlew
vendored
234
gradlew
vendored
@@ -1,234 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=${0##*/}
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
89
gradlew.bat
vendored
89
gradlew.bat
vendored
@@ -1,89 +0,0 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
BIN
hexagonal.png
Normal file
BIN
hexagonal.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 89 KiB |
@@ -1,4 +0,0 @@
|
||||
POSTGRES_NAME=postgres-skeleton-db
|
||||
POSTGRES_DB=postgres_rv_database
|
||||
POSTGRES_USER=rv_user
|
||||
POSTGRES_PASSWORD=rv_password
|
||||
115
readme.md
115
readme.md
@@ -1,115 +0,0 @@
|
||||
# Cartfidential
|
||||
|
||||
Within the current landscape of digital commerce, there is no such progress and there are still the same problems of
|
||||
scalability and performance with high traffic than some years ago. For this reason, we have decided to implement a new
|
||||
type of ecommerce based on the [Blockchain](https://builtin.com/blockchain) technology, creating a decentralized network
|
||||
to execute and store, in a decentralized way, the different processes of an ecommerce.
|
||||
|
||||
That's why you will be in charge of creating a very important part of it, the shopping cart.
|
||||
|
||||
## How it works?
|
||||
|
||||
The aim of this API is to manage a shopping cart of our ecommerce website. So, through it, the Frontend Team will be
|
||||
able to request and create, update or delete any item in the current cart.
|
||||
|
||||
Every action of the API will generate a new _Block_ on the _Blockchain_ in order to create a history and persist the
|
||||
information, so we can retrieve it later, but also keeps a history of which items have the user added to the cart.
|
||||
|
||||
You could find the API description on the OpenAPI description file.
|
||||
|
||||
### Workflow
|
||||
|
||||
The workflow of this API is as follows:
|
||||
|
||||
* Create
|
||||
|
||||
1. Create request is received
|
||||
2. Check if the `id` for a Cart is not already used
|
||||
1. If it has been used we return error
|
||||
2. If it has not been used, we create the cart with the given item and generates a new Block to add to the
|
||||
Blockchain
|
||||
3. Add the new _Block_ to the _Blockchain_ with the current information of this Cart
|
||||
|
||||
* Update
|
||||
|
||||
1. Update request is received
|
||||
2. Check if the `id` for a Cart exists
|
||||
1. If not exists return error
|
||||
2. If exist retrieve it
|
||||
3. Update the items in the cart and generate a new Block with the information
|
||||
4. Add the new _Block_ to the _Blockchain_
|
||||
|
||||
* Delete
|
||||
|
||||
1. Delete request is received
|
||||
2. Check if the `id` for a Cart exists
|
||||
1. If not exists return error
|
||||
2. If exist retrieve it
|
||||
3. Remove cart information and create a new _Block_
|
||||
4. Add the new _Block_ to the _Blockchain_
|
||||
|
||||
## Technical Considerations
|
||||
|
||||
Keep in mind the following:
|
||||
|
||||
1. Related with the Blockchain:
|
||||
1. The blockchain have a first block called 'genesis block', these block doesn't contain a reference of the previous
|
||||
block, usually is hardcoded on the software
|
||||
2. Every Block has multiple properties:
|
||||
1. timestamp: the timestamp for the moment when the block was created
|
||||
2. lastHash: hash of the previous block on the _blockchain_
|
||||
3. data: information we want to store in the block (in our case the votes)
|
||||
4. nonce: a unique number
|
||||
5. hash: a SHA256 string for the block, calculated concatenating the timestamp, lastHash, data and nonce.
|
||||
3. The implementation of the Blockchain must follow these contract:
|
||||
```
|
||||
Blockchain
|
||||
/** Adds new block to blockchain */
|
||||
addBlock(block: Block): Block
|
||||
/** The new blockchain that is a candidate for replacing the current blockchain */
|
||||
replace(blockchain: Blockchain): boolean
|
||||
/**
|
||||
* Validates the chain by checking if:
|
||||
* - Genesis Block hash match given blockchain genesis block hash
|
||||
* - every element's last hash value matches previous block's hash
|
||||
* - data hasn't been tampered (which will produce a different hash value)
|
||||
*/
|
||||
isValid(blockchain: Blockchain): boolean
|
||||
|
||||
Block
|
||||
/** Generate the first block for the chain */
|
||||
static getGenesisBlock(): Block
|
||||
/** Generate the hash for the given block */
|
||||
static generateHashFromBlock(block: Block): string
|
||||
```
|
||||
|
||||
## Technical requirements
|
||||
|
||||
* Create a **clean**, **maintainable** and **well-designed** code. We expect to see a good and clear architecture that
|
||||
allows to add or modify the solution without so much troubles.
|
||||
* **Test** your code until you are comfortable with it. We don't expect a 100% of Code Coverage but some tests that
|
||||
helps to have a more stable and confident base code.
|
||||
|
||||
To understand how you take decisions during the implementation, **please write a COMMENTS.md** file explaining some of
|
||||
the most important parts of the application. You would also be able to defend your code through
|
||||
[Rviewer](https://rviewer.io), once you submit your solution.
|
||||
|
||||
---
|
||||
|
||||
## How to submit your solution
|
||||
|
||||
* Push your code to the `devel` branch - we encourage you to commit regularly to show your thinking process was.
|
||||
* **Create a new Pull Request** to `main` branch & **merge it**.
|
||||
|
||||
Once merged you **won't be able to change or add** anything to your solution, so double-check that everything is as
|
||||
you expected!
|
||||
|
||||
Remember that **there is no countdown**, so take your time and implement a solution that you are proud!
|
||||
|
||||
---
|
||||
|
||||
<p align="center">
|
||||
If you have any feedback or problem, <a href="mailto:help@rviewer.io">let us know!</a> 🤘
|
||||
<br><br>
|
||||
Made with ❤️ by <a href="https://rviewer.io">Rviewer</a>
|
||||
</p>
|
||||
@@ -1 +1 @@
|
||||
rootProject.name = 'rviewer-skeleton-java-spring'
|
||||
rootProject.name = 'cartchain'
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
sonar.sources=src/main/java
|
||||
sonar.java.binaries=build/classes/java/
|
||||
sonar.java.libraries=build/libs/rviewer-skeleton-java-spring-1.0.0.jar
|
||||
sonar.language=java
|
||||
sonar.sourceEncoding=UTF-8
|
||||
sonar.coverage.jacoco.xmlReportPaths=build/reports/jacoco/test/jacocoTestReport.xml
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.rviewer.skeletons;
|
||||
package com.cartchain;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class RviewerSkeletonApplication {
|
||||
public class CartChainApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(RviewerSkeletonApplication.class, args);
|
||||
SpringApplication.run(CartChainApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.rviewer.skeletons.application.adapter;
|
||||
package com.cartchain.application.adapter;
|
||||
|
||||
import com.rviewer.skeletons.application.exception.CartAlreadyExistsException;
|
||||
import com.rviewer.skeletons.application.exception.CartNotFoundException;
|
||||
import com.rviewer.skeletons.domain.model.Cart;
|
||||
import com.rviewer.skeletons.domain.model.Item;
|
||||
import com.rviewer.skeletons.domain.ports.inbound.CartServicePort;
|
||||
import com.rviewer.skeletons.application.request.CreateCartReq;
|
||||
import com.rviewer.skeletons.application.request.UpdateCartReq;
|
||||
import com.cartchain.application.exception.CartAlreadyExistsException;
|
||||
import com.cartchain.application.exception.CartNotFoundException;
|
||||
import com.cartchain.application.request.CreateCartReq;
|
||||
import com.cartchain.application.request.UpdateCartReq;
|
||||
import com.cartchain.domain.model.Item;
|
||||
import com.cartchain.domain.model.Cart;
|
||||
import com.cartchain.domain.ports.inbound.CartServicePort;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.rviewer.skeletons.application.exception;
|
||||
package com.cartchain.application.exception;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.rviewer.skeletons.application.exception;
|
||||
package com.cartchain.application.exception;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.rviewer.skeletons.application.exception;
|
||||
package com.cartchain.application.exception;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.rviewer.skeletons.application.request;
|
||||
package com.cartchain.application.request;
|
||||
|
||||
import com.rviewer.skeletons.domain.model.Item;
|
||||
import com.cartchain.domain.model.Item;
|
||||
import lombok.Getter;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.rviewer.skeletons.application.request;
|
||||
package com.cartchain.application.request;
|
||||
|
||||
import com.rviewer.skeletons.domain.model.Item;
|
||||
import com.cartchain.domain.model.Item;
|
||||
import lombok.Getter;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.rviewer.skeletons.domain.exception;
|
||||
package com.cartchain.domain.exception;
|
||||
|
||||
public class HashGenerationException extends RuntimeException {
|
||||
public HashGenerationException(Throwable cause) {
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.rviewer.skeletons.domain.model;
|
||||
package com.cartchain.domain.model;
|
||||
|
||||
import com.rviewer.skeletons.domain.exception.HashGenerationException;
|
||||
import com.cartchain.domain.exception.HashGenerationException;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.rviewer.skeletons.domain.model;
|
||||
package com.cartchain.domain.model;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -13,9 +13,8 @@ public class Blockchain {
|
||||
return blockchainList;
|
||||
}
|
||||
|
||||
public Block addBlock(Block block) {
|
||||
public void addBlock(Block block) {
|
||||
blockchainList.add(block);
|
||||
return blockchainList.getLast();
|
||||
}
|
||||
|
||||
public Boolean replace(List<Block> blockchainList) {
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.rviewer.skeletons.domain.model;
|
||||
package com.cartchain.domain.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.rviewer.skeletons.domain.model;
|
||||
package com.cartchain.domain.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.rviewer.skeletons.domain.model;
|
||||
package com.cartchain.domain.model;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.rviewer.skeletons.domain.ports.inbound;
|
||||
package com.cartchain.domain.ports.inbound;
|
||||
|
||||
import com.rviewer.skeletons.domain.model.Cart;
|
||||
import com.cartchain.domain.model.Cart;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.rviewer.skeletons.domain.ports.outbound;
|
||||
package com.cartchain.domain.ports.outbound;
|
||||
|
||||
import com.rviewer.skeletons.domain.model.Cart;
|
||||
import com.cartchain.domain.model.Cart;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.rviewer.skeletons.domain.service;
|
||||
package com.cartchain.domain.service;
|
||||
|
||||
import com.rviewer.skeletons.domain.model.Block;
|
||||
import com.rviewer.skeletons.domain.model.Blockchain;
|
||||
import com.rviewer.skeletons.domain.model.Cart;
|
||||
import com.rviewer.skeletons.domain.ports.inbound.CartServicePort;
|
||||
import com.rviewer.skeletons.domain.ports.outbound.CartDatabasePort;
|
||||
import com.cartchain.domain.model.Block;
|
||||
import com.cartchain.domain.model.Blockchain;
|
||||
import com.cartchain.domain.model.Cart;
|
||||
import com.cartchain.domain.ports.inbound.CartServicePort;
|
||||
import com.cartchain.domain.ports.outbound.CartDatabasePort;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.rviewer.skeletons.infrastructure.database.adapter;
|
||||
package com.cartchain.infrastructure.database.adapter;
|
||||
|
||||
import com.rviewer.skeletons.domain.model.Cart;
|
||||
import com.rviewer.skeletons.domain.ports.outbound.CartDatabasePort;
|
||||
import com.rviewer.skeletons.infrastructure.database.dto.PostgresCart;
|
||||
import com.rviewer.skeletons.infrastructure.database.repository.PostgresCartRepository;
|
||||
import com.cartchain.domain.model.Cart;
|
||||
import com.cartchain.domain.ports.outbound.CartDatabasePort;
|
||||
import com.cartchain.infrastructure.database.dto.PostgresCart;
|
||||
import com.cartchain.infrastructure.database.repository.PostgresCartRepository;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Optional;
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.rviewer.skeletons.infrastructure.database.dto;
|
||||
package com.cartchain.infrastructure.database.dto;
|
||||
|
||||
import com.rviewer.skeletons.domain.model.Cart;
|
||||
import com.cartchain.domain.model.Cart;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.With;
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.rviewer.skeletons.infrastructure.database.dto;
|
||||
package com.cartchain.infrastructure.database.dto;
|
||||
|
||||
import com.rviewer.skeletons.domain.model.Item;
|
||||
import com.cartchain.domain.model.Item;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.With;
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.rviewer.skeletons.infrastructure.database.repository;
|
||||
package com.cartchain.infrastructure.database.repository;
|
||||
|
||||
import com.rviewer.skeletons.infrastructure.database.dto.PostgresCart;
|
||||
import com.cartchain.infrastructure.database.dto.PostgresCart;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
server.port=8080
|
||||
application.title=Cartfidential
|
||||
application.title=CartChain
|
||||
application.version=1.0.0
|
||||
|
||||
spring.sql.init.mode=always
|
||||
spring.datasource.username = rv_user
|
||||
spring.datasource.password = rv_password
|
||||
spring.datasource.driverClassName = org.postgresql.Driver
|
||||
spring.jpa.hibernate.ddl-auto = update
|
||||
spring.datasource.username=user
|
||||
spring.datasource.password=password
|
||||
spring.datasource.driverClassName=org.postgresql.Driver
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
|
||||
spring.datasource.url = jdbc:postgresql://localhost:5432/postgres_rv_database
|
||||
spring.datasource.url=jdbc:postgresql://postgres-cartchain-db:5432/postgres_database
|
||||
springdoc.api-docs.path=/api-docs
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
,------. ,--.
|
||||
| .--. ' ,--. ,--. `--' ,---. ,--. ,--. ,---. ,--.--.
|
||||
| '--'.' \ `' / ,--. | .-. : | |.'.| | | .-. : | .--'
|
||||
| |\ \ \ / | | \ --. | .'. | \ --. | |
|
||||
`--' '--' `--' `--' `----' '--' '--' `----' `--'
|
||||
/$$$$$$ /$$ /$$$$$$ /$$ /$$
|
||||
/$$__ $$ | $$ /$$__ $$| $$ |__/
|
||||
| $$ \__/ /$$$$$$ /$$$$$$ /$$$$$$ | $$ \__/| $$$$$$$ /$$$$$$ /$$ /$$$$$$$
|
||||
| $$ |____ $$ /$$__ $$|_ $$_/ | $$ | $$__ $$ |____ $$| $$| $$__ $$
|
||||
| $$ /$$$$$$$| $$ \__/ | $$ | $$ | $$ \ $$ /$$$$$$$| $$| $$ \ $$
|
||||
| $$ $$ /$$__ $$| $$ | $$ /$$| $$ $$| $$ | $$ /$$__ $$| $$| $$ | $$
|
||||
| $$$$$$/| $$$$$$$| $$ | $$$$/| $$$$$$/| $$ | $$| $$$$$$$| $$| $$ | $$
|
||||
\______/ \_______/|__/ \___/ \______/ |__/ |__/ \_______/|__/|__/ |__/
|
||||
|
||||
${application.title} - v${application.version}
|
||||
Powered by Rviewer
|
||||
@@ -1,11 +1,13 @@
|
||||
package com.rviewer.skeletons.application.adapter;
|
||||
package com.cartchain.application.adapter;
|
||||
|
||||
import com.cartchain.application.exception.CartAlreadyExistsException;
|
||||
import com.cartchain.application.exception.CartNotFoundException;
|
||||
import com.cartchain.application.exception.ControllerExceptionHandler;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.rviewer.skeletons.domain.model.Cart;
|
||||
import com.rviewer.skeletons.domain.model.Item;
|
||||
import com.rviewer.skeletons.domain.ports.inbound.CartServicePort;
|
||||
import com.rviewer.skeletons.application.exception.CartAlreadyExistsException;
|
||||
import com.rviewer.skeletons.application.exception.CartNotFoundException;
|
||||
import com.cartchain.domain.model.Cart;
|
||||
import com.cartchain.domain.model.Item;
|
||||
import com.cartchain.domain.ports.inbound.CartServicePort;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
@@ -21,7 +23,6 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.rviewer.skeletons.application.exception.ControllerExceptionHandler.INVALID_BODY;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -102,7 +103,7 @@ class CartControllerTest {
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isBadRequest())
|
||||
.andExpect(result -> assertTrue(result.getResolvedException() instanceof MethodArgumentNotValidException))
|
||||
.andExpect(result -> assertEquals(INVALID_BODY, result.getResponse().getContentAsString()));
|
||||
.andExpect(result -> Assertions.assertEquals(ControllerExceptionHandler.INVALID_BODY, result.getResponse().getContentAsString()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -116,7 +117,7 @@ class CartControllerTest {
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isBadRequest())
|
||||
.andExpect(result -> assertTrue(result.getResolvedException() instanceof HttpMessageNotReadableException))
|
||||
.andExpect(result -> assertEquals(INVALID_BODY, result.getResponse().getContentAsString()));
|
||||
.andExpect(result -> Assertions.assertEquals(ControllerExceptionHandler.INVALID_BODY, result.getResponse().getContentAsString()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -159,7 +160,7 @@ class CartControllerTest {
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isBadRequest())
|
||||
.andExpect(result -> assertTrue(result.getResolvedException() instanceof MethodArgumentNotValidException))
|
||||
.andExpect(result -> assertEquals(INVALID_BODY, result.getResponse().getContentAsString()));
|
||||
.andExpect(result -> Assertions.assertEquals(ControllerExceptionHandler.INVALID_BODY, result.getResponse().getContentAsString()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -173,7 +174,7 @@ class CartControllerTest {
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isBadRequest())
|
||||
.andExpect(result -> assertTrue(result.getResolvedException() instanceof HttpMessageNotReadableException))
|
||||
.andExpect(result -> assertEquals(INVALID_BODY, result.getResponse().getContentAsString()))
|
||||
.andExpect(result -> Assertions.assertEquals(ControllerExceptionHandler.INVALID_BODY, result.getResponse().getContentAsString()))
|
||||
;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.rviewer.skeletons.domain.model;
|
||||
package com.cartchain.domain.model;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.rviewer.skeletons.infrastructure.database.adapter;
|
||||
package com.cartchain.infrastructure.database.adapter;
|
||||
|
||||
import com.rviewer.skeletons.domain.model.Cart;
|
||||
import com.rviewer.skeletons.domain.model.Item;
|
||||
import com.rviewer.skeletons.infrastructure.database.dto.PostgresCart;
|
||||
import com.rviewer.skeletons.infrastructure.database.repository.PostgresCartRepository;
|
||||
import com.cartchain.infrastructure.database.dto.PostgresCart;
|
||||
import com.cartchain.infrastructure.database.repository.PostgresCartRepository;
|
||||
import com.cartchain.domain.model.Cart;
|
||||
import com.cartchain.domain.model.Item;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
@@ -1,5 +1,5 @@
|
||||
server.port=8080
|
||||
application.title=Cartfidential
|
||||
application.title=CartChain
|
||||
application.version=1.0.0
|
||||
|
||||
spring.datasource.driver-class-name=org.h2.Driver
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
,------. ,--.
|
||||
| .--. ' ,--. ,--. `--' ,---. ,--. ,--. ,---. ,--.--.
|
||||
| '--'.' \ `' / ,--. | .-. : | |.'.| | | .-. : | .--'
|
||||
| |\ \ \ / | | \ --. | .'. | \ --. | |
|
||||
`--' '--' `--' `--' `----' '--' '--' `----' `--'
|
||||
/$$$$$$ /$$ /$$$$$$ /$$ /$$
|
||||
/$$__ $$ | $$ /$$__ $$| $$ |__/
|
||||
| $$ \__/ /$$$$$$ /$$$$$$ /$$$$$$ | $$ \__/| $$$$$$$ /$$$$$$ /$$ /$$$$$$$
|
||||
| $$ |____ $$ /$$__ $$|_ $$_/ | $$ | $$__ $$ |____ $$| $$| $$__ $$
|
||||
| $$ /$$$$$$$| $$ \__/ | $$ | $$ | $$ \ $$ /$$$$$$$| $$| $$ \ $$
|
||||
| $$ $$ /$$__ $$| $$ | $$ /$$| $$ $$| $$ | $$ /$$__ $$| $$| $$ | $$
|
||||
| $$$$$$/| $$$$$$$| $$ | $$$$/| $$$$$$/| $$ | $$| $$$$$$$| $$| $$ | $$
|
||||
\______/ \_______/|__/ \___/ \______/ |__/ |__/ \_______/|__/|__/ |__/
|
||||
|
||||
${application.title} - v${application.version}
|
||||
Powered by Rviewer
|
||||
Reference in New Issue
Block a user