Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lottery Assessment 1.0 #12

Open
wants to merge 69 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
c33f43b
feat(docker) : init docker-compose.yml and Dockerfile.multi
peachoenixzz Feb 17, 2024
f93dea9
feat(Lottery) : init lottery application and env name
peachoenixzz Feb 17, 2024
0230101
feat(Lottery) : implement dependencies in build.gradle
peachoenixzz Feb 17, 2024
47a7198
feat(Lottery) : implement api exception handler code status
peachoenixzz Feb 19, 2024
69a2579
feat(Lottery) : implement config security
peachoenixzz Feb 19, 2024
877999b
feat(Lottery) : change java config
peachoenixzz Feb 19, 2024
981a9b6
feat(Lottery) : change java config
peachoenixzz Feb 19, 2024
e47f23f
feat(Lottery) : init first sql design
peachoenixzz Feb 19, 2024
7fb38eb
feat(Lottery) : add controllerAdmin
peachoenixzz Feb 19, 2024
79077be
feat(Lottery) : add Lottery Entity
peachoenixzz Feb 19, 2024
8cf657a
feat(Lottery) : add LotteryController
peachoenixzz Feb 19, 2024
aad3748
feat(Lottery) : add LotteryRepository
peachoenixzz Feb 19, 2024
015d9e5
feat(Lottery) : add LotteryRequestDto
peachoenixzz Feb 19, 2024
44a87a1
feat(Lottery) : add LotteryService
peachoenixzz Feb 19, 2024
01052f0
feat(Lottery) : add LotteryService
peachoenixzz Feb 19, 2024
7460fc5
feat(Lottery) : add LotteryTicketResponse
peachoenixzz Feb 19, 2024
e18ab99
feat(Lottery) : refactor class name LotteryTicketResponse to LotteryT…
peachoenixzz Feb 19, 2024
162eeaa
feat(Lottery) : re-design database and Lottery Class
peachoenixzz Feb 19, 2024
958767c
feat(Lottery) : add constant variable file
peachoenixzz Feb 20, 2024
221a95a
feat(Lottery) : change design DB
peachoenixzz Feb 20, 2024
981b819
feat(Lottery) : change design DB
peachoenixzz Feb 20, 2024
a1ee76d
feat(Lottery) : change design DB
peachoenixzz Feb 20, 2024
24e4f12
feat(Lottery) : implement UserController
peachoenixzz Feb 20, 2024
b0d80ab
feat(Lottery) : implement UserTicket Entity
peachoenixzz Feb 20, 2024
cda71a1
feat(Lottery) : implement Users Entity
peachoenixzz Feb 20, 2024
5af8ebb
feat(Lottery) : add repo for Users entity and usersTicket entity
peachoenixzz Feb 20, 2024
557f776
feat(Lottery) : implement purchase logic to lotteryService
peachoenixzz Feb 20, 2024
f97291a
feat(Lottery) : change LotteryResponse Class to LotteryResponseDto
peachoenixzz Feb 20, 2024
3d42853
feat(Lottery) : implement response LotteryPurchase
peachoenixzz Feb 20, 2024
c93d38b
feat(Lottery) : refactor name class LotteryResponse to LotteryRespons…
peachoenixzz Feb 20, 2024
71e7ce7
feat(Lottery) : implement Join column on all entity
peachoenixzz Feb 20, 2024
2f8cfb4
feat(Lottery) : implement query for UserTicketRepository
peachoenixzz Feb 20, 2024
8c09dfa
feat(Lottery) : implement delete, purchase and get lottery by user an…
peachoenixzz Feb 20, 2024
e548b83
feat(Lottery) : implement LotteryUserResponseDto
peachoenixzz Feb 20, 2024
da7fc28
feat(Lottery) : implement getUserLottery and deleteLottery
peachoenixzz Feb 20, 2024
708b8f3
feat(Lottery) : implement deleteLottery and refactor class name on an…
peachoenixzz Feb 20, 2024
b58d2f1
feat(Lottery) : implement globalException about validate
peachoenixzz Feb 20, 2024
398fae8
feat(Lottery) : add more constant variable
peachoenixzz Feb 20, 2024
582d887
feat(Lottery) : refactor annotation valid to validate
peachoenixzz Feb 20, 2024
f892a39
feat(Lottery) : refactor annotation valid to validate
peachoenixzz Feb 20, 2024
83c9cf6
feat(Lottery) : delete @Modify from SELECT Query on UserTicketRepository
peachoenixzz Feb 20, 2024
a70749e
feat(Lottery) : delete sold_back_flag because Delete Method is requir…
peachoenixzz Feb 20, 2024
44148ad
feat(Lottery) : delete sold_back_flag because Delete Method is requir…
peachoenixzz Feb 20, 2024
d5bc16e
feat(Lottery) : delete sold_back_flag because Delete Method is requir…
peachoenixzz Feb 20, 2024
d6fa114
Merge branch 'KBTG-Kampus-ClassNest-SE-Java:main' into dev
peachoenixzz Feb 21, 2024
707a8df
Merge pull request #1 from peachoenixzz/dev
peachoenixzz Feb 21, 2024
72a91ba
Test(UserController) : refactor code a bit
peachoenixzz Feb 21, 2024
c3278ec
Test(UserController) : implement test case for UserController
peachoenixzz Feb 21, 2024
2c201f0
Merge pull request #3 from peachoenixzz/2-featurelottery-create-test-…
peachoenixzz Feb 21, 2024
d6027b4
feat(docker-compose) : add docker compose test and run
peachoenixzz Feb 22, 2024
6fe4461
Test(userController) : add method for test and change wrong descripti…
peachoenixzz Feb 22, 2024
5024961
Merge pull request #5 from peachoenixzz/4-implement-docker-compose-ru…
peachoenixzz Feb 22, 2024
a7b3436
Merge pull request #6 from peachoenixzz/2-featurelottery-create-test-…
peachoenixzz Feb 22, 2024
645045c
Defect(response-code) : hotfix response code create 200 to 201
peachoenixzz Feb 22, 2024
2a860a8
Merge pull request #8 from peachoenixzz/7-defectapi-change-response-c…
peachoenixzz Feb 22, 2024
775568a
Test(UserController) : combine Integration to UIS and add docker-comp…
peachoenixzz Feb 22, 2024
f44f83e
Change(Lottery) : delete useless annotation and add useful annotation
peachoenixzz Feb 22, 2024
d025f38
Merge pull request #10 from peachoenixzz/9-changeapi-delete-some-usel…
peachoenixzz Feb 22, 2024
94a6e1b
Merge pull request #12 from peachoenixzz/2-featurelottery-create-test…
peachoenixzz Feb 22, 2024
90cf387
Merge branch 'dev' of github.com:peachoenixzz/assessment into 11-test…
peachoenixzz Feb 22, 2024
4ada868
Test(AdminController) : implement Test for AdminControllerTest
peachoenixzz Feb 22, 2024
ddf959f
Merge pull request #13 from peachoenixzz/dev
peachoenixzz Feb 22, 2024
216c4d9
Merge pull request #14 from peachoenixzz/11-testapi-implement-test-ad…
peachoenixzz Feb 22, 2024
fcd9eb7
Test(LotteryController) : implement test for LotteryControllerTest
peachoenixzz Feb 22, 2024
64afadd
Merge pull request #16 from peachoenixzz/15-testapi-implement-test-lo…
peachoenixzz Feb 22, 2024
ee1b479
Merge pull request #18 from peachoenixzz/dev
peachoenixzz Feb 22, 2024
2207c3f
Test(API) : add postman collection for newman test
peachoenixzz Feb 24, 2024
b6ec406
Merge pull request #20 from peachoenixzz/19-testapi-add-postman-json-…
peachoenixzz Feb 24, 2024
300a216
Merge pull request #21 from peachoenixzz/dev
peachoenixzz Feb 24, 2024
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
11 changes: 11 additions & 0 deletions posttest/Dockerfile.multi
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# stage-1 build artifact
FROM amazoncorretto:17.0.9-alpine3.18 as builder
WORKDIR /app
ADD . .
RUN ["./gradlew","bootJar"]

# stage-2 running image
FROM gcr.io/distroless/java17-debian12:latest
WORKDIR /app
COPY --from=builder /app/build/libs/lottery-0.0.1-SNAPSHOT.jar lottery-0.0.1-SNAPSHOT.jar
ENTRYPOINT ["java", "-jar", "lottery-0.0.1-SNAPSHOT.jar"]
22 changes: 19 additions & 3 deletions posttest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,28 @@ repositories {
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.postgresql:postgresql'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'

testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.testcontainers:junit-jupiter'
}

configurations {
integrationTestCompile.extendsFrom testCompile
integrationTestRuntime.extendsFrom testRuntime
integrationTestImplementation.extendsFrom testImplementation
}

tasks.register('integrationTest', Test) {
jvmArgs('-Djdk.attach.allowAttachSelf=true', '-XX:+StartAttachListener')

description = 'Runs the integration tests.'
group = 'verification'
useJUnitPlatform()
}

tasks.named('test') {
Expand Down
30 changes: 30 additions & 0 deletions posttest/database/init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
DROP TABLE IF EXISTS lottery;
DROP TABLE IF EXISTS user_ticket;

CREATE TABLE lottery (
ticket_number VARCHAR(6) NOT NULL PRIMARY KEY,
price DECIMAL NOT NULL,
amount_available INT NOT NULL,
last_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT (NOW()),
created_at TIMESTAMP WITHOUT TIME ZONE DEFAULT (NOW())
);

CREATE TABLE users (
user_id VARCHAR(100) NOT NULL PRIMARY KEY,
created_at TIMESTAMP WITHOUT TIME ZONE DEFAULT NOW()
);

CREATE TABLE user_ticket (
ticket_id SERIAL PRIMARY KEY,
ticket_number VARCHAR(6) NOT NULL,
user_id VARCHAR(100) NOT NULL,
price_paid DECIMAL NOT NULL,
purchase_date TIMESTAMP WITHOUT TIME ZONE DEFAULT (NOW()),
created_at TIMESTAMP WITHOUT TIME ZONE DEFAULT NOW(),
last_updated TIMESTAMP WITHOUT TIME ZONE DEFAULT (NOW()),
FOREIGN KEY (ticket_number) REFERENCES lottery(ticket_number),
FOREIGN KEY (user_id) REFERENCES users(user_id)
);

CREATE INDEX idx_ticket_number ON lottery(ticket_number);
CREATE INDEX idx_user_id ON user_ticket(user_id);
37 changes: 37 additions & 0 deletions posttest/docker-compose.run.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#file: noinspection YAMLSchemaValidation
version: '3.8'

networks:
lottery_application:
services:
postgres:
image: postgres:latest
restart: always
environment:
POSTGRES_DB: lottery
POSTGRES_USER: lottery
POSTGRES_PASSWORD: Plottery001!@#
volumes:
- ./database/init.sql:/docker-entrypoint-initdb.d/init.sql
ports:
- "5432:5432"
networks:
- lottery_application
lottery_app:
image: amazoncorretto:17.0.9-alpine3.18
volumes:
- $PWD:/app
working_dir: /app
environment:
- DATABASE_URL=jdbc:postgresql://postgres:5432/lottery
- DATABASE_USERNAME=lottery
- DATABASE_PASSWORD=Plottery001!@#
depends_on:
- postgres
ports:
- "8888:8888"
networks:
- lottery_application
command: [ "./gradlew", "clean", "bootRun"]
volumes:
data:
37 changes: 37 additions & 0 deletions posttest/docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#file: noinspection YAMLSchemaValidation
version: '3.8'

networks:
integration-test:
services:
postgres:
image: postgres:latest
restart: always
environment:
POSTGRES_DB: lottery
POSTGRES_USER: lottery
POSTGRES_PASSWORD: Plottery001!@#
volumes:
- ./database/init.sql:/docker-entrypoint-initdb.d/init.sql
ports:
- "5432:5432"
networks:
- integration-test
it_test:
image: amazoncorretto:17.0.9-alpine3.18
volumes:
- $PWD:/app
working_dir: /app
depends_on:
- postgres
environment:
- DATABASE_URL=jdbc:postgresql://postgres:5432/lottery
- DATABASE_USERNAME=lottery
- DATABASE_PASSWORD=Plottery001!@#
ports:
- "8888:8888"
networks:
- integration-test
command: ["./gradlew", "clean", "integrationTest"]
volumes:
data:
20 changes: 20 additions & 0 deletions posttest/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: '3'

networks:
lottery_application:
services:
postgres:
image: postgres:latest
restart: always
environment:
POSTGRES_DB: lottery
POSTGRES_USER: lottery
POSTGRES_PASSWORD: Plottery001!@#
volumes:
- ./database/init.sql:/docker-entrypoint-initdb.d/init.sql
ports:
- "5432:5432"
networks:
- lottery_application
volumes:
pgdata:
Loading