From 45ac5d08654c210a6841062aed13a9c9859dfcd0 Mon Sep 17 00:00:00 2001 From: lcaohoanq Date: Thu, 12 Dec 2024 09:49:56 +0700 Subject: [PATCH] test: add unit test --- SPCServer/springboot/pom.xml | 6 +- .../src/main/resources/application-test.yml | 86 +++++++++++++++++++ .../shoppe/util/DTOConverterTest.java | 61 +++++++++++++ 3 files changed, 152 insertions(+), 1 deletion(-) create mode 100755 SPCServer/springboot/src/main/resources/application-test.yml create mode 100644 SPCServer/springboot/src/test/java/com/lcaohoanq/shoppe/util/DTOConverterTest.java diff --git a/SPCServer/springboot/pom.xml b/SPCServer/springboot/pom.xml index 9126c50..c1cd9af 100644 --- a/SPCServer/springboot/pom.xml +++ b/SPCServer/springboot/pom.xml @@ -339,7 +339,11 @@ com.fasterxml.jackson.core jackson-databind - + + com.h2database + h2 + + diff --git a/SPCServer/springboot/src/main/resources/application-test.yml b/SPCServer/springboot/src/main/resources/application-test.yml new file mode 100755 index 0000000..5eadac7 --- /dev/null +++ b/SPCServer/springboot/src/main/resources/application-test.yml @@ -0,0 +1,86 @@ +server: + port: 4000 + +api: + prefix: /api/v1 + +spring: + datasource: + url: jdbc:h2:mem:testdb + driver-class-name: org.h2.Driver + username: sa + password: password + jpa: + database-platform: org.hibernate.dialect.H2Dialect + hibernate: + ddl-auto: create-drop + show-sql: true + + mail: + host: smtp.gmail.com + port: 587 + username: ${MAIL_USERNAME} + password: ${MAIL_PASSWORD} + + data: + redis: + #spring.data.redis.use-redis-cache + use-redis-cache: false + host: ${REDIS_HOST:localhost} # Default to 'localhost' if not provided + port: ${REDIS_PORT:6379} # Default to 6379 if not provided + +alert: + manager: + emails: ${ALERT_MANAGER_EMAILS} + +jwt: + expiration: ${JWT_EXPIRATION} + expiration-refresh-token: ${JWT_EXPIRATION_REFRESH_TOKEN} + secretKey: ${JWT_SECRET_KEY} + +logging: + level: + org.springframework: DEBUG + springframework.security: DEBUG + org.hibernate: DEBUG + +# swagger-ui custom path +springdoc: + swagger-ui: + path: ${api.prefix}/swagger-ui.html + enabled: true + disable-swagger-default-url: true + security: + basic: + enabled: true + api-docs: + path: ${api.prefix}/api-docs + enabled: true + show-actuator: true + paths-to-match: ${api.prefix}/** + +#health check +management: + endpoints: + web: + base-path: /api/v1/actuator + exposure: + include: "health,info,prometheus" + endpoint: + health: + show-details: always + metrics: + enabled: true + prometheus: + enabled: true + +vnpay: + api: + vnp_Version: ${VNPAY_VERSION} + vnp_Command: ${VNPAY_COMMAND} + vnp_OrderType: ${VNPAY_ORDER_TYPE} + vnp_PayUrl: ${VNPAY_PAY_URL} + vnp_Returnurl: ${VNPAY_RETURN_URL} + vnp_TmnCode: ${VNPAY_TMN_CODE} + vnp_HashSecret: ${VNPAY_HASH_SECRET} + vnp_apiUrl: ${VNPAY_API_URL} \ No newline at end of file diff --git a/SPCServer/springboot/src/test/java/com/lcaohoanq/shoppe/util/DTOConverterTest.java b/SPCServer/springboot/src/test/java/com/lcaohoanq/shoppe/util/DTOConverterTest.java new file mode 100644 index 0000000..5bbb8e9 --- /dev/null +++ b/SPCServer/springboot/src/test/java/com/lcaohoanq/shoppe/util/DTOConverterTest.java @@ -0,0 +1,61 @@ +package com.lcaohoanq.shoppe.util; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; + +@SpringBootTest +@ActiveProfiles("test") +class DTOConverterTest { + + @BeforeEach + void setUp() { + } + + @Test + void toUserResponse() { + } + + @Test + void toCategoryResponse() { + } + + @Test + void toRoleResponse() { + } + + @Test + void toOrderResponse() { + } + + @Test + void toProductResponse() { + } + + @Test + void toProductImageResponse() { + } + + @Test + void toOrderDetailResponse() { + } + + @Test + void toCartResponse() { + } + + @Test + void toCartItemResponse() { + } + + @Test + void toWalletResponse() { + } + + @Test + void toWareHouseResponse() { + } +} \ No newline at end of file