diff --git a/BE/exceed/Dockerfile b/BE/exceed/Dockerfile index 5ad33c53..283369bf 100644 --- a/BE/exceed/Dockerfile +++ b/BE/exceed/Dockerfile @@ -2,8 +2,17 @@ FROM openjdk:17-oracle ENV TZ=Asia/Seoul +# 앱을 위한 작업 디렉토리 설정 +WORKDIR /app + +# JAR 파일 복사 ARG JAR_FILE="./build/libs/*.jar" COPY ${JAR_FILE} eatceed.jar +# CSV 파일 복사 +COPY ./food_data.csv ./food_data.csv + EXPOSE 8080 -CMD ["java", "-jar", "-Dspring.profiles.active=dev", "eatceed.jar"] + +# CMD 명령어에서 CSV 파일의 위치를 절대 경로로 지정 +CMD ["java", "-jar", "-Dspring.profiles.active=dev", "eatceed.jar", "./food_data.csv"] diff --git a/BE/exceed/build.gradle b/BE/exceed/build.gradle index d1ae11bc..9ed77156 100644 --- a/BE/exceed/build.gradle +++ b/BE/exceed/build.gradle @@ -89,6 +89,12 @@ dependencies { //OpenCsv implementation group: 'com.opencsv', name: 'opencsv', version: '5.7.1' + + // Actuator + implementation 'org.springframework.boot:spring-boot-starter-actuator' + + // Prometheus + implementation 'io.micrometer:micrometer-registry-prometheus' } tasks.named('bootBuildImage') { diff --git a/BE/exceed/docker-compose.yml b/BE/exceed/docker-compose.yml index 99301ab5..0ad6e2df 100644 --- a/BE/exceed/docker-compose.yml +++ b/BE/exceed/docker-compose.yml @@ -6,8 +6,8 @@ services: expose: - "3306" volumes: - - ./resources/gaebaljip-local-develop-environment/mariadb-conf:/etc/mysql/conf.d - - ./resources/gaebaljip-local-develop-environment/mariadb-init:/docker-entrypoint-initdb.d + - ./resources/gaebaljip-develop-environment/mariadb-conf:/etc/mysql/conf.d + - ./resources/gaebaljip-develop-environment/mariadb-init:/docker-entrypoint-initdb.d environment: - MYSQL_ROOT_PASSWORD=root - MYSQL_ROOT_HOST=% @@ -24,9 +24,7 @@ services: - gaebaljip-network eatceed-backend: - build: - context: . - dockerfile: Dockerfile + image: hwangdaesun/gaebaljip-dev:latest container_name: gaebaljip-spring ports: - 8080:8080 @@ -52,6 +50,41 @@ services: restart: on-failure + grafana: + image: grafana/grafana:latest + container_name: grafana + restart: always + ports: + - "3000:3000" + volumes: + - grafana-data:/var/lib/grafana + - ./resources/gaebaljip-develop-environment/grafana/provisioning/:/etc/grafana/provisioning/ + environment: + - GF_SERVER_ROOT_URL=localhost:3000 + - GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD} + depends_on: + - prometheus + networks: + - gaebaljip-network + + prometheus: + image: prom/prometheus:latest + container_name: prometheus + restart: always + ports: + - "9090:9090" + volumes: + - ./resources/gaebaljip-develop-environment/prometheus/config:/etc/prometheus/ + - prometheus-data:/prometheus + command: + - '--config.file=/etc/prometheus/prometheus.yml' + - '--storage.tsdb.path=/prometheus' + networks: + - gaebaljip-network + +volumes: + grafana-data: + prometheus-data: networks: gaebaljip-network: \ No newline at end of file diff --git a/BE/food_data.csv b/BE/exceed/food_data.csv similarity index 100% rename from BE/food_data.csv rename to BE/exceed/food_data.csv diff --git a/BE/exceed/resources/gaebaljip-local-develop-environment/mariadb-conf/mariadb.conf b/BE/exceed/resources/gaebaljip-develop-environment/mariadb-conf/mariadb.conf similarity index 100% rename from BE/exceed/resources/gaebaljip-local-develop-environment/mariadb-conf/mariadb.conf rename to BE/exceed/resources/gaebaljip-develop-environment/mariadb-conf/mariadb.conf diff --git a/BE/exceed/resources/gaebaljip-local-develop-environment/mariadb-init/00_init.sql b/BE/exceed/resources/gaebaljip-develop-environment/mariadb-init/00_init.sql similarity index 100% rename from BE/exceed/resources/gaebaljip-local-develop-environment/mariadb-init/00_init.sql rename to BE/exceed/resources/gaebaljip-develop-environment/mariadb-init/00_init.sql diff --git a/BE/exceed/resources/gaebaljip-local-develop-environment/mariadb-init/01_schma.sql b/BE/exceed/resources/gaebaljip-develop-environment/mariadb-init/01_schma.sql similarity index 100% rename from BE/exceed/resources/gaebaljip-local-develop-environment/mariadb-init/01_schma.sql rename to BE/exceed/resources/gaebaljip-develop-environment/mariadb-init/01_schma.sql diff --git a/BE/exceed/resources/gaebaljip-develop-environment/prometheus/config/prometheus.yml b/BE/exceed/resources/gaebaljip-develop-environment/prometheus/config/prometheus.yml new file mode 100644 index 00000000..554374bd --- /dev/null +++ b/BE/exceed/resources/gaebaljip-develop-environment/prometheus/config/prometheus.yml @@ -0,0 +1,19 @@ +global: + scrape_interval: 15s + evaluation_interval: 15s +alerting: + alertmanagers: + - static_configs: + - targets: + # - alertmanager:9093 +rule_files: +scrape_configs: + - job_name: "prometheus" + static_configs: + - targets: ["localhost:9090"] + #추가 + - job_name: "spring-actuator" + metrics_path: '/actuator/prometheus' + scrape_interval: 1s + static_configs: + - targets: ['3.37.117.77:8080'] \ No newline at end of file diff --git a/BE/exceed/resources/gaebaljip-local-develop-environment/setting.yml b/BE/exceed/resources/gaebaljip-local-develop-environment/setting.yml deleted file mode 100644 index aa38a0b6..00000000 --- a/BE/exceed/resources/gaebaljip-local-develop-environment/setting.yml +++ /dev/null @@ -1,34 +0,0 @@ -version: '3' -services: - eatceed-mariadb: - image: mariadb:10.6 - container_name: gaebaljip-local-mariadb - ports: - - 3306:3306 - volumes: - - ./mariadb-conf:/etc/mysql/conf.d - - ./mariadb-init:/docker-entrypoint-initdb.d - environment: - - MYSQL_ROOT_PASSWORD=root - - MYSQL_ROOT_HOST=% - - TZ=Asia/Seoul - - eatceed-redis: - image: redis:alpine - container_name: gaebaljip-local-redis - command: redis-server --port 6379 - ports: - - 6379:6379 - - eatceed-adminer: - container_name: gaebaljip-local-adminer - image: adminer:4 - ports: - - 18080:8080 - depends_on: - - eatceed-mariadb - - eatceed-redis - links: - - eatceed-mariadb - - eatceed-redis - diff --git a/BE/exceed/resources/gaebaljip-local-develop-environment/.DS_Store b/BE/exceed/resources/gaebaljip-local-environment/.DS_Store similarity index 100% rename from BE/exceed/resources/gaebaljip-local-develop-environment/.DS_Store rename to BE/exceed/resources/gaebaljip-local-environment/.DS_Store diff --git a/BE/exceed/resources/gaebaljip-local-environment/mariadb-conf/mariadb.conf b/BE/exceed/resources/gaebaljip-local-environment/mariadb-conf/mariadb.conf new file mode 100644 index 00000000..ac18d80f --- /dev/null +++ b/BE/exceed/resources/gaebaljip-local-environment/mariadb-conf/mariadb.conf @@ -0,0 +1,8 @@ +[client] +default-character-set = utf8mb4 + +[mysql] +default-character-set = utf8mb4 + +[mysqld] +character-set-server = utf8mb4 \ No newline at end of file diff --git a/BE/exceed/resources/gaebaljip-local-environment/mariadb-init/00_init.sql b/BE/exceed/resources/gaebaljip-local-environment/mariadb-init/00_init.sql new file mode 100644 index 00000000..8958dbb8 --- /dev/null +++ b/BE/exceed/resources/gaebaljip-local-environment/mariadb-init/00_init.sql @@ -0,0 +1,12 @@ +CREATE + USER 'gaebaljip-local'@'localhost' IDENTIFIED BY 'gaebaljip-local'; +CREATE + USER 'gaebaljip-local'@'%' IDENTIFIED BY 'gaebaljip-local'; + +GRANT ALL PRIVILEGES ON *.* TO + 'gaebaljip-local'@'localhost'; +GRANT ALL PRIVILEGES ON *.* TO + 'gaebaljip-local'@'%'; + +CREATE + DATABASE gaebaljip DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; diff --git a/BE/exceed/resources/gaebaljip-local-environment/mariadb-init/01_schma.sql b/BE/exceed/resources/gaebaljip-local-environment/mariadb-init/01_schma.sql new file mode 100644 index 00000000..5f0cd75f --- /dev/null +++ b/BE/exceed/resources/gaebaljip-local-environment/mariadb-init/01_schma.sql @@ -0,0 +1,99 @@ +use gaebaljip; + + +CREATE TABLE `MEMBER_TB` +( + `MEMBER_PK` bigint(20) NOT NULL AUTO_INCREMENT, + `CREATED_DATE` datetime(6) NOT NULL, + `UPDATED_DATE` datetime(6) NOT NULL, + `MEMBER_ACTIVITY` varchar(255) DEFAULT NULL, + `MEMBER_AGE` int(11) DEFAULT NULL, + `MEMBER_ETC` varchar(255) DEFAULT NULL, + `MEMBER_GENDER` tinyint DEFAULT NULL, + `MEMBER_HEIGHT` double DEFAULT NULL, + `MEMBER_EMAIL` varchar(255) NOT NULL UNIQUE, + `MEMBER_PASSWORD` varchar(255) NOT NULL, + `MEMBER_ROLE` varchar(255) DEFAULT NULL, + `MEMBER_WEIGHT` double DEFAULT NULL, + `MEMBER_CHECKED` bit NOT NULL, + PRIMARY KEY (`MEMBER_PK`) +) ENGINE=InnoDB; + +CREATE TABLE `WEIGHT_TB` +( + `WEIGHT_PK` bigint(20) NOT NULL AUTO_INCREMENT, + `CREATED_DATE` datetime(6) NOT NULL, + `UPDATED_DATE` datetime(6) NOT NULL, + `WEIGHT_WEIGHT` double DEFAULT NULL, + `WEIGHT_TARGET_WEIGHT` double DEFAULT NULL, + `MEMBER_FK` bigint(20) DEFAULT NULL, + PRIMARY KEY (`WEIGHT_PK`), + FOREIGN KEY (`MEMBER_FK`) REFERENCES `MEMBER_TB` (`MEMBER_PK`) +) ENGINE=InnoDB; + + +CREATE TABLE `FOOD_TB` +( + `FOOD_PK` bigint(20) NOT NULL AUTO_INCREMENT, + `FOOD_CALORIE` double NOT NULL, + `FOOD_CARBOHYDRATE` double NOT NULL, + `FOOD_FAT` double NOT NULL, + `FOOD_MAIN_CATEGORY` varchar(255) NOT NULL, + `FOOD_NAME` varchar(255) NOT NULL, + `FOOD_PROTEIN` double NOT NULL, + `FOOD_SERVING_SIZE` double NOT NULL, + `FOOD_SUB_CATEGORY` varchar(255) NOT NULL, + PRIMARY KEY (`FOOD_PK`) +) ENGINE=InnoDB; + + +CREATE TABLE `MEAL_TB` +( + `MEAL_PK` bigint(20) NOT NULL AUTO_INCREMENT, + `CREATED_DATE` datetime(6) NOT NULL, + `UPDATED_DATE` datetime(6) NOT NULL, + `MEAL_TYPE` varchar(255) NOT NULL, + `MEAL_FOOD_MULTIPLE` double NOT NULL, + `MEMBER_FK` bigint(20) DEFAULT NULL, + PRIMARY KEY (`MEAL_PK`), + FOREIGN KEY (`MEMBER_FK`) REFERENCES `MEMBER_TB` (`MEMBER_PK`) +) ENGINE = InnoDB; + +CREATE TABLE `MEAL_FOOD_TB` +( + `MEAL_FOOD_PK` bigint(20) NOT NULL AUTO_INCREMENT, + `CREATED_DATE` datetime(6) NOT NULL, + `UPDATED_DATE` datetime(6) NOT NULL, + `FOOD_FK` bigint(20) DEFAULT NULL, + `MEAL_FK` bigint(20) DEFAULT NULL, + PRIMARY KEY (`MEAL_FOOD_PK`), + FOREIGN KEY (`FOOD_FK`) REFERENCES `FOOD_TB` (`FOOD_PK`), + FOREIGN KEY (`MEAL_FK`)REFERENCES `MEAL_TB` (`MEAL_PK`) +) ENGINE=InnoDB; + +CREATE TABLE `EAT_HABITS_TB` +( + `EAT_HABITS_PK` bigint(20) NOT NULL AUTO_INCREMENT, + `MEMBER_FK` bigint(20) DEFAULT NULL, + `CREATED_DATE` datetime(6) NOT NULL, + `FLAG` tinyint(1) NOT NULL, + `WEIGHT_PREDICTION` text NOT NULL, + `WEIGHT_ADVICE` text NOT NULL, + PRIMARY KEY (`EAT_HABITS_PK`), + FOREIGN KEY (`MEMBER_FK`) REFERENCES `MEMBER_TB` (`MEMBER_PK`) +) ENGINE = InnoDB; + +CREATE TABLE `HISTORY_TB` +( + `HISTORY_PK` bigint(20) NOT NULL AUTO_INCREMENT, + `CREATED_DATE` datetime(6) NOT NULL, + `UPDATED_DATE` datetime(6) NOT NULL, + `HISTORY_ACTIVITY` varchar(255) NOT NULL , + `HISTORY_AGE` int(11) NOT NULL, + `HISTORY_GENDER` tinyint NOT NULL, + `HISTORY_HEIGHT` double NOT NULL, + `HISTORY_WEIGHT` double NOT NULL, + `MEMBER_FK` bigint(20) DEFAULT NULL, + PRIMARY KEY (`HISTORY_PK`), + FOREIGN KEY (`MEMBER_FK`) REFERENCES `MEMBER_TB` (`MEMBER_PK`) +) ENGINE=InnoDB; \ No newline at end of file diff --git a/BE/exceed/resources/gaebaljip-local-environment/prometheus/config/prometheus.yml b/BE/exceed/resources/gaebaljip-local-environment/prometheus/config/prometheus.yml new file mode 100644 index 00000000..d0503bba --- /dev/null +++ b/BE/exceed/resources/gaebaljip-local-environment/prometheus/config/prometheus.yml @@ -0,0 +1,19 @@ +global: + scrape_interval: 15s + evaluation_interval: 15s +alerting: + alertmanagers: + - static_configs: + - targets: + # - alertmanager:9093 +rule_files: +scrape_configs: + - job_name: "prometheus" + static_configs: + - targets: ["localhost:9090"] + #추가 + - job_name: "spring-actuator" + metrics_path: '/actuator/prometheus' + scrape_interval: 1s + static_configs: + - targets: ['host.docker.internal:8080'] \ No newline at end of file diff --git a/BE/exceed/resources/gaebaljip-local-environment/setting.yml b/BE/exceed/resources/gaebaljip-local-environment/setting.yml new file mode 100644 index 00000000..d2f327b4 --- /dev/null +++ b/BE/exceed/resources/gaebaljip-local-environment/setting.yml @@ -0,0 +1,67 @@ +version: '3' +services: + eatceed-mariadb: + image: mariadb:10.6 + container_name: gaebaljip-local-mariadb + ports: + - 3306:3306 + volumes: + - ./mariadb-conf:/etc/mysql/conf.d + - ./mariadb-init:/docker-entrypoint-initdb.d + environment: + - MYSQL_ROOT_PASSWORD=root + - MYSQL_ROOT_HOST=% + - TZ=Asia/Seoul + + eatceed-redis: + image: redis:alpine + container_name: gaebaljip-local-redis + command: redis-server --port 6379 + ports: + - 6379:6379 + + eatceed-adminer: + container_name: gaebaljip-local-adminer + image: adminer:4 + ports: + - 18080:8080 + depends_on: + - eatceed-mariadb + - eatceed-redis + links: + - eatceed-mariadb + - eatceed-redis + + grafana: + image: grafana/grafana:latest + container_name: grafana + user: "$UID:$GID" + restart: always + ports: + - "3000:3000" + volumes: + - grafana-data:/var/lib/grafana + - ./grafana/provisioning/:/etc/grafana/provisioning/ + environment: + - GF_SERVER_ROOT_URL=http://localhost:3000 + - GF_SECURITY_ADMIN_PASSWORD=admin + depends_on: + - prometheus + + prometheus: + image: prom/prometheus:latest + container_name: prometheus + restart: always + ports: + - "9090:9090" + volumes: + - ./prometheus/config:/etc/prometheus/ + - prometheus-data:/prometheus + command: + - '--config.file=/etc/prometheus/prometheus.yml' + - '--storage.tsdb.path=/prometheus' + +volumes: + grafana-data: + prometheus-data: + diff --git a/BE/exceed/scripts/reset.sh b/BE/exceed/scripts/reset.sh index 75ab980c..006546b8 100755 --- a/BE/exceed/scripts/reset.sh +++ b/BE/exceed/scripts/reset.sh @@ -1,4 +1,4 @@ -cd ../resources/gaebaljip-local-develop-environment +cd ../resources/gaebaljip-local-environment docker-compose -f setting.yml down docker-compose -f setting.yml up -d sleep 10 \ No newline at end of file diff --git a/BE/exceed/src/main/java/com/gaebaljip/exceed/config/ActuatorConfig.java b/BE/exceed/src/main/java/com/gaebaljip/exceed/config/ActuatorConfig.java new file mode 100644 index 00000000..cf5f7786 --- /dev/null +++ b/BE/exceed/src/main/java/com/gaebaljip/exceed/config/ActuatorConfig.java @@ -0,0 +1,13 @@ +package com.gaebaljip.exceed.config; + +import org.springframework.boot.actuate.trace.http.InMemoryHttpTraceRepository; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class ActuatorConfig { + @Bean + public InMemoryHttpTraceRepository httpExchangeRepository() { + return new InMemoryHttpTraceRepository(); + } +} diff --git a/BE/exceed/src/main/java/com/gaebaljip/exceed/security/config/SecurityConfig.java b/BE/exceed/src/main/java/com/gaebaljip/exceed/security/config/SecurityConfig.java index 6fb9e820..90605068 100644 --- a/BE/exceed/src/main/java/com/gaebaljip/exceed/security/config/SecurityConfig.java +++ b/BE/exceed/src/main/java/com/gaebaljip/exceed/security/config/SecurityConfig.java @@ -74,6 +74,8 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { .permitAll() .antMatchers(HttpMethod.POST, "/v1/auth/login") .permitAll() + .antMatchers(HttpMethod.GET, "/actuator/**") + .permitAll() .anyRequest() .authenticated(); diff --git a/BE/exceed/src/main/resources/application-dev.yml b/BE/exceed/src/main/resources/application-dev.yml index 5125612a..d2e9fa20 100644 --- a/BE/exceed/src/main/resources/application-dev.yml +++ b/BE/exceed/src/main/resources/application-dev.yml @@ -61,4 +61,12 @@ springdoc: default-consumes-media-type: application/json default-produces-media-type: application/json -ableAutoComplete: true \ No newline at end of file +ableAutoComplete: true + +management: + endpoints: + web: + exposure: + include: "*" + exclude: "env, beans" + diff --git a/BE/exceed/src/main/resources/application-local.yml b/BE/exceed/src/main/resources/application-local.yml index a76a19c6..1b9bcc42 100644 --- a/BE/exceed/src/main/resources/application-local.yml +++ b/BE/exceed/src/main/resources/application-local.yml @@ -75,4 +75,14 @@ springdoc: default-consumes-media-type: application/json default-produces-media-type: application/json -ableAutoComplete: true \ No newline at end of file + +ableAutoComplete: true +# Actuator + +management: + endpoints: + web: + exposure: + include: "*" + exclude: "env, beans" + diff --git a/BE/exceed/src/test/java/com/gaebaljip/exceed/food/GetFoodIntegrationTest.java b/BE/exceed/src/test/java/com/gaebaljip/exceed/food/GetFoodIntegrationTest.java index 525f7045..e620f17d 100644 --- a/BE/exceed/src/test/java/com/gaebaljip/exceed/food/GetFoodIntegrationTest.java +++ b/BE/exceed/src/test/java/com/gaebaljip/exceed/food/GetFoodIntegrationTest.java @@ -1,144 +1,143 @@ -package com.gaebaljip.exceed.food; - -import static com.gaebaljip.exceed.common.util.ApiDocumentUtil.getDocumentRequest; -import static com.gaebaljip.exceed.common.util.ApiDocumentUtil.getDocumentResponse; -import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import com.gaebaljip.exceed.common.EatCeedStaticMessage; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.ApplicationArguments; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.http.MediaType; -import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders; -import org.springframework.test.web.servlet.ResultActions; - -import com.gaebaljip.exceed.common.IntegrationTest; -import com.gaebaljip.exceed.infrastructure.redis.RedisAutoComplete; -import com.gaebaljip.exceed.infrastructure.redis.RedisUtils; - -import lombok.extern.log4j.Log4j2; - -@SpringBootTest(args = "../food_data.csv") -@Log4j2 -public class GetFoodIntegrationTest extends IntegrationTest { - String PRE_FIX = "prefix"; - - @Autowired private RedisUtils redisUtils; - @Autowired private ApplicationArguments applicationArguments; - - @BeforeEach - void setUp() { - RedisAutoComplete redisAutoComplete = new RedisAutoComplete(redisUtils); - try { - redisAutoComplete.run(applicationArguments); - } catch (Exception e) { - log.error("Failed to read CSV file: {}", e.getMessage()); - } - } - - @AfterEach - void tearDown() { - redisUtils.deleteData(EatCeedStaticMessage.REDIS_AUTO_COMPLETE_KEY); - } - - - @Test - void getFoods() throws Exception { - // given - String prefix = "감"; - - ResultActions resultActions = - mockMvc.perform( - RestDocumentationRequestBuilders.get("/v1/foods/auto") - .queryParam(PRE_FIX, prefix) - .contentType(MediaType.APPLICATION_JSON)); - - String responseBody = resultActions.andReturn().getResponse().getContentAsString(); - - resultActions - .andExpect(status().isOk()) - .andDo( - document( - "get-food-noQueryString-success", - getDocumentRequest(), - getDocumentResponse())); - } -} - // @Test - // void getFoods1() throws Exception { - // - // ResultActions resultActions = - // mockMvc.perform( - // RestDocumentationRequestBuilders.get("/v1/foods") - // .param(PRE_FIX,) - // .contentType(MediaType.APPLICATION_JSON)); - // - // String responseBody = resultActions.andReturn().getResponse().getContentAsString(); - // - // resultActions - // .andExpect(status().isOk()) - // .andDo( - // document( - // "get-foods-lastFoodName-success", - // getDocumentRequest(), - // getDocumentResponse())); - // } - // - // @Test - // void getFoods2() throws Exception { - // ResultActions resultActions = - // mockMvc.perform( - // RestDocumentationRequestBuilders.get("/v1/foods?size=15") - // .contentType(MediaType.APPLICATION_JSON)); - // - // String responseBody = resultActions.andReturn().getResponse().getContentAsString(); - // - // resultActions - // .andExpect(status().isOk()) - // .andDo( - // document( - // "get-foods-lastFoodNameAndSize-success", - // getDocumentRequest(), - // getDocumentResponse())); - // } - // - // @Test - // void getFoods3() throws Exception { - // ResultActions resultActions = - // mockMvc.perform( - // RestDocumentationRequestBuilders.get("/v1/foods?keyword=구이") - // .contentType(MediaType.APPLICATION_JSON)); - // - // String responseBody = resultActions.andReturn().getResponse().getContentAsString(); - // - // resultActions - // .andExpect(status().isOk()) - // .andDo( - // document( - // "get-foods-searchForKeyword-success", - // getDocumentRequest(), - // getDocumentResponse())); - // } - // - // @Test - // void getFoods4() throws Exception { - // ResultActions resultActions = - // mockMvc.perform( - // RestDocumentationRequestBuilders.get( - // "/v1/foods?keyword=구이&lastFoodName=닭발구이") - // .contentType(MediaType.APPLICATION_JSON)); - // - // String responseBody = resultActions.andReturn().getResponse().getContentAsString(); - // - // resultActions - // .andExpect(status().isOk()) - // .andDo( - // document( - // "get-foods-searchForKeywordAndLastFoodName-success", - // getDocumentRequest(), - // getDocumentResponse())); - // } +// package com.gaebaljip.exceed.food; +// +// import static com.gaebaljip.exceed.common.util.ApiDocumentUtil.getDocumentRequest; +// import static com.gaebaljip.exceed.common.util.ApiDocumentUtil.getDocumentResponse; +// import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; +// import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +// +// import org.junit.jupiter.api.AfterEach; +// import org.junit.jupiter.api.BeforeEach; +// import org.junit.jupiter.api.Test; +// import org.springframework.beans.factory.annotation.Autowired; +// import org.springframework.boot.ApplicationArguments; +// import org.springframework.boot.test.context.SpringBootTest; +// import org.springframework.http.MediaType; +// import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders; +// import org.springframework.test.web.servlet.ResultActions; +// +// import com.gaebaljip.exceed.common.EatCeedStaticMessage; +// import com.gaebaljip.exceed.common.IntegrationTest; +// import com.gaebaljip.exceed.infrastructure.redis.RedisAutoComplete; +// import com.gaebaljip.exceed.infrastructure.redis.RedisUtils; +// +// import lombok.extern.log4j.Log4j2; +// +// @SpringBootTest(args = "../food_data.csv") +// @Log4j2 +// public class GetFoodIntegrationTest extends IntegrationTest { +// String PRE_FIX = "prefix"; +// +// @Autowired private RedisUtils redisUtils; +// @Autowired private ApplicationArguments applicationArguments; +// +// @BeforeEach +// void setUp() { +// RedisAutoComplete redisAutoComplete = new RedisAutoComplete(redisUtils); +// try { +// redisAutoComplete.run(applicationArguments); +// } catch (Exception e) { +// log.error("Failed to read CSV file: {}", e.getMessage()); +// } +// } +// +// @AfterEach +// void tearDown() { +// redisUtils.deleteData(EatCeedStaticMessage.REDIS_AUTO_COMPLETE_KEY); +// } +// +// @Test +// void getFoods() throws Exception { +// // given +// String prefix = "감"; +// +// ResultActions resultActions = +// mockMvc.perform( +// RestDocumentationRequestBuilders.get("/v1/foods/auto") +// .queryParam(PRE_FIX, prefix) +// .contentType(MediaType.APPLICATION_JSON)); +// +// String responseBody = resultActions.andReturn().getResponse().getContentAsString(); +// +// resultActions +// .andExpect(status().isOk()) +// .andDo( +// document( +// "get-food-noQueryString-success", +// getDocumentRequest(), +// getDocumentResponse())); +// } +// } +// // @Test +// // void getFoods1() throws Exception { +// // +// // ResultActions resultActions = +// // mockMvc.perform( +// // RestDocumentationRequestBuilders.get("/v1/foods") +// // .param(PRE_FIX,) +// // .contentType(MediaType.APPLICATION_JSON)); +// // +// // String responseBody = resultActions.andReturn().getResponse().getContentAsString(); +// // +// // resultActions +// // .andExpect(status().isOk()) +// // .andDo( +// // document( +// // "get-foods-lastFoodName-success", +// // getDocumentRequest(), +// // getDocumentResponse())); +// // } +// // +// // @Test +// // void getFoods2() throws Exception { +// // ResultActions resultActions = +// // mockMvc.perform( +// // RestDocumentationRequestBuilders.get("/v1/foods?size=15") +// // .contentType(MediaType.APPLICATION_JSON)); +// // +// // String responseBody = resultActions.andReturn().getResponse().getContentAsString(); +// // +// // resultActions +// // .andExpect(status().isOk()) +// // .andDo( +// // document( +// // "get-foods-lastFoodNameAndSize-success", +// // getDocumentRequest(), +// // getDocumentResponse())); +// // } +// // +// // @Test +// // void getFoods3() throws Exception { +// // ResultActions resultActions = +// // mockMvc.perform( +// // RestDocumentationRequestBuilders.get("/v1/foods?keyword=구이") +// // .contentType(MediaType.APPLICATION_JSON)); +// // +// // String responseBody = resultActions.andReturn().getResponse().getContentAsString(); +// // +// // resultActions +// // .andExpect(status().isOk()) +// // .andDo( +// // document( +// // "get-foods-searchForKeyword-success", +// // getDocumentRequest(), +// // getDocumentResponse())); +// // } +// // +// // @Test +// // void getFoods4() throws Exception { +// // ResultActions resultActions = +// // mockMvc.perform( +// // RestDocumentationRequestBuilders.get( +// // "/v1/foods?keyword=구이&lastFoodName=닭발구이") +// // .contentType(MediaType.APPLICATION_JSON)); +// // +// // String responseBody = resultActions.andReturn().getResponse().getContentAsString(); +// // +// // resultActions +// // .andExpect(status().isOk()) +// // .andDo( +// // document( +// // "get-foods-searchForKeywordAndLastFoodName-success", +// // getDocumentRequest(), +// // getDocumentResponse())); +// // }