diff --git a/.github/workflows/back-dev.yml b/.github/workflows/back-dev.yml deleted file mode 100644 index cd2910236..000000000 --- a/.github/workflows/back-dev.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: back deploy for dev - -on: - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - services: - mysql: - image: mysql:8.0.28 - env: - MYSQL_USER: user - MYSQL_PASSWORD: password - MYSQL_ROOT_PASSWORD: root - MYSQL_DATABASE: prolog - ports: - - 13306:3306 - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 - - steps: - - name: Checkout Source Code - uses: actions/checkout@v2 - - - name: Set up JDK 1.8 - uses: actions/setup-java@v1.4.3 - with: - java-version: 1.8 - - - name: Grant execute permission for gradlew - run: chmod +x ./gradlew - shell: bash - working-directory: backend - - - name: Build with Gradle - run: ./gradlew flywayClean flywayBaseline flywayMigrate bootJar -Dflyway.baselineVersion=0 - shell: bash - working-directory: backend - - - name: Get current time - uses: 1466587594/get-current-time@v2 - id: current-time - with: - format: YYYY-MM-DDTHH-mm-ss - utcOffset: "+09:00" - - - name: Generate deployment package - run: | - cd backend - mkdir -p deploy - cp build/libs/*.jar deploy/application.jar - cp -r .ebextensions deploy/.ebextensions - cd deploy && zip -r deploy.zip . - - - name: Deploy to EB - uses: einaregilsson/beanstalk-deploy@v16 - with: - aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - application_name: pro-log - environment_name: Prolog-env-dev - version_label: github-action-${{steps.current-time.outputs.formattedTime}} - region: ap-northeast-2 - deployment_package: backend/deploy/deploy.zip diff --git a/.github/workflows/back-prod.yml b/.github/workflows/back-prod.yml deleted file mode 100644 index 48cd744ec..000000000 --- a/.github/workflows/back-prod.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: back deploy for prod - -on: - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - services: - mysql: - image: mysql:8.0.28 - env: - MYSQL_USER: user - MYSQL_PASSWORD: password - MYSQL_ROOT_PASSWORD: root - MYSQL_DATABASE: prolog - ports: - - 13306:3306 - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 - - steps: - - name: Checkout Source Code - uses: actions/checkout@v2 - - - name: Set up JDK 1.8 - uses: actions/setup-java@v1.4.3 - with: - java-version: 1.8 - - - name: Grant execute permission for gradlew - run: chmod +x ./gradlew - shell: bash - working-directory: backend - - - name: Build with Gradle - run: ./gradlew flywayClean flywayBaseline flywayMigrate bootJar -Dflyway.baselineVersion=0 - shell: bash - working-directory: backend - - - name: Get current time - uses: 1466587594/get-current-time@v2 - id: current-time - with: - format: YYYY-MM-DDTHH-mm-ss - utcOffset: "+09:00" - - - name: Generate deployment package - run: | - cd backend - mkdir -p deploy - cp build/libs/*.jar deploy/application.jar - cp -r .ebextensions deploy/.ebextensions - cd deploy && zip -r deploy.zip . - - - name: Deploy to EB - uses: einaregilsson/beanstalk-deploy@v16 - with: - aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - application_name: pro-log - environment_name: Prolog-env-prod - version_label: github-action-${{steps.current-time.outputs.formattedTime}} - region: ap-northeast-2 - deployment_package: backend/deploy/deploy.zip diff --git a/.github/workflows/back.yml b/.github/workflows/back.yml new file mode 100644 index 000000000..739ddc94e --- /dev/null +++ b/.github/workflows/back.yml @@ -0,0 +1,74 @@ +name: back deploy + +on: + workflow_dispatch: + inputs: + environment: + description: 'Target environment (dev, prod)' + required: true + default: 'dev' + +jobs: + deploy: + runs-on: ubuntu-latest + environment: ${{ github.event.inputs.environment }} + services: + mysql: + image: mysql:8.0.28 + env: + MYSQL_USER: user + MYSQL_PASSWORD: password + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: prolog + ports: + - 13306:3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + + steps: + - name: Checkout Source Code + uses: actions/checkout@v2 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: 'corretto' + java-version: 21 + + - name: Grant execute permission for gradlew + run: chmod +x ./gradlew + shell: bash + working-directory: backend + + - name: Build with Gradle + run: ./gradlew flywayClean flywayBaseline flywayMigrate bootJar -Dflyway.baselineVersion=0 + shell: bash + working-directory: backend + + - name: Generate deployment package + working-directory: backend + run: | + mkdir -p deploy + cp build/libs/*.jar deploy/app.jar + cp appspec.yml deploy/appspec.yml + cp -r scripts deploy/scripts + cd deploy && zip -r app.zip . + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + + - name: Upload to S3 + run: | + aws s3 cp backend/deploy/app.zip s3://${{ secrets.BUCKET_NAME }}/app.zip + + - name: Trigger AWS CodeDeploy + run: | + aws deploy create-deployment \ + --application-name ${{ secrets.APPLICATION_NAME }} \ + --deployment-group-name ${{ secrets.DEPLOYMENT_GROUP_NAME }} \ + --s3-location bucket=${{ secrets.BUCKET_NAME }},key=app.zip,bundleType=zip \ + --deployment-config-name CodeDeployDefault.AllAtOnce \ + --auto-rollback-configuration enabled=true,events=DEPLOYMENT_FAILURE diff --git a/.github/workflows/sonar-build.yml b/.github/workflows/sonar-build.yml index 0cd5a1e48..9b323ff3c 100644 --- a/.github/workflows/sonar-build.yml +++ b/.github/workflows/sonar-build.yml @@ -25,10 +25,11 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - name: Set up JDK 11 - uses: actions/setup-java@v1 + - name: Set up JDK 21 + uses: actions/setup-java@v4 with: - java-version: 11 + distribution: 'corretto' + java-version: 21 - name: Cache SonarCloud packages uses: actions/cache@v1 with: diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml new file mode 100644 index 000000000..a6c14fc21 --- /dev/null +++ b/.github/workflows/terraform.yml @@ -0,0 +1,35 @@ +name: terraform deploy + +on: + workflow_dispatch: + inputs: + environment: + description: 'Target environment (dev, prod)' + required: true + default: 'dev' + +jobs: + deploy: + runs-on: ubuntu-latest + env: + TF_API_TOKEN: ${{ secrets.TF_API_TOKEN }} + + steps: + - name: Checkout Source Code + uses: actions/checkout@v2 + + - name: Set up Terraform + uses: hashicorp/setup-terraform@v2 + with: + terraform_version: 1.5.3 + + - name: Select workspace + run: | + ENVIRONMENT=${{ github.event.inputs.environment }} + terraform workspace select "$ENVIRONMENT" || terraform workspace new "$ENVIRONMENT" + + - name: Terraform Init and Apply + run: | + terraform init + terraform plan -out=tfplan + terraform apply tfplan diff --git a/.gitignore b/.gitignore index 2065e324d..fcdf3956d 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,41 @@ ### direnv ### .envrc + +# Terraform state files +*.tfstate +*.tfstate.* + +# Backup files created by Terraform +*.tfstate.backup + +# Crash log files +crash.log + +# Terraform variable files containing sensitive data +*.tfvars +*.tfvars.json + +# Terraform plan files +tfplan +*.tfplan + +# Terraform override files +override.tf +override.tf.json +*_override.tf +*_override.tf.json + +# Terraform provider plugins +.terraform/ +.terraform.lock.hcl + +# Local command logs +.terraform.rc +terraform.rc + +# Deploy folder +backend/deploy + +# Private key +private_key.pem diff --git a/backend/.ebextensions/01-set-timezone.config b/backend/.ebextensions/01-set-timezone.config deleted file mode 100644 index f74207638..000000000 --- a/backend/.ebextensions/01-set-timezone.config +++ /dev/null @@ -1,6 +0,0 @@ - -commands: - 01-remove_local: - command: rm -rf /etc/localtime - 02-link_seoul_zone: - command: ln -s /usr/share/zoneinfo/Asia/Seoul /etc/localtime diff --git a/backend/.ebextensions/02-set-filebeat.config b/backend/.ebextensions/02-set-filebeat.config deleted file mode 100644 index c85323769..000000000 --- a/backend/.ebextensions/02-set-filebeat.config +++ /dev/null @@ -1,27 +0,0 @@ -{ - "files": { - "/tmp/make_filebeat_yml.sh": { - "mode": "000755", - "content": "#!/bin/bash\nPASSWORD=$(sudo /opt/elasticbeanstalk/bin/get-config environment -k ELASTICSEARCH_PASSWORD)\nHOST=$(sudo /opt/elasticbeanstalk/bin/get-config environment -k ELASTICSEARCH_HOST)\nPORT=$(sudo /opt/elasticbeanstalk/bin/get-config environment -k ELASTICSEARCH_PORT)\nUSER=$(sudo /opt/elasticbeanstalk/bin/get-config environment -k ELASTICSEARCH_USER)\ncat > /home/ec2-user/filebeat-7.14.1-linux-x86_64/filebeat.yml < filebeat.log 2>&1 &)\necho \"Filebeat restarted\"\n" - } - }, - "commands": { - "01_run_install_filebeat": { - "command": "bash /tmp/install_filebeat.sh" - }, - "02_run_make_filebeat_yml_script": { - "command": "bash /tmp/make_filebeat_yml.sh" - }, - "03_run_filebeat": { - "command": "bash /tmp/restart_filebeat.sh" - } - } -} diff --git a/backend/appspec.yml b/backend/appspec.yml new file mode 100644 index 000000000..342cbc394 --- /dev/null +++ b/backend/appspec.yml @@ -0,0 +1,27 @@ +version: 0.0 +os: linux + +files: + - source: /app.jar + destination: /home/ec2-user/ + +hooks: + ApplicationStop: + - location: scripts/stop-app.sh + timeout: 300 + runas: ec2-user + + BeforeInstall: + - location: scripts/before-install.sh + timeout: 300 + runas: ec2-user + + AfterInstall: + - location: scripts/after-install.sh + timeout: 300 + runas: ec2-user + + ApplicationStart: + - location: scripts/start-app.sh + timeout: 300 + runas: ec2-user diff --git a/backend/build.gradle b/backend/build.gradle index 4e0c9f206..d5940a1ef 100644 --- a/backend/build.gradle +++ b/backend/build.gradle @@ -2,16 +2,16 @@ plugins { id 'java' id 'idea' id "jacoco" - id 'org.springframework.boot' version '2.4.5' - id 'io.spring.dependency-management' version '1.0.11.RELEASE' + id 'org.springframework.boot' version '3.4.1' + id 'io.spring.dependency-management' version '1.1.6' id "org.sonarqube" version "3.3" id 'org.flywaydb.flyway' version "6.4.2" } group = 'wooteco' version = '0.0.1-SNAPSHOT' -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 +sourceCompatibility = JavaVersion.VERSION_21 +targetCompatibility = JavaVersion.VERSION_21 repositories { mavenCentral() @@ -48,7 +48,7 @@ dependencies { implementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.2.4' // rest-assured - acceptanceTestImplementation 'io.rest-assured:rest-assured:3.3.0' + acceptanceTestImplementation 'io.rest-assured:rest-assured' // cucumber acceptanceTestImplementation 'io.cucumber:cucumber-java:6.10.4' @@ -56,19 +56,15 @@ dependencies { acceptanceTestImplementation 'io.cucumber:cucumber-junit-platform-engine:6.10.4' //lombok - compileOnly 'org.projectlombok:lombok:1.18.20' + compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' // reflections implementation 'org.reflections:reflections:0.9.10' - // elastic-search - implementation 'org.springframework.boot:spring-boot-starter-data-elasticsearch' - implementation "org.testcontainers:elasticsearch:1.15.3" - testImplementation "org.testcontainers:elasticsearch:1.16.0" - //flyway - implementation 'org.flywaydb:flyway-core:6.4.2' + implementation 'org.flywaydb:flyway-core' + implementation 'org.flywaydb:flyway-mysql' // embedded mysql implementation 'com.wix:wix-embedded-mysql:4.6.2' @@ -95,7 +91,7 @@ dependencies { implementation group: 'commons-io', name: 'commons-io', version: '2.11.0' runtimeOnly 'com.h2database:h2' - runtimeOnly 'mysql:mysql-connector-java' + runtimeOnly 'com.mysql:mysql-connector-j' // jsoup implementation group: 'org.jsoup', name: 'jsoup', version: '1.16.1' @@ -103,6 +99,9 @@ dependencies { // swagger implementation 'io.springfox:springfox-boot-starter:3.0.0' + // aws secrets manager + implementation 'org.springframework.cloud:spring-cloud-starter-bootstrap:4.2.0' + implementation 'io.awspring.cloud:spring-cloud-starter-aws-secrets-manager-config:2.4.4' } ext { @@ -119,7 +118,7 @@ test { jacocoTestReport { reports { - xml.enabled true + xml.required.set(true) } } diff --git a/backend/docker/docker-compose.yml b/backend/docker/docker-compose.yml index 2c21a4ad5..14c8301e3 100644 --- a/backend/docker/docker-compose.yml +++ b/backend/docker/docker-compose.yml @@ -23,12 +23,3 @@ services: MYSQL_PASSWORD: password TZ: Asia/Seoul command: ["mysqld", "--character-set-server=utf8mb4", "--collation-server=utf8mb4_general_ci"] - elasticsearch: - image: docker.elastic.co/elasticsearch/elasticsearch:7.14.0 - container_name: elasticsearch - restart: always - ports: - - "9200:9200" - environment: - - "discovery.type=single-node" - - "ES_JAVA_OPTS=-Xms512m -Xmx512m" diff --git a/backend/gradle/wrapper/gradle-wrapper.jar b/backend/gradle/wrapper/gradle-wrapper.jar index e708b1c02..a4b76b953 100644 Binary files a/backend/gradle/wrapper/gradle-wrapper.jar and b/backend/gradle/wrapper/gradle-wrapper.jar differ diff --git a/backend/gradle/wrapper/gradle-wrapper.properties b/backend/gradle/wrapper/gradle-wrapper.properties index 442d9132e..9355b4155 100644 --- a/backend/gradle/wrapper/gradle-wrapper.properties +++ b/backend/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/backend/gradlew b/backend/gradlew index 4f906e0c8..f5feea6d6 100755 --- a/backend/gradlew +++ b/backend/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# 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. @@ -15,69 +15,104 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## -## -## Gradle start up script for UN*X -## +# +# 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/HEAD/platforms/jvm/plugins-application/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 -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +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 -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$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"' +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +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 - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +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 @@ -87,9 +122,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 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" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -98,88 +133,120 @@ 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. + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + 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 fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -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" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +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 - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + 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 - i=`expr $i + 1` + # 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 - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +# 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"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# 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" "$@" diff --git a/backend/gradlew.bat b/backend/gradlew.bat index 107acd32c..9d21a2183 100644 --- a/backend/gradlew.bat +++ b/backend/gradlew.bat @@ -13,8 +13,10 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +27,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,13 +43,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 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. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -56,11 +59,11 @@ 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. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -75,13 +78,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 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 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/backend/scripts/after-install.sh b/backend/scripts/after-install.sh new file mode 100644 index 000000000..395729b5d --- /dev/null +++ b/backend/scripts/after-install.sh @@ -0,0 +1,4 @@ +#!/bin/bash +echo "Setting permissions..." + +sudo chmod +x /home/ec2-user/app.jar diff --git a/backend/scripts/before-install.sh b/backend/scripts/before-install.sh new file mode 100644 index 000000000..34aaf12d5 --- /dev/null +++ b/backend/scripts/before-install.sh @@ -0,0 +1,3 @@ +#!/bin/bash +echo "Preparing for application installation..." +rm -rf /home/ec2-user/app.jar diff --git a/backend/scripts/start-app.sh b/backend/scripts/start-app.sh new file mode 100644 index 000000000..105c77d77 --- /dev/null +++ b/backend/scripts/start-app.sh @@ -0,0 +1,6 @@ +#!/bin/bash +echo "Starting application..." + +source /etc/environment + +sudo nohup java -jar /home/ec2-user/app.jar > /home/ec2-user/app.log 2>&1 & diff --git a/backend/scripts/stop-app.sh b/backend/scripts/stop-app.sh new file mode 100644 index 000000000..fd4e11664 --- /dev/null +++ b/backend/scripts/stop-app.sh @@ -0,0 +1,4 @@ +#!/bin/bash +echo "Stopping application..." + +sudo pkill -f app.jar || true diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/AcceptanceContext.java b/backend/src/acceptanceTest/java/wooteco/prolog/AcceptanceContext.java index e60f51cbb..36213837c 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/AcceptanceContext.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/AcceptanceContext.java @@ -4,11 +4,12 @@ import io.restassured.http.ContentType; import io.restassured.response.Response; import io.restassured.specification.RequestSpecification; -import java.util.HashMap; -import java.util.Map; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import java.util.HashMap; +import java.util.Map; + @Component @Scope(scopeName = "cucumber-glue") public class AcceptanceContext { diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/AcceptanceHooks.java b/backend/src/acceptanceTest/java/wooteco/prolog/AcceptanceHooks.java index 660c830e9..fcf9cc063 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/AcceptanceHooks.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/AcceptanceHooks.java @@ -7,7 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.boot.test.web.server.LocalServerPort; import wooteco.prolog.common.DataInitializer; @CucumberContextConfiguration diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/GithubResponses.java b/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/GithubResponses.java index af8a73625..a1cd75ae1 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/GithubResponses.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/GithubResponses.java @@ -1,8 +1,9 @@ package wooteco.prolog.fixtures; -import java.util.Arrays; import org.apache.commons.lang3.StringUtils; +import java.util.Arrays; + public enum GithubResponses { 소롱("1", "access_token_1", "소롱", "soulG", "111111", "https://avatars.githubusercontent.com/u/52682603?v=4"), diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/LevellogFixture.java b/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/LevellogFixture.java index 356aeeee6..6d44fb50b 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/LevellogFixture.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/LevellogFixture.java @@ -1,10 +1,11 @@ package wooteco.prolog.fixtures; +import wooteco.prolog.levellogs.application.dto.LevelLogRequest; +import wooteco.prolog.levellogs.application.dto.SelfDiscussionRequest; + import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import wooteco.prolog.levellogs.application.dto.LevelLogRequest; -import wooteco.prolog.levellogs.application.dto.SelfDiscussionRequest; public class LevellogFixture { diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/PostAcceptanceFixture.java b/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/PostAcceptanceFixture.java index 742453193..feddca3ee 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/PostAcceptanceFixture.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/PostAcceptanceFixture.java @@ -1,5 +1,11 @@ package wooteco.prolog.fixtures; +import wooteco.prolog.studylog.application.dto.StudylogRequest; +import wooteco.prolog.studylog.application.dto.TagRequest; + +import java.util.Arrays; +import java.util.List; + import static java.util.stream.Collectors.toList; import static wooteco.prolog.fixtures.TagAcceptanceFixture.TAG1; import static wooteco.prolog.fixtures.TagAcceptanceFixture.TAG2; @@ -8,11 +14,6 @@ import static wooteco.prolog.fixtures.TagAcceptanceFixture.TAG5; import static wooteco.prolog.fixtures.TagAcceptanceFixture.TAG6; -import java.util.Arrays; -import java.util.List; -import wooteco.prolog.studylog.application.dto.StudylogRequest; -import wooteco.prolog.studylog.application.dto.TagRequest; - public enum PostAcceptanceFixture { POST1( "[자바][옵셔널] 학습log 제출합니다.", diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/SessionAcceptanceFixture.java b/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/SessionAcceptanceFixture.java index e49b725fa..75c02c8f4 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/SessionAcceptanceFixture.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/SessionAcceptanceFixture.java @@ -1,8 +1,9 @@ package wooteco.prolog.fixtures; +import wooteco.prolog.session.application.dto.SessionRequest; + import java.util.Arrays; import java.util.List; -import wooteco.prolog.session.application.dto.SessionRequest; public class SessionAcceptanceFixture { diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/StudylogAcceptanceFixture.java b/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/StudylogAcceptanceFixture.java index 78fce5b9f..184b04c28 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/StudylogAcceptanceFixture.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/StudylogAcceptanceFixture.java @@ -1,5 +1,12 @@ package wooteco.prolog.fixtures; +import wooteco.prolog.studylog.application.dto.StudylogRequest; +import wooteco.prolog.studylog.application.dto.TagRequest; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + import static java.util.stream.Collectors.toList; import static wooteco.prolog.fixtures.TagAcceptanceFixture.TAG1; import static wooteco.prolog.fixtures.TagAcceptanceFixture.TAG2; @@ -8,12 +15,6 @@ import static wooteco.prolog.fixtures.TagAcceptanceFixture.TAG5; import static wooteco.prolog.fixtures.TagAcceptanceFixture.TAG6; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import wooteco.prolog.studylog.application.dto.StudylogRequest; -import wooteco.prolog.studylog.application.dto.TagRequest; - public enum StudylogAcceptanceFixture { STUDYLOG1( "[자바][옵셔널] 학습log 제출합니다.", @@ -99,7 +100,7 @@ public enum StudylogAcceptanceFixture { "진짜 어려움", 1L, 1L, - Arrays.asList(4L) + List.of(4L) ); private final StudylogRequest studylogRequest; diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/steps/ArticleStepDefinitions.java b/backend/src/acceptanceTest/java/wooteco/prolog/steps/ArticleStepDefinitions.java index 8dbd8d4d1..e945a0af0 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/steps/ArticleStepDefinitions.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/steps/ArticleStepDefinitions.java @@ -1,20 +1,21 @@ package wooteco.prolog.steps; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertAll; -import static wooteco.prolog.fixtures.ArticleFixture.ARTICLE_REQUEST1; -import static wooteco.prolog.fixtures.ArticleFixture.ARTICLE_REQUEST2; - import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; -import java.util.List; import org.springframework.http.HttpStatus; import wooteco.prolog.AcceptanceSteps; import wooteco.prolog.article.application.dto.ArticleBookmarkRequest; import wooteco.prolog.article.application.dto.ArticleResponse; import wooteco.prolog.article.application.dto.ArticleUrlResponse; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertAll; +import static wooteco.prolog.fixtures.ArticleFixture.ARTICLE_REQUEST1; +import static wooteco.prolog.fixtures.ArticleFixture.ARTICLE_REQUEST2; + public class ArticleStepDefinitions extends AcceptanceSteps { @@ -139,7 +140,7 @@ public class ArticleStepDefinitions extends AcceptanceSteps { @When("{long}번 아티클에 조회수 추가요청을 보내면") public void 아티클에_조회수_추가요청을_보내면(final Long articleId) { context.invokeHttpPost( - String.format("/articles/%d/views", articleId),"" + String.format("/articles/%d/views", articleId), "" ); } diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/steps/BadgesStepDefinitions.java b/backend/src/acceptanceTest/java/wooteco/prolog/steps/BadgesStepDefinitions.java index 7dc4d2843..5ef7f8b16 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/steps/BadgesStepDefinitions.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/steps/BadgesStepDefinitions.java @@ -1,18 +1,19 @@ package wooteco.prolog.steps; -import static org.assertj.core.api.Assertions.assertThat; -import static wooteco.prolog.fixtures.StudylogAcceptanceFixture.STUDYLOG8; -import static wooteco.prolog.fixtures.StudylogAcceptanceFixture.STUDYLOG9; - import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; -import java.util.List; import org.springframework.http.HttpStatus; import wooteco.prolog.AcceptanceSteps; import wooteco.prolog.badge.domain.BadgeType; import wooteco.prolog.common.exception.ExceptionDto; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static wooteco.prolog.fixtures.StudylogAcceptanceFixture.STUDYLOG8; +import static wooteco.prolog.fixtures.StudylogAcceptanceFixture.STUDYLOG9; + public class BadgesStepDefinitions extends AcceptanceSteps { @When("존재하지 않는 멤버의 배지를 조회하면") diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/steps/CommentStepDefinitions.java b/backend/src/acceptanceTest/java/wooteco/prolog/steps/CommentStepDefinitions.java index 87d3dcdbe..e73f645d5 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/steps/CommentStepDefinitions.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/steps/CommentStepDefinitions.java @@ -1,13 +1,8 @@ package wooteco.prolog.steps; -import static org.assertj.core.api.Assertions.assertThat; -import static wooteco.prolog.fixtures.CommentAcceptanceFixture.COMMENT; -import static wooteco.prolog.fixtures.CommentAcceptanceFixture.UPDATED_COMMENT; - import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; -import org.elasticsearch.common.collect.List; import org.springframework.http.HttpStatus; import wooteco.prolog.AcceptanceSteps; import wooteco.prolog.fixtures.GithubResponses; @@ -15,6 +10,12 @@ import wooteco.prolog.studylog.application.dto.CommentResponse; import wooteco.prolog.studylog.application.dto.CommentsResponse; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static wooteco.prolog.fixtures.CommentAcceptanceFixture.COMMENT; +import static wooteco.prolog.fixtures.CommentAcceptanceFixture.UPDATED_COMMENT; + public class CommentStepDefinitions extends AcceptanceSteps { @Given("{long}번 스터디로그에 대한 댓글을 작성하고") diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/steps/CurriculumStepDefinitions.java b/backend/src/acceptanceTest/java/wooteco/prolog/steps/CurriculumStepDefinitions.java index 7985b65d2..c2ac1a272 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/steps/CurriculumStepDefinitions.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/steps/CurriculumStepDefinitions.java @@ -1,14 +1,14 @@ package wooteco.prolog.steps; -import static org.assertj.core.api.Assertions.assertThat; -import static wooteco.prolog.fixtures.CurriculumFixture.커리큘럼1_생성_요청_DTO; -import static wooteco.prolog.fixtures.CurriculumFixture.커리큘럼_수정_요청_DTO; - import io.cucumber.java.en.Then; import io.cucumber.java.en.When; import org.springframework.http.HttpStatus; import wooteco.prolog.AcceptanceSteps; +import static org.assertj.core.api.Assertions.assertThat; +import static wooteco.prolog.fixtures.CurriculumFixture.커리큘럼1_생성_요청_DTO; +import static wooteco.prolog.fixtures.CurriculumFixture.커리큘럼_수정_요청_DTO; + public class CurriculumStepDefinitions extends AcceptanceSteps { @When("커리큘럼을 생성하고") diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/steps/EssayAnswerStepDefinitions.java b/backend/src/acceptanceTest/java/wooteco/prolog/steps/EssayAnswerStepDefinitions.java index 8dca559fd..7c5ca1835 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/steps/EssayAnswerStepDefinitions.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/steps/EssayAnswerStepDefinitions.java @@ -1,7 +1,5 @@ package wooteco.prolog.steps; -import static org.assertj.core.api.Assertions.assertThat; - import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; @@ -10,6 +8,8 @@ import wooteco.prolog.roadmap.application.dto.EssayAnswerRequest; import wooteco.prolog.roadmap.application.dto.EssayAnswerUpdateRequest; +import static org.assertj.core.api.Assertions.assertThat; + public final class EssayAnswerStepDefinitions extends AcceptanceSteps { @Given("{long}번 퀴즈에 {string}(이)라는 답변을 생성하(면)(고)") diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/steps/FilterStepDefinitions.java b/backend/src/acceptanceTest/java/wooteco/prolog/steps/FilterStepDefinitions.java index 6b33c0745..347b73362 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/steps/FilterStepDefinitions.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/steps/FilterStepDefinitions.java @@ -1,12 +1,12 @@ package wooteco.prolog.steps; -import static org.assertj.core.api.Assertions.assertThat; - import io.cucumber.java.en.Then; import io.cucumber.java.en.When; import org.springframework.http.HttpStatus; import wooteco.prolog.AcceptanceSteps; +import static org.assertj.core.api.Assertions.assertThat; + public class FilterStepDefinitions extends AcceptanceSteps { @When("필터요청이 들어오면") diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/steps/GroupMemberStepDefinitions.java b/backend/src/acceptanceTest/java/wooteco/prolog/steps/GroupMemberStepDefinitions.java index 2474d7a39..36b4c2c92 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/steps/GroupMemberStepDefinitions.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/steps/GroupMemberStepDefinitions.java @@ -1,10 +1,5 @@ package wooteco.prolog.steps; -import static wooteco.prolog.member.domain.Part.ANDROID; -import static wooteco.prolog.member.domain.Part.BACKEND; -import static wooteco.prolog.member.domain.Part.FRONTEND; -import static wooteco.prolog.member.domain.Term.FOURTH; - import io.cucumber.java.en.Given; import wooteco.prolog.AcceptanceSteps; import wooteco.prolog.member.domain.Department; @@ -14,6 +9,11 @@ import wooteco.prolog.member.domain.repository.DepartmentRepository; import wooteco.prolog.member.domain.repository.MemberRepository; +import static wooteco.prolog.member.domain.Part.ANDROID; +import static wooteco.prolog.member.domain.Part.BACKEND; +import static wooteco.prolog.member.domain.Part.FRONTEND; +import static wooteco.prolog.member.domain.Term.FOURTH; + public class GroupMemberStepDefinitions extends AcceptanceSteps { private final MemberRepository memberRepository; diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/steps/KeywordRecommendedPostStepDefinitions.java b/backend/src/acceptanceTest/java/wooteco/prolog/steps/KeywordRecommendedPostStepDefinitions.java index d4b78a343..c2e315454 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/steps/KeywordRecommendedPostStepDefinitions.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/steps/KeywordRecommendedPostStepDefinitions.java @@ -1,7 +1,5 @@ package wooteco.prolog.steps; -import static org.assertj.core.api.Assertions.assertThat; - import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; @@ -9,13 +7,15 @@ import wooteco.prolog.AcceptanceSteps; import wooteco.prolog.roadmap.application.dto.RecommendedRequest; +import static org.assertj.core.api.Assertions.assertThat; + public class KeywordRecommendedPostStepDefinitions extends AcceptanceSteps { @Given("{int}번 키워드에 대해 추천 포스트 {string}를 작성하고") @When("{int}번 키워드에 대해 추천 포스트 {string}를 작성하면") public void 추천_포스트를_추가하면(int keywordId, String url) { context.invokeHttpPost( - "/keywords/"+keywordId+"/recommended-posts", + "/keywords/" + keywordId + "/recommended-posts", new RecommendedRequest(url) ); } @@ -23,7 +23,7 @@ public class KeywordRecommendedPostStepDefinitions extends AcceptanceSteps { @When("{int}번 키워드에 대한 {int}번 추천 포스트를 {string}로 수정하면") public void 추천_포스트를_수정하면(int keywordId, int recommendedId, String url) { context.invokeHttpPut( - "/keywords/"+keywordId+"/recommended-posts/"+recommendedId, + "/keywords/" + keywordId + "/recommended-posts/" + recommendedId, new RecommendedRequest(url)); } diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/steps/KeywordStepDefinitions.java b/backend/src/acceptanceTest/java/wooteco/prolog/steps/KeywordStepDefinitions.java index 4aff5b7f7..d6d5ef276 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/steps/KeywordStepDefinitions.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/steps/KeywordStepDefinitions.java @@ -1,8 +1,5 @@ package wooteco.prolog.steps; -import static org.assertj.core.api.Assertions.assertThat; -import static wooteco.prolog.fixtures.KeywordAcceptanceFixture.KEYWORD_REQUEST; - import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; @@ -10,6 +7,9 @@ import wooteco.prolog.AcceptanceSteps; import wooteco.prolog.session.application.dto.SessionRequest; +import static org.assertj.core.api.Assertions.assertThat; +import static wooteco.prolog.fixtures.KeywordAcceptanceFixture.KEYWORD_REQUEST; + public class KeywordStepDefinitions extends AcceptanceSteps { /** diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/steps/LevellogsStepDefinitions.java b/backend/src/acceptanceTest/java/wooteco/prolog/steps/LevellogsStepDefinitions.java index bf8e28994..6fc54f063 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/steps/LevellogsStepDefinitions.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/steps/LevellogsStepDefinitions.java @@ -1,17 +1,8 @@ package wooteco.prolog.steps; -import static org.apache.http.HttpHeaders.LOCATION; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; -import static org.junit.jupiter.api.Assertions.assertAll; -import static wooteco.prolog.fixtures.LevellogFixture.LEVEL_LOG_UPDATE_REQUEST; -import static wooteco.prolog.fixtures.LevellogFixture.levelLogRequests; - import io.cucumber.java.en.And; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; -import java.util.ArrayList; -import java.util.List; import org.springframework.http.HttpStatus; import wooteco.prolog.AcceptanceSteps; import wooteco.prolog.fixtures.LevellogFixture; @@ -21,6 +12,16 @@ import wooteco.prolog.levellogs.application.dto.LevelLogSummaryResponse; import wooteco.prolog.levellogs.application.dto.SelfDiscussionResponse; +import java.util.ArrayList; +import java.util.List; + +import static org.apache.http.HttpHeaders.LOCATION; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.tuple; +import static org.junit.jupiter.api.Assertions.assertAll; +import static wooteco.prolog.fixtures.LevellogFixture.LEVEL_LOG_UPDATE_REQUEST; +import static wooteco.prolog.fixtures.LevellogFixture.levelLogRequests; + public class LevellogsStepDefinitions extends AcceptanceSteps { @When("레벨로그를 작성하(고)(면)") diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/steps/LoginStepDefinitions.java b/backend/src/acceptanceTest/java/wooteco/prolog/steps/LoginStepDefinitions.java index 68e63c33b..868014a2f 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/steps/LoginStepDefinitions.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/steps/LoginStepDefinitions.java @@ -1,16 +1,17 @@ package wooteco.prolog.steps; -import static org.assertj.core.api.Assertions.assertThat; - import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; -import java.util.HashMap; import wooteco.prolog.AcceptanceSteps; import wooteco.prolog.fixtures.GithubResponses; import wooteco.prolog.login.application.dto.TokenResponse; import wooteco.prolog.member.application.dto.MemberResponse; +import java.util.HashMap; + +import static org.assertj.core.api.Assertions.assertThat; + public class LoginStepDefinitions extends AcceptanceSteps { @Given("{string}(이)(가) 크루역할로 로그인을 하고") diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/steps/MemberStepDefinitions.java b/backend/src/acceptanceTest/java/wooteco/prolog/steps/MemberStepDefinitions.java index df43e7105..1253042a8 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/steps/MemberStepDefinitions.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/steps/MemberStepDefinitions.java @@ -1,7 +1,5 @@ package wooteco.prolog.steps; -import static org.assertj.core.api.Assertions.assertThat; - import io.cucumber.java.en.Then; import io.cucumber.java.en.When; import wooteco.prolog.AcceptanceSteps; @@ -11,6 +9,8 @@ import wooteco.prolog.member.application.dto.MemberUpdateRequest; import wooteco.prolog.studylog.application.dto.StudylogsResponse; +import static org.assertj.core.api.Assertions.assertThat; + public class MemberStepDefinitions extends AcceptanceSteps { @When("{string}의 멤버 정보를 조회하면") diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/steps/MissionStepDefinitions.java b/backend/src/acceptanceTest/java/wooteco/prolog/steps/MissionStepDefinitions.java index 853642e31..5067520e0 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/steps/MissionStepDefinitions.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/steps/MissionStepDefinitions.java @@ -1,11 +1,8 @@ package wooteco.prolog.steps; -import static org.assertj.core.api.Assertions.assertThat; - import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; -import java.util.List; import org.springframework.http.HttpStatus; import wooteco.prolog.AcceptanceSteps; import wooteco.prolog.fixtures.MissionAcceptanceFixture; @@ -14,6 +11,10 @@ import wooteco.prolog.session.application.dto.MissionResponse; import wooteco.prolog.session.application.dto.SessionRequest; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + public class MissionStepDefinitions extends AcceptanceSteps { @Given("세션 여러개를 생성하고") diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/steps/NewSessionStepDefinitions.java b/backend/src/acceptanceTest/java/wooteco/prolog/steps/NewSessionStepDefinitions.java index 27ab53f13..84899823a 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/steps/NewSessionStepDefinitions.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/steps/NewSessionStepDefinitions.java @@ -1,7 +1,5 @@ package wooteco.prolog.steps; -import static org.assertj.core.api.Assertions.assertThat; - import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; @@ -9,6 +7,8 @@ import wooteco.prolog.AcceptanceSteps; import wooteco.prolog.session.application.dto.SessionRequest; +import static org.assertj.core.api.Assertions.assertThat; + public class NewSessionStepDefinitions extends AcceptanceSteps { @Given("{int}번 커리큘럼에 {string} 세션을 작성하고") diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/steps/ProfileStepDefinitions.java b/backend/src/acceptanceTest/java/wooteco/prolog/steps/ProfileStepDefinitions.java index 557ab26da..6ac5cc194 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/steps/ProfileStepDefinitions.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/steps/ProfileStepDefinitions.java @@ -1,16 +1,16 @@ package wooteco.prolog.steps; -import static org.assertj.core.api.Assertions.assertThat; - import io.cucumber.java.en.Then; import io.cucumber.java.en.When; import wooteco.prolog.AcceptanceSteps; import wooteco.prolog.fixtures.GithubResponses; -import wooteco.prolog.member.application.dto.MemberResponse; import wooteco.prolog.member.application.dto.ProfileIntroRequest; import wooteco.prolog.member.application.dto.ProfileIntroResponse; +import wooteco.prolog.member.application.dto.ProfileResponse; import wooteco.prolog.studylog.application.dto.StudylogsResponse; +import static org.assertj.core.api.Assertions.assertThat; + public class ProfileStepDefinitions extends AcceptanceSteps { @When("{string}의 멤버 프로필을 조회하면") @@ -34,7 +34,7 @@ public class ProfileStepDefinitions extends AcceptanceSteps { @Then("{string}의 멤버 프로필이 조회된다") public void 멤버프로필이조회된다(String member) { - String memberName = context.response.as(MemberResponse.class).getNickname(); + String memberName = context.response.as(ProfileResponse.class).getNickname(); assertThat(memberName).isEqualTo(member); } diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/steps/QuizStepDefinitions.java b/backend/src/acceptanceTest/java/wooteco/prolog/steps/QuizStepDefinitions.java index a5ad8fa6b..2c9f3cecd 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/steps/QuizStepDefinitions.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/steps/QuizStepDefinitions.java @@ -1,13 +1,13 @@ package wooteco.prolog.steps; -import static org.assertj.core.api.Assertions.assertThat; - import io.cucumber.java.en.Then; import io.cucumber.java.en.When; import org.springframework.http.HttpStatus; import wooteco.prolog.AcceptanceSteps; import wooteco.prolog.roadmap.application.dto.QuizRequest; +import static org.assertj.core.api.Assertions.assertThat; + public class QuizStepDefinitions extends AcceptanceSteps { diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/steps/SessionMemberStepDefinitions.java b/backend/src/acceptanceTest/java/wooteco/prolog/steps/SessionMemberStepDefinitions.java index 4a182923a..4b163a05c 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/steps/SessionMemberStepDefinitions.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/steps/SessionMemberStepDefinitions.java @@ -1,17 +1,18 @@ package wooteco.prolog.steps; -import static org.assertj.core.api.Assertions.assertThat; - import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; -import java.util.HashMap; import org.springframework.http.HttpStatus; import wooteco.prolog.AcceptanceSteps; import wooteco.prolog.fixtures.GithubResponses; import wooteco.prolog.login.application.dto.TokenResponse; import wooteco.prolog.session.application.dto.SessionRequest; +import java.util.HashMap; + +import static org.assertj.core.api.Assertions.assertThat; + public class SessionMemberStepDefinitions extends AcceptanceSteps { @Given("{string} 이 로그인을 하공") diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/steps/SessionStepDefinitions.java b/backend/src/acceptanceTest/java/wooteco/prolog/steps/SessionStepDefinitions.java index 0b6e6bce9..b3fb98e2d 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/steps/SessionStepDefinitions.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/steps/SessionStepDefinitions.java @@ -1,15 +1,16 @@ package wooteco.prolog.steps; -import static org.assertj.core.api.Assertions.assertThat; - import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; -import java.util.List; import org.springframework.http.HttpStatus; import wooteco.prolog.AcceptanceSteps; import wooteco.prolog.session.application.dto.SessionRequest; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + public class SessionStepDefinitions extends AcceptanceSteps { @Given("강의 여러개를 작성하고") diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/steps/StudylogOverviewStepDefinitions.java b/backend/src/acceptanceTest/java/wooteco/prolog/steps/StudylogOverviewStepDefinitions.java index 3604ba9ec..a8e83c2bf 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/steps/StudylogOverviewStepDefinitions.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/steps/StudylogOverviewStepDefinitions.java @@ -1,13 +1,7 @@ package wooteco.prolog.steps; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - import io.cucumber.java.en.Then; import io.cucumber.java.en.When; -import java.time.MonthDay; -import java.time.Year; -import java.util.List; import wooteco.prolog.AcceptanceSteps; import wooteco.prolog.fixtures.GithubResponses; import wooteco.prolog.fixtures.PostAcceptanceFixture; @@ -15,6 +9,13 @@ import wooteco.prolog.studylog.application.dto.CalendarStudylogResponse; import wooteco.prolog.studylog.application.dto.MemberTagResponse; +import java.time.MonthDay; +import java.time.Year; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.tuple; + public class StudylogOverviewStepDefinitions extends AcceptanceSteps { @When("{string}의 태그 목록을 조회하면") diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/steps/StudylogStepDefinitions.java b/backend/src/acceptanceTest/java/wooteco/prolog/steps/StudylogStepDefinitions.java index ffaf15cdf..d890e798d 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/steps/StudylogStepDefinitions.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/steps/StudylogStepDefinitions.java @@ -1,26 +1,10 @@ package wooteco.prolog.steps; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertAll; -import static wooteco.prolog.fixtures.StudylogAcceptanceFixture.STUDYLOG1; -import static wooteco.prolog.fixtures.StudylogAcceptanceFixture.STUDYLOG10; -import static wooteco.prolog.fixtures.StudylogAcceptanceFixture.STUDYLOG2; -import static wooteco.prolog.fixtures.StudylogAcceptanceFixture.STUDYLOG3; -import static wooteco.prolog.fixtures.StudylogAcceptanceFixture.STUDYLOG4; -import static wooteco.prolog.fixtures.TagAcceptanceFixture.TAG1; -import static wooteco.prolog.fixtures.TagAcceptanceFixture.TAG2; - import com.google.common.collect.Iterables; import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; import io.cucumber.messages.internal.com.google.common.collect.Lists; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; import org.springframework.http.HttpStatus; import wooteco.prolog.AcceptanceSteps; import wooteco.prolog.fixtures.StudylogAcceptanceFixture; @@ -32,6 +16,23 @@ import wooteco.prolog.studylog.application.dto.StudylogsResponse; import wooteco.prolog.studylog.application.dto.TagRequest; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertAll; +import static wooteco.prolog.fixtures.StudylogAcceptanceFixture.STUDYLOG1; +import static wooteco.prolog.fixtures.StudylogAcceptanceFixture.STUDYLOG10; +import static wooteco.prolog.fixtures.StudylogAcceptanceFixture.STUDYLOG2; +import static wooteco.prolog.fixtures.StudylogAcceptanceFixture.STUDYLOG3; +import static wooteco.prolog.fixtures.StudylogAcceptanceFixture.STUDYLOG4; +import static wooteco.prolog.fixtures.TagAcceptanceFixture.TAG1; +import static wooteco.prolog.fixtures.TagAcceptanceFixture.TAG2; + public class StudylogStepDefinitions extends AcceptanceSteps { @Given("스터디로그 여러개를 작성하고") diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/steps/TagStepDefinitions.java b/backend/src/acceptanceTest/java/wooteco/prolog/steps/TagStepDefinitions.java index 35ca16e43..fb9f5c565 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/steps/TagStepDefinitions.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/steps/TagStepDefinitions.java @@ -1,14 +1,15 @@ package wooteco.prolog.steps; -import static org.assertj.core.api.Assertions.assertThat; - import io.cucumber.java.en.Then; import io.cucumber.java.en.When; -import java.util.List; import org.springframework.http.HttpStatus; import wooteco.prolog.AcceptanceSteps; import wooteco.prolog.studylog.application.dto.TagResponse; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + public class TagStepDefinitions extends AcceptanceSteps { @Then("태그도 작성된다") diff --git a/backend/src/acceptanceTest/resources/logback-spring.xml b/backend/src/acceptanceTest/resources/logback-spring.xml index 707c117bc..c8107f4fb 100644 --- a/backend/src/acceptanceTest/resources/logback-spring.xml +++ b/backend/src/acceptanceTest/resources/logback-spring.xml @@ -18,12 +18,12 @@ + additivity="false"> + additivity="false"> diff --git a/backend/src/acceptanceTest/resources/wooteco/prolog/studylog.feature b/backend/src/acceptanceTest/resources/wooteco/prolog/studylog.feature index 320377e33..c494e2085 100644 --- a/backend/src/acceptanceTest/resources/wooteco/prolog/studylog.feature +++ b/backend/src/acceptanceTest/resources/wooteco/prolog/studylog.feature @@ -58,15 +58,16 @@ Feature: 스터디로그 관련 기능 When 1번 미션과 1번 태그로 20개를 조회하면 Then 13개의 스터디로그 목록을 받는다 - Scenario: 조건별 스터디로그 목록 페이지 조회하기 - 검색어 - Given 서로 다른 태그와 미션을 가진 스터디로그를 다수 생성하고 - When "학습log"을 검색하면 - Then 10개의 스터디로그 목록을 받는다 - - Scenario: 조건별 스터디로그 목록 페이지 조회하기 - 검색어 - Given 서로 다른 태그와 미션을 가진 스터디로그를 다수 생성하고 - When "학습log"을 검색하면 - Then 10개의 스터디로그를 id의 역순으로 받는다 +# TODO: ES와 같이 제거됨. 다시 구현 필요 +# Scenario: 조건별 스터디로그 목록 페이지 조회하기 - 검색어 +# Given 서로 다른 태그와 미션을 가진 스터디로그를 다수 생성하고 +# When "학습log"을 검색하면 +# Then 10개의 스터디로그 목록을 받는다 +# +# Scenario: 조건별 스터디로그 목록 페이지 조회하기 - 검색어 +# Given 서로 다른 태그와 미션을 가진 스터디로그를 다수 생성하고 +# When "학습log"을 검색하면 +# Then 10개의 스터디로그를 id의 역순으로 받는다 Scenario: 조건별 스터디로그 목록 페이지 조회하기 - 검색어 + 태그 Given 서로 다른 태그와 미션을 가진 스터디로그를 다수 생성하고 diff --git a/backend/src/main/java/wooteco/prolog/DataLoaderApplicationListener.java b/backend/src/main/java/wooteco/prolog/DataLoaderApplicationListener.java index f62733ce7..c7a3103af 100644 --- a/backend/src/main/java/wooteco/prolog/DataLoaderApplicationListener.java +++ b/backend/src/main/java/wooteco/prolog/DataLoaderApplicationListener.java @@ -1,20 +1,7 @@ package wooteco.prolog; -import static java.util.stream.Collectors.toList; -import static java.util.stream.Collectors.toMap; - -import java.security.SecureRandom; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.Set; -import java.util.function.Function; -import java.util.stream.Collectors; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; import lombok.AllArgsConstructor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -43,6 +30,20 @@ import wooteco.prolog.studylog.domain.repository.StudylogRepository; import wooteco.prolog.studylog.domain.repository.TagRepository; +import java.security.SecureRandom; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.Set; +import java.util.function.Function; +import java.util.stream.Collectors; + +import static java.util.stream.Collectors.toList; +import static java.util.stream.Collectors.toMap; + /** * prolog 서비스를 띄울 때 기본 데이터가 없다면 기본 데이터를 추가한다. */ diff --git a/backend/src/main/java/wooteco/prolog/PrologApplication.java b/backend/src/main/java/wooteco/prolog/PrologApplication.java index 203fce9c4..2707c5495 100644 --- a/backend/src/main/java/wooteco/prolog/PrologApplication.java +++ b/backend/src/main/java/wooteco/prolog/PrologApplication.java @@ -1,11 +1,12 @@ package wooteco.prolog; -import java.util.TimeZone; -import javax.annotation.PostConstruct; +import jakarta.annotation.PostConstruct; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.scheduling.annotation.EnableScheduling; +import java.util.TimeZone; + @EnableScheduling @SpringBootApplication public class PrologApplication { diff --git a/backend/src/main/java/wooteco/prolog/article/application/ArticleService.java b/backend/src/main/java/wooteco/prolog/article/application/ArticleService.java index 3f232b324..ae58054fc 100644 --- a/backend/src/main/java/wooteco/prolog/article/application/ArticleService.java +++ b/backend/src/main/java/wooteco/prolog/article/application/ArticleService.java @@ -1,14 +1,6 @@ package wooteco.prolog.article.application; -import static java.util.stream.Collectors.toList; -import static wooteco.prolog.common.exception.BadRequestCode.ARTICLE_NOT_FOUND_EXCEPTION; -import static wooteco.prolog.common.exception.BadRequestCode.MEMBER_NOT_ALLOWED; - import com.google.common.collect.Lists; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; import lombok.RequiredArgsConstructor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -29,6 +21,15 @@ import wooteco.prolog.member.domain.MemberUpdatedEvent; import wooteco.prolog.member.domain.Role; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; + +import static java.util.stream.Collectors.toList; +import static wooteco.prolog.common.exception.BadRequestCode.ARTICLE_NOT_FOUND_EXCEPTION; +import static wooteco.prolog.common.exception.BadRequestCode.MEMBER_NOT_ALLOWED; + @RequiredArgsConstructor @Service @Transactional(readOnly = true) diff --git a/backend/src/main/java/wooteco/prolog/article/application/MetaOgService.java b/backend/src/main/java/wooteco/prolog/article/application/MetaOgService.java index c0f45a1e5..667dcbfe5 100644 --- a/backend/src/main/java/wooteco/prolog/article/application/MetaOgService.java +++ b/backend/src/main/java/wooteco/prolog/article/application/MetaOgService.java @@ -1,12 +1,13 @@ package wooteco.prolog.article.application; -import java.util.Map; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import wooteco.prolog.article.application.OgTagParser.OgType; import wooteco.prolog.article.application.dto.ArticleUrlRequest; import wooteco.prolog.article.application.dto.ArticleUrlResponse; +import java.util.Map; + @RequiredArgsConstructor @Service public class MetaOgService { diff --git a/backend/src/main/java/wooteco/prolog/article/application/OgTagParser.java b/backend/src/main/java/wooteco/prolog/article/application/OgTagParser.java index f246ca6c9..ef936eeb3 100644 --- a/backend/src/main/java/wooteco/prolog/article/application/OgTagParser.java +++ b/backend/src/main/java/wooteco/prolog/article/application/OgTagParser.java @@ -1,10 +1,5 @@ package wooteco.prolog.article.application; -import java.util.Arrays; -import java.util.Map; -import java.util.Optional; -import java.util.function.Function; -import java.util.stream.Collectors; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; @@ -12,6 +7,12 @@ import wooteco.prolog.common.exception.BadRequestCode; import wooteco.prolog.common.exception.BadRequestException; +import java.util.Arrays; +import java.util.Map; +import java.util.Optional; +import java.util.function.Function; +import java.util.stream.Collectors; + @Component public class OgTagParser { diff --git a/backend/src/main/java/wooteco/prolog/article/application/RssClient.java b/backend/src/main/java/wooteco/prolog/article/application/RssClient.java index efe910be9..476453015 100644 --- a/backend/src/main/java/wooteco/prolog/article/application/RssClient.java +++ b/backend/src/main/java/wooteco/prolog/article/application/RssClient.java @@ -1,16 +1,17 @@ package wooteco.prolog.article.application; -import static java.util.stream.Collectors.toList; - import com.rometools.rome.feed.synd.SyndFeed; import com.rometools.rome.io.SyndFeedInput; import com.rometools.rome.io.XmlReader; -import java.net.URL; -import java.util.ArrayList; import org.springframework.stereotype.Component; import wooteco.prolog.article.domain.RssFeed; import wooteco.prolog.article.domain.RssFeeds; +import java.net.URL; +import java.util.ArrayList; + +import static java.util.stream.Collectors.toList; + @Component public class RssClient { public RssFeeds fromRssFeedBy(String feedUrl) { diff --git a/backend/src/main/java/wooteco/prolog/article/application/SSLUtil.java b/backend/src/main/java/wooteco/prolog/article/application/SSLUtil.java index c6c246e82..197a0f321 100644 --- a/backend/src/main/java/wooteco/prolog/article/application/SSLUtil.java +++ b/backend/src/main/java/wooteco/prolog/article/application/SSLUtil.java @@ -1,11 +1,11 @@ package wooteco.prolog.article.application; -import java.security.cert.X509Certificate; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; +import java.security.cert.X509Certificate; public class SSLUtil { diff --git a/backend/src/main/java/wooteco/prolog/article/application/SlackService.java b/backend/src/main/java/wooteco/prolog/article/application/SlackService.java index cc38e4117..4b4fb7b2f 100644 --- a/backend/src/main/java/wooteco/prolog/article/application/SlackService.java +++ b/backend/src/main/java/wooteco/prolog/article/application/SlackService.java @@ -13,10 +13,6 @@ import com.slack.api.model.block.composition.MarkdownTextObject; import com.slack.api.model.block.composition.PlainTextObject; import com.slack.api.model.block.element.ButtonElement; -import java.io.IOException; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; import lombok.RequiredArgsConstructor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -25,6 +21,11 @@ import org.springframework.transaction.annotation.Transactional; import wooteco.prolog.article.domain.Article; +import java.io.IOException; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + @RequiredArgsConstructor @Service @Transactional(readOnly = true) @@ -81,7 +82,7 @@ public void sendSlackMessage(Article article) { .build(); ActionsBlock actionsBlock = ActionsBlock.builder() - .elements(Arrays.asList(buttonElement)) + .elements(Collections.singletonList(buttonElement)) .build(); // Divider block diff --git a/backend/src/main/java/wooteco/prolog/article/application/dto/ArticleRequest.java b/backend/src/main/java/wooteco/prolog/article/application/dto/ArticleRequest.java index 09a0d6bac..318ba8e73 100644 --- a/backend/src/main/java/wooteco/prolog/article/application/dto/ArticleRequest.java +++ b/backend/src/main/java/wooteco/prolog/article/application/dto/ArticleRequest.java @@ -1,6 +1,5 @@ package wooteco.prolog.article.application.dto; -import java.time.LocalDateTime; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; @@ -11,6 +10,8 @@ import wooteco.prolog.article.domain.Url; import wooteco.prolog.member.domain.Member; +import java.time.LocalDateTime; + @Getter @AllArgsConstructor @NoArgsConstructor diff --git a/backend/src/main/java/wooteco/prolog/article/application/dto/ArticleResponse.java b/backend/src/main/java/wooteco/prolog/article/application/dto/ArticleResponse.java index 163db81f8..1ca016ecc 100644 --- a/backend/src/main/java/wooteco/prolog/article/application/dto/ArticleResponse.java +++ b/backend/src/main/java/wooteco/prolog/article/application/dto/ArticleResponse.java @@ -1,10 +1,11 @@ package wooteco.prolog.article.application.dto; import com.fasterxml.jackson.annotation.JsonFormat; -import java.time.LocalDateTime; import lombok.AllArgsConstructor; import wooteco.prolog.article.domain.Article; +import java.time.LocalDateTime; + @AllArgsConstructor public class ArticleResponse { diff --git a/backend/src/main/java/wooteco/prolog/article/application/dto/ArticleUrlResponse.java b/backend/src/main/java/wooteco/prolog/article/application/dto/ArticleUrlResponse.java index ab087c6c1..31958a98a 100644 --- a/backend/src/main/java/wooteco/prolog/article/application/dto/ArticleUrlResponse.java +++ b/backend/src/main/java/wooteco/prolog/article/application/dto/ArticleUrlResponse.java @@ -1,10 +1,11 @@ package wooteco.prolog.article.application.dto; -import java.util.Map; import lombok.AllArgsConstructor; import lombok.Getter; import wooteco.prolog.article.application.OgTagParser.OgType; +import java.util.Map; + @Getter @AllArgsConstructor public class ArticleUrlResponse { diff --git a/backend/src/main/java/wooteco/prolog/article/domain/Article.java b/backend/src/main/java/wooteco/prolog/article/domain/Article.java index 9ca8a78cc..2d6f76e48 100644 --- a/backend/src/main/java/wooteco/prolog/article/domain/Article.java +++ b/backend/src/main/java/wooteco/prolog/article/domain/Article.java @@ -1,18 +1,15 @@ package wooteco.prolog.article.domain; -import static java.lang.Boolean.TRUE; - -import java.time.LocalDateTime; -import javax.persistence.Column; -import javax.persistence.Embedded; -import javax.persistence.Entity; -import javax.persistence.EntityListeners; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; +import jakarta.persistence.Column; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.EntityListeners; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -22,6 +19,10 @@ import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.member.domain.Member; +import java.time.LocalDateTime; + +import static java.lang.Boolean.TRUE; + @Entity @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) diff --git a/backend/src/main/java/wooteco/prolog/article/domain/ArticleBookmark.java b/backend/src/main/java/wooteco/prolog/article/domain/ArticleBookmark.java index 8c1686b3c..34691722b 100644 --- a/backend/src/main/java/wooteco/prolog/article/domain/ArticleBookmark.java +++ b/backend/src/main/java/wooteco/prolog/article/domain/ArticleBookmark.java @@ -1,17 +1,18 @@ package wooteco.prolog.article.domain; -import java.util.Objects; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; import lombok.AccessLevel; import lombok.NoArgsConstructor; +import java.util.Objects; + @Entity @NoArgsConstructor(access = AccessLevel.PROTECTED) @Table(name = "article_bookmark") diff --git a/backend/src/main/java/wooteco/prolog/article/domain/ArticleBookmarks.java b/backend/src/main/java/wooteco/prolog/article/domain/ArticleBookmarks.java index cb1d4f795..d65005936 100644 --- a/backend/src/main/java/wooteco/prolog/article/domain/ArticleBookmarks.java +++ b/backend/src/main/java/wooteco/prolog/article/domain/ArticleBookmarks.java @@ -1,12 +1,13 @@ package wooteco.prolog.article.domain; -import java.util.ArrayList; -import java.util.List; -import javax.persistence.Embeddable; -import javax.persistence.OneToMany; +import jakarta.persistence.Embeddable; +import jakarta.persistence.OneToMany; import org.hibernate.annotations.Cascade; import org.hibernate.annotations.CascadeType; +import java.util.ArrayList; +import java.util.List; + @Embeddable public class ArticleBookmarks { diff --git a/backend/src/main/java/wooteco/prolog/article/domain/ArticleLike.java b/backend/src/main/java/wooteco/prolog/article/domain/ArticleLike.java index 5ecd7cacc..c410db2d8 100644 --- a/backend/src/main/java/wooteco/prolog/article/domain/ArticleLike.java +++ b/backend/src/main/java/wooteco/prolog/article/domain/ArticleLike.java @@ -1,17 +1,18 @@ package wooteco.prolog.article.domain; -import java.util.Objects; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; import lombok.AccessLevel; import lombok.NoArgsConstructor; +import java.util.Objects; + @Entity @NoArgsConstructor(access = AccessLevel.PROTECTED) @Table(name = "article_like") diff --git a/backend/src/main/java/wooteco/prolog/article/domain/ArticleLikes.java b/backend/src/main/java/wooteco/prolog/article/domain/ArticleLikes.java index 3b0c65d23..6d6a66cc0 100644 --- a/backend/src/main/java/wooteco/prolog/article/domain/ArticleLikes.java +++ b/backend/src/main/java/wooteco/prolog/article/domain/ArticleLikes.java @@ -1,12 +1,13 @@ package wooteco.prolog.article.domain; -import java.util.ArrayList; -import java.util.List; -import javax.persistence.Embeddable; -import javax.persistence.OneToMany; +import jakarta.persistence.Embeddable; +import jakarta.persistence.OneToMany; import org.hibernate.annotations.Cascade; import org.hibernate.annotations.CascadeType; +import java.util.ArrayList; +import java.util.List; + @Embeddable public class ArticleLikes { diff --git a/backend/src/main/java/wooteco/prolog/article/domain/Description.java b/backend/src/main/java/wooteco/prolog/article/domain/Description.java index 1d39dd95e..0f09fc516 100644 --- a/backend/src/main/java/wooteco/prolog/article/domain/Description.java +++ b/backend/src/main/java/wooteco/prolog/article/domain/Description.java @@ -1,6 +1,6 @@ package wooteco.prolog.article.domain; -import javax.persistence.Embeddable; +import jakarta.persistence.Embeddable; import lombok.AccessLevel; import lombok.EqualsAndHashCode; import lombok.Getter; diff --git a/backend/src/main/java/wooteco/prolog/article/domain/ImageUrl.java b/backend/src/main/java/wooteco/prolog/article/domain/ImageUrl.java index c737ece7c..9496d6c93 100644 --- a/backend/src/main/java/wooteco/prolog/article/domain/ImageUrl.java +++ b/backend/src/main/java/wooteco/prolog/article/domain/ImageUrl.java @@ -1,14 +1,15 @@ package wooteco.prolog.article.domain; -import java.util.Objects; -import javax.persistence.Column; -import javax.persistence.Embeddable; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; import lombok.AccessLevel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.ToString; +import java.util.Objects; + @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @EqualsAndHashCode diff --git a/backend/src/main/java/wooteco/prolog/article/domain/RssFeed.java b/backend/src/main/java/wooteco/prolog/article/domain/RssFeed.java index e2325e8b2..04010d571 100644 --- a/backend/src/main/java/wooteco/prolog/article/domain/RssFeed.java +++ b/backend/src/main/java/wooteco/prolog/article/domain/RssFeed.java @@ -3,15 +3,16 @@ import com.rometools.rome.feed.synd.SyndContent; import com.rometools.rome.feed.synd.SyndEntry; import com.rometools.rome.feed.synd.SyndFeed; -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.util.Objects; import lombok.Getter; import org.jdom2.Element; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import wooteco.prolog.member.domain.Member; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.Objects; + @Getter public class RssFeed { private String title; diff --git a/backend/src/main/java/wooteco/prolog/article/domain/RssFeeds.java b/backend/src/main/java/wooteco/prolog/article/domain/RssFeeds.java index 72fed3039..e3f35147d 100644 --- a/backend/src/main/java/wooteco/prolog/article/domain/RssFeeds.java +++ b/backend/src/main/java/wooteco/prolog/article/domain/RssFeeds.java @@ -1,12 +1,13 @@ package wooteco.prolog.article.domain; -import static java.util.stream.Collectors.toList; +import lombok.AllArgsConstructor; +import lombok.Getter; import java.time.LocalDateTime; import java.util.Comparator; import java.util.List; -import lombok.AllArgsConstructor; -import lombok.Getter; + +import static java.util.stream.Collectors.toList; @Getter @AllArgsConstructor diff --git a/backend/src/main/java/wooteco/prolog/article/domain/Title.java b/backend/src/main/java/wooteco/prolog/article/domain/Title.java index 65603f850..d977a50b1 100644 --- a/backend/src/main/java/wooteco/prolog/article/domain/Title.java +++ b/backend/src/main/java/wooteco/prolog/article/domain/Title.java @@ -1,14 +1,15 @@ package wooteco.prolog.article.domain; -import java.util.Objects; -import javax.persistence.Column; -import javax.persistence.Embeddable; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; import lombok.AccessLevel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.ToString; +import java.util.Objects; + @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @EqualsAndHashCode diff --git a/backend/src/main/java/wooteco/prolog/article/domain/Url.java b/backend/src/main/java/wooteco/prolog/article/domain/Url.java index 28b7a05ed..1bc02b9b0 100644 --- a/backend/src/main/java/wooteco/prolog/article/domain/Url.java +++ b/backend/src/main/java/wooteco/prolog/article/domain/Url.java @@ -1,10 +1,7 @@ package wooteco.prolog.article.domain; -import static wooteco.prolog.common.exception.BadRequestCode.ARTICLE_URL_OVER_LENGTH_EXCEPTION; - -import java.util.Objects; -import javax.persistence.Column; -import javax.persistence.Embeddable; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; import lombok.AccessLevel; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -13,6 +10,10 @@ import wooteco.prolog.common.exception.BadRequestCode; import wooteco.prolog.common.exception.BadRequestException; +import java.util.Objects; + +import static wooteco.prolog.common.exception.BadRequestCode.ARTICLE_URL_OVER_LENGTH_EXCEPTION; + @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @EqualsAndHashCode diff --git a/backend/src/main/java/wooteco/prolog/article/domain/ViewCount.java b/backend/src/main/java/wooteco/prolog/article/domain/ViewCount.java index f452d117e..41b217f4f 100644 --- a/backend/src/main/java/wooteco/prolog/article/domain/ViewCount.java +++ b/backend/src/main/java/wooteco/prolog/article/domain/ViewCount.java @@ -1,6 +1,6 @@ package wooteco.prolog.article.domain; -import javax.persistence.Embeddable; +import jakarta.persistence.Embeddable; import lombok.AccessLevel; import lombok.EqualsAndHashCode; import lombok.Getter; diff --git a/backend/src/main/java/wooteco/prolog/article/domain/repository/ArticleRepository.java b/backend/src/main/java/wooteco/prolog/article/domain/repository/ArticleRepository.java index 71fe45daa..cf858bb11 100644 --- a/backend/src/main/java/wooteco/prolog/article/domain/repository/ArticleRepository.java +++ b/backend/src/main/java/wooteco/prolog/article/domain/repository/ArticleRepository.java @@ -1,12 +1,13 @@ package wooteco.prolog.article.domain.repository; -import java.util.List; -import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import wooteco.prolog.article.domain.Article; +import java.util.List; +import java.util.Optional; + public interface ArticleRepository extends JpaRepository { List
findAllByOrderByCreatedAtDesc(); diff --git a/backend/src/main/java/wooteco/prolog/article/ui/ArticleController.java b/backend/src/main/java/wooteco/prolog/article/ui/ArticleController.java index 992071ad5..dc526942d 100644 --- a/backend/src/main/java/wooteco/prolog/article/ui/ArticleController.java +++ b/backend/src/main/java/wooteco/prolog/article/ui/ArticleController.java @@ -1,7 +1,5 @@ package wooteco.prolog.article.ui; -import java.net.URI; -import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; @@ -22,6 +20,9 @@ import wooteco.prolog.login.domain.AuthMemberPrincipal; import wooteco.prolog.login.ui.LoginMember; +import java.net.URI; +import java.util.List; + @RequiredArgsConstructor @RestController @RequestMapping("/articles") @@ -69,8 +70,8 @@ public ResponseEntity likeArticle(@PathVariable final Long id, @GetMapping public ResponseEntity> getArticlesByPublishedAt(@AuthMemberPrincipal final LoginMember member, - @RequestParam("course") final ArticleFilterType course, - @RequestParam("onlyBookmarked") boolean onlyBookmarked) { + @RequestParam("course") final ArticleFilterType course, + @RequestParam("onlyBookmarked") boolean onlyBookmarked) { final List articleResponses = articleService.getArticlesByPublishedAt(member); return ResponseEntity.ok(articleResponses); diff --git a/backend/src/main/java/wooteco/prolog/badge/application/BadgeCreator.java b/backend/src/main/java/wooteco/prolog/badge/application/BadgeCreator.java index 23f30967e..839d918fa 100644 --- a/backend/src/main/java/wooteco/prolog/badge/application/BadgeCreator.java +++ b/backend/src/main/java/wooteco/prolog/badge/application/BadgeCreator.java @@ -1,8 +1,9 @@ package wooteco.prolog.badge.application; -import java.util.Optional; import wooteco.prolog.badge.domain.BadgeType; +import java.util.Optional; + public interface BadgeCreator { Optional create(String username); diff --git a/backend/src/main/java/wooteco/prolog/badge/application/BadgeService.java b/backend/src/main/java/wooteco/prolog/badge/application/BadgeService.java index 94c00b2b4..cd16ef53d 100644 --- a/backend/src/main/java/wooteco/prolog/badge/application/BadgeService.java +++ b/backend/src/main/java/wooteco/prolog/badge/application/BadgeService.java @@ -1,13 +1,14 @@ package wooteco.prolog.badge.application; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; import org.springframework.stereotype.Service; import wooteco.prolog.badge.domain.BadgeType; import wooteco.prolog.member.application.MemberService; import wooteco.prolog.member.domain.Member; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + @Service public class BadgeService { diff --git a/backend/src/main/java/wooteco/prolog/badge/application/ComplimentKingBadgeCreator.java b/backend/src/main/java/wooteco/prolog/badge/application/ComplimentKingBadgeCreator.java index fa5f06d5e..99507ad03 100644 --- a/backend/src/main/java/wooteco/prolog/badge/application/ComplimentKingBadgeCreator.java +++ b/backend/src/main/java/wooteco/prolog/badge/application/ComplimentKingBadgeCreator.java @@ -1,10 +1,11 @@ package wooteco.prolog.badge.application; -import java.util.List; -import java.util.Optional; import wooteco.prolog.badge.domain.BadgeType; import wooteco.prolog.studylog.domain.repository.BadgeRepository; +import java.util.List; +import java.util.Optional; + public class ComplimentKingBadgeCreator implements BadgeCreator { private static final int COMPLIMENT_KING_CRITERIA = 15; diff --git a/backend/src/main/java/wooteco/prolog/badge/application/PassionKingBadgeCreator.java b/backend/src/main/java/wooteco/prolog/badge/application/PassionKingBadgeCreator.java index 0787d3c71..290744ef9 100644 --- a/backend/src/main/java/wooteco/prolog/badge/application/PassionKingBadgeCreator.java +++ b/backend/src/main/java/wooteco/prolog/badge/application/PassionKingBadgeCreator.java @@ -1,10 +1,11 @@ package wooteco.prolog.badge.application; -import java.util.List; -import java.util.Optional; import wooteco.prolog.badge.domain.BadgeType; import wooteco.prolog.studylog.domain.repository.BadgeRepository; +import java.util.List; +import java.util.Optional; + public class PassionKingBadgeCreator implements BadgeCreator { private static final int PASSION_KING_CRITERIA = 7; diff --git a/backend/src/main/java/wooteco/prolog/badge/application/dto/BadgesResponse.java b/backend/src/main/java/wooteco/prolog/badge/application/dto/BadgesResponse.java index e9cf7658b..526488f1c 100644 --- a/backend/src/main/java/wooteco/prolog/badge/application/dto/BadgesResponse.java +++ b/backend/src/main/java/wooteco/prolog/badge/application/dto/BadgesResponse.java @@ -1,10 +1,11 @@ package wooteco.prolog.badge.application.dto; -import java.util.List; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; +import java.util.List; + @NoArgsConstructor @AllArgsConstructor diff --git a/backend/src/main/java/wooteco/prolog/badge/ui/BadgeController.java b/backend/src/main/java/wooteco/prolog/badge/ui/BadgeController.java index 351868760..7d14ea81c 100644 --- a/backend/src/main/java/wooteco/prolog/badge/ui/BadgeController.java +++ b/backend/src/main/java/wooteco/prolog/badge/ui/BadgeController.java @@ -1,7 +1,5 @@ package wooteco.prolog.badge.ui; -import java.util.List; -import java.util.stream.Collectors; import lombok.AllArgsConstructor; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; @@ -14,6 +12,9 @@ import wooteco.prolog.badge.application.dto.BadgesResponse; import wooteco.prolog.badge.domain.BadgeType; +import java.util.List; +import java.util.stream.Collectors; + @RestController @AllArgsConstructor @RequestMapping("/members") diff --git a/backend/src/main/java/wooteco/prolog/common/AuditingEntity.java b/backend/src/main/java/wooteco/prolog/common/AuditingEntity.java index aba2022f6..4721d330d 100644 --- a/backend/src/main/java/wooteco/prolog/common/AuditingEntity.java +++ b/backend/src/main/java/wooteco/prolog/common/AuditingEntity.java @@ -1,14 +1,15 @@ package wooteco.prolog.common; -import java.time.LocalDateTime; -import javax.persistence.Column; -import javax.persistence.EntityListeners; -import javax.persistence.MappedSuperclass; +import jakarta.persistence.Column; +import jakarta.persistence.EntityListeners; +import jakarta.persistence.MappedSuperclass; import lombok.Getter; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.LastModifiedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; +import java.time.LocalDateTime; + @Getter @MappedSuperclass @EntityListeners(AuditingEntityListener.class) diff --git a/backend/src/main/java/wooteco/prolog/common/ElasticSearchConfig.java b/backend/src/main/java/wooteco/prolog/common/ElasticSearchConfig.java deleted file mode 100644 index 4449e0a2d..000000000 --- a/backend/src/main/java/wooteco/prolog/common/ElasticSearchConfig.java +++ /dev/null @@ -1,49 +0,0 @@ -package wooteco.prolog.common; - -import org.apache.http.HttpHost; -import org.apache.http.auth.AuthScope; -import org.apache.http.auth.UsernamePasswordCredentials; -import org.apache.http.impl.client.BasicCredentialsProvider; -import org.elasticsearch.client.RestClient; -import org.elasticsearch.client.RestHighLevelClient; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.springframework.data.elasticsearch.config.AbstractElasticsearchConfiguration; -import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; - -@Profile({"dev", "prod"}) -@Configuration -@EnableElasticsearchRepositories -public class ElasticSearchConfig extends AbstractElasticsearchConfiguration { - - @Value("${elasticsearch.host}") - private String host; - @Value("${elasticsearch.port}") - private int port; - @Value("${elasticsearch.user}") - private String user; - @Value("${elasticsearch.password}") - private String password; - - - @Bean - @Override - public RestHighLevelClient elasticsearchClient() { - final BasicCredentialsProvider basicCredentialsProvider = new BasicCredentialsProvider(); - basicCredentialsProvider.setCredentials( - AuthScope.ANY, - new UsernamePasswordCredentials(user, password) - ); - - return new RestHighLevelClient( - RestClient.builder(new HttpHost(host, port, "http")) - .setHttpClientConfigCallback(httpClientBuilder -> { - httpClientBuilder.disableAuthCaching(); - return httpClientBuilder.setDefaultCredentialsProvider( - basicCredentialsProvider); - }) - ); - } -} diff --git a/backend/src/main/java/wooteco/prolog/common/PageableResponse.java b/backend/src/main/java/wooteco/prolog/common/PageableResponse.java index 2891bfd02..4ae5a2d45 100644 --- a/backend/src/main/java/wooteco/prolog/common/PageableResponse.java +++ b/backend/src/main/java/wooteco/prolog/common/PageableResponse.java @@ -1,10 +1,11 @@ package wooteco.prolog.common; -import java.util.List; import lombok.AllArgsConstructor; import lombok.Getter; import org.springframework.data.domain.Page; +import java.util.List; + @AllArgsConstructor @Getter public class PageableResponse { diff --git a/backend/src/main/java/wooteco/prolog/common/ResourceSizeAdvice.java b/backend/src/main/java/wooteco/prolog/common/ResourceSizeAdvice.java index f908cf119..b767329eb 100644 --- a/backend/src/main/java/wooteco/prolog/common/ResourceSizeAdvice.java +++ b/backend/src/main/java/wooteco/prolog/common/ResourceSizeAdvice.java @@ -1,6 +1,5 @@ package wooteco.prolog.common; -import java.util.Collection; import org.springframework.core.MethodParameter; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; @@ -10,6 +9,8 @@ import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice; +import java.util.Collection; + @ControllerAdvice public class ResourceSizeAdvice implements ResponseBodyAdvice { diff --git a/backend/src/main/java/wooteco/prolog/common/WebConfig.java b/backend/src/main/java/wooteco/prolog/common/WebConfig.java index d328ca871..e02a9203f 100644 --- a/backend/src/main/java/wooteco/prolog/common/WebConfig.java +++ b/backend/src/main/java/wooteco/prolog/common/WebConfig.java @@ -1,7 +1,6 @@ package wooteco.prolog.common; import com.fasterxml.jackson.databind.ObjectMapper; -import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -16,6 +15,8 @@ import wooteco.support.performance.PerformanceLogger; import wooteco.support.performance.RequestApiExtractor; +import java.util.List; + @Configuration public class WebConfig implements WebMvcConfigurer { diff --git a/backend/src/main/java/wooteco/prolog/common/WebConverterConfig.java b/backend/src/main/java/wooteco/prolog/common/WebConverterConfig.java index bbb3003ca..c0277be27 100644 --- a/backend/src/main/java/wooteco/prolog/common/WebConverterConfig.java +++ b/backend/src/main/java/wooteco/prolog/common/WebConverterConfig.java @@ -1,13 +1,14 @@ package wooteco.prolog.common; -import java.time.LocalDate; -import java.time.Month; -import java.time.format.DateTimeFormatter; import org.springframework.context.annotation.Configuration; import org.springframework.format.FormatterRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import wooteco.prolog.article.domain.ArticleFilterType; +import java.time.LocalDate; +import java.time.Month; +import java.time.format.DateTimeFormatter; + @Configuration public class WebConverterConfig implements WebMvcConfigurer { diff --git a/backend/src/main/java/wooteco/prolog/common/exception/ElasticsearchCustomException.java b/backend/src/main/java/wooteco/prolog/common/exception/ElasticsearchCustomException.java deleted file mode 100644 index 88c9b8a0b..000000000 --- a/backend/src/main/java/wooteco/prolog/common/exception/ElasticsearchCustomException.java +++ /dev/null @@ -1,8 +0,0 @@ -package wooteco.prolog.common.exception; - -public class ElasticsearchCustomException extends RuntimeException { - - public ElasticsearchCustomException(String message) { - super(message); - } -} diff --git a/backend/src/main/java/wooteco/prolog/common/exception/ExceptionController.java b/backend/src/main/java/wooteco/prolog/common/exception/ExceptionController.java index d6a53fcf8..0f81c9a1c 100644 --- a/backend/src/main/java/wooteco/prolog/common/exception/ExceptionController.java +++ b/backend/src/main/java/wooteco/prolog/common/exception/ExceptionController.java @@ -1,9 +1,5 @@ package wooteco.prolog.common.exception; -import static wooteco.prolog.common.slacklogger.SlackAlarmErrorLevel.ERROR; - -import java.util.Arrays; -import java.util.stream.Collectors; import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -11,6 +7,11 @@ import org.springframework.web.bind.annotation.RestControllerAdvice; import wooteco.prolog.common.slacklogger.SlackAlarm; +import java.util.Arrays; +import java.util.stream.Collectors; + +import static wooteco.prolog.common.slacklogger.SlackAlarmErrorLevel.ERROR; + @Slf4j @RestControllerAdvice public class ExceptionController { @@ -22,16 +23,6 @@ public ResponseEntity badRequestExceptionHandler(BadRequestExcepti .body(new ExceptionDto(e.getCode(), e.getMessage())); } - @SlackAlarm(level = ERROR) - @ExceptionHandler(ElasticsearchCustomException.class) - public ResponseEntity elasticsearchCustomExceptionHandler( - ElasticsearchCustomException e) { - log.error(e.getMessage()); - return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) - .body(new ExceptionDto(500, "알 수 없는 에러")); - } - - @SlackAlarm(level = ERROR) @ExceptionHandler(Exception.class) public ResponseEntity runtimeExceptionHandler(Exception e) { diff --git a/backend/src/main/java/wooteco/prolog/common/filter/ServletWrappingFilter.java b/backend/src/main/java/wooteco/prolog/common/filter/ServletWrappingFilter.java index d1dc32c95..7f8c9606c 100644 --- a/backend/src/main/java/wooteco/prolog/common/filter/ServletWrappingFilter.java +++ b/backend/src/main/java/wooteco/prolog/common/filter/ServletWrappingFilter.java @@ -1,15 +1,16 @@ package wooteco.prolog.common.filter; -import java.io.IOException; -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.FilterChain; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import org.springframework.stereotype.Component; import org.springframework.web.filter.OncePerRequestFilter; import org.springframework.web.util.ContentCachingRequestWrapper; import wooteco.prolog.common.slacklogger.RequestStorage; +import java.io.IOException; + @Component public class ServletWrappingFilter extends OncePerRequestFilter { diff --git a/backend/src/main/java/wooteco/prolog/common/slacklogger/PrologSlack.java b/backend/src/main/java/wooteco/prolog/common/slacklogger/PrologSlack.java index c9dcc2a65..22b08b0b8 100644 --- a/backend/src/main/java/wooteco/prolog/common/slacklogger/PrologSlack.java +++ b/backend/src/main/java/wooteco/prolog/common/slacklogger/PrologSlack.java @@ -2,26 +2,29 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import java.util.HashMap; -import java.util.Map; +import org.springframework.beans.factory.annotation.Value; import org.springframework.http.MediaType; import org.springframework.stereotype.Component; import org.springframework.web.reactive.function.client.WebClient; +import java.util.HashMap; +import java.util.Map; + @Component public class PrologSlack { - private static final String SLACK_LOGGER_WEBHOOK_URI = - System.getenv("SLACK_LOGGER_WEBHOOK_URI"); + private final String slackLoggerWebhookUri; public final ObjectMapper objectMapper; - public PrologSlack(ObjectMapper objectMapper) { + public PrologSlack(@Value("${slack.logger-webhook-uri}") String slackLoggerWebhookUri, + ObjectMapper objectMapper) { + this.slackLoggerWebhookUri = slackLoggerWebhookUri; this.objectMapper = objectMapper; } public void send(String message) { - WebClient.create(SLACK_LOGGER_WEBHOOK_URI) + WebClient.create(slackLoggerWebhookUri) .post() .contentType(MediaType.APPLICATION_JSON) .bodyValue(toJson(message)) diff --git a/backend/src/main/java/wooteco/prolog/common/slacklogger/SlackMessageGenerator.java b/backend/src/main/java/wooteco/prolog/common/slacklogger/SlackMessageGenerator.java index d8e204032..1deb2b30e 100644 --- a/backend/src/main/java/wooteco/prolog/common/slacklogger/SlackMessageGenerator.java +++ b/backend/src/main/java/wooteco/prolog/common/slacklogger/SlackMessageGenerator.java @@ -1,6 +1,11 @@ package wooteco.prolog.common.slacklogger; -import static java.util.stream.Collectors.joining; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; +import org.springframework.web.util.ContentCachingRequestWrapper; +import wooteco.prolog.common.exception.BadRequestException; +import wooteco.prolog.login.application.AuthorizationExtractor; +import wooteco.prolog.login.application.JwtTokenProvider; import java.time.LocalDateTime; import java.util.Arrays; @@ -8,12 +13,8 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Component; -import org.springframework.web.util.ContentCachingRequestWrapper; -import wooteco.prolog.common.exception.BadRequestException; -import wooteco.prolog.login.application.AuthorizationExtractor; -import wooteco.prolog.login.application.JwtTokenProvider; + +import static java.util.stream.Collectors.joining; @Component public class SlackMessageGenerator { diff --git a/backend/src/main/java/wooteco/prolog/common/ui/HealthCheckController.java b/backend/src/main/java/wooteco/prolog/common/ui/HealthCheckController.java index eff5d05e3..4ae7c4b8f 100644 --- a/backend/src/main/java/wooteco/prolog/common/ui/HealthCheckController.java +++ b/backend/src/main/java/wooteco/prolog/common/ui/HealthCheckController.java @@ -1,12 +1,13 @@ package wooteco.prolog.common.ui; -import static com.google.common.collect.ImmutableMap.of; - import com.google.common.collect.ImmutableMap; -import java.util.Map; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.Map; + +import static com.google.common.collect.ImmutableMap.of; + @RestController public class HealthCheckController { diff --git a/backend/src/main/java/wooteco/prolog/image/application/ImageService.java b/backend/src/main/java/wooteco/prolog/image/application/ImageService.java index 2c6c9cfd5..d957d4459 100644 --- a/backend/src/main/java/wooteco/prolog/image/application/ImageService.java +++ b/backend/src/main/java/wooteco/prolog/image/application/ImageService.java @@ -1,8 +1,5 @@ package wooteco.prolog.image.application; -import static wooteco.prolog.common.exception.BadRequestCode.FILE_NAME_EMPTY_EXCEPTION; - -import java.util.Objects; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; @@ -11,6 +8,10 @@ import wooteco.prolog.image.infrastructure.FileNameGenerator; import wooteco.prolog.image.infrastructure.S3Uploader; +import java.util.Objects; + +import static wooteco.prolog.common.exception.BadRequestCode.FILE_NAME_EMPTY_EXCEPTION; + @RequiredArgsConstructor @Service public class ImageService { diff --git a/backend/src/main/java/wooteco/prolog/image/infrastructure/FileNameGenerator.java b/backend/src/main/java/wooteco/prolog/image/infrastructure/FileNameGenerator.java index ddacb7243..12eeb03d7 100644 --- a/backend/src/main/java/wooteco/prolog/image/infrastructure/FileNameGenerator.java +++ b/backend/src/main/java/wooteco/prolog/image/infrastructure/FileNameGenerator.java @@ -1,13 +1,14 @@ package wooteco.prolog.image.infrastructure; -import static wooteco.prolog.common.exception.BadRequestCode.UNSUPPORTED_FILE_EXTENSION_EXCEPTION; - -import java.util.UUID; -import org.apache.commons.compress.utils.FileNameUtils; +import org.apache.commons.io.FilenameUtils; import org.springframework.stereotype.Component; import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.image.domain.FileExtension; +import java.util.UUID; + +import static wooteco.prolog.common.exception.BadRequestCode.UNSUPPORTED_FILE_EXTENSION_EXCEPTION; + @Component public class FileNameGenerator { @@ -18,7 +19,7 @@ public String generate(final String originalFilename) { } private static String getExtension(final String originalFilename) { - final String extension = FileNameUtils.getExtension(originalFilename); + final String extension = FilenameUtils.getExtension(originalFilename); if (FileExtension.isSupport(extension)) { return extension; } diff --git a/backend/src/main/java/wooteco/prolog/image/infrastructure/S3Uploader.java b/backend/src/main/java/wooteco/prolog/image/infrastructure/S3Uploader.java index b7143dcd0..5edf46afd 100644 --- a/backend/src/main/java/wooteco/prolog/image/infrastructure/S3Uploader.java +++ b/backend/src/main/java/wooteco/prolog/image/infrastructure/S3Uploader.java @@ -1,17 +1,18 @@ package wooteco.prolog.image.infrastructure; -import static wooteco.prolog.common.exception.BadRequestCode.FILE_UPLOAD_FAIL_EXCEPTION; - import com.amazonaws.services.s3.AmazonS3; import com.amazonaws.services.s3.model.ObjectMetadata; import com.amazonaws.services.s3.model.PutObjectRequest; -import java.io.IOException; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import org.springframework.web.multipart.MultipartFile; import wooteco.prolog.common.exception.BadRequestException; +import java.io.IOException; + +import static wooteco.prolog.common.exception.BadRequestCode.FILE_UPLOAD_FAIL_EXCEPTION; + @RequiredArgsConstructor @Component public class S3Uploader { diff --git a/backend/src/main/java/wooteco/prolog/levellogs/application/LevelLogService.java b/backend/src/main/java/wooteco/prolog/levellogs/application/LevelLogService.java index 06ba5cdcf..2c194b04e 100644 --- a/backend/src/main/java/wooteco/prolog/levellogs/application/LevelLogService.java +++ b/backend/src/main/java/wooteco/prolog/levellogs/application/LevelLogService.java @@ -1,12 +1,5 @@ package wooteco.prolog.levellogs.application; -import static wooteco.prolog.common.exception.BadRequestCode.INVALID_LEVEL_LOG_AUTHOR_EXCEPTION; -import static wooteco.prolog.common.exception.BadRequestCode.LEVEL_LOG_NOT_FOUND_EXCEPTION; -import static wooteco.prolog.common.exception.BadRequestCode.MEMBER_NOT_FOUND; -import static wooteco.prolog.common.exception.BadRequestCode.SELF_DISCUSSION_NOT_FOUND_EXCEPTION; - -import java.util.List; -import java.util.stream.Collectors; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; @@ -24,6 +17,14 @@ import wooteco.prolog.member.domain.Member; import wooteco.prolog.member.domain.repository.MemberRepository; +import java.util.List; +import java.util.stream.Collectors; + +import static wooteco.prolog.common.exception.BadRequestCode.INVALID_LEVEL_LOG_AUTHOR_EXCEPTION; +import static wooteco.prolog.common.exception.BadRequestCode.LEVEL_LOG_NOT_FOUND_EXCEPTION; +import static wooteco.prolog.common.exception.BadRequestCode.MEMBER_NOT_FOUND; +import static wooteco.prolog.common.exception.BadRequestCode.SELF_DISCUSSION_NOT_FOUND_EXCEPTION; + @Service @Transactional(readOnly = true) public class LevelLogService { diff --git a/backend/src/main/java/wooteco/prolog/levellogs/application/dto/LevelLogRequest.java b/backend/src/main/java/wooteco/prolog/levellogs/application/dto/LevelLogRequest.java index a5572195f..eee03e1aa 100644 --- a/backend/src/main/java/wooteco/prolog/levellogs/application/dto/LevelLogRequest.java +++ b/backend/src/main/java/wooteco/prolog/levellogs/application/dto/LevelLogRequest.java @@ -1,11 +1,12 @@ package wooteco.prolog.levellogs.application.dto; -import com.sun.istack.NotNull; -import java.util.List; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.ToString; +import org.jetbrains.annotations.NotNull; + +import java.util.List; @NoArgsConstructor(access = AccessLevel.PROTECTED) @Getter diff --git a/backend/src/main/java/wooteco/prolog/levellogs/application/dto/LevelLogResponse.java b/backend/src/main/java/wooteco/prolog/levellogs/application/dto/LevelLogResponse.java index 7febce2a7..8f9ed9ab9 100644 --- a/backend/src/main/java/wooteco/prolog/levellogs/application/dto/LevelLogResponse.java +++ b/backend/src/main/java/wooteco/prolog/levellogs/application/dto/LevelLogResponse.java @@ -1,8 +1,5 @@ package wooteco.prolog.levellogs.application.dto; -import java.time.LocalDateTime; -import java.util.List; -import java.util.stream.Collectors; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; @@ -12,6 +9,10 @@ import wooteco.prolog.levellogs.domain.SelfDiscussion; import wooteco.prolog.member.application.dto.MemberResponse; +import java.time.LocalDateTime; +import java.util.List; +import java.util.stream.Collectors; + @AllArgsConstructor @NoArgsConstructor(access = AccessLevel.PROTECTED) @Getter diff --git a/backend/src/main/java/wooteco/prolog/levellogs/application/dto/LevelLogSummariesResponse.java b/backend/src/main/java/wooteco/prolog/levellogs/application/dto/LevelLogSummariesResponse.java index 946fbad43..21ed20f1d 100644 --- a/backend/src/main/java/wooteco/prolog/levellogs/application/dto/LevelLogSummariesResponse.java +++ b/backend/src/main/java/wooteco/prolog/levellogs/application/dto/LevelLogSummariesResponse.java @@ -1,12 +1,13 @@ package wooteco.prolog.levellogs.application.dto; -import java.util.List; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.ToString; +import java.util.List; + @AllArgsConstructor @NoArgsConstructor(access = AccessLevel.PROTECTED) @Getter diff --git a/backend/src/main/java/wooteco/prolog/levellogs/application/dto/LevelLogSummaryResponse.java b/backend/src/main/java/wooteco/prolog/levellogs/application/dto/LevelLogSummaryResponse.java index 174a7575a..dbecac0ca 100644 --- a/backend/src/main/java/wooteco/prolog/levellogs/application/dto/LevelLogSummaryResponse.java +++ b/backend/src/main/java/wooteco/prolog/levellogs/application/dto/LevelLogSummaryResponse.java @@ -1,6 +1,5 @@ package wooteco.prolog.levellogs.application.dto; -import java.time.LocalDateTime; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; @@ -9,6 +8,8 @@ import wooteco.prolog.levellogs.domain.LevelLog; import wooteco.prolog.member.application.dto.MemberResponse; +import java.time.LocalDateTime; + @AllArgsConstructor @NoArgsConstructor(access = AccessLevel.PROTECTED) @Getter diff --git a/backend/src/main/java/wooteco/prolog/levellogs/application/dto/SelfDiscussionRequest.java b/backend/src/main/java/wooteco/prolog/levellogs/application/dto/SelfDiscussionRequest.java index 2ca76bbe6..6bb418be7 100644 --- a/backend/src/main/java/wooteco/prolog/levellogs/application/dto/SelfDiscussionRequest.java +++ b/backend/src/main/java/wooteco/prolog/levellogs/application/dto/SelfDiscussionRequest.java @@ -1,11 +1,11 @@ package wooteco.prolog.levellogs.application.dto; -import com.sun.istack.NotNull; import lombok.AccessLevel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.ToString; +import org.jetbrains.annotations.NotNull; @Getter @EqualsAndHashCode diff --git a/backend/src/main/java/wooteco/prolog/levellogs/domain/Content.java b/backend/src/main/java/wooteco/prolog/levellogs/domain/Content.java index 3511c2e69..9a169bbd4 100644 --- a/backend/src/main/java/wooteco/prolog/levellogs/domain/Content.java +++ b/backend/src/main/java/wooteco/prolog/levellogs/domain/Content.java @@ -1,15 +1,15 @@ package wooteco.prolog.levellogs.domain; -import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_CONTENT_NULL_OR_EMPTY; - -import javax.persistence.Column; -import javax.persistence.Embeddable; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.ToString; import wooteco.prolog.common.exception.BadRequestException; +import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_CONTENT_NULL_OR_EMPTY; + @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @ToString diff --git a/backend/src/main/java/wooteco/prolog/levellogs/domain/LevelLog.java b/backend/src/main/java/wooteco/prolog/levellogs/domain/LevelLog.java index de70092db..205c65a31 100644 --- a/backend/src/main/java/wooteco/prolog/levellogs/domain/LevelLog.java +++ b/backend/src/main/java/wooteco/prolog/levellogs/domain/LevelLog.java @@ -1,21 +1,21 @@ package wooteco.prolog.levellogs.domain; -import static wooteco.prolog.common.exception.BadRequestCode.INVALID_LEVEL_LOG_AUTHOR_EXCEPTION; - -import javax.persistence.Embedded; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; import lombok.AccessLevel; import lombok.NoArgsConstructor; import wooteco.prolog.common.AuditingEntity; import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.member.domain.Member; +import static wooteco.prolog.common.exception.BadRequestCode.INVALID_LEVEL_LOG_AUTHOR_EXCEPTION; + @Entity @NoArgsConstructor(access = AccessLevel.PROTECTED) public class LevelLog extends AuditingEntity { diff --git a/backend/src/main/java/wooteco/prolog/levellogs/domain/SelfDiscussion.java b/backend/src/main/java/wooteco/prolog/levellogs/domain/SelfDiscussion.java index ce451de15..4ae8369c5 100644 --- a/backend/src/main/java/wooteco/prolog/levellogs/domain/SelfDiscussion.java +++ b/backend/src/main/java/wooteco/prolog/levellogs/domain/SelfDiscussion.java @@ -1,12 +1,12 @@ package wooteco.prolog.levellogs.domain; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; import lombok.AccessLevel; import lombok.NoArgsConstructor; diff --git a/backend/src/main/java/wooteco/prolog/levellogs/domain/Title.java b/backend/src/main/java/wooteco/prolog/levellogs/domain/Title.java index 8bb6c3081..e671be7a1 100644 --- a/backend/src/main/java/wooteco/prolog/levellogs/domain/Title.java +++ b/backend/src/main/java/wooteco/prolog/levellogs/domain/Title.java @@ -1,11 +1,7 @@ package wooteco.prolog.levellogs.domain; -import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_TITLE_NULL_OR_EMPTY; -import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_TITLE_TOO_LONG; - -import java.util.Objects; -import javax.persistence.Column; -import javax.persistence.Embeddable; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; import lombok.AccessLevel; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -13,6 +9,11 @@ import lombok.ToString; import wooteco.prolog.common.exception.BadRequestException; +import java.util.Objects; + +import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_TITLE_NULL_OR_EMPTY; +import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_TITLE_TOO_LONG; + @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @EqualsAndHashCode diff --git a/backend/src/main/java/wooteco/prolog/levellogs/domain/repository/SelfDiscussionRepository.java b/backend/src/main/java/wooteco/prolog/levellogs/domain/repository/SelfDiscussionRepository.java index ffedb8ddc..fd0c1eb7b 100644 --- a/backend/src/main/java/wooteco/prolog/levellogs/domain/repository/SelfDiscussionRepository.java +++ b/backend/src/main/java/wooteco/prolog/levellogs/domain/repository/SelfDiscussionRepository.java @@ -1,10 +1,11 @@ package wooteco.prolog.levellogs.domain.repository; -import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import wooteco.prolog.levellogs.domain.LevelLog; import wooteco.prolog.levellogs.domain.SelfDiscussion; +import java.util.List; + public interface SelfDiscussionRepository extends JpaRepository { List findByLevelLog(LevelLog levelLog); diff --git a/backend/src/main/java/wooteco/prolog/levellogs/ui/LevelLogsController.java b/backend/src/main/java/wooteco/prolog/levellogs/ui/LevelLogsController.java index 5750db131..856fff25d 100644 --- a/backend/src/main/java/wooteco/prolog/levellogs/ui/LevelLogsController.java +++ b/backend/src/main/java/wooteco/prolog/levellogs/ui/LevelLogsController.java @@ -1,6 +1,5 @@ package wooteco.prolog.levellogs.ui; -import java.net.URI; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort.Direction; import org.springframework.data.web.PageableDefault; @@ -21,6 +20,8 @@ import wooteco.prolog.login.domain.AuthMemberPrincipal; import wooteco.prolog.login.ui.LoginMember; +import java.net.URI; + @RestController @RequestMapping("/levellogs") public class LevelLogsController { diff --git a/backend/src/main/java/wooteco/prolog/login/aop/LoginMemberVerifier.java b/backend/src/main/java/wooteco/prolog/login/aop/LoginMemberVerifier.java index 905f50e1a..a352479f1 100644 --- a/backend/src/main/java/wooteco/prolog/login/aop/LoginMemberVerifier.java +++ b/backend/src/main/java/wooteco/prolog/login/aop/LoginMemberVerifier.java @@ -1,7 +1,5 @@ package wooteco.prolog.login.aop; -import static wooteco.prolog.common.exception.BadRequestCode.MEMBER_NOT_ALLOWED; - import lombok.RequiredArgsConstructor; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; @@ -9,6 +7,8 @@ import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.login.ui.LoginMember.Authority; +import static wooteco.prolog.common.exception.BadRequestCode.MEMBER_NOT_ALLOWED; + @Aspect @Component @RequiredArgsConstructor diff --git a/backend/src/main/java/wooteco/prolog/login/application/AuthorizationExtractor.java b/backend/src/main/java/wooteco/prolog/login/application/AuthorizationExtractor.java index 59f21b948..37dfe1c38 100644 --- a/backend/src/main/java/wooteco/prolog/login/application/AuthorizationExtractor.java +++ b/backend/src/main/java/wooteco/prolog/login/application/AuthorizationExtractor.java @@ -1,7 +1,8 @@ package wooteco.prolog.login.application; +import jakarta.servlet.http.HttpServletRequest; + import java.util.Enumeration; -import javax.servlet.http.HttpServletRequest; public class AuthorizationExtractor { diff --git a/backend/src/main/java/wooteco/prolog/login/application/GithubClient.java b/backend/src/main/java/wooteco/prolog/login/application/GithubClient.java index e0af3b50d..a702eaa91 100644 --- a/backend/src/main/java/wooteco/prolog/login/application/GithubClient.java +++ b/backend/src/main/java/wooteco/prolog/login/application/GithubClient.java @@ -1,8 +1,5 @@ package wooteco.prolog.login.application; -import static wooteco.prolog.common.exception.BadRequestCode.GITHUB_API_FAIL; -import static wooteco.prolog.common.exception.BadRequestCode.GITHUB_CONNECTION_FAIL; - import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; @@ -17,6 +14,9 @@ import wooteco.prolog.login.application.dto.GithubAccessTokenResponse; import wooteco.prolog.login.application.dto.GithubProfileResponse; +import static wooteco.prolog.common.exception.BadRequestCode.GITHUB_API_FAIL; +import static wooteco.prolog.common.exception.BadRequestCode.GITHUB_CONNECTION_FAIL; + @Component public class GithubClient { diff --git a/backend/src/main/java/wooteco/prolog/login/application/GithubLoginService.java b/backend/src/main/java/wooteco/prolog/login/application/GithubLoginService.java index b8635723a..3ede1f067 100644 --- a/backend/src/main/java/wooteco/prolog/login/application/GithubLoginService.java +++ b/backend/src/main/java/wooteco/prolog/login/application/GithubLoginService.java @@ -1,7 +1,5 @@ package wooteco.prolog.login.application; -import static wooteco.prolog.common.exception.BadRequestCode.TOKEN_NOT_VALID; - import org.springframework.stereotype.Service; import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.login.application.dto.GithubProfileResponse; @@ -10,6 +8,8 @@ import wooteco.prolog.member.application.MemberService; import wooteco.prolog.member.domain.Member; +import static wooteco.prolog.common.exception.BadRequestCode.TOKEN_NOT_VALID; + @Service public class GithubLoginService { diff --git a/backend/src/main/java/wooteco/prolog/login/application/JwtTokenProvider.java b/backend/src/main/java/wooteco/prolog/login/application/JwtTokenProvider.java index 6e941422a..df883e397 100644 --- a/backend/src/main/java/wooteco/prolog/login/application/JwtTokenProvider.java +++ b/backend/src/main/java/wooteco/prolog/login/application/JwtTokenProvider.java @@ -1,19 +1,20 @@ package wooteco.prolog.login.application; -import static wooteco.prolog.common.exception.BadRequestCode.TOKEN_NOT_VALID; - import io.jsonwebtoken.Claims; import io.jsonwebtoken.Jws; import io.jsonwebtoken.JwtException; import io.jsonwebtoken.Jwts; import io.jsonwebtoken.SignatureAlgorithm; -import java.util.Date; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.member.domain.Member; +import java.util.Date; + +import static wooteco.prolog.common.exception.BadRequestCode.TOKEN_NOT_VALID; + @Component @Slf4j public class JwtTokenProvider { diff --git a/backend/src/main/java/wooteco/prolog/login/ui/AuthMemberPrincipalArgumentResolver.java b/backend/src/main/java/wooteco/prolog/login/ui/AuthMemberPrincipalArgumentResolver.java index c2e50a8b0..3cc0f8eeb 100644 --- a/backend/src/main/java/wooteco/prolog/login/ui/AuthMemberPrincipalArgumentResolver.java +++ b/backend/src/main/java/wooteco/prolog/login/ui/AuthMemberPrincipalArgumentResolver.java @@ -1,8 +1,6 @@ package wooteco.prolog.login.ui; -import static wooteco.prolog.common.exception.BadRequestCode.TOKEN_NOT_VALID; - -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import lombok.AllArgsConstructor; import org.springframework.core.MethodParameter; import org.springframework.web.bind.support.WebDataBinderFactory; @@ -16,6 +14,8 @@ import wooteco.prolog.login.domain.AuthMemberPrincipal; import wooteco.prolog.login.ui.LoginMember.Authority; +import static wooteco.prolog.common.exception.BadRequestCode.TOKEN_NOT_VALID; + @AllArgsConstructor public class AuthMemberPrincipalArgumentResolver implements HandlerMethodArgumentResolver { diff --git a/backend/src/main/java/wooteco/prolog/login/ui/LoginConfig.java b/backend/src/main/java/wooteco/prolog/login/ui/LoginConfig.java index ec12ee4a8..b0d031ed4 100644 --- a/backend/src/main/java/wooteco/prolog/login/ui/LoginConfig.java +++ b/backend/src/main/java/wooteco/prolog/login/ui/LoginConfig.java @@ -1,6 +1,5 @@ package wooteco.prolog.login.ui; -import java.util.List; import lombok.AllArgsConstructor; import org.springframework.context.annotation.Configuration; import org.springframework.web.method.support.HandlerMethodArgumentResolver; @@ -12,6 +11,8 @@ import wooteco.prolog.login.domain.AuthMemberPrincipal; import wooteco.support.autoceptor.AutoInterceptorPatternMaker; +import java.util.List; + @Configuration @AllArgsConstructor public class LoginConfig implements WebMvcConfigurer { diff --git a/backend/src/main/java/wooteco/prolog/login/ui/LoginInterceptor.java b/backend/src/main/java/wooteco/prolog/login/ui/LoginInterceptor.java index 150a8774a..8d3c99568 100644 --- a/backend/src/main/java/wooteco/prolog/login/ui/LoginInterceptor.java +++ b/backend/src/main/java/wooteco/prolog/login/ui/LoginInterceptor.java @@ -1,7 +1,7 @@ package wooteco.prolog.login.ui; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import lombok.AllArgsConstructor; import org.springframework.web.servlet.HandlerInterceptor; import wooteco.prolog.login.application.AuthorizationExtractor; diff --git a/backend/src/main/java/wooteco/prolog/login/ui/LoginMember.java b/backend/src/main/java/wooteco/prolog/login/ui/LoginMember.java index 802c675de..15af6c956 100644 --- a/backend/src/main/java/wooteco/prolog/login/ui/LoginMember.java +++ b/backend/src/main/java/wooteco/prolog/login/ui/LoginMember.java @@ -1,8 +1,9 @@ package wooteco.prolog.login.ui; +import lombok.NoArgsConstructor; + import java.util.function.Function; import java.util.function.Supplier; -import lombok.NoArgsConstructor; @NoArgsConstructor public class LoginMember { diff --git a/backend/src/main/java/wooteco/prolog/member/application/DepartmentMemberService.java b/backend/src/main/java/wooteco/prolog/member/application/DepartmentMemberService.java index 80fd7d323..d33c21890 100644 --- a/backend/src/main/java/wooteco/prolog/member/application/DepartmentMemberService.java +++ b/backend/src/main/java/wooteco/prolog/member/application/DepartmentMemberService.java @@ -1,12 +1,13 @@ package wooteco.prolog.member.application; -import java.util.List; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import wooteco.prolog.member.domain.DepartmentMember; import wooteco.prolog.member.domain.repository.DepartmentMemberRepository; +import java.util.List; + @Service @AllArgsConstructor @Transactional(readOnly = true) diff --git a/backend/src/main/java/wooteco/prolog/member/application/MemberService.java b/backend/src/main/java/wooteco/prolog/member/application/MemberService.java index 0360065fa..5ab869340 100644 --- a/backend/src/main/java/wooteco/prolog/member/application/MemberService.java +++ b/backend/src/main/java/wooteco/prolog/member/application/MemberService.java @@ -1,12 +1,5 @@ package wooteco.prolog.member.application; -import static wooteco.prolog.common.exception.BadRequestCode.MEMBER_NOT_ALLOWED; -import static wooteco.prolog.common.exception.BadRequestCode.MEMBER_NOT_FOUND; - -import java.util.Comparator; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.ApplicationEventPublisher; import org.springframework.data.domain.Page; @@ -30,7 +23,14 @@ import wooteco.prolog.member.domain.repository.MemberRepository; import wooteco.prolog.organization.application.OrganizationService; import wooteco.prolog.organization.domain.OrganizationGroup; -import wooteco.prolog.organization.domain.OrganizationGroupMember; + +import java.util.Comparator; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +import static wooteco.prolog.common.exception.BadRequestCode.MEMBER_NOT_ALLOWED; +import static wooteco.prolog.common.exception.BadRequestCode.MEMBER_NOT_FOUND; @Service @Transactional(readOnly = true) diff --git a/backend/src/main/java/wooteco/prolog/member/application/MemberTagService.java b/backend/src/main/java/wooteco/prolog/member/application/MemberTagService.java index e39ecef2a..2732879fe 100644 --- a/backend/src/main/java/wooteco/prolog/member/application/MemberTagService.java +++ b/backend/src/main/java/wooteco/prolog/member/application/MemberTagService.java @@ -1,6 +1,5 @@ package wooteco.prolog.member.application; -import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -12,6 +11,8 @@ import wooteco.prolog.studylog.domain.Tags; import wooteco.prolog.studylog.domain.repository.StudylogRepository; +import java.util.List; + @Service @RequiredArgsConstructor @Transactional(readOnly = true) diff --git a/backend/src/main/java/wooteco/prolog/member/application/dto/MembersResponse.java b/backend/src/main/java/wooteco/prolog/member/application/dto/MembersResponse.java index ba0a07c3f..ae095e1f8 100644 --- a/backend/src/main/java/wooteco/prolog/member/application/dto/MembersResponse.java +++ b/backend/src/main/java/wooteco/prolog/member/application/dto/MembersResponse.java @@ -1,13 +1,14 @@ package wooteco.prolog.member.application.dto; -import java.util.List; -import java.util.stream.Collectors; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import org.springframework.data.domain.Page; import wooteco.prolog.member.domain.Member; +import java.util.List; +import java.util.stream.Collectors; + @NoArgsConstructor @AllArgsConstructor @Getter diff --git a/backend/src/main/java/wooteco/prolog/member/application/dto/ProfileResponse.java b/backend/src/main/java/wooteco/prolog/member/application/dto/ProfileResponse.java index a5d66e207..f61de0406 100644 --- a/backend/src/main/java/wooteco/prolog/member/application/dto/ProfileResponse.java +++ b/backend/src/main/java/wooteco/prolog/member/application/dto/ProfileResponse.java @@ -1,13 +1,14 @@ package wooteco.prolog.member.application.dto; -import java.util.List; -import java.util.stream.Collectors; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import wooteco.prolog.member.domain.Member; import wooteco.prolog.organization.domain.OrganizationGroup; +import java.util.List; +import java.util.stream.Collectors; + @NoArgsConstructor @AllArgsConstructor @Getter diff --git a/backend/src/main/java/wooteco/prolog/member/domain/Department.java b/backend/src/main/java/wooteco/prolog/member/domain/Department.java index 39ec37766..c0c557807 100644 --- a/backend/src/main/java/wooteco/prolog/member/domain/Department.java +++ b/backend/src/main/java/wooteco/prolog/member/domain/Department.java @@ -1,11 +1,11 @@ package wooteco.prolog.member.domain; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/backend/src/main/java/wooteco/prolog/member/domain/DepartmentMember.java b/backend/src/main/java/wooteco/prolog/member/domain/DepartmentMember.java index 690ecad41..b6cdac2da 100644 --- a/backend/src/main/java/wooteco/prolog/member/domain/DepartmentMember.java +++ b/backend/src/main/java/wooteco/prolog/member/domain/DepartmentMember.java @@ -1,12 +1,12 @@ package wooteco.prolog.member.domain; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/backend/src/main/java/wooteco/prolog/member/domain/Departments.java b/backend/src/main/java/wooteco/prolog/member/domain/Departments.java index 04ab1103e..c6cbbe5e1 100644 --- a/backend/src/main/java/wooteco/prolog/member/domain/Departments.java +++ b/backend/src/main/java/wooteco/prolog/member/domain/Departments.java @@ -1,9 +1,10 @@ package wooteco.prolog.member.domain; -import java.util.List; import lombok.AllArgsConstructor; import lombok.Getter; +import java.util.List; + @AllArgsConstructor @Getter public class Departments { diff --git a/backend/src/main/java/wooteco/prolog/member/domain/Member.java b/backend/src/main/java/wooteco/prolog/member/domain/Member.java index 1f4829908..7594aed70 100644 --- a/backend/src/main/java/wooteco/prolog/member/domain/Member.java +++ b/backend/src/main/java/wooteco/prolog/member/domain/Member.java @@ -1,16 +1,13 @@ package wooteco.prolog.member.domain; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; -import javax.persistence.Column; -import javax.persistence.Embedded; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; +import jakarta.persistence.Column; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -18,6 +15,10 @@ import wooteco.prolog.studylog.domain.Tag; import wooteco.prolog.studylog.domain.Tags; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @Entity @@ -175,10 +176,9 @@ public boolean equals(Object o) { if (this == o) { return true; } - if (!(o instanceof Member)) { + if (!(o instanceof Member member)) { return false; } - Member member = (Member) o; return Objects.equals(id, member.getId()); } diff --git a/backend/src/main/java/wooteco/prolog/member/domain/MemberTag.java b/backend/src/main/java/wooteco/prolog/member/domain/MemberTag.java index 35b738e2f..8dadcbaf4 100644 --- a/backend/src/main/java/wooteco/prolog/member/domain/MemberTag.java +++ b/backend/src/main/java/wooteco/prolog/member/domain/MemberTag.java @@ -1,19 +1,20 @@ package wooteco.prolog.member.domain; -import java.util.Objects; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; import wooteco.prolog.studylog.domain.Tag; +import java.util.Objects; + @Entity @NoArgsConstructor(access = AccessLevel.PROTECTED) @Getter diff --git a/backend/src/main/java/wooteco/prolog/member/domain/MemberTags.java b/backend/src/main/java/wooteco/prolog/member/domain/MemberTags.java index 12c04f9c2..3412be4f9 100644 --- a/backend/src/main/java/wooteco/prolog/member/domain/MemberTags.java +++ b/backend/src/main/java/wooteco/prolog/member/domain/MemberTags.java @@ -1,19 +1,20 @@ package wooteco.prolog.member.domain; -import static wooteco.prolog.common.exception.BadRequestCode.DUPLICATE_MEMBER_TAG; -import static wooteco.prolog.common.exception.BadRequestCode.NOT_EXISTS_MEMBER_TAG; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import javax.persistence.Embeddable; -import javax.persistence.FetchType; -import javax.persistence.OneToMany; +import jakarta.persistence.Embeddable; +import jakarta.persistence.FetchType; +import jakarta.persistence.OneToMany; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; import wooteco.prolog.common.exception.BadRequestException; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import static wooteco.prolog.common.exception.BadRequestCode.DUPLICATE_MEMBER_TAG; +import static wooteco.prolog.common.exception.BadRequestCode.NOT_EXISTS_MEMBER_TAG; + @Getter @Embeddable @NoArgsConstructor(access = AccessLevel.PROTECTED) diff --git a/backend/src/main/java/wooteco/prolog/member/domain/Part.java b/backend/src/main/java/wooteco/prolog/member/domain/Part.java index 62ab9d2c4..7f6960af6 100644 --- a/backend/src/main/java/wooteco/prolog/member/domain/Part.java +++ b/backend/src/main/java/wooteco/prolog/member/domain/Part.java @@ -1,9 +1,10 @@ package wooteco.prolog.member.domain; -import java.util.Arrays; import lombok.AllArgsConstructor; import lombok.Getter; +import java.util.Arrays; + @Getter @AllArgsConstructor public enum Part { diff --git a/backend/src/main/java/wooteco/prolog/member/domain/Term.java b/backend/src/main/java/wooteco/prolog/member/domain/Term.java index 8109cf3e1..162b67402 100644 --- a/backend/src/main/java/wooteco/prolog/member/domain/Term.java +++ b/backend/src/main/java/wooteco/prolog/member/domain/Term.java @@ -1,9 +1,10 @@ package wooteco.prolog.member.domain; -import java.util.Arrays; import lombok.AllArgsConstructor; import lombok.Getter; +import java.util.Arrays; + @Getter @AllArgsConstructor public enum Term { diff --git a/backend/src/main/java/wooteco/prolog/member/domain/repository/DepartmentMemberRepository.java b/backend/src/main/java/wooteco/prolog/member/domain/repository/DepartmentMemberRepository.java index 2902f3dcf..2fd3aafd9 100644 --- a/backend/src/main/java/wooteco/prolog/member/domain/repository/DepartmentMemberRepository.java +++ b/backend/src/main/java/wooteco/prolog/member/domain/repository/DepartmentMemberRepository.java @@ -1,11 +1,12 @@ package wooteco.prolog.member.domain.repository; -import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import wooteco.prolog.member.domain.Department; import wooteco.prolog.member.domain.DepartmentMember; import wooteco.prolog.member.domain.Member; +import java.util.List; + public interface DepartmentMemberRepository extends JpaRepository { List findByDepartmentId(Long departmentId); diff --git a/backend/src/main/java/wooteco/prolog/member/domain/repository/JdbcMemberTagRepository.java b/backend/src/main/java/wooteco/prolog/member/domain/repository/JdbcMemberTagRepository.java index 1ca2ce90a..e831ea3e7 100644 --- a/backend/src/main/java/wooteco/prolog/member/domain/repository/JdbcMemberTagRepository.java +++ b/backend/src/main/java/wooteco/prolog/member/domain/repository/JdbcMemberTagRepository.java @@ -1,11 +1,5 @@ package wooteco.prolog.member.domain.repository; -import java.sql.PreparedStatement; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.springframework.jdbc.core.BatchPreparedStatementSetter; import org.springframework.jdbc.core.JdbcTemplate; @@ -13,6 +7,13 @@ import wooteco.prolog.member.domain.MemberTag; import wooteco.prolog.member.domain.MemberTags; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + @Component @RequiredArgsConstructor public class JdbcMemberTagRepository implements MemberTagRepository { diff --git a/backend/src/main/java/wooteco/prolog/member/domain/repository/MemberRepository.java b/backend/src/main/java/wooteco/prolog/member/domain/repository/MemberRepository.java index 012ebc48d..4d3e26735 100644 --- a/backend/src/main/java/wooteco/prolog/member/domain/repository/MemberRepository.java +++ b/backend/src/main/java/wooteco/prolog/member/domain/repository/MemberRepository.java @@ -1,10 +1,11 @@ package wooteco.prolog.member.domain.repository; -import java.util.List; -import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import wooteco.prolog.member.domain.Member; +import java.util.List; +import java.util.Optional; + public interface MemberRepository extends JpaRepository { Optional findByGithubId(Long githubId); diff --git a/backend/src/main/java/wooteco/prolog/member/ui/MemberController.java b/backend/src/main/java/wooteco/prolog/member/ui/MemberController.java index ea85d6e4d..8d87b878f 100644 --- a/backend/src/main/java/wooteco/prolog/member/ui/MemberController.java +++ b/backend/src/main/java/wooteco/prolog/member/ui/MemberController.java @@ -1,7 +1,5 @@ package wooteco.prolog.member.ui; -import static org.springframework.data.domain.Sort.Direction.DESC; - import lombok.AllArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.data.web.PageableDefault; @@ -23,6 +21,8 @@ import wooteco.prolog.member.application.dto.MembersResponse; import wooteco.prolog.member.application.dto.RoleUpdateRequest; +import static org.springframework.data.domain.Sort.Direction.DESC; + @RestController @AllArgsConstructor @RequestMapping("/members") diff --git a/backend/src/main/java/wooteco/prolog/member/ui/MemberReactionController.java b/backend/src/main/java/wooteco/prolog/member/ui/MemberReactionController.java index 00b50c086..b2977a2da 100644 --- a/backend/src/main/java/wooteco/prolog/member/ui/MemberReactionController.java +++ b/backend/src/main/java/wooteco/prolog/member/ui/MemberReactionController.java @@ -1,8 +1,5 @@ package wooteco.prolog.member.ui; -import static org.springframework.data.domain.Sort.Direction.DESC; - -import java.net.URI; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.data.web.PageableDefault; @@ -24,6 +21,10 @@ import wooteco.prolog.studylog.application.StudylogScrapService; import wooteco.prolog.studylog.application.dto.StudylogsResponse; +import java.net.URI; + +import static org.springframework.data.domain.Sort.Direction.DESC; + @RestController @RequiredArgsConstructor @RequestMapping("/members") diff --git a/backend/src/main/java/wooteco/prolog/organization/application/OrganizationService.java b/backend/src/main/java/wooteco/prolog/organization/application/OrganizationService.java index 427382760..2a95ac6d2 100644 --- a/backend/src/main/java/wooteco/prolog/organization/application/OrganizationService.java +++ b/backend/src/main/java/wooteco/prolog/organization/application/OrganizationService.java @@ -1,7 +1,5 @@ package wooteco.prolog.organization.application; -import java.util.List; -import java.util.stream.Collectors; import org.springframework.context.event.EventListener; import org.springframework.stereotype.Service; import wooteco.prolog.member.domain.MemberCreatedEvent; @@ -15,6 +13,9 @@ import wooteco.prolog.organization.domain.repository.OrganizationRepository; import wooteco.prolog.session.domain.Session; +import java.util.List; +import java.util.stream.Collectors; + @Service public class OrganizationService { diff --git a/backend/src/main/java/wooteco/prolog/organization/domain/Organization.java b/backend/src/main/java/wooteco/prolog/organization/domain/Organization.java index 64868e82f..2935a254c 100644 --- a/backend/src/main/java/wooteco/prolog/organization/domain/Organization.java +++ b/backend/src/main/java/wooteco/prolog/organization/domain/Organization.java @@ -1,9 +1,9 @@ package wooteco.prolog.organization.domain; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/backend/src/main/java/wooteco/prolog/organization/domain/OrganizationGroup.java b/backend/src/main/java/wooteco/prolog/organization/domain/OrganizationGroup.java index ace391c66..ba1618955 100644 --- a/backend/src/main/java/wooteco/prolog/organization/domain/OrganizationGroup.java +++ b/backend/src/main/java/wooteco/prolog/organization/domain/OrganizationGroup.java @@ -1,9 +1,9 @@ package wooteco.prolog.organization.domain; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/backend/src/main/java/wooteco/prolog/organization/domain/OrganizationGroupMember.java b/backend/src/main/java/wooteco/prolog/organization/domain/OrganizationGroupMember.java index 340ac3edb..53127e384 100644 --- a/backend/src/main/java/wooteco/prolog/organization/domain/OrganizationGroupMember.java +++ b/backend/src/main/java/wooteco/prolog/organization/domain/OrganizationGroupMember.java @@ -1,9 +1,9 @@ package wooteco.prolog.organization.domain; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/backend/src/main/java/wooteco/prolog/organization/domain/OrganizationGroupSession.java b/backend/src/main/java/wooteco/prolog/organization/domain/OrganizationGroupSession.java index a87b4bb61..e3d6ce547 100644 --- a/backend/src/main/java/wooteco/prolog/organization/domain/OrganizationGroupSession.java +++ b/backend/src/main/java/wooteco/prolog/organization/domain/OrganizationGroupSession.java @@ -1,12 +1,12 @@ package wooteco.prolog.organization.domain; -import javax.persistence.CascadeType; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; import lombok.Getter; import lombok.NoArgsConstructor; import wooteco.prolog.session.domain.Session; diff --git a/backend/src/main/java/wooteco/prolog/organization/domain/repository/OrganizationGroupMemberRepository.java b/backend/src/main/java/wooteco/prolog/organization/domain/repository/OrganizationGroupMemberRepository.java index c201db360..f95fd0d76 100644 --- a/backend/src/main/java/wooteco/prolog/organization/domain/repository/OrganizationGroupMemberRepository.java +++ b/backend/src/main/java/wooteco/prolog/organization/domain/repository/OrganizationGroupMemberRepository.java @@ -1,9 +1,10 @@ package wooteco.prolog.organization.domain.repository; -import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import wooteco.prolog.organization.domain.OrganizationGroupMember; +import java.util.List; + public interface OrganizationGroupMemberRepository extends JpaRepository { List findByUsername(String username); diff --git a/backend/src/main/java/wooteco/prolog/organization/domain/repository/OrganizationGroupRepository.java b/backend/src/main/java/wooteco/prolog/organization/domain/repository/OrganizationGroupRepository.java index f2fa2e446..de0b81fde 100644 --- a/backend/src/main/java/wooteco/prolog/organization/domain/repository/OrganizationGroupRepository.java +++ b/backend/src/main/java/wooteco/prolog/organization/domain/repository/OrganizationGroupRepository.java @@ -1,9 +1,10 @@ package wooteco.prolog.organization.domain.repository; -import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import wooteco.prolog.organization.domain.OrganizationGroup; +import java.util.List; + public interface OrganizationGroupRepository extends JpaRepository { List findByIdInOrderByIdDesc(List organizationGroupIds); diff --git a/backend/src/main/java/wooteco/prolog/organization/domain/repository/OrganizationGroupSessionRepository.java b/backend/src/main/java/wooteco/prolog/organization/domain/repository/OrganizationGroupSessionRepository.java index c4dbb1ab3..2434ecff6 100644 --- a/backend/src/main/java/wooteco/prolog/organization/domain/repository/OrganizationGroupSessionRepository.java +++ b/backend/src/main/java/wooteco/prolog/organization/domain/repository/OrganizationGroupSessionRepository.java @@ -1,9 +1,10 @@ package wooteco.prolog.organization.domain.repository; -import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import wooteco.prolog.organization.domain.OrganizationGroupSession; +import java.util.List; + public interface OrganizationGroupSessionRepository extends JpaRepository { List findByOrganizationGroupIdIn(List organizationGroupIds); diff --git a/backend/src/main/java/wooteco/prolog/roadmap/application/CurriculumService.java b/backend/src/main/java/wooteco/prolog/roadmap/application/CurriculumService.java index f3ff51df1..cf7861694 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/application/CurriculumService.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/application/CurriculumService.java @@ -1,8 +1,5 @@ package wooteco.prolog.roadmap.application; -import static wooteco.prolog.common.exception.BadRequestCode.CURRICULUM_NOT_FOUND_EXCEPTION; - -import java.util.List; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import wooteco.prolog.common.exception.BadRequestException; @@ -11,6 +8,10 @@ import wooteco.prolog.roadmap.domain.Curriculum; import wooteco.prolog.roadmap.domain.repository.CurriculumRepository; +import java.util.List; + +import static wooteco.prolog.common.exception.BadRequestCode.CURRICULUM_NOT_FOUND_EXCEPTION; + @Transactional @Service public class CurriculumService { diff --git a/backend/src/main/java/wooteco/prolog/roadmap/application/EssayAnswerService.java b/backend/src/main/java/wooteco/prolog/roadmap/application/EssayAnswerService.java index 1b2943dc4..e83fd9452 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/application/EssayAnswerService.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/application/EssayAnswerService.java @@ -1,13 +1,5 @@ package wooteco.prolog.roadmap.application; -import static wooteco.prolog.common.exception.BadRequestCode.CURRICULUM_NOT_FOUND_EXCEPTION; -import static wooteco.prolog.common.exception.BadRequestCode.ESSAY_ANSWER_NOT_FOUND_EXCEPTION; -import static wooteco.prolog.common.exception.BadRequestCode.MEMBER_NOT_ALLOWED; -import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_QUIZ_NOT_FOUND_EXCEPTION; -import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_SESSION_NOT_FOUND_EXCEPTION; - -import java.util.List; -import java.util.stream.Collectors; import org.hibernate.Hibernate; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -32,6 +24,15 @@ import wooteco.prolog.session.domain.repository.SessionRepository; import wooteco.prolog.studylog.application.dto.EssayAnswersResponse; +import java.util.List; +import java.util.stream.Collectors; + +import static wooteco.prolog.common.exception.BadRequestCode.CURRICULUM_NOT_FOUND_EXCEPTION; +import static wooteco.prolog.common.exception.BadRequestCode.ESSAY_ANSWER_NOT_FOUND_EXCEPTION; +import static wooteco.prolog.common.exception.BadRequestCode.MEMBER_NOT_ALLOWED; +import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_QUIZ_NOT_FOUND_EXCEPTION; +import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_SESSION_NOT_FOUND_EXCEPTION; + @Transactional @Service diff --git a/backend/src/main/java/wooteco/prolog/roadmap/application/KeywordService.java b/backend/src/main/java/wooteco/prolog/roadmap/application/KeywordService.java index c61fbd7a4..b76335c4c 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/application/KeywordService.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/application/KeywordService.java @@ -1,10 +1,5 @@ package wooteco.prolog.roadmap.application; -import static java.util.Collections.emptyMap; -import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_KEYWORD_NOT_FOUND_EXCEPTION; -import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_SESSION_NOT_FOUND_EXCEPTION; - -import java.util.List; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import wooteco.prolog.common.exception.BadRequestException; @@ -16,6 +11,12 @@ import wooteco.prolog.roadmap.domain.repository.KeywordRepository; import wooteco.prolog.session.domain.repository.SessionRepository; +import java.util.List; + +import static java.util.Collections.emptyMap; +import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_KEYWORD_NOT_FOUND_EXCEPTION; +import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_SESSION_NOT_FOUND_EXCEPTION; + @Transactional @Service public class KeywordService { diff --git a/backend/src/main/java/wooteco/prolog/roadmap/application/NewSessionService.java b/backend/src/main/java/wooteco/prolog/roadmap/application/NewSessionService.java index ef156c406..40c280088 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/application/NewSessionService.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/application/NewSessionService.java @@ -1,9 +1,5 @@ package wooteco.prolog.roadmap.application; -import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_SESSION_NOT_FOUND_EXCEPTION; - -import java.util.List; -import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -14,6 +10,11 @@ import wooteco.prolog.session.domain.Session; import wooteco.prolog.session.domain.repository.SessionRepository; +import java.util.List; +import java.util.stream.Collectors; + +import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_SESSION_NOT_FOUND_EXCEPTION; + @Transactional(readOnly = true) @RequiredArgsConstructor @Service diff --git a/backend/src/main/java/wooteco/prolog/roadmap/application/QuizService.java b/backend/src/main/java/wooteco/prolog/roadmap/application/QuizService.java index 06fcae13f..f8265f8d4 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/application/QuizService.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/application/QuizService.java @@ -1,12 +1,5 @@ package wooteco.prolog.roadmap.application; -import static java.util.Objects.isNull; -import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_KEYWORD_ORDER_EXCEPTION; -import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_QUIZ_NOT_FOUND_EXCEPTION; - -import java.util.Comparator; -import java.util.List; -import java.util.stream.Collectors; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -21,6 +14,14 @@ import wooteco.prolog.roadmap.domain.repository.KeywordRepository; import wooteco.prolog.roadmap.domain.repository.QuizRepository; +import java.util.Comparator; +import java.util.List; +import java.util.stream.Collectors; + +import static java.util.Objects.isNull; +import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_KEYWORD_ORDER_EXCEPTION; +import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_QUIZ_NOT_FOUND_EXCEPTION; + @Service @Transactional(readOnly = true) @AllArgsConstructor diff --git a/backend/src/main/java/wooteco/prolog/roadmap/application/RecommendedPostService.java b/backend/src/main/java/wooteco/prolog/roadmap/application/RecommendedPostService.java index 52a95b90f..6d3c00cc1 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/application/RecommendedPostService.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/application/RecommendedPostService.java @@ -1,8 +1,5 @@ package wooteco.prolog.roadmap.application; -import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_KEYWORD_NOT_FOUND_EXCEPTION; -import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_RECOMMENDED_POST_NOT_FOUND; - import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import wooteco.prolog.common.exception.BadRequestException; @@ -13,6 +10,9 @@ import wooteco.prolog.roadmap.domain.repository.KeywordRepository; import wooteco.prolog.roadmap.domain.repository.RecommendedPostRepository; +import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_KEYWORD_NOT_FOUND_EXCEPTION; +import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_RECOMMENDED_POST_NOT_FOUND; + @Transactional(readOnly = true) @Service public class RecommendedPostService { diff --git a/backend/src/main/java/wooteco/prolog/roadmap/application/RoadMapService.java b/backend/src/main/java/wooteco/prolog/roadmap/application/RoadMapService.java index 1e0a60ab2..bff726073 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/application/RoadMapService.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/application/RoadMapService.java @@ -1,9 +1,5 @@ package wooteco.prolog.roadmap.application; -import static java.util.stream.Collectors.toMap; - -import java.util.List; -import java.util.Map; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -13,6 +9,11 @@ import wooteco.prolog.roadmap.domain.repository.dto.KeywordIdAndAnsweredQuizCount; import wooteco.prolog.roadmap.domain.repository.dto.KeywordIdAndTotalQuizCount; +import java.util.List; +import java.util.Map; + +import static java.util.stream.Collectors.toMap; + @RequiredArgsConstructor @Transactional(readOnly = true) @Service diff --git a/backend/src/main/java/wooteco/prolog/roadmap/application/dto/CurriculumResponses.java b/backend/src/main/java/wooteco/prolog/roadmap/application/dto/CurriculumResponses.java index d8fa66461..213f33c4e 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/application/dto/CurriculumResponses.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/application/dto/CurriculumResponses.java @@ -1,12 +1,13 @@ package wooteco.prolog.roadmap.application.dto; -import java.util.List; -import java.util.stream.Collectors; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; import wooteco.prolog.roadmap.domain.Curriculum; +import java.util.List; +import java.util.stream.Collectors; + @NoArgsConstructor(access = AccessLevel.PROTECTED) @Getter public class CurriculumResponses { diff --git a/backend/src/main/java/wooteco/prolog/roadmap/application/dto/EssayAnswerResponse.java b/backend/src/main/java/wooteco/prolog/roadmap/application/dto/EssayAnswerResponse.java index 32e5bc145..df0d36d4c 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/application/dto/EssayAnswerResponse.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/application/dto/EssayAnswerResponse.java @@ -1,6 +1,5 @@ package wooteco.prolog.roadmap.application.dto; -import java.time.LocalDateTime; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; @@ -8,6 +7,8 @@ import wooteco.prolog.member.application.dto.MemberResponse; import wooteco.prolog.roadmap.domain.EssayAnswer; +import java.time.LocalDateTime; + @AllArgsConstructor @NoArgsConstructor(access = AccessLevel.PRIVATE) @Getter diff --git a/backend/src/main/java/wooteco/prolog/roadmap/application/dto/EssayAnswerSearchRequest.java b/backend/src/main/java/wooteco/prolog/roadmap/application/dto/EssayAnswerSearchRequest.java index 289dd382f..315401e32 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/application/dto/EssayAnswerSearchRequest.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/application/dto/EssayAnswerSearchRequest.java @@ -1,12 +1,13 @@ package wooteco.prolog.roadmap.application.dto; -import java.util.List; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; +import java.util.List; + @Setter @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) diff --git a/backend/src/main/java/wooteco/prolog/roadmap/application/dto/KeywordResponse.java b/backend/src/main/java/wooteco/prolog/roadmap/application/dto/KeywordResponse.java index 925f80936..5b0fda6d1 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/application/dto/KeywordResponse.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/application/dto/KeywordResponse.java @@ -1,14 +1,15 @@ package wooteco.prolog.roadmap.application.dto; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; +import wooteco.prolog.roadmap.domain.Keyword; + import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; -import wooteco.prolog.roadmap.domain.Keyword; @NoArgsConstructor(access = AccessLevel.PROTECTED) @Getter diff --git a/backend/src/main/java/wooteco/prolog/roadmap/application/dto/KeywordsResponse.java b/backend/src/main/java/wooteco/prolog/roadmap/application/dto/KeywordsResponse.java index 1e4c33e5c..c5927f0a1 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/application/dto/KeywordsResponse.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/application/dto/KeywordsResponse.java @@ -1,13 +1,14 @@ package wooteco.prolog.roadmap.application.dto; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; import wooteco.prolog.roadmap.domain.Keyword; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + @NoArgsConstructor(access = AccessLevel.PROTECTED) @Getter public class KeywordsResponse { diff --git a/backend/src/main/java/wooteco/prolog/roadmap/application/dto/QuizzesResponse.java b/backend/src/main/java/wooteco/prolog/roadmap/application/dto/QuizzesResponse.java index 29c31599a..cf31d7521 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/application/dto/QuizzesResponse.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/application/dto/QuizzesResponse.java @@ -1,10 +1,11 @@ package wooteco.prolog.roadmap.application.dto; -import java.util.List; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; +import java.util.List; + @NoArgsConstructor(access = AccessLevel.PROTECTED) @Getter public class QuizzesResponse { diff --git a/backend/src/main/java/wooteco/prolog/roadmap/application/dto/SessionsResponse.java b/backend/src/main/java/wooteco/prolog/roadmap/application/dto/SessionsResponse.java index 5be2023f0..576dcb478 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/application/dto/SessionsResponse.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/application/dto/SessionsResponse.java @@ -1,10 +1,11 @@ package wooteco.prolog.roadmap.application.dto; -import java.util.List; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; +import java.util.List; + @NoArgsConstructor(access = AccessLevel.PROTECTED) @Getter public class SessionsResponse { diff --git a/backend/src/main/java/wooteco/prolog/roadmap/domain/Curriculum.java b/backend/src/main/java/wooteco/prolog/roadmap/domain/Curriculum.java index 669bed52d..2f59bfad5 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/domain/Curriculum.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/domain/Curriculum.java @@ -1,17 +1,17 @@ package wooteco.prolog.roadmap.domain; -import static wooteco.prolog.common.exception.BadRequestCode.CURRICULUM_INVALID_EXCEPTION; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; import wooteco.prolog.common.exception.BadRequestException; +import static wooteco.prolog.common.exception.BadRequestCode.CURRICULUM_INVALID_EXCEPTION; + @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @Entity diff --git a/backend/src/main/java/wooteco/prolog/roadmap/domain/EssayAnswer.java b/backend/src/main/java/wooteco/prolog/roadmap/domain/EssayAnswer.java index e0da72786..05e14e414 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/domain/EssayAnswer.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/domain/EssayAnswer.java @@ -1,19 +1,16 @@ package wooteco.prolog.roadmap.domain; -import static wooteco.prolog.common.exception.BadRequestCode.ESSAY_ANSWER_NOT_VALID_USER; -import static wooteco.prolog.common.exception.BadRequestCode.NOT_EMPTY_ESSAY_ANSWER_EXCEPTION; - -import javax.persistence.Column; -import javax.persistence.ConstraintMode; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.ForeignKey; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.ConstraintMode; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.ForeignKey; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -22,6 +19,9 @@ import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.member.domain.Member; +import static wooteco.prolog.common.exception.BadRequestCode.ESSAY_ANSWER_NOT_VALID_USER; +import static wooteco.prolog.common.exception.BadRequestCode.NOT_EMPTY_ESSAY_ANSWER_EXCEPTION; + @Table(name = "essay_answer") @Entity @Getter diff --git a/backend/src/main/java/wooteco/prolog/roadmap/domain/Keyword.java b/backend/src/main/java/wooteco/prolog/roadmap/domain/Keyword.java index 97936ae05..6a740e3a9 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/domain/Keyword.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/domain/Keyword.java @@ -1,28 +1,29 @@ package wooteco.prolog.roadmap.domain; -import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_KEYWORD_AND_KEYWORD_PARENT_SAME_EXCEPTION; -import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_KEYWORD_SEQUENCE_EXCEPTION; - -import java.util.HashSet; -import java.util.Objects; -import java.util.Set; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.OneToMany; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.OneToMany; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; import org.hibernate.annotations.BatchSize; import wooteco.prolog.common.exception.BadRequestException; +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; + +import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_KEYWORD_AND_KEYWORD_PARENT_SAME_EXCEPTION; +import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_KEYWORD_SEQUENCE_EXCEPTION; + @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @Entity @@ -48,7 +49,7 @@ public class Keyword { @BatchSize(size = 1000) @OneToMany(mappedBy = "keyword", cascade = CascadeType.ALL, orphanRemoval = true) - private Set recommendedPosts = new HashSet<>(); + private final Set recommendedPosts = new HashSet<>(); @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "parent_id") @@ -119,10 +120,9 @@ public boolean equals(final Object o) { if (this == o) { return true; } - if (!(o instanceof Keyword)) { + if (!(o instanceof Keyword keyword)) { return false; } - Keyword keyword = (Keyword) o; return Objects.equals(id, keyword.id); } diff --git a/backend/src/main/java/wooteco/prolog/roadmap/domain/Quiz.java b/backend/src/main/java/wooteco/prolog/roadmap/domain/Quiz.java index 8054e6957..6b6fbb6ec 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/domain/Quiz.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/domain/Quiz.java @@ -1,19 +1,19 @@ package wooteco.prolog.roadmap.domain; -import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_QUIZ_NOT_FOUND_EXCEPTION; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; import lombok.AccessLevel; import lombok.NoArgsConstructor; import wooteco.prolog.common.exception.BadRequestException; +import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_QUIZ_NOT_FOUND_EXCEPTION; + @NoArgsConstructor(access = AccessLevel.PROTECTED) @Entity public class Quiz { diff --git a/backend/src/main/java/wooteco/prolog/roadmap/domain/RecommendedPost.java b/backend/src/main/java/wooteco/prolog/roadmap/domain/RecommendedPost.java index 537d5a964..e1bbcc04e 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/domain/RecommendedPost.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/domain/RecommendedPost.java @@ -1,24 +1,25 @@ package wooteco.prolog.roadmap.domain; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; +import wooteco.prolog.common.exception.BadRequestException; + +import java.util.Objects; + import static io.micrometer.core.instrument.util.StringUtils.isBlank; import static java.util.Objects.hash; import static java.util.Objects.isNull; import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_KEYWORD_NOT_FOUND_EXCEPTION; import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_RECOMMENDED_POST_INVALID_URL_LENGTH; -import java.util.Objects; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; -import wooteco.prolog.common.exception.BadRequestException; - @Entity @NoArgsConstructor(access = AccessLevel.PROTECTED) @Getter @@ -74,8 +75,7 @@ public void addKeyword(final Keyword keyword) { @Override public boolean equals(final Object o) { if (this == o) return true; - if (!(o instanceof RecommendedPost)) return false; - final RecommendedPost post = (RecommendedPost) o; + if (!(o instanceof RecommendedPost post)) return false; return Objects.equals(id, post.id); } diff --git a/backend/src/main/java/wooteco/prolog/roadmap/domain/repository/EssayAnswerRepository.java b/backend/src/main/java/wooteco/prolog/roadmap/domain/repository/EssayAnswerRepository.java index 2b057cf39..1e9acc605 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/domain/repository/EssayAnswerRepository.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/domain/repository/EssayAnswerRepository.java @@ -1,14 +1,15 @@ package wooteco.prolog.roadmap.domain.repository; -import java.util.List; -import java.util.Optional; -import java.util.Set; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import wooteco.prolog.roadmap.domain.EssayAnswer; +import java.util.List; +import java.util.Optional; +import java.util.Set; + public interface EssayAnswerRepository extends JpaRepository, JpaSpecificationExecutor { diff --git a/backend/src/main/java/wooteco/prolog/roadmap/domain/repository/EssayAnswerSpecification.java b/backend/src/main/java/wooteco/prolog/roadmap/domain/repository/EssayAnswerSpecification.java index c939b79f1..501b43263 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/domain/repository/EssayAnswerSpecification.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/domain/repository/EssayAnswerSpecification.java @@ -1,10 +1,11 @@ package wooteco.prolog.roadmap.domain.repository; -import java.util.List; -import javax.persistence.criteria.JoinType; +import jakarta.persistence.criteria.JoinType; import org.springframework.data.jpa.domain.Specification; import wooteco.prolog.roadmap.domain.EssayAnswer; +import java.util.List; + public class EssayAnswerSpecification { private EssayAnswerSpecification() { diff --git a/backend/src/main/java/wooteco/prolog/roadmap/domain/repository/KeywordRepository.java b/backend/src/main/java/wooteco/prolog/roadmap/domain/repository/KeywordRepository.java index c241fab7c..c9f96348b 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/domain/repository/KeywordRepository.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/domain/repository/KeywordRepository.java @@ -1,6 +1,5 @@ package wooteco.prolog.roadmap.domain.repository; -import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; @@ -8,6 +7,8 @@ import wooteco.prolog.roadmap.domain.repository.dto.KeywordIdAndAnsweredQuizCount; import wooteco.prolog.roadmap.domain.repository.dto.KeywordIdAndTotalQuizCount; +import java.util.List; + public interface KeywordRepository extends JpaRepository { @Query("SELECT k.id AS keywordId, COUNT (q.id) as totalQuizCount " + diff --git a/backend/src/main/java/wooteco/prolog/roadmap/domain/repository/QuizRepository.java b/backend/src/main/java/wooteco/prolog/roadmap/domain/repository/QuizRepository.java index 33702685f..be6c50b79 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/domain/repository/QuizRepository.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/domain/repository/QuizRepository.java @@ -1,12 +1,13 @@ package wooteco.prolog.roadmap.domain.repository; -import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import wooteco.prolog.roadmap.application.dto.CurriculumQuizResponse; import wooteco.prolog.roadmap.domain.Quiz; +import java.util.List; + public interface QuizRepository extends JpaRepository { @Query("SELECT q FROM Quiz q" @@ -17,8 +18,8 @@ public interface QuizRepository extends JpaRepository { @Query(nativeQuery = true, value = "SELECT q.id, q.question " + "FROM curriculum c " + - "JOIN session s ON c.id = :curriculumId AND s.curriculum_id = c.id " + - "JOIN keyword k ON k.session_id = s.id " + - "JOIN quiz q ON q.keyword_id = k.id") + "JOIN session s ON c.id = :curriculumId AND s.curriculum_id = c.id " + + "JOIN keyword k ON k.session_id = s.id " + + "JOIN quiz q ON q.keyword_id = k.id") List findQuizzesByCurriculum(@Param("curriculumId") Long curriculumId); } diff --git a/backend/src/main/java/wooteco/prolog/roadmap/ui/CurriculumController.java b/backend/src/main/java/wooteco/prolog/roadmap/ui/CurriculumController.java index c3c06af4b..4097786e2 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/ui/CurriculumController.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/ui/CurriculumController.java @@ -1,6 +1,5 @@ package wooteco.prolog.roadmap.ui; -import java.net.URI; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -14,6 +13,8 @@ import wooteco.prolog.roadmap.application.dto.CurriculumRequest; import wooteco.prolog.roadmap.application.dto.CurriculumResponses; +import java.net.URI; + @RestController @RequestMapping("/curriculums") public class CurriculumController { diff --git a/backend/src/main/java/wooteco/prolog/roadmap/ui/EssayAnswerController.java b/backend/src/main/java/wooteco/prolog/roadmap/ui/EssayAnswerController.java index f56807baf..42b282091 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/ui/EssayAnswerController.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/ui/EssayAnswerController.java @@ -1,8 +1,5 @@ package wooteco.prolog.roadmap.ui; -import static java.util.stream.Collectors.toList; - -import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Pageable; import org.springframework.data.web.PageableDefault; @@ -26,6 +23,10 @@ import wooteco.prolog.roadmap.domain.EssayAnswer; import wooteco.prolog.studylog.application.dto.EssayAnswersResponse; +import java.util.List; + +import static java.util.stream.Collectors.toList; + @RestController @RequestMapping @@ -36,14 +37,14 @@ public class EssayAnswerController { @Autowired public EssayAnswerController(EssayAnswerService essayAnswerService, - QuizService quizService) { + QuizService quizService) { this.essayAnswerService = essayAnswerService; this.quizService = quizService; } @PostMapping("/essay-answers") public ResponseEntity create(@RequestBody EssayAnswerRequest request, - @AuthMemberPrincipal LoginMember member) { + @AuthMemberPrincipal LoginMember member) { return ResponseEntity.ok(essayAnswerService.createEssayAnswer(request, member.getId())); } @@ -64,8 +65,8 @@ public ResponseEntity findById(@PathVariable Long essayAnsw @PatchMapping("/essay-answers/{essayAnswerId}") public ResponseEntity updateById(@PathVariable Long essayAnswerId, - @AuthMemberPrincipal LoginMember member, - @RequestBody EssayAnswerUpdateRequest request) { + @AuthMemberPrincipal LoginMember member, + @RequestBody EssayAnswerUpdateRequest request) { essayAnswerService.updateEssayAnswer(essayAnswerId, request, member.getId()); return ResponseEntity.ok().build(); } diff --git a/backend/src/main/java/wooteco/prolog/roadmap/ui/KeywordController.java b/backend/src/main/java/wooteco/prolog/roadmap/ui/KeywordController.java index b47e07c1f..7091c1f7c 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/ui/KeywordController.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/ui/KeywordController.java @@ -1,6 +1,5 @@ package wooteco.prolog.roadmap.ui; -import java.net.URI; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -15,6 +14,8 @@ import wooteco.prolog.roadmap.application.dto.KeywordUpdateRequest; import wooteco.prolog.roadmap.application.dto.KeywordsResponse; +import java.net.URI; + @RestController public class KeywordController { @@ -26,7 +27,7 @@ public KeywordController(final KeywordService keywordService) { @PostMapping("/sessions/{sessionId}/keywords") public ResponseEntity createKeyword(@PathVariable Long sessionId, - @RequestBody KeywordCreateRequest createRequest) { + @RequestBody KeywordCreateRequest createRequest) { Long keywordId = keywordService.createKeyword(sessionId, createRequest); return ResponseEntity.created( URI.create("/sessions/" + sessionId + "/keywords/" + keywordId)).build(); @@ -34,7 +35,7 @@ public ResponseEntity createKeyword(@PathVariable Long sessionId, @GetMapping("/sessions/{sessionId}/keywords/{keywordId}") public ResponseEntity findKeyword(@PathVariable Long sessionId, - @PathVariable Long keywordId) { + @PathVariable Long keywordId) { KeywordResponse response = keywordService.findKeyword(sessionId, keywordId); return ResponseEntity.ok(response); } @@ -49,15 +50,15 @@ public ResponseEntity newFindKeyword( @PutMapping("/sessions/{sessionId}/keywords/{keywordId}") public ResponseEntity updateKeyword(@PathVariable Long sessionId, - @PathVariable Long keywordId, - @RequestBody KeywordUpdateRequest updateRequest) { + @PathVariable Long keywordId, + @RequestBody KeywordUpdateRequest updateRequest) { keywordService.updateKeyword(sessionId, keywordId, updateRequest); return ResponseEntity.noContent().build(); } @DeleteMapping("/sessions/{sessionId}/keywords/{keywordId}") public ResponseEntity deleteKeyword(@PathVariable Long sessionId, - @PathVariable Long keywordId) { + @PathVariable Long keywordId) { keywordService.deleteKeyword(sessionId, keywordId); return ResponseEntity.noContent().build(); } @@ -78,7 +79,7 @@ public ResponseEntity newFindSessionIncludeRootKeywords() { @GetMapping("/sessions/{sessionId}/keywords/{keywordId}/children") public ResponseEntity find(@PathVariable Long sessionId, - @PathVariable Long keywordId) { + @PathVariable Long keywordId) { KeywordResponse response = keywordService.findKeywordWithAllChild(sessionId, keywordId); return ResponseEntity.ok(response); } diff --git a/backend/src/main/java/wooteco/prolog/roadmap/ui/NewSessionController.java b/backend/src/main/java/wooteco/prolog/roadmap/ui/NewSessionController.java index f4d0fface..e7dec7df7 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/ui/NewSessionController.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/ui/NewSessionController.java @@ -1,6 +1,5 @@ package wooteco.prolog.roadmap.ui; -import java.net.URI; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; @@ -15,6 +14,8 @@ import wooteco.prolog.roadmap.application.dto.SessionRequest; import wooteco.prolog.roadmap.application.dto.SessionsResponse; +import java.net.URI; + @RequiredArgsConstructor @RestController @RequestMapping("/curriculums/{curriculumId}/sessions") diff --git a/backend/src/main/java/wooteco/prolog/roadmap/ui/QuizController.java b/backend/src/main/java/wooteco/prolog/roadmap/ui/QuizController.java index 3f610c952..dddd19f58 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/ui/QuizController.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/ui/QuizController.java @@ -1,7 +1,5 @@ package wooteco.prolog.roadmap.ui; -import java.net.URI; -import java.util.List; import lombok.AllArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; @@ -20,6 +18,9 @@ import wooteco.prolog.roadmap.application.dto.QuizResponse; import wooteco.prolog.roadmap.application.dto.QuizzesResponse; +import java.net.URI; +import java.util.List; + @RestController @AllArgsConstructor public class QuizController { @@ -29,7 +30,7 @@ public class QuizController { //: todo admin login 생기면 검증 추가 @PostMapping("/sessions/{sessionId}/keywords/{keywordId}/quizs") public ResponseEntity create(@PathVariable Long sessionId, @PathVariable Long keywordId, - @RequestBody QuizRequest quizRequest) { + @RequestBody QuizRequest quizRequest) { final Long quizId = quizService.createQuiz(keywordId, quizRequest); return ResponseEntity.created( @@ -39,7 +40,7 @@ public ResponseEntity create(@PathVariable Long sessionId, @PathVariable L @GetMapping("/sessions/{sessionId}/keywords/{keywordId}/quizs/{quizId}") public ResponseEntity findQuizById(@PathVariable Long quizId, - @AuthMemberPrincipal LoginMember member) { + @AuthMemberPrincipal LoginMember member) { return ResponseEntity.ok(quizService.findById(quizId, member.getId())); } @@ -53,8 +54,8 @@ public ResponseEntity newFindQuizById( @GetMapping("/sessions/{sessionId}/keywords/{keywordId}/quizs") public ResponseEntity findQuizzesByKeyword(@PathVariable Long sessionId, - @PathVariable Long keywordId, - @AuthMemberPrincipal LoginMember member) { + @PathVariable Long keywordId, + @AuthMemberPrincipal LoginMember member) { return ResponseEntity.ok(quizService.findQuizzesByKeywordId(keywordId, member.getId())); } @@ -75,17 +76,17 @@ public ResponseEntity> findQuizzesByCurriculum( @PutMapping("/sessions/{sessionId}/keywords/{keywordId}/quizs/{quizId}") ResponseEntity updateQuiz(@PathVariable Long sessionId, - @PathVariable Long keywordId, - @PathVariable Long quizId, - @RequestBody QuizRequest quizRequest) { + @PathVariable Long keywordId, + @PathVariable Long quizId, + @RequestBody QuizRequest quizRequest) { quizService.updateQuiz(quizId, quizRequest); return ResponseEntity.noContent().build(); } @DeleteMapping("/sessions/{sessionId}/keywords/{keywordId}/quizs/{quizId}") public ResponseEntity deleteQuiz(@PathVariable Long sessionId, - @PathVariable Long keywordId, - @PathVariable Long quizId) { + @PathVariable Long keywordId, + @PathVariable Long quizId) { quizService.deleteQuiz(quizId); return ResponseEntity.noContent().build(); } diff --git a/backend/src/main/java/wooteco/prolog/session/application/MissionService.java b/backend/src/main/java/wooteco/prolog/session/application/MissionService.java index 486a1e86f..964e46b79 100644 --- a/backend/src/main/java/wooteco/prolog/session/application/MissionService.java +++ b/backend/src/main/java/wooteco/prolog/session/application/MissionService.java @@ -1,13 +1,5 @@ package wooteco.prolog.session.application; -import static java.util.stream.Collectors.toList; -import static wooteco.prolog.common.exception.BadRequestCode.DUPLICATE_MISSION; -import static wooteco.prolog.common.exception.BadRequestCode.MISSION_NOT_FOUND; - -import java.util.Collection; -import java.util.List; -import java.util.Optional; -import java.util.stream.Stream; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -19,6 +11,15 @@ import wooteco.prolog.session.domain.Session; import wooteco.prolog.session.domain.repository.MissionRepository; +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.stream.Stream; + +import static java.util.stream.Collectors.toList; +import static wooteco.prolog.common.exception.BadRequestCode.DUPLICATE_MISSION; +import static wooteco.prolog.common.exception.BadRequestCode.MISSION_NOT_FOUND; + @Service @AllArgsConstructor @Transactional(readOnly = true) diff --git a/backend/src/main/java/wooteco/prolog/session/application/SessionMemberService.java b/backend/src/main/java/wooteco/prolog/session/application/SessionMemberService.java index 9bf2df56c..5fc71c848 100644 --- a/backend/src/main/java/wooteco/prolog/session/application/SessionMemberService.java +++ b/backend/src/main/java/wooteco/prolog/session/application/SessionMemberService.java @@ -4,6 +4,7 @@ import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_SESSION_NOT_FOUND_EXCEPTION; import java.util.List; + import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; diff --git a/backend/src/main/java/wooteco/prolog/session/application/SessionService.java b/backend/src/main/java/wooteco/prolog/session/application/SessionService.java index 9f82f7509..4abbce3e5 100644 --- a/backend/src/main/java/wooteco/prolog/session/application/SessionService.java +++ b/backend/src/main/java/wooteco/prolog/session/application/SessionService.java @@ -8,6 +8,7 @@ import java.util.List; import java.util.Optional; import java.util.stream.Stream; + import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; diff --git a/backend/src/main/java/wooteco/prolog/session/application/dto/MissionResponse.java b/backend/src/main/java/wooteco/prolog/session/application/dto/MissionResponse.java index 9286f1ae9..93007cafe 100644 --- a/backend/src/main/java/wooteco/prolog/session/application/dto/MissionResponse.java +++ b/backend/src/main/java/wooteco/prolog/session/application/dto/MissionResponse.java @@ -1,12 +1,13 @@ package wooteco.prolog.session.application.dto; -import java.util.List; -import java.util.stream.Collectors; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import wooteco.prolog.session.domain.Mission; +import java.util.List; +import java.util.stream.Collectors; + @NoArgsConstructor @AllArgsConstructor @Getter diff --git a/backend/src/main/java/wooteco/prolog/session/application/dto/SessionMemberRequest.java b/backend/src/main/java/wooteco/prolog/session/application/dto/SessionMemberRequest.java index bf16d74cb..1111dcac4 100644 --- a/backend/src/main/java/wooteco/prolog/session/application/dto/SessionMemberRequest.java +++ b/backend/src/main/java/wooteco/prolog/session/application/dto/SessionMemberRequest.java @@ -1,10 +1,11 @@ package wooteco.prolog.session.application.dto; -import java.util.List; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; +import java.util.List; + @NoArgsConstructor @AllArgsConstructor @Getter diff --git a/backend/src/main/java/wooteco/prolog/session/domain/Mission.java b/backend/src/main/java/wooteco/prolog/session/domain/Mission.java index 3944856e0..79e29f6cd 100644 --- a/backend/src/main/java/wooteco/prolog/session/domain/Mission.java +++ b/backend/src/main/java/wooteco/prolog/session/domain/Mission.java @@ -1,20 +1,20 @@ package wooteco.prolog.session.domain; -import static wooteco.prolog.common.exception.BadRequestCode.TOO_LONG_MISSION_NAME; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; import lombok.AccessLevel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; import wooteco.prolog.common.exception.BadRequestException; +import static wooteco.prolog.common.exception.BadRequestCode.TOO_LONG_MISSION_NAME; + @Entity @NoArgsConstructor(access = AccessLevel.PROTECTED) @Getter diff --git a/backend/src/main/java/wooteco/prolog/session/domain/Session.java b/backend/src/main/java/wooteco/prolog/session/domain/Session.java index 5b16772ff..241758ea6 100644 --- a/backend/src/main/java/wooteco/prolog/session/domain/Session.java +++ b/backend/src/main/java/wooteco/prolog/session/domain/Session.java @@ -1,11 +1,10 @@ package wooteco.prolog.session.domain; -import java.util.Objects; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -13,6 +12,8 @@ import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.studylog.domain.Curriculum; +import java.util.Objects; + @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @Entity @@ -69,10 +70,9 @@ public boolean equals(Object o) { if (this == o) { return true; } - if (!(o instanceof Session)) { + if (!(o instanceof Session level)) { return false; } - Session level = (Session) o; return Objects.equals(id, level.id); } diff --git a/backend/src/main/java/wooteco/prolog/session/domain/SessionMember.java b/backend/src/main/java/wooteco/prolog/session/domain/SessionMember.java index 91f669457..78af1610b 100644 --- a/backend/src/main/java/wooteco/prolog/session/domain/SessionMember.java +++ b/backend/src/main/java/wooteco/prolog/session/domain/SessionMember.java @@ -1,11 +1,11 @@ package wooteco.prolog.session.domain; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; import lombok.AccessLevel; import lombok.EqualsAndHashCode; import lombok.Getter; diff --git a/backend/src/main/java/wooteco/prolog/session/domain/repository/MissionRepository.java b/backend/src/main/java/wooteco/prolog/session/domain/repository/MissionRepository.java index b34ac6979..693020631 100644 --- a/backend/src/main/java/wooteco/prolog/session/domain/repository/MissionRepository.java +++ b/backend/src/main/java/wooteco/prolog/session/domain/repository/MissionRepository.java @@ -1,10 +1,11 @@ package wooteco.prolog.session.domain.repository; -import java.util.List; -import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import wooteco.prolog.session.domain.Mission; +import java.util.List; +import java.util.Optional; + public interface MissionRepository extends JpaRepository { Optional findByName(String name); diff --git a/backend/src/main/java/wooteco/prolog/session/domain/repository/SessionMemberRepository.java b/backend/src/main/java/wooteco/prolog/session/domain/repository/SessionMemberRepository.java index ba1629413..ccd472385 100644 --- a/backend/src/main/java/wooteco/prolog/session/domain/repository/SessionMemberRepository.java +++ b/backend/src/main/java/wooteco/prolog/session/domain/repository/SessionMemberRepository.java @@ -1,11 +1,12 @@ package wooteco.prolog.session.domain.repository; -import java.util.List; -import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import wooteco.prolog.member.domain.Member; import wooteco.prolog.session.domain.SessionMember; +import java.util.List; +import java.util.Optional; + public interface SessionMemberRepository extends JpaRepository { List findAllBySessionId(Long sessionId); diff --git a/backend/src/main/java/wooteco/prolog/session/domain/repository/SessionRepository.java b/backend/src/main/java/wooteco/prolog/session/domain/repository/SessionRepository.java index 2011727ed..2ce292b0b 100644 --- a/backend/src/main/java/wooteco/prolog/session/domain/repository/SessionRepository.java +++ b/backend/src/main/java/wooteco/prolog/session/domain/repository/SessionRepository.java @@ -1,10 +1,11 @@ package wooteco.prolog.session.domain.repository; -import java.util.List; -import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import wooteco.prolog.session.domain.Session; +import java.util.List; +import java.util.Optional; + public interface SessionRepository extends JpaRepository { Optional findByName(String name); diff --git a/backend/src/main/java/wooteco/prolog/session/ui/MissionController.java b/backend/src/main/java/wooteco/prolog/session/ui/MissionController.java index c00bd6547..3ab5a0a1e 100644 --- a/backend/src/main/java/wooteco/prolog/session/ui/MissionController.java +++ b/backend/src/main/java/wooteco/prolog/session/ui/MissionController.java @@ -1,6 +1,5 @@ package wooteco.prolog.session.ui; -import java.util.List; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -14,6 +13,8 @@ import wooteco.prolog.session.application.dto.MissionRequest; import wooteco.prolog.session.application.dto.MissionResponse; +import java.util.List; + @RestController @RequestMapping("/missions") public class MissionController { diff --git a/backend/src/main/java/wooteco/prolog/session/ui/SessionController.java b/backend/src/main/java/wooteco/prolog/session/ui/SessionController.java index 2e1fbb6db..21e62edae 100644 --- a/backend/src/main/java/wooteco/prolog/session/ui/SessionController.java +++ b/backend/src/main/java/wooteco/prolog/session/ui/SessionController.java @@ -1,7 +1,5 @@ package wooteco.prolog.session.ui; -import java.net.URI; -import java.util.List; import lombok.AllArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; @@ -16,6 +14,9 @@ import wooteco.prolog.session.application.dto.SessionRequest; import wooteco.prolog.session.application.dto.SessionResponse; +import java.net.URI; +import java.util.List; + @RestController @RequestMapping("/sessions") @AllArgsConstructor diff --git a/backend/src/main/java/wooteco/prolog/session/ui/SessionMemberController.java b/backend/src/main/java/wooteco/prolog/session/ui/SessionMemberController.java index 24b66ce11..8e4175a9c 100644 --- a/backend/src/main/java/wooteco/prolog/session/ui/SessionMemberController.java +++ b/backend/src/main/java/wooteco/prolog/session/ui/SessionMemberController.java @@ -1,6 +1,5 @@ package wooteco.prolog.session.ui; -import java.util.List; import lombok.AllArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; @@ -16,6 +15,8 @@ import wooteco.prolog.session.application.SessionMemberService; import wooteco.prolog.session.application.dto.SessionGroupMemberRequest; +import java.util.List; + @RestController @RequestMapping("/sessions/{sessionId}/members") @AllArgsConstructor diff --git a/backend/src/main/java/wooteco/prolog/studylog/application/AbstractStudylogDocumentService.java b/backend/src/main/java/wooteco/prolog/studylog/application/AbstractStudylogDocumentService.java index 0a54c9f53..796a1ac5d 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/AbstractStudylogDocumentService.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/AbstractStudylogDocumentService.java @@ -1,62 +1,50 @@ package wooteco.prolog.studylog.application; -import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_DOCUMENT_NOT_FOUND; +import wooteco.prolog.common.exception.BadRequestException; +import wooteco.prolog.studylog.domain.StudylogDocument; +import wooteco.prolog.studylog.domain.repository.StudylogRepository; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.stream.Collectors; -import wooteco.prolog.common.exception.BadRequestException; -import wooteco.prolog.studylog.domain.Studylog; -import wooteco.prolog.studylog.domain.StudylogDocument; -import wooteco.prolog.studylog.domain.repository.StudylogDocumentRepository; -import wooteco.prolog.studylog.domain.repository.StudylogRepository; + +import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_DOCUMENT_NOT_FOUND; public abstract class AbstractStudylogDocumentService implements DocumentService { private static final String EMPTY = " "; - protected final StudylogDocumentRepository studylogDocumentRepository; protected final StudylogRepository studylogRepository; - public AbstractStudylogDocumentService(StudylogDocumentRepository studylogDocumentRepository, - StudylogRepository studylogRepository) { - this.studylogDocumentRepository = studylogDocumentRepository; + public AbstractStudylogDocumentService(StudylogRepository studylogRepository) { this.studylogRepository = studylogRepository; } @Override public void save(StudylogDocument studylogDocument) { - studylogDocumentRepository.save(studylogDocument); + // TODO: ES와 같이 제거됨. 다시 구현 필요 } @Override public StudylogDocument findById(Long id) { - return studylogDocumentRepository.findById(id) - .orElseThrow(() -> new BadRequestException(STUDYLOG_DOCUMENT_NOT_FOUND)); + // TODO: ES와 같이 제거됨. 다시 구현 필요 + + throw new BadRequestException(STUDYLOG_DOCUMENT_NOT_FOUND); } @Override public void delete(StudylogDocument studylogDocument) { - studylogDocumentRepository.delete(studylogDocument); + // TODO: ES와 같이 제거됨. 다시 구현 필요 } @Override public void sync() { - // sync between es and db - studylogDocumentRepository.deleteAll(); - - List studylogs = studylogRepository.findAll(); - studylogDocumentRepository.saveAll( - studylogs.stream() - .map(Studylog::toStudylogDocument) - .collect(Collectors.toList()) - ); + // TODO: ES와 같이 제거됨. 다시 구현 필요 } @Override public void update(StudylogDocument studylogDocument) { - studylogDocumentRepository.save(studylogDocument); + // TODO: ES와 같이 제거됨. 다시 구현 필요 } protected List preprocess(String searchKeyword) { diff --git a/backend/src/main/java/wooteco/prolog/studylog/application/CommentService.java b/backend/src/main/java/wooteco/prolog/studylog/application/CommentService.java index b229f9aa5..552655470 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/CommentService.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/CommentService.java @@ -1,12 +1,5 @@ package wooteco.prolog.studylog.application; -import static wooteco.prolog.common.exception.BadRequestCode.COMMENT_NOT_FOUND; -import static wooteco.prolog.common.exception.BadRequestCode.MEMBER_NOT_ALLOWED; -import static wooteco.prolog.common.exception.BadRequestCode.MEMBER_NOT_FOUND; -import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_NOT_FOUND; - -import java.util.List; -import java.util.stream.Collectors; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -23,6 +16,14 @@ import wooteco.prolog.studylog.domain.repository.CommentRepository; import wooteco.prolog.studylog.domain.repository.StudylogRepository; +import java.util.List; +import java.util.stream.Collectors; + +import static wooteco.prolog.common.exception.BadRequestCode.COMMENT_NOT_FOUND; +import static wooteco.prolog.common.exception.BadRequestCode.MEMBER_NOT_ALLOWED; +import static wooteco.prolog.common.exception.BadRequestCode.MEMBER_NOT_FOUND; +import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_NOT_FOUND; + @Transactional @AllArgsConstructor @Service diff --git a/backend/src/main/java/wooteco/prolog/studylog/application/DocumentService.java b/backend/src/main/java/wooteco/prolog/studylog/application/DocumentService.java index 831d375a6..5b96aeb5b 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/DocumentService.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/DocumentService.java @@ -1,11 +1,12 @@ package wooteco.prolog.studylog.application; -import java.time.LocalDate; -import java.util.List; import org.springframework.data.domain.Pageable; import wooteco.prolog.studylog.application.dto.StudylogDocumentResponse; import wooteco.prolog.studylog.domain.StudylogDocument; +import java.time.LocalDate; +import java.util.List; + public interface DocumentService { void save(StudylogDocument toStudylogDocument); diff --git a/backend/src/main/java/wooteco/prolog/studylog/application/FakeStudylogDocumentService.java b/backend/src/main/java/wooteco/prolog/studylog/application/FakeStudylogDocumentService.java index 3a49b9912..e9771b5fb 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/FakeStudylogDocumentService.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/FakeStudylogDocumentService.java @@ -1,10 +1,5 @@ package wooteco.prolog.studylog.application; -import java.time.LocalDate; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; import org.springframework.context.annotation.Profile; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -13,18 +8,22 @@ import wooteco.prolog.studylog.application.dto.StudylogDocumentResponse; import wooteco.prolog.studylog.domain.DocumentQueryParser; import wooteco.prolog.studylog.domain.Studylog; -import wooteco.prolog.studylog.domain.repository.StudylogDocumentRepository; import wooteco.prolog.studylog.domain.repository.StudylogRepository; import wooteco.prolog.studylog.domain.repository.StudylogSpecification; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + @Profile({"local", "test"}) @Service public class FakeStudylogDocumentService extends AbstractStudylogDocumentService { public FakeStudylogDocumentService( - StudylogDocumentRepository studylogDocumentRepository, StudylogRepository studylogRepository) { - super(studylogDocumentRepository, studylogRepository); + super(studylogRepository); } @Override diff --git a/backend/src/main/java/wooteco/prolog/studylog/application/FilterService.java b/backend/src/main/java/wooteco/prolog/studylog/application/FilterService.java index 199f76358..e3af704bd 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/FilterService.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/FilterService.java @@ -1,6 +1,5 @@ package wooteco.prolog.studylog.application; -import java.util.List; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; import wooteco.prolog.login.ui.LoginMember; @@ -10,6 +9,8 @@ import wooteco.prolog.session.application.dto.SessionResponse; import wooteco.prolog.studylog.application.dto.FilterResponse; +import java.util.List; + @Service @AllArgsConstructor public class FilterService { diff --git a/backend/src/main/java/wooteco/prolog/studylog/application/PopularStudylogService.java b/backend/src/main/java/wooteco/prolog/studylog/application/PopularStudylogService.java index abd66a222..73b39e83e 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/PopularStudylogService.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/PopularStudylogService.java @@ -1,13 +1,5 @@ package wooteco.prolog.studylog.application; -import static java.util.stream.Collectors.toList; - -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; import lombok.AllArgsConstructor; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; @@ -28,6 +20,15 @@ import wooteco.prolog.studylog.domain.repository.PopularStudylogRepository; import wooteco.prolog.studylog.domain.repository.StudylogRepository; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import static java.util.stream.Collectors.toList; + @Service @AllArgsConstructor @Transactional(readOnly = true) @@ -90,8 +91,8 @@ private List findRecentStudylogs(final LocalDateTime dateTime, } private List filterStudylogsByDepartmets(final List studylogs, - final Departments departments, - final List departmentMembers) { + final Departments departments, + final List departmentMembers) { return studylogs.stream() .filter( @@ -101,7 +102,7 @@ private List filterStudylogsByDepartmets(final List studylog } private boolean checkMemberAssignedInDepartmets(Departments departments, Member member, - List departmentMembers) { + List departmentMembers) { return departmentMembers.stream().anyMatch( it -> it.getMember().equals(member) && departments.isContainsDepartments(it.getDepartment())); } diff --git a/backend/src/main/java/wooteco/prolog/studylog/application/StudylogDocumentService.java b/backend/src/main/java/wooteco/prolog/studylog/application/StudylogDocumentService.java index 69370253c..67cd962e3 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/StudylogDocumentService.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/StudylogDocumentService.java @@ -1,36 +1,22 @@ package wooteco.prolog.studylog.application; -import static java.util.stream.Collectors.toList; - -import java.time.LocalDate; -import java.util.List; import org.springframework.context.annotation.Profile; import org.springframework.data.domain.Pageable; -import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; -import org.springframework.data.elasticsearch.core.SearchHitSupport; -import org.springframework.data.elasticsearch.core.SearchHits; -import org.springframework.data.elasticsearch.core.SearchPage; -import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates; -import org.springframework.data.elasticsearch.core.query.Query; import org.springframework.stereotype.Service; import wooteco.prolog.studylog.application.dto.StudylogDocumentResponse; -import wooteco.prolog.studylog.domain.StudylogDocument; -import wooteco.prolog.studylog.domain.StudylogDocumentQueryBuilder; -import wooteco.prolog.studylog.domain.repository.StudylogDocumentRepository; import wooteco.prolog.studylog.domain.repository.StudylogRepository; +import java.time.LocalDate; +import java.util.List; + @Profile({"dev", "prod"}) @Service public class StudylogDocumentService extends AbstractStudylogDocumentService { - private final ElasticsearchRestTemplate elasticsearchRestTemplate; public StudylogDocumentService( - StudylogDocumentRepository studylogDocumentRepository, - StudylogRepository studylogRepository, - ElasticsearchRestTemplate elasticsearchRestTemplate) { - super(studylogDocumentRepository, studylogRepository); - this.elasticsearchRestTemplate = elasticsearchRestTemplate; + StudylogRepository studylogRepository) { + super(studylogRepository); } @Override @@ -44,27 +30,6 @@ public StudylogDocumentResponse findBySearchKeyword( LocalDate end, Pageable pageable ) { - - final Query query = StudylogDocumentQueryBuilder.makeQuery(preprocess(keyword), tags, - missions, levels, - usernames, start, end, pageable); - - // Query 결과를 ES에서 조회한다. - final SearchHits searchHits - = elasticsearchRestTemplate.search(query, StudylogDocument.class, - IndexCoordinates.of("studylog-document")); - - // 조회된 SearchHits를 페이징할 수 있는 SearchPage로 변경한다. - final SearchPage searchPages - = SearchHitSupport.searchPageFor(searchHits, query.getPageable()); - - final List studylogIds = searchPages.stream() - .map(searchPage -> searchPage.getContent().getId()) - .collect(toList()); - - return StudylogDocumentResponse.of(studylogIds, - searchPages.getTotalElements(), - searchPages.getTotalPages(), - searchPages.getNumber()); + return new StudylogDocumentResponse(); } } diff --git a/backend/src/main/java/wooteco/prolog/studylog/application/StudylogLikeService.java b/backend/src/main/java/wooteco/prolog/studylog/application/StudylogLikeService.java index ab715c4b3..e9d3d663a 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/StudylogLikeService.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/StudylogLikeService.java @@ -1,8 +1,5 @@ package wooteco.prolog.studylog.application; -import static wooteco.prolog.common.exception.BadRequestCode.INVALID_LIKE_REQUEST_EXCEPTION; -import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_NOT_FOUND; - import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -13,6 +10,9 @@ import wooteco.prolog.studylog.domain.Studylog; import wooteco.prolog.studylog.domain.repository.StudylogRepository; +import static wooteco.prolog.common.exception.BadRequestCode.INVALID_LIKE_REQUEST_EXCEPTION; +import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_NOT_FOUND; + @Service @AllArgsConstructor @Transactional(readOnly = true) diff --git a/backend/src/main/java/wooteco/prolog/studylog/application/StudylogScrapService.java b/backend/src/main/java/wooteco/prolog/studylog/application/StudylogScrapService.java index 27df5a23e..b19396f57 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/StudylogScrapService.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/StudylogScrapService.java @@ -1,10 +1,5 @@ package wooteco.prolog.studylog.application; -import static wooteco.prolog.common.exception.BadRequestCode.MEMBER_NOT_ALLOWED; -import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_NOT_FOUND; -import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_SCRAP_ALREADY_REGISTERED_EXCEPTION; -import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_SCRAP_NOT_EXIST_EXCEPTION; - import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -20,6 +15,11 @@ import wooteco.prolog.studylog.domain.repository.StudylogRepository; import wooteco.prolog.studylog.domain.repository.StudylogScrapRepository; +import static wooteco.prolog.common.exception.BadRequestCode.MEMBER_NOT_ALLOWED; +import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_NOT_FOUND; +import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_SCRAP_ALREADY_REGISTERED_EXCEPTION; +import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_SCRAP_NOT_EXIST_EXCEPTION; + @RequiredArgsConstructor @Service @Transactional(readOnly = true) diff --git a/backend/src/main/java/wooteco/prolog/studylog/application/StudylogService.java b/backend/src/main/java/wooteco/prolog/studylog/application/StudylogService.java index 9689b1356..d170065f2 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/StudylogService.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/StudylogService.java @@ -1,21 +1,5 @@ package wooteco.prolog.studylog.application; -import static java.time.temporal.TemporalAdjusters.firstDayOfMonth; -import static java.time.temporal.TemporalAdjusters.lastDayOfMonth; -import static java.util.stream.Collectors.toList; -import static java.util.stream.Collectors.toMap; -import static wooteco.prolog.common.exception.BadRequestCode.MEMBER_NOT_ALLOWED; -import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_ARGUMENT; -import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_DOCUMENT_NOT_FOUND; -import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_NOT_FOUND; -import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_SCRAP_NOT_EXIST_EXCEPTION; - -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.util.List; -import java.util.Map; -import java.util.Objects; import lombok.AllArgsConstructor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -60,6 +44,23 @@ import wooteco.prolog.studylog.domain.repository.dto.CommentCount; import wooteco.prolog.studylog.event.StudylogDeleteEvent; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +import static java.time.temporal.TemporalAdjusters.firstDayOfMonth; +import static java.time.temporal.TemporalAdjusters.lastDayOfMonth; +import static java.util.stream.Collectors.toList; +import static java.util.stream.Collectors.toMap; +import static wooteco.prolog.common.exception.BadRequestCode.MEMBER_NOT_ALLOWED; +import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_ARGUMENT; +import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_DOCUMENT_NOT_FOUND; +import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_NOT_FOUND; +import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_SCRAP_NOT_EXIST_EXCEPTION; + @Service @AllArgsConstructor @Transactional(readOnly = true) diff --git a/backend/src/main/java/wooteco/prolog/studylog/application/StudylogSessionService.java b/backend/src/main/java/wooteco/prolog/studylog/application/StudylogSessionService.java index 14527a2e2..750cc64af 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/StudylogSessionService.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/StudylogSessionService.java @@ -1,12 +1,13 @@ package wooteco.prolog.studylog.application; -import java.util.List; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import wooteco.prolog.studylog.domain.Studylog; import wooteco.prolog.studylog.domain.repository.StudylogRepository; +import java.util.List; + @Service @AllArgsConstructor @Transactional(readOnly = true) diff --git a/backend/src/main/java/wooteco/prolog/studylog/application/StudylogTagService.java b/backend/src/main/java/wooteco/prolog/studylog/application/StudylogTagService.java index 8cdcdd98a..c579e6ff9 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/StudylogTagService.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/StudylogTagService.java @@ -1,8 +1,5 @@ package wooteco.prolog.studylog.application; -import static java.util.stream.Collectors.toList; - -import java.util.List; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -11,6 +8,10 @@ import wooteco.prolog.studylog.domain.Tag; import wooteco.prolog.studylog.domain.repository.StudylogTagRepository; +import java.util.List; + +import static java.util.stream.Collectors.toList; + @Service @AllArgsConstructor @Transactional(readOnly = true) diff --git a/backend/src/main/java/wooteco/prolog/studylog/application/TagService.java b/backend/src/main/java/wooteco/prolog/studylog/application/TagService.java index af409c5f3..2e9221a26 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/TagService.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/TagService.java @@ -1,10 +1,5 @@ package wooteco.prolog.studylog.application; -import static java.util.stream.Collectors.collectingAndThen; -import static java.util.stream.Collectors.toList; - -import java.util.Comparator; -import java.util.List; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -17,6 +12,12 @@ import wooteco.prolog.studylog.domain.Tags; import wooteco.prolog.studylog.domain.repository.TagRepository; +import java.util.Comparator; +import java.util.List; + +import static java.util.stream.Collectors.collectingAndThen; +import static java.util.stream.Collectors.toList; + @Service @AllArgsConstructor @Transactional(readOnly = true) diff --git a/backend/src/main/java/wooteco/prolog/studylog/application/ViewedStudyLogCookieGenerator.java b/backend/src/main/java/wooteco/prolog/studylog/application/ViewedStudyLogCookieGenerator.java index 5c653fab1..00c1dbf5f 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/ViewedStudyLogCookieGenerator.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/ViewedStudyLogCookieGenerator.java @@ -1,12 +1,13 @@ package wooteco.prolog.studylog.application; -import java.time.Duration; -import java.time.LocalTime; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletResponse; import org.springframework.http.HttpHeaders; import org.springframework.http.ResponseCookie; import org.springframework.stereotype.Component; +import java.time.Duration; +import java.time.LocalTime; + @Component public class ViewedStudyLogCookieGenerator { diff --git a/backend/src/main/java/wooteco/prolog/studylog/application/dto/CalendarStudylogResponse.java b/backend/src/main/java/wooteco/prolog/studylog/application/dto/CalendarStudylogResponse.java index 3abd9f1ca..f00fdcddf 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/dto/CalendarStudylogResponse.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/dto/CalendarStudylogResponse.java @@ -1,11 +1,12 @@ package wooteco.prolog.studylog.application.dto; -import java.time.LocalDateTime; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import wooteco.prolog.studylog.domain.Studylog; +import java.time.LocalDateTime; + @Getter @AllArgsConstructor @NoArgsConstructor diff --git a/backend/src/main/java/wooteco/prolog/studylog/application/dto/CommentResponse.java b/backend/src/main/java/wooteco/prolog/studylog/application/dto/CommentResponse.java index 64bf00860..e5b2d4515 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/dto/CommentResponse.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/dto/CommentResponse.java @@ -1,12 +1,13 @@ package wooteco.prolog.studylog.application.dto; import com.fasterxml.jackson.annotation.JsonFormat; -import java.time.LocalDateTime; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; import wooteco.prolog.studylog.domain.Comment; +import java.time.LocalDateTime; + @NoArgsConstructor(access = AccessLevel.PROTECTED) @Getter public class CommentResponse { diff --git a/backend/src/main/java/wooteco/prolog/studylog/application/dto/CommentsResponse.java b/backend/src/main/java/wooteco/prolog/studylog/application/dto/CommentsResponse.java index 4c3604e1a..5ca14fdb7 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/dto/CommentsResponse.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/dto/CommentsResponse.java @@ -1,10 +1,11 @@ package wooteco.prolog.studylog.application.dto; -import java.util.List; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; +import java.util.List; + @NoArgsConstructor(access = AccessLevel.PROTECTED) @Getter public class CommentsResponse { diff --git a/backend/src/main/java/wooteco/prolog/studylog/application/dto/EssayAnswersResponse.java b/backend/src/main/java/wooteco/prolog/studylog/application/dto/EssayAnswersResponse.java index 2157e649a..16a260473 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/dto/EssayAnswersResponse.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/dto/EssayAnswersResponse.java @@ -1,9 +1,6 @@ package wooteco.prolog.studylog.application.dto; -import static java.util.stream.Collectors.toList; - -import java.util.List; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; @@ -12,6 +9,10 @@ import wooteco.prolog.roadmap.application.dto.EssayAnswerResponse; import wooteco.prolog.roadmap.domain.EssayAnswer; +import java.util.List; + +import static java.util.stream.Collectors.toList; + @NoArgsConstructor @AllArgsConstructor @Getter diff --git a/backend/src/main/java/wooteco/prolog/studylog/application/dto/FilterResponse.java b/backend/src/main/java/wooteco/prolog/studylog/application/dto/FilterResponse.java index f30528276..e32345139 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/dto/FilterResponse.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/dto/FilterResponse.java @@ -1,12 +1,13 @@ package wooteco.prolog.studylog.application.dto; -import java.util.List; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import wooteco.prolog.session.application.dto.MissionResponse; import wooteco.prolog.session.application.dto.SessionResponse; +import java.util.List; + @NoArgsConstructor @AllArgsConstructor @Getter diff --git a/backend/src/main/java/wooteco/prolog/studylog/application/dto/MemberTagResponse.java b/backend/src/main/java/wooteco/prolog/studylog/application/dto/MemberTagResponse.java index 477e3d14e..f7b2a3bdc 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/dto/MemberTagResponse.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/dto/MemberTagResponse.java @@ -1,14 +1,15 @@ package wooteco.prolog.studylog.application.dto; import com.fasterxml.jackson.annotation.JsonUnwrapped; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import wooteco.prolog.member.domain.MemberTag; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + @Getter @NoArgsConstructor @AllArgsConstructor diff --git a/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogDocumentResponse.java b/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogDocumentResponse.java index 0523f8875..feb358a0c 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogDocumentResponse.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogDocumentResponse.java @@ -1,10 +1,11 @@ package wooteco.prolog.studylog.application.dto; -import java.util.List; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; +import java.util.List; + @NoArgsConstructor @AllArgsConstructor @Getter diff --git a/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogRequest.java b/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogRequest.java index 2c3f1f239..d57a9a407 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogRequest.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogRequest.java @@ -1,10 +1,11 @@ package wooteco.prolog.studylog.application.dto; -import java.util.List; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; +import java.util.List; + @NoArgsConstructor @AllArgsConstructor @Getter diff --git a/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogResponse.java b/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogResponse.java index bbc3349ff..3a97a7300 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogResponse.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogResponse.java @@ -1,9 +1,5 @@ package wooteco.prolog.studylog.application.dto; -import static java.util.stream.Collectors.toList; - -import java.time.LocalDateTime; -import java.util.List; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; @@ -15,6 +11,11 @@ import wooteco.prolog.studylog.domain.Studylog; import wooteco.prolog.studylog.domain.StudylogTag; +import java.time.LocalDateTime; +import java.util.List; + +import static java.util.stream.Collectors.toList; + @NoArgsConstructor @AllArgsConstructor @Getter diff --git a/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogRssFeedResponse.java b/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogRssFeedResponse.java index 23189c896..d7fd77f9f 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogRssFeedResponse.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogRssFeedResponse.java @@ -1,15 +1,16 @@ package wooteco.prolog.studylog.application.dto; -import static java.util.stream.Collectors.toList; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.apache.commons.lang3.StringEscapeUtils; +import wooteco.prolog.studylog.domain.Studylog; import java.time.Instant; import java.time.format.DateTimeFormatter; import java.util.Date; import java.util.List; -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.apache.commons.lang3.StringEscapeUtils; -import wooteco.prolog.studylog.domain.Studylog; + +import static java.util.stream.Collectors.toList; @AllArgsConstructor @Getter diff --git a/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogSearchRequest.java b/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogSearchRequest.java index 340751357..010c3c46d 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogSearchRequest.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogSearchRequest.java @@ -1,9 +1,10 @@ package wooteco.prolog.studylog.application.dto; -import java.time.LocalDate; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDate; + @Data public class StudylogSearchRequest { diff --git a/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogTempResponse.java b/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogTempResponse.java index ae0ba39ec..9625ea36e 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogTempResponse.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogTempResponse.java @@ -1,8 +1,5 @@ package wooteco.prolog.studylog.application.dto; -import static java.util.stream.Collectors.toList; - -import java.util.List; import lombok.Getter; import lombok.NoArgsConstructor; import wooteco.prolog.member.application.dto.MemberResponse; @@ -11,6 +8,10 @@ import wooteco.prolog.studylog.domain.StudylogTemp; import wooteco.prolog.studylog.domain.StudylogTempTags; +import java.util.List; + +import static java.util.stream.Collectors.toList; + @NoArgsConstructor @Getter public class StudylogTempResponse { diff --git a/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogsResponse.java b/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogsResponse.java index 8d4d4b5cb..fdd47aff4 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogsResponse.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogsResponse.java @@ -1,10 +1,5 @@ package wooteco.prolog.studylog.application.dto; -import static java.util.stream.Collectors.toList; - -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; @@ -16,6 +11,12 @@ import wooteco.prolog.studylog.domain.StudylogTag; import wooteco.prolog.studylog.domain.Tag; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import static java.util.stream.Collectors.toList; + @NoArgsConstructor @AllArgsConstructor @Getter diff --git a/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogsWithScrapCountResponse.java b/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogsWithScrapCountResponse.java index c101e1843..0313fb96c 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogsWithScrapCountResponse.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/dto/StudylogsWithScrapCountResponse.java @@ -1,13 +1,14 @@ package wooteco.prolog.studylog.application.dto; -import java.util.List; -import java.util.stream.Collectors; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import org.springframework.data.domain.Page; import wooteco.prolog.studylog.domain.Studylog; +import java.util.List; +import java.util.stream.Collectors; + @NoArgsConstructor @AllArgsConstructor @Getter diff --git a/backend/src/main/java/wooteco/prolog/studylog/application/dto/search/SearchArgumentResolver.java b/backend/src/main/java/wooteco/prolog/studylog/application/dto/search/SearchArgumentResolver.java index 8e6e5e2b0..5ef09b8f8 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/dto/search/SearchArgumentResolver.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/dto/search/SearchArgumentResolver.java @@ -1,13 +1,5 @@ package wooteco.prolog.studylog.application.dto.search; -import static java.util.stream.Collectors.toList; - -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Objects; import org.springframework.core.MethodParameter; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -20,6 +12,15 @@ import wooteco.prolog.common.exception.BadRequestCode; import wooteco.prolog.common.exception.BadRequestException; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +import static java.util.stream.Collectors.toList; + @Component public class SearchArgumentResolver implements HandlerMethodArgumentResolver { diff --git a/backend/src/main/java/wooteco/prolog/studylog/application/dto/search/StudylogsSearchRequest.java b/backend/src/main/java/wooteco/prolog/studylog/application/dto/search/StudylogsSearchRequest.java index d834398b0..0d7653a9a 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/dto/search/StudylogsSearchRequest.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/dto/search/StudylogsSearchRequest.java @@ -1,11 +1,12 @@ package wooteco.prolog.studylog.application.dto.search; -import java.time.LocalDate; -import java.util.List; import lombok.AllArgsConstructor; import lombok.Getter; import org.springframework.data.domain.Pageable; +import java.time.LocalDate; +import java.util.List; + @AllArgsConstructor @Getter public class StudylogsSearchRequest { diff --git a/backend/src/main/java/wooteco/prolog/studylog/domain/Comment.java b/backend/src/main/java/wooteco/prolog/studylog/domain/Comment.java index 34d84ca7e..27cfdfab9 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/Comment.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/Comment.java @@ -1,16 +1,13 @@ package wooteco.prolog.studylog.domain; -import static wooteco.prolog.common.exception.BadRequestCode.COMMENT_DELETE_EXCEPTION; - -import java.util.Objects; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -18,6 +15,10 @@ import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.member.domain.Member; +import java.util.Objects; + +import static wooteco.prolog.common.exception.BadRequestCode.COMMENT_DELETE_EXCEPTION; + @Entity @NoArgsConstructor(access = AccessLevel.PROTECTED) @Getter diff --git a/backend/src/main/java/wooteco/prolog/studylog/domain/Content.java b/backend/src/main/java/wooteco/prolog/studylog/domain/Content.java index 3f6981e55..44f098b5a 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/Content.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/Content.java @@ -1,11 +1,8 @@ package wooteco.prolog.studylog.domain; -import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_CONTENT_NULL_OR_EMPTY; - -import java.util.Objects; -import javax.persistence.Column; -import javax.persistence.Embeddable; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; import lombok.AccessLevel; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -13,6 +10,10 @@ import lombok.ToString; import wooteco.prolog.common.exception.BadRequestException; +import java.util.Objects; + +import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_CONTENT_NULL_OR_EMPTY; + @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @EqualsAndHashCode diff --git a/backend/src/main/java/wooteco/prolog/studylog/domain/Like.java b/backend/src/main/java/wooteco/prolog/studylog/domain/Like.java index ede40d709..14e2d7c1f 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/Like.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/Like.java @@ -1,18 +1,19 @@ package wooteco.prolog.studylog.domain; -import java.util.Objects; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; import lombok.AccessLevel; import lombok.NoArgsConstructor; import org.hibernate.annotations.BatchSize; +import java.util.Objects; + @NoArgsConstructor(access = AccessLevel.PROTECTED) @Table(name = "LIKES") @Entity diff --git a/backend/src/main/java/wooteco/prolog/studylog/domain/Likes.java b/backend/src/main/java/wooteco/prolog/studylog/domain/Likes.java index fbc25ad01..ec30bac93 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/Likes.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/Likes.java @@ -1,14 +1,15 @@ package wooteco.prolog.studylog.domain; -import static wooteco.prolog.common.exception.BadRequestCode.INVALID_LIKE_REQUEST_EXCEPTION; -import static wooteco.prolog.common.exception.BadRequestCode.INVALID_UNLIKE_REQUEST_EXCEPTION; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Embeddable; +import jakarta.persistence.OneToMany; +import wooteco.prolog.common.exception.BadRequestException; import java.util.ArrayList; import java.util.List; -import javax.persistence.CascadeType; -import javax.persistence.Embeddable; -import javax.persistence.OneToMany; -import wooteco.prolog.common.exception.BadRequestException; + +import static wooteco.prolog.common.exception.BadRequestCode.INVALID_LIKE_REQUEST_EXCEPTION; +import static wooteco.prolog.common.exception.BadRequestCode.INVALID_UNLIKE_REQUEST_EXCEPTION; @Embeddable public class Likes { diff --git a/backend/src/main/java/wooteco/prolog/studylog/domain/PopularStudylog.java b/backend/src/main/java/wooteco/prolog/studylog/domain/PopularStudylog.java index 48cfe2b12..8f284e481 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/PopularStudylog.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/PopularStudylog.java @@ -1,10 +1,10 @@ package wooteco.prolog.studylog.domain; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/backend/src/main/java/wooteco/prolog/studylog/domain/Studylog.java b/backend/src/main/java/wooteco/prolog/studylog/domain/Studylog.java index 1aa422bec..a788c0c8e 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/Studylog.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/Studylog.java @@ -1,15 +1,13 @@ package wooteco.prolog.studylog.domain; -import java.util.List; -import java.util.stream.Collectors; -import javax.persistence.Embedded; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -20,6 +18,9 @@ import wooteco.prolog.session.domain.Mission; import wooteco.prolog.session.domain.Session; +import java.util.List; +import java.util.stream.Collectors; + @Entity @NoArgsConstructor(access = AccessLevel.PROTECTED) @Getter diff --git a/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogDocument.java b/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogDocument.java index 526d41ab3..e35453785 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogDocument.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogDocument.java @@ -1,46 +1,34 @@ package wooteco.prolog.studylog.domain; -import java.time.LocalDateTime; -import java.util.List; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; -import org.springframework.data.elasticsearch.annotations.DateFormat; -import org.springframework.data.elasticsearch.annotations.Document; -import org.springframework.data.elasticsearch.annotations.Field; -import org.springframework.data.elasticsearch.annotations.FieldType; + +import java.time.LocalDateTime; +import java.util.List; @Getter @EqualsAndHashCode @NoArgsConstructor @Builder @AllArgsConstructor -@Document(indexName = "studylog-document") public class StudylogDocument { - @Field(type = FieldType.Long) private Long id; - @Field(type = FieldType.Text) private String title; - @Field(type = FieldType.Text) private String content; - @Field(type = FieldType.Auto) private List tagIds; - @Field(type = FieldType.Long) private Long missionId; - @Field(type = FieldType.Long) private Long levelId; - @Field(type = FieldType.Text) private String username; - @Field(type = FieldType.Date, format = DateFormat.date_optional_time) private LocalDateTime dateTime; } diff --git a/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogDocumentQueryBuilder.java b/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogDocumentQueryBuilder.java deleted file mode 100644 index 6358bcdff..000000000 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogDocumentQueryBuilder.java +++ /dev/null @@ -1,103 +0,0 @@ -package wooteco.prolog.studylog.domain; - -import static wooteco.prolog.studylog.domain.DocumentQueryParser.makeDefaultQueryString; -import static wooteco.prolog.studylog.domain.DocumentQueryParser.makeKeywordsQueryString; -import static wooteco.prolog.studylog.domain.DocumentQueryParser.removeSpecialChars; - -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.index.query.QueryStringQueryBuilder; -import org.elasticsearch.index.query.RangeQueryBuilder; -import org.springframework.data.domain.Pageable; -import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; -import org.springframework.data.elasticsearch.core.query.Query; - -public class StudylogDocumentQueryBuilder { - - private StudylogDocumentQueryBuilder() { - } - - public static Query makeQuery(List inputKeywords, - List tags, - List missions, - List levels, - List usernames, - LocalDate start, - LocalDate end, - Pageable pageable - ) { - - List keywords = removeSpecialChars(inputKeywords); - NativeSearchQueryBuilder query = new NativeSearchQueryBuilder(); - makeBoolQuery(query, - makeKeywordsQueryString(keywords), - makeDefaultQueryString(usernames), - makeDefaultQueryString(convertToListString(levels)), - makeDefaultQueryString(convertToListString(missions)), - start, - end); - makeFilterQuery(query, tags); - - return query - .withPageable(pageable) - .build(); - } - - private static List convertToListString(List values) { - return values.stream() - .map(String::valueOf) - .collect(Collectors.toList()); - } - - private static void makeBoolQuery( - NativeSearchQueryBuilder query, - String keyword, - String username, - String levels, - String missions, - LocalDate start, - LocalDate end) { - query.withQuery(QueryBuilders.boolQuery() - .must(multiField(keyword)) - .must(defaultField(username, "username")) -// .must(defaultField(levels, "levelId")) -// .must(defaultField(missions, "missionId")) -// .filter(rangeQuery(start, end)) - ); - } - - private static QueryStringQueryBuilder multiField(String keyword) { - return QueryBuilders.queryStringQuery(keyword) - .field("title") - .field("content"); - } - - private static QueryStringQueryBuilder defaultField(String query, String field) { - return QueryBuilders - .queryStringQuery(query) - .defaultField(field); - } - - private static void makeFilterQuery(NativeSearchQueryBuilder query, List tags) { - if (Objects.isNull(tags) || tags.isEmpty()) { - return; - } - query.withFilter(QueryBuilders.termsQuery("tagIds", tags)); - } - - private static RangeQueryBuilder rangeQuery(LocalDate start, LocalDate end) { - if (Objects.isNull(start)) { - start = LocalDate.parse("19000101", DateTimeFormatter.BASIC_ISO_DATE); - } - if (Objects.isNull(end)) { - end = LocalDate.parse("99991231", DateTimeFormatter.BASIC_ISO_DATE); - } - return QueryBuilders.rangeQuery("dateTime") - .from(start) - .to(end); - } -} diff --git a/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogRead.java b/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogRead.java index aa3110fd1..a0f3c2323 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogRead.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogRead.java @@ -1,12 +1,12 @@ package wooteco.prolog.studylog.domain; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogScrap.java b/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogScrap.java index 8fe4024a8..fcc492472 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogScrap.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogScrap.java @@ -1,18 +1,19 @@ package wooteco.prolog.studylog.domain; -import java.util.Objects; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; import wooteco.prolog.member.domain.Member; +import java.util.Objects; + @Entity @NoArgsConstructor(access = AccessLevel.PROTECTED) @Getter @@ -45,10 +46,9 @@ public boolean equals(Object o) { if (this == o) { return true; } - if (!(o instanceof StudylogScrap)) { + if (!(o instanceof StudylogScrap studylogScrap)) { return false; } - StudylogScrap studylogScrap = (StudylogScrap) o; return Objects.equals(member.getId(), studylogScrap.member.getId()) && Objects.equals(studylog.getId(), studylogScrap.getStudylog().getId()); } diff --git a/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogTag.java b/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogTag.java index 4636a7b82..bd0271169 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogTag.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogTag.java @@ -1,17 +1,18 @@ package wooteco.prolog.studylog.domain; -import java.util.Objects; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; +import java.util.Objects; + @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @Entity @@ -48,10 +49,9 @@ public boolean equals(Object o) { if (this == o) { return true; } - if (!(o instanceof StudylogTag)) { + if (!(o instanceof StudylogTag studylogTag)) { return false; } - StudylogTag studylogTag = (StudylogTag) o; return Objects.equals(id, studylogTag.id); } diff --git a/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogTags.java b/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogTags.java index af63f9a33..1490833be 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogTags.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogTags.java @@ -1,16 +1,17 @@ package wooteco.prolog.studylog.domain; -import static java.util.stream.Collectors.groupingBy; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Embeddable; +import jakarta.persistence.OneToMany; +import lombok.Getter; +import org.hibernate.annotations.BatchSize; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.stream.Collectors; -import javax.persistence.CascadeType; -import javax.persistence.Embeddable; -import javax.persistence.OneToMany; -import lombok.Getter; -import org.hibernate.annotations.BatchSize; + +import static java.util.stream.Collectors.groupingBy; @Getter @Embeddable diff --git a/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogTemp.java b/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogTemp.java index 4491da412..01c2e151f 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogTemp.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogTemp.java @@ -1,16 +1,13 @@ package wooteco.prolog.studylog.domain; -import static java.util.stream.Collectors.toList; - -import java.util.List; -import javax.persistence.Embedded; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -18,6 +15,10 @@ import wooteco.prolog.session.domain.Mission; import wooteco.prolog.session.domain.Session; +import java.util.List; + +import static java.util.stream.Collectors.toList; + @Entity @NoArgsConstructor(access = AccessLevel.PROTECTED) @Getter diff --git a/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogTempTag.java b/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogTempTag.java index be5f1098e..ffe925193 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogTempTag.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogTempTag.java @@ -1,17 +1,18 @@ package wooteco.prolog.studylog.domain; -import java.util.Objects; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; +import java.util.Objects; + @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @Entity @@ -48,10 +49,9 @@ public boolean equals(Object o) { if (this == o) { return true; } - if (!(o instanceof StudylogTempTag)) { + if (!(o instanceof StudylogTempTag studylogTempTag)) { return false; } - StudylogTempTag studylogTempTag = (StudylogTempTag) o; return Objects.equals(id, studylogTempTag.id); } diff --git a/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogTempTags.java b/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogTempTags.java index 2a79b29de..9b6b74574 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogTempTags.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogTempTags.java @@ -1,13 +1,14 @@ package wooteco.prolog.studylog.domain; -import java.util.ArrayList; -import java.util.List; -import javax.persistence.CascadeType; -import javax.persistence.Embeddable; -import javax.persistence.OneToMany; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Embeddable; +import jakarta.persistence.OneToMany; import lombok.Getter; import org.hibernate.annotations.BatchSize; +import java.util.ArrayList; +import java.util.List; + @Getter @Embeddable public class StudylogTempTags { diff --git a/backend/src/main/java/wooteco/prolog/studylog/domain/Tag.java b/backend/src/main/java/wooteco/prolog/studylog/domain/Tag.java index 1b0266e47..e359e3dab 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/Tag.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/Tag.java @@ -1,15 +1,16 @@ package wooteco.prolog.studylog.domain; -import java.util.Objects; -import javax.persistence.Embedded; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; import lombok.AccessLevel; import lombok.NoArgsConstructor; import org.hibernate.annotations.BatchSize; +import java.util.Objects; + @NoArgsConstructor(access = AccessLevel.PROTECTED) @Entity @BatchSize(size = 1000) @@ -52,10 +53,9 @@ public boolean equals(Object o) { if (this == o) { return true; } - if (!(o instanceof Tag)) { + if (!(o instanceof Tag tag)) { return false; } - Tag tag = (Tag) o; return Objects.equals(id, tag.id); } diff --git a/backend/src/main/java/wooteco/prolog/studylog/domain/TagName.java b/backend/src/main/java/wooteco/prolog/studylog/domain/TagName.java index 304aae426..adb645a13 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/TagName.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/TagName.java @@ -1,16 +1,17 @@ package wooteco.prolog.studylog.domain; -import static wooteco.prolog.common.exception.BadRequestCode.TAG_NAME_NULL_OR_EMPTY; -import static wooteco.prolog.common.exception.BadRequestCode.TOO_LONG_TAG_NAME; - -import java.util.Objects; -import javax.persistence.Column; -import javax.persistence.Embeddable; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; import lombok.AccessLevel; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import wooteco.prolog.common.exception.BadRequestException; +import java.util.Objects; + +import static wooteco.prolog.common.exception.BadRequestCode.TAG_NAME_NULL_OR_EMPTY; +import static wooteco.prolog.common.exception.BadRequestCode.TOO_LONG_TAG_NAME; + @EqualsAndHashCode @NoArgsConstructor(access = AccessLevel.PROTECTED) @Embeddable diff --git a/backend/src/main/java/wooteco/prolog/studylog/domain/Tags.java b/backend/src/main/java/wooteco/prolog/studylog/domain/Tags.java index cd71ad6b3..91f535fdf 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/Tags.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/Tags.java @@ -1,15 +1,16 @@ package wooteco.prolog.studylog.domain; -import static java.util.stream.Collectors.collectingAndThen; -import static java.util.stream.Collectors.toList; -import static wooteco.prolog.common.exception.BadRequestCode.DUPLICATE_TAG; +import wooteco.prolog.common.exception.BadRequestException; +import wooteco.prolog.member.domain.Member; +import wooteco.prolog.member.domain.MemberTag; import java.util.HashSet; import java.util.List; import java.util.Set; -import wooteco.prolog.common.exception.BadRequestException; -import wooteco.prolog.member.domain.Member; -import wooteco.prolog.member.domain.MemberTag; + +import static java.util.stream.Collectors.collectingAndThen; +import static java.util.stream.Collectors.toList; +import static wooteco.prolog.common.exception.BadRequestCode.DUPLICATE_TAG; public class Tags { diff --git a/backend/src/main/java/wooteco/prolog/studylog/domain/Title.java b/backend/src/main/java/wooteco/prolog/studylog/domain/Title.java index 30b95b5c8..ff7db729d 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/Title.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/Title.java @@ -1,11 +1,7 @@ package wooteco.prolog.studylog.domain; -import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_TITLE_NULL_OR_EMPTY; -import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_TITLE_TOO_LONG; - -import java.util.Objects; -import javax.persistence.Column; -import javax.persistence.Embeddable; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; import lombok.AccessLevel; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -13,6 +9,11 @@ import lombok.ToString; import wooteco.prolog.common.exception.BadRequestException; +import java.util.Objects; + +import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_TITLE_NULL_OR_EMPTY; +import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_TITLE_TOO_LONG; + @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @EqualsAndHashCode diff --git a/backend/src/main/java/wooteco/prolog/studylog/domain/ViewCount.java b/backend/src/main/java/wooteco/prolog/studylog/domain/ViewCount.java index 25276800a..886c59221 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/ViewCount.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/ViewCount.java @@ -1,6 +1,6 @@ package wooteco.prolog.studylog.domain; -import javax.persistence.Embeddable; +import jakarta.persistence.Embeddable; import lombok.AccessLevel; import lombok.EqualsAndHashCode; import lombok.Getter; diff --git a/backend/src/main/java/wooteco/prolog/studylog/domain/repository/BadgeRepository.java b/backend/src/main/java/wooteco/prolog/studylog/domain/repository/BadgeRepository.java index ba7820fa2..a21095b78 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/repository/BadgeRepository.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/repository/BadgeRepository.java @@ -1,14 +1,15 @@ package wooteco.prolog.studylog.domain.repository; -import java.util.HashMap; -import java.util.List; -import java.util.Map; import org.springframework.jdbc.core.ResultSetExtractor; import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; import org.springframework.jdbc.core.namedparam.SqlParameterSource; import org.springframework.stereotype.Repository; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + @Repository public class BadgeRepository { diff --git a/backend/src/main/java/wooteco/prolog/studylog/domain/repository/CommentRepository.java b/backend/src/main/java/wooteco/prolog/studylog/domain/repository/CommentRepository.java index 498c00d7c..66bdf91c2 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/repository/CommentRepository.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/repository/CommentRepository.java @@ -1,6 +1,5 @@ package wooteco.prolog.studylog.domain.repository; -import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; @@ -8,6 +7,8 @@ import wooteco.prolog.studylog.domain.Studylog; import wooteco.prolog.studylog.domain.repository.dto.CommentCount; +import java.util.List; + public interface CommentRepository extends JpaRepository { @Query("SELECT c FROM Comment c" diff --git a/backend/src/main/java/wooteco/prolog/studylog/domain/repository/FakeStudylogDocumentRepository.java b/backend/src/main/java/wooteco/prolog/studylog/domain/repository/FakeStudylogDocumentRepository.java deleted file mode 100644 index a96a23c98..000000000 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/repository/FakeStudylogDocumentRepository.java +++ /dev/null @@ -1,138 +0,0 @@ -package wooteco.prolog.studylog.domain.repository; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.Optional; -import java.util.stream.Collectors; -import java.util.stream.StreamSupport; -import org.elasticsearch.index.query.QueryBuilder; -import org.springframework.context.annotation.Profile; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.data.elasticsearch.core.query.Query; -import org.springframework.stereotype.Repository; -import wooteco.prolog.studylog.domain.StudylogDocument; -import wooteco.support.fake.FakeDocumentRepository; - -@Profile({"local", "test"}) -@Repository -public class FakeStudylogDocumentRepository implements StudylogDocumentRepository, - FakeDocumentRepository { - - private static final List STUDYLOG_DOCUMENTS = new ArrayList<>(); - - @Override - public S save(S studylogDocument) { - Optional document = findById(studylogDocument.getId()); - document.ifPresent(STUDYLOG_DOCUMENTS::remove); - STUDYLOG_DOCUMENTS.add(studylogDocument); - return studylogDocument; - } - - @Override - public void delete(StudylogDocument studylogDocument) { - STUDYLOG_DOCUMENTS.remove(studylogDocument); - } - - @Override - public void deleteAll(Iterable entities) { - List idsForRemoving = StreamSupport.stream(entities.spliterator(), false) - .map(it -> it.getId()) - .collect(Collectors.toList()); - - STUDYLOG_DOCUMENTS.removeIf(it -> idsForRemoving.contains(it)); - } - - @Override - public void deleteAll() { - STUDYLOG_DOCUMENTS.clear(); - } - - @Override - public Iterable saveAll(Iterable inputStudylogDocuments) { - List studylogDocumentsWithId = new ArrayList<>(); - for (StudylogDocument studylogDocument : inputStudylogDocuments) { - STUDYLOG_DOCUMENTS.add(studylogDocument); - STUDYLOG_DOCUMENTS.add(studylogDocument); - } - return (Iterable) studylogDocumentsWithId; - } - - @Override - public Optional findById(Long id) { - for (StudylogDocument studylogDocument : STUDYLOG_DOCUMENTS) { - if (Objects.equals(studylogDocument.getId(), id)) { - return Optional.of(studylogDocument); - } - } - return Optional.empty(); - } - - @Override - public boolean existsById(Long aLong) { - return false; - } - - @Override - public Iterable findAll() { - return null; - } - - @Override - public Iterable findAllById(Iterable longs) { - return null; - } - - @Override - public long count() { - return 0; - } - - @Override - public void deleteById(Long aLong) { - - } - - @Override - public S indexWithoutRefresh(S entity) { - return null; - } - - @Override - public Iterable search(QueryBuilder query) { - return null; - } - - @Override - public Page search(QueryBuilder query, Pageable pageable) { - return null; - } - - @Override - public Page search(Query searchQuery) { - return null; - } - - @Override - public Page searchSimilar(StudylogDocument entity, String[] fields, - Pageable pageable) { - return null; - } - - @Override - public void refresh() { - - } - - @Override - public Iterable findAll(Sort sort) { - return null; - } - - @Override - public Page findAll(Pageable pageable) { - return null; - } -} diff --git a/backend/src/main/java/wooteco/prolog/studylog/domain/repository/PopularStudylogRepository.java b/backend/src/main/java/wooteco/prolog/studylog/domain/repository/PopularStudylogRepository.java index 012397da9..ec7662fbe 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/repository/PopularStudylogRepository.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/repository/PopularStudylogRepository.java @@ -1,9 +1,10 @@ package wooteco.prolog.studylog.domain.repository; -import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import wooteco.prolog.studylog.domain.PopularStudylog; +import java.util.List; + public interface PopularStudylogRepository extends JpaRepository { List findAllByDeletedFalse(); diff --git a/backend/src/main/java/wooteco/prolog/studylog/domain/repository/StudylogDocumentRepository.java b/backend/src/main/java/wooteco/prolog/studylog/domain/repository/StudylogDocumentRepository.java deleted file mode 100644 index 6ca09173e..000000000 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/repository/StudylogDocumentRepository.java +++ /dev/null @@ -1,11 +0,0 @@ -package wooteco.prolog.studylog.domain.repository; - -import org.springframework.context.annotation.Profile; -import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; -import wooteco.prolog.studylog.domain.StudylogDocument; - -@Profile({"dev", "prod"}) -public interface StudylogDocumentRepository extends - ElasticsearchRepository { - -} diff --git a/backend/src/main/java/wooteco/prolog/studylog/domain/repository/StudylogReadRepository.java b/backend/src/main/java/wooteco/prolog/studylog/domain/repository/StudylogReadRepository.java index b6cb1fefc..7603389ec 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/repository/StudylogReadRepository.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/repository/StudylogReadRepository.java @@ -1,10 +1,11 @@ package wooteco.prolog.studylog.domain.repository; -import java.util.List; -import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import wooteco.prolog.studylog.domain.StudylogRead; +import java.util.List; +import java.util.Optional; + public interface StudylogReadRepository extends JpaRepository { boolean existsByMemberIdAndStudylogId(Long memberId, Long studylogId); diff --git a/backend/src/main/java/wooteco/prolog/studylog/domain/repository/StudylogRepository.java b/backend/src/main/java/wooteco/prolog/studylog/domain/repository/StudylogRepository.java index f2628a7eb..d459f0ed7 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/repository/StudylogRepository.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/repository/StudylogRepository.java @@ -1,7 +1,5 @@ package wooteco.prolog.studylog.domain.repository; -import java.time.LocalDateTime; -import java.util.List; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; @@ -10,6 +8,9 @@ import wooteco.prolog.member.domain.Member; import wooteco.prolog.studylog.domain.Studylog; +import java.time.LocalDateTime; +import java.util.List; + public interface StudylogRepository extends JpaRepository, JpaSpecificationExecutor { diff --git a/backend/src/main/java/wooteco/prolog/studylog/domain/repository/StudylogScrapRepository.java b/backend/src/main/java/wooteco/prolog/studylog/domain/repository/StudylogScrapRepository.java index 36feede90..58f7178ef 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/repository/StudylogScrapRepository.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/repository/StudylogScrapRepository.java @@ -1,13 +1,14 @@ package wooteco.prolog.studylog.domain.repository; -import java.util.List; -import java.util.Optional; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import wooteco.prolog.studylog.domain.StudylogScrap; +import java.util.List; +import java.util.Optional; + public interface StudylogScrapRepository extends JpaRepository { @Query("select count(ms) from StudylogScrap ms where ms.member.id = :memberId and ms.studylog.id = :studylogId") diff --git a/backend/src/main/java/wooteco/prolog/studylog/domain/repository/StudylogSpecification.java b/backend/src/main/java/wooteco/prolog/studylog/domain/repository/StudylogSpecification.java index 1078b6508..8b8238d7a 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/repository/StudylogSpecification.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/repository/StudylogSpecification.java @@ -1,14 +1,15 @@ package wooteco.prolog.studylog.domain.repository; +import jakarta.persistence.criteria.JoinType; +import jakarta.persistence.criteria.Predicate; +import org.springframework.data.jpa.domain.Specification; +import wooteco.prolog.studylog.domain.Studylog; + import java.time.LocalDate; import java.time.LocalTime; import java.util.ArrayList; import java.util.List; import java.util.Objects; -import javax.persistence.criteria.JoinType; -import javax.persistence.criteria.Predicate; -import org.springframework.data.jpa.domain.Specification; -import wooteco.prolog.studylog.domain.Studylog; public class StudylogSpecification { @@ -37,17 +38,7 @@ public static Specification equalIn(String key, List values) { return builder.and(); } - return root.get(key).in(values); - }; - } - - public static Specification equalIn(String key, List values, boolean isSearch) { - return (root, query, builder) -> { - if (!isSearch && (values == null || values.isEmpty())) { - return builder.and(); - } - - return root.get(key).in(values); + return root.get(key).get("id").in(values); }; } @@ -57,7 +48,7 @@ public static Specification findByTagIn(List values) { return builder.and(); } - return root.join("studylogTags", JoinType.LEFT).join("values", JoinType.LEFT).get("tag") + return root.join("studylogTags", JoinType.LEFT).join("values", JoinType.LEFT).get("tag").get("id") .in(values); }; } diff --git a/backend/src/main/java/wooteco/prolog/studylog/domain/repository/StudylogTagRepository.java b/backend/src/main/java/wooteco/prolog/studylog/domain/repository/StudylogTagRepository.java index bdb978a6a..f1127c58a 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/repository/StudylogTagRepository.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/repository/StudylogTagRepository.java @@ -1,11 +1,12 @@ package wooteco.prolog.studylog.domain.repository; -import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import wooteco.prolog.studylog.domain.StudylogTag; import wooteco.prolog.studylog.domain.Tag; +import java.util.List; + public interface StudylogTagRepository extends JpaRepository { List findByTagIn(List tags); diff --git a/backend/src/main/java/wooteco/prolog/studylog/domain/repository/TagRepository.java b/backend/src/main/java/wooteco/prolog/studylog/domain/repository/TagRepository.java index 9cb05e206..04553a07d 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/repository/TagRepository.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/repository/TagRepository.java @@ -1,12 +1,13 @@ package wooteco.prolog.studylog.domain.repository; -import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import wooteco.prolog.member.domain.Member; import wooteco.prolog.studylog.domain.Studylog; import wooteco.prolog.studylog.domain.Tag; +import java.util.List; + public interface TagRepository extends JpaRepository { List findByNameValueIn(List name); diff --git a/backend/src/main/java/wooteco/prolog/studylog/ui/CommentController.java b/backend/src/main/java/wooteco/prolog/studylog/ui/CommentController.java index c95146a8b..5874fa999 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/ui/CommentController.java +++ b/backend/src/main/java/wooteco/prolog/studylog/ui/CommentController.java @@ -1,6 +1,5 @@ package wooteco.prolog.studylog.ui; -import java.net.URI; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; @@ -18,6 +17,8 @@ import wooteco.prolog.studylog.application.dto.CommentCreateRequest; import wooteco.prolog.studylog.application.dto.CommentsResponse; +import java.net.URI; + @RestController @RequestMapping("/studylogs") public class CommentController { diff --git a/backend/src/main/java/wooteco/prolog/studylog/ui/PostController.java b/backend/src/main/java/wooteco/prolog/studylog/ui/PostController.java index b44dbac0a..a8895816a 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/ui/PostController.java +++ b/backend/src/main/java/wooteco/prolog/studylog/ui/PostController.java @@ -1,9 +1,5 @@ package wooteco.prolog.studylog.ui; -import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_NOT_FOUND; - -import java.net.URI; -import java.util.List; import org.apache.commons.lang3.StringUtils; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; @@ -25,6 +21,11 @@ import wooteco.prolog.studylog.application.dto.search.SearchParams; import wooteco.prolog.studylog.application.dto.search.StudylogsSearchRequest; +import java.net.URI; +import java.util.List; + +import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_NOT_FOUND; + @Deprecated @RestController @RequestMapping("/posts") diff --git a/backend/src/main/java/wooteco/prolog/studylog/ui/ProfileStudylogController.java b/backend/src/main/java/wooteco/prolog/studylog/ui/ProfileStudylogController.java index e5f40d6a9..5a6e1cff0 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/ui/ProfileStudylogController.java +++ b/backend/src/main/java/wooteco/prolog/studylog/ui/ProfileStudylogController.java @@ -1,9 +1,5 @@ package wooteco.prolog.studylog.ui; -import java.time.LocalDate; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; import lombok.AllArgsConstructor; import lombok.Data; import org.springframework.data.domain.Pageable; @@ -20,13 +16,17 @@ import wooteco.prolog.login.domain.AuthMemberPrincipal; import wooteco.prolog.login.ui.LoginMember; import wooteco.prolog.member.application.MemberService; -import wooteco.prolog.member.application.dto.MemberResponse; import wooteco.prolog.member.application.dto.ProfileIntroRequest; import wooteco.prolog.member.application.dto.ProfileIntroResponse; import wooteco.prolog.member.application.dto.ProfileResponse; import wooteco.prolog.studylog.application.StudylogService; import wooteco.prolog.studylog.application.dto.StudylogsResponse; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + @RestController @AllArgsConstructor @RequestMapping("/members") diff --git a/backend/src/main/java/wooteco/prolog/studylog/ui/StudylogController.java b/backend/src/main/java/wooteco/prolog/studylog/ui/StudylogController.java index d0e4d3e9b..53dab3aff 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/ui/StudylogController.java +++ b/backend/src/main/java/wooteco/prolog/studylog/ui/StudylogController.java @@ -1,9 +1,6 @@ package wooteco.prolog.studylog.ui; -import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_NOT_FOUND; - -import java.net.URI; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletResponse; import org.apache.commons.lang3.StringUtils; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.CookieValue; @@ -28,6 +25,10 @@ import wooteco.prolog.studylog.application.dto.search.SearchParams; import wooteco.prolog.studylog.application.dto.search.StudylogsSearchRequest; +import java.net.URI; + +import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_NOT_FOUND; + @RestController @RequestMapping("/studylogs") public class StudylogController { diff --git a/backend/src/main/java/wooteco/prolog/studylog/ui/StudylogOverviewController.java b/backend/src/main/java/wooteco/prolog/studylog/ui/StudylogOverviewController.java index 70d6e4765..8997046b4 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/ui/StudylogOverviewController.java +++ b/backend/src/main/java/wooteco/prolog/studylog/ui/StudylogOverviewController.java @@ -1,8 +1,5 @@ package wooteco.prolog.studylog.ui; -import java.time.LocalDate; -import java.time.Month; -import java.util.List; import lombok.AllArgsConstructor; import lombok.Data; import lombok.Getter; @@ -18,6 +15,10 @@ import wooteco.prolog.studylog.application.dto.CalendarStudylogResponse; import wooteco.prolog.studylog.application.dto.MemberTagResponse; +import java.time.LocalDate; +import java.time.Month; +import java.util.List; + @RestController @RequestMapping("/members") @RequiredArgsConstructor diff --git a/backend/src/main/java/wooteco/prolog/studylog/ui/StudylogRssFeedController.java b/backend/src/main/java/wooteco/prolog/studylog/ui/StudylogRssFeedController.java index 479e35f37..3d887d70f 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/ui/StudylogRssFeedController.java +++ b/backend/src/main/java/wooteco/prolog/studylog/ui/StudylogRssFeedController.java @@ -1,6 +1,5 @@ package wooteco.prolog.studylog.ui; -import java.util.List; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; @@ -10,6 +9,8 @@ import wooteco.prolog.studylog.application.StudylogService; import wooteco.prolog.studylog.application.dto.StudylogRssFeedResponse; +import java.util.List; + @Controller @RequestMapping("/rss") public class StudylogRssFeedController { diff --git a/backend/src/main/java/wooteco/prolog/studylog/ui/StudylogRssFeedView.java b/backend/src/main/java/wooteco/prolog/studylog/ui/StudylogRssFeedView.java index 1cad40aa5..093f114c5 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/ui/StudylogRssFeedView.java +++ b/backend/src/main/java/wooteco/prolog/studylog/ui/StudylogRssFeedView.java @@ -1,19 +1,20 @@ package wooteco.prolog.studylog.ui; -import static java.util.stream.Collectors.toList; - import com.rometools.rome.feed.rss.Channel; import com.rometools.rome.feed.rss.Description; import com.rometools.rome.feed.rss.Item; -import java.util.List; -import java.util.Map; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import org.springframework.web.servlet.view.feed.AbstractRssFeedView; import wooteco.prolog.studylog.application.dto.StudylogRssFeedResponse; +import java.util.List; +import java.util.Map; + +import static java.util.stream.Collectors.toList; + @Component public class StudylogRssFeedView extends AbstractRssFeedView { diff --git a/backend/src/main/java/wooteco/prolog/studylog/ui/TagController.java b/backend/src/main/java/wooteco/prolog/studylog/ui/TagController.java index 6210b55a7..337569209 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/ui/TagController.java +++ b/backend/src/main/java/wooteco/prolog/studylog/ui/TagController.java @@ -1,6 +1,5 @@ package wooteco.prolog.studylog.ui; -import java.util.List; import lombok.AllArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; @@ -9,6 +8,8 @@ import wooteco.prolog.studylog.application.StudylogTagService; import wooteco.prolog.studylog.application.dto.TagResponse; +import java.util.List; + @RestController @RequestMapping("/tags") @AllArgsConstructor diff --git a/backend/src/main/java/wooteco/support/autoceptor/AuthenticationDetector.java b/backend/src/main/java/wooteco/support/autoceptor/AuthenticationDetector.java index 710a8e15c..fdc042e4c 100644 --- a/backend/src/main/java/wooteco/support/autoceptor/AuthenticationDetector.java +++ b/backend/src/main/java/wooteco/support/autoceptor/AuthenticationDetector.java @@ -1,12 +1,13 @@ package wooteco.support.autoceptor; -import java.util.List; -import java.util.Objects; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpMethod; +import java.util.List; +import java.util.Objects; + @RequiredArgsConstructor public class AuthenticationDetector { diff --git a/backend/src/main/java/wooteco/support/autoceptor/AutoInterceptorPatternMaker.java b/backend/src/main/java/wooteco/support/autoceptor/AutoInterceptorPatternMaker.java index d984a149a..86bcad30d 100644 --- a/backend/src/main/java/wooteco/support/autoceptor/AutoInterceptorPatternMaker.java +++ b/backend/src/main/java/wooteco/support/autoceptor/AutoInterceptorPatternMaker.java @@ -1,14 +1,15 @@ package wooteco.support.autoceptor; -import java.lang.annotation.Annotation; -import java.util.Arrays; -import java.util.List; -import java.util.Set; import wooteco.support.autoceptor.scanner.ClassScanner; import wooteco.support.autoceptor.scanner.ControllerScanner; import wooteco.support.autoceptor.scanner.MethodScanner; import wooteco.support.autoceptor.scanner.URIScanner; +import java.lang.annotation.Annotation; +import java.util.Arrays; +import java.util.List; +import java.util.Set; + public class AutoInterceptorPatternMaker { private final URIScanner uriScanner; diff --git a/backend/src/main/java/wooteco/support/autoceptor/MethodPattern.java b/backend/src/main/java/wooteco/support/autoceptor/MethodPattern.java index 1c336abf6..116487bce 100644 --- a/backend/src/main/java/wooteco/support/autoceptor/MethodPattern.java +++ b/backend/src/main/java/wooteco/support/autoceptor/MethodPattern.java @@ -1,9 +1,10 @@ package wooteco.support.autoceptor; -import java.util.regex.Pattern; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import org.springframework.http.HttpMethod; +import java.util.regex.Pattern; + public class MethodPattern { private static final String INVALID_METHOD_PATTERN_MESSAGE = "uri 와 method 가 지정되지 않은 MethodPattern 이 있습니다. method : %s, uri : %s"; @@ -33,9 +34,6 @@ public boolean match(HttpServletRequest request) { if (!pattern.matcher(request.getRequestURI()).matches()) { return false; } - if (!method.matches(request.getMethod())) { - return false; - } - return true; + return method.matches(request.getMethod()); } } diff --git a/backend/src/main/java/wooteco/support/autoceptor/scanner/ClassScanner.java b/backend/src/main/java/wooteco/support/autoceptor/scanner/ClassScanner.java index 5f8f42eb0..0f4210120 100644 --- a/backend/src/main/java/wooteco/support/autoceptor/scanner/ClassScanner.java +++ b/backend/src/main/java/wooteco/support/autoceptor/scanner/ClassScanner.java @@ -1,10 +1,11 @@ package wooteco.support.autoceptor.scanner; -import java.util.HashSet; -import java.util.Set; import org.reflections.Reflections; import org.reflections.scanners.SubTypesScanner; +import java.util.HashSet; +import java.util.Set; + public class ClassScanner { private final String basePackage; diff --git a/backend/src/main/java/wooteco/support/autoceptor/scanner/ControllerScanner.java b/backend/src/main/java/wooteco/support/autoceptor/scanner/ControllerScanner.java index 73aedf29c..b8ff82369 100644 --- a/backend/src/main/java/wooteco/support/autoceptor/scanner/ControllerScanner.java +++ b/backend/src/main/java/wooteco/support/autoceptor/scanner/ControllerScanner.java @@ -1,12 +1,13 @@ package wooteco.support.autoceptor.scanner; -import static java.util.stream.Collectors.toList; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RestController; import java.util.Arrays; import java.util.Collection; import java.util.List; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RestController; + +import static java.util.stream.Collectors.toList; public class ControllerScanner { diff --git a/backend/src/main/java/wooteco/support/autoceptor/scanner/MappingAnnotation.java b/backend/src/main/java/wooteco/support/autoceptor/scanner/MappingAnnotation.java index 27f5669e8..2afbe8523 100644 --- a/backend/src/main/java/wooteco/support/autoceptor/scanner/MappingAnnotation.java +++ b/backend/src/main/java/wooteco/support/autoceptor/scanner/MappingAnnotation.java @@ -1,11 +1,5 @@ package wooteco.support.autoceptor.scanner; -import java.lang.annotation.Annotation; -import java.lang.reflect.GenericDeclaration; -import java.util.Arrays; -import java.util.List; -import java.util.function.Function; -import java.util.function.Supplier; import org.springframework.http.HttpMethod; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -14,6 +8,13 @@ import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestMapping; +import java.lang.annotation.Annotation; +import java.lang.reflect.GenericDeclaration; +import java.util.Arrays; +import java.util.List; +import java.util.function.Function; +import java.util.function.Supplier; + public enum MappingAnnotation { REQUEST_MAPPING(RequestMapping.class, declaration -> Arrays.asList(declaration.getAnnotation(RequestMapping.class).value()), @@ -53,9 +54,9 @@ public static List extractUriFrom(GenericDeclaration declaration) { .filter(httpMethod -> declaration.isAnnotationPresent(httpMethod.typeToken)) .findAny() .map(httpMethod -> httpMethod.values.apply(declaration)) - .orElseGet(() -> Arrays.asList("")); - if(methodUris.isEmpty()){ - return Arrays.asList(""); + .orElseGet(() -> List.of("")); + if (methodUris.isEmpty()) { + return List.of(""); } return methodUris; } diff --git a/backend/src/main/java/wooteco/support/autoceptor/scanner/MethodScanner.java b/backend/src/main/java/wooteco/support/autoceptor/scanner/MethodScanner.java index 0fa3b5e1c..43a5e0561 100644 --- a/backend/src/main/java/wooteco/support/autoceptor/scanner/MethodScanner.java +++ b/backend/src/main/java/wooteco/support/autoceptor/scanner/MethodScanner.java @@ -1,13 +1,13 @@ package wooteco.support.autoceptor.scanner; -import static java.util.stream.Collectors.toList; - import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.Arrays; import java.util.Collection; import java.util.List; +import static java.util.stream.Collectors.toList; + public class MethodScanner { private final Collection> targetAnnotations; diff --git a/backend/src/main/java/wooteco/support/autoceptor/scanner/URIScanner.java b/backend/src/main/java/wooteco/support/autoceptor/scanner/URIScanner.java index 761498f2d..49d879681 100644 --- a/backend/src/main/java/wooteco/support/autoceptor/scanner/URIScanner.java +++ b/backend/src/main/java/wooteco/support/autoceptor/scanner/URIScanner.java @@ -1,7 +1,9 @@ package wooteco.support.autoceptor.scanner; -import static java.util.stream.Collectors.joining; -import static java.util.stream.Collectors.toList; +import org.springframework.http.HttpMethod; +import org.springframework.util.StringUtils; +import wooteco.support.autoceptor.AuthenticationDetector; +import wooteco.support.autoceptor.MethodPattern; import java.lang.reflect.Method; import java.util.ArrayList; @@ -12,10 +14,9 @@ import java.util.List; import java.util.Set; import java.util.stream.Stream; -import org.springframework.http.HttpMethod; -import org.springframework.util.StringUtils; -import wooteco.support.autoceptor.AuthenticationDetector; -import wooteco.support.autoceptor.MethodPattern; + +import static java.util.stream.Collectors.joining; +import static java.util.stream.Collectors.toList; public class URIScanner { diff --git a/backend/src/main/java/wooteco/support/fake/FakeDocumentRepository.java b/backend/src/main/java/wooteco/support/fake/FakeDocumentRepository.java deleted file mode 100644 index 1b039470c..000000000 --- a/backend/src/main/java/wooteco/support/fake/FakeDocumentRepository.java +++ /dev/null @@ -1,6 +0,0 @@ -package wooteco.support.fake; - -public interface FakeDocumentRepository { - - void deleteAll(); -} diff --git a/backend/src/main/java/wooteco/support/performance/PerformanceLogger.java b/backend/src/main/java/wooteco/support/performance/PerformanceLogger.java index 8c6a423ac..9c9aef1ae 100644 --- a/backend/src/main/java/wooteco/support/performance/PerformanceLogger.java +++ b/backend/src/main/java/wooteco/support/performance/PerformanceLogger.java @@ -2,7 +2,6 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import java.lang.reflect.Proxy; import lombok.RequiredArgsConstructor; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.ProceedingJoinPoint; @@ -14,6 +13,8 @@ import org.springframework.transaction.support.TransactionSynchronization; import org.springframework.transaction.support.TransactionSynchronizationManager; +import java.lang.reflect.Proxy; + @Aspect @RequiredArgsConstructor public class PerformanceLogger { diff --git a/backend/src/main/java/wooteco/support/performance/RequestApiExtractor.java b/backend/src/main/java/wooteco/support/performance/RequestApiExtractor.java index b31388997..c9ef20e2c 100644 --- a/backend/src/main/java/wooteco/support/performance/RequestApiExtractor.java +++ b/backend/src/main/java/wooteco/support/performance/RequestApiExtractor.java @@ -1,9 +1,5 @@ package wooteco.support.performance; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.reflect.MethodSignature; import org.springframework.web.bind.annotation.RequestMapping; @@ -13,6 +9,11 @@ import wooteco.support.performance.annotationDataExtractor.PostMappingDataExtractor; import wooteco.support.performance.annotationDataExtractor.PutMappingDataExtractor; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; + public class RequestApiExtractor { private final List dataExtractors = new ArrayList<>(); diff --git a/backend/src/main/java/wooteco/support/performance/annotationDataExtractor/AnnotationDataExtractor.java b/backend/src/main/java/wooteco/support/performance/annotationDataExtractor/AnnotationDataExtractor.java index 1111a918a..7278739c1 100644 --- a/backend/src/main/java/wooteco/support/performance/annotationDataExtractor/AnnotationDataExtractor.java +++ b/backend/src/main/java/wooteco/support/performance/annotationDataExtractor/AnnotationDataExtractor.java @@ -1,8 +1,9 @@ package wooteco.support.performance.annotationDataExtractor; -import java.lang.reflect.Method; import wooteco.support.performance.RequestApi; +import java.lang.reflect.Method; + public interface AnnotationDataExtractor { boolean isAssignable(Method method); diff --git a/backend/src/main/java/wooteco/support/performance/annotationDataExtractor/DeleteMappingDataExtractor.java b/backend/src/main/java/wooteco/support/performance/annotationDataExtractor/DeleteMappingDataExtractor.java index d9980ecc3..35e65a0f8 100644 --- a/backend/src/main/java/wooteco/support/performance/annotationDataExtractor/DeleteMappingDataExtractor.java +++ b/backend/src/main/java/wooteco/support/performance/annotationDataExtractor/DeleteMappingDataExtractor.java @@ -1,10 +1,11 @@ package wooteco.support.performance.annotationDataExtractor; -import java.lang.reflect.Method; -import java.util.Arrays; import org.springframework.web.bind.annotation.DeleteMapping; import wooteco.support.performance.RequestApi; +import java.lang.reflect.Method; +import java.util.Arrays; + public class DeleteMappingDataExtractor implements AnnotationDataExtractor { @Override diff --git a/backend/src/main/java/wooteco/support/performance/annotationDataExtractor/GetMappingDataExtractor.java b/backend/src/main/java/wooteco/support/performance/annotationDataExtractor/GetMappingDataExtractor.java index e8f561f19..ee5190540 100644 --- a/backend/src/main/java/wooteco/support/performance/annotationDataExtractor/GetMappingDataExtractor.java +++ b/backend/src/main/java/wooteco/support/performance/annotationDataExtractor/GetMappingDataExtractor.java @@ -1,10 +1,11 @@ package wooteco.support.performance.annotationDataExtractor; -import java.lang.reflect.Method; -import java.util.Arrays; import org.springframework.web.bind.annotation.GetMapping; import wooteco.support.performance.RequestApi; +import java.lang.reflect.Method; +import java.util.Arrays; + public class GetMappingDataExtractor implements AnnotationDataExtractor { @Override diff --git a/backend/src/main/java/wooteco/support/performance/annotationDataExtractor/PostMappingDataExtractor.java b/backend/src/main/java/wooteco/support/performance/annotationDataExtractor/PostMappingDataExtractor.java index 5d73397cc..9c3ae9689 100644 --- a/backend/src/main/java/wooteco/support/performance/annotationDataExtractor/PostMappingDataExtractor.java +++ b/backend/src/main/java/wooteco/support/performance/annotationDataExtractor/PostMappingDataExtractor.java @@ -1,10 +1,11 @@ package wooteco.support.performance.annotationDataExtractor; -import java.lang.reflect.Method; -import java.util.Arrays; import org.springframework.web.bind.annotation.PostMapping; import wooteco.support.performance.RequestApi; +import java.lang.reflect.Method; +import java.util.Arrays; + public class PostMappingDataExtractor implements AnnotationDataExtractor { @Override diff --git a/backend/src/main/java/wooteco/support/performance/annotationDataExtractor/PutMappingDataExtractor.java b/backend/src/main/java/wooteco/support/performance/annotationDataExtractor/PutMappingDataExtractor.java index dfa1b2c55..d9d85eb8d 100644 --- a/backend/src/main/java/wooteco/support/performance/annotationDataExtractor/PutMappingDataExtractor.java +++ b/backend/src/main/java/wooteco/support/performance/annotationDataExtractor/PutMappingDataExtractor.java @@ -1,10 +1,11 @@ package wooteco.support.performance.annotationDataExtractor; -import java.lang.reflect.Method; -import java.util.Arrays; import org.springframework.web.bind.annotation.PutMapping; import wooteco.support.performance.RequestApi; +import java.lang.reflect.Method; +import java.util.Arrays; + public class PutMappingDataExtractor implements AnnotationDataExtractor { @Override diff --git a/backend/src/main/resources/application-local.yml b/backend/src/main/resources/application-local.yml index 6b94c3dbf..efb112665 100644 --- a/backend/src/main/resources/application-local.yml +++ b/backend/src/main/resources/application-local.yml @@ -13,10 +13,6 @@ github: id: f91b56445e08d44adb76 secret: f02769f780ed3d40f9db9283f5b7cc79ecf9074e -elasticsearch: - host: 127.0.0.1 - port: 9200 - manager: role: GUEST diff --git a/backend/src/main/resources/application.yml b/backend/src/main/resources/application.yml index b969b96e2..31dfcebb9 100644 --- a/backend/src/main/resources/application.yml +++ b/backend/src/main/resources/application.yml @@ -24,9 +24,6 @@ spring: out-of-order: true management: - health: - elasticsearch: - enabled: false endpoints: web: exposure: @@ -53,9 +50,5 @@ cloud: stack: auto: false -elasticsearch: - host: 127.0.0.1 - port: 9200 - manager: role: COACH diff --git a/backend/src/main/resources/bootstrap-dev.yml b/backend/src/main/resources/bootstrap-dev.yml new file mode 100644 index 000000000..1e1839838 --- /dev/null +++ b/backend/src/main/resources/bootstrap-dev.yml @@ -0,0 +1,3 @@ +aws: + secretsmanager: + enabled: true diff --git a/backend/src/main/resources/bootstrap-prod.yml b/backend/src/main/resources/bootstrap-prod.yml new file mode 100644 index 000000000..1e1839838 --- /dev/null +++ b/backend/src/main/resources/bootstrap-prod.yml @@ -0,0 +1,3 @@ +aws: + secretsmanager: + enabled: true diff --git a/backend/src/main/resources/bootstrap.yml b/backend/src/main/resources/bootstrap.yml new file mode 100644 index 000000000..8f39d2644 --- /dev/null +++ b/backend/src/main/resources/bootstrap.yml @@ -0,0 +1,7 @@ +aws: + secretsmanager: + enabled: false + name: prolog + prefix: secrets + default-context: prolog + region: ap-northeast-2 diff --git a/backend/src/main/resources/db/migration/prod/V9__alter_table_group_and_member.sql b/backend/src/main/resources/db/migration/prod/V9__alter_table_group_and_member.sql index 6766b3a8e..a19a32a12 100644 --- a/backend/src/main/resources/db/migration/prod/V9__alter_table_group_and_member.sql +++ b/backend/src/main/resources/db/migration/prod/V9__alter_table_group_and_member.sql @@ -11,7 +11,7 @@ create table if not exists department_member id bigint auto_increment primary key, member_id bigint not null, department_id bigint not null, - constraint FK_DEPARTMENT_MEMBER_ON_MEMBERㅇ + constraint FK_DEPARTMENT_MEMBER_ON_MEMBER foreign key (member_id) references prolog.member (id), constraint FK_DEPARTMENT_MEMBER_ON_DEPARTMENT foreign key (department_id) references prolog.department (id) diff --git a/backend/src/main/resources/logback-spring.xml b/backend/src/main/resources/logback-spring.xml index 1d7f734c7..f75b8dc8d 100644 --- a/backend/src/main/resources/logback-spring.xml +++ b/backend/src/main/resources/logback-spring.xml @@ -60,12 +60,12 @@ + additivity="false"> + additivity="false"> diff --git a/backend/src/main/resources/logback/file-access-logger.xml b/backend/src/main/resources/logback/file-access-logger.xml index bd8563bff..c5cc1d0ce 100644 --- a/backend/src/main/resources/logback/file-access-logger.xml +++ b/backend/src/main/resources/logback/file-access-logger.xml @@ -3,12 +3,9 @@ ${home}access.log - + ${home}access-%d{yyyyMMdd}-%i.log - - 15MB - + 15MB 7 diff --git a/backend/src/main/resources/logback/file-debug-logger.xml b/backend/src/main/resources/logback/file-debug-logger.xml index f0236d56a..837360b76 100644 --- a/backend/src/main/resources/logback/file-debug-logger.xml +++ b/backend/src/main/resources/logback/file-debug-logger.xml @@ -8,12 +8,9 @@ ACCEPT DENY - + ${home}debug-%d{yyyyMMdd}-%i.log - - 15MB - + 15MB 7 diff --git a/backend/src/main/resources/logback/file-error-logger.xml b/backend/src/main/resources/logback/file-error-logger.xml index d1b4b2249..cd4b405c2 100644 --- a/backend/src/main/resources/logback/file-error-logger.xml +++ b/backend/src/main/resources/logback/file-error-logger.xml @@ -8,12 +8,9 @@ ACCEPT DENY - + ${home}error-%d{yyyyMMdd}-%i.log - - 15MB - + 15MB 7 diff --git a/backend/src/main/resources/logback/file-info-logger.xml b/backend/src/main/resources/logback/file-info-logger.xml index 10b888b44..4d6c14048 100644 --- a/backend/src/main/resources/logback/file-info-logger.xml +++ b/backend/src/main/resources/logback/file-info-logger.xml @@ -8,12 +8,9 @@ ACCEPT DENY - + ${home}info-%d{yyyyMMdd}-%i.log - - 15MB - + 15MB 7 diff --git a/backend/src/main/resources/logback/file-warn-logger.xml b/backend/src/main/resources/logback/file-warn-logger.xml index 16b180459..0ab5cc8d6 100644 --- a/backend/src/main/resources/logback/file-warn-logger.xml +++ b/backend/src/main/resources/logback/file-warn-logger.xml @@ -8,12 +8,9 @@ ACCEPT DENY - + ${home}warn-%d{yyyyMMdd}-%i.log - - 15MB - + 15MB 30 diff --git a/backend/src/main/resources/logback/performance-logger.xml b/backend/src/main/resources/logback/performance-logger.xml index ee24a46f1..b4ada9242 100644 --- a/backend/src/main/resources/logback/performance-logger.xml +++ b/backend/src/main/resources/logback/performance-logger.xml @@ -3,12 +3,9 @@ ${home}performance.log - + ${home}performance-%d{yyyyMMdd}-%i.log - - 15MB - + 15MB 1 diff --git a/backend/src/test/java/wooteco/prolog/article/application/ArticleServiceTest.java b/backend/src/test/java/wooteco/prolog/article/application/ArticleServiceTest.java index fe06b3d8e..50e0b709d 100644 --- a/backend/src/test/java/wooteco/prolog/article/application/ArticleServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/article/application/ArticleServiceTest.java @@ -1,18 +1,5 @@ package wooteco.prolog.article.application; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.atLeastOnce; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static wooteco.prolog.login.ui.LoginMember.Authority.ANONYMOUS; -import static wooteco.prolog.login.ui.LoginMember.Authority.MEMBER; -import static wooteco.prolog.member.domain.Role.CREW; - -import java.util.Arrays; -import java.util.List; -import java.util.Optional; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; @@ -37,6 +24,20 @@ import wooteco.prolog.member.domain.Member; import wooteco.prolog.member.domain.Role; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.atLeastOnce; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static wooteco.prolog.login.ui.LoginMember.Authority.ANONYMOUS; +import static wooteco.prolog.login.ui.LoginMember.Authority.MEMBER; +import static wooteco.prolog.member.domain.Role.CREW; + @ExtendWith(MockitoExtension.class) class ArticleServiceTest { @@ -310,7 +311,7 @@ void filter() { final Article article = new Article(member, new Title("title"), new Url("url"), new ImageUrl("imageUrl")); final LoginMember unLoginMember = new LoginMember(1L, ANONYMOUS); - when(articleRepository.findAllByOrderByCreatedAtDesc()).thenReturn(Arrays.asList(article)); + when(articleRepository.findAllByOrderByCreatedAtDesc()).thenReturn(List.of(article)); //when final List articleResponses = articleService.getFilteredArticles(unLoginMember, ArticleFilterType.BACKEND, false); @@ -328,7 +329,7 @@ void filter_isBookmarked() { final Article article = new Article(member, new Title("title"), new Url("url"), new ImageUrl("imageUrl")); final LoginMember loginMember = new LoginMember(1L, MEMBER); - when(articleRepository.findAllByOrderByCreatedAtDesc()).thenReturn(Arrays.asList(article)); + when(articleRepository.findAllByOrderByCreatedAtDesc()).thenReturn(List.of(article)); //when final List articleResponses = articleService.getFilteredArticles(loginMember, ArticleFilterType.BACKEND, true); diff --git a/backend/src/test/java/wooteco/prolog/article/application/MetaOgServiceTest.java b/backend/src/test/java/wooteco/prolog/article/application/MetaOgServiceTest.java index 781aec743..e5fdb4c06 100644 --- a/backend/src/test/java/wooteco/prolog/article/application/MetaOgServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/article/application/MetaOgServiceTest.java @@ -1,11 +1,5 @@ package wooteco.prolog.article.application; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.when; - -import java.util.HashMap; -import java.util.Map; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -16,6 +10,13 @@ import wooteco.prolog.article.application.dto.ArticleUrlRequest; import wooteco.prolog.article.application.dto.ArticleUrlResponse; +import java.util.HashMap; +import java.util.Map; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; + @ExtendWith(MockitoExtension.class) class MetaOgServiceTest { diff --git a/backend/src/test/java/wooteco/prolog/article/application/RssClientTest.java b/backend/src/test/java/wooteco/prolog/article/application/RssClientTest.java index 4565d6c43..41bd4faba 100644 --- a/backend/src/test/java/wooteco/prolog/article/application/RssClientTest.java +++ b/backend/src/test/java/wooteco/prolog/article/application/RssClientTest.java @@ -1,10 +1,10 @@ package wooteco.prolog.article.application; -import static org.assertj.core.api.Assertions.assertThat; - import org.junit.jupiter.api.Test; import wooteco.prolog.article.domain.RssFeeds; +import static org.assertj.core.api.Assertions.assertThat; + class RssClientTest { @Test void fromTistoryRssFeedBy() { diff --git a/backend/src/test/java/wooteco/prolog/article/domain/ArticleBookmarkTest.java b/backend/src/test/java/wooteco/prolog/article/domain/ArticleBookmarkTest.java index 8f9914730..cafe524f4 100644 --- a/backend/src/test/java/wooteco/prolog/article/domain/ArticleBookmarkTest.java +++ b/backend/src/test/java/wooteco/prolog/article/domain/ArticleBookmarkTest.java @@ -1,12 +1,12 @@ package wooteco.prolog.article.domain; -import static org.assertj.core.api.Assertions.assertThat; - import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import wooteco.prolog.member.domain.Member; import wooteco.prolog.member.domain.Role; +import static org.assertj.core.api.Assertions.assertThat; + class ArticleBookmarkTest { @DisplayName("memberId가 동일한지 확인") diff --git a/backend/src/test/java/wooteco/prolog/article/domain/ArticleBookmarksTest.java b/backend/src/test/java/wooteco/prolog/article/domain/ArticleBookmarksTest.java index dd945cd9a..76668551b 100644 --- a/backend/src/test/java/wooteco/prolog/article/domain/ArticleBookmarksTest.java +++ b/backend/src/test/java/wooteco/prolog/article/domain/ArticleBookmarksTest.java @@ -1,13 +1,13 @@ package wooteco.prolog.article.domain; -import static org.assertj.core.api.Assertions.assertThat; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import wooteco.prolog.member.domain.Member; import wooteco.prolog.member.domain.Role; +import static org.assertj.core.api.Assertions.assertThat; + class ArticleBookmarksTest { private Member member; diff --git a/backend/src/test/java/wooteco/prolog/article/domain/ArticleLikeTest.java b/backend/src/test/java/wooteco/prolog/article/domain/ArticleLikeTest.java index c0527dda4..25e2a556f 100644 --- a/backend/src/test/java/wooteco/prolog/article/domain/ArticleLikeTest.java +++ b/backend/src/test/java/wooteco/prolog/article/domain/ArticleLikeTest.java @@ -1,12 +1,12 @@ package wooteco.prolog.article.domain; -import static org.assertj.core.api.Assertions.assertThat; - import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import wooteco.prolog.member.domain.Member; import wooteco.prolog.member.domain.Role; +import static org.assertj.core.api.Assertions.assertThat; + class ArticleLikeTest { @DisplayName("memberId가 동일한지 확인") diff --git a/backend/src/test/java/wooteco/prolog/article/domain/ArticleLikesTest.java b/backend/src/test/java/wooteco/prolog/article/domain/ArticleLikesTest.java index 2647f3c8a..5a8254ab2 100644 --- a/backend/src/test/java/wooteco/prolog/article/domain/ArticleLikesTest.java +++ b/backend/src/test/java/wooteco/prolog/article/domain/ArticleLikesTest.java @@ -1,13 +1,13 @@ package wooteco.prolog.article.domain; -import static org.assertj.core.api.Assertions.assertThat; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import wooteco.prolog.member.domain.Member; import wooteco.prolog.member.domain.Role; +import static org.assertj.core.api.Assertions.assertThat; + class ArticleLikesTest { private Member member; diff --git a/backend/src/test/java/wooteco/prolog/article/domain/ArticleTest.java b/backend/src/test/java/wooteco/prolog/article/domain/ArticleTest.java index 918486e85..deefd6330 100644 --- a/backend/src/test/java/wooteco/prolog/article/domain/ArticleTest.java +++ b/backend/src/test/java/wooteco/prolog/article/domain/ArticleTest.java @@ -1,10 +1,5 @@ package wooteco.prolog.article.domain; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; - -import joptsimple.internal.Strings; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; @@ -13,6 +8,10 @@ import wooteco.prolog.member.domain.Member; import wooteco.prolog.member.domain.Role; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; + class ArticleTest { private Member member; @@ -82,10 +81,10 @@ void update_invalidTitle() { final Article article = new Article(member, title, url, imageUrl); //when - article.update(Strings.repeat('a', 51), "newUrl"); + article.update("a".repeat(51), "newUrl"); //then - assertThat(article.getTitle().getTitle()).isEqualTo(Strings.repeat('a', 50)); + assertThat(article.getTitle().getTitle()).isEqualTo("a".repeat(50)); } @DisplayName("유효하지 않은 URL으로 업데이트시 예외를 발생한다.") @@ -96,7 +95,7 @@ void update_invalidUrl() { //when //then - assertThatThrownBy(() -> article.update("newTitle", Strings.repeat('.', 1025))) + assertThatThrownBy(() -> article.update("newTitle", ".".repeat(1025))) .isInstanceOf(BadRequestException.class); } diff --git a/backend/src/test/java/wooteco/prolog/article/domain/ImageUrlTest.java b/backend/src/test/java/wooteco/prolog/article/domain/ImageUrlTest.java index dc412ae61..39e7a6f1a 100644 --- a/backend/src/test/java/wooteco/prolog/article/domain/ImageUrlTest.java +++ b/backend/src/test/java/wooteco/prolog/article/domain/ImageUrlTest.java @@ -1,14 +1,13 @@ package wooteco.prolog.article.domain; -import static org.assertj.core.api.Assertions.assertThat; - -import joptsimple.internal.Strings; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.NullSource; import org.junit.jupiter.params.provider.ValueSource; +import static org.assertj.core.api.Assertions.assertThat; + class ImageUrlTest { @ParameterizedTest(name = "이미지 URL이 \"{0}\" 일 때") @@ -22,7 +21,7 @@ void createUrl_fail(final String url) { @DisplayName("이미지 URL의 길이가 최대길이를 초과할 경우") @Test void createUrl_fail_overLength() { - final String url = Strings.repeat('.', 1025); + final String url = ".".repeat(1025); ImageUrl imageUrl = new ImageUrl(url); assertThat(imageUrl.getUrl()).isNotBlank(); } diff --git a/backend/src/test/java/wooteco/prolog/article/domain/TitleTest.java b/backend/src/test/java/wooteco/prolog/article/domain/TitleTest.java index 367c7460c..bb16179a2 100644 --- a/backend/src/test/java/wooteco/prolog/article/domain/TitleTest.java +++ b/backend/src/test/java/wooteco/prolog/article/domain/TitleTest.java @@ -1,14 +1,13 @@ package wooteco.prolog.article.domain; -import static org.assertj.core.api.Assertions.assertThat; - -import joptsimple.internal.Strings; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.NullSource; import org.junit.jupiter.params.provider.ValueSource; +import static org.assertj.core.api.Assertions.assertThat; + class TitleTest { @ParameterizedTest(name = "타이틀이 \"{0}\" 일 때 예외가 발생한다") @@ -23,7 +22,7 @@ void createTitle_fail(final String title) { @Test void createTitle_fail_overLength() { //given - final String title = Strings.repeat('.', 51); + final String title = ".".repeat(51); Title result = new Title(title); assertThat(result.getTitle()).isEqualTo(title.substring(0, 50)); diff --git a/backend/src/test/java/wooteco/prolog/article/domain/UrlTest.java b/backend/src/test/java/wooteco/prolog/article/domain/UrlTest.java index 80092dd16..d90a79e55 100644 --- a/backend/src/test/java/wooteco/prolog/article/domain/UrlTest.java +++ b/backend/src/test/java/wooteco/prolog/article/domain/UrlTest.java @@ -1,9 +1,5 @@ package wooteco.prolog.article.domain; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -import joptsimple.internal.Strings; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; @@ -11,6 +7,9 @@ import org.junit.jupiter.params.provider.ValueSource; import wooteco.prolog.common.exception.BadRequestException; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + class UrlTest { @ParameterizedTest(name = "URL이 \"{0}\" 일 때 예외가 발생한다") @@ -24,7 +23,7 @@ void createUrl_fail(final String url) { @DisplayName("URL의 길이가 최대길이를 초과할 경우 예외가 발생한다") @Test void createUrl_fail_overLength() { - final String url = Strings.repeat('.', 1025); + final String url = ".".repeat(1025); assertThatThrownBy(() -> new Url(url)) .isInstanceOf(BadRequestException.class); } diff --git a/backend/src/test/java/wooteco/prolog/badge/application/ComplimentKingBadgeCreatorTest.java b/backend/src/test/java/wooteco/prolog/badge/application/ComplimentKingBadgeCreatorTest.java index 4ebbf4656..e7f34af5e 100644 --- a/backend/src/test/java/wooteco/prolog/badge/application/ComplimentKingBadgeCreatorTest.java +++ b/backend/src/test/java/wooteco/prolog/badge/application/ComplimentKingBadgeCreatorTest.java @@ -7,6 +7,7 @@ import java.util.Arrays; import java.util.Optional; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/backend/src/test/java/wooteco/prolog/badge/application/PassionKingBadgeCreatorTest.java b/backend/src/test/java/wooteco/prolog/badge/application/PassionKingBadgeCreatorTest.java index 5b7a3a6d5..f86d4527d 100644 --- a/backend/src/test/java/wooteco/prolog/badge/application/PassionKingBadgeCreatorTest.java +++ b/backend/src/test/java/wooteco/prolog/badge/application/PassionKingBadgeCreatorTest.java @@ -1,11 +1,5 @@ package wooteco.prolog.badge.application; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.when; - -import java.util.Arrays; -import java.util.Optional; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -15,6 +9,13 @@ import wooteco.prolog.badge.domain.BadgeType; import wooteco.prolog.studylog.domain.repository.BadgeRepository; +import java.util.Arrays; +import java.util.Optional; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; + @ExtendWith(MockitoExtension.class) class PassionKingBadgeCreatorTest { diff --git a/backend/src/test/java/wooteco/prolog/badge/domain/FourthCrewSessionsTest.java b/backend/src/test/java/wooteco/prolog/badge/domain/FourthCrewSessionsTest.java index 5de72137c..548c4e24e 100644 --- a/backend/src/test/java/wooteco/prolog/badge/domain/FourthCrewSessionsTest.java +++ b/backend/src/test/java/wooteco/prolog/badge/domain/FourthCrewSessionsTest.java @@ -1,11 +1,11 @@ package wooteco.prolog.badge.domain; +import org.junit.jupiter.api.Test; + import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertAll; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import org.junit.jupiter.api.Test; - class FourthCrewSessionsTest { @Test diff --git a/backend/src/test/java/wooteco/prolog/common/DataInitializer.java b/backend/src/test/java/wooteco/prolog/common/DataInitializer.java index 837ac5033..83bc21639 100644 --- a/backend/src/test/java/wooteco/prolog/common/DataInitializer.java +++ b/backend/src/test/java/wooteco/prolog/common/DataInitializer.java @@ -1,18 +1,18 @@ package wooteco.prolog.common; -import java.sql.DatabaseMetaData; -import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.List; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import javax.sql.DataSource; +import jakarta.persistence.EntityManager; +import jakarta.persistence.PersistenceContext; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; -import wooteco.support.fake.FakeDocumentRepository; + +import javax.sql.DataSource; +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.List; @Component @Profile("test") @@ -21,9 +21,6 @@ public class DataInitializer implements InitializingBean { @PersistenceContext private EntityManager entityManager; - @Autowired - private List fakeDocumentRepositories; - @Autowired private DataSource dataSource; @@ -51,7 +48,6 @@ public void afterPropertiesSet() { @Transactional public void execute() { truncateAllTables(); - deleteAllDocuments(); } private void truncateAllTables() { @@ -66,8 +62,4 @@ private void truncateAllTables() { private void executeQueryWithTable(String tableName) { entityManager.createNativeQuery("TRUNCATE TABLE " + tableName).executeUpdate(); } - - private void deleteAllDocuments() { - fakeDocumentRepositories.forEach(it -> it.deleteAll()); - } } diff --git a/backend/src/test/java/wooteco/prolog/common/exception/BadRequestCodeTest.java b/backend/src/test/java/wooteco/prolog/common/exception/BadRequestCodeTest.java index 42b983b0f..e3367e4f5 100644 --- a/backend/src/test/java/wooteco/prolog/common/exception/BadRequestCodeTest.java +++ b/backend/src/test/java/wooteco/prolog/common/exception/BadRequestCodeTest.java @@ -1,12 +1,12 @@ package wooteco.prolog.common.exception; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + import static org.assertj.core.api.Assertions.assertThat; import static wooteco.prolog.common.exception.BadRequestCode.GITHUB_API_FAIL; import static wooteco.prolog.common.exception.BadRequestCode.MEMBER_NOT_FOUND; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; - class BadRequestCodeTest { @DisplayName("예외 코드와 메시지가 잘 바인딩되는지 확인한다.") diff --git a/backend/src/test/java/wooteco/prolog/levellogs/domain/LevelLogTest.java b/backend/src/test/java/wooteco/prolog/levellogs/domain/LevelLogTest.java index 1e145824a..71fbc0fa0 100644 --- a/backend/src/test/java/wooteco/prolog/levellogs/domain/LevelLogTest.java +++ b/backend/src/test/java/wooteco/prolog/levellogs/domain/LevelLogTest.java @@ -1,12 +1,12 @@ package wooteco.prolog.levellogs.domain; -import static org.assertj.core.api.Assertions.assertThat; - import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import wooteco.prolog.member.domain.Member; import wooteco.prolog.member.domain.Role; +import static org.assertj.core.api.Assertions.assertThat; + public class LevelLogTest { @DisplayName("작성자인지 확인한다.") diff --git a/backend/src/test/java/wooteco/prolog/login/application/JwtTokenProviderTest.java b/backend/src/test/java/wooteco/prolog/login/application/JwtTokenProviderTest.java index 4f9af6627..d1add3fcd 100644 --- a/backend/src/test/java/wooteco/prolog/login/application/JwtTokenProviderTest.java +++ b/backend/src/test/java/wooteco/prolog/login/application/JwtTokenProviderTest.java @@ -1,16 +1,17 @@ package wooteco.prolog.login.application; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static wooteco.prolog.common.exception.BadRequestCode.TOKEN_NOT_VALID; - import io.jsonwebtoken.Jwts; import io.jsonwebtoken.SignatureAlgorithm; -import java.util.Date; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.member.domain.Role; +import java.util.Date; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static wooteco.prolog.common.exception.BadRequestCode.TOKEN_NOT_VALID; + class JwtTokenProviderTest { @DisplayName("유효하지 않은 JWT 토큰이 입력됐을 때 TokenNotValidException이 발생하는지 확인 ") diff --git a/backend/src/test/java/wooteco/prolog/login/domain/MemberTest.java b/backend/src/test/java/wooteco/prolog/login/domain/MemberTest.java index 3a7ba66b8..a2435e9a1 100644 --- a/backend/src/test/java/wooteco/prolog/login/domain/MemberTest.java +++ b/backend/src/test/java/wooteco/prolog/login/domain/MemberTest.java @@ -7,6 +7,7 @@ import java.util.List; import java.util.stream.Collectors; import java.util.stream.LongStream; + import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import wooteco.prolog.member.domain.Member; diff --git a/backend/src/test/java/wooteco/prolog/member/application/DepartmentMemberServiceTest.java b/backend/src/test/java/wooteco/prolog/member/application/DepartmentMemberServiceTest.java index 3557ea559..1a4ce1ec4 100644 --- a/backend/src/test/java/wooteco/prolog/member/application/DepartmentMemberServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/member/application/DepartmentMemberServiceTest.java @@ -1,13 +1,6 @@ package wooteco.prolog.member.application; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.when; -import static wooteco.prolog.member.domain.Part.BACKEND; -import static wooteco.prolog.member.domain.Term.FIFTH; - import com.google.common.collect.ImmutableList; -import java.util.List; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -20,6 +13,14 @@ import wooteco.prolog.member.domain.Role; import wooteco.prolog.member.domain.repository.DepartmentMemberRepository; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; +import static wooteco.prolog.member.domain.Part.BACKEND; +import static wooteco.prolog.member.domain.Term.FIFTH; + @ExtendWith(MockitoExtension.class) class DepartmentMemberServiceTest { diff --git a/backend/src/test/java/wooteco/prolog/member/application/MemberServiceTest.java b/backend/src/test/java/wooteco/prolog/member/application/MemberServiceTest.java index dc37ef77d..ae2c6767b 100644 --- a/backend/src/test/java/wooteco/prolog/member/application/MemberServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/member/application/MemberServiceTest.java @@ -1,20 +1,5 @@ package wooteco.prolog.member.application; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.jupiter.api.Assertions.assertAll; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.when; -import static wooteco.prolog.common.exception.BadRequestCode.MEMBER_NOT_ALLOWED; -import static wooteco.prolog.common.exception.BadRequestCode.MEMBER_NOT_FOUND; - -import java.util.Arrays; -import java.util.Comparator; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; -import java.util.stream.LongStream; import org.assertj.core.util.Lists; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -42,6 +27,22 @@ import wooteco.prolog.member.domain.repository.MemberRepository; import wooteco.prolog.organization.application.OrganizationService; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; +import java.util.stream.LongStream; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; +import static wooteco.prolog.common.exception.BadRequestCode.MEMBER_NOT_ALLOWED; +import static wooteco.prolog.common.exception.BadRequestCode.MEMBER_NOT_FOUND; + @ExtendWith(MockitoExtension.class) class MemberServiceTest { diff --git a/backend/src/test/java/wooteco/prolog/member/application/MemberTagServiceTest.java b/backend/src/test/java/wooteco/prolog/member/application/MemberTagServiceTest.java index 1099cda88..af10538a1 100644 --- a/backend/src/test/java/wooteco/prolog/member/application/MemberTagServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/member/application/MemberTagServiceTest.java @@ -1,17 +1,5 @@ package wooteco.prolog.member.application; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.groups.Tuple.tuple; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.IntStream; -import java.util.stream.LongStream; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -30,6 +18,19 @@ import wooteco.prolog.studylog.domain.Tags; import wooteco.prolog.studylog.domain.repository.StudylogRepository; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; +import java.util.stream.LongStream; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.groups.Tuple.tuple; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + @ExtendWith(MockitoExtension.class) class MemberTagServiceTest { diff --git a/backend/src/test/java/wooteco/prolog/member/domain/DepartmentTest.java b/backend/src/test/java/wooteco/prolog/member/domain/DepartmentTest.java index 3f0f9e7f7..bb86db511 100644 --- a/backend/src/test/java/wooteco/prolog/member/domain/DepartmentTest.java +++ b/backend/src/test/java/wooteco/prolog/member/domain/DepartmentTest.java @@ -1,5 +1,7 @@ package wooteco.prolog.member.domain; +import org.junit.jupiter.api.Test; + import static org.assertj.core.api.AssertionsForClassTypes.assertThat; import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; import static wooteco.prolog.member.domain.Part.ANDROID; @@ -8,8 +10,6 @@ import static wooteco.prolog.member.domain.Term.FIFTH; import static wooteco.prolog.member.domain.Term.FOURTH; -import org.junit.jupiter.api.Test; - class DepartmentTest { private static final Department ANDROID_DEPARTMENT = new Department(null, ANDROID, FIFTH); diff --git a/backend/src/test/java/wooteco/prolog/member/domain/MemberTagTest.java b/backend/src/test/java/wooteco/prolog/member/domain/MemberTagTest.java index 81f27d935..8f4e18d8d 100644 --- a/backend/src/test/java/wooteco/prolog/member/domain/MemberTagTest.java +++ b/backend/src/test/java/wooteco/prolog/member/domain/MemberTagTest.java @@ -1,8 +1,5 @@ package wooteco.prolog.member.domain; -import static org.junit.jupiter.params.provider.Arguments.arguments; - -import java.util.stream.Stream; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -11,6 +8,10 @@ import org.junit.jupiter.params.provider.MethodSource; import wooteco.prolog.studylog.domain.Tag; +import java.util.stream.Stream; + +import static org.junit.jupiter.params.provider.Arguments.arguments; + class MemberTagTest { private static final Member bebe = new Member(1L, "최원용", "베베", Role.CREW, 1L, "test"); diff --git a/backend/src/test/java/wooteco/prolog/member/domain/repository/DepartmentMemberRepositoryTest.java b/backend/src/test/java/wooteco/prolog/member/domain/repository/DepartmentMemberRepositoryTest.java index 8816d8174..02196d51f 100644 --- a/backend/src/test/java/wooteco/prolog/member/domain/repository/DepartmentMemberRepositoryTest.java +++ b/backend/src/test/java/wooteco/prolog/member/domain/repository/DepartmentMemberRepositoryTest.java @@ -1,9 +1,5 @@ package wooteco.prolog.member.domain.repository; -import static org.assertj.core.api.Assertions.assertThat; -import static wooteco.prolog.member.domain.Part.FRONTEND; -import static wooteco.prolog.member.domain.Term.FIFTH; - import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -13,6 +9,10 @@ import wooteco.prolog.member.domain.Role; import wooteco.support.utils.RepositoryTest; +import static org.assertj.core.api.Assertions.assertThat; +import static wooteco.prolog.member.domain.Part.FRONTEND; +import static wooteco.prolog.member.domain.Term.FIFTH; + @RepositoryTest class DepartmentMemberRepositoryTest { diff --git a/backend/src/test/java/wooteco/prolog/member/domain/repository/MemberRepositoryTest.java b/backend/src/test/java/wooteco/prolog/member/domain/repository/MemberRepositoryTest.java index adc0bcf04..c2c3aad9b 100644 --- a/backend/src/test/java/wooteco/prolog/member/domain/repository/MemberRepositoryTest.java +++ b/backend/src/test/java/wooteco/prolog/member/domain/repository/MemberRepositoryTest.java @@ -1,8 +1,5 @@ package wooteco.prolog.member.domain.repository; -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.Optional; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -10,10 +7,14 @@ import wooteco.prolog.member.domain.Role; import wooteco.support.utils.RepositoryTest; +import java.util.Optional; + +import static org.assertj.core.api.Assertions.assertThat; + @RepositoryTest class MemberRepositoryTest { - private static final Member 웨지 = new Member("sihyung92", "웨지", Role.CREW, 2222L, + private final Member 웨지 = new Member("sihyung92", "웨지", Role.CREW, 2222L, "https://avatars.githubusercontent.com/u/51393021?v=4"); @Autowired diff --git a/backend/src/test/java/wooteco/prolog/organization/application/OrganizationServiceTest.java b/backend/src/test/java/wooteco/prolog/organization/application/OrganizationServiceTest.java index 303d39a80..ab0aebaed 100644 --- a/backend/src/test/java/wooteco/prolog/organization/application/OrganizationServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/organization/application/OrganizationServiceTest.java @@ -1,9 +1,6 @@ package wooteco.prolog.organization.application; -import static org.assertj.core.api.Assertions.assertThat; - import com.google.common.collect.Lists; -import java.util.List; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -12,6 +9,10 @@ import wooteco.prolog.organization.domain.OrganizationGroup; import wooteco.prolog.organization.domain.OrganizationGroupSession; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + @SpringBootTest @Transactional class OrganizationServiceTest { diff --git a/backend/src/test/java/wooteco/prolog/roadmap/application/CurriculumServiceTest.java b/backend/src/test/java/wooteco/prolog/roadmap/application/CurriculumServiceTest.java index 629980719..a7eb212a1 100644 --- a/backend/src/test/java/wooteco/prolog/roadmap/application/CurriculumServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/roadmap/application/CurriculumServiceTest.java @@ -1,16 +1,5 @@ package wooteco.prolog.roadmap.application; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static wooteco.prolog.common.exception.BadRequestCode.CURRICULUM_NOT_FOUND_EXCEPTION; - -import java.util.Arrays; -import java.util.Optional; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -23,6 +12,18 @@ import wooteco.prolog.roadmap.domain.Curriculum; import wooteco.prolog.roadmap.domain.repository.CurriculumRepository; +import java.util.Arrays; +import java.util.Optional; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static wooteco.prolog.common.exception.BadRequestCode.CURRICULUM_NOT_FOUND_EXCEPTION; + @ExtendWith(MockitoExtension.class) class CurriculumServiceTest { diff --git a/backend/src/test/java/wooteco/prolog/roadmap/application/EssayAnswerSearchTest.java b/backend/src/test/java/wooteco/prolog/roadmap/application/EssayAnswerSearchTest.java index 868331ec4..36f9e2ec9 100644 --- a/backend/src/test/java/wooteco/prolog/roadmap/application/EssayAnswerSearchTest.java +++ b/backend/src/test/java/wooteco/prolog/roadmap/application/EssayAnswerSearchTest.java @@ -1,10 +1,5 @@ package wooteco.prolog.roadmap.application; -import static org.assertj.core.api.Assertions.assertThat; - -import java.time.LocalDateTime; -import java.util.Arrays; -import java.util.List; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -31,17 +26,24 @@ import wooteco.prolog.session.domain.repository.SessionRepository; import wooteco.prolog.studylog.application.dto.EssayAnswersResponse; +import java.time.LocalDateTime; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + @SpringBootTest @Transactional @TestConstructor(autowireMode = AutowireMode.ALL) public class EssayAnswerSearchTest { - private CurriculumRepository curriculumRepository; - private SessionRepository sessionRepository; - private KeywordRepository keywordRepository; - private QuizRepository quizRepository; - private MemberRepository memberRepository; - private EssayAnswerService essayAnswerService; + private final CurriculumRepository curriculumRepository; + private final SessionRepository sessionRepository; + private final KeywordRepository keywordRepository; + private final QuizRepository quizRepository; + private final MemberRepository memberRepository; + private final EssayAnswerService essayAnswerService; public EssayAnswerSearchTest(CurriculumRepository curriculumRepository, SessionRepository sessionRepository, @@ -239,7 +241,7 @@ void init() { curriculum.getId(), keyword4.getId(), null, - Arrays.asList(member1.getId()) + Collections.singletonList(member1.getId()) ); // when @@ -270,7 +272,7 @@ void init() { curriculum.getId(), keyword4.getId(), Arrays.asList(quiz6.getId(), quiz7.getId()), - Arrays.asList(member1.getId()) + Collections.singletonList(member1.getId()) ); // when @@ -299,7 +301,7 @@ void init() { curriculum.getId(), null, null, - Arrays.asList(member1.getId()) + Collections.singletonList(member1.getId()) ); // when diff --git a/backend/src/test/java/wooteco/prolog/roadmap/application/EssayAnswerServiceTest.java b/backend/src/test/java/wooteco/prolog/roadmap/application/EssayAnswerServiceTest.java index 6e1fc443e..91d05106d 100644 --- a/backend/src/test/java/wooteco/prolog/roadmap/application/EssayAnswerServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/roadmap/application/EssayAnswerServiceTest.java @@ -1,17 +1,5 @@ package wooteco.prolog.roadmap.application; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.anyLong; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static wooteco.prolog.common.exception.BadRequestCode.MEMBER_NOT_FOUND; - -import java.util.Arrays; -import java.util.List; -import java.util.Optional; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -29,6 +17,19 @@ import wooteco.prolog.roadmap.domain.repository.EssayAnswerRepository; import wooteco.prolog.roadmap.domain.repository.QuizRepository; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.anyLong; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static wooteco.prolog.common.exception.BadRequestCode.MEMBER_NOT_FOUND; + @ExtendWith(MockitoExtension.class) class EssayAnswerServiceTest { diff --git a/backend/src/test/java/wooteco/prolog/roadmap/application/KeywordServiceTest.java b/backend/src/test/java/wooteco/prolog/roadmap/application/KeywordServiceTest.java index 7d188054c..035ca515f 100644 --- a/backend/src/test/java/wooteco/prolog/roadmap/application/KeywordServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/roadmap/application/KeywordServiceTest.java @@ -1,14 +1,5 @@ package wooteco.prolog.roadmap.application; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.mockito.Mockito.any; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_KEYWORD_NOT_FOUND_EXCEPTION; - -import java.util.Collections; -import java.util.Optional; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -22,6 +13,16 @@ import wooteco.prolog.roadmap.domain.repository.KeywordRepository; import wooteco.prolog.session.domain.repository.SessionRepository; +import java.util.Collections; +import java.util.Optional; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.Mockito.any; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_KEYWORD_NOT_FOUND_EXCEPTION; + @ExtendWith(MockitoExtension.class) class KeywordServiceTest { diff --git a/backend/src/test/java/wooteco/prolog/roadmap/application/QuizServiceTest.java b/backend/src/test/java/wooteco/prolog/roadmap/application/QuizServiceTest.java index cf256805d..4d9b83815 100644 --- a/backend/src/test/java/wooteco/prolog/roadmap/application/QuizServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/roadmap/application/QuizServiceTest.java @@ -1,16 +1,5 @@ package wooteco.prolog.roadmap.application; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.jupiter.api.Assertions.assertAll; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_QUIZ_NOT_FOUND_EXCEPTION; - -import java.util.Arrays; -import java.util.Optional; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -30,6 +19,18 @@ import wooteco.prolog.roadmap.domain.repository.KeywordRepository; import wooteco.prolog.roadmap.domain.repository.QuizRepository; +import java.util.Arrays; +import java.util.Optional; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertAll; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_QUIZ_NOT_FOUND_EXCEPTION; + @ExtendWith(MockitoExtension.class) class QuizServiceTest { diff --git a/backend/src/test/java/wooteco/prolog/roadmap/application/RecommendedPostServiceTest.java b/backend/src/test/java/wooteco/prolog/roadmap/application/RecommendedPostServiceTest.java index a7637417f..1a5417144 100644 --- a/backend/src/test/java/wooteco/prolog/roadmap/application/RecommendedPostServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/roadmap/application/RecommendedPostServiceTest.java @@ -1,7 +1,5 @@ package wooteco.prolog.roadmap.application; -import static org.assertj.core.api.Assertions.assertThat; - import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -18,6 +16,8 @@ import wooteco.prolog.session.domain.Session; import wooteco.prolog.session.domain.repository.SessionRepository; +import static org.assertj.core.api.Assertions.assertThat; + @SpringBootTest class RecommendedPostServiceTest { diff --git a/backend/src/test/java/wooteco/prolog/roadmap/application/RoadMapServiceTest.java b/backend/src/test/java/wooteco/prolog/roadmap/application/RoadMapServiceTest.java index b7195ab6e..ec4800464 100644 --- a/backend/src/test/java/wooteco/prolog/roadmap/application/RoadMapServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/roadmap/application/RoadMapServiceTest.java @@ -1,14 +1,8 @@ package wooteco.prolog.roadmap.application; -import static java.util.Collections.emptySet; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.SoftAssertions.assertSoftly; - -import java.util.List; -import java.util.function.Consumer; import org.assertj.core.api.AbstractListAssert; +import org.assertj.core.api.ListAssert; import org.assertj.core.api.ObjectAssert; -import org.assertj.core.api.ProxyableListAssert; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -29,6 +23,13 @@ import wooteco.prolog.session.domain.Session; import wooteco.prolog.session.domain.repository.SessionRepository; +import java.util.List; +import java.util.function.Consumer; + +import static java.util.Collections.emptySet; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.SoftAssertions.assertSoftly; + @SpringBootTest class RoadMapServiceTest { @@ -76,7 +77,7 @@ void findAllKeywordsWithProgress() { //then assertSoftly(softAssertions -> { - final ProxyableListAssert roots = softAssertions.assertThat(response.getData()); + final ListAssert roots = softAssertions.assertThat(response.getData()); final AbstractListAssert, KeywordResponse, ObjectAssert> oneDepthChildren = roots.flatMap(KeywordResponse::getChildrenKeywords); final AbstractListAssert, KeywordResponse, ObjectAssert> twoDepthChildren @@ -127,7 +128,7 @@ void findAllKeywordsWithProgress_login() { //then assertSoftly(softAssertions -> { - final ProxyableListAssert roots = softAssertions.assertThat(response.getData()); + final ListAssert roots = softAssertions.assertThat(response.getData()); final AbstractListAssert, KeywordResponse, ObjectAssert> oneDepthChildren = roots.flatMap(KeywordResponse::getChildrenKeywords); final AbstractListAssert, KeywordResponse, ObjectAssert> twoDepthChildren diff --git a/backend/src/test/java/wooteco/prolog/roadmap/domain/CurriculumTest.java b/backend/src/test/java/wooteco/prolog/roadmap/domain/CurriculumTest.java index f171d7f9e..79333febe 100644 --- a/backend/src/test/java/wooteco/prolog/roadmap/domain/CurriculumTest.java +++ b/backend/src/test/java/wooteco/prolog/roadmap/domain/CurriculumTest.java @@ -1,13 +1,13 @@ package wooteco.prolog.roadmap.domain; -import static wooteco.prolog.common.exception.BadRequestCode.CURRICULUM_INVALID_EXCEPTION; - import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; import wooteco.prolog.common.exception.BadRequestException; +import static wooteco.prolog.common.exception.BadRequestCode.CURRICULUM_INVALID_EXCEPTION; + class CurriculumTest { @ParameterizedTest diff --git a/backend/src/test/java/wooteco/prolog/roadmap/domain/EssayAnswerTest.java b/backend/src/test/java/wooteco/prolog/roadmap/domain/EssayAnswerTest.java index 1d6330c3b..af0e425ff 100644 --- a/backend/src/test/java/wooteco/prolog/roadmap/domain/EssayAnswerTest.java +++ b/backend/src/test/java/wooteco/prolog/roadmap/domain/EssayAnswerTest.java @@ -1,14 +1,14 @@ package wooteco.prolog.roadmap.domain; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; - import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.member.domain.Member; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + class EssayAnswerTest { @ValueSource(strings = {"", " "}) diff --git a/backend/src/test/java/wooteco/prolog/roadmap/domain/KeywordTest.java b/backend/src/test/java/wooteco/prolog/roadmap/domain/KeywordTest.java index d9caa28c7..5f58518c5 100644 --- a/backend/src/test/java/wooteco/prolog/roadmap/domain/KeywordTest.java +++ b/backend/src/test/java/wooteco/prolog/roadmap/domain/KeywordTest.java @@ -1,15 +1,15 @@ package wooteco.prolog.roadmap.domain; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.jupiter.api.Assertions.assertAll; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import wooteco.prolog.common.exception.BadRequestException; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertAll; + class KeywordTest { private static final Long SESSION_ID = 3L; diff --git a/backend/src/test/java/wooteco/prolog/roadmap/domain/RecommendedPostTest.java b/backend/src/test/java/wooteco/prolog/roadmap/domain/RecommendedPostTest.java index 704d11144..b9c234d9b 100644 --- a/backend/src/test/java/wooteco/prolog/roadmap/domain/RecommendedPostTest.java +++ b/backend/src/test/java/wooteco/prolog/roadmap/domain/RecommendedPostTest.java @@ -1,5 +1,14 @@ package wooteco.prolog.roadmap.domain; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.NullAndEmptySource; +import wooteco.prolog.common.exception.BadRequestException; + +import java.util.stream.Collectors; +import java.util.stream.Stream; + import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.SoftAssertions.assertSoftly; @@ -7,14 +16,6 @@ import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_KEYWORD_NOT_FOUND_EXCEPTION; import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_RECOMMENDED_POST_INVALID_URL_LENGTH; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.NullAndEmptySource; -import wooteco.prolog.common.exception.BadRequestException; - class RecommendedPostTest { @Test diff --git a/backend/src/test/java/wooteco/prolog/roadmap/repository/EssayAnswerRepositoryTest.java b/backend/src/test/java/wooteco/prolog/roadmap/repository/EssayAnswerRepositoryTest.java index 75879e2ed..ec2405471 100644 --- a/backend/src/test/java/wooteco/prolog/roadmap/repository/EssayAnswerRepositoryTest.java +++ b/backend/src/test/java/wooteco/prolog/roadmap/repository/EssayAnswerRepositoryTest.java @@ -1,11 +1,5 @@ package wooteco.prolog.roadmap.repository; -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -17,6 +11,13 @@ import wooteco.prolog.roadmap.domain.repository.EssayAnswerRepository; import wooteco.support.utils.RepositoryTest; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static org.assertj.core.api.Assertions.assertThat; + @RepositoryTest class EssayAnswerRepositoryTest { diff --git a/backend/src/test/java/wooteco/prolog/roadmap/repository/KeywordRepositoryTest.java b/backend/src/test/java/wooteco/prolog/roadmap/repository/KeywordRepositoryTest.java index dd5d9847b..5cb37ec77 100644 --- a/backend/src/test/java/wooteco/prolog/roadmap/repository/KeywordRepositoryTest.java +++ b/backend/src/test/java/wooteco/prolog/roadmap/repository/KeywordRepositoryTest.java @@ -1,12 +1,6 @@ package wooteco.prolog.roadmap.repository; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.SoftAssertions.assertSoftly; -import static org.junit.jupiter.api.Assertions.assertAll; - -import java.util.Arrays; -import java.util.List; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -27,6 +21,13 @@ import wooteco.prolog.session.domain.repository.SessionRepository; import wooteco.support.utils.RepositoryTest; +import java.util.Arrays; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.SoftAssertions.assertSoftly; +import static org.junit.jupiter.api.Assertions.assertAll; + @RepositoryTest class KeywordRepositoryTest { diff --git a/backend/src/test/java/wooteco/prolog/roadmap/repository/QuizRepositoryTest.java b/backend/src/test/java/wooteco/prolog/roadmap/repository/QuizRepositoryTest.java index 2f689f68e..7ef25aece 100644 --- a/backend/src/test/java/wooteco/prolog/roadmap/repository/QuizRepositoryTest.java +++ b/backend/src/test/java/wooteco/prolog/roadmap/repository/QuizRepositoryTest.java @@ -1,9 +1,5 @@ package wooteco.prolog.roadmap.repository; -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.Arrays; -import java.util.List; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -19,6 +15,11 @@ import wooteco.prolog.session.domain.repository.SessionRepository; import wooteco.support.utils.RepositoryTest; +import java.util.Arrays; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + @RepositoryTest class QuizRepositoryTest { diff --git a/backend/src/test/java/wooteco/prolog/session/application/MissionServiceTest.java b/backend/src/test/java/wooteco/prolog/session/application/MissionServiceTest.java index e8579426a..9844d4181 100644 --- a/backend/src/test/java/wooteco/prolog/session/application/MissionServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/session/application/MissionServiceTest.java @@ -1,18 +1,5 @@ package wooteco.prolog.session.application; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertThrows; -import static org.junit.jupiter.api.Assertions.assertAll; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.when; -import static wooteco.prolog.login.ui.LoginMember.Authority.ANONYMOUS; -import static wooteco.prolog.login.ui.LoginMember.Authority.MEMBER; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Optional; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -28,6 +15,20 @@ import wooteco.prolog.session.domain.Session; import wooteco.prolog.session.domain.repository.MissionRepository; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Optional; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertAll; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.when; +import static wooteco.prolog.login.ui.LoginMember.Authority.ANONYMOUS; +import static wooteco.prolog.login.ui.LoginMember.Authority.MEMBER; + @ExtendWith(MockitoExtension.class) class MissionServiceTest { @@ -83,9 +84,9 @@ void validateName() { void findAll() { // given final List missions = new ArrayList<>(); - missions.addAll(Arrays.asList(new Mission("mission1", new Session("session1")))); - missions.addAll(Arrays.asList(new Mission("mission2", new Session("session2")))); - missions.addAll(Arrays.asList(new Mission("mission3", new Session("session3")))); + missions.addAll(List.of(new Mission("mission1", new Session("session1")))); + missions.addAll(List.of(new Mission("mission2", new Session("session2")))); + missions.addAll(List.of(new Mission("mission3", new Session("session3")))); doReturn(missions).when(missionRepository).findAll(); // when diff --git a/backend/src/test/java/wooteco/prolog/session/application/SessionMemberServiceTest.java b/backend/src/test/java/wooteco/prolog/session/application/SessionMemberServiceTest.java index 5327feb44..8e8ac44cc 100644 --- a/backend/src/test/java/wooteco/prolog/session/application/SessionMemberServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/session/application/SessionMemberServiceTest.java @@ -1,18 +1,5 @@ package wooteco.prolog.session.application; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.jupiter.api.Assertions.assertAll; -import static org.mockito.Mockito.atMostOnce; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static wooteco.prolog.member.domain.Role.CREW; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -29,6 +16,20 @@ import wooteco.prolog.session.domain.repository.SessionMemberRepository; import wooteco.prolog.session.domain.repository.SessionRepository; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertAll; +import static org.mockito.Mockito.atMostOnce; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static wooteco.prolog.member.domain.Role.CREW; + @ExtendWith(MockitoExtension.class) class SessionMemberServiceTest { diff --git a/backend/src/test/java/wooteco/prolog/session/application/SessionServiceTest.java b/backend/src/test/java/wooteco/prolog/session/application/SessionServiceTest.java index dd71e8d90..da708934a 100644 --- a/backend/src/test/java/wooteco/prolog/session/application/SessionServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/session/application/SessionServiceTest.java @@ -1,19 +1,5 @@ package wooteco.prolog.session.application; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.jupiter.api.Assertions.assertAll; -import static org.mockito.Mockito.doReturn; -import static wooteco.prolog.common.exception.BadRequestCode.DUPLICATE_SESSION_EXCEPTION; -import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_SESSION_NOT_FOUND_EXCEPTION; -import static wooteco.prolog.login.ui.LoginMember.Authority.ANONYMOUS; -import static wooteco.prolog.login.ui.LoginMember.Authority.MEMBER; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Optional; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -30,6 +16,21 @@ import wooteco.prolog.session.domain.SessionMember; import wooteco.prolog.session.domain.repository.SessionRepository; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertAll; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doReturn; +import static wooteco.prolog.common.exception.BadRequestCode.DUPLICATE_SESSION_EXCEPTION; +import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_SESSION_NOT_FOUND_EXCEPTION; +import static wooteco.prolog.login.ui.LoginMember.Authority.ANONYMOUS; +import static wooteco.prolog.login.ui.LoginMember.Authority.MEMBER; + @ExtendWith(MockitoExtension.class) class SessionServiceTest { @@ -142,7 +143,7 @@ void findMySessions() { sessionMembers.add(new SessionMember(1L, new Member("member1", "베베", Role.CREW, Long.MIN_VALUE, "img"))); doReturn(sessionMembers).when(sessionMemberService).findByMemberId(member.getId()); - doReturn(sessions).when(sessionRepository).findAllById(Arrays.asList(1L)); + doReturn(sessions).when(sessionRepository).findAllByIdInOrderByIdDesc(List.of(1L)); // when List responses = sessionService.findMySessions(member); @@ -182,13 +183,13 @@ void findALlWithMySessionFirst() { final List mySessions = new ArrayList<>(); mySessions.add(session2); - doReturn(mySessions).when(sessionRepository).findAllById(Collections.emptyList()); + doReturn(mySessions).when(sessionRepository).findAllByIdInOrderByIdDesc(any()); final List allSessions = new ArrayList<>(); allSessions.add(session1); allSessions.add(session2); allSessions.add(session3); - doReturn(allSessions).when(sessionRepository).findAll(); + doReturn(allSessions).when(sessionRepository).findAllByOrderByIdDesc(); // when List responses = sessionService.findAllWithMySessionFirst(loginMember); @@ -213,7 +214,7 @@ void findALlWithMySessionFirstReturnFindAll() { allSessions.add(session1); allSessions.add(session2); allSessions.add(session3); - doReturn(allSessions).when(sessionRepository).findAll(); + doReturn(allSessions).when(sessionRepository).findAllByOrderByIdDesc(); // when final List responses = sessionService.findAllWithMySessionFirst(loginMember); diff --git a/backend/src/test/java/wooteco/prolog/session/domain/MissionTest.java b/backend/src/test/java/wooteco/prolog/session/domain/MissionTest.java index 03da23658..4a64f0189 100644 --- a/backend/src/test/java/wooteco/prolog/session/domain/MissionTest.java +++ b/backend/src/test/java/wooteco/prolog/session/domain/MissionTest.java @@ -1,13 +1,13 @@ package wooteco.prolog.session.domain; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static wooteco.prolog.common.exception.BadRequestCode.TOO_LONG_MISSION_NAME; - import com.google.common.base.Supplier; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import wooteco.prolog.common.exception.BadRequestException; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static wooteco.prolog.common.exception.BadRequestCode.TOO_LONG_MISSION_NAME; + class MissionTest { private static final Session TEST_SESSION = new Session(4L, 5L, "세션"); diff --git a/backend/src/test/java/wooteco/prolog/session/domain/SessionTest.java b/backend/src/test/java/wooteco/prolog/session/domain/SessionTest.java index fd9f78b77..2fbcd703a 100644 --- a/backend/src/test/java/wooteco/prolog/session/domain/SessionTest.java +++ b/backend/src/test/java/wooteco/prolog/session/domain/SessionTest.java @@ -1,12 +1,12 @@ package wooteco.prolog.session.domain; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; - import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import wooteco.prolog.studylog.domain.Curriculum; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + public class SessionTest { private final static String BACKEND_LEVEL1_SESSION = "백엔드 Java 레벨 1"; diff --git a/backend/src/test/java/wooteco/prolog/session/domain/repository/SessionMemberRepositoryTest.java b/backend/src/test/java/wooteco/prolog/session/domain/repository/SessionMemberRepositoryTest.java index 60a4e24ec..c45cb9d50 100644 --- a/backend/src/test/java/wooteco/prolog/session/domain/repository/SessionMemberRepositoryTest.java +++ b/backend/src/test/java/wooteco/prolog/session/domain/repository/SessionMemberRepositoryTest.java @@ -1,9 +1,5 @@ package wooteco.prolog.session.domain.repository; -import static org.assertj.core.api.Assertions.assertThat; -import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_SESSION_NOT_FOUND_EXCEPTION; - -import java.util.Optional; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -15,6 +11,11 @@ import wooteco.prolog.session.domain.SessionMember; import wooteco.support.utils.RepositoryTest; +import java.util.Optional; + +import static org.assertj.core.api.Assertions.assertThat; +import static wooteco.prolog.common.exception.BadRequestCode.ROADMAP_SESSION_NOT_FOUND_EXCEPTION; + @RepositoryTest class SessionMemberRepositoryTest { diff --git a/backend/src/test/java/wooteco/prolog/session/domain/repository/SessionRepositoryTest.java b/backend/src/test/java/wooteco/prolog/session/domain/repository/SessionRepositoryTest.java index 3ef309015..ce707f2ec 100644 --- a/backend/src/test/java/wooteco/prolog/session/domain/repository/SessionRepositoryTest.java +++ b/backend/src/test/java/wooteco/prolog/session/domain/repository/SessionRepositoryTest.java @@ -1,14 +1,15 @@ package wooteco.prolog.session.domain.repository; -import static org.assertj.core.api.Assertions.assertThat; - import com.google.common.collect.Lists; -import java.util.List; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import wooteco.prolog.session.domain.Session; import wooteco.support.utils.RepositoryTest; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + @RepositoryTest class SessionRepositoryTest { diff --git a/backend/src/test/java/wooteco/prolog/studylog/application/CommentServiceTest.java b/backend/src/test/java/wooteco/prolog/studylog/application/CommentServiceTest.java index 00715c137..2b472ff19 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/application/CommentServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/application/CommentServiceTest.java @@ -1,17 +1,5 @@ package wooteco.prolog.studylog.application; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static wooteco.prolog.common.exception.BadRequestCode.COMMENT_NOT_FOUND; -import static wooteco.prolog.common.exception.BadRequestCode.MEMBER_NOT_FOUND; -import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_NOT_FOUND; - -import java.util.Arrays; -import java.util.List; -import java.util.Optional; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -36,6 +24,19 @@ import wooteco.prolog.studylog.domain.repository.CommentRepository; import wooteco.prolog.studylog.domain.repository.StudylogRepository; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static wooteco.prolog.common.exception.BadRequestCode.COMMENT_NOT_FOUND; +import static wooteco.prolog.common.exception.BadRequestCode.MEMBER_NOT_FOUND; +import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_NOT_FOUND; + @ExtendWith(MockitoExtension.class) class CommentServiceTest { diff --git a/backend/src/test/java/wooteco/prolog/studylog/application/FakeStudylogDocumentServiceTest.java b/backend/src/test/java/wooteco/prolog/studylog/application/FakeStudylogDocumentServiceTest.java deleted file mode 100644 index 7de801512..000000000 --- a/backend/src/test/java/wooteco/prolog/studylog/application/FakeStudylogDocumentServiceTest.java +++ /dev/null @@ -1,152 +0,0 @@ -package wooteco.prolog.studylog.application; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.anyIterable; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_DOCUMENT_NOT_FOUND; - -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.util.Arrays; -import java.util.Collections; -import java.util.Optional; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; -import org.springframework.data.domain.PageImpl; -import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.domain.Specification; -import wooteco.prolog.common.exception.BadRequestException; -import wooteco.prolog.member.domain.Member; -import wooteco.prolog.member.domain.Role; -import wooteco.prolog.studylog.domain.Studylog; -import wooteco.prolog.studylog.domain.StudylogDocument; -import wooteco.prolog.studylog.domain.Tags; -import wooteco.prolog.studylog.domain.repository.StudylogDocumentRepository; -import wooteco.prolog.studylog.domain.repository.StudylogRepository; - -@ExtendWith(MockitoExtension.class) -class FakeStudylogDocumentServiceTest { - - @Mock - private StudylogDocumentRepository studylogDocumentRepository; - @Mock - private StudylogRepository studylogRepository; - @InjectMocks - private FakeStudylogDocumentService fakeStudylogDocumentService; - - - @DisplayName("StudylogDocument save 호출 테스트") - @Test - void save() { - //given - final StudylogDocument studylogDocument = new StudylogDocument(1L, "라온", "오션", Arrays.asList(1L), 1L, 1L, "오션라온", LocalDateTime.now()); - when(studylogDocumentRepository.save(any())).thenReturn(any()); - - //when - fakeStudylogDocumentService.save(studylogDocument); - - //then - verify(studylogDocumentRepository, times(1)).save(studylogDocument); - } - - @DisplayName("StudylogDocument id로 조회 찾지 못할 경우 예외 테스트") - @Test - void findById_Exception() { - //given - when(studylogDocumentRepository.findById(1L)).thenReturn(Optional.empty()); - - //when & then - assertThatThrownBy(() -> fakeStudylogDocumentService.findById(1L)) - .isInstanceOf(BadRequestException.class) - .hasMessage(STUDYLOG_DOCUMENT_NOT_FOUND.getMessage()); - - } - - @DisplayName("StudylogDocument id로 조회 성공 테스트") - @Test - void findById() { - //given - final StudylogDocument studylogDocument = new StudylogDocument(1L, "라온", "오션", Arrays.asList(1L), 1L, 1L, "오션라온", LocalDateTime.now()); - when(studylogDocumentRepository.findById(1L)).thenReturn(Optional.of(studylogDocument)); - - //when & then - assertThat(fakeStudylogDocumentService.findById(1L)).isEqualTo(studylogDocument); - } - - @DisplayName("StudylogDocument delete 호출 성공 테스트") - @Test - void delete() { - //given - final StudylogDocument studylogDocument = new StudylogDocument(1L, "라온", "오션", Arrays.asList(1L), 1L, 1L, "오션라온", LocalDateTime.now()); - doNothing().when(studylogDocumentRepository).delete(any()); - - //when - fakeStudylogDocumentService.delete(studylogDocument); - - //then - verify(studylogDocumentRepository, times(1)).delete(studylogDocument); - } - - @DisplayName("StudylogDocument update 호출 성공 테스트") - @Test - void update() { - //given - final StudylogDocument studylogDocument = new StudylogDocument(1L, "라온", "오션", Arrays.asList(1L), 1L, 1L, "오션라온", LocalDateTime.now()); - when(studylogDocumentRepository.save(any())).thenReturn(any()); - - //when - fakeStudylogDocumentService.update(studylogDocument); - - //then - verify(studylogDocumentRepository, times(1)).save(studylogDocument); - } - - @DisplayName("elasticsearch와 db간 동기화를 한다.") - @Test - void sync() { - //given - doNothing().when(studylogDocumentRepository).deleteAll(); - - //when - fakeStudylogDocumentService.sync(); - - //then - verify(studylogDocumentRepository, times(1)).deleteAll(); - verify(studylogRepository, times(1)).findAll(); - verify(studylogDocumentRepository, times(1)).saveAll(anyIterable()); - } - - @DisplayName("searchKeyword를 공백으로 전처리한다.") - @Test - void preprocess() { - final String searchKeyword = "오션 라온"; - - assertThat(fakeStudylogDocumentService.preprocess(searchKeyword)) - .containsExactly("오션", "라온", "오션 라온"); - } - - @DisplayName("searchkeyword로 StudylogDocument를 찾아 반환한다.") - @Test - void findBySearchKeyword() { - //given - final Tags tags = Tags.of(Collections.singletonList("스터디로그")); - final Member member = new Member(1L, "김동해", "오션", Role.CREW, 1L, "image"); - final Studylog studylog = new Studylog(member, "제목", "내용", null, null, tags.getList()); - when(studylogRepository.findAll((Specification) any(), (Pageable) any())).thenReturn(new PageImpl<>(Arrays.asList(studylog))); - - //when - fakeStudylogDocumentService.findBySearchKeyword("오션 라온", Arrays.asList(1L), Arrays.asList(1L), Arrays.asList(1L), Arrays.asList("오션", "라온"), LocalDate.now(), LocalDate.now(), Pageable.unpaged()); - - // then - verify(studylogRepository, times(1)).findAll((Specification) any(), (Pageable) any()); - } -} diff --git a/backend/src/test/java/wooteco/prolog/studylog/application/FilterServiceTest.java b/backend/src/test/java/wooteco/prolog/studylog/application/FilterServiceTest.java index 7df5fbf52..55585cb82 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/application/FilterServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/application/FilterServiceTest.java @@ -1,11 +1,5 @@ package wooteco.prolog.studylog.application; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertAll; -import static org.mockito.Mockito.doReturn; - -import java.util.ArrayList; -import java.util.List; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -20,6 +14,13 @@ import wooteco.prolog.session.application.dto.MissionResponse; import wooteco.prolog.studylog.application.dto.FilterResponse; +import java.util.ArrayList; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertAll; +import static org.mockito.Mockito.doReturn; + @ExtendWith(MockitoExtension.class) class FilterServiceTest { diff --git a/backend/src/test/java/wooteco/prolog/studylog/application/IntegratedStudylogServiceTest.java b/backend/src/test/java/wooteco/prolog/studylog/application/IntegratedStudylogServiceTest.java index 376a3c3f7..bac64c9c3 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/application/IntegratedStudylogServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/application/IntegratedStudylogServiceTest.java @@ -1,18 +1,9 @@ package wooteco.prolog.studylog.application; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertAll; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.stream.IntStream; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.transaction.annotation.Transactional; import wooteco.prolog.member.domain.Member; import wooteco.prolog.member.domain.Role; import wooteco.prolog.member.domain.repository.MemberRepository; @@ -28,9 +19,17 @@ import wooteco.prolog.studylog.domain.StudylogRead; import wooteco.prolog.studylog.domain.repository.StudylogReadRepository; import wooteco.prolog.studylog.domain.repository.StudylogRepository; +import wooteco.support.utils.RepositoryTest; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.IntStream; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertAll; -@SpringBootTest -@Transactional +@RepositoryTest class IntegratedStudylogServiceTest { @Autowired @@ -53,7 +52,7 @@ class IntegratedStudylogServiceTest { @BeforeEach void setUp() { - Member 주디 = new Member(1L, "xrabcde", "바다", Role.CREW, 1111L, + Member 주디 = new Member("xrabcde", "바다", Role.CREW, 1111L, "https://avatars.githubusercontent.com/u/56033755?v=4"); judy = memberRepository.save(주디); session = sessionRepository.save(new Session("세션1")); @@ -85,7 +84,7 @@ void updateRead() { List readIds = studylogService.findReadIds(judy.getId()); SessionResponse sessionResponse = new SessionResponse(1L, "sessionResponse"); - List studylogs = Arrays.asList(new StudylogResponse(studylog, sessionResponse, new MissionResponse(1L, "missionResponse", sessionResponse), + List studylogs = List.of(new StudylogResponse(studylog, sessionResponse, new MissionResponse(1L, "missionResponse", sessionResponse), new ArrayList<>(), false, 0L)); //when diff --git a/backend/src/test/java/wooteco/prolog/studylog/application/PopularStudylogServiceTest.java b/backend/src/test/java/wooteco/prolog/studylog/application/PopularStudylogServiceTest.java index 195b35195..12e331fe0 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/application/PopularStudylogServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/application/PopularStudylogServiceTest.java @@ -1,16 +1,5 @@ package wooteco.prolog.studylog.application; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertAll; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.Arrays; -import java.util.List; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -36,6 +25,18 @@ import wooteco.prolog.studylog.domain.repository.PopularStudylogRepository; import wooteco.prolog.studylog.domain.repository.StudylogRepository; +import java.util.Arrays; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertAll; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + @ExtendWith(MockitoExtension.class) class PopularStudylogServiceTest { @@ -371,7 +372,7 @@ private Department setUpDepartment(final String part, final String term) { } private Member setUpMember(final Long id, final String userName, - final String nickname, final Long githubId) { + final String nickname, final Long githubId) { return new Member(id, userName, nickname, Role.CREW, githubId, "image url"); } diff --git a/backend/src/test/java/wooteco/prolog/studylog/application/StudylogLikeServiceTest.java b/backend/src/test/java/wooteco/prolog/studylog/application/StudylogLikeServiceTest.java index 613a07bd8..8953de8c4 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/application/StudylogLikeServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/application/StudylogLikeServiceTest.java @@ -1,12 +1,5 @@ package wooteco.prolog.studylog.application; -import static org.assertj.core.api.Assertions.assertThatCode; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.mockito.Mockito.when; -import static wooteco.prolog.common.exception.BadRequestCode.INVALID_LIKE_REQUEST_EXCEPTION; -import static wooteco.prolog.common.exception.BadRequestCode.INVALID_UNLIKE_REQUEST_EXCEPTION; - -import java.util.Optional; import org.assertj.core.util.Lists; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -22,6 +15,14 @@ import wooteco.prolog.studylog.domain.Studylog; import wooteco.prolog.studylog.domain.repository.StudylogRepository; +import java.util.Optional; + +import static org.assertj.core.api.Assertions.assertThatCode; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.Mockito.when; +import static wooteco.prolog.common.exception.BadRequestCode.INVALID_LIKE_REQUEST_EXCEPTION; +import static wooteco.prolog.common.exception.BadRequestCode.INVALID_UNLIKE_REQUEST_EXCEPTION; + public class StudylogLikeServiceTest { private static final Member member = new Member("yboy", "잉", Role.CREW, 1L, "https://"); diff --git a/backend/src/test/java/wooteco/prolog/studylog/application/StudylogScrapServiceTest.java b/backend/src/test/java/wooteco/prolog/studylog/application/StudylogScrapServiceTest.java index 53ffabd9d..7702cc14d 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/application/StudylogScrapServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/application/StudylogScrapServiceTest.java @@ -1,20 +1,5 @@ package wooteco.prolog.studylog.application; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.jupiter.api.Assertions.assertAll; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static wooteco.prolog.common.exception.BadRequestCode.MEMBER_NOT_ALLOWED; -import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_NOT_FOUND; -import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_SCRAP_ALREADY_REGISTERED_EXCEPTION; -import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_SCRAP_NOT_EXIST_EXCEPTION; - -import java.util.Arrays; -import java.util.List; -import java.util.Optional; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -40,6 +25,22 @@ import wooteco.prolog.studylog.domain.repository.StudylogRepository; import wooteco.prolog.studylog.domain.repository.StudylogScrapRepository; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertAll; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static wooteco.prolog.common.exception.BadRequestCode.MEMBER_NOT_ALLOWED; +import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_NOT_FOUND; +import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_SCRAP_ALREADY_REGISTERED_EXCEPTION; +import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_SCRAP_NOT_EXIST_EXCEPTION; + @ExtendWith(MockitoExtension.class) class StudylogScrapServiceTest { diff --git a/backend/src/test/java/wooteco/prolog/studylog/application/StudylogServiceTest.java b/backend/src/test/java/wooteco/prolog/studylog/application/StudylogServiceTest.java index 7663ba901..3850a267d 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/application/StudylogServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/application/StudylogServiceTest.java @@ -1,33 +1,5 @@ package wooteco.prolog.studylog.application; -import static java.util.Collections.emptyList; -import static java.util.Collections.singletonList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertEquals; -import static org.junit.jupiter.api.Assertions.assertAll; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyList; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static wooteco.prolog.common.exception.BadRequestCode.ONLY_AUTHOR_CAN_EDIT; -import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_ARGUMENT; -import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_NOT_FOUND; - -import java.lang.reflect.Field; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; @@ -80,6 +52,35 @@ import wooteco.prolog.studylog.domain.repository.dto.CommentCount; import wooteco.prolog.studylog.event.StudylogDeleteEvent; +import java.lang.reflect.Field; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static java.util.Collections.emptyList; +import static java.util.Collections.singletonList; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertAll; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyList; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static wooteco.prolog.common.exception.BadRequestCode.ONLY_AUTHOR_CAN_EDIT; +import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_ARGUMENT; +import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_NOT_FOUND; + @ExtendWith(MockitoExtension.class) class StudylogServiceTest { @@ -347,7 +348,7 @@ void findStudylogById() { class retrieveStudylogById { private Studylog studylog; - private long studyLogId = 1L; + private final long studyLogId = 1L; @BeforeEach void setting() throws NoSuchFieldException, IllegalAccessException { @@ -460,7 +461,7 @@ void retrieveStudylogById_readMineStudyLog() { class deleteStudylog { private Studylog studylog; - private long studyLogId = 1L; + private final long studyLogId = 1L; @BeforeEach void setting() throws NoSuchFieldException, IllegalAccessException { @@ -543,7 +544,7 @@ void deleteStudylog() { class updateStudylogMIssion { private Studylog studylog; - private long studyLogId = 1L; + private final long studyLogId = 1L; @BeforeEach void setting() throws NoSuchFieldException, IllegalAccessException { @@ -644,13 +645,13 @@ void findStudylogs_responseByRequestIds() { final int findElementCounts = 1; given(studylogRepository.findByIdInAndDeletedFalseOrderByIdDesc(any(), any())) .willReturn(new PageImpl<>( - Arrays.asList(studylog), + singletonList(studylog), pageableRequest, findElementCounts )); given(commentRepository.countByStudylogIn(anyList())) - .willReturn(Arrays.asList( + .willReturn(List.of( new CommentCount(studylog, 1L) ) ); @@ -666,7 +667,7 @@ void findStudylogs_responseByRequestIds() { requestPage + oneIndexedParameter), () -> assertThat(studylogsResponse.getTotalSize()).isEqualTo(findElementCounts), () -> assertThat(studylogsResponse.getTotalPage()).isEqualTo( - (findElementCounts / pageSize) + 1), + 1), () -> assertThat(studylogsResponse.getData()).hasSize(1) ); } @@ -694,14 +695,14 @@ void findStudylogs_findBySpecs() { given(studylogRepository.findAll(any(Specification.class), any(Pageable.class))) .willReturn( new PageImpl<>( - Arrays.asList(studylog), + singletonList(studylog), pageableRequest, findElementCounts ) ); given(commentRepository.countByStudylogIn(anyList())) - .willReturn(Arrays.asList( + .willReturn(List.of( new CommentCount(studylog, 1L) ) ); @@ -717,7 +718,7 @@ void findStudylogs_findBySpecs() { requestPage + oneIndexedParameter), () -> assertThat(studylogsResponse.getTotalSize()).isEqualTo(findElementCounts), () -> assertThat(studylogsResponse.getTotalPage()).isEqualTo( - (findElementCounts / pageSize) + 1), + 1), () -> assertThat(studylogsResponse.getData()).hasSize(1) ); } @@ -743,14 +744,14 @@ void findStudylogs_findByKeyword() { given(studylogDocumentService.findBySearchKeyword(any(), any(), any(), any(), any(), any(), any(), any())) - .willReturn(StudylogDocumentResponse.of(Arrays.asList(1L), 1, 1, 0)); + .willReturn(StudylogDocumentResponse.of(List.of(1L), 1, 1, 0)); final int findElementCounts = 1; given(studylogRepository.findByIdInAndDeletedFalseOrderByIdDesc(anyList())) - .willReturn(Arrays.asList(studylog)); + .willReturn(singletonList(studylog)); given(commentRepository.countByStudylogIn(anyList())) - .willReturn(Arrays.asList( + .willReturn(List.of( new CommentCount(studylog, 1L) ) ); @@ -766,7 +767,7 @@ void findStudylogs_findByKeyword() { requestPage + oneIndexedParameter), () -> assertThat(studylogsResponse.getTotalSize()).isEqualTo(findElementCounts), () -> assertThat(studylogsResponse.getTotalPage()).isEqualTo( - (findElementCounts / pageSize) + 1), + 1), () -> assertThat(studylogsResponse.getData()).hasSize(1) ); } diff --git a/backend/src/test/java/wooteco/prolog/studylog/application/StudylogSessionServiceTest.java b/backend/src/test/java/wooteco/prolog/studylog/application/StudylogSessionServiceTest.java index 3dbce67be..032be12a4 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/application/StudylogSessionServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/application/StudylogSessionServiceTest.java @@ -1,10 +1,5 @@ package wooteco.prolog.studylog.application; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; -import java.util.List; import org.assertj.core.util.Lists; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -19,6 +14,12 @@ import wooteco.prolog.studylog.domain.Studylog; import wooteco.prolog.studylog.domain.repository.StudylogRepository; +import java.util.ArrayList; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; + @ExtendWith(MockitoExtension.class) class StudylogSessionServiceTest { diff --git a/backend/src/test/java/wooteco/prolog/studylog/application/StudylogTagServiceTest.java b/backend/src/test/java/wooteco/prolog/studylog/application/StudylogTagServiceTest.java index 5ac3750f4..dd58dc4df 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/application/StudylogTagServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/application/StudylogTagServiceTest.java @@ -1,11 +1,7 @@ package wooteco.prolog.studylog.application; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.when; - import com.google.common.collect.ImmutableList; -import java.util.List; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -21,6 +17,11 @@ import wooteco.prolog.studylog.domain.Tag; import wooteco.prolog.studylog.domain.repository.StudylogTagRepository; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; + @ExtendWith(MockitoExtension.class) class StudylogTagServiceTest { diff --git a/backend/src/test/java/wooteco/prolog/studylog/application/TagServiceTest.java b/backend/src/test/java/wooteco/prolog/studylog/application/TagServiceTest.java index cb8479b1d..309b95ab7 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/application/TagServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/application/TagServiceTest.java @@ -1,16 +1,5 @@ package wooteco.prolog.studylog.application; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertAll; -import static org.mockito.ArgumentMatchers.anyList; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -30,6 +19,18 @@ import wooteco.prolog.studylog.domain.Tags; import wooteco.prolog.studylog.domain.repository.TagRepository; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertAll; +import static org.mockito.ArgumentMatchers.anyList; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + @ExtendWith(MockitoExtension.class) class TagServiceTest { diff --git a/backend/src/test/java/wooteco/prolog/studylog/application/ViewedStudyLogCookieGeneratorTest.java b/backend/src/test/java/wooteco/prolog/studylog/application/ViewedStudyLogCookieGeneratorTest.java index 857758a16..6a2064d5e 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/application/ViewedStudyLogCookieGeneratorTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/application/ViewedStudyLogCookieGeneratorTest.java @@ -1,7 +1,5 @@ package wooteco.prolog.studylog.application; -import static org.assertj.core.api.Assertions.assertThat; - import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -10,6 +8,8 @@ import org.springframework.http.ResponseCookie; import org.springframework.mock.web.MockHttpServletResponse; +import static org.assertj.core.api.Assertions.assertThat; + class ViewedStudyLogCookieGeneratorTest { private ViewedStudyLogCookieGenerator viewedStudyLogCookieGenerator; diff --git a/backend/src/test/java/wooteco/prolog/studylog/domain/CommentTest.java b/backend/src/test/java/wooteco/prolog/studylog/domain/CommentTest.java index 04fbf1270..7ab4bff90 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/domain/CommentTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/domain/CommentTest.java @@ -1,9 +1,5 @@ package wooteco.prolog.studylog.domain; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static wooteco.prolog.common.exception.BadRequestCode.COMMENT_DELETE_EXCEPTION; - -import java.util.Arrays; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import wooteco.prolog.common.exception.BadRequestException; @@ -12,6 +8,11 @@ import wooteco.prolog.session.domain.Mission; import wooteco.prolog.session.domain.Session; +import java.util.Arrays; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static wooteco.prolog.common.exception.BadRequestCode.COMMENT_DELETE_EXCEPTION; + public class CommentTest { @Test diff --git a/backend/src/test/java/wooteco/prolog/studylog/domain/DocumentQueryParserTest.java b/backend/src/test/java/wooteco/prolog/studylog/domain/DocumentQueryParserTest.java index 246e36479..664b83816 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/domain/DocumentQueryParserTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/domain/DocumentQueryParserTest.java @@ -1,18 +1,19 @@ package wooteco.prolog.studylog.domain; -import static java.util.Collections.emptyList; -import static org.assertj.core.api.Assertions.assertThat; -import static wooteco.prolog.studylog.domain.DocumentQueryParser.removeSpecialChars; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; + +import static java.util.Collections.emptyList; +import static org.assertj.core.api.Assertions.assertThat; +import static wooteco.prolog.studylog.domain.DocumentQueryParser.removeSpecialChars; class DocumentQueryParserTest { - private List escapedChars = Arrays.asList( + private final List escapedChars = Arrays.asList( "?", "!", "/", "\\", "!", "+", "-", "*", "[", "]", "{", "}", "&", "|", "(", ")", ":" ); @@ -130,7 +131,7 @@ void makeDefaultQueryString() { void makeDefaultQueryStringSingle() { // given String result = DocumentQueryParser.makeDefaultQueryString( - Arrays.asList("joanne") + List.of("joanne") ); // when - then assertThat(result).isEqualTo("joanne"); @@ -163,7 +164,7 @@ void makeKeywordsQueryStringNull() { void makeKeywordsQueryStringSingle() { // given String keyword = DocumentQueryParser.makeKeywordsQueryString( - Arrays.asList("java") + List.of("java") ); // when - then assertThat(keyword).isEqualTo("*java*"); diff --git a/backend/src/test/java/wooteco/prolog/studylog/domain/StudylogTagsTest.java b/backend/src/test/java/wooteco/prolog/studylog/domain/StudylogTagsTest.java index b9ec148a1..47a075069 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/domain/StudylogTagsTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/domain/StudylogTagsTest.java @@ -1,10 +1,5 @@ package wooteco.prolog.studylog.domain; -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; import org.assertj.core.util.Lists; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -14,6 +9,12 @@ import wooteco.prolog.session.domain.Mission; import wooteco.prolog.session.domain.Session; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + public class StudylogTagsTest { private static final Member 웨지 = new Member("sihyung92", "웨지", Role.CREW, 2222L, diff --git a/backend/src/test/java/wooteco/prolog/studylog/domain/StudylogTest.java b/backend/src/test/java/wooteco/prolog/studylog/domain/StudylogTest.java index f00f7f584..392e06e71 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/domain/StudylogTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/domain/StudylogTest.java @@ -1,15 +1,5 @@ package wooteco.prolog.studylog.domain; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.jupiter.api.Assertions.assertAll; -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static wooteco.prolog.common.exception.BadRequestCode.ONLY_AUTHOR_CAN_EDIT; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -19,6 +9,17 @@ import wooteco.prolog.session.domain.Mission; import wooteco.prolog.session.domain.Session; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertAll; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static wooteco.prolog.common.exception.BadRequestCode.ONLY_AUTHOR_CAN_EDIT; + class StudylogTest { private static final Long SELF_MEMBER_ID = 1L; diff --git a/backend/src/test/java/wooteco/prolog/studylog/domain/repository/CommentRepositoryTest.java b/backend/src/test/java/wooteco/prolog/studylog/domain/repository/CommentRepositoryTest.java index 713e843cb..f98b97405 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/domain/repository/CommentRepositoryTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/domain/repository/CommentRepositoryTest.java @@ -1,10 +1,7 @@ package wooteco.prolog.studylog.domain.repository; -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.List; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; +import jakarta.persistence.EntityManager; +import jakarta.persistence.PersistenceContext; import org.assertj.core.util.Lists; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -21,6 +18,10 @@ import wooteco.prolog.studylog.domain.Studylog; import wooteco.support.utils.RepositoryTest; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + @RepositoryTest class CommentRepositoryTest { diff --git a/backend/src/test/java/wooteco/prolog/studylog/domain/repository/StudylogTagRepositoryTest.java b/backend/src/test/java/wooteco/prolog/studylog/domain/repository/StudylogTagRepositoryTest.java index 9206a24a2..53e22e54f 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/domain/repository/StudylogTagRepositoryTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/domain/repository/StudylogTagRepositoryTest.java @@ -1,9 +1,5 @@ package wooteco.prolog.studylog.domain.repository; -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.Arrays; -import java.util.List; import org.assertj.core.util.Lists; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -20,10 +16,15 @@ import wooteco.prolog.studylog.domain.Tag; import wooteco.support.utils.RepositoryTest; +import java.util.Arrays; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + @RepositoryTest class StudylogTagRepositoryTest { - private static final Member 웨지 = new Member("sihyung92", "웨지", Role.CREW, 2222L, + private final Member 웨지 = new Member("sihyung92", "웨지", Role.CREW, 2222L, "https://avatars.githubusercontent.com/u/51393021?v=4"); @Autowired diff --git a/backend/src/test/java/wooteco/prolog/studylog/mission/domain/repository/MissionRepositoryTest.java b/backend/src/test/java/wooteco/prolog/studylog/mission/domain/repository/MissionRepositoryTest.java index 362476ead..c6e200687 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/mission/domain/repository/MissionRepositoryTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/mission/domain/repository/MissionRepositoryTest.java @@ -1,8 +1,5 @@ package wooteco.prolog.studylog.mission.domain.repository; -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.Optional; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -13,6 +10,10 @@ import wooteco.prolog.session.domain.repository.SessionRepository; import wooteco.support.utils.RepositoryTest; +import java.util.Optional; + +import static org.assertj.core.api.Assertions.assertThat; + @RepositoryTest class MissionRepositoryTest { diff --git a/backend/src/test/java/wooteco/prolog/studylog/studylog/domain/ContentTest.java b/backend/src/test/java/wooteco/prolog/studylog/studylog/domain/ContentTest.java index 9fb640f31..eba393058 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/studylog/domain/ContentTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/studylog/domain/ContentTest.java @@ -1,13 +1,13 @@ package wooteco.prolog.studylog.studylog.domain; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_CONTENT_NULL_OR_EMPTY; - import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.studylog.domain.Content; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_CONTENT_NULL_OR_EMPTY; + class ContentTest { @DisplayName("값이 null이거나 empty면 예외") diff --git a/backend/src/test/java/wooteco/prolog/studylog/studylog/domain/TitleTest.java b/backend/src/test/java/wooteco/prolog/studylog/studylog/domain/TitleTest.java index 687beb5bd..e88906a79 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/studylog/domain/TitleTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/studylog/domain/TitleTest.java @@ -1,14 +1,14 @@ package wooteco.prolog.studylog.studylog.domain; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_TITLE_NULL_OR_EMPTY; - import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.studylog.domain.Title; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_TITLE_NULL_OR_EMPTY; + class TitleTest { @DisplayName("값이 null이거나 empty면 예외") diff --git a/backend/src/test/java/wooteco/prolog/studylog/studylog/domain/repository/StudylogReadRepositoryTest.java b/backend/src/test/java/wooteco/prolog/studylog/studylog/domain/repository/StudylogReadRepositoryTest.java index 8d8dcc3ce..1fba133ff 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/studylog/domain/repository/StudylogReadRepositoryTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/studylog/domain/repository/StudylogReadRepositoryTest.java @@ -1,9 +1,5 @@ package wooteco.prolog.studylog.studylog.domain.repository; -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.Collections; -import java.util.List; import org.assertj.core.util.Lists; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -22,13 +18,18 @@ import wooteco.prolog.studylog.domain.repository.StudylogRepository; import wooteco.support.utils.RepositoryTest; +import java.util.Collections; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + @RepositoryTest class StudylogReadRepositoryTest { - private static final Member 웨지 = new Member("sihyung92", "웨지", Role.CREW, 2222L, + private final Member 웨지 = new Member("sihyung92", "웨지", Role.CREW, 2222L, "https://avatars.githubusercontent.com/u/51393021?v=4"); - private static final Member 바다 = new Member("xrabcde", "바다", Role.CREW, 1111L, + private final Member 바다 = new Member("xrabcde", "바다", Role.CREW, 1111L, "https://avatars.githubusercontent.com/u/56033755?v=4"); private Studylog studylog; diff --git a/backend/src/test/java/wooteco/prolog/studylog/studylog/domain/repository/StudylogRepositoryTest.java b/backend/src/test/java/wooteco/prolog/studylog/studylog/domain/repository/StudylogRepositoryTest.java index 934abf0d9..f9c2178e3 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/studylog/domain/repository/StudylogRepositoryTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/studylog/domain/repository/StudylogRepositoryTest.java @@ -1,14 +1,5 @@ package wooteco.prolog.studylog.studylog.domain.repository; -import static java.util.Arrays.asList; -import static java.util.Collections.singletonList; -import static java.util.stream.Collectors.toList; -import static org.assertj.core.api.Assertions.assertThat; - -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -33,6 +24,16 @@ import wooteco.prolog.studylog.domain.repository.TagRepository; import wooteco.support.utils.RepositoryTest; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; + +import static java.util.Arrays.asList; +import static java.util.Collections.singletonList; +import static java.util.stream.Collectors.toList; +import static org.assertj.core.api.Assertions.assertThat; + @RepositoryTest class StudylogRepositoryTest { @@ -75,7 +76,7 @@ class StudylogRepositoryTest { private final Studylog studylog1 = new Studylog(member1, STUDYLOG1_TITLE, "피케이와 포모의 스터디로그", session1, mission1, asList(tag1, tag2)); private final Studylog studylog2 = new Studylog(member1, STUDYLOG2_TITLE, "피케이와 포모의 스터디로그 2", session1, mission1, asList(tag2, tag3)); private final Studylog studylog3 = new Studylog(member2, STUDYLOG3_TITLE, "피케이 스터디로그", session2, mission2, asList(tag3, tag4, tag5)); - private final Studylog studylog4 = new Studylog(member2, STUDYLOG4_TITLE, "포모의 스터디로그", session2, mission2, asList()); + private final Studylog studylog4 = new Studylog(member2, STUDYLOG4_TITLE, "포모의 스터디로그", session2, mission2, List.of()); @BeforeEach void setUp() { diff --git a/backend/src/test/java/wooteco/prolog/studylog/studylog/domain/repository/StudylogScrapRepositoryTest.java b/backend/src/test/java/wooteco/prolog/studylog/studylog/domain/repository/StudylogScrapRepositoryTest.java index 0637796cd..bb87db7db 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/studylog/domain/repository/StudylogScrapRepositoryTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/studylog/domain/repository/StudylogScrapRepositoryTest.java @@ -1,7 +1,5 @@ package wooteco.prolog.studylog.studylog.domain.repository; -import static org.assertj.core.api.Assertions.assertThat; - import org.assertj.core.util.Lists; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -20,10 +18,12 @@ import wooteco.prolog.studylog.domain.repository.StudylogScrapRepository; import wooteco.support.utils.RepositoryTest; +import static org.assertj.core.api.Assertions.assertThat; + @RepositoryTest public class StudylogScrapRepositoryTest { - private static final Member 웨지 = new Member("sihyung92", "웨지", Role.CREW, 2222L, + private final Member 웨지 = new Member("sihyung92", "웨지", Role.CREW, 2222L, "https://avatars.githubusercontent.com/u/51393021?v=4"); private Studylog studylog; diff --git a/backend/src/test/java/wooteco/prolog/studylog/studylog/util/StudylogFixture.java b/backend/src/test/java/wooteco/prolog/studylog/studylog/util/StudylogFixture.java index 9ba13acb6..b27643df7 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/studylog/util/StudylogFixture.java +++ b/backend/src/test/java/wooteco/prolog/studylog/studylog/util/StudylogFixture.java @@ -1,12 +1,6 @@ package wooteco.prolog.studylog.studylog.util; -import static java.util.EnumSet.allOf; - -import java.util.Arrays; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; -import javax.annotation.PostConstruct; +import jakarta.annotation.PostConstruct; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import wooteco.prolog.session.application.MissionService; @@ -21,6 +15,13 @@ import wooteco.prolog.studylog.application.dto.TagRequest; import wooteco.prolog.studylog.domain.Tags; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +import static java.util.EnumSet.allOf; + public enum StudylogFixture { 자동차_미션_정리("자동차 미션 정리", "부릉 부릉 자동차가 나가신다 부릉부릉", "자동차 미션", "임파시블세션", Tags.of( Arrays.asList("자동차", "전략 패턴", "부릉"))), diff --git a/backend/src/test/java/wooteco/prolog/studylog/studylogtag/domain/StudylogTagsTest.java b/backend/src/test/java/wooteco/prolog/studylog/studylogtag/domain/StudylogTagsTest.java index aef876591..eca0bbaf4 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/studylogtag/domain/StudylogTagsTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/studylogtag/domain/StudylogTagsTest.java @@ -1,10 +1,5 @@ package wooteco.prolog.studylog.studylogtag.domain; -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; import org.assertj.core.util.Lists; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -18,6 +13,12 @@ import wooteco.prolog.studylog.domain.StudylogTags; import wooteco.prolog.studylog.domain.Tag; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + public class StudylogTagsTest { private static final Member 웨지 = new Member("sihyung92", "웨지", Role.CREW, 2222L, diff --git a/backend/src/test/java/wooteco/prolog/studylog/studylogtag/domain/repository/StudylogTagRepositoryTest.java b/backend/src/test/java/wooteco/prolog/studylog/studylogtag/domain/repository/StudylogTagRepositoryTest.java index 922518e51..6d95736d9 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/studylogtag/domain/repository/StudylogTagRepositoryTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/studylogtag/domain/repository/StudylogTagRepositoryTest.java @@ -1,9 +1,5 @@ package wooteco.prolog.studylog.studylogtag.domain.repository; -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.Arrays; -import java.util.List; import org.assertj.core.util.Lists; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -23,10 +19,15 @@ import wooteco.prolog.studylog.domain.repository.TagRepository; import wooteco.support.utils.RepositoryTest; +import java.util.Arrays; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + @RepositoryTest class StudylogTagRepositoryTest { - private static final Member 웨지 = new Member("sihyung92", "웨지", Role.CREW, 2222L, + private final Member 웨지 = new Member("sihyung92", "웨지", Role.CREW, 2222L, "https://avatars.githubusercontent.com/u/51393021?v=4"); @Autowired diff --git a/backend/src/test/java/wooteco/prolog/studylog/tag/domain/TagNameTest.java b/backend/src/test/java/wooteco/prolog/studylog/tag/domain/TagNameTest.java index bb2255895..32e43d1de 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/tag/domain/TagNameTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/tag/domain/TagNameTest.java @@ -1,14 +1,14 @@ package wooteco.prolog.studylog.tag.domain; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static wooteco.prolog.common.exception.BadRequestCode.TAG_NAME_NULL_OR_EMPTY; - import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.studylog.domain.TagName; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static wooteco.prolog.common.exception.BadRequestCode.TAG_NAME_NULL_OR_EMPTY; + class TagNameTest { @DisplayName("값이 null이거나 empty면 예외") diff --git a/backend/src/test/java/wooteco/prolog/studylog/tag/domain/TagsTest.java b/backend/src/test/java/wooteco/prolog/studylog/tag/domain/TagsTest.java index e267a4571..97089d7df 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/tag/domain/TagsTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/tag/domain/TagsTest.java @@ -1,17 +1,18 @@ package wooteco.prolog.studylog.tag.domain; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static wooteco.prolog.common.exception.BadRequestCode.DUPLICATE_TAG; - -import java.util.Arrays; -import java.util.List; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.studylog.domain.Tag; import wooteco.prolog.studylog.domain.Tags; +import java.util.Arrays; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static wooteco.prolog.common.exception.BadRequestCode.DUPLICATE_TAG; + class TagsTest { private static final Tag 자바 = new Tag("자바"); diff --git a/backend/src/test/java/wooteco/prolog/studylog/tag/domain/repository/TagRepositoryTest.java b/backend/src/test/java/wooteco/prolog/studylog/tag/domain/repository/TagRepositoryTest.java index 5e893eb93..cc71472ed 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/tag/domain/repository/TagRepositoryTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/tag/domain/repository/TagRepositoryTest.java @@ -1,9 +1,5 @@ package wooteco.prolog.studylog.tag.domain.repository; -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.Arrays; -import java.util.List; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -11,6 +7,11 @@ import wooteco.prolog.studylog.domain.repository.TagRepository; import wooteco.support.utils.RepositoryTest; +import java.util.Arrays; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + @RepositoryTest class TagRepositoryTest { diff --git a/backend/src/test/java/wooteco/support/autoceptor/AutoInterceptorPatternMakerTest.java b/backend/src/test/java/wooteco/support/autoceptor/AutoInterceptorPatternMakerTest.java index 856327aea..0242eed63 100644 --- a/backend/src/test/java/wooteco/support/autoceptor/AutoInterceptorPatternMakerTest.java +++ b/backend/src/test/java/wooteco/support/autoceptor/AutoInterceptorPatternMakerTest.java @@ -1,12 +1,13 @@ package wooteco.support.autoceptor; -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.List; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import wooteco.prolog.login.domain.AuthMemberPrincipal; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + class AutoInterceptorPatternMakerTest { @DisplayName("URI Patterns를 반환한다.") diff --git a/backend/src/test/java/wooteco/support/autoceptor/ClassScannerTest.java b/backend/src/test/java/wooteco/support/autoceptor/ClassScannerTest.java index 30590b059..bedd7b3f4 100644 --- a/backend/src/test/java/wooteco/support/autoceptor/ClassScannerTest.java +++ b/backend/src/test/java/wooteco/support/autoceptor/ClassScannerTest.java @@ -1,8 +1,5 @@ package wooteco.support.autoceptor; -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.Set; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import wooteco.support.autoceptor.scanner.ClassScanner; @@ -10,6 +7,10 @@ import wooteco.support.autoceptor.test_classes.NormalClass; import wooteco.support.autoceptor.test_classes.RestControllerClass; +import java.util.Set; + +import static org.assertj.core.api.Assertions.assertThat; + class ClassScannerTest { @DisplayName("하위 패키지의 모든 컨트롤러를 파싱한다.") diff --git a/backend/src/test/java/wooteco/support/autoceptor/ControllerScannerTest.java b/backend/src/test/java/wooteco/support/autoceptor/ControllerScannerTest.java index c17533a77..43d940163 100644 --- a/backend/src/test/java/wooteco/support/autoceptor/ControllerScannerTest.java +++ b/backend/src/test/java/wooteco/support/autoceptor/ControllerScannerTest.java @@ -1,8 +1,5 @@ package wooteco.support.autoceptor; -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.List; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import wooteco.support.autoceptor.scanner.ControllerScanner; @@ -10,6 +7,10 @@ import wooteco.support.autoceptor.test_classes.NormalClass; import wooteco.support.autoceptor.test_classes.RestControllerClass; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + class ControllerScannerTest { @DisplayName("클래스 리스트 중에서 컨트롤러 클래스만 추출한다.") diff --git a/backend/src/test/java/wooteco/support/autoceptor/MappingAnnotationTest.java b/backend/src/test/java/wooteco/support/autoceptor/MappingAnnotationTest.java index b2e1b274c..bd6c7c558 100644 --- a/backend/src/test/java/wooteco/support/autoceptor/MappingAnnotationTest.java +++ b/backend/src/test/java/wooteco/support/autoceptor/MappingAnnotationTest.java @@ -1,12 +1,5 @@ package wooteco.support.autoceptor; -import static java.util.stream.Collectors.toList; -import static org.assertj.core.api.Assertions.assertThat; - -import java.lang.reflect.Member; -import java.lang.reflect.Method; -import java.util.Collection; -import java.util.List; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.web.bind.annotation.DeleteMapping; @@ -17,6 +10,14 @@ import wooteco.support.autoceptor.scanner.MappingAnnotation; import wooteco.support.autoceptor.scanner.MethodScanner; +import java.lang.reflect.Member; +import java.lang.reflect.Method; +import java.util.Collection; +import java.util.List; + +import static java.util.stream.Collectors.toList; +import static org.assertj.core.api.Assertions.assertThat; + class MappingAnnotationTest { @DisplayName("스프링 Mapping annotation 에서 Uri를 파싱한다.") diff --git a/backend/src/test/java/wooteco/support/autoceptor/MethodPatternTest.java b/backend/src/test/java/wooteco/support/autoceptor/MethodPatternTest.java index 6f6f7247e..bf235686f 100644 --- a/backend/src/test/java/wooteco/support/autoceptor/MethodPatternTest.java +++ b/backend/src/test/java/wooteco/support/autoceptor/MethodPatternTest.java @@ -1,9 +1,6 @@ package wooteco.support.autoceptor; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.BDDMockito.given; - -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; import org.junit.jupiter.api.extension.ExtendWith; @@ -13,6 +10,9 @@ import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.http.HttpMethod; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.given; + @DisplayNameGeneration(ReplaceUnderscores.class) @SuppressWarnings("NonAsciiCharacters") @ExtendWith(MockitoExtension.class) diff --git a/backend/src/test/java/wooteco/support/autoceptor/MethodScannerTest.java b/backend/src/test/java/wooteco/support/autoceptor/MethodScannerTest.java index 4175ac911..99a0c183d 100644 --- a/backend/src/test/java/wooteco/support/autoceptor/MethodScannerTest.java +++ b/backend/src/test/java/wooteco/support/autoceptor/MethodScannerTest.java @@ -1,13 +1,5 @@ package wooteco.support.autoceptor; -import static java.util.stream.Collectors.toList; -import static org.assertj.core.api.Assertions.assertThat; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import wooteco.prolog.login.domain.AuthMemberPrincipal; @@ -15,6 +7,15 @@ import wooteco.support.autoceptor.test_classes.ControllerClass; import wooteco.support.autoceptor.test_classes.RestControllerClass; +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import static java.util.stream.Collectors.toList; +import static org.assertj.core.api.Assertions.assertThat; + class MethodScannerTest { @DisplayName("특정 어노테이션이 파라메터에 적용된 메서드를 반환한다.") diff --git a/backend/src/test/java/wooteco/support/autoceptor/URIScannerTest.java b/backend/src/test/java/wooteco/support/autoceptor/URIScannerTest.java index 35f2feea6..124d8e2a2 100644 --- a/backend/src/test/java/wooteco/support/autoceptor/URIScannerTest.java +++ b/backend/src/test/java/wooteco/support/autoceptor/URIScannerTest.java @@ -1,11 +1,5 @@ package wooteco.support.autoceptor; -import static org.assertj.core.api.Assertions.assertThat; - -import java.lang.annotation.Annotation; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.springframework.http.HttpMethod; @@ -16,6 +10,13 @@ import wooteco.support.autoceptor.test_classes.ControllerClass; import wooteco.support.autoceptor.test_classes.RestControllerClass; +import java.lang.annotation.Annotation; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + class URIScannerTest { @Test diff --git a/backend/src/test/java/wooteco/support/autoceptor/test_classes/ControllerClass.java b/backend/src/test/java/wooteco/support/autoceptor/test_classes/ControllerClass.java index 1e41921e4..f6430f513 100644 --- a/backend/src/test/java/wooteco/support/autoceptor/test_classes/ControllerClass.java +++ b/backend/src/test/java/wooteco/support/autoceptor/test_classes/ControllerClass.java @@ -1,6 +1,5 @@ package wooteco.support.autoceptor.test_classes; -import javax.websocket.server.PathParam; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -17,7 +16,7 @@ public void annotationExists(@AuthMemberPrincipal Member member) { } @DeleteMapping("/test/{testId}") - public void pattern(@AuthMemberPrincipal Member member, @PathParam("testId") Long testId) { + public void pattern(@AuthMemberPrincipal Member member, @jakarta.websocket.server.PathParam("testId") Long testId) { } } diff --git a/backend/src/test/java/wooteco/support/utils/RepositoryTest.java b/backend/src/test/java/wooteco/support/utils/RepositoryTest.java index 571c8f536..ff684c9e5 100644 --- a/backend/src/test/java/wooteco/support/utils/RepositoryTest.java +++ b/backend/src/test/java/wooteco/support/utils/RepositoryTest.java @@ -1,11 +1,12 @@ package wooteco.support.utils; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.transaction.annotation.Transactional; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.transaction.annotation.Transactional; @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) diff --git a/search/.env b/search/.env deleted file mode 100644 index 63ec3f1f2..000000000 --- a/search/.env +++ /dev/null @@ -1 +0,0 @@ -ELK_VERSION=7.14.0 diff --git a/search/HELP.md b/search/HELP.md deleted file mode 100644 index bcf03ce27..000000000 --- a/search/HELP.md +++ /dev/null @@ -1,9 +0,0 @@ -## How to run - -### How to run docker-compose in /deprecated -cd deprecated -docker-compose up -d - -### How to run docker-compose-{profile}.yml in /search -docker-compose -f docker-compose-{profile}.yml up -d - diff --git a/search/deprecated/docker-compose.yml b/search/deprecated/docker-compose.yml deleted file mode 100644 index 45a4f6046..000000000 --- a/search/deprecated/docker-compose.yml +++ /dev/null @@ -1,104 +0,0 @@ -version: '3.3' -services: - es01: - build: - context: elasticsearch/ - args: - ELK_VERSION: $ELK_VERSION - # image: docker.elastic.co/elasticsearch/elasticsearch:7.14.0 - container_name: es01 - environment: - - node.name=es01 - - cluster.name=es-docker-cluster - - discovery.seed_hosts=es02,es03 - - cluster.initial_master_nodes=es01,es02,es03 - - bootstrap.memory_lock=true - - "ES_JAVA_OPTS=-Xms512m -Xmx512m" - ulimits: - memlock: - soft: -1 - hard: -1 - nofile: - soft: 65535 - hard: 65535 - volumes: - - data01:/usr/share/elasticsearch/data - ports: - - 9200:9200 - networks: - - elastic - - es02: - build: - context: elasticsearch/ - args: - ELK_VERSION: $ELK_VERSION - # image: docker.elastic.co/elasticsearch/elasticsearch:7.14.0 - container_name: es02 - environment: - - node.name=es02 - - cluster.name=es-docker-cluster - - discovery.seed_hosts=es01,es03 - - cluster.initial_master_nodes=es01,es02,es03 - - bootstrap.memory_lock=true - - "ES_JAVA_OPTS=-Xms512m -Xmx512m" - ulimits: - memlock: - soft: -1 - hard: -1 - nofile: - soft: 65535 - hard: 65535 - volumes: - - data02:/usr/share/elasticsearch/data - networks: - - elastic - - es03: - build: - context: elasticsearch/ - args: - ELK_VERSION: $ELK_VERSION - # image: docker.elastic.co/elasticsearch/elasticsearch:7.14.0 - container_name: es03 - environment: - - node.name=es03 - - cluster.name=es-docker-cluster - - discovery.seed_hosts=es01,es02 - - cluster.initial_master_nodes=es01,es02,es03 - - bootstrap.memory_lock=true - - "ES_JAVA_OPTS=-Xms512m -Xmx512m" - ulimits: - memlock: - soft: -1 - hard: -1 - nofile: - soft: 65535 - hard: 65535 - volumes: - - data03:/usr/share/elasticsearch/data - networks: - - elastic - - kib01: - image: docker.elastic.co/kibana/kibana:7.14.0 - container_name: kib01 - ports: - - 5601:5601 - environment: - ELASTICSEARCH_URL: http://es01:9200 - ELASTICSEARCH_HOSTS: '["http://es01:9200","http://es02:9200","http://es03:9200"]' - networks: - - elastic - -volumes: - data01: - driver: local - data02: - driver: local - data03: - driver: local - -networks: - elastic: - driver: bridge diff --git a/search/docker-compose-dev.yml b/search/docker-compose-dev.yml deleted file mode 100644 index 387d37d8e..000000000 --- a/search/docker-compose-dev.yml +++ /dev/null @@ -1,110 +0,0 @@ -version: '3.3' -services: - es01: - build: - context: elasticsearch/ - args: - ELK_VERSION: $ELK_VERSION - # image: docker.elastic.co/elasticsearch/elasticsearch:7.14.0 - container_name: es01 - environment: - - node.name=es01 - - cluster.name=es-docker-cluster - - discovery.seed_hosts=es02,es03 - - cluster.initial_master_nodes=es01,es02,es03 - - bootstrap.memory_lock=true - - "ES_JAVA_OPTS=-Xms512m -Xmx512m" - ulimits: - memlock: - soft: -1 - hard: -1 - nofile: - soft: 65535 - hard: 65535 - volumes: - - data01:/usr/share/elasticsearch/data - ports: - - 9200:9200 - networks: - - elastic - logging: - driver: awslogs - options: - awslogs-group: "prolog-es-stack-log" - awslogs-region: "ap-northeast-2" - awslogs-stream: "dev-es01-log" - - es02: - build: - context: elasticsearch/ - args: - ELK_VERSION: $ELK_VERSION - # image: docker.elastic.co/elasticsearch/elasticsearch:7.14.0 - container_name: es02 - environment: - - node.name=es02 - - cluster.name=es-docker-cluster - - discovery.seed_hosts=es01,es03 - - cluster.initial_master_nodes=es01,es02,es03 - - bootstrap.memory_lock=true - - "ES_JAVA_OPTS=-Xms512m -Xmx512m" - ulimits: - memlock: - soft: -1 - hard: -1 - nofile: - soft: 65535 - hard: 65535 - volumes: - - data02:/usr/share/elasticsearch/data - networks: - - elastic - - es03: - build: - context: elasticsearch/ - args: - ELK_VERSION: $ELK_VERSION - # image: docker.elastic.co/elasticsearch/elasticsearch:7.14.0 - container_name: es03 - environment: - - node.name=es03 - - cluster.name=es-docker-cluster - - discovery.seed_hosts=es01,es02 - - cluster.initial_master_nodes=es01,es02,es03 - - bootstrap.memory_lock=true - - "ES_JAVA_OPTS=-Xms512m -Xmx512m" - ulimits: - memlock: - soft: -1 - hard: -1 - nofile: - soft: 65535 - hard: 65535 - volumes: - - data03:/usr/share/elasticsearch/data - networks: - - elastic - - kib01: - image: docker.elastic.co/kibana/kibana:7.14.1 - container_name: kib01 - ports: - - 5601:5601 - environment: - ELASTICSEARCH_URL: http://es01:9200 - ELASTICSEARCH_HOSTS: '["http://es01:9200","http://es02:9200","http://es03:9200"]' - networks: - - elastic - -volumes: - data01: - driver: local - data02: - driver: local - data03: - driver: local - -networks: - elastic: - driver: bridge diff --git a/search/docker-compose-prod.yml b/search/docker-compose-prod.yml deleted file mode 100644 index 4c313bbec..000000000 --- a/search/docker-compose-prod.yml +++ /dev/null @@ -1,110 +0,0 @@ -version: '3.3' -services: - es01: - build: - context: elasticsearch/ - args: - ELK_VERSION: $ELK_VERSION - # image: docker.elastic.co/elasticsearch/elasticsearch:7.14.0 - container_name: es01 - environment: - - node.name=es01 - - cluster.name=es-docker-cluster - - discovery.seed_hosts=es02,es03 - - cluster.initial_master_nodes=es01,es02,es03 - - bootstrap.memory_lock=true - - "ES_JAVA_OPTS=-Xms512m -Xmx512m" - ulimits: - memlock: - soft: -1 - hard: -1 - nofile: - soft: 65535 - hard: 65535 - volumes: - - data01:/usr/share/elasticsearch/data - ports: - - 9200:9200 - networks: - - elastic - logging: - driver: awslogs - options: - awslogs-group: "prolog-es-stack-log" - awslogs-region: "ap-northeast-2" - awslogs-stream: "prod-es01-log" - - es02: - build: - context: elasticsearch/ - args: - ELK_VERSION: $ELK_VERSION - # image: docker.elastic.co/elasticsearch/elasticsearch:7.14.0 - container_name: es02 - environment: - - node.name=es02 - - cluster.name=es-docker-cluster - - discovery.seed_hosts=es01,es03 - - cluster.initial_master_nodes=es01,es02,es03 - - bootstrap.memory_lock=true - - "ES_JAVA_OPTS=-Xms512m -Xmx512m" - ulimits: - memlock: - soft: -1 - hard: -1 - nofile: - soft: 65535 - hard: 65535 - volumes: - - data02:/usr/share/elasticsearch/data - networks: - - elastic - - es03: - build: - context: elasticsearch/ - args: - ELK_VERSION: $ELK_VERSION - # image: docker.elastic.co/elasticsearch/elasticsearch:7.14.0 - container_name: es03 - environment: - - node.name=es03 - - cluster.name=es-docker-cluster - - discovery.seed_hosts=es01,es02 - - cluster.initial_master_nodes=es01,es02,es03 - - bootstrap.memory_lock=true - - "ES_JAVA_OPTS=-Xms512m -Xmx512m" - ulimits: - memlock: - soft: -1 - hard: -1 - nofile: - soft: 65535 - hard: 65535 - volumes: - - data03:/usr/share/elasticsearch/data - networks: - - elastic - - kib01: - image: docker.elastic.co/kibana/kibana:7.14.1 - container_name: kib01 - ports: - - 5601:5601 - environment: - ELASTICSEARCH_URL: http://es01:9200 - ELASTICSEARCH_HOSTS: '["http://es01:9200","http://es02:9200","http://es03:9200"]' - networks: - - elastic - -volumes: - data01: - driver: local - data02: - driver: local - data03: - driver: local - -networks: - elastic: - driver: bridge diff --git a/search/elasticsearch/Dockerfile b/search/elasticsearch/Dockerfile deleted file mode 100644 index 8286b9f3d..000000000 --- a/search/elasticsearch/Dockerfile +++ /dev/null @@ -1,8 +0,0 @@ -ARG ELK_VERSION - -# https://www.docker.elastic.co/ -FROM docker.elastic.co/elasticsearch/elasticsearch:${ELK_VERSION} - -# Add your elasticsearch plugins setup here -# Example: RUN elasticsearch-plugin install analysis-icu -RUN elasticsearch-plugin install analysis-nori \ No newline at end of file diff --git a/search/elasticsearch/config/elasticsearch.yml b/search/elasticsearch/config/elasticsearch.yml deleted file mode 100644 index 03af20cac..000000000 --- a/search/elasticsearch/config/elasticsearch.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -## Default Elasticsearch configuration from Elasticsearch base image. -## https://github.com/elastic/elasticsearch/blob/master/distribution/docker/src/docker/config/elasticsearch.yml -# - -## X-Pack settings -## see https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-xpack.html -# -xpack.license.self_generated.type: trial -xpack.security.enabled: true -xpack.monitoring.collection.enabled: true diff --git a/search/mapping-index-and-sync/HELP.md b/search/mapping-index-and-sync/HELP.md deleted file mode 100644 index c97524e6e..000000000 --- a/search/mapping-index-and-sync/HELP.md +++ /dev/null @@ -1,3 +0,0 @@ -## HOW TO RUN -chmod 744 mapping-index-and-sync.sh -sh ./mapping-index-and-sync.sh diff --git a/search/mapping-index-and-sync/mapping-index-and-sync.sh b/search/mapping-index-and-sync/mapping-index-and-sync.sh deleted file mode 100644 index 80cda187e..000000000 --- a/search/mapping-index-and-sync/mapping-index-and-sync.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash - -DEV_API="https://dev-api.prolog.techcourse.co.kr" -PROD_API="https://api.prolog.techcourse.co.kr" -USE_API="" - -if [ $USER = "ELASTIC-STACK-DEV" ];then - USE_API=${DEV_API} -else - USE_API=${PROD_API} -fi - -curl -X PUT "localhost:9200/studylog-document?pretty" -H 'Content-Type: application/json' -d' -{ - "settings":{ - "index":{ - "analysis":{ - "tokenizer":{ - "nori_tokenizer_mixed_dict":{ - "type":"nori_tokenizer", - "decompound_mode":"mixed" - } - }, - "analyzer": { - "korean":{ - "type":"custom", - "tokenizer":"nori_tokenizer_mixed_dict", - "filter":[ - "nori_readingform","lowercase", - "nori_part_of_speech_basic"] - } - }, - "filter":{ - "nori_part_of_speech_basic":{ - "type":"nori_part_of_speech", - "stoptags":["E","IC","J","MAG","MAJ","MM","SP","SSC","SSO","SC","SE","XPN","XSA","XSN","XSV","UNA","NA","VSV"] - } - } - } - } - } -} -' - -curl -v ${USE_API}/sync diff --git a/terraform/backend.tf b/terraform/backend.tf new file mode 100644 index 000000000..1f908b9a8 --- /dev/null +++ b/terraform/backend.tf @@ -0,0 +1,9 @@ +terraform { + cloud { + organization = "cholog" + + workspaces { + name = "cholog" + } + } +} diff --git a/terraform/environments/dev/deploy.sh b/terraform/environments/dev/deploy.sh new file mode 100644 index 000000000..aecde98e1 --- /dev/null +++ b/terraform/environments/dev/deploy.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# 현재 작업 디렉토리 이름 가져오기 (dev, prod 등) +ENVIRONMENT=$(basename "$PWD") + +# 워크스페이스 선택 또는 생성 +terraform workspace select "$ENVIRONMENT" || terraform workspace new "$ENVIRONMENT" + +# 변경 사항 계획 +terraform plan -out=tfplan + +# 변경 사항 적용 +terraform apply tfplan diff --git a/terraform/environments/dev/main.tf b/terraform/environments/dev/main.tf new file mode 100644 index 000000000..e30525842 --- /dev/null +++ b/terraform/environments/dev/main.tf @@ -0,0 +1,85 @@ +module "tags" { + source = "../../modules/tags" + + project_name = var.project_name + environment = var.environment +} + +module "compute" { + source = "../../modules/compute" + + project_name = var.project_name +} + + +module "network" { + source = "../../modules/network" + + region = var.region + project_name = var.project_name + server_tags = module.tags.server_tags + gateway_tags = module.tags.gateway_tags +} + +module "storage" { + source = "../../modules/storage" + + bucket_name = var.bucket_name + project_name = var.project_name + storage_tags = module.tags.storage_tags +} + +module "iam" { + source = "../../modules/iam" + + project_name = var.project_name + bucket_arns = [ + module.storage.bucket_arn, + "${module.storage.bucket_arn}/*" + ] +} + +module "bastion" { + source = "../../modules/bastion" + + vpc_id = module.network.vpc_id + project_name = var.project_name + ami_id = module.compute.ami_id + key_pair_name = module.compute.key_pair_name + public_subnet_ids = module.network.public_subnet_ids + server_tags = module.tags.server_tags + +} + +module "application" { + source = "../../modules/application" + + vpc_id = module.network.vpc_id + project_name = var.project_name + environment = var.environment + ec2_role_name = module.iam.ec2_role_name + bucket_name = module.storage.bucket_name + region = var.region + code_deploy_role_arn = module.iam.code_deploy_role_arn + ami_id = module.compute.ami_id + key_pair_name = module.compute.key_pair_name + bastion_sg_id = module.bastion.bastion_sg_id + private_subnet_ids = module.network.private_subnet_ids + public_subnet_ids = module.network.public_subnet_ids + service_worker_tags = module.tags.service_worker_tags + server_tags = module.tags.server_tags +} + +module "database" { + source = "../../modules/database" + + vpc_id = module.network.vpc_id + project_name = var.project_name + db_name = var.db_name + secret_name = var.db_secret_name + ingress_security_group_ids = [module.application.application_sg_id, module.bastion.bastion_sg_id] + + private_subnet_ids = module.network.private_subnet_ids + server_tags = module.tags.server_tags + database_tags = module.tags.database_tags +} diff --git a/terraform/environments/dev/outputs.tf b/terraform/environments/dev/outputs.tf new file mode 100644 index 000000000..f00afaffa --- /dev/null +++ b/terraform/environments/dev/outputs.tf @@ -0,0 +1,80 @@ +# Network +output "vpc_id" { + description = "VPC ID created by the network module" + value = module.network.vpc_id +} + +output "public_subnet_ids" { + description = "Public subnet IDs created by the network module" + value = module.network.public_subnet_ids +} + +output "private_subnet_ids" { + description = "Private subnet IDs created by the network module" + value = module.network.private_subnet_ids +} + +# Storage +output "bucket_arn" { + description = "Bucket ARN created by the storage module" + value = module.storage.bucket_arn +} + +output "bucket_name" { + description = "Bucket name created by the storage module" + value = module.storage.bucket_name +} + +# IAM +output "ec2_role_name" { + description = "EC2 IAM role name created by the IAM module" + value = module.iam.ec2_role_name +} + +output "s3_policy_arn" { + description = "S3 access policy ARN created by the IAM module" + value = module.iam.s3_access_policy_arn +} + +# Bastion +output "bastion_sg_id" { + description = "Security Group ID for the Bastion host" + value = module.bastion.bastion_sg_id +} + +output "bastion_eip" { + description = "Elastic IP address for the Bastion host" + value = module.bastion.bastion_eip_allocation_id +} + +# Application +output "application_sg_id" { + description = "Security Group ID for the application instances" + value = module.application.application_sg_id +} + +output "application_asg_name" { + description = "Name of the Auto Scaling Group for application instances" + value = module.application.asg_name +} + +output "application_launch_template_id" { + description = "Launch Template ID for application instances" + value = module.application.launch_template_id +} + +# Database +output "database_endpoint" { + description = "Endpoint of the RDS database" + value = module.database.db_instance_endpoint +} + +output "database_id" { + description = "ID of the RDS database instance" + value = module.database.db_instance_id +} + +output "database_sg_id" { + description = "Security Group ID for the database" + value = module.database.database_sg_id +} diff --git a/terraform/environments/dev/variables.tf b/terraform/environments/dev/variables.tf new file mode 100644 index 000000000..04bbb23c5 --- /dev/null +++ b/terraform/environments/dev/variables.tf @@ -0,0 +1,21 @@ +variable "region" { + default = "ap-northeast-2" +} +variable "project_name" { + default = "prolog-dev" +} +variable "environment" { + default = "dev" +} +variable "bucket_name" { + default = "prolog-dev-bucket" +} +variable "key_pair_name" { + default = "prolog-dev" +} +variable "db_name" { + default = "prolog" +} +variable "db_secret_name" { + default = "secrets/prolog_dev" +} diff --git a/terraform/modules/application/main.tf b/terraform/modules/application/main.tf new file mode 100644 index 000000000..629a456fd --- /dev/null +++ b/terraform/modules/application/main.tf @@ -0,0 +1,310 @@ +resource "aws_security_group" "alb_sg" { + vpc_id = var.vpc_id + + ingress { + from_port = 80 + to_port = 80 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + description = "Allow HTTP traffic" + } + ingress { + from_port = 443 + to_port = 443 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + description = "Allow HTTPS traffic" + } + + egress { + from_port = 0 + to_port = 0 + protocol = "-1" + cidr_blocks = ["0.0.0.0/0"] + } + + tags = merge(var.server_tags, { + Name = "${var.project_name}_alb_sg" + }) +} + +resource "aws_lb" "alb" { + name = "${var.project_name}-alb" + internal = false + load_balancer_type = "application" + security_groups = [aws_security_group.alb_sg.id] + subnets = var.public_subnet_ids + + tags = merge(var.service_worker_tags, { + Name = "${var.project_name}_alb" + }) +} + +resource "aws_lb_target_group" "tg" { + name = "${var.project_name}-tg" + port = 8080 + protocol = "HTTP" + vpc_id = var.vpc_id + + health_check { + path = "/elb-health" + interval = 30 + timeout = 5 + healthy_threshold = 2 + unhealthy_threshold = 2 + } + + tags = merge(var.service_worker_tags, { + Name = "${var.project_name}_tg" + }) +} + +resource "aws_lb_listener" "lb_http" { + load_balancer_arn = aws_lb.alb.arn + port = 80 + protocol = "HTTP" + + default_action { + type = "redirect" + + redirect { + protocol = "HTTPS" + port = "443" + status_code = "HTTP_301" + } + } + + tags = merge(var.service_worker_tags, { + Name = "${var.project_name}_lb_http" + }) +} + +// Note: 기존에 있는 인증서 사용 +data "aws_acm_certificate" "certificate" { + domain = "prolog.techcourse.co.kr" + statuses = ["ISSUED"] + most_recent = true +} + +resource "aws_lb_listener" "lb_https" { + load_balancer_arn = aws_lb.alb.arn + port = 443 + protocol = "HTTPS" + ssl_policy = "ELBSecurityPolicy-TLS13-1-2-2021-06" + certificate_arn = data.aws_acm_certificate.certificate.arn + + default_action { + type = "forward" + target_group_arn = aws_lb_target_group.tg.arn + } + + tags = merge(var.service_worker_tags, { + Name = "${var.project_name}_lb_https" + }) +} + +resource "aws_autoscaling_group" "asg" { + launch_template { + id = aws_launch_template.ec2_launch_template.id + version = "$Latest" + } + + max_size = 4 + min_size = 1 + desired_capacity = 1 + vpc_zone_identifier = var.private_subnet_ids + + // Note: 이후 target_group_arns는 CodeDeploy에서 알아서 관리 예정 + target_group_arns = [ + aws_lb_target_group.tg.arn + ] + + dynamic "tag" { + for_each = var.server_tags + content { + key = tag.key + value = tag.value + propagate_at_launch = true + } + } + tag { + key = "Environment" + value = var.environment + propagate_at_launch = true + } + tag { + key = "Name" + value = var.project_name + propagate_at_launch = true + } +} + +data "aws_ami" "ec2_ami" { + most_recent = true + owners = ["amazon"] + filter { + name = "name" + values = ["amzn2-ami-hvm-*-arm64-gp2"] + } +} + +resource "aws_security_group" "application_sg" { + vpc_id = var.vpc_id + + ingress { + from_port = 8080 + to_port = 8080 + protocol = "tcp" + security_groups = [aws_security_group.alb_sg.id] + } + + ingress { + from_port = 22 + to_port = 22 + protocol = "tcp" + security_groups = [var.bastion_sg_id] + } + + egress { + from_port = 0 + to_port = 0 + protocol = "-1" + cidr_blocks = ["0.0.0.0/0"] + } + + tags = merge(var.server_tags, { + Name = "${var.project_name}_application_sg" + }) +} + +resource "aws_iam_instance_profile" "ec2_instance_profile" { + name = "${var.project_name}-ec2-instance-profile" + role = var.ec2_role_name + + tags = merge(var.service_worker_tags, { + Name = "${var.project_name}_ec2instance_profile" + }) +} + +resource "aws_launch_template" "ec2_launch_template" { + name = "${var.project_name}-ec2-launch-template" + image_id = var.ami_id + instance_type = "t4g.small" + key_name = var.key_pair_name + + user_data = base64encode(templatefile("${path.module}/templates/user_data.tpl", { + environment = var.environment, + bucket_name = var.bucket_name, + region = var.region + })) + + network_interfaces { + security_groups = [aws_security_group.application_sg.id] + associate_public_ip_address = false + } + + iam_instance_profile { + name = aws_iam_instance_profile.ec2_instance_profile.name + } + + monitoring { + enabled = true + } + + tags = merge(var.service_worker_tags, { + Name = "${var.project_name}_ec2_launch_template" + }) +} + +resource "aws_codedeploy_app" "deploy" { + name = "${var.project_name}-code-deploy" + + tags = merge(var.server_tags, { + Name = "${var.project_name}_code_deploy" + }) +} + +resource "aws_codedeploy_deployment_group" "deployment_group" { + app_name = aws_codedeploy_app.deploy.name + deployment_group_name = var.project_name + service_role_arn = var.code_deploy_role_arn + + autoscaling_groups = [aws_autoscaling_group.asg.name] + + deployment_style { + deployment_type = "IN_PLACE" + } + + auto_rollback_configuration { + enabled = true + events = ["DEPLOYMENT_FAILURE"] + } +} + +/* +resource "aws_lb_target_group" "tg_blue" { + name = "${var.project_name}-tg-blue" + port = 80 + protocol = "HTTP" + vpc_id = var.vpc_id + + tags = merge(var.service_worker_tags, { + Name = "${var.project_name}_tg_blue" + }) +} + +resource "aws_lb_target_group" "tg_green" { + name = "${var.project_name}-tg-green" + port = 80 + protocol = "HTTP" + vpc_id = var.vpc_id + + tags = merge(var.service_worker_tags, { + Name = "${var.project_name}_tg_green" + }) +} + +resource "aws_codedeploy_deployment_group" "deployment_group" { + app_name = aws_codedeploy_app.deploy.name + deployment_group_name = var.project_name + service_role_arn = var.code_deploy_role_arn + + autoscaling_groups = [aws_autoscaling_group.asg.name] + + deployment_style { + deployment_type = "BLUE_GREEN" + deployment_option = "WITH_TRAFFIC_CONTROL" + } + + auto_rollback_configuration { + enabled = true + events = ["DEPLOYMENT_FAILURE"] + } + + blue_green_deployment_config { + terminate_blue_instances_on_deployment_success { + action = "TERMINATE" + termination_wait_time_in_minutes = 10 + } + + deployment_ready_option { + action_on_timeout = "STOP_DEPLOYMENT" + wait_time_in_minutes = 10 + } + } + + load_balancer_info { + target_group_pair_info { + target_group { + name = aws_lb_target_group.tg_blue.name + } + target_group { + name = aws_lb_target_group.tg_green.name + } + prod_traffic_route { + listener_arns = [aws_lb_listener.lb_https.arn] + } + } + } +} + */ diff --git a/terraform/modules/application/outputs.tf b/terraform/modules/application/outputs.tf new file mode 100644 index 000000000..5764f45cb --- /dev/null +++ b/terraform/modules/application/outputs.tf @@ -0,0 +1,65 @@ +output "alb_sg_id" { + description = "Security Group ID for the Application Load Balancer" + value = aws_security_group.alb_sg.id +} + +output "alb_arn" { + description = "ARN of the Application Load Balancer" + value = aws_lb.alb.arn +} + +output "alb_dns_name" { + description = "DNS name of the Application Load Balancer" + value = aws_lb.alb.dns_name +} + +output "alb_target_group_arn" { + description = "ARN of the Target Group" + value = aws_lb_target_group.tg.arn +} + + +output "alb_http_listener_arn" { + description = "ARN of the HTTP Listener" + value = aws_lb_listener.lb_http.arn +} + +output "alb_https_listener_arn" { + description = "ARN of the HTTPS Listener" + value = aws_lb_listener.lb_https.arn +} + +output "asg_name" { + description = "Name of the Auto Scaling Group" + value = aws_autoscaling_group.asg.name +} + +output "asg_arn" { + description = "ARN of the Auto Scaling Group" + value = aws_autoscaling_group.asg.arn +} + +output "application_sg_id" { + description = "Security Group ID for the application instances" + value = aws_security_group.application_sg.id +} + +output "launch_template_id" { + description = "ID of the EC2 Launch Template" + value = aws_launch_template.ec2_launch_template.id +} + +output "launch_template_name" { + description = "Name of the EC2 Launch Template" + value = aws_launch_template.ec2_launch_template.name +} + +output "ami_id" { + description = "ID of the AMI used in the Launch Template" + value = data.aws_ami.ec2_ami.id +} + +output "certificate_arn" { + description = "ARN of the ACM certificate used for HTTPS Listener" + value = data.aws_acm_certificate.certificate.arn +} diff --git a/terraform/modules/application/templates/user_data.tpl b/terraform/modules/application/templates/user_data.tpl new file mode 100644 index 000000000..3d8ae5861 --- /dev/null +++ b/terraform/modules/application/templates/user_data.tpl @@ -0,0 +1,35 @@ +#!/bin/bash -xe +# Set profiles +echo "export SPRING_PROFILES_ACTIVE=${environment}" | sudo tee -a /etc/environment +source /etc/environment + +# Set Timezone +sudo timedatectl set-timezone Asia/Seoul + +# Set Java +sudo wget https://corretto.aws/downloads/latest/amazon-corretto-21-aarch64-linux-jdk.rpm +sudo yum localinstall -y amazon-corretto-21-aarch64-linux-jdk.rpm + +# Set Code Deploy Agent +sudo yum install -y ruby +sudo yum install -y wget +cd /home/ec2-user +wget https://aws-codedeploy-${region}.s3.${region}.amazonaws.com/latest/install +chmod +x ./install +sudo ./install auto +sudo service codedeploy-agent start +sudo systemctl enable codedeploy-agent + +# Create and grant logging folder +sudo mkdir -p /logs/error +sudo chmod -R 755 /logs +sudo chown -R ec2-user:ec2-user /logs + +# Download application from S3 +aws s3 cp s3://${bucket_name}/app.zip /home/ec2-user/app.zip + +# Unzip +unzip app.zip + +# Start the application +nohup java -jar /home/ec2-user/app.jar > /home/ec2-user/app.log 2>&1 & diff --git a/terraform/modules/application/variables.tf b/terraform/modules/application/variables.tf new file mode 100644 index 000000000..9feb963f5 --- /dev/null +++ b/terraform/modules/application/variables.tf @@ -0,0 +1,22 @@ +variable "vpc_id" {} +variable "project_name" {} +variable "environment" {} +variable "ec2_role_name" {} +variable "bucket_name" {} +variable "region" {} +variable "code_deploy_role_arn" {} +variable "ami_id" {} +variable "key_pair_name" {} +variable "bastion_sg_id" {} +variable "private_subnet_ids" { + type = list(string) +} +variable "public_subnet_ids" { + type = list(string) +} +variable "service_worker_tags" { + type = map(string) +} +variable "server_tags" { + type = map(string) +} diff --git a/terraform/modules/bastion/main.tf b/terraform/modules/bastion/main.tf new file mode 100644 index 000000000..7fd8a8297 --- /dev/null +++ b/terraform/modules/bastion/main.tf @@ -0,0 +1,52 @@ +resource "aws_security_group" "bastion_sg" { + vpc_id = var.vpc_id + + ingress { + from_port = 22 + to_port = 22 + protocol = "tcp" + cidr_blocks = ["58.76.251.0/24"] + description = "for VPN" + } + + egress { + from_port = 0 + to_port = 0 + protocol = "-1" + cidr_blocks = ["0.0.0.0/0"] + } + + tags = merge(var.server_tags, { + Name = "${var.project_name}_bastion_sg" + }) +} + +resource "aws_eip" "bastion_eip" { + tags = merge(var.server_tags, { + Name = "${var.project_name}_bastion_eip" + }) +} + +resource "aws_instance" "bastion" { + ami = var.ami_id + instance_type = "t4g.micro" + subnet_id = element(var.public_subnet_ids, 0) + vpc_security_group_ids = [aws_security_group.bastion_sg.id] + key_name = var.key_pair_name + + user_data = <<-EOF + #!/bin/bash + sudo timedatectl set-timezone Asia/Seoul + EOF + + depends_on = [aws_eip.bastion_eip] + + tags = merge(var.server_tags, { + Name = "${var.project_name}_bastion" + }) +} + +resource "aws_eip_association" "bastion_eip" { + instance_id = aws_instance.bastion.id + allocation_id = aws_eip.bastion_eip.id +} diff --git a/terraform/modules/bastion/outputs.tf b/terraform/modules/bastion/outputs.tf new file mode 100644 index 000000000..5841832cf --- /dev/null +++ b/terraform/modules/bastion/outputs.tf @@ -0,0 +1,34 @@ +output "bastion_sg_id" { + description = "The ID of the Security Group for the Bastion Host" + value = aws_security_group.bastion_sg.id +} + +output "bastion_sg_name" { + description = "The Name tag of the Security Group for the Bastion Host" + value = aws_security_group.bastion_sg.tags["Name"] +} + +output "bastion_instance_id" { + description = "The ID of the Bastion Host instance" + value = aws_instance.bastion.id +} + +output "bastion_instance_public_ip" { + description = "The public IP address of the Bastion Host" + value = aws_eip.bastion_eip.public_ip +} + +output "bastion_instance_private_ip" { + description = "The private IP address of the Bastion Host" + value = aws_instance.bastion.private_ip +} + +output "bastion_eip_allocation_id" { + description = "The Allocation ID of the Elastic IP associated with the Bastion Host" + value = aws_eip.bastion_eip.id +} + +output "bastion_instance_arn" { + description = "The ARN of the Bastion Host instance" + value = aws_instance.bastion.arn +} diff --git a/terraform/modules/bastion/variables.tf b/terraform/modules/bastion/variables.tf new file mode 100644 index 000000000..bb8b92a7f --- /dev/null +++ b/terraform/modules/bastion/variables.tf @@ -0,0 +1,10 @@ +variable "vpc_id" {} +variable "project_name" {} +variable "ami_id" {} +variable "key_pair_name" {} +variable "public_subnet_ids" { + type = list(string) +} +variable "server_tags" { + type = map(string) +} diff --git a/terraform/modules/compute/main.tf b/terraform/modules/compute/main.tf new file mode 100644 index 000000000..c76708e5e --- /dev/null +++ b/terraform/modules/compute/main.tf @@ -0,0 +1,26 @@ +data "aws_ami" "ec2_ami" { + most_recent = true + owners = ["amazon"] + filter { + name = "name" + values = ["amzn2-ami-hvm-*-arm64-gp2"] + } +} + +resource "tls_private_key" "private_key" { + algorithm = "RSA" + rsa_bits = 2048 +} + +resource "aws_key_pair" "key_pair" { + key_name = "${var.project_name}_key_pair" + public_key = tls_private_key.private_key.public_key_openssh + + // Note: Tag not required +} + +resource "local_file" "private_key" { + filename = "${path.root}/keys/private_key.pem" + content = tls_private_key.private_key.private_key_pem + file_permission = "0600" +} diff --git a/terraform/modules/compute/outputs.tf b/terraform/modules/compute/outputs.tf new file mode 100644 index 000000000..473aba73c --- /dev/null +++ b/terraform/modules/compute/outputs.tf @@ -0,0 +1,29 @@ +output "ami_id" { + description = "The ID of the most recent Amazon Linux 2 AMI" + value = data.aws_ami.ec2_ami.id +} + +output "ami_name" { + description = "The name of the most recent Amazon Linux 2 AMI" + value = data.aws_ami.ec2_ami.name +} + +output "ami_owner_id" { + description = "The owner ID of the AMI" + value = data.aws_ami.ec2_ami.owner_id +} + +output "ami_creation_date" { + description = "The creation date of the most recent Amazon Linux 2 AMI" + value = data.aws_ami.ec2_ami.creation_date +} + +output "key_pair_name" { + description = "Name of the EC2 Key Pair" + value = aws_key_pair.key_pair.key_name +} + +output "private_key_file" { + description = "Path to the private key file generated locally" + value = local_file.private_key.filename +} diff --git a/terraform/modules/compute/variables.tf b/terraform/modules/compute/variables.tf new file mode 100644 index 000000000..34b739530 --- /dev/null +++ b/terraform/modules/compute/variables.tf @@ -0,0 +1 @@ +variable "project_name" {} diff --git a/terraform/modules/database/main.tf b/terraform/modules/database/main.tf new file mode 100644 index 000000000..ecac90d81 --- /dev/null +++ b/terraform/modules/database/main.tf @@ -0,0 +1,58 @@ +module "secret" { + source = "../../modules/secret" + + secret_name = var.secret_name +} + +locals { + username = module.secret.value["spring.datasource.username"] + password = module.secret.value["spring.datasource.password"] +} + +resource "aws_security_group" "database_sg" { + vpc_id = var.vpc_id + + ingress { + from_port = 3306 + to_port = 3306 + protocol = "tcp" + security_groups = var.ingress_security_group_ids + } + + egress { + from_port = 0 + to_port = 0 + protocol = "-1" + cidr_blocks = ["0.0.0.0/0"] + } + tags = merge(var.server_tags, { + Name = "${var.project_name}_database_sg" + }) +} + +resource "aws_db_subnet_group" "database_subnet_group" { + name = "${var.project_name}-subnet-group" + subnet_ids = var.private_subnet_ids + + // Note: Tag not required +} + +resource "aws_db_instance" "database" { + identifier = var.project_name + allocated_storage = 20 + engine = "mysql" + engine_version = "8.0" + instance_class = "db.t4g.micro" + db_name = var.db_name + username = local.username + password = local.password + parameter_group_name = "default.mysql8.0" + skip_final_snapshot = true + publicly_accessible = false + vpc_security_group_ids = [aws_security_group.database_sg.id] + db_subnet_group_name = aws_db_subnet_group.database_subnet_group.name + + tags = merge(var.database_tags, { + Name = "${var.project_name}_database" + }) +} diff --git a/terraform/modules/database/outputs.tf b/terraform/modules/database/outputs.tf new file mode 100644 index 000000000..b8641b4e6 --- /dev/null +++ b/terraform/modules/database/outputs.tf @@ -0,0 +1,39 @@ +output "database_sg_id" { + description = "Security Group ID for the database" + value = aws_security_group.database_sg.id +} + +output "database_sg_name" { + description = "Name of the Security Group for the database" + value = aws_security_group.database_sg.tags["Name"] +} + +output "db_subnet_group_name" { + description = "Name of the DB Subnet Group" + value = aws_db_subnet_group.database_subnet_group.name +} + +output "db_instance_id" { + description = "ID of the DB instance" + value = aws_db_instance.database.id +} + +output "db_instance_arn" { + description = "ARN of the DB instance" + value = aws_db_instance.database.arn +} + +output "db_instance_endpoint" { + description = "Endpoint of the DB instance" + value = aws_db_instance.database.endpoint +} + +output "db_instance_username" { + description = "Username for the DB instance" + value = aws_db_instance.database.username +} + +output "db_instance_name" { + description = "Name of the database created on the DB instance" + value = aws_db_instance.database.db_name +} diff --git a/terraform/modules/database/variables.tf b/terraform/modules/database/variables.tf new file mode 100644 index 000000000..4f2f61f7c --- /dev/null +++ b/terraform/modules/database/variables.tf @@ -0,0 +1,16 @@ +variable "vpc_id" {} +variable "project_name" {} +variable "db_name" {} +variable "secret_name" {} +variable "ingress_security_group_ids" { + type = list(string) +} +variable "private_subnet_ids" { + type = list(string) +} +variable "server_tags" { + type = map(string) +} +variable "database_tags" { + type = map(string) +} diff --git a/terraform/modules/iam/main.tf b/terraform/modules/iam/main.tf new file mode 100644 index 000000000..80d0a9604 --- /dev/null +++ b/terraform/modules/iam/main.tf @@ -0,0 +1,112 @@ +resource "aws_iam_role" "ec2_role" { + name = "${var.project_name}-s3-access-role" + + assume_role_policy = jsonencode({ + Version = "2012-10-17", + Statement = [ + { + Action = "sts:AssumeRole", + Effect = "Allow", + Principal = { + Service = "ec2.amazonaws.com" + } + } + ] + }) +} + +resource "aws_iam_policy" "s3_access_policy" { + name = "${var.project_name}-s3-access-policy" + + policy = jsonencode({ + Version = "2012-10-17", + Statement = [ + { + Action = [ + "s3:Get*", + "s3:List*" + ], + Effect = "Allow", + Resource = var.bucket_arns + } + ] + }) + + // Note: Tag not required +} + +resource "aws_iam_role_policy_attachment" "s3_access_attachment" { + role = aws_iam_role.ec2_role.name + policy_arn = aws_iam_policy.s3_access_policy.arn +} + +resource "aws_iam_policy" "secrets_manager_access_policy" { + name = "${var.project_name}-secrets_manager_access-policy" + + policy = jsonencode({ + Version = "2012-10-17", + Statement = [ + { + Action = [ + "secretsmanager:GetSecretValue" + ], + Effect = "Allow", + Resource = "*" + } + ] + }) + + // Note: Tag not required +} + +resource "aws_iam_role_policy_attachment" "secrets_manager_access_attachment" { + role = aws_iam_role.ec2_role.name + policy_arn = aws_iam_policy.secrets_manager_access_policy.arn +} + +resource "aws_iam_role" "code_deploy_role" { + name = "${var.project_name}-code-deploy-role" + + assume_role_policy = jsonencode({ + Version = "2012-10-17", + Statement = [ + { + Action = "sts:AssumeRole", + Effect = "Allow", + Principal = { + Service = "codedeploy.amazonaws.com" + } + } + ] + }) +} + +resource "aws_iam_policy" "code_deploy_policy" { + name = "${var.project_name}-code-deploy-policy" + + policy = jsonencode({ + Version = "2012-10-17", + Statement = [ + { + Action = [ + "autoscaling:*", + "ec2:*", + "elasticloadbalancing:*", + "cloudwatch:PutMetricData", + "s3:Get*", + "s3:List*" + ], + Effect = "Allow", + Resource = "*" + } + + ] + }) + + // Note: Tag not required +} + +resource "aws_iam_role_policy_attachment" "code_deploy_attachment" { + role = aws_iam_role.code_deploy_role.name + policy_arn = aws_iam_policy.code_deploy_policy.arn +} diff --git a/terraform/modules/iam/outputs.tf b/terraform/modules/iam/outputs.tf new file mode 100644 index 000000000..c2363735e --- /dev/null +++ b/terraform/modules/iam/outputs.tf @@ -0,0 +1,49 @@ +output "ec2_role_name" { + description = "The name of the IAM Role created for EC2 instances" + value = aws_iam_role.ec2_role.name +} + +output "ec2_role_arn" { + description = "The ARN of the IAM Role created for EC2 instances" + value = aws_iam_role.ec2_role.arn +} + +output "s3_access_policy_name" { + description = "The name of the IAM Policy created for S3 access" + value = aws_iam_policy.s3_access_policy.name +} + +output "s3_access_policy_arn" { + description = "The ARN of the IAM Policy created for S3 access" + value = aws_iam_policy.s3_access_policy.arn +} + +output "s3_access_policy_attachment_id" { + description = "The ID of the IAM Role Policy Attachment for the S3 access policy" + value = aws_iam_role_policy_attachment.s3_access_attachment.id +} + +output "code_deploy_role_name" { + description = "The name of the IAM Role created for CodeDeploy" + value = aws_iam_role.code_deploy_role.name +} + +output "code_deploy_role_arn" { + description = "The ARN of the IAM Role created for CodeDeploy" + value = aws_iam_role.code_deploy_role.arn +} + +output "code_deploy_policy_name" { + description = "The name of the IAM Policy created for CodeDeploy" + value = aws_iam_policy.code_deploy_policy.name +} + +output "code_deploy_policy_arn" { + description = "The ARN of the IAM Policy created for CodeDeploy" + value = aws_iam_policy.code_deploy_policy.arn +} + +output "code_deploy_policy_attachment_id" { + description = "The ID of the IAM Role Policy Attachment for the CodeDeploy" + value = aws_iam_role_policy_attachment.code_deploy_attachment.id +} diff --git a/terraform/modules/iam/variables.tf b/terraform/modules/iam/variables.tf new file mode 100644 index 000000000..27ca07f61 --- /dev/null +++ b/terraform/modules/iam/variables.tf @@ -0,0 +1,5 @@ +variable "project_name" {} + +variable "bucket_arns" { + type = list(string) +} diff --git a/terraform/modules/network/main.tf b/terraform/modules/network/main.tf new file mode 100644 index 000000000..9b0468a71 --- /dev/null +++ b/terraform/modules/network/main.tf @@ -0,0 +1,129 @@ +// VPC +resource "aws_vpc" "vpc" { + cidr_block = "10.0.0.0/16" + assign_generated_ipv6_cidr_block = false + enable_dns_support = true + enable_dns_hostnames = true + instance_tenancy = "default" + tags = merge(var.server_tags, { + Name = "${var.project_name}_vpc" + }) +} + +// Public Subnet +resource "aws_subnet" "public_a" { + vpc_id = aws_vpc.vpc.id + cidr_block = "10.0.1.0/24" + assign_ipv6_address_on_creation = false + availability_zone = "${var.region}a" + map_public_ip_on_launch = false + + tags = merge(var.server_tags, { + Name = "${var.project_name}_public_a" + }) +} + +resource "aws_subnet" "public_b" { + vpc_id = aws_vpc.vpc.id + cidr_block = "10.0.2.0/24" + assign_ipv6_address_on_creation = false + availability_zone = "${var.region}b" + map_public_ip_on_launch = false + + tags = merge(var.server_tags, { + Name = "${var.project_name}_public_b" + }) +} + +resource "aws_subnet" "private_a" { + vpc_id = aws_vpc.vpc.id + cidr_block = "10.0.3.0/24" + assign_ipv6_address_on_creation = false + availability_zone = "${var.region}a" + map_public_ip_on_launch = false + + tags = merge(var.server_tags, { + Name = "${var.project_name}_private_a" + }) +} + +resource "aws_subnet" "private_b" { + vpc_id = aws_vpc.vpc.id + cidr_block = "10.0.4.0/24" + assign_ipv6_address_on_creation = false + availability_zone = "${var.region}b" + map_public_ip_on_launch = false + + tags = merge(var.server_tags, { + Name = "${var.project_name}_private_b" + }) +} + +resource "aws_internet_gateway" "igw" { + vpc_id = aws_vpc.vpc.id + + tags = merge(var.gateway_tags, { + Name = "${var.project_name}_igw" + }) +} + +resource "aws_route_table" "public_rt" { + vpc_id = aws_vpc.vpc.id + + route { + cidr_block = "0.0.0.0/0" + gateway_id = aws_internet_gateway.igw.id + } + + tags = merge(var.server_tags, { + Name = "${var.project_name}_public_rt" + }) +} + +resource "aws_route_table_association" "public_rt_a" { + subnet_id = aws_subnet.public_a.id + route_table_id = aws_route_table.public_rt.id +} + +resource "aws_route_table_association" "public_rt_b" { + subnet_id = aws_subnet.public_b.id + route_table_id = aws_route_table.public_rt.id +} + +resource "aws_eip" "ngw_eip" { + tags = merge(var.server_tags, { + Name = "${var.project_name}_ngw_eip" + }) +} + +resource "aws_nat_gateway" "ngw" { + allocation_id = aws_eip.ngw_eip.id + subnet_id = aws_subnet.public_a.id + + tags = merge(var.server_tags, { + Name = "${var.project_name}_ngw" + }) +} + +resource "aws_route_table" "private_rt" { + vpc_id = aws_vpc.vpc.id + + route { + cidr_block = "0.0.0.0/0" + gateway_id = aws_nat_gateway.ngw.id + } + + tags = merge(var.server_tags, { + Name = "${var.project_name}_private_rt" + }) +} + +resource "aws_route_table_association" "private_rt_a" { + subnet_id = aws_subnet.private_a.id + route_table_id = aws_route_table.private_rt.id +} + +resource "aws_route_table_association" "private_rt_b" { + subnet_id = aws_subnet.private_b.id + route_table_id = aws_route_table.private_rt.id +} diff --git a/terraform/modules/network/outputs.tf b/terraform/modules/network/outputs.tf new file mode 100644 index 000000000..57ea4c68f --- /dev/null +++ b/terraform/modules/network/outputs.tf @@ -0,0 +1,173 @@ +// VPC +output "vpc_id" { + description = "The ID of the created VPC" + value = aws_vpc.vpc.id +} + +output "vpc_cidr_block" { + description = "The CIDR block of the created VPC" + value = aws_vpc.vpc.cidr_block +} + +output "vpc_arn" { + description = "The ARN of the created VPC" + value = aws_vpc.vpc.arn +} + +output "vpc_dns_support" { + description = "Whether DNS support is enabled for the VPC" + value = aws_vpc.vpc.enable_dns_support +} + +output "vpc_dns_hostnames" { + description = "Whether DNS hostnames are enabled for the VPC" + value = aws_vpc.vpc.enable_dns_hostnames +} + +output "vpc_tags" { + description = "Tags applied to the VPC" + value = aws_vpc.vpc.tags +} + +// Public Subnet +output "public_subnet_a_id" { + description = "The ID of the public subnet in availability zone A" + value = aws_subnet.public_a.id +} + +output "public_subnet_b_id" { + description = "The ID of the public subnet in availability zone B" + value = aws_subnet.public_b.id +} + +output "public_subnet_ids" { + description = "A list of all public subnet IDs" + value = [aws_subnet.public_a.id, aws_subnet.public_b.id] +} + +// Private Subnet +output "private_subnet_a_id" { + description = "The ID of the private subnet in availability zone A" + value = aws_subnet.private_a.id +} + +output "private_subnet_b_id" { + description = "The ID of the private subnet in availability zone B" + value = aws_subnet.private_b.id +} + +output "private_subnet_ids" { + description = "A list of all private subnet IDs" + value = [aws_subnet.private_a.id, aws_subnet.private_b.id] +} + +output "all_subnet_ids" { + description = "A list of all subnet IDs (both public and private)" + value = [ + aws_subnet.public_a.id, + aws_subnet.public_b.id, + aws_subnet.private_a.id, + aws_subnet.private_b.id + ] +} + +// Internet Gateway +output "internet_gateway_id" { + description = "The ID of the Internet Gateway" + value = aws_internet_gateway.igw.id +} + +output "internet_gateway_arn" { + description = "The ARN of the Internet Gateway" + value = aws_internet_gateway.igw.arn +} + +output "internet_gateway_name" { + description = "The Name tag of the Internet Gateway" + value = aws_internet_gateway.igw.tags["Name"] +} + +// Public Route Table +output "public_route_table_id" { + description = "The ID of the public route table" + value = aws_route_table.public_rt.id +} + +output "public_route_table_name" { + description = "The Name tag of the public route table" + value = aws_route_table.public_rt.tags["Name"] +} + +output "public_route_table_associations" { + description = "A list of subnet IDs associated with the public route table" + value = [ + aws_route_table_association.public_rt_a.subnet_id, + aws_route_table_association.public_rt_b.subnet_id + ] +} + +output "public_route_table_association_ids" { + description = "A list of IDs for the public route table associations" + value = [ + aws_route_table_association.public_rt_a.id, + aws_route_table_association.public_rt_b.id + ] +} + +// Nat Gateway +output "nat_gateway_id" { + description = "The ID of the NAT Gateway" + value = aws_nat_gateway.ngw.id +} + +output "nat_gateway_name" { + description = "The Name tag of the NAT Gateway" + value = aws_nat_gateway.ngw.tags["Name"] +} + +output "nat_gateway_allocation_id" { + description = "The Allocation ID of the Elastic IP associated with the NAT Gateway" + value = aws_nat_gateway.ngw.allocation_id +} + +output "nat_gateway_public_ip" { + description = "The public IP address of the NAT Gateway" + value = aws_nat_gateway.ngw.public_ip +} + +output "elastic_ip_id" { + description = "The ID of the Elastic IP associated with the NAT Gateway" + value = aws_eip.ngw_eip.id +} + +output "elastic_ip_address" { + description = "The public IP address of the Elastic IP" + value = aws_eip.ngw_eip.public_ip +} + +// Private Route Table +output "private_route_table_id" { + description = "The ID of the private route table" + value = aws_route_table.private_rt.id +} + +output "private_route_table_name" { + description = "The Name tag of the private route table" + value = aws_route_table.private_rt.tags["Name"] +} + +output "private_route_table_associations" { + description = "A list of subnet IDs associated with the private route table" + value = [ + aws_route_table_association.private_rt_a.subnet_id, + aws_route_table_association.private_rt_b.subnet_id + ] +} + +output "private_route_table_association_ids" { + description = "A list of IDs for the private route table associations" + value = [ + aws_route_table_association.private_rt_a.id, + aws_route_table_association.private_rt_b.id + ] +} diff --git a/terraform/modules/network/variables.tf b/terraform/modules/network/variables.tf new file mode 100644 index 000000000..a67565b30 --- /dev/null +++ b/terraform/modules/network/variables.tf @@ -0,0 +1,8 @@ +variable "region" {} +variable "project_name" {} +variable "server_tags" { + type = map(string) +} +variable "gateway_tags" { + type = map(string) +} diff --git a/terraform/modules/secret/main.tf b/terraform/modules/secret/main.tf new file mode 100644 index 000000000..2a0fbce42 --- /dev/null +++ b/terraform/modules/secret/main.tf @@ -0,0 +1,7 @@ +data "aws_secretsmanager_secret" "secret" { + name = var.secret_name +} + +data "aws_secretsmanager_secret_version" "secret_version" { + secret_id = data.aws_secretsmanager_secret.secret.id +} diff --git a/terraform/modules/secret/outputs.tf b/terraform/modules/secret/outputs.tf new file mode 100644 index 000000000..986dfd51f --- /dev/null +++ b/terraform/modules/secret/outputs.tf @@ -0,0 +1,3 @@ +output "value" { + value = jsondecode(data.aws_secretsmanager_secret_version.secret_version.secret_string) +} diff --git a/terraform/modules/secret/variables.tf b/terraform/modules/secret/variables.tf new file mode 100644 index 000000000..e59fa63c4 --- /dev/null +++ b/terraform/modules/secret/variables.tf @@ -0,0 +1 @@ +variable "secret_name" {} diff --git a/terraform/modules/storage/main.tf b/terraform/modules/storage/main.tf new file mode 100644 index 000000000..5a77eafea --- /dev/null +++ b/terraform/modules/storage/main.tf @@ -0,0 +1,17 @@ +resource "aws_s3_bucket" "bucket" { + bucket = var.bucket_name + force_destroy = true + + tags = merge(var.storage_tags, { + Name = "${var.project_name}_bucket" + }) +} + +resource "aws_s3_bucket_public_access_block" "public_access" { + bucket = aws_s3_bucket.bucket.id + + block_public_acls = true + block_public_policy = true + ignore_public_acls = true + restrict_public_buckets = true +} diff --git a/terraform/modules/storage/outputs.tf b/terraform/modules/storage/outputs.tf new file mode 100644 index 000000000..10d6b555e --- /dev/null +++ b/terraform/modules/storage/outputs.tf @@ -0,0 +1,14 @@ +output "bucket_name" { + description = "The name of the S3 bucket" + value = aws_s3_bucket.bucket.id +} + +output "bucket_arn" { + description = "The ARN of the S3 bucket" + value = aws_s3_bucket.bucket.arn +} + +output "public_access_block_id" { + description = "The ID of the S3 bucket public access block configuration" + value = aws_s3_bucket_public_access_block.public_access.id +} diff --git a/terraform/modules/storage/variables.tf b/terraform/modules/storage/variables.tf new file mode 100644 index 000000000..b69ebd9de --- /dev/null +++ b/terraform/modules/storage/variables.tf @@ -0,0 +1,5 @@ +variable "bucket_name" {} +variable "project_name" {} +variable "storage_tags" { + type = map(string) +} diff --git a/terraform/modules/tags/main.tf b/terraform/modules/tags/main.tf new file mode 100644 index 000000000..dd172fcc8 --- /dev/null +++ b/terraform/modules/tags/main.tf @@ -0,0 +1,21 @@ +locals { + common_tags = { + Service = var.project_name, + Environment = var.environment + } + server_tags = merge(local.common_tags, { + Role = "${var.project_name}-server" + }) + gateway_tags = merge(local.common_tags, { + Role = "${var.project_name}-gateway" + }) + storage_tags = merge(local.common_tags, { + Role = "${var.project_name}-storage" + }) + database_tags = merge(local.common_tags, { + Role = "${var.project_name}-db" + }) + service_worker_tags = merge(local.common_tags, { + Role = "service-worker" + }) +} diff --git a/terraform/modules/tags/outputs.tf b/terraform/modules/tags/outputs.tf new file mode 100644 index 000000000..2882144fa --- /dev/null +++ b/terraform/modules/tags/outputs.tf @@ -0,0 +1,29 @@ +output "common_tags" { + description = "Common tags for all resources" + value = local.common_tags +} + +output "server_tags" { + description = "Tags for server resources" + value = local.server_tags +} + +output "gateway_tags" { + description = "Tags for gateway resources" + value = local.gateway_tags +} + +output "storage_tags" { + description = "Tags for storage resources" + value = local.storage_tags +} + +output "database_tags" { + description = "Tags for database resources" + value = local.database_tags +} + +output "service_worker_tags" { + description = "Tags for service worker resources" + value = local.service_worker_tags +} diff --git a/terraform/modules/tags/variables.tf b/terraform/modules/tags/variables.tf new file mode 100644 index 000000000..662fe70cc --- /dev/null +++ b/terraform/modules/tags/variables.tf @@ -0,0 +1,2 @@ +variable "project_name" {} +variable "environment" {} diff --git a/terraform/provider.tf b/terraform/provider.tf new file mode 100644 index 000000000..2be9fc62a --- /dev/null +++ b/terraform/provider.tf @@ -0,0 +1,17 @@ +provider "aws" { + region = var.region + + /** Note: access_key와 secret_key는 환경변수를 통해 설정하면 된다. + export AWS_ACCESS_KEY_ID="your-access-key" + export AWS_SECRET_ACCESS_KEY="your-secret-key" + */ +} + +terraform { + required_providers { + aws = { + source = "hashicorp/aws" + version = "5.54.1" + } + } +} diff --git a/terraform/variables.tf b/terraform/variables.tf new file mode 100644 index 000000000..1028ecf5e --- /dev/null +++ b/terraform/variables.tf @@ -0,0 +1 @@ +variable "region" {}