diff --git a/.github/workflows/back-dev.yml b/.github/workflows/back-dev.yml index 732a581aa..cd2910236 100644 --- a/.github/workflows/back-dev.yml +++ b/.github/workflows/back-dev.yml @@ -50,7 +50,6 @@ jobs: mkdir -p deploy cp build/libs/*.jar deploy/application.jar cp -r .ebextensions deploy/.ebextensions - cp -r deploy-config deploy cd deploy && zip -r deploy.zip . - name: Deploy to EB diff --git a/backend/.ebextensions/02-set-filebeat.config b/backend/.ebextensions/02-set-filebeat.config new file mode 100644 index 000000000..5a0648d88 --- /dev/null +++ b/backend/.ebextensions/02-set-filebeat.config @@ -0,0 +1,48 @@ +files: + "/tmp/make_filebeat_yml.sh": + mode: "000755" + content: | + #!/bin/bash + PASSWORD=$(sudo /opt/elasticbeanstalk/bin/get-config environment -k ELASTICSEARCH_PASSWORD) + HOST=$(sudo /opt/elasticbeanstalk/bin/get-config environment -k ELASTICSEARCH_HOST) + PORT=$(sudo /opt/elasticbeanstalk/bin/get-config environment -k ELASTICSEARCH_PORT) + USER=$(sudo /opt/elasticbeanstalk/bin/get-config environment -k ELASTICSEARCH_USER) + cat > /home/ec2-user/filebeat-7.14.1-linux-x86_64/filebeat.yml < /dev/null 2>&1 &" diff --git a/backend/deploy-config/promtail-local-config.yaml b/backend/deploy-config/promtail-local-config.yaml deleted file mode 100644 index c13d78b87..000000000 --- a/backend/deploy-config/promtail-local-config.yaml +++ /dev/null @@ -1,46 +0,0 @@ -server: - http_listen_port: 9080 - grpc_listen_port: 0 - -positions: - filename: /tmp/positions.yaml - -clients: - - url: http://13.125.198.59:3100/loki/api/v1/push - -scrape_configs: - - job_name: access - static_configs: - - targets: - - localhost - labels: - job: access - __path__: /var/app/current/logs/access/access.log - - job_name: info - static_configs: - - targets: - - localhost - labels: - job: info - __path__: /var/app/current/logs/info/info.log - - job_name: warn - static_configs: - - targets: - - localhost - labels: - job: warn - __path__: /var/app/current/logs/warn/warn.log - - job_name: error - static_configs: - - targets: - - localhost - labels: - job: error - __path__: /var/app/current/logs/error/error.log - - job_name: performance - static_configs: - - targets: - - localhost - labels: - job: performance - __path__: /var/app/current/logs/performance/performance.log diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/AcceptanceContext.java b/backend/src/acceptanceTest/java/wooteco/prolog/AcceptanceContext.java index 817fc32ba..e60f51cbb 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/AcceptanceContext.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/AcceptanceContext.java @@ -4,11 +4,10 @@ import io.restassured.http.ContentType; import io.restassured.response.Response; import io.restassured.specification.RequestSpecification; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Component; - import java.util.HashMap; import java.util.Map; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; @Component @Scope(scopeName = "cucumber-glue") @@ -65,7 +64,8 @@ public void invokeHttpGetWithToken(String path, Object... pathParams) { response.then().log().all(); } - public void invokeHttpGetWithTokenAndCookies(String path, Map cookies, Object... pathParams) { + public void invokeHttpGetWithTokenAndCookies(String path, Map cookies, + Object... pathParams) { request = RestAssured.given().log().all() .cookies(cookies) .auth().oauth2(accessToken); diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/ArticleFixture.java b/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/ArticleFixture.java new file mode 100644 index 000000000..7cccfa05b --- /dev/null +++ b/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/ArticleFixture.java @@ -0,0 +1,8 @@ +package wooteco.prolog.fixtures; + +import wooteco.prolog.article.ui.ArticleRequest; + +public class ArticleFixture { + public static final ArticleRequest ARTICLE_REQUEST1 = new ArticleRequest("첫 아티클 제목","첫 아티클 주소"); + public static final ArticleRequest ARTICLE_REQUEST2 = new ArticleRequest("두번째 아티클 제목","두번째 아티클 주소"); +} diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/GithubResponses.java b/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/GithubResponses.java index 279665aa1..af8a73625 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/GithubResponses.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/GithubResponses.java @@ -19,12 +19,12 @@ public enum GithubResponses { 수달("7", "access_token_7", "수달", "her0807", "777777", "https://avatars.githubusercontent.com/u/26570275?v=4"); - private String code; - private String accessToken; - private String name; - private String login; - private String id; - private String avatarUrl; + private final String code; + private final String accessToken; + private final String name; + private final String login; + private final String id; + private final String avatarUrl; GithubResponses(String code, String accessToken, String name, String login, String id, String avatarUrl) { diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/GithubTestController.java b/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/GithubTestController.java index 7c9d2abc8..740ee264b 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/GithubTestController.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/GithubTestController.java @@ -27,9 +27,9 @@ public ResponseEntity user( String accessToken = authorization.split(" ")[1]; GithubResponses githubResponse = GithubResponses.findByToken(accessToken); GithubProfileResponse response = new GithubProfileResponse(githubResponse.getName(), - githubResponse.getLogin(), - githubResponse.getId(), - githubResponse.getAvatarUrl()); + githubResponse.getLogin(), + githubResponse.getId(), + githubResponse.getAvatarUrl()); return ResponseEntity.ok(response); } } diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/PostAcceptanceFixture.java b/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/PostAcceptanceFixture.java index b550fcb95..742453193 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/PostAcceptanceFixture.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/PostAcceptanceFixture.java @@ -1,68 +1,72 @@ package wooteco.prolog.fixtures; -import wooteco.prolog.studylog.application.dto.StudylogRequest; -import wooteco.prolog.studylog.application.dto.TagRequest; +import static java.util.stream.Collectors.toList; +import static wooteco.prolog.fixtures.TagAcceptanceFixture.TAG1; +import static wooteco.prolog.fixtures.TagAcceptanceFixture.TAG2; +import static wooteco.prolog.fixtures.TagAcceptanceFixture.TAG3; +import static wooteco.prolog.fixtures.TagAcceptanceFixture.TAG4; +import static wooteco.prolog.fixtures.TagAcceptanceFixture.TAG5; +import static wooteco.prolog.fixtures.TagAcceptanceFixture.TAG6; import java.util.Arrays; import java.util.List; - -import static java.util.stream.Collectors.toList; -import static wooteco.prolog.fixtures.TagAcceptanceFixture.*; +import wooteco.prolog.studylog.application.dto.StudylogRequest; +import wooteco.prolog.studylog.application.dto.TagRequest; public enum PostAcceptanceFixture { POST1( - "[자바][옵셔널] 학습log 제출합니다.", - "옵셔널은 NPE를 배제하기 위해 만들어진 자바8에 추가된 라이브러리입니다. \n " + - "다양한 메소드를 호출하여 원하는 대로 활용할 수 있습니다", - 1L, - TAG1, - TAG2 + "[자바][옵셔널] 학습log 제출합니다.", + "옵셔널은 NPE를 배제하기 위해 만들어진 자바8에 추가된 라이브러리입니다. \n " + + "다양한 메소드를 호출하여 원하는 대로 활용할 수 있습니다", + 1L, + TAG1, + TAG2 ), POST2( - "[자바스크립트][비동기] 학습log 제출합니다.", - "모던 JS의 fetch문, ajax라이브러리인 axios등을 통해 비동기 요청을 \n " + - "편하게 할 수 있습니다. 자바 최고", - 2L, - TAG3, - TAG4 + "[자바스크립트][비동기] 학습log 제출합니다.", + "모던 JS의 fetch문, ajax라이브러리인 axios등을 통해 비동기 요청을 \n " + + "편하게 할 수 있습니다. 자바 최고", + 2L, + TAG3, + TAG4 ), POST3( - "[자료구조] 자료구조는 어려워요", - "진짜 어려움", - 1L, - TAG1, - TAG5 + "[자료구조] 자료구조는 어려워요", + "진짜 어려움", + 1L, + TAG1, + TAG5 ), POST4( - "[DOM] DOM DOM Dance", - "덤덤 댄스 아니고", - 2L + "[DOM] DOM DOM Dance", + "덤덤 댄스 아니고", + 2L ), POST5( - "[알고리즘] 자료구조의 big O에 관하여", - "big O는 small O보다 크다", - 2L, - TAG5, - TAG6 + "[알고리즘] 자료구조의 big O에 관하여", + "big O는 small O보다 크다", + 2L, + TAG5, + TAG6 ), POST6( - "새로운 스터디로그", - "옵셔널은 NPE를 배제하기 위해 만들어진 자바8에 추가된 라이브러리입니다. \n " + - "다양한 메소드를 호출하여 원하는 대로 활용할 수 있습니다", - 1L, - TAG1, - TAG2 + "새로운 스터디로그", + "옵셔널은 NPE를 배제하기 위해 만들어진 자바8에 추가된 라이브러리입니다. \n " + + "다양한 메소드를 호출하여 원하는 대로 활용할 수 있습니다", + 1L, + TAG1, + TAG2 ); PostAcceptanceFixture( - String title, - String content, - Long missionId, - TagAcceptanceFixture... tags) { + String title, + String content, + Long missionId, + TagAcceptanceFixture... tags) { this.tags = Arrays.asList(tags); List tagRequests = Arrays.stream(tags) - .map(TagAcceptanceFixture::getTagRequest) - .collect(toList()); + .map(TagAcceptanceFixture::getTagRequest) + .collect(toList()); this.studylogRequest = new StudylogRequest(title, content, missionId, tagRequests); } @@ -75,15 +79,15 @@ public StudylogRequest getPostRequest() { public static List findByMissionNumber(Long missionId) { return Arrays.stream(PostAcceptanceFixture.values()) - .map(PostAcceptanceFixture::getPostRequest) - .filter(it -> it.getMissionId().equals(missionId)) - .collect(toList()); + .map(PostAcceptanceFixture::getPostRequest) + .filter(it -> it.getMissionId().equals(missionId)) + .collect(toList()); } public static List findByTagNumber(Long tagId) { return Arrays.stream(PostAcceptanceFixture.values()) - .filter(it -> it.tags.stream().anyMatch(tag -> tag.getTagId().equals(tagId))) - .map(PostAcceptanceFixture::getPostRequest) - .collect(toList()); + .filter(it -> it.tags.stream().anyMatch(tag -> tag.getTagId().equals(tagId))) + .map(PostAcceptanceFixture::getPostRequest) + .collect(toList()); } } diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/StudylogAcceptanceFixture.java b/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/StudylogAcceptanceFixture.java index 93861d907..78fce5b9f 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/StudylogAcceptanceFixture.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/StudylogAcceptanceFixture.java @@ -116,7 +116,8 @@ public enum StudylogAcceptanceFixture { List tagRequests = Arrays.stream(tags) .map(TagAcceptanceFixture::getTagRequest) .collect(toList()); - this.studylogRequest = new StudylogRequest(title, content, sessionId, missionId, tagRequests); + this.studylogRequest = new StudylogRequest(title, content, sessionId, missionId, + tagRequests); } public static List findByMissionNumber(Long missionId) { diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/TagAcceptanceFixture.java b/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/TagAcceptanceFixture.java index 9bf6edfa5..bb322b50e 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/TagAcceptanceFixture.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/fixtures/TagAcceptanceFixture.java @@ -10,8 +10,8 @@ public enum TagAcceptanceFixture { TAG5(5L, "자료구조"), TAG6(6L, "알고리즘"); - private Long tagId; - private TagRequest tagRequest; + private final Long tagId; + private final TagRequest tagRequest; TagAcceptanceFixture(Long id, String name) { this.tagId = id; diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/steps/ArticleStepDefinitions.java b/backend/src/acceptanceTest/java/wooteco/prolog/steps/ArticleStepDefinitions.java new file mode 100644 index 000000000..a34e95060 --- /dev/null +++ b/backend/src/acceptanceTest/java/wooteco/prolog/steps/ArticleStepDefinitions.java @@ -0,0 +1,78 @@ +package wooteco.prolog.steps; + +import io.cucumber.java.en.Given; +import io.cucumber.java.en.Then; +import io.cucumber.java.en.When; +import org.springframework.http.HttpStatus; +import wooteco.prolog.AcceptanceSteps; +import wooteco.prolog.article.ui.ArticleResponse; + +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static wooteco.prolog.fixtures.ArticleFixture.ARTICLE_REQUEST1; +import static wooteco.prolog.fixtures.ArticleFixture.ARTICLE_REQUEST2; + + +public class ArticleStepDefinitions extends AcceptanceSteps { + + @Given("아티클을 여러개 작성하고") + public void 아티클을_여러개_작성하고() { + context.invokeHttpPostWithToken("/articles", ARTICLE_REQUEST1); + context.invokeHttpPostWithToken("/articles", ARTICLE_REQUEST2); + } + + @Given("아티클을 작성하고") + @When("아티클을 작성하면") + public void 아티클을_작성하면() { + context.invokeHttpPostWithToken("/articles", ARTICLE_REQUEST1); + if (context.response.statusCode() == HttpStatus.CREATED.value()) { + context.storage.put("article", context.response.statusCode()); + } + } + + @When("아티클을 전체 조회 하면") + public void 아티클을_전체_조회_하면() { + context.invokeHttpGetWithToken("/articles"); + context.storage.put("articles", context.response.as(Object.class)); + } + + @When("{long}번 아티클을 수정하면") + public void 아티클을_수정하면(Long articleId) { + String path = "/articles/" + articleId; + context.invokeHttpPutWithToken(path, ARTICLE_REQUEST2); + } + + @When("{long}번 아티클을 삭제하면") + public void 아티클을_삭제하면(Long articleId) { + String path = "/articles/" + articleId; + context.invokeHttpDeleteWithToken(path, ARTICLE_REQUEST2); + } + + @Then("아티클이 작성된다") + public void 아티클이_작성된다() { + int statusCode = context.response.statusCode(); + assertThat(statusCode).isEqualTo(HttpStatus.CREATED.value()); + } + + @Then("아티클이 전체 조회 된다") + public void 아티클이_전체_조회된다() { + int statusCode = context.response.statusCode(); + assertThat(statusCode).isEqualTo(HttpStatus.OK.value()); + + List articleResponses = (List) context.storage.get("articles"); + assertThat(articleResponses.size()).isEqualTo(2); + } + + @Then("아티클이 수정된다") + public void 아티클이_수정된다() { + int statusCode = context.response.statusCode(); + assertThat(statusCode).isEqualTo(HttpStatus.OK.value()); + } + + @Then("아티클이 삭제된다") + public void 아티클이_삭제된다() { + int statusCode = context.response.statusCode(); + assertThat(statusCode).isEqualTo(HttpStatus.NO_CONTENT.value()); + } +} diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/steps/BadgesStepDefinitions.java b/backend/src/acceptanceTest/java/wooteco/prolog/steps/BadgesStepDefinitions.java index 4e8f0286c..7dc4d2843 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/steps/BadgesStepDefinitions.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/steps/BadgesStepDefinitions.java @@ -10,8 +10,8 @@ import java.util.List; import org.springframework.http.HttpStatus; import wooteco.prolog.AcceptanceSteps; -import wooteco.prolog.common.exception.ExceptionDto; import wooteco.prolog.badge.domain.BadgeType; +import wooteco.prolog.common.exception.ExceptionDto; public class BadgesStepDefinitions extends AcceptanceSteps { diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/steps/FilterStepDefinitions.java b/backend/src/acceptanceTest/java/wooteco/prolog/steps/FilterStepDefinitions.java index 3afd83432..6b33c0745 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/steps/FilterStepDefinitions.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/steps/FilterStepDefinitions.java @@ -18,7 +18,7 @@ public class FilterStepDefinitions extends AcceptanceSteps { public void nickname을기준으로멤버데이터들을오름차순정렬하여반환한다() { assertThat(context.response.statusCode()).isEqualTo(HttpStatus.OK.value()); assertThat(context.response.body().jsonPath().getList("members")) - .extracting("nickname") - .containsExactly("브라운", "서니", "현구막"); + .extracting("nickname") + .containsExactly("브라운", "서니", "현구막"); } } diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/steps/GroupMemberStepDefinitions.java b/backend/src/acceptanceTest/java/wooteco/prolog/steps/GroupMemberStepDefinitions.java index 6caf05ec5..1747c700e 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/steps/GroupMemberStepDefinitions.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/steps/GroupMemberStepDefinitions.java @@ -26,9 +26,11 @@ public GroupMemberStepDefinitions(MemberRepository memberRepository, @Given("{string}을 멤버그룹과 그룹멤버에 등록하고") public void 그룹멤버를_생성하고(String title) { Member member = memberRepository.findById(1L).get(); - MemberGroup 프론트엔드 = memberGroupRepository.save(new MemberGroup(null, "4기 프론트엔드", "4기 프론트엔드 설명")); + MemberGroup 프론트엔드 = memberGroupRepository.save( + new MemberGroup(null, "4기 프론트엔드", "4기 프론트엔드 설명")); MemberGroup 백엔드 = memberGroupRepository.save(new MemberGroup(null, "4기 백엔드", "4기 백엔드 설명")); - MemberGroup 안드로이드 = memberGroupRepository.save(new MemberGroup(null, "4기 안드로이드", "4기 안드로이드 설명")); + MemberGroup 안드로이드 = memberGroupRepository.save( + new MemberGroup(null, "4기 안드로이드", "4기 안드로이드 설명")); groupMemberRepository.save(new GroupMember(null, member, 백엔드)); groupMemberRepository.save(new GroupMember(null, member, 프론트엔드)); groupMemberRepository.save(new GroupMember(null, member, 안드로이드)); diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/steps/MemberStepDefinitions.java b/backend/src/acceptanceTest/java/wooteco/prolog/steps/MemberStepDefinitions.java index 9c9ac0ac7..df43e7105 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/steps/MemberStepDefinitions.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/steps/MemberStepDefinitions.java @@ -51,19 +51,20 @@ public class MemberStepDefinitions extends AcceptanceSteps { } @When("{int}번 스터디로그를 스크랩하면") - public void studylog를스크랩하면(int studylogId){ - context.invokeHttpPostWithToken("/members/scrap", new MemberScrapRequest((long)studylogId)); + public void studylog를스크랩하면(int studylogId) { + context.invokeHttpPostWithToken("/members/scrap", + new MemberScrapRequest((long) studylogId)); assertThat(context.response.statusCode()).isEqualTo(201); } @When("{int}번 스터디로그를 스크랩 취소하면") - public void studylog를스크랩취소하면(int studylogId){ + public void studylog를스크랩취소하면(int studylogId) { context.invokeHttpDeleteWithToken("/members/scrap?studylog=" + studylogId); assertThat(context.response.statusCode()).isEqualTo(204); } @Then("스크랩한 {int}번 스터디로그를 볼 수 있다") - public void 스크랩한studylog를볼수있다(int studylogId){ + public void 스크랩한studylog를볼수있다(int studylogId) { context.invokeHttpGetWithToken("/members/scrap"); assertThat(checkIfScrap(studylogId)).isTrue(); } diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/steps/NewSessionStepDefinitions.java b/backend/src/acceptanceTest/java/wooteco/prolog/steps/NewSessionStepDefinitions.java index b274dfa7e..27ab53f13 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/steps/NewSessionStepDefinitions.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/steps/NewSessionStepDefinitions.java @@ -14,7 +14,8 @@ public class NewSessionStepDefinitions extends AcceptanceSteps { @Given("{int}번 커리큘럼에 {string} 세션을 작성하고") @When("{int}번 커리큘럼에 {string} 세션을 작성하면") public void 세션을_생성하고(int curriculumId, String name) { - context.invokeHttpPost("/curriculums/" + curriculumId + "/sessions", new SessionRequest(name)); + context.invokeHttpPost("/curriculums/" + curriculumId + "/sessions", + new SessionRequest(name)); } @Then("세션이 생성된다") @@ -34,7 +35,8 @@ public class NewSessionStepDefinitions extends AcceptanceSteps { @When("{int}번 커리큘럼의 {int}번 세션을 {string} 세션으로 수정하면") public void 세션을_수정하면(int curriculumId, int sessionId, String name) { - context.invokeHttpPut("/curriculums/" + curriculumId + "/sessions/" + sessionId, new SessionRequest(name)); + context.invokeHttpPut("/curriculums/" + curriculumId + "/sessions/" + sessionId, + new SessionRequest(name)); } @Then("세션이 수정된다") diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/steps/StudylogOverviewStepDefinitions.java b/backend/src/acceptanceTest/java/wooteco/prolog/steps/StudylogOverviewStepDefinitions.java index 7d9ba38b4..3604ba9ec 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/steps/StudylogOverviewStepDefinitions.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/steps/StudylogOverviewStepDefinitions.java @@ -26,27 +26,28 @@ public class StudylogOverviewStepDefinitions extends AcceptanceSteps { @Then("해당 유저의 태그 목록이 조회된다") public void 나의태그목록이조회된다() { final List data = context.response.then().extract() - .body() - .jsonPath() - .getList("data", MemberTagResponse.class); + .body() + .jsonPath() + .getList("data", MemberTagResponse.class); assertThat(data) - .extracting( - memberTagResponse -> memberTagResponse.getTagResponse().getName(), - MemberTagResponse::getCount) - .containsExactlyInAnyOrder( - tuple(TagAcceptanceFixture.TAG1.getTagName(), 2), - tuple(TagAcceptanceFixture.TAG2.getTagName(), 2), - tuple(TagAcceptanceFixture.TAG3.getTagName(), 2), - tuple(TagAcceptanceFixture.TAG4.getTagName(), 2), - tuple("ALL", 4) - ); + .extracting( + memberTagResponse -> memberTagResponse.getTagResponse().getName(), + MemberTagResponse::getCount) + .containsExactlyInAnyOrder( + tuple(TagAcceptanceFixture.TAG1.getTagName(), 2), + tuple(TagAcceptanceFixture.TAG2.getTagName(), 2), + tuple(TagAcceptanceFixture.TAG3.getTagName(), 2), + tuple(TagAcceptanceFixture.TAG4.getTagName(), 2), + tuple("ALL", 4) + ); } @When("{string}의 {int}년 {int}월 스터디로그 목록을 조회하면") public void 나의스터디로그목록을조회하면(String name, int year, int month) { final String memberName = GithubResponses.findByName(name).getLogin(); - String path = String.format("members/%s/calendar-studylogs?year=%d&month=%d", memberName, year, month); + String path = String.format("members/%s/calendar-studylogs?year=%d&month=%d", memberName, + year, month); context.invokeHttpGet(path); } @@ -58,14 +59,14 @@ public class StudylogOverviewStepDefinitions extends AcceptanceSteps { @Then("해당 유저의 스터디로그 목록이 조회된다") public void 나의스터디로그목록이조회된다() { final List data = context.response.then().extract() - .body() - .jsonPath() - .getList("data", CalendarStudylogResponse.class); + .body() + .jsonPath() + .getList("data", CalendarStudylogResponse.class); assertThat(data).extracting(CalendarStudylogResponse::getTitle) - .containsExactlyInAnyOrder( - PostAcceptanceFixture.POST1.getPostRequest().getTitle(), - PostAcceptanceFixture.POST2.getPostRequest().getTitle() - ); + .containsExactlyInAnyOrder( + PostAcceptanceFixture.POST1.getPostRequest().getTitle(), + PostAcceptanceFixture.POST2.getPostRequest().getTitle() + ); } } diff --git a/backend/src/acceptanceTest/java/wooteco/prolog/steps/StudylogStepDefinitions.java b/backend/src/acceptanceTest/java/wooteco/prolog/steps/StudylogStepDefinitions.java index 2e96ea67f..ffaf15cdf 100644 --- a/backend/src/acceptanceTest/java/wooteco/prolog/steps/StudylogStepDefinitions.java +++ b/backend/src/acceptanceTest/java/wooteco/prolog/steps/StudylogStepDefinitions.java @@ -88,7 +88,8 @@ public class StudylogStepDefinitions extends AcceptanceSteps { @Given("{string} 스터디로그를 작성하고") public void 특정스터디로그를작성하고(String title) { - StudylogRequest studylogRequest = new StudylogRequest(title, "content", 1L, Collections.emptyList()); + StudylogRequest studylogRequest = new StudylogRequest(title, "content", 1L, + Collections.emptyList()); context.invokeHttpPostWithToken("/studylogs", studylogRequest); context.storage.put(title, context.response.as(StudylogResponse.class)); } @@ -115,7 +116,8 @@ public class StudylogStepDefinitions extends AcceptanceSteps { @Given("{int}번 미션의 스터디로그를 {long}개 작성하고") public void 특정미션스터디로그를다수작성하면(int missionNumber, Long totalSize) { - List requests = StudylogAcceptanceFixture.findByMissionNumber((long) missionNumber); + List requests = StudylogAcceptanceFixture.findByMissionNumber( + (long) missionNumber); if (requests.isEmpty()) { throw new RuntimeException("해당 미션의 스터디로그는 없습니다."); @@ -128,7 +130,8 @@ public class StudylogStepDefinitions extends AcceptanceSteps { @Given("{int}번 태그의 스터디로그를 {long}개 작성하고") public void 특정태그스터디로그를다수작성하면(int tagNumber, Long totalSize) { - List requests = StudylogAcceptanceFixture.findByTagNumber((long) tagNumber); + List requests = StudylogAcceptanceFixture.findByTagNumber( + (long) tagNumber); if (requests.isEmpty()) { throw new RuntimeException("해당 미션의 스터디로그는 없습니다."); @@ -165,7 +168,8 @@ public class StudylogStepDefinitions extends AcceptanceSteps { @When("{int}번 미션과 {int}번 태그로 {long}개를 조회하면") public void 미션태그필터를사이즈와함께조회한다(int missionNumber, int tagNumber, Long pageSize) { - String path = String.format("/studylogs?tags=%d&missions=%d&size=%d", tagNumber, missionNumber, pageSize); + String path = String.format("/studylogs?tags=%d&missions=%d&size=%d", tagNumber, + missionNumber, pageSize); context.invokeHttpGet(path); } @@ -354,7 +358,8 @@ public class StudylogStepDefinitions extends AcceptanceSteps { }); assertAll( - () -> assertThat(Iterables.elementsEqual(studylogs.getData(), studylogResponses)).isTrue(), + () -> assertThat( + Iterables.elementsEqual(studylogs.getData(), studylogResponses)).isTrue(), () -> assertThat(studylogs.getData().size()).isEqualTo(pageSize) ); } @@ -405,7 +410,8 @@ public class StudylogStepDefinitions extends AcceptanceSteps { public void 스터디로그가Id순서로조회된다(String studylogIds) { context.invokeHttpGet("/studylogs/popular"); assertThat(context.response.statusCode()).isEqualTo(HttpStatus.OK.value()); - PopularStudylogsResponse studylogsResponse = context.response.as(PopularStudylogsResponse.class); + PopularStudylogsResponse studylogsResponse = context.response.as( + PopularStudylogsResponse.class); List ids = Arrays.asList(studylogIds.split(", ")); for (int i = 0; i < ids.size(); i++) { @@ -418,27 +424,31 @@ public class StudylogStepDefinitions extends AcceptanceSteps { @When("스터디로그 세션을 {long}로 수정하면") public void 스터디로그세션을L로수정하면(long sessionId) { StudylogResponse studylogResponse = (StudylogResponse) context.storage.get("studylog"); - context.invokeHttpPutWithToken("/studylogs/" + studylogResponse.getId() + "/sessions", new StudylogSessionRequest(sessionId)); + context.invokeHttpPutWithToken("/studylogs/" + studylogResponse.getId() + "/sessions", + new StudylogSessionRequest(sessionId)); } @Then("스터디로그 세션이 {long}로 수정된다") public void 스터디로그세션이로수정된다(long sessionId) { StudylogResponse studylogResponse = (StudylogResponse) context.storage.get("studylog"); context.invokeHttpGet("/studylogs/" + studylogResponse.getId()); - assertThat(context.response.as(StudylogResponse.class).getSession().getId()).isEqualTo(sessionId); + assertThat(context.response.as(StudylogResponse.class).getSession().getId()).isEqualTo( + sessionId); } @When("스터디로그 미션을 {long}로 수정하면") public void 스터디로그미션을로수정하면(long missionId) { StudylogResponse studylogResponse = (StudylogResponse) context.storage.get("studylog"); - context.invokeHttpPutWithToken("/studylogs/" + studylogResponse.getId() + "/missions", new StudylogMissionRequest(missionId)); + context.invokeHttpPutWithToken("/studylogs/" + studylogResponse.getId() + "/missions", + new StudylogMissionRequest(missionId)); } @Then("스터디로그 미션이 {long}로 수정된다") public void 스터디로그미션이로수정된다(long missionId) { StudylogResponse studylogResponse = (StudylogResponse) context.storage.get("studylog"); context.invokeHttpGet("/studylogs/" + studylogResponse.getId()); - assertThat(context.response.as(StudylogResponse.class).getMission().getId()).isEqualTo(missionId); + assertThat(context.response.as(StudylogResponse.class).getMission().getId()).isEqualTo( + missionId); } @Given("{long}, {long} 역량을 맵핑한 {string} 스터디로그를 작성하고") diff --git a/backend/src/acceptanceTest/resources/logback-spring.xml b/backend/src/acceptanceTest/resources/logback-spring.xml index af27e5744..707c117bc 100644 --- a/backend/src/acceptanceTest/resources/logback-spring.xml +++ b/backend/src/acceptanceTest/resources/logback-spring.xml @@ -1,28 +1,30 @@ - + - - + + - - - + + + - - - + + + - - - + + + - - - + + + - - - - + + + + diff --git a/backend/src/acceptanceTest/resources/logback/console-logger.xml b/backend/src/acceptanceTest/resources/logback/console-logger.xml index 12481bff1..646cad908 100644 --- a/backend/src/acceptanceTest/resources/logback/console-logger.xml +++ b/backend/src/acceptanceTest/resources/logback/console-logger.xml @@ -1,20 +1,21 @@ - - - utf8 - - %cyan(%d{yyyy-MM-dd HH:mm:ss}:%-4relative) %highlight(%-5level) %yellow([%C.%M]:%boldWhite(%L)]) %n > %msg%n - - - + + + utf8 + + %cyan(%d{yyyy-MM-dd HH:mm:ss}:%-4relative) %highlight(%-5level) + %yellow([%C.%M]:%boldWhite(%L)]) %n > %msg%n + + + - - - utf8 - - %green( > %msg%n) - - - + + + utf8 + + %green( > %msg%n) + + + diff --git a/backend/src/acceptanceTest/resources/wooteco/prolog/article.feature b/backend/src/acceptanceTest/resources/wooteco/prolog/article.feature new file mode 100644 index 000000000..e74da9e7c --- /dev/null +++ b/backend/src/acceptanceTest/resources/wooteco/prolog/article.feature @@ -0,0 +1,24 @@ +@api +Feature: 아티클 관련 기능 + + Background: 사전 작업 + Given "브라운"이 로그인을 하고 + + Scenario: 아티클을 작성하기 + When 아티클을 작성하면 + Then 아티클이 작성된다 + + Scenario: 아티클을 전체 조회하기 + Given 아티클을 여러개 작성하고 + When 아티클을 전체 조회 하면 + Then 아티클이 전체 조회 된다 + + Scenario: 아티클을 수정하기 + Given 아티클을 여러개 작성하고 + When 1번 아티클을 수정하면 + Then 아티클이 수정된다 + + Scenario: 아티클을 삭제하기 + Given 아티클을 여러개 작성하고 + When 1번 아티클을 삭제하면 + Then 아티클이 삭제된다 diff --git a/backend/src/acceptanceTest/resources/wooteco/prolog/badges.feature b/backend/src/acceptanceTest/resources/wooteco/prolog/badges.feature index e3ccdb48c..0b1404365 100644 --- a/backend/src/acceptanceTest/resources/wooteco/prolog/badges.feature +++ b/backend/src/acceptanceTest/resources/wooteco/prolog/badges.feature @@ -1,18 +1,18 @@ @api Feature: 배지 관련 기능 - Background: 사전 작업 - Given 세션 여러개를 생성하고 - And 미션 여러개를 생성하고 + Background: 사전 작업 + Given 세션 여러개를 생성하고 + And 미션 여러개를 생성하고 - Scenario: 존재하지 않는 멤버로 배지 조회하기 - When 존재하지 않는 멤버의 배지를 조회하면 - Then 존재하지 않는 멤버 관련 예외가 발생한다 + Scenario: 존재하지 않는 멤버로 배지 조회하기 + When 존재하지 않는 멤버의 배지를 조회하면 + Then 존재하지 않는 멤버 관련 예외가 발생한다 - Scenario: 배지목록 조회하기 - Given "브라운"이 로그인을 하고 - And 여러개의 스터디로그를 작성하고 - When 배지를 조회하면 - Then 열정왕 배지를 부여한다. + Scenario: 배지목록 조회하기 + Given "브라운"이 로그인을 하고 + And 여러개의 스터디로그를 작성하고 + When 배지를 조회하면 + Then 열정왕 배지를 부여한다. diff --git a/backend/src/acceptanceTest/resources/wooteco/prolog/comment.feature b/backend/src/acceptanceTest/resources/wooteco/prolog/comment.feature index 7425ea5e0..361ad0fc3 100644 --- a/backend/src/acceptanceTest/resources/wooteco/prolog/comment.feature +++ b/backend/src/acceptanceTest/resources/wooteco/prolog/comment.feature @@ -1,29 +1,29 @@ @api Feature: 댓글 관련 기능 - Background: 사전 작업 - Given "브라운"이 로그인을 하고 - And 세션 여러개를 생성하고 - And 미션 여러개를 생성하고 - And 스터디로그를 작성하면 + Background: 사전 작업 + Given "브라운"이 로그인을 하고 + And 세션 여러개를 생성하고 + And 미션 여러개를 생성하고 + And 스터디로그를 작성하면 - Scenario: 댓글 작성하기 - When 1번 스터디로그에 대한 댓글을 작성하면 - Then 댓글이 작성된다 + Scenario: 댓글 작성하기 + When 1번 스터디로그에 대한 댓글을 작성하면 + Then 댓글이 작성된다 - Scenario: 스터디로그의 댓글 목록 조회하기 - Given 1번 스터디로그에 대한 댓글을 작성하고 - And "웨지"가 로그인을 하고 - And 1번 스터디로그에 대한 댓글을 작성하고 - When 1번 스터디로그의 댓글을 조회하면 - Then 해당 스터디로그의 댓글 목록을 조회한다 + Scenario: 스터디로그의 댓글 목록 조회하기 + Given 1번 스터디로그에 대한 댓글을 작성하고 + And "웨지"가 로그인을 하고 + And 1번 스터디로그에 대한 댓글을 작성하고 + When 1번 스터디로그의 댓글을 조회하면 + Then 해당 스터디로그의 댓글 목록을 조회한다 - Scenario: 댓글 수정하기 - Given 1번 스터디로그에 대한 댓글을 작성하고 - When 1번 스터디로그에 대한 1번 댓글을 수정하면 - Then 댓글이 수정된다 + Scenario: 댓글 수정하기 + Given 1번 스터디로그에 대한 댓글을 작성하고 + When 1번 스터디로그에 대한 1번 댓글을 수정하면 + Then 댓글이 수정된다 - Scenario: 댓글 삭제하기 - Given 1번 스터디로그에 대한 댓글을 작성하고 - When 1번 스터디로그에 대한 1번 댓글을 삭제하면 - Then 댓글이 삭제된다 + Scenario: 댓글 삭제하기 + Given 1번 스터디로그에 대한 댓글을 작성하고 + When 1번 스터디로그에 대한 1번 댓글을 삭제하면 + Then 댓글이 삭제된다 diff --git a/backend/src/acceptanceTest/resources/wooteco/prolog/curriculum.feature b/backend/src/acceptanceTest/resources/wooteco/prolog/curriculum.feature index 1269a8213..757cffe71 100644 --- a/backend/src/acceptanceTest/resources/wooteco/prolog/curriculum.feature +++ b/backend/src/acceptanceTest/resources/wooteco/prolog/curriculum.feature @@ -1,25 +1,25 @@ @api Feature: 커리큘럼 관련 기능 - Background: 사전 작업 - Given "수달"이 로그인을 하고 + Background: 사전 작업 + Given "수달"이 로그인을 하고 - Scenario: 커리큘럼 생성하기 - When 커리큘럼을 생성하면 - Then 커리큘럼이 생성된다 + Scenario: 커리큘럼 생성하기 + When 커리큘럼을 생성하면 + Then 커리큘럼이 생성된다 - Scenario: 커리큘럼 목록 조회하기 - When 커리큘럼을 생성하고 - And 커리쿨럼을 조회하면 - Then 커리큘럼이 조회된다 + Scenario: 커리큘럼 목록 조회하기 + When 커리큘럼을 생성하고 + And 커리쿨럼을 조회하면 + Then 커리큘럼이 조회된다 - Scenario: 커리큘럼 수정하기 - When 커리큘럼을 생성하고 - And 1번 커리쿨럼을 수정하면 - Then 커리큘럼이 수정된다 + Scenario: 커리큘럼 수정하기 + When 커리큘럼을 생성하고 + And 1번 커리쿨럼을 수정하면 + Then 커리큘럼이 수정된다 - Scenario: 커리큘럼 삭제하기 - When 커리큘럼을 생성하고 - And 1번 커리쿨럼을 삭제하면 - Then 커리큘럼이 삭제된다 + Scenario: 커리큘럼 삭제하기 + When 커리큘럼을 생성하고 + And 1번 커리쿨럼을 삭제하면 + Then 커리큘럼이 삭제된다 diff --git a/backend/src/acceptanceTest/resources/wooteco/prolog/filter.feature b/backend/src/acceptanceTest/resources/wooteco/prolog/filter.feature index e57d70074..203cd1dd3 100644 --- a/backend/src/acceptanceTest/resources/wooteco/prolog/filter.feature +++ b/backend/src/acceptanceTest/resources/wooteco/prolog/filter.feature @@ -1,11 +1,11 @@ @api Feature: 필터 관련 기능 - Background: 사전 작업 - Given "현구막"이 로그인을 하고 - And "브라운"이 로그인을 하고 - And "서니"가 로그인을 하고 + Background: 사전 작업 + Given "현구막"이 로그인을 하고 + And "브라운"이 로그인을 하고 + And "서니"가 로그인을 하고 - Scenario: 필터 목록 조회하기 - When 필터요청이 들어오면 - Then nickname을 기준으로 멤버데이터들을 오름차순 정렬하여 반환한다 + Scenario: 필터 목록 조회하기 + When 필터요청이 들어오면 + Then nickname을 기준으로 멤버데이터들을 오름차순 정렬하여 반환한다 diff --git a/backend/src/acceptanceTest/resources/wooteco/prolog/keyword.feature b/backend/src/acceptanceTest/resources/wooteco/prolog/keyword.feature index 06f654ad5..cce3a3cda 100644 --- a/backend/src/acceptanceTest/resources/wooteco/prolog/keyword.feature +++ b/backend/src/acceptanceTest/resources/wooteco/prolog/keyword.feature @@ -1,39 +1,39 @@ @api Feature: 로드맵 키워드 관련 기능 - Background: 사전 작업 - Given "2022 백엔드 레벨1" 세션을 생성하고 - 1번 세션 - And "2022 프론트엔드 레벨1" 세션을 생성하고 - 2번 세션 + Background: 사전 작업 + Given "2022 백엔드 레벨1" 세션을 생성하고 - 1번 세션 + And "2022 프론트엔드 레벨1" 세션을 생성하고 - 2번 세션 - Scenario: 키워드 생성하기 - When 1번 세션에 "자바"라는 키워드를 순서 1, 중요도 1로 작성하면 - Then 키워드가 생성된다 + Scenario: 키워드 생성하기 + When 1번 세션에 "자바"라는 키워드를 순서 1, 중요도 1로 작성하면 + Then 키워드가 생성된다 - Scenario: 키워드 단일 조회하기 - Given 1번 세션에 "자바"라는 키워드를 순서 1, 중요도 1로 작성하고 - When 1번 세션과 1번 키워드를 조회하면 - Then 키워드가 조회된다 + Scenario: 키워드 단일 조회하기 + Given 1번 세션에 "자바"라는 키워드를 순서 1, 중요도 1로 작성하고 + When 1번 세션과 1번 키워드를 조회하면 + Then 키워드가 조회된다 - Scenario: 키워드 수정하기 - Given 1번 세션에 "자바"라는 키워드를 순서 1, 중요도 1로 작성하고 - When 1번 세션과 1번 키워드를 키워드 "스프링", 순서 1, 중요도 2로 수정하면 - Then 키워드가 수정된다 + Scenario: 키워드 수정하기 + Given 1번 세션에 "자바"라는 키워드를 순서 1, 중요도 1로 작성하고 + When 1번 세션과 1번 키워드를 키워드 "스프링", 순서 1, 중요도 2로 수정하면 + Then 키워드가 수정된다 - Scenario: 키워드 삭제하기 - Given 1번 세션에 "자바"라는 키워드를 순서 1, 중요도 1로 작성하고 - When 1번 세션에 대한 1번 키워드를 삭제하면 - Then 키워드가 삭제된다 + Scenario: 키워드 삭제하기 + Given 1번 세션에 "자바"라는 키워드를 순서 1, 중요도 1로 작성하고 + When 1번 세션에 대한 1번 키워드를 삭제하면 + Then 키워드가 삭제된다 - Scenario: 세션별 최상위 키워드 목록 조회하기 - Given 1번 세션에 "자바"라는 키워드를 순서 1, 중요도 1로 작성하고 - And 1번 세션에 "스프링"라는 키워드를 순서 1, 중요도 1로 작성하고 - When 1번 세션에 대해서 최상위 키워드들을 조회하면 - Then 키워드 목록이 조회된다 + Scenario: 세션별 최상위 키워드 목록 조회하기 + Given 1번 세션에 "자바"라는 키워드를 순서 1, 중요도 1로 작성하고 + And 1번 세션에 "스프링"라는 키워드를 순서 1, 중요도 1로 작성하고 + When 1번 세션에 대해서 최상위 키워드들을 조회하면 + Then 키워드 목록이 조회된다 - Scenario: 최상위 키워드의 모든 자식 키워드를 조회하기 - Given 1번 세션에 "자바"라는 키워드를 순서 1, 중요도 1로 작성하고 - And 1번 세션에 "List"라는 키워드를 순서 1, 중요도 1, 부모 키워드 1로 작성하고 - And 1번 세션에 "List.of()"라는 키워드를 순서 1, 중요도 1, 부모 키워드 2로 작성하고 - And 1번 세션에 "Set"라는 키워드를 순서 1, 중요도 1, 부모 키워드 1로 작성하고 - When 1번 세션에 대한 1번 키워드와 자식 키워드를 함께 조회하면 - Then 키워드 목록이 조회된다 + Scenario: 최상위 키워드의 모든 자식 키워드를 조회하기 + Given 1번 세션에 "자바"라는 키워드를 순서 1, 중요도 1로 작성하고 + And 1번 세션에 "List"라는 키워드를 순서 1, 중요도 1, 부모 키워드 1로 작성하고 + And 1번 세션에 "List.of()"라는 키워드를 순서 1, 중요도 1, 부모 키워드 2로 작성하고 + And 1번 세션에 "Set"라는 키워드를 순서 1, 중요도 1, 부모 키워드 1로 작성하고 + When 1번 세션에 대한 1번 키워드와 자식 키워드를 함께 조회하면 + Then 키워드 목록이 조회된다 diff --git a/backend/src/acceptanceTest/resources/wooteco/prolog/levellogs.feature b/backend/src/acceptanceTest/resources/wooteco/prolog/levellogs.feature index 6577ceee4..0af1c9994 100644 --- a/backend/src/acceptanceTest/resources/wooteco/prolog/levellogs.feature +++ b/backend/src/acceptanceTest/resources/wooteco/prolog/levellogs.feature @@ -1,25 +1,25 @@ @api Feature: 레벨 로그 관련 기능 - Background: 사전 작업 - Given "브라운"이 로그인을 하고 + Background: 사전 작업 + Given "브라운"이 로그인을 하고 - Scenario: 레벨 로그 작성하기 - When 레벨로그를 작성하면 - Then 레벨로그가 조회된다 + Scenario: 레벨 로그 작성하기 + When 레벨로그를 작성하면 + Then 레벨로그가 조회된다 - Scenario: 레벨 로그 삭제하기 - When 레벨로그를 작성하고 - And 레벨로그를 삭제하면 - Then 레벨로그가 삭제된다 + Scenario: 레벨 로그 삭제하기 + When 레벨로그를 작성하고 + And 레벨로그를 삭제하면 + Then 레벨로그가 삭제된다 - Scenario: 레벨 로그 수정하기 - When 레벨로그를 작성하고 - And 레벨로그를 수정하면 - Then 레벨로그가 수정된다 + Scenario: 레벨 로그 수정하기 + When 레벨로그를 작성하고 + And 레벨로그를 수정하면 + Then 레벨로그가 수정된다 - Scenario: 레벨 로그 목록 조회하기 - When 레벨로그를 여러개 작성하면 - Then 레벨로그가 여러개 조회된다 + Scenario: 레벨 로그 목록 조회하기 + When 레벨로그를 여러개 작성하면 + Then 레벨로그가 여러개 조회된다 diff --git a/backend/src/acceptanceTest/resources/wooteco/prolog/login.feature b/backend/src/acceptanceTest/resources/wooteco/prolog/login.feature index ca41852d9..6126ba5b6 100644 --- a/backend/src/acceptanceTest/resources/wooteco/prolog/login.feature +++ b/backend/src/acceptanceTest/resources/wooteco/prolog/login.feature @@ -2,5 +2,5 @@ Feature: 로그인 기능 Scenario: 로그인하기 - When "브라운"이 로그인을 하면 - Then 액세스 토큰을 받는다 \ No newline at end of file + When "브라운"이 로그인을 하면 + Then 액세스 토큰을 받는다 diff --git a/backend/src/acceptanceTest/resources/wooteco/prolog/member.feature b/backend/src/acceptanceTest/resources/wooteco/prolog/member.feature index 216951128..cf56a1f39 100644 --- a/backend/src/acceptanceTest/resources/wooteco/prolog/member.feature +++ b/backend/src/acceptanceTest/resources/wooteco/prolog/member.feature @@ -1,12 +1,12 @@ @api Feature: 멤버 관련 기능 - Scenario: 자신의 멤버정보 조회하기 - Given "브라운"이 로그인을 하고 - When 자신의 멤버 정보를 조회하면 - Then 멤버 정보가 조회된다 + Scenario: 자신의 멤버정보 조회하기 + Given "브라운"이 로그인을 하고 + When 자신의 멤버 정보를 조회하면 + Then 멤버 정보가 조회된다 - Scenario: 자신의 정보를 수정하기 - Given "브라운"이 로그인을 하고 - When 자신의 닉네임을 "brown"으로 수정하면 - Then "브라운"의 닉네임이 "brown"으로 수정 + Scenario: 자신의 정보를 수정하기 + Given "브라운"이 로그인을 하고 + When 자신의 닉네임을 "brown"으로 수정하면 + Then "브라운"의 닉네임이 "brown"으로 수정 diff --git a/backend/src/acceptanceTest/resources/wooteco/prolog/mission.feature b/backend/src/acceptanceTest/resources/wooteco/prolog/mission.feature index 165c8ee80..8762bfc2a 100644 --- a/backend/src/acceptanceTest/resources/wooteco/prolog/mission.feature +++ b/backend/src/acceptanceTest/resources/wooteco/prolog/mission.feature @@ -1,22 +1,22 @@ @api Feature: 로그인 기능 - Background: 사전 작업 - Given 세션 여러개를 생성하고 + Background: 사전 작업 + Given 세션 여러개를 생성하고 - Scenario: 미션 등록하기 - Given "브라운"이 로그인을 하고 - When "이런저런" 미션 등록을 하면 - Then 미션이 등록된다 + Scenario: 미션 등록하기 + Given "브라운"이 로그인을 하고 + When "이런저런" 미션 등록을 하면 + Then 미션이 등록된다 - Scenario: 미션 조회하기 - Given "브라운"이 로그인을 하고 - And "이런저런" 미션 등록을 하고 - When 미션 목록을 조회하면 - Then 미션 목록을 받는다 + Scenario: 미션 조회하기 + Given "브라운"이 로그인을 하고 + And "이런저런" 미션 등록을 하고 + When 미션 목록을 조회하면 + Then 미션 목록을 받는다 - Scenario: 중복된 이름으로 미션 등록하기 - Given "브라운"이 로그인을 하고 - And "이런저런" 미션 등록을 하고 - When "이런저런" 미션 등록을 하면 - Then 미션을 실패한다 \ No newline at end of file + Scenario: 중복된 이름으로 미션 등록하기 + Given "브라운"이 로그인을 하고 + And "이런저런" 미션 등록을 하고 + When "이런저런" 미션 등록을 하면 + Then 미션을 실패한다 diff --git a/backend/src/acceptanceTest/resources/wooteco/prolog/new-session.feature b/backend/src/acceptanceTest/resources/wooteco/prolog/new-session.feature index a85557ce3..1e8463258 100644 --- a/backend/src/acceptanceTest/resources/wooteco/prolog/new-session.feature +++ b/backend/src/acceptanceTest/resources/wooteco/prolog/new-session.feature @@ -1,29 +1,29 @@ @api Feature: 로드맵 키워드 관련 기능 - Background: 사전 작업 + Background: 사전 작업 # 커리큘럼 병합 후 작성 - Scenario: 세션 생성하기 - When 1번 커리큘럼에 "백엔드 레벨1" 세션을 작성하면 - Then 세션이 생성된다 + Scenario: 세션 생성하기 + When 1번 커리큘럼에 "백엔드 레벨1" 세션을 작성하면 + Then 세션이 생성된다 - Scenario: 세션 목록 조회하기 - Given 1번 커리큘럼에 "백엔드 레벨1" 세션을 작성하고 - When 1번 커리큘럼의 세션 목록을 조회하면 - Then 세션 목록이 조회된다 + Scenario: 세션 목록 조회하기 + Given 1번 커리큘럼에 "백엔드 레벨1" 세션을 작성하고 + When 1번 커리큘럼의 세션 목록을 조회하면 + Then 세션 목록이 조회된다 - Scenario: 세션 목록 조회하기 - Given 1번 커리큘럼에 "백엔드 레벨1" 세션을 작성하고 - When 1번 커리큘럼의 세션 목록을 조회하면 - Then 세션 목록이 조회된다 + Scenario: 세션 목록 조회하기 + Given 1번 커리큘럼에 "백엔드 레벨1" 세션을 작성하고 + When 1번 커리큘럼의 세션 목록을 조회하면 + Then 세션 목록이 조회된다 - Scenario: 세션 수정하기 - Given 1번 커리큘럼에 "백엔드 레벨1" 세션을 작성하고 - When 1번 커리큘럼의 1번 세션을 "백엔드 레벨2" 세션으로 수정하면 - Then 세션이 수정된다 + Scenario: 세션 수정하기 + Given 1번 커리큘럼에 "백엔드 레벨1" 세션을 작성하고 + When 1번 커리큘럼의 1번 세션을 "백엔드 레벨2" 세션으로 수정하면 + Then 세션이 수정된다 - Scenario: 세션 삭제하기 - Given 1번 커리큘럼에 "백엔드 레벨1" 세션을 작성하고 - When 1번 커리큘럼의 1번 세션을 삭제하면 - Then 세션이 삭제된다 + Scenario: 세션 삭제하기 + Given 1번 커리큘럼에 "백엔드 레벨1" 세션을 작성하고 + When 1번 커리큘럼의 1번 세션을 삭제하면 + Then 세션이 삭제된다 diff --git a/backend/src/acceptanceTest/resources/wooteco/prolog/profile.feature b/backend/src/acceptanceTest/resources/wooteco/prolog/profile.feature index cd0f2320d..300deab8f 100644 --- a/backend/src/acceptanceTest/resources/wooteco/prolog/profile.feature +++ b/backend/src/acceptanceTest/resources/wooteco/prolog/profile.feature @@ -1,31 +1,32 @@ @api Feature: 프로필 관련 기능 - Background: 사전 작업 - Given 세션 여러개를 생성하고 - And 미션 여러개를 생성하고 - Scenario: 멤버 프로필 조회하기 - Given "브라운"이 로그인을 하고 - Given "서니"이 로그인을 하고 - When "브라운"의 멤버 프로필을 조회하면 - Then "브라운"의 멤버 프로필이 조회된다 + Background: 사전 작업 + Given 세션 여러개를 생성하고 + And 미션 여러개를 생성하고 - Scenario: 멤버 프로필 인트로 조회하기 - Given "브라운"이 로그인을 하고 - Given "브라운"의 멤버 프로필 인트로를 수정하고 - Given "서니"이 로그인을 하고 - When "브라운"의 멤버 프로필 인트로를 조회하면 - Then "브라운"의 멤버 프로필 인트로가 조회된다 + Scenario: 멤버 프로필 조회하기 + Given "브라운"이 로그인을 하고 + Given "서니"이 로그인을 하고 + When "브라운"의 멤버 프로필을 조회하면 + Then "브라운"의 멤버 프로필이 조회된다 - Scenario: 멤버 프로필 인트로 수정하기 - Given "브라운"이 로그인을 하고 - When "브라운"의 멤버 프로필 인트로를 수정하면 - Then "브라운"의 멤버 프로필 인트로가 수정된다 + Scenario: 멤버 프로필 인트로 조회하기 + Given "브라운"이 로그인을 하고 + Given "브라운"의 멤버 프로필 인트로를 수정하고 + Given "서니"이 로그인을 하고 + When "브라운"의 멤버 프로필 인트로를 조회하면 + Then "브라운"의 멤버 프로필 인트로가 조회된다 - Scenario: 멤버 프로필 스터디로그 조회하기 - Given "브라운"이 로그인을 하고 - And 스터디로그 여러개를 작성하고 - And "엘라"가 로그인을 하고 - When "브라운"의 프로필 스터디로그를 조회하면 - Then "브라운"의 프로필 스터디로그가 조회된다 + Scenario: 멤버 프로필 인트로 수정하기 + Given "브라운"이 로그인을 하고 + When "브라운"의 멤버 프로필 인트로를 수정하면 + Then "브라운"의 멤버 프로필 인트로가 수정된다 + + Scenario: 멤버 프로필 스터디로그 조회하기 + Given "브라운"이 로그인을 하고 + And 스터디로그 여러개를 작성하고 + And "엘라"가 로그인을 하고 + When "브라운"의 프로필 스터디로그를 조회하면 + Then "브라운"의 프로필 스터디로그가 조회된다 diff --git a/backend/src/acceptanceTest/resources/wooteco/prolog/quiz.feature b/backend/src/acceptanceTest/resources/wooteco/prolog/quiz.feature index c967951b1..527a89747 100644 --- a/backend/src/acceptanceTest/resources/wooteco/prolog/quiz.feature +++ b/backend/src/acceptanceTest/resources/wooteco/prolog/quiz.feature @@ -1,28 +1,28 @@ @api Feature: 로드맵 키워드 관련 기능 - Background: 사전 작업 - Given "2022 백엔드 레벨1" 세션을 생성하고 - 1번 세션 - When 1번 세션에 "자바"라는 키워드를 순서 1, 중요도 1로 작성하면 - Then 키워드가 생성된다 + Background: 사전 작업 + Given "2022 백엔드 레벨1" 세션을 생성하고 - 1번 세션 + When 1번 세션에 "자바"라는 키워드를 순서 1, 중요도 1로 작성하면 + Then 키워드가 생성된다 - Scenario: 퀴즈 생성하기 - When 1번 세션, 1번 키워드에 퀴즈를 작성하면 - Then 퀴즈가 생성된다 + Scenario: 퀴즈 생성하기 + When 1번 세션, 1번 키워드에 퀴즈를 작성하면 + Then 퀴즈가 생성된다 - Scenario: 퀴즈 단일 조회하기 - When 1번 세션, 1번 키워드에 퀴즈를 작성하면 - And 1번 세션과 1번 키워드와 1번 퀴즈를 조회하면 - Then 퀴즈가 조회된다 + Scenario: 퀴즈 단일 조회하기 + When 1번 세션, 1번 키워드에 퀴즈를 작성하면 + And 1번 세션과 1번 키워드와 1번 퀴즈를 조회하면 + Then 퀴즈가 조회된다 - Scenario: 퀴즈 수정하기 - When 1번 세션, 1번 키워드에 퀴즈를 작성하고 - And 1번 세션과 1번 키워드와 1번 퀴즈 내용을 "수달이수정한퀴즈"으로 수정하면 - Then 퀴즈가 수정된다 + Scenario: 퀴즈 수정하기 + When 1번 세션, 1번 키워드에 퀴즈를 작성하고 + And 1번 세션과 1번 키워드와 1번 퀴즈 내용을 "수달이수정한퀴즈"으로 수정하면 + Then 퀴즈가 수정된다 - Scenario: 퀴즈 삭제하기 - When 1번 세션, 1번 키워드에 퀴즈를 작성하고 - And 1번 세션과 1번 키워드와 1번 퀴즈를 삭제하면 - Then 퀴즈가 삭제된다 + Scenario: 퀴즈 삭제하기 + When 1번 세션, 1번 키워드에 퀴즈를 작성하고 + And 1번 세션과 1번 키워드와 1번 퀴즈를 삭제하면 + Then 퀴즈가 삭제된다 diff --git a/backend/src/acceptanceTest/resources/wooteco/prolog/session.feature b/backend/src/acceptanceTest/resources/wooteco/prolog/session.feature index febb1afa9..6f31acda6 100644 --- a/backend/src/acceptanceTest/resources/wooteco/prolog/session.feature +++ b/backend/src/acceptanceTest/resources/wooteco/prolog/session.feature @@ -1,11 +1,11 @@ @api Feature: 강의 관련 기능 - Scenario: 강의 생성기능 - When "새로운이름" 강의를 추가하면 - Then "새로운이름" 강의가 추가된다 + Scenario: 강의 생성기능 + When "새로운이름" 강의를 추가하면 + Then "새로운이름" 강의가 추가된다 - Scenario: 강의 목록 조회하기 - Given 강의 여러개를 작성하고 - When 강의 목록을 조회하면 - Then 강의 목록을 받는다 \ No newline at end of file + Scenario: 강의 목록 조회하기 + Given 강의 여러개를 작성하고 + When 강의 목록을 조회하면 + Then 강의 목록을 받는다 diff --git a/backend/src/acceptanceTest/resources/wooteco/prolog/sessionmember.feature b/backend/src/acceptanceTest/resources/wooteco/prolog/sessionmember.feature index 2e5131f9b..45f309fa5 100644 --- a/backend/src/acceptanceTest/resources/wooteco/prolog/sessionmember.feature +++ b/backend/src/acceptanceTest/resources/wooteco/prolog/sessionmember.feature @@ -1,14 +1,15 @@ @api Feature: 세션 멤버 기능 - Scenario: 강의에 자신을 등록하는 기능 - Given "브라운" 이 로그인을 하공 - Given "강의1" 추가하면 - When 1 강의에 자신을 등록하면 - Then 강의에 내가 추가된다. - Scenario: 강의에서 자신을 제거하는 기능 - Given "브라운" 이 로그인을 하공 - Given "강의1" 추가하면 - Given 1 강의에 자신을 등록하고 - When 1 강의에서 자신을 제거하면 - Then 강의에서 내가 제거된다. + Scenario: 강의에 자신을 등록하는 기능 + Given "브라운" 이 로그인을 하공 + Given "강의1" 추가하면 + When 1 강의에 자신을 등록하면 + Then 강의에 내가 추가된다. + + Scenario: 강의에서 자신을 제거하는 기능 + Given "브라운" 이 로그인을 하공 + Given "강의1" 추가하면 + Given 1 강의에 자신을 등록하고 + When 1 강의에서 자신을 제거하면 + Then 강의에서 내가 제거된다. diff --git a/backend/src/acceptanceTest/resources/wooteco/prolog/studylog-create.feature b/backend/src/acceptanceTest/resources/wooteco/prolog/studylog-create.feature index d38ba423a..28d37d288 100644 --- a/backend/src/acceptanceTest/resources/wooteco/prolog/studylog-create.feature +++ b/backend/src/acceptanceTest/resources/wooteco/prolog/studylog-create.feature @@ -1,25 +1,25 @@ @api Feature: 스터디로그 관련 기능 - Background: 사전 작업 - Given 세션 여러개를 생성하고 - And 미션 여러개를 생성하고 - And "브라운"이 로그인을 하고 + Background: 사전 작업 + Given 세션 여러개를 생성하고 + And 미션 여러개를 생성하고 + And "브라운"이 로그인을 하고 - Scenario: 스터디로그 작성하기 - When 스터디로그를 작성하면 - Then 스터디로그가 작성된다 + Scenario: 스터디로그 작성하기 + When 스터디로그를 작성하면 + Then 스터디로그가 작성된다 - Scenario: 세션, 미션 없이 스터디로그 작성하기 - When 세션과 미션 없이 스터디로그를 작성하면 - Then 스터디로그가 작성된다 + Scenario: 세션, 미션 없이 스터디로그 작성하기 + When 세션과 미션 없이 스터디로그를 작성하면 + Then 스터디로그가 작성된다 - Scenario: 스터디로그 세션 수정하기 - Given 스터디로그를 작성하고 - When 스터디로그 세션을 2로 수정하면 - Then 스터디로그 세션이 2로 수정된다 + Scenario: 스터디로그 세션 수정하기 + Given 스터디로그를 작성하고 + When 스터디로그 세션을 2로 수정하면 + Then 스터디로그 세션이 2로 수정된다 - Scenario: 스터디로그 미션 수정하기 - Given 스터디로그를 작성하고 - When 스터디로그 미션을 2로 수정하면 - Then 스터디로그 미션이 2로 수정된다 + Scenario: 스터디로그 미션 수정하기 + Given 스터디로그를 작성하고 + When 스터디로그 미션을 2로 수정하면 + Then 스터디로그 미션이 2로 수정된다 diff --git a/backend/src/acceptanceTest/resources/wooteco/prolog/studylog-popular.feature b/backend/src/acceptanceTest/resources/wooteco/prolog/studylog-popular.feature index bf4997a72..c35321b7c 100644 --- a/backend/src/acceptanceTest/resources/wooteco/prolog/studylog-popular.feature +++ b/backend/src/acceptanceTest/resources/wooteco/prolog/studylog-popular.feature @@ -1,14 +1,14 @@ @api Feature: 인기있는 학습로그 관련 기능 - Background: 사전 작업 - Given 세션 여러개를 생성하고 - And 미션 여러개를 생성하고 - And "브라운"이 로그인을 하고 - And "브라운"을 멤버그룹과 그룹멤버에 등록하고 + Background: 사전 작업 + Given 세션 여러개를 생성하고 + And 미션 여러개를 생성하고 + And "브라운"이 로그인을 하고 + And "브라운"을 멤버그룹과 그룹멤버에 등록하고 - Scenario: 인기 있는 순서로 스터디로그 목록 조회하기 - Given 스터디로그 여러개를 작성하고 - When 로그인된 사용자가 2번째 스터디로그를 좋아요 하고 - When 인기 있는 스터디로그 목록을 "2"개만큼 갱신하고 - Then 인기있는 스터디로그 목록 요청시 id "2, 1" 순서로 조회된다 + Scenario: 인기 있는 순서로 스터디로그 목록 조회하기 + Given 스터디로그 여러개를 작성하고 + When 로그인된 사용자가 2번째 스터디로그를 좋아요 하고 + When 인기 있는 스터디로그 목록을 "2"개만큼 갱신하고 + Then 인기있는 스터디로그 목록 요청시 id "2, 1" 순서로 조회된다 diff --git a/backend/src/acceptanceTest/resources/wooteco/prolog/studylog.feature b/backend/src/acceptanceTest/resources/wooteco/prolog/studylog.feature index e0d1d0056..8fb28dba3 100644 --- a/backend/src/acceptanceTest/resources/wooteco/prolog/studylog.feature +++ b/backend/src/acceptanceTest/resources/wooteco/prolog/studylog.feature @@ -1,164 +1,164 @@ @api Feature: 스터디로그 관련 기능 - Background: 사전 작업 - Given 세션 여러개를 생성하고 - And 미션 여러개를 생성하고 - And "브라운"이 로그인을 하고 - - Scenario: 스터디로그 작성하기 - When 스터디로그를 작성하면 - Then 스터디로그가 작성된다 - - Scenario: 스터디로그 수정하기 - Given 스터디로그 여러개를 작성하고 - When 1번째 스터디로그를 수정하면 - Then 1번째 스터디로그가 수정된다 - - Scenario: 다른 계정으로 스터디로그 수정하기 - Given 스터디로그 여러개를 작성하고 - And "웨지"가 로그인을 하고 - When 1번째 스터디로그를 수정하면 - Then 에러 응답을 받는다 - - Scenario: 스터디로그 목록 조회하기 - Given 스터디로그 여러개를 작성하고 - When 스터디로그 목록을 조회하면 - Then 스터디로그 목록을 받는다 - - Scenario: 스터디로그 목록 페이지 조회하기 - Given 70개의 스터디로그를 작성하고 - When 10개, 2쪽의 페이지를 조회하면 - Then 10개의 스터디로그 목록을 받는다 - - Scenario: 조건별 목록 페이지 조회하기 - 미션 - Given 1번 미션의 스터디로그를 9개 작성하고 - Given 2번 미션의 스터디로그를 11개 작성하고 - When 1번 미션의 스터디로그를 조회하면 - Then 9개의 스터디로그 목록을 받는다 - - Scenario: 조건별 스터디로그 목록 페이지 조회하기 - 태그 - Given 1번 태그의 스터디로그를 13개 작성하고 - Given 3번 태그의 스터디로그를 7개 작성하고 - When 총 20개, 1번 태그의 스터디로그를 조회하면 - Then 13개의 스터디로그 목록을 받는다 - - Scenario: 조건별 스터디로그 목록 페이지 조회하기 - 태그 + 미션1 - Given 서로 다른 태그와 미션을 가진 스터디로그를 다수 생성하고 - When 1번 미션과 5번 태그로 조회하면 - Then 6개의 스터디로그 목록을 받는다 - - Scenario: 조건별 스터디로그 목록 페이지 조회하기 - 태그 + 미션2 - Given 서로 다른 태그와 미션을 가진 스터디로그를 다수 생성하고 - When 2번 미션과 3번 태그로 조회하면 - Then 5개의 스터디로그 목록을 받는다 - - Scenario: 조건별 스터디로그 목록 페이지 조회하기 - 태그 + 미션3 - Given 서로 다른 태그와 미션을 가진 스터디로그를 다수 생성하고 - When 1번 미션과 1번 태그로 20개를 조회하면 - Then 13개의 스터디로그 목록을 받는다 - - Scenario: 조건별 스터디로그 목록 페이지 조회하기 - 검색어 - Given 서로 다른 태그와 미션을 가진 스터디로그를 다수 생성하고 - When "학습log"을 검색하면 - Then 10개의 스터디로그 목록을 받는다 - - Scenario: 조건별 스터디로그 목록 페이지 조회하기 - 검색어 - Given 서로 다른 태그와 미션을 가진 스터디로그를 다수 생성하고 - When "학습log"을 검색하면 - Then 10개의 스터디로그를 id의 역순으로 받는다 - - Scenario: 조건별 스터디로그 목록 페이지 조회하기 - 검색어 + 태그 - Given 서로 다른 태그와 미션을 가진 스터디로그를 다수 생성하고 - When "학습log"을 검색하고 1번 태그의 스터디로그를 조회하면 - Then 7개의 스터디로그 목록을 받는다 - - Scenario: 조건별 스터디로그 목록 페이지 조회하기 - 검색어 + 태그 + 미션1 - Given 서로 다른 태그와 미션을 가진 스터디로그를 다수 생성하고 - When "학습log"을 검색하고 2번 미션과 1번 태그로 조회하면 - Then 0개의 스터디로그 목록을 받는다 - - Scenario: 조건별 스터디로그 목록 페이지 조회하기 - 세션 - Given 서로 다른 세션을 가진 스터디로그를 다수 생성하고 - When 1번 세션의 스터디로그를 조회하면 - Then 2개의 스터디로그 목록을 받는다 - - Scenario: 스터디로그 단건 조회하기 - Given 스터디로그 여러개를 작성하고 - When 1번째 스터디로그를 조회하면 - Then 1번째 스터디로그가 조회된다 - - Scenario: 스터디로그 조회 시 조회수 증가하기 - Given 스터디로그 여러개를 작성하고 - When 1번째 스터디로그를 조회하면 - Then 조회된 스터디로그의 조회수가 1로 증가된다 - - Scenario: 작성자가 스터디로그 조회 시 조회수 증가하지 않기 - Given 스터디로그 여러개를 작성하고 - When 로그인된 사용자가 1번째 스터디로그를 조회하면 - Then 조회된 스터디로그의 조회수가 증가되지 않고 0이다 - - Scenario: 작성자가 아닌 로그인된 사용자가 스터디로그 조회 시 조회수 증가하기 - Given 스터디로그 여러개를 작성하고 - And "웨지"가 로그인을 하고 - When 로그인된 사용자가 1번째 스터디로그를 조회하면 - Then 조회된 스터디로그의 조회수가 1로 증가된다 - - Scenario: 조회한 글을 하루 이내에 다시 조회할 경우 조회수는 증가되지 않는다 - Given 스터디로그 여러개를 작성하고 - And "웨지"가 로그인을 하고 - When 로그인된 사용자가 1번째 스터디로그를 조회하면 - Then 조회된 스터디로그의 조회수가 1로 증가된다 - When 로그인된 사용자가 1번째 스터디로그를 이미 조회한 상태로 조회하면 - Then 조회된 스터디로그의 조회수가 증가되지 않고 1이다 - - Scenario: 스터디로그 삭제하기 - Given 스터디로그 여러개를 작성하고 - When 1번째 스터디로그를 삭제하면 - Then 스터디로그가 삭제된다 - - Scenario: 스터디로그 스크랩 하기 - Given 스터디로그 여러개를 작성하고 - When 1번 스터디로그를 스크랩하면 - Then 스크랩한 1번 스터디로그를 볼 수 있다 - When 1번 스터디로그를 스크랩 취소하면 - Then 스크랩한 1번 스터디로그를 볼 수 없다 - - Scenario: 스터디로그 id로 여러개 가져오기 - Given 70개의 스터디로그를 작성하고 - When id "1, 2, 4, 6, 10, 32, 33, 41, 44, 48" 스터디로그를 조회하면 - Then id "1, 2, 4, 6, 10, 32, 33, 41, 44, 48" 스터디로그가 조회된다 - - Scenario: 스터디로그 id로 여러개 가져오기 - Given 70개의 스터디로그를 작성하고 - When id "1, 2, 4, 6, 10, 32, 33, 41, 44, 48, 49, 50, 51" 스터디로그를 조회하면 - Then id "1, 2, 4, 6, 10, 32, 33, 41, 44, 48" 스터디로그가 조회된다 - - Scenario: 스터디로그 좋아요 하기 - Given 스터디로그 여러개를 작성하고 - When 로그인된 사용자가 1번째 스터디로그를 좋아요 하고 - When 1번째 스터디로그를 조회하면 - Then 조회된 스터디로그의 좋아요 수가 증가한다 - - Scenario: 스터디로그 좋아요 취소하기 - Given 스터디로그 여러개를 작성하고 - When 로그인된 사용자가 1번째 스터디로그를 좋아요 하고 - When 로그인된 사용자가 1번째 스터디로그를 좋아요 취소하고 - When 1번째 스터디로그를 조회하면 - Then 조회된 스터디로그의 좋아요 수가 증가하지 않는다 - - Scenario: 로그인 사용자 스터디로그 좋아요 여부 확인하기 - Given 스터디로그 여러개를 작성하고 - When 로그인된 사용자가 1번째 스터디로그를 좋아요 하고 - When 로그인된 사용자가 1번째 스터디로그를 조회하면 - Then 조회된 스터디로그의 좋아요 여부가 참이다 - - Scenario: 로그인 사용자 스터디로그 좋아요 취소 여부 확인하기 - Given 스터디로그 여러개를 작성하고 - When 로그인된 사용자가 1번째 스터디로그를 좋아요 하고 - When 로그인된 사용자가 1번째 스터디로그를 좋아요 취소하고 - When 로그인된 사용자가 1번째 스터디로그를 조회하면 - Then 조회된 스터디로그의 좋아요 여부가 거짓이다 + Background: 사전 작업 + Given 세션 여러개를 생성하고 + And 미션 여러개를 생성하고 + And "브라운"이 로그인을 하고 + + Scenario: 스터디로그 작성하기 + When 스터디로그를 작성하면 + Then 스터디로그가 작성된다 + + Scenario: 스터디로그 수정하기 + Given 스터디로그 여러개를 작성하고 + When 1번째 스터디로그를 수정하면 + Then 1번째 스터디로그가 수정된다 + + Scenario: 다른 계정으로 스터디로그 수정하기 + Given 스터디로그 여러개를 작성하고 + And "웨지"가 로그인을 하고 + When 1번째 스터디로그를 수정하면 + Then 에러 응답을 받는다 + + Scenario: 스터디로그 목록 조회하기 + Given 스터디로그 여러개를 작성하고 + When 스터디로그 목록을 조회하면 + Then 스터디로그 목록을 받는다 + + Scenario: 스터디로그 목록 페이지 조회하기 + Given 70개의 스터디로그를 작성하고 + When 10개, 2쪽의 페이지를 조회하면 + Then 10개의 스터디로그 목록을 받는다 + + Scenario: 조건별 목록 페이지 조회하기 - 미션 + Given 1번 미션의 스터디로그를 9개 작성하고 + Given 2번 미션의 스터디로그를 11개 작성하고 + When 1번 미션의 스터디로그를 조회하면 + Then 9개의 스터디로그 목록을 받는다 + + Scenario: 조건별 스터디로그 목록 페이지 조회하기 - 태그 + Given 1번 태그의 스터디로그를 13개 작성하고 + Given 3번 태그의 스터디로그를 7개 작성하고 + When 총 20개, 1번 태그의 스터디로그를 조회하면 + Then 13개의 스터디로그 목록을 받는다 + + Scenario: 조건별 스터디로그 목록 페이지 조회하기 - 태그 + 미션1 + Given 서로 다른 태그와 미션을 가진 스터디로그를 다수 생성하고 + When 1번 미션과 5번 태그로 조회하면 + Then 6개의 스터디로그 목록을 받는다 + + Scenario: 조건별 스터디로그 목록 페이지 조회하기 - 태그 + 미션2 + Given 서로 다른 태그와 미션을 가진 스터디로그를 다수 생성하고 + When 2번 미션과 3번 태그로 조회하면 + Then 5개의 스터디로그 목록을 받는다 + + Scenario: 조건별 스터디로그 목록 페이지 조회하기 - 태그 + 미션3 + Given 서로 다른 태그와 미션을 가진 스터디로그를 다수 생성하고 + When 1번 미션과 1번 태그로 20개를 조회하면 + Then 13개의 스터디로그 목록을 받는다 + + Scenario: 조건별 스터디로그 목록 페이지 조회하기 - 검색어 + Given 서로 다른 태그와 미션을 가진 스터디로그를 다수 생성하고 + When "학습log"을 검색하면 + Then 10개의 스터디로그 목록을 받는다 + + Scenario: 조건별 스터디로그 목록 페이지 조회하기 - 검색어 + Given 서로 다른 태그와 미션을 가진 스터디로그를 다수 생성하고 + When "학습log"을 검색하면 + Then 10개의 스터디로그를 id의 역순으로 받는다 + + Scenario: 조건별 스터디로그 목록 페이지 조회하기 - 검색어 + 태그 + Given 서로 다른 태그와 미션을 가진 스터디로그를 다수 생성하고 + When "학습log"을 검색하고 1번 태그의 스터디로그를 조회하면 + Then 7개의 스터디로그 목록을 받는다 + + Scenario: 조건별 스터디로그 목록 페이지 조회하기 - 검색어 + 태그 + 미션1 + Given 서로 다른 태그와 미션을 가진 스터디로그를 다수 생성하고 + When "학습log"을 검색하고 2번 미션과 1번 태그로 조회하면 + Then 0개의 스터디로그 목록을 받는다 + + Scenario: 조건별 스터디로그 목록 페이지 조회하기 - 세션 + Given 서로 다른 세션을 가진 스터디로그를 다수 생성하고 + When 1번 세션의 스터디로그를 조회하면 + Then 2개의 스터디로그 목록을 받는다 + + Scenario: 스터디로그 단건 조회하기 + Given 스터디로그 여러개를 작성하고 + When 1번째 스터디로그를 조회하면 + Then 1번째 스터디로그가 조회된다 + + Scenario: 스터디로그 조회 시 조회수 증가하기 + Given 스터디로그 여러개를 작성하고 + When 1번째 스터디로그를 조회하면 + Then 조회된 스터디로그의 조회수가 1로 증가된다 + + Scenario: 작성자가 스터디로그 조회 시 조회수 증가하지 않기 + Given 스터디로그 여러개를 작성하고 + When 로그인된 사용자가 1번째 스터디로그를 조회하면 + Then 조회된 스터디로그의 조회수가 증가되지 않고 0이다 + + Scenario: 작성자가 아닌 로그인된 사용자가 스터디로그 조회 시 조회수 증가하기 + Given 스터디로그 여러개를 작성하고 + And "웨지"가 로그인을 하고 + When 로그인된 사용자가 1번째 스터디로그를 조회하면 + Then 조회된 스터디로그의 조회수가 1로 증가된다 + + Scenario: 조회한 글을 하루 이내에 다시 조회할 경우 조회수는 증가되지 않는다 + Given 스터디로그 여러개를 작성하고 + And "웨지"가 로그인을 하고 + When 로그인된 사용자가 1번째 스터디로그를 조회하면 + Then 조회된 스터디로그의 조회수가 1로 증가된다 + When 로그인된 사용자가 1번째 스터디로그를 이미 조회한 상태로 조회하면 + Then 조회된 스터디로그의 조회수가 증가되지 않고 1이다 + + Scenario: 스터디로그 삭제하기 + Given 스터디로그 여러개를 작성하고 + When 1번째 스터디로그를 삭제하면 + Then 스터디로그가 삭제된다 + + Scenario: 스터디로그 스크랩 하기 + Given 스터디로그 여러개를 작성하고 + When 1번 스터디로그를 스크랩하면 + Then 스크랩한 1번 스터디로그를 볼 수 있다 + When 1번 스터디로그를 스크랩 취소하면 + Then 스크랩한 1번 스터디로그를 볼 수 없다 + + Scenario: 스터디로그 id로 여러개 가져오기 + Given 70개의 스터디로그를 작성하고 + When id "1, 2, 4, 6, 10, 32, 33, 41, 44, 48" 스터디로그를 조회하면 + Then id "1, 2, 4, 6, 10, 32, 33, 41, 44, 48" 스터디로그가 조회된다 + + Scenario: 스터디로그 id로 여러개 가져오기 + Given 70개의 스터디로그를 작성하고 + When id "1, 2, 4, 6, 10, 32, 33, 41, 44, 48, 49, 50, 51" 스터디로그를 조회하면 + Then id "1, 2, 4, 6, 10, 32, 33, 41, 44, 48" 스터디로그가 조회된다 + + Scenario: 스터디로그 좋아요 하기 + Given 스터디로그 여러개를 작성하고 + When 로그인된 사용자가 1번째 스터디로그를 좋아요 하고 + When 1번째 스터디로그를 조회하면 + Then 조회된 스터디로그의 좋아요 수가 증가한다 + + Scenario: 스터디로그 좋아요 취소하기 + Given 스터디로그 여러개를 작성하고 + When 로그인된 사용자가 1번째 스터디로그를 좋아요 하고 + When 로그인된 사용자가 1번째 스터디로그를 좋아요 취소하고 + When 1번째 스터디로그를 조회하면 + Then 조회된 스터디로그의 좋아요 수가 증가하지 않는다 + + Scenario: 로그인 사용자 스터디로그 좋아요 여부 확인하기 + Given 스터디로그 여러개를 작성하고 + When 로그인된 사용자가 1번째 스터디로그를 좋아요 하고 + When 로그인된 사용자가 1번째 스터디로그를 조회하면 + Then 조회된 스터디로그의 좋아요 여부가 참이다 + + Scenario: 로그인 사용자 스터디로그 좋아요 취소 여부 확인하기 + Given 스터디로그 여러개를 작성하고 + When 로그인된 사용자가 1번째 스터디로그를 좋아요 하고 + When 로그인된 사용자가 1번째 스터디로그를 좋아요 취소하고 + When 로그인된 사용자가 1번째 스터디로그를 조회하면 + Then 조회된 스터디로그의 좋아요 여부가 거짓이다 # Scenario: 인기 있는 순서로 스터디로그 목록 조회하기 # Given 스터디로그 여러개를 작성하고 diff --git a/backend/src/acceptanceTest/resources/wooteco/prolog/studylogOverview.feature b/backend/src/acceptanceTest/resources/wooteco/prolog/studylogOverview.feature index ca9b681d7..c54fe0dc3 100644 --- a/backend/src/acceptanceTest/resources/wooteco/prolog/studylogOverview.feature +++ b/backend/src/acceptanceTest/resources/wooteco/prolog/studylogOverview.feature @@ -1,21 +1,21 @@ @api Feature: 스터디로그 오버뷰 기능 - Background: 사전 작업 - Given 세션 여러개를 생성하고 - And 미션 여러개를 생성하고 - And "브라운"이 로그인을 하고 + Background: 사전 작업 + Given 세션 여러개를 생성하고 + And 미션 여러개를 생성하고 + And "브라운"이 로그인을 하고 - Scenario: 해당 유저의 태그 목록 조회하기 - Given 1번 태그의 스터디로그를 1개 작성하고 - Given 2번 태그의 스터디로그를 1개 작성하고 - Given 3번 태그의 스터디로그를 1개 작성하고 - Given 4번 태그의 스터디로그를 1개 작성하고 - When "브라운"의 태그 목록을 조회하면 - Then 해당 유저의 태그 목록이 조회된다 + Scenario: 해당 유저의 태그 목록 조회하기 + Given 1번 태그의 스터디로그를 1개 작성하고 + Given 2번 태그의 스터디로그를 1개 작성하고 + Given 3번 태그의 스터디로그를 1개 작성하고 + Given 4번 태그의 스터디로그를 1개 작성하고 + When "브라운"의 태그 목록을 조회하면 + Then 해당 유저의 태그 목록이 조회된다 - Scenario: 해당 유저의 스터디로그 목록 월별로 조회하기 - Given 1번 태그의 스터디로그를 1개 작성하고 - Given 3번 태그의 스터디로그를 1개 작성하고 - When "브라운"의 이번 달 스터디로그 목록을 조회하면 - Then 해당 유저의 스터디로그 목록이 조회된다 + Scenario: 해당 유저의 스터디로그 목록 월별로 조회하기 + Given 1번 태그의 스터디로그를 1개 작성하고 + Given 3번 태그의 스터디로그를 1개 작성하고 + When "브라운"의 이번 달 스터디로그 목록을 조회하면 + Then 해당 유저의 스터디로그 목록이 조회된다 diff --git a/backend/src/acceptanceTest/resources/wooteco/prolog/tag.feature b/backend/src/acceptanceTest/resources/wooteco/prolog/tag.feature index cac18e135..a8822dc88 100644 --- a/backend/src/acceptanceTest/resources/wooteco/prolog/tag.feature +++ b/backend/src/acceptanceTest/resources/wooteco/prolog/tag.feature @@ -1,16 +1,16 @@ @api Feature: 태그 관련 기능 - Background: 사전 작업 - Given 세션 여러개를 생성하고 - And 미션 여러개를 생성하고 - And "웨지"가 로그인을 하고 + Background: 사전 작업 + Given 세션 여러개를 생성하고 + And 미션 여러개를 생성하고 + And "웨지"가 로그인을 하고 - Scenario: 태그 작성하기 - When 스터디로그를 작성하면 - Then 태그도 작성된다 + Scenario: 태그 작성하기 + When 스터디로그를 작성하면 + Then 태그도 작성된다 - Scenario: 태그 목록 조회하기 - Given 스터디로그 여러개를 작성하고 - When 태그 목록을 조회하면 - Then 태그 목록을 받는다 + Scenario: 태그 목록 조회하기 + Given 스터디로그 여러개를 작성하고 + When 태그 목록을 조회하면 + Then 태그 목록을 받는다 diff --git a/backend/src/documentation/adoc/mission.adoc b/backend/src/documentation/adoc/mission.adoc index 806ba5084..d3c691afe 100644 --- a/backend/src/documentation/adoc/mission.adoc +++ b/backend/src/documentation/adoc/mission.adoc @@ -11,7 +11,6 @@ include::{snippets}/mission/create/success/http-request.adoc[] include::{snippets}/mission/create/success/http-response.adoc[] - === 미션 중복 생성 시 실패 ==== Request @@ -30,4 +29,4 @@ include::{snippets}/mission/list/http-request.adoc[] ==== Response -include::{snippets}/mission/list/http-response.adoc[] \ No newline at end of file +include::{snippets}/mission/list/http-response.adoc[] diff --git a/backend/src/documentation/java/wooteco/prolog/Documentation.java b/backend/src/documentation/java/wooteco/prolog/Documentation.java index 28021c636..60b90313f 100644 --- a/backend/src/documentation/java/wooteco/prolog/Documentation.java +++ b/backend/src/documentation/java/wooteco/prolog/Documentation.java @@ -54,7 +54,7 @@ public RequestSpecification given(String identifier) { return RestAssured .given(spec).log().all() .filter(document(identifier, - preprocessRequest(prettyPrint()), - preprocessResponse(prettyPrint()))); + preprocessRequest(prettyPrint()), + preprocessResponse(prettyPrint()))); } } diff --git a/backend/src/documentation/java/wooteco/prolog/GithubResponses.java b/backend/src/documentation/java/wooteco/prolog/GithubResponses.java index c797b2811..42f6a154d 100644 --- a/backend/src/documentation/java/wooteco/prolog/GithubResponses.java +++ b/backend/src/documentation/java/wooteco/prolog/GithubResponses.java @@ -5,24 +5,24 @@ public enum GithubResponses { 소롱("1", "access_token_1", "소롱", "soulG", "111111", - "https://avatars.githubusercontent.com/u/52682603?v=4"), + "https://avatars.githubusercontent.com/u/52682603?v=4"), 웨지("2", "access_token_2", "웨지", "sihyung92", "222222", - "https://avatars.githubusercontent.com/u/51393021?v=4"), + "https://avatars.githubusercontent.com/u/51393021?v=4"), 서니("3", "access_token_3", "서니", "sunhpark42", "333333", - "https://avatars.githubusercontent.com/u/67677561?v=4"), + "https://avatars.githubusercontent.com/u/67677561?v=4"), 엘라("4", "access_token_4", "엘라", "HyuuunjuKim", "444444", - "https://avatars.githubusercontent.com/u/43339385?v=4"), + "https://avatars.githubusercontent.com/u/43339385?v=4"), 브라운("5", "access_token_5", "브라운", "gracefulBrown", "555555", "https://avatars.githubusercontent.com/u/46308949?v=4"), 티케("6", "access_token_6", "티케", "devhyun637", "59258239", "https://avatars.githubusercontent.com/u/46308949?v=4"); - private String code; - private String accessToken; - private String name; - private String login; - private String id; - private String avatarUrl; + private final String code; + private final String accessToken; + private final String name; + private final String login; + private final String id; + private final String avatarUrl; GithubResponses(String code, String accessToken, String name, String login, String id, String avatarUrl) { diff --git a/backend/src/documentation/java/wooteco/prolog/GithubTestController.java b/backend/src/documentation/java/wooteco/prolog/GithubTestController.java index 21dea31d2..8fe6dae6a 100644 --- a/backend/src/documentation/java/wooteco/prolog/GithubTestController.java +++ b/backend/src/documentation/java/wooteco/prolog/GithubTestController.java @@ -29,9 +29,9 @@ public ResponseEntity user( String accessToken = authorization.split(" ")[1]; GithubResponses githubResponse = GithubResponses.findByToken(accessToken); GithubProfileResponse response = new GithubProfileResponse(githubResponse.getName(), - githubResponse.getLogin(), - githubResponse.getId(), - githubResponse.getAvatarUrl()); + githubResponse.getLogin(), + githubResponse.getId(), + githubResponse.getAvatarUrl()); return ResponseEntity.ok(response); } } diff --git a/backend/src/documentation/java/wooteco/prolog/NewDocumentation.java b/backend/src/documentation/java/wooteco/prolog/NewDocumentation.java index 2553b9e6d..68161a47a 100644 --- a/backend/src/documentation/java/wooteco/prolog/NewDocumentation.java +++ b/backend/src/documentation/java/wooteco/prolog/NewDocumentation.java @@ -23,11 +23,13 @@ public class NewDocumentation { public String accessToken; @BeforeEach - public void setUp(WebApplicationContext webApplicationContext, RestDocumentationContextProvider restDocumentation) { - given = RestAssuredMockMvc.given().mockMvc(MockMvcBuilders.webAppContextSetup(webApplicationContext) + public void setUp(WebApplicationContext webApplicationContext, + RestDocumentationContextProvider restDocumentation) { + given = RestAssuredMockMvc.given() + .mockMvc(MockMvcBuilders.webAppContextSetup(webApplicationContext) .apply(documentationConfiguration(restDocumentation).operationPreprocessors() - .withRequestDefaults(prettyPrint()) - .withResponseDefaults(prettyPrint())) + .withRequestDefaults(prettyPrint()) + .withResponseDefaults(prettyPrint())) .build()).log().all(); accessToken = "accessToken"; diff --git a/backend/src/documentation/java/wooteco/prolog/ResponseFixture.java b/backend/src/documentation/java/wooteco/prolog/ResponseFixture.java index cdafea694..01071cf36 100644 --- a/backend/src/documentation/java/wooteco/prolog/ResponseFixture.java +++ b/backend/src/documentation/java/wooteco/prolog/ResponseFixture.java @@ -25,94 +25,94 @@ public class ResponseFixture { public static final SessionResponse SESSION_RESPONSE = - new SessionResponse(1L, "세션1"); + new SessionResponse(1L, "세션1"); public static final MissionResponse MISSION_RESPONSE1 = - new MissionResponse(1L, "지하철 노선도 미션", SESSION_RESPONSE); + new MissionResponse(1L, "지하철 노선도 미션", SESSION_RESPONSE); public static final MissionResponse MISSION_RESPONSE2 = - new MissionResponse(1L, "로또 미션", SESSION_RESPONSE); + new MissionResponse(1L, "로또 미션", SESSION_RESPONSE); public static final MemberResponse MEMBER_RESPONSE = new MemberResponse( - 1L, - "soulG", - "잉", - CREW, - "https://avatars.githubusercontent.com/u/52682603?v=4" + 1L, + "soulG", + "잉", + CREW, + "https://avatars.githubusercontent.com/u/52682603?v=4" ); public static final StudylogResponse STUDYLOG_RESPONSE1 = new StudylogResponse( - 1L, - MEMBER_RESPONSE, - LocalDateTime.now(), - LocalDateTime.now(), - SESSION_RESPONSE, - MISSION_RESPONSE1, - "JAVA", - "Spring Data JPA를 학습함.", - Arrays.asList(new TagResponse(3L, "java"), new TagResponse(4L, "jpa")), - false, - false, - 0, - false, - 0 + 1L, + MEMBER_RESPONSE, + LocalDateTime.now(), + LocalDateTime.now(), + SESSION_RESPONSE, + MISSION_RESPONSE1, + "JAVA", + "Spring Data JPA를 학습함.", + Arrays.asList(new TagResponse(3L, "java"), new TagResponse(4L, "jpa")), + false, + false, + 0, + false, + 0 ); private static final StudylogResponse STUDYLOG_RESPONSE2 = new StudylogResponse( - 2L, - MEMBER_RESPONSE, - LocalDateTime.now(), - LocalDateTime.now(), - SESSION_RESPONSE, - MISSION_RESPONSE2, - "SPA", - "SPA 방식으로 앱을 구현하였음.\nrouter 를 구현 하여 이용함.\n", - Arrays.asList(new TagResponse(1L, "spa"), new TagResponse(2L, "router")), - false, - false, - 0, - false, - 0 + 2L, + MEMBER_RESPONSE, + LocalDateTime.now(), + LocalDateTime.now(), + SESSION_RESPONSE, + MISSION_RESPONSE2, + "SPA", + "SPA 방식으로 앱을 구현하였음.\nrouter 를 구현 하여 이용함.\n", + Arrays.asList(new TagResponse(1L, "spa"), new TagResponse(2L, "router")), + false, + false, + 0, + false, + 0 ); public static final StudylogsResponse STUDYLOGS_RESPONSE = new StudylogsResponse(Arrays.asList( - STUDYLOG_RESPONSE1, - STUDYLOG_RESPONSE2 + STUDYLOG_RESPONSE1, + STUDYLOG_RESPONSE2 ), 2L, 1, 1); public static final String COMMENT = "댓글의 내용입니다."; public static final CommentsResponse COMMENTS_RESPONSE = new CommentsResponse(Arrays.asList( - new CommentResponse(1L, - new CommentMemberResponse(1L, "yboy", "잉", - "https://avatars.githubusercontent.com/u/52682603?v=4", "CREW") - , COMMENT, - LocalDateTime.now()) + new CommentResponse(1L, + new CommentMemberResponse(1L, "yboy", "잉", + "https://avatars.githubusercontent.com/u/52682603?v=4", "CREW") + , COMMENT, + LocalDateTime.now()) )); public static final Member MEMBER - = new Member("yboy", "잉", Role.CREW, 1L, GithubResponses.소롱.getAvatarUrl()); + = new Member("yboy", "잉", Role.CREW, 1L, GithubResponses.소롱.getAvatarUrl()); public static final TagResponse TAG_RESPONSE1 = new TagResponse(1L, "자바"); public static final TagResponse TAG_RESPONSE2 = new TagResponse(2L, "코틀린"); public static final List TAG_RESPONSES = Arrays.asList( - TAG_RESPONSE1, - TAG_RESPONSE2 + TAG_RESPONSE1, + TAG_RESPONSE2 ); public static final List MEMBER_TAB_RESPONSES = Arrays.asList( - new MemberTagResponse(TAG_RESPONSE1, 2), - new MemberTagResponse(TAG_RESPONSE2, 2) + new MemberTagResponse(TAG_RESPONSE1, 2), + new MemberTagResponse(TAG_RESPONSE2, 2) ); public static final List CALENDER_STUDYLOG_RESPONSES = Arrays.asList( - new CalendarStudylogResponse(1L, "instanceOf()를 지양하자", LocalDateTime.now().minusMonths(2), - LocalDateTime.now()), - new CalendarStudylogResponse(2L, "JPA 쿼리 개선기", LocalDateTime.now().minusMonths(1), - LocalDateTime.now()) + new CalendarStudylogResponse(1L, "instanceOf()를 지양하자", LocalDateTime.now().minusMonths(2), + LocalDateTime.now()), + new CalendarStudylogResponse(2L, "JPA 쿼리 개선기", LocalDateTime.now().minusMonths(1), + LocalDateTime.now()) ); public static final List STUDYLOG_RSS_FEED_RESPONSES = Arrays.asList( - new StudylogRssFeedResponse("Prolog | 우아한테크코스 학습로그 저장소", "자바", "잉", "http://localhost:8080", - Date.from(Instant.now()))); + new StudylogRssFeedResponse("Prolog | 우아한테크코스 학습로그 저장소", "자바", "잉", "http://localhost:8080", + Date.from(Instant.now()))); } diff --git a/backend/src/documentation/java/wooteco/prolog/docu/CommentDocumentation.java b/backend/src/documentation/java/wooteco/prolog/docu/CommentDocumentation.java index 59fcf5f2e..2b67a33d9 100644 --- a/backend/src/documentation/java/wooteco/prolog/docu/CommentDocumentation.java +++ b/backend/src/documentation/java/wooteco/prolog/docu/CommentDocumentation.java @@ -30,11 +30,11 @@ public class CommentDocumentation extends NewDocumentation { //given, when CommentCreateRequest params = new CommentCreateRequest(COMMENT); ValidatableMockMvcResponse response = given - .header("Authorization", "Bearer " + accessToken) - .contentType(MediaType.APPLICATION_JSON_UTF8_VALUE) - .body(params) - .when().post("/studylogs/{studylogId}/comments", 1L) - .then().log().all(); + .header("Authorization", "Bearer " + accessToken) + .contentType(MediaType.APPLICATION_JSON_UTF8_VALUE) + .body(params) + .when().post("/studylogs/{studylogId}/comments", 1L) + .then().log().all(); //then response.expect(status().isCreated()); @@ -48,14 +48,14 @@ public class CommentDocumentation extends NewDocumentation { void 단일_스터디로그에_대한_댓글을_조회한다() { //given given(commentService.findComments(any())) - .willReturn(COMMENTS_RESPONSE); + .willReturn(COMMENTS_RESPONSE); //when ValidatableMockMvcResponse response = given - .header("Authorization", "Bearer " + accessToken) - .contentType(MediaType.APPLICATION_JSON_VALUE) - .when().get("/studylogs/{studylogId}/comments", 1L) - .then().log().all(); + .header("Authorization", "Bearer " + accessToken) + .contentType(MediaType.APPLICATION_JSON_VALUE) + .when().get("/studylogs/{studylogId}/comments", 1L) + .then().log().all(); //then response.expect(status().isOk()); @@ -69,11 +69,11 @@ public class CommentDocumentation extends NewDocumentation { //given, when CommentChangeRequest params = new CommentChangeRequest("수정된 댓글의 내용입니다."); ValidatableMockMvcResponse response = given - .header("Authorization", "Bearer " + accessToken) - .contentType(MediaType.APPLICATION_JSON_UTF8_VALUE) - .body(params) - .when().put("/studylogs/{studylogId}/comments/{commentId}", 1L, 1L) - .then().log().all(); + .header("Authorization", "Bearer " + accessToken) + .contentType(MediaType.APPLICATION_JSON_UTF8_VALUE) + .body(params) + .when().put("/studylogs/{studylogId}/comments/{commentId}", 1L, 1L) + .then().log().all(); //then response.expect(status().isNoContent()); @@ -86,10 +86,10 @@ public class CommentDocumentation extends NewDocumentation { void 댓글을_삭제한다() { //given, when ValidatableMockMvcResponse response = given - .header("Authorization", "Bearer " + accessToken) - .contentType(MediaType.APPLICATION_JSON_UTF8_VALUE) - .when().delete("/studylogs/{studylogId}/comments/{commentId}", 1L, 1L) - .then().log().all(); + .header("Authorization", "Bearer " + accessToken) + .contentType(MediaType.APPLICATION_JSON_UTF8_VALUE) + .when().delete("/studylogs/{studylogId}/comments/{commentId}", 1L, 1L) + .then().log().all(); //then response.expect(status().isNoContent()); diff --git a/backend/src/documentation/java/wooteco/prolog/docu/CurriculumDocumentation.java b/backend/src/documentation/java/wooteco/prolog/docu/CurriculumDocumentation.java index 6e70d46ce..edd0409d2 100644 --- a/backend/src/documentation/java/wooteco/prolog/docu/CurriculumDocumentation.java +++ b/backend/src/documentation/java/wooteco/prolog/docu/CurriculumDocumentation.java @@ -73,13 +73,13 @@ public class CurriculumDocumentation extends NewDocumentation { } - private static CurriculumRequest CURRICULUM_REQUEST = new CurriculumRequest( + private static final CurriculumRequest CURRICULUM_REQUEST = new CurriculumRequest( "수달이 슬로를 위해 만든 커리큘럼"); - private static CurriculumRequest CURRICULUM_EDIT_REQUEST = new CurriculumRequest( + private static final CurriculumRequest CURRICULUM_EDIT_REQUEST = new CurriculumRequest( "수달이 에덴을 위해 수정한 커리큘럼"); - private static CurriculumResponses CURRICULUMS_RESPONSE = new CurriculumResponses( + private static final CurriculumResponses CURRICULUMS_RESPONSE = new CurriculumResponses( Arrays.asList(new CurriculumResponse(1L, "이스트 전용 커리큘럼"), new CurriculumResponse(1L, "동키콩 전용 커리큘럼"))); } diff --git a/backend/src/documentation/java/wooteco/prolog/docu/FilterDocumentation.java b/backend/src/documentation/java/wooteco/prolog/docu/FilterDocumentation.java index d45722d78..5665671e3 100644 --- a/backend/src/documentation/java/wooteco/prolog/docu/FilterDocumentation.java +++ b/backend/src/documentation/java/wooteco/prolog/docu/FilterDocumentation.java @@ -12,8 +12,8 @@ import wooteco.prolog.NewDocumentation; import wooteco.prolog.member.application.dto.MemberResponse; import wooteco.prolog.member.domain.Role; -import wooteco.prolog.session.application.dto.SessionResponse; import wooteco.prolog.session.application.dto.MissionResponse; +import wooteco.prolog.session.application.dto.SessionResponse; import wooteco.prolog.studylog.application.FilterService; import wooteco.prolog.studylog.application.dto.FilterResponse; import wooteco.prolog.studylog.application.dto.TagResponse; @@ -36,18 +36,22 @@ public class FilterDocumentation extends NewDocumentation { private static final FilterResponse FILTER_RESPONSE = new FilterResponse( Lists.newArrayList(new SessionResponse(1L, "세션1"), new SessionResponse(2L, "세션2")), - Lists.newArrayList(new MissionResponse(1L, "지하철 노선도 미션 1", new SessionResponse(1L, "세션1")), new MissionResponse(2L, "지하철 노선도 미션 2", new SessionResponse(2L, "세션2"))), - Lists.newArrayList(new TagResponse(1L, "자바"), new TagResponse(2L, "파이썬"), new TagResponse(3L, "자바스크립트")), + Lists.newArrayList(new MissionResponse(1L, "지하철 노선도 미션 1", new SessionResponse(1L, "세션1")), + new MissionResponse(2L, "지하철 노선도 미션 2", new SessionResponse(2L, "세션2"))), + Lists.newArrayList(new TagResponse(1L, "자바"), new TagResponse(2L, "파이썬"), + new TagResponse(3L, "자바스크립트")), Lists.newArrayList(new MemberResponse(1L, "username", "nickname", Role.CREW, "imageUrl")) ); private static final FilterResponse FILTER_RESPONSE_OF_NICKNAME_ASC_SORT = new FilterResponse( - Lists.newArrayList(new SessionResponse(1L, "세션1"), new SessionResponse(2L, "세션2")), - Lists.newArrayList(new MissionResponse(1L, "지하철 노선도 미션 1", new SessionResponse(1L, "세션1")), new MissionResponse(2L, "지하철 노선도 미션 2", new SessionResponse(2L, "세션2"))), - Lists.newArrayList(new TagResponse(1L, "자바"), new TagResponse(2L, "파이썬"), new TagResponse(3L, "자바스크립트")), - Lists.newArrayList( - new MemberResponse(1L, "username", "브라운", Role.CREW, "imageUrl"), - new MemberResponse(2L, "username", "서니", Role.CREW, "imageUrl"), - new MemberResponse(3L, "username", "현구막", Role.CREW, "imageUrl")) + Lists.newArrayList(new SessionResponse(1L, "세션1"), new SessionResponse(2L, "세션2")), + Lists.newArrayList(new MissionResponse(1L, "지하철 노선도 미션 1", new SessionResponse(1L, "세션1")), + new MissionResponse(2L, "지하철 노선도 미션 2", new SessionResponse(2L, "세션2"))), + Lists.newArrayList(new TagResponse(1L, "자바"), new TagResponse(2L, "파이썬"), + new TagResponse(3L, "자바스크립트")), + Lists.newArrayList( + new MemberResponse(1L, "username", "브라운", Role.CREW, "imageUrl"), + new MemberResponse(2L, "username", "서니", Role.CREW, "imageUrl"), + new MemberResponse(3L, "username", "현구막", Role.CREW, "imageUrl")) ); } diff --git a/backend/src/documentation/java/wooteco/prolog/docu/KeywordDocumentation.java b/backend/src/documentation/java/wooteco/prolog/docu/KeywordDocumentation.java index d8d715429..dd51f1199 100644 --- a/backend/src/documentation/java/wooteco/prolog/docu/KeywordDocumentation.java +++ b/backend/src/documentation/java/wooteco/prolog/docu/KeywordDocumentation.java @@ -73,7 +73,8 @@ public class KeywordDocumentation extends NewDocumentation { @Test void 세션별_키워드_목록_조회() { - given(keywordService.findSessionIncludeRootKeywords(any())).willReturn(KEYWORD_SESSION_INCLUDE_MULTI_RESPONSE); + given(keywordService.findSessionIncludeRootKeywords(any())).willReturn( + KEYWORD_SESSION_INCLUDE_MULTI_RESPONSE); given .when().get("/sessions/1/keywords") @@ -83,7 +84,8 @@ public class KeywordDocumentation extends NewDocumentation { @Test void 최상위_키워드의_모든_자식_키워드들의_목록_조회() { - given(keywordService.findKeywordWithAllChild(any(), any())).willReturn(KEYWORD_WITH_ALL_CHILD_MULTI_RESPONSE); + given(keywordService.findKeywordWithAllChild(any(), any())).willReturn( + KEYWORD_WITH_ALL_CHILD_MULTI_RESPONSE); given .when().get("/sessions/1/keywords/1/children") diff --git a/backend/src/documentation/java/wooteco/prolog/docu/LoginDocumentation.java b/backend/src/documentation/java/wooteco/prolog/docu/LoginDocumentation.java index 707669348..9386aaf6c 100644 --- a/backend/src/documentation/java/wooteco/prolog/docu/LoginDocumentation.java +++ b/backend/src/documentation/java/wooteco/prolog/docu/LoginDocumentation.java @@ -28,15 +28,15 @@ public class LoginDocumentation extends NewDocumentation { void 토큰을_생성한다() { //given given(loginService.createToken(any())) - .willReturn(TokenResponse.of(accessToken)); + .willReturn(TokenResponse.of(accessToken)); //when TokenRequest params = new TokenRequest(GithubResponses.소롱.getCode()); ValidatableMockMvcResponse response = given - .contentType(MediaType.APPLICATION_JSON_VALUE) - .body(params) - .when().post("/login/token") - .then().log().all(); + .contentType(MediaType.APPLICATION_JSON_VALUE) + .body(params) + .when().post("/login/token") + .then().log().all(); //then response.expect(status().isOk()); diff --git a/backend/src/documentation/java/wooteco/prolog/docu/MemberDocumentation.java b/backend/src/documentation/java/wooteco/prolog/docu/MemberDocumentation.java index 060f1c528..c661e71f0 100644 --- a/backend/src/documentation/java/wooteco/prolog/docu/MemberDocumentation.java +++ b/backend/src/documentation/java/wooteco/prolog/docu/MemberDocumentation.java @@ -28,14 +28,14 @@ public class MemberDocumentation extends NewDocumentation { void 사용자_본인_정보를_조회한다() { //given given(memberService.findById(any())) - .willReturn(MEMBER); + .willReturn(MEMBER); //when ValidatableMockMvcResponse response = given - .header("Authorization", "Bearer " + accessToken) - .contentType(MediaType.APPLICATION_JSON_VALUE) - .when().get("/members/me") - .then().log().all(); + .header("Authorization", "Bearer " + accessToken) + .contentType(MediaType.APPLICATION_JSON_VALUE) + .when().get("/members/me") + .then().log().all(); //then response.expect(status().isOk()); @@ -48,14 +48,14 @@ public class MemberDocumentation extends NewDocumentation { void 자신의_사용자_정보를_수정한다() { //given, when MemberUpdateRequest params = new MemberUpdateRequest( - "다른이름", - "https://avatars.githubusercontent.com/u/51393021?v=4"); + "다른이름", + "https://avatars.githubusercontent.com/u/51393021?v=4"); ValidatableMockMvcResponse response = given - .header("Authorization", "Bearer " + accessToken) - .contentType(MediaType.APPLICATION_JSON_VALUE) - .body(params) - .when().put("/members/{username}", GithubResponses.소롱.getLogin()) - .then().log().all(); + .header("Authorization", "Bearer " + accessToken) + .contentType(MediaType.APPLICATION_JSON_VALUE) + .body(params) + .when().put("/members/{username}", GithubResponses.소롱.getLogin()) + .then().log().all(); //then response.expect(status().isOk()); @@ -68,14 +68,14 @@ public class MemberDocumentation extends NewDocumentation { void 사용자_정보를_조회한다() { //given given(memberService.findByUsername(any())) - .willReturn(MEMBER); + .willReturn(MEMBER); //when ValidatableMockMvcResponse response = given - .header("Authorization", "Bearer " + accessToken) - .contentType(MediaType.APPLICATION_JSON_VALUE) - .when().get("/members/{username}", GithubResponses.소롱.getLogin()) - .then().log().all(); + .header("Authorization", "Bearer " + accessToken) + .contentType(MediaType.APPLICATION_JSON_VALUE) + .when().get("/members/{username}", GithubResponses.소롱.getLogin()) + .then().log().all(); //then response.expect(status().isOk()); diff --git a/backend/src/documentation/java/wooteco/prolog/docu/MemberReactionDocumentation.java b/backend/src/documentation/java/wooteco/prolog/docu/MemberReactionDocumentation.java index f7c8a18f0..e828db5ec 100644 --- a/backend/src/documentation/java/wooteco/prolog/docu/MemberReactionDocumentation.java +++ b/backend/src/documentation/java/wooteco/prolog/docu/MemberReactionDocumentation.java @@ -30,16 +30,16 @@ public class MemberReactionDocumentation extends NewDocumentation { void 스터디로그를_스크랩한다() { //given given(studylogScrapService.registerScrap(any(), any())) - .willReturn(new MemberScrapResponse(MEMBER_RESPONSE, STUDYLOG_RESPONSE1)); + .willReturn(new MemberScrapResponse(MEMBER_RESPONSE, STUDYLOG_RESPONSE1)); //when MemberScrapRequest params = new MemberScrapRequest(1L); ValidatableMockMvcResponse response = given - .header("Authorization", "Bearer " + accessToken) - .contentType(MediaType.APPLICATION_JSON_VALUE) - .body(params) - .when().post("/members/scrap") - .then().log().all(); + .header("Authorization", "Bearer " + accessToken) + .contentType(MediaType.APPLICATION_JSON_VALUE) + .body(params) + .when().post("/members/scrap") + .then().log().all(); //then response.expect(status().isCreated()); @@ -54,12 +54,12 @@ public class MemberReactionDocumentation extends NewDocumentation { //given, when MemberScrapRequest params = new MemberScrapRequest(1L); ValidatableMockMvcResponse response = given - .header("Authorization", "Bearer " + accessToken) - .contentType(MediaType.APPLICATION_JSON_VALUE) - .body(params) - .formParam("studylog", 1L) - .when().delete("/members/scrap") - .then().log().all(); + .header("Authorization", "Bearer " + accessToken) + .contentType(MediaType.APPLICATION_JSON_VALUE) + .body(params) + .formParam("studylog", 1L) + .when().delete("/members/scrap") + .then().log().all(); //then response.expect(status().isNoContent()); @@ -72,16 +72,16 @@ public class MemberReactionDocumentation extends NewDocumentation { void 스크랩한_스터디로그를_목록을_조회한다() { //given given(studylogScrapService.showScrap(any(), any())) - .willReturn(STUDYLOGS_RESPONSE); + .willReturn(STUDYLOGS_RESPONSE); //when MemberScrapRequest params = new MemberScrapRequest(1L); ValidatableMockMvcResponse response = given - .header("Authorization", "Bearer " + accessToken) - .contentType(MediaType.APPLICATION_JSON_VALUE) - .body(params) - .when().get("/members/scrap") - .then().log().all(); + .header("Authorization", "Bearer " + accessToken) + .contentType(MediaType.APPLICATION_JSON_VALUE) + .body(params) + .when().get("/members/scrap") + .then().log().all(); //then response.expect(status().isOk()); diff --git a/backend/src/documentation/java/wooteco/prolog/docu/MissionDocumentation.java b/backend/src/documentation/java/wooteco/prolog/docu/MissionDocumentation.java index f4e83503c..851abd7b4 100644 --- a/backend/src/documentation/java/wooteco/prolog/docu/MissionDocumentation.java +++ b/backend/src/documentation/java/wooteco/prolog/docu/MissionDocumentation.java @@ -8,19 +8,19 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import static wooteco.prolog.ResponseFixture.MISSION_RESPONSE1; import static wooteco.prolog.ResponseFixture.MISSION_RESPONSE2; +import static wooteco.prolog.common.exception.BadRequestCode.DUPLICATE_MISSION; import io.restassured.module.mockmvc.response.ValidatableMockMvcResponse; import java.util.Arrays; -import java.util.List; import org.junit.jupiter.api.Test; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.MediaType; import wooteco.prolog.NewDocumentation; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.session.application.MissionService; import wooteco.prolog.session.application.dto.MissionRequest; import wooteco.prolog.session.ui.MissionController; -import wooteco.prolog.studylog.exception.DuplicateMissionException; @WebMvcTest(controllers = MissionController.class) public class MissionDocumentation extends NewDocumentation { @@ -32,13 +32,13 @@ public class MissionDocumentation extends NewDocumentation { void 미션_목록을_조회한다() { //given given(missionService.findAll()) - .willReturn(Arrays.asList(MISSION_RESPONSE1, MISSION_RESPONSE2)); + .willReturn(Arrays.asList(MISSION_RESPONSE1, MISSION_RESPONSE2)); //when ValidatableMockMvcResponse response = given - .accept(MediaType.APPLICATION_JSON_VALUE) - .when().get("/missions") - .then().log().all(); + .accept(MediaType.APPLICATION_JSON_VALUE) + .when().get("/missions") + .then().log().all(); //then response.expect(status().isOk()); @@ -51,15 +51,15 @@ public class MissionDocumentation extends NewDocumentation { void 미션을_저장한다() { //given given(missionService.create(any())) - .willReturn(MISSION_RESPONSE1); + .willReturn(MISSION_RESPONSE1); //when MissionRequest params = new MissionRequest("지하철 노선도 미션", 1L); ValidatableMockMvcResponse response = given - .contentType(MediaType.APPLICATION_JSON_UTF8_VALUE) - .body(params) - .when().post("/missions") - .then().log().all(); + .contentType(MediaType.APPLICATION_JSON_UTF8_VALUE) + .body(params) + .when().post("/missions") + .then().log().all(); //then response.expect(status().isOk()); @@ -71,16 +71,16 @@ public class MissionDocumentation extends NewDocumentation { @Test void 미션_이름이_중복될_경우_예외처리한다() { //given - doThrow(new DuplicateMissionException()).when(missionService) - .create(any()); + doThrow(new BadRequestException(DUPLICATE_MISSION)).when(missionService) + .create(any()); //when MissionRequest params = new MissionRequest("지하철 노선도 미션", 1L); ValidatableMockMvcResponse response = given - .contentType(MediaType.APPLICATION_JSON_UTF8_VALUE) - .body(params) - .when().post("/missions") - .then().log().all(); + .contentType(MediaType.APPLICATION_JSON_UTF8_VALUE) + .body(params) + .when().post("/missions") + .then().log().all(); //then response.expect(status().isBadRequest()); diff --git a/backend/src/documentation/java/wooteco/prolog/docu/ProfileDocumentation.java b/backend/src/documentation/java/wooteco/prolog/docu/ProfileDocumentation.java index 7a406cd18..c78e31621 100644 --- a/backend/src/documentation/java/wooteco/prolog/docu/ProfileDocumentation.java +++ b/backend/src/documentation/java/wooteco/prolog/docu/ProfileDocumentation.java @@ -33,14 +33,15 @@ public class ProfileDocumentation extends NewDocumentation { public void 스터디로그_목록을_작성자별로_조회한다() { //given given(studylogService - .findStudylogsWithoutKeyword(any(), any(), any(), any(), any(), any(), any(), any(), any())) - .willReturn(STUDYLOGS_RESPONSE); + .findStudylogsWithoutKeyword(any(), any(), any(), any(), any(), any(), any(), any(), + any())) + .willReturn(STUDYLOGS_RESPONSE); //when ValidatableMockMvcResponse response = given - .accept(MediaType.APPLICATION_JSON_VALUE) - .when().get("/members/{username}/studylogs", GithubResponses.소롱.getLogin()) - .then().log().all(); + .accept(MediaType.APPLICATION_JSON_VALUE) + .when().get("/members/{username}/studylogs", GithubResponses.소롱.getLogin()) + .then().log().all(); //then response.expect(status().isOk()); @@ -53,13 +54,13 @@ public class ProfileDocumentation extends NewDocumentation { void 사용자_프로필을_조회한다() { //given given(memberService.findMemberResponseByUsername(any())) - .willReturn(MEMBER_RESPONSE); + .willReturn(MEMBER_RESPONSE); //when ValidatableMockMvcResponse response = given - .accept(MediaType.APPLICATION_JSON_VALUE) - .when().get("/members/{username}/profile", GithubResponses.소롱.getLogin()) - .then().log().all(); + .accept(MediaType.APPLICATION_JSON_VALUE) + .when().get("/members/{username}/profile", GithubResponses.소롱.getLogin()) + .then().log().all(); //then response.expect(status().isOk()); @@ -72,13 +73,13 @@ public class ProfileDocumentation extends NewDocumentation { void 사용자_소개글을_조회한다() { //given given(memberService.findProfileIntro(any())) - .willReturn(new ProfileIntroResponse("안녕하세요 잉입니다.")); + .willReturn(new ProfileIntroResponse("안녕하세요 잉입니다.")); //when ValidatableMockMvcResponse response = given - .accept(MediaType.APPLICATION_JSON_VALUE) - .when().get("/members/{username}/profile-intro", GithubResponses.소롱.getLogin()) - .then().log().all(); + .accept(MediaType.APPLICATION_JSON_VALUE) + .when().get("/members/{username}/profile-intro", GithubResponses.소롱.getLogin()) + .then().log().all(); //then response.expect(status().isOk()); @@ -91,16 +92,16 @@ public class ProfileDocumentation extends NewDocumentation { void 사용자가_본인의_소개글을_수정한다() { //given given(memberService.findProfileIntro(any())) - .willReturn(new ProfileIntroResponse("안녕하세요 잉입니다.")); + .willReturn(new ProfileIntroResponse("안녕하세요 잉입니다.")); //when ProfileIntroRequest params = new ProfileIntroRequest("수정된 소개글 입니다."); ValidatableMockMvcResponse response = given - .header("Authorization", "Bearer " + accessToken) - .contentType(MediaType.APPLICATION_JSON_UTF8_VALUE) - .body(params) - .when().put("/members/{username}/profile-intro", GithubResponses.소롱.getLogin()) - .then().log().all(); + .header("Authorization", "Bearer " + accessToken) + .contentType(MediaType.APPLICATION_JSON_UTF8_VALUE) + .body(params) + .when().put("/members/{username}/profile-intro", GithubResponses.소롱.getLogin()) + .then().log().all(); //then response.expect(status().isOk()); diff --git a/backend/src/documentation/java/wooteco/prolog/docu/SessionDocumentation.java b/backend/src/documentation/java/wooteco/prolog/docu/SessionDocumentation.java index c3252652c..c688ed633 100644 --- a/backend/src/documentation/java/wooteco/prolog/docu/SessionDocumentation.java +++ b/backend/src/documentation/java/wooteco/prolog/docu/SessionDocumentation.java @@ -33,7 +33,8 @@ public class SessionDocumentation extends NewDocumentation { .contentType(MediaType.APPLICATION_JSON_UTF8_VALUE) .body(LEVEL_REQUEST) .when().post("/sessions") - .then().log().all().apply(document("sessions/create")).statusCode(HttpStatus.CREATED.value()); + .then().log().all().apply(document("sessions/create")) + .statusCode(HttpStatus.CREATED.value()); } diff --git a/backend/src/documentation/java/wooteco/prolog/docu/SessionMemberDocumentation.java b/backend/src/documentation/java/wooteco/prolog/docu/SessionMemberDocumentation.java index 66ca1c8d3..e0985ed2a 100644 --- a/backend/src/documentation/java/wooteco/prolog/docu/SessionMemberDocumentation.java +++ b/backend/src/documentation/java/wooteco/prolog/docu/SessionMemberDocumentation.java @@ -22,10 +22,10 @@ public class SessionMemberDocumentation extends NewDocumentation { void 강의에_자신을_등록한다() { //given, when ValidatableMockMvcResponse response = given - .header("Authorization", "Bearer " + accessToken) - .contentType(MediaType.APPLICATION_JSON_VALUE) - .when().post("/sessions/{sessionId}/members/me", 1L) - .then().log().all(); + .header("Authorization", "Bearer " + accessToken) + .contentType(MediaType.APPLICATION_JSON_VALUE) + .when().post("/sessions/{sessionId}/members/me", 1L) + .then().log().all(); //then response.expect(status().isOk()); @@ -38,10 +38,10 @@ public class SessionMemberDocumentation extends NewDocumentation { void 강의에서_자신을_제거한다() { //given, when ValidatableMockMvcResponse response = given - .header("Authorization", "Bearer " + accessToken) - .contentType(MediaType.APPLICATION_JSON_VALUE) - .when().delete("/sessions/{sessionId}/members/me", 1L) - .then().log().all(); + .header("Authorization", "Bearer " + accessToken) + .contentType(MediaType.APPLICATION_JSON_VALUE) + .when().delete("/sessions/{sessionId}/members/me", 1L) + .then().log().all(); //then response.expect(status().isOk()); diff --git a/backend/src/documentation/java/wooteco/prolog/docu/StudylogDocumentation.java b/backend/src/documentation/java/wooteco/prolog/docu/StudylogDocumentation.java index 36cdba458..96e3341c5 100644 --- a/backend/src/documentation/java/wooteco/prolog/docu/StudylogDocumentation.java +++ b/backend/src/documentation/java/wooteco/prolog/docu/StudylogDocumentation.java @@ -1,8 +1,14 @@ package wooteco.prolog.docu; +import static org.assertj.core.api.Assertions.assertThat; + import io.restassured.RestAssured; import io.restassured.response.ExtractableResponse; import io.restassured.response.Response; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -20,14 +26,11 @@ import wooteco.prolog.session.application.dto.MissionResponse; import wooteco.prolog.session.application.dto.SessionRequest; import wooteco.prolog.session.application.dto.SessionResponse; -import wooteco.prolog.studylog.application.dto.*; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.stream.Collectors; - -import static org.assertj.core.api.Assertions.assertThat; +import wooteco.prolog.studylog.application.dto.PopularStudylogsResponse; +import wooteco.prolog.studylog.application.dto.StudylogRequest; +import wooteco.prolog.studylog.application.dto.StudylogResponse; +import wooteco.prolog.studylog.application.dto.StudylogsResponse; +import wooteco.prolog.studylog.application.dto.TagRequest; class StudylogDocumentation extends Documentation { @@ -69,11 +72,11 @@ class StudylogDocumentation extends Documentation { void 스터디로그_임시저장_한다() { //given, when ExtractableResponse createResponse = given("studylog/create/temp") - .header("Authorization", "Bearer " + 로그인_사용자.getAccessToken()) - .body(createStudylogRequest1()) - .contentType(MediaType.APPLICATION_JSON_VALUE) - .when().put("/studylogs/temp") - .then().log().all().extract(); + .header("Authorization", "Bearer " + 로그인_사용자.getAccessToken()) + .body(createStudylogRequest1()) + .contentType(MediaType.APPLICATION_JSON_VALUE) + .when().put("/studylogs/temp") + .then().log().all().extract(); //then assertThat(createResponse.statusCode()).isEqualTo(HttpStatus.CREATED.value()); @@ -84,17 +87,17 @@ class StudylogDocumentation extends Documentation { void 임시저장_스터디로그_조회한다() { //given given("studylog/create/temp") - .header("Authorization", "Bearer " + 로그인_사용자.getAccessToken()) - .body(createStudylogRequest1()) - .contentType(MediaType.APPLICATION_JSON_VALUE) - .when().put("/studylogs/temp") - .then().log().all().extract(); + .header("Authorization", "Bearer " + 로그인_사용자.getAccessToken()) + .body(createStudylogRequest1()) + .contentType(MediaType.APPLICATION_JSON_VALUE) + .when().put("/studylogs/temp") + .then().log().all().extract(); //when ExtractableResponse createResponse = given("studylog/create/temp") - .header("Authorization", "Bearer " + 로그인_사용자.getAccessToken()) - .contentType(MediaType.APPLICATION_JSON_VALUE) - .when().get("/studylogs/temp") - .then().log().all().extract(); + .header("Authorization", "Bearer " + 로그인_사용자.getAccessToken()) + .contentType(MediaType.APPLICATION_JSON_VALUE) + .when().get("/studylogs/temp") + .then().log().all().extract(); // then assertThat(createResponse.statusCode()).isEqualTo(HttpStatus.OK.value()); @@ -169,7 +172,8 @@ class StudylogDocumentation extends Documentation { .then().log().all().extract(); // then - PopularStudylogsResponse popularStudylogsResponse = response.as(PopularStudylogsResponse.class); + PopularStudylogsResponse popularStudylogsResponse = response.as( + PopularStudylogsResponse.class); assertThat(popularStudylogsResponse.getAllResponse().getData()).hasSize(3); assertThat(popularStudylogsResponse.getFrontResponse().getData()).hasSize(3); assertThat(popularStudylogsResponse.getBackResponse().getData()).hasSize(3); @@ -311,7 +315,8 @@ private StudylogRequest createStudylogRequest3() { MemberGroup 프론트엔드 = memberGroupRepository.save( new MemberGroup(null, "4기 프론트엔드", "4기 프론트엔드 설명")); MemberGroup 백엔드 = memberGroupRepository.save(new MemberGroup(null, "4기 백엔드", "4기 백엔드 설명")); - MemberGroup 안드로이드 = memberGroupRepository.save(new MemberGroup(null, "4기 안드로이드", "4기 안드로이드 설명")); + MemberGroup 안드로이드 = memberGroupRepository.save( + new MemberGroup(null, "4기 안드로이드", "4기 안드로이드 설명")); groupMemberRepository.save(new GroupMember(null, member, 백엔드)); groupMemberRepository.save(new GroupMember(null, member, 프론트엔드)); groupMemberRepository.save(new GroupMember(null, member, 안드로이드)); diff --git a/backend/src/documentation/java/wooteco/prolog/docu/StudylogOverviewDocumentation.java b/backend/src/documentation/java/wooteco/prolog/docu/StudylogOverviewDocumentation.java index 30822d0f7..5780567ce 100644 --- a/backend/src/documentation/java/wooteco/prolog/docu/StudylogOverviewDocumentation.java +++ b/backend/src/documentation/java/wooteco/prolog/docu/StudylogOverviewDocumentation.java @@ -31,14 +31,14 @@ public class StudylogOverviewDocumentation extends NewDocumentation { void 유저의_태그를_조회한다() { //given given(memberTagService.findByMember(any())) - .willReturn(MEMBER_TAB_RESPONSES); + .willReturn(MEMBER_TAB_RESPONSES); //when ValidatableMockMvcResponse response = given - .header("Authorization", "Bearer " + accessToken) - .contentType(MediaType.APPLICATION_JSON_VALUE) - .when().get("/members/{username}/tags", GithubResponses.브라운.getLogin()) - .then().log().all(); + .header("Authorization", "Bearer " + accessToken) + .contentType(MediaType.APPLICATION_JSON_VALUE) + .when().get("/members/{username}/tags", GithubResponses.브라운.getLogin()) + .then().log().all(); //then response.expect(status().isOk()); @@ -51,16 +51,16 @@ public class StudylogOverviewDocumentation extends NewDocumentation { void 유저의_달력_스터디로그를_조회한다() { //given given(studylogService.findCalendarStudylogs(any(), any())) - .willReturn(CALENDER_STUDYLOG_RESPONSES); + .willReturn(CALENDER_STUDYLOG_RESPONSES); //when ValidatableMockMvcResponse response = given - .header("Authorization", "Bearer " + accessToken) - .contentType(MediaType.APPLICATION_JSON_VALUE) - .param("year", 2021) - .param("month", 8) - .when().get("/members/{username}/calendar-studylogs", GithubResponses.브라운.getLogin()) - .then().log().all(); + .header("Authorization", "Bearer " + accessToken) + .contentType(MediaType.APPLICATION_JSON_VALUE) + .param("year", 2021) + .param("month", 8) + .when().get("/members/{username}/calendar-studylogs", GithubResponses.브라운.getLogin()) + .then().log().all(); //then response.expect(status().isOk()); diff --git a/backend/src/documentation/java/wooteco/prolog/docu/StudylogRssFeedDocumentation.java b/backend/src/documentation/java/wooteco/prolog/docu/StudylogRssFeedDocumentation.java index 6ca2492a0..af1693bba 100644 --- a/backend/src/documentation/java/wooteco/prolog/docu/StudylogRssFeedDocumentation.java +++ b/backend/src/documentation/java/wooteco/prolog/docu/StudylogRssFeedDocumentation.java @@ -4,24 +4,15 @@ import static org.mockito.BDDMockito.given; import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import static wooteco.prolog.ResponseFixture.MEMBER; import static wooteco.prolog.ResponseFixture.STUDYLOG_RSS_FEED_RESPONSES; import io.restassured.module.mockmvc.response.ValidatableMockMvcResponse; -import java.sql.Date; -import java.time.Instant; -import java.util.List; import org.junit.jupiter.api.Test; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.MediaType; import wooteco.prolog.NewDocumentation; -import wooteco.prolog.session.domain.Mission; -import wooteco.prolog.session.domain.Session; import wooteco.prolog.studylog.application.StudylogService; -import wooteco.prolog.studylog.application.dto.StudylogRssFeedResponse; -import wooteco.prolog.studylog.domain.Studylog; -import wooteco.prolog.studylog.domain.Tag; import wooteco.prolog.studylog.ui.StudylogRssFeedController; import wooteco.prolog.studylog.ui.StudylogRssFeedView; @@ -38,14 +29,14 @@ class StudylogRssFeedDocumentation extends NewDocumentation { void RSS_피드를_조회한다() { //given given(studylogService.readRssFeeds(any())) - .willReturn(STUDYLOG_RSS_FEED_RESPONSES); + .willReturn(STUDYLOG_RSS_FEED_RESPONSES); //when ValidatableMockMvcResponse response = given - .header("Authorization", "Bearer " + accessToken) - .contentType(MediaType.APPLICATION_RSS_XML_VALUE) - .when().get("/rss") - .then().log().all(); + .header("Authorization", "Bearer " + accessToken) + .contentType(MediaType.APPLICATION_RSS_XML_VALUE) + .when().get("/rss") + .then().log().all(); //then response.expect(status().isOk()); diff --git a/backend/src/documentation/java/wooteco/prolog/docu/TagDocumentation.java b/backend/src/documentation/java/wooteco/prolog/docu/TagDocumentation.java index 598cd493d..d3b30f61f 100644 --- a/backend/src/documentation/java/wooteco/prolog/docu/TagDocumentation.java +++ b/backend/src/documentation/java/wooteco/prolog/docu/TagDocumentation.java @@ -24,14 +24,14 @@ public class TagDocumentation extends NewDocumentation { void 태그_목록을_조회한다() { //given given(studylogTagService.findTagsIncludedInStudylogs()) - .willReturn(TAG_RESPONSES); + .willReturn(TAG_RESPONSES); //when ValidatableMockMvcResponse response = given - .header("Authorization", "Bearer " + accessToken) - .contentType(MediaType.APPLICATION_JSON_VALUE) - .when().get("/tags") - .then().log().all(); + .header("Authorization", "Bearer " + accessToken) + .contentType(MediaType.APPLICATION_JSON_VALUE) + .when().get("/tags") + .then().log().all(); //then response.expect(status().isOk()); diff --git a/backend/src/main/java/wooteco/prolog/DataLoaderApplicationListener.java b/backend/src/main/java/wooteco/prolog/DataLoaderApplicationListener.java index e95097e35..2763c6058 100644 --- a/backend/src/main/java/wooteco/prolog/DataLoaderApplicationListener.java +++ b/backend/src/main/java/wooteco/prolog/DataLoaderApplicationListener.java @@ -55,7 +55,8 @@ public class DataLoaderApplicationListener implements ApplicationListener { private static final Random random = new SecureRandom(); - private static final Logger logger = LoggerFactory.getLogger(DataLoaderApplicationListener.class); + private static final Logger logger = LoggerFactory.getLogger( + DataLoaderApplicationListener.class); private final EntityManagerFactory entityManagerFactory; private final SessionRepository sessionRepository; @@ -90,8 +91,8 @@ private void cleanUp() { final EntityManager entityManager = entityManagerFactory.createEntityManager(); entityManager.getTransaction().begin(); try { - @SuppressWarnings("unchecked") - final Set tableNames = (Set) entityManager.createNativeQuery("SHOW TABLES") + @SuppressWarnings("unchecked") final Set tableNames = (Set) entityManager.createNativeQuery( + "SHOW TABLES") .getResultStream() .map(Object::toString) .collect(Collectors.toSet()); @@ -121,18 +122,22 @@ private void populate() { final Map missions = populateMission(sessions); final Map tags = populateTags(); final Map members = populateMember(); - final Map> sessionMembers = populateSessionMembers(sessions, members); - final Map> studylogs = populateStudylogs(members, sessions, missions, tags); + final Map> sessionMembers = populateSessionMembers( + sessions, members); + final Map> studylogs = populateStudylogs(members, sessions, + missions, tags); final List popularStudylogs = populatePopularStudyLog(studylogs); populateUpdatedContents(); final Map levelLogs = populateLevelLog(members); - final Map selfDiscussions = populateSelfDiscussion(levelLogs); + final Map selfDiscussions = populateSelfDiscussion( + levelLogs); logger.debug("Complete populate"); } private Map populateSession() { - final Function createSession = it -> sessionRepository.save(new Session(it.name)); + final Function createSession = it -> sessionRepository.save( + new Session(it.name)); return Arrays.stream(SessionDummy.values()) .collect(toMap(Function.identity(), createSession)); @@ -177,20 +182,22 @@ private Map> populateSessionMembers( final Function> createSessionMembers = it -> { final List sessionMembers = it.value.stream() - .map(memberDummy -> new SessionMember(backendLevel1SessionId, members.get(memberDummy))) + .map(memberDummy -> new SessionMember(backendLevel1SessionId, + members.get(memberDummy))) .collect(toList()); return sessionMemberRepository.saveAll(sessionMembers); }; return Arrays.stream(SessionMembersDummy.values()) - .collect(toMap(Function.identity(), createSessionMembers)); + .collect(toMap(Function.identity(), createSessionMembers)); } - private Map> populateStudylogs(final Map members, - final Map sessions, - final Map missions, - final Map tags) { + private Map> populateStudylogs( + final Map members, + final Map sessions, + final Map missions, + final Map tags) { final Function> insertStudyLogs = it -> { final Member member = members.get(it.memberDummy); @@ -218,7 +225,8 @@ private T pickRandom(final Collection values) { return list.get(random.nextInt(list.size())); } - private List populatePopularStudyLog(final Map> studylogs) { + private List populatePopularStudyLog( + final Map> studylogs) { final List randomPopularStudyLogs = studylogs.values() .stream() .flatMap(Collection::stream) @@ -232,7 +240,8 @@ private List populatePopularStudyLog(final Map populateLevelLog(final Map members) { @@ -298,18 +307,21 @@ private enum TagsDummy { } private enum MemberDummy { - BROWN("류성현", "gracefulBrown", 46308949, "https://avatars.githubusercontent.com/u/46308949?v=4"), + BROWN("류성현", "gracefulBrown", 46308949, + "https://avatars.githubusercontent.com/u/46308949?v=4"), JOANNE("서민정", "seovalue", 123456, "https://avatars.githubusercontent.com/u/48412963?v=4"), TYCHE("티케", "devhyun637", 59258239, "https://avatars.githubusercontent.com/u/59258239?v=4"), SUNNY("박선희", "서니", 67677561, "https://avatars.githubusercontent.com/u/67677561?v=4"), - HYEON9MAK("최현구", "hyeon9mak", 37354145, "https://avatars.githubusercontent.com/u/37354145?v=4"); + HYEON9MAK("최현구", "hyeon9mak", 37354145, + "https://avatars.githubusercontent.com/u/37354145?v=4"); final String nickname; final String loginName; final long githubId; final String imageUrl; - MemberDummy(final String nickname, final String loginName, final long githubId, final String imageUrl) { + MemberDummy(final String nickname, final String loginName, final long githubId, + final String imageUrl) { this.nickname = nickname; this.loginName = loginName; this.githubId = githubId; @@ -348,8 +360,10 @@ private enum StudylogDummy { private enum LevelLogDummy { HOW_TO_SET_DUMMY(MemberDummy.BROWN, "더미데이터 넣는 방법", "DataLoderApplication 에서 넣으세요."), - SECRETLY_WRITTEN_LEVEL_LOG_1(MemberDummy.SUNNY, "수달이 서니 이름으로 작성한 레벨로그1", "서니처럼 멋진 개발자가 되는 방법에 대해서 고민해보았습니다."), - SECRETLY_WRITTEN_LEVEL_LOG_2(MemberDummy.SUNNY, "수달이 서니 이름으로 작성한 레벨로그2", "서니는 언제부터 개발자가 되고 싶었나요?"); + SECRETLY_WRITTEN_LEVEL_LOG_1(MemberDummy.SUNNY, "수달이 서니 이름으로 작성한 레벨로그1", + "서니처럼 멋진 개발자가 되는 방법에 대해서 고민해보았습니다."), + SECRETLY_WRITTEN_LEVEL_LOG_2(MemberDummy.SUNNY, "수달이 서니 이름으로 작성한 레벨로그2", + "서니는 언제부터 개발자가 되고 싶었나요?"); final MemberDummy memberDummy; final String title; @@ -365,13 +379,15 @@ private enum LevelLogDummy { private enum SelfDiscussionDummy { HOW_TO_RESET("초기화 하는 방법", "후이에게 부탁하기", LevelLogDummy.HOW_TO_SET_DUMMY), WHAT_IS_COOL_PERSON("멋진 사람이란", "우테코 수료한사람 ~", LevelLogDummy.SECRETLY_WRITTEN_LEVEL_LOG_1), - WHAT_IS_BACKEND_DEVELOPER("백엔드 개발자란?", "우테코 수료한사람 ~", LevelLogDummy.SECRETLY_WRITTEN_LEVEL_LOG_2); + WHAT_IS_BACKEND_DEVELOPER("백엔드 개발자란?", "우테코 수료한사람 ~", + LevelLogDummy.SECRETLY_WRITTEN_LEVEL_LOG_2); final String question; final String answer; final LevelLogDummy levelLogDummy; - SelfDiscussionDummy(final String question, final String answer, final LevelLogDummy levelLogDummy) { + SelfDiscussionDummy(final String question, final String answer, + final LevelLogDummy levelLogDummy) { this.question = question; this.answer = answer; this.levelLogDummy = levelLogDummy; diff --git a/backend/src/main/java/wooteco/prolog/article/domain/Article.java b/backend/src/main/java/wooteco/prolog/article/domain/Article.java new file mode 100644 index 000000000..f8136129d --- /dev/null +++ b/backend/src/main/java/wooteco/prolog/article/domain/Article.java @@ -0,0 +1,61 @@ +package wooteco.prolog.article.domain; + +import java.time.LocalDateTime; +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 lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; +import wooteco.prolog.common.exception.BadRequestCode; +import wooteco.prolog.common.exception.BadRequestException; +import wooteco.prolog.member.domain.Member; + +@Entity +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@EntityListeners(AuditingEntityListener.class) +public class Article { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "member_id", nullable = false) + private Member member; + + @Embedded + private Title title; + + @Embedded + private Url url; + + @CreatedDate + private LocalDateTime createdAt; + + public Article(final Member member, final Title title, final Url url) { + this.member = member; + this.title = title; + this.url = url; + } + + public void validateOwner(final Member member) { + if (!member.equals(this.member)) { + throw new BadRequestException(BadRequestCode.INVALID_ARTICLE_AUTHOR_EXCEPTION); + } + } + + public void update(final String title, final String url) { + this.title = new Title(title); + this.url = new Url(url); + } +} diff --git a/backend/src/main/java/wooteco/prolog/article/domain/ArticleService.java b/backend/src/main/java/wooteco/prolog/article/domain/ArticleService.java new file mode 100644 index 000000000..456d6377e --- /dev/null +++ b/backend/src/main/java/wooteco/prolog/article/domain/ArticleService.java @@ -0,0 +1,62 @@ +package wooteco.prolog.article.domain; + +import static java.util.stream.Collectors.toList; + +import java.util.List; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import wooteco.prolog.article.domain.repository.ArticleRepository; +import wooteco.prolog.article.ui.ArticleRequest; +import wooteco.prolog.article.ui.ArticleResponse; +import wooteco.prolog.common.exception.BadRequestCode; +import wooteco.prolog.common.exception.BadRequestException; +import wooteco.prolog.login.ui.LoginMember; +import wooteco.prolog.member.application.MemberService; +import wooteco.prolog.member.domain.Member; + +@RequiredArgsConstructor +@Service +@Transactional(readOnly = true) +public class ArticleService { + + private final ArticleRepository articleRepository; + private final MemberService memberService; + + @Transactional + public Long create(final ArticleRequest articleRequest, final LoginMember loginMember) { + final Member member = memberService.findById(loginMember.getId()); + final Article article = articleRequest.toArticle(member); + return articleRepository.save(article).getId(); + } + + public List getAll() { + return articleRepository.findAll() + .stream() + .map(ArticleResponse::from) + .collect(toList()); + } + + @Transactional + public void update(final Long id, final ArticleRequest articleRequest, + final LoginMember loginMember) { + final Article article = articleRepository.findById(id) + .orElseThrow(() -> new BadRequestException(BadRequestCode.ARTICLE_NOT_FOUND_EXCEPTION)); + + final Member member = memberService.findById(loginMember.getId()); + article.validateOwner(member); + + article.update(articleRequest.getTitle(), articleRequest.getUrl()); + } + + @Transactional + public void delete(final Long id, final LoginMember loginMember) { + final Article article = articleRepository.findById(id) + .orElseThrow(() -> new BadRequestException(BadRequestCode.ARTICLE_NOT_FOUND_EXCEPTION)); + + final Member member = memberService.findById(loginMember.getId()); + article.validateOwner(member); + + articleRepository.delete(article); + } +} diff --git a/backend/src/main/java/wooteco/prolog/article/domain/Title.java b/backend/src/main/java/wooteco/prolog/article/domain/Title.java new file mode 100644 index 000000000..849e4a425 --- /dev/null +++ b/backend/src/main/java/wooteco/prolog/article/domain/Title.java @@ -0,0 +1,63 @@ +package wooteco.prolog.article.domain; + +import static wooteco.prolog.common.exception.BadRequestCode.ARTICLE_TITLE_NULL_OR_EMPTY_EXCEPTION; + +import java.util.Objects; +import javax.persistence.Column; +import javax.persistence.Embeddable; +import lombok.AccessLevel; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; +import wooteco.prolog.common.exception.BadRequestCode; +import wooteco.prolog.common.exception.BadRequestException; + +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@EqualsAndHashCode +@ToString +@Embeddable +public class Title { + + public static final int MAX_LENGTH = 50; + + @Column(nullable = false, length = MAX_LENGTH) + private String title; + + public Title(String title) { + validateNull(title); + validateEmpty(title); + validateOnlyBlank(title); + validateMaxLength(title); + this.title = trim(title); + } + + private String trim(String name) { + return name.trim(); + } + + private void validateNull(String title) { + if (Objects.isNull(title)) { + throw new BadRequestException(ARTICLE_TITLE_NULL_OR_EMPTY_EXCEPTION); + } + } + + private void validateEmpty(String title) { + if (title.isEmpty()) { + throw new BadRequestException(ARTICLE_TITLE_NULL_OR_EMPTY_EXCEPTION); + } + } + + private void validateOnlyBlank(String title) { + if (title.trim().isEmpty()) { + throw new BadRequestException(ARTICLE_TITLE_NULL_OR_EMPTY_EXCEPTION); + } + } + + private void validateMaxLength(String title) { + if (title.length() > MAX_LENGTH) { + throw new BadRequestException(BadRequestCode.ARTICLE_TITLE_OVER_LENGTH_EXCEPTION); + } + } +} diff --git a/backend/src/main/java/wooteco/prolog/article/domain/Url.java b/backend/src/main/java/wooteco/prolog/article/domain/Url.java new file mode 100644 index 000000000..9370ba4dc --- /dev/null +++ b/backend/src/main/java/wooteco/prolog/article/domain/Url.java @@ -0,0 +1,63 @@ +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 lombok.AccessLevel; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; +import wooteco.prolog.common.exception.BadRequestCode; +import wooteco.prolog.common.exception.BadRequestException; + +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@EqualsAndHashCode +@ToString +@Embeddable +public class Url { + + public static final int MAX_LENGTH = 1024; + + @Column(nullable = false, length = MAX_LENGTH) + private String url; + + public Url(String url) { + validateNull(url); + validateEmpty(url); + validateOnlyBlank(url); + validateMaxLength(url); + this.url = trim(url); + } + + private String trim(String name) { + return name.trim(); + } + + private void validateNull(String url) { + if (Objects.isNull(url)) { + throw new BadRequestException(BadRequestCode.ARTICLE_URL_NULL_OR_EMPTY_EXCEPTION); + } + } + + private void validateEmpty(String url) { + if (url.isEmpty()) { + throw new BadRequestException(BadRequestCode.ARTICLE_URL_NULL_OR_EMPTY_EXCEPTION); + } + } + + private void validateOnlyBlank(String url) { + if (url.trim().isEmpty()) { + throw new BadRequestException(BadRequestCode.ARTICLE_URL_NULL_OR_EMPTY_EXCEPTION); + } + } + + private void validateMaxLength(String url) { + if (url.length() > MAX_LENGTH) { + throw new BadRequestException(ARTICLE_URL_OVER_LENGTH_EXCEPTION); + } + } +} 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 new file mode 100644 index 000000000..9d2dee026 --- /dev/null +++ b/backend/src/main/java/wooteco/prolog/article/domain/repository/ArticleRepository.java @@ -0,0 +1,8 @@ +package wooteco.prolog.article.domain.repository; + +import org.springframework.data.jpa.repository.JpaRepository; +import wooteco.prolog.article.domain.Article; + +public interface ArticleRepository extends JpaRepository { + +} diff --git a/backend/src/main/java/wooteco/prolog/article/ui/ArticleController.java b/backend/src/main/java/wooteco/prolog/article/ui/ArticleController.java new file mode 100644 index 000000000..18eb06ad4 --- /dev/null +++ b/backend/src/main/java/wooteco/prolog/article/ui/ArticleController.java @@ -0,0 +1,46 @@ +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.*; +import wooteco.prolog.article.domain.ArticleService; +import wooteco.prolog.login.domain.AuthMemberPrincipal; +import wooteco.prolog.login.ui.LoginMember; + +@RequiredArgsConstructor +@RestController +@RequestMapping("/articles") +public class ArticleController { + + private final ArticleService articleService; + + @PostMapping + public ResponseEntity createArticles(@RequestBody final ArticleRequest articleRequest, + @AuthMemberPrincipal final LoginMember member) { + final Long id = articleService.create(articleRequest, member); + return ResponseEntity.created(URI.create("/articles/" + id)).build(); + } + + @GetMapping + public ResponseEntity> getArticles() { + final List allArticles = articleService.getAll(); + return ResponseEntity.ok(allArticles); + } + + @PutMapping("/{id}") + public ResponseEntity updateArticle(@RequestBody final ArticleRequest articleRequest, + @AuthMemberPrincipal final LoginMember member, + @PathVariable final Long id) { + articleService.update(id, articleRequest, member); + return ResponseEntity.ok().build(); + } + + @DeleteMapping("/{id}") + public ResponseEntity deleteArticle(@PathVariable final Long id, + @AuthMemberPrincipal final LoginMember member) { + articleService.delete(id, member); + return ResponseEntity.noContent().build(); + } +} diff --git a/backend/src/main/java/wooteco/prolog/article/ui/ArticleRequest.java b/backend/src/main/java/wooteco/prolog/article/ui/ArticleRequest.java new file mode 100644 index 000000000..685750de7 --- /dev/null +++ b/backend/src/main/java/wooteco/prolog/article/ui/ArticleRequest.java @@ -0,0 +1,20 @@ +package wooteco.prolog.article.ui; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import wooteco.prolog.article.domain.Article; +import wooteco.prolog.article.domain.Title; +import wooteco.prolog.article.domain.Url; +import wooteco.prolog.member.domain.Member; + +@Getter +@AllArgsConstructor +public class ArticleRequest { + + private final String title; + private final String url; + + public Article toArticle(final Member member) { + return new Article(member, new Title(title), new Url(url)); + } +} diff --git a/backend/src/main/java/wooteco/prolog/article/ui/ArticleResponse.java b/backend/src/main/java/wooteco/prolog/article/ui/ArticleResponse.java new file mode 100644 index 000000000..17ebadf7c --- /dev/null +++ b/backend/src/main/java/wooteco/prolog/article/ui/ArticleResponse.java @@ -0,0 +1,30 @@ +package wooteco.prolog.article.ui; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import wooteco.prolog.article.domain.Article; + +@AllArgsConstructor +@Getter +public class ArticleResponse { + + private final Long id; + private final String userName; + private final String title; + private final String url; + private final String createdAt; + + private ArticleResponse() { + this(null, null, null, null, null); + } + + public static ArticleResponse from(final Article article) { + final Long id = article.getId(); + final String nickName = article.getMember().getNickname(); + final String title = article.getTitle().getTitle(); + final String url = article.getUrl().getUrl(); + final String createdAt = article.getCreatedAt().toString(); + + return new ArticleResponse(id, nickName, title, url, createdAt); + } +} 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 45f08686c..94c00b2b4 100644 --- a/backend/src/main/java/wooteco/prolog/badge/application/BadgeService.java +++ b/backend/src/main/java/wooteco/prolog/badge/application/BadgeService.java @@ -23,9 +23,9 @@ public List getBadges(String username) { Member member = memberService.findByUsername(username); return badgeCreators.stream() - .map(creator -> creator.create(member.getUsername())) - .filter(Optional::isPresent) - .map(Optional::get) - .collect(Collectors.toList()); + .map(creator -> creator.create(member.getUsername())) + .filter(Optional::isPresent) + .map(Optional::get) + .collect(Collectors.toList()); } } diff --git a/backend/src/main/java/wooteco/prolog/badge/application/dto/BadgeResponse.java b/backend/src/main/java/wooteco/prolog/badge/application/dto/BadgeResponse.java index 5234b4566..994136c68 100644 --- a/backend/src/main/java/wooteco/prolog/badge/application/dto/BadgeResponse.java +++ b/backend/src/main/java/wooteco/prolog/badge/application/dto/BadgeResponse.java @@ -1,7 +1,6 @@ package wooteco.prolog.badge.application.dto; import lombok.AllArgsConstructor; -import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/backend/src/main/java/wooteco/prolog/badge/config/BadgeCreatorConfig.java b/backend/src/main/java/wooteco/prolog/badge/config/BadgeCreatorConfig.java index a380e54da..d4381e645 100644 --- a/backend/src/main/java/wooteco/prolog/badge/config/BadgeCreatorConfig.java +++ b/backend/src/main/java/wooteco/prolog/badge/config/BadgeCreatorConfig.java @@ -13,21 +13,25 @@ public class BadgeCreatorConfig { @Bean public BadgeCreator levelTwoPassionKingBadgeCreator(BadgeRepository badgeRepository) { - return new PassionKingBadgeCreator(badgeRepository, FourthCrewSessions.LEVEL_TWO.getSessionIds()); + return new PassionKingBadgeCreator(badgeRepository, + FourthCrewSessions.LEVEL_TWO.getSessionIds()); } @Bean public BadgeCreator levelTwoComplimentKingBadgeCreator(BadgeRepository badgeRepository) { - return new ComplimentKingBadgeCreator(badgeRepository, FourthCrewSessions.LEVEL_TWO.getSessionIds()); + return new ComplimentKingBadgeCreator(badgeRepository, + FourthCrewSessions.LEVEL_TWO.getSessionIds()); } @Bean public BadgeCreator levelThreePassionKingBadgeCreator(BadgeRepository badgeRepository) { - return new PassionKingBadgeCreator(badgeRepository, FourthCrewSessions.LEVEL_THREE.getSessionIds()); + return new PassionKingBadgeCreator(badgeRepository, + FourthCrewSessions.LEVEL_THREE.getSessionIds()); } @Bean public BadgeCreator levelThreeComplimentKingBadgeCreator(BadgeRepository badgeRepository) { - return new ComplimentKingBadgeCreator(badgeRepository, FourthCrewSessions.LEVEL_THREE.getSessionIds()); + return new ComplimentKingBadgeCreator(badgeRepository, + FourthCrewSessions.LEVEL_THREE.getSessionIds()); } } diff --git a/backend/src/main/java/wooteco/prolog/badge/domain/Badge.java b/backend/src/main/java/wooteco/prolog/badge/domain/Badge.java index fd47b4784..29c7d5dd5 100644 --- a/backend/src/main/java/wooteco/prolog/badge/domain/Badge.java +++ b/backend/src/main/java/wooteco/prolog/badge/domain/Badge.java @@ -15,7 +15,7 @@ public String getName() { @Override public String toString() { return "Badge{" + - "name='" + name + '\'' + - '}'; + "name='" + name + '\'' + + '}'; } } 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 f3f85f840..351868760 100644 --- a/backend/src/main/java/wooteco/prolog/badge/ui/BadgeController.java +++ b/backend/src/main/java/wooteco/prolog/badge/ui/BadgeController.java @@ -25,9 +25,9 @@ public class BadgeController { public ResponseEntity findMemberBadges(@PathVariable String username) { List badges = badgeService.getBadges(username); List badgeResponses = badges.stream() - .map(BadgeType::toString) - .map(BadgeResponse::new) - .collect(Collectors.toList()); + .map(BadgeType::toString) + .map(BadgeResponse::new) + .collect(Collectors.toList()); return ResponseEntity.ok(new BadgesResponse(badgeResponses)); } } diff --git a/backend/src/main/java/wooteco/prolog/common/ElasticSearchConfig.java b/backend/src/main/java/wooteco/prolog/common/ElasticSearchConfig.java index d7f9b87ac..4449e0a2d 100644 --- a/backend/src/main/java/wooteco/prolog/common/ElasticSearchConfig.java +++ b/backend/src/main/java/wooteco/prolog/common/ElasticSearchConfig.java @@ -41,7 +41,8 @@ public RestHighLevelClient elasticsearchClient() { RestClient.builder(new HttpHost(host, port, "http")) .setHttpClientConfigCallback(httpClientBuilder -> { httpClientBuilder.disableAuthCaching(); - return httpClientBuilder.setDefaultCredentialsProvider(basicCredentialsProvider); + 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 2a5d13d1d..2891bfd02 100644 --- a/backend/src/main/java/wooteco/prolog/common/PageableResponse.java +++ b/backend/src/main/java/wooteco/prolog/common/PageableResponse.java @@ -17,6 +17,7 @@ public class PageableResponse { private int currentPage; public static PageableResponse of(List data, Page page) { - return new PageableResponse<>(data, page.getTotalElements(), page.getTotalPages(), page.getNumber() + ONE_INDEXED_PARAMETER); + return new PageableResponse<>(data, page.getTotalElements(), page.getTotalPages(), + page.getNumber() + ONE_INDEXED_PARAMETER); } } diff --git a/backend/src/main/java/wooteco/prolog/common/ResourceSizeAdvice.java b/backend/src/main/java/wooteco/prolog/common/ResourceSizeAdvice.java index 18291586d..f908cf119 100644 --- a/backend/src/main/java/wooteco/prolog/common/ResourceSizeAdvice.java +++ b/backend/src/main/java/wooteco/prolog/common/ResourceSizeAdvice.java @@ -1,5 +1,6 @@ package wooteco.prolog.common; +import java.util.Collection; import org.springframework.core.MethodParameter; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; @@ -9,21 +10,24 @@ 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 { @Override - public boolean supports(MethodParameter returnType, Class> converterType) { + public boolean supports(MethodParameter returnType, + Class> converterType) { return ResponseEntity.class.isAssignableFrom(returnType.getParameterType()); } @Override - public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType, Class> selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) { + public Object beforeBodyWrite(Object body, MethodParameter returnType, + MediaType selectedContentType, + Class> selectedConverterType, + ServerHttpRequest request, ServerHttpResponse response) { if (body instanceof Collection) { response.getHeaders().add("Access-Control-Expose-Headers", "X-Total-Count"); - response.getHeaders().add("X-Total-Count", String.valueOf(((Collection) body).size())); + response.getHeaders() + .add("X-Total-Count", String.valueOf(((Collection) body).size())); } return body; } diff --git a/backend/src/main/java/wooteco/prolog/common/WebConfig.java b/backend/src/main/java/wooteco/prolog/common/WebConfig.java index c14aa8900..d328ca871 100644 --- a/backend/src/main/java/wooteco/prolog/common/WebConfig.java +++ b/backend/src/main/java/wooteco/prolog/common/WebConfig.java @@ -2,9 +2,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import java.util.List; -import org.flywaydb.core.Flyway; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.flyway.FlywayMigrationStrategy; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Scope; diff --git a/backend/src/main/java/wooteco/prolog/common/exception/BadRequestCode.java b/backend/src/main/java/wooteco/prolog/common/exception/BadRequestCode.java index 0c400c3f4..f7790786f 100644 --- a/backend/src/main/java/wooteco/prolog/common/exception/BadRequestCode.java +++ b/backend/src/main/java/wooteco/prolog/common/exception/BadRequestCode.java @@ -1,122 +1,87 @@ package wooteco.prolog.common.exception; -import java.util.Arrays; import lombok.AllArgsConstructor; import lombok.Getter; -import wooteco.prolog.levellogs.exception.InvalidLevelLogAuthorException; -import wooteco.prolog.levellogs.exception.LevelLogNotFoundException; -import wooteco.prolog.login.excetpion.GithubApiFailException; -import wooteco.prolog.login.excetpion.GithubConnectionException; -import wooteco.prolog.login.excetpion.RoleNameNotFoundException; -import wooteco.prolog.login.excetpion.StudylogTitleNullOrEmptyException; -import wooteco.prolog.login.excetpion.TokenNotValidException; -import wooteco.prolog.member.exception.DuplicateMemberTagException; -import wooteco.prolog.member.exception.MemberNotAllowedException; -import wooteco.prolog.member.exception.MemberNotFoundException; -import wooteco.prolog.roadmap.exception.CurriculumInvalidException; -import wooteco.prolog.roadmap.exception.CurriculumNotFoundException; -import wooteco.prolog.roadmap.exception.KeywordAndKeywordParentSameException; -import wooteco.prolog.roadmap.exception.KeywordNotFoundException; -import wooteco.prolog.roadmap.exception.KeywordOrderException; -import wooteco.prolog.roadmap.exception.QuizNotFoundException; -import wooteco.prolog.roadmap.exception.QuizQuestionException; import wooteco.prolog.session.domain.Mission; +import wooteco.prolog.session.domain.Session; import wooteco.prolog.studylog.domain.TagName; import wooteco.prolog.studylog.domain.Title; -import wooteco.prolog.studylog.exception.AuthorNotValidException; -import wooteco.prolog.studylog.exception.CommentDeleteException; -import wooteco.prolog.studylog.exception.CommentNotFoundException; -import wooteco.prolog.studylog.exception.DuplicateMissionException; -import wooteco.prolog.studylog.exception.DuplicateTagException; -import wooteco.prolog.studylog.exception.InvalidLikeRequestException; -import wooteco.prolog.studylog.exception.InvalidUnlikeRequestException; -import wooteco.prolog.studylog.exception.MissionNotFoundException; -import wooteco.prolog.studylog.exception.NotValidSortNameException; -import wooteco.prolog.studylog.exception.StudylogArgumentException; -import wooteco.prolog.studylog.exception.StudylogContentNullOrEmptyException; -import wooteco.prolog.studylog.exception.StudylogDocumentNotFoundException; -import wooteco.prolog.studylog.exception.StudylogNotFoundException; -import wooteco.prolog.studylog.exception.StudylogScrapAlreadyRegisteredException; -import wooteco.prolog.studylog.exception.StudylogScrapNotExistException; -import wooteco.prolog.studylog.exception.StudylogScrapNotValidUserException; -import wooteco.prolog.studylog.exception.TagNameNullOrEmptyException; -import wooteco.prolog.studylog.exception.TooLongMissionNameException; -import wooteco.prolog.studylog.exception.TooLongTagNameException; -import wooteco.prolog.studylog.exception.TooLongTitleException; @AllArgsConstructor @Getter public enum BadRequestCode { - NOT_FOUND_ERROR_CODE(0000, "해당 에러의 에러코드를 찾을 수 없습니다.", NotFoundErrorCodeException.class), + NOT_FOUND_ERROR_CODE(0000, "해당 에러의 에러코드를 찾을 수 없습니다."), - GITHUB_API_FAIL(1000, "깃헙 API에서 엑세스 토큰을 받아오는 데 실패했습니다.", GithubApiFailException.class), - GITHUB_CONNECTION_FAIL(1001, "깃헙 API에서 엑세스 토큰을 받아오는 데 실패했습니다.", - GithubConnectionException.class), - TOKEN_NOT_VALID(1002, "JWT 토큰이 유효하지 않습니다.", TokenNotValidException.class), - ROLE_NAME_NOT_FOUND(1003, "해당 이름을 가진 역할이 없습니다.", RoleNameNotFoundException.class), - MEMBER_NOT_FOUND(1004, "해당 ID를 가진 멤버가 없습니다.", MemberNotFoundException.class), - MEMBER_NOT_ALLOWED(1005, "권한이 없습니다.", MemberNotAllowedException.class), + GITHUB_API_FAIL(1000, "깃헙 API에서 엑세스 토큰을 받아오는 데 실패했습니다."), + GITHUB_CONNECTION_FAIL(1001, "깃헙 API에서 엑세스 토큰을 받아오는 데 실패했습니다."), + TOKEN_NOT_VALID(1002, "JWT 토큰이 유효하지 않습니다."), + ROLE_NAME_NOT_FOUND(1003, "해당 이름을 가진 역할이 없습니다."), + MEMBER_NOT_FOUND(1004, "해당 ID를 가진 멤버가 없습니다."), + MEMBER_NOT_ALLOWED(1005, "권한이 없습니다."), - STUDYLOG_ARGUMENT(2000, "최소 1개의 글이 있어야 합니다.", StudylogArgumentException.class), - STUDYLOG_CONTENT_NULL_OR_EMPTY(2001, "글 내용은 공백일 수 없습나다.", - StudylogContentNullOrEmptyException.class), - STUDYLOG_TITLE_NULL_OR_EMPTY(2002, "글 제목은 공백일 수 없습나다.", - StudylogTitleNullOrEmptyException.class), - NOT_VALID_SORT_NAME(2003, "정렬 형식이 올바르지 않습니다.", NotValidSortNameException.class), - STUDYLOG_NOT_FOUND(2004, "존재하지 않는 글입니다.", StudylogNotFoundException.class), - STUDYLOG_TITLE_TOO_LONG(2005, String.format("스터디로그 제목이 %d자 초과입니다.", Title.MAX_LENGTH), - TooLongTitleException.class), - ONLY_AUTHOR_CAN_EDIT(2006, "작성자만 수정할 수 있습니다.", AuthorNotValidException.class), - STUDYLOG_DOCUMENT_NOT_FOUND(2007, "검색용 스터디로그가 존재하지 않습니다.", - StudylogDocumentNotFoundException.class), + STUDYLOG_ARGUMENT(2000, "최소 1개의 글이 있어야 합니다."), + STUDYLOG_CONTENT_NULL_OR_EMPTY(2001, "글 내용은 공백일 수 없습니다."), + STUDYLOG_TITLE_NULL_OR_EMPTY(2002, "글 제목은 공백일 수 없습니다."), + NOT_VALID_SORT_NAME(2003, "정렬 형식이 올바르지 않습니다."), + STUDYLOG_NOT_FOUND(2004, "존재하지 않는 글입니다."), + STUDYLOG_TITLE_TOO_LONG(2005, String.format("스터디로그 제목이 %d자 초과입니다.", Title.MAX_LENGTH)), + ONLY_AUTHOR_CAN_EDIT(2006, "작성자만 수정할 수 있습니다."), + STUDYLOG_DOCUMENT_NOT_FOUND(2007, "검색용 스터디로그가 존재하지 않습니다."), + STUDYLOG_SCRAP_ALREADY_REGISTERED_EXCEPTION(2008, "이미 등록한 스터디 로그 스크랩입니다."), + STUDYLOG_SCRAP_NOT_EXIST_EXCEPTION(2009, "존재하지 않는 스터디 로그 스크랩입니다."), - MISSION_NOT_FOUND(3000, "존재하지 않는 미션입니다.", MissionNotFoundException.class), - DUPLICATE_MISSION(3001, "미션이 중복됩니다.", DuplicateMissionException.class), - DUPLICATE_TAG(3002, "태그가 중복됩니다.", DuplicateTagException.class), - TAG_NAME_NULL_OR_EMPTY(3003, "태그 이름이 null이거나 비어있습니다.", TagNameNullOrEmptyException.class), - TOO_LONG_TAG_NAME(3004, String.format("태그 이름이 %d자 초과입니다.", TagName.MAX_LENGTH), - TooLongTagNameException.class), - TOO_LONG_MISSION_NAME(3005, String.format("미션 이름이 %d자 초과입니다.", Mission.MAX_LENGTH), - TooLongMissionNameException.class), - DUPLICATE_MEMBER_TAG(3006, "중복되는 멤버 태그 입니다.", DuplicateMemberTagException.class), - SCRAP_ALREADY_REGISTERED(3007, "이미 스크랩한 스터디로그입니다.", - StudylogScrapAlreadyRegisteredException.class), - SCRAP_NOT_EXIST(3008, "스크랩이 존재하지 않습니다.", StudylogScrapNotExistException.class), - SCRAP_NOT_VALID_USER(3009, "본인의 스크랩만 추가할 수 있습니다.", StudylogScrapNotValidUserException.class), + MISSION_NOT_FOUND(3000, "존재하지 않는 미션입니다."), + DUPLICATE_MISSION(3001, "미션이 중복됩니다."), + DUPLICATE_TAG(3002, "태그가 중복됩니다."), + TAG_NAME_NULL_OR_EMPTY(3003, "태그 이름이 null이거나 비어있습니다."), + TOO_LONG_TAG_NAME(3004, String.format("태그 이름이 %d자 초과입니다.", TagName.MAX_LENGTH)), + TOO_LONG_MISSION_NAME(3005, String.format("미션 이름이 %d자 초과입니다.", Mission.MAX_LENGTH)), + DUPLICATE_MEMBER_TAG(3006, "중복되는 멤버 태그 입니다."), + SCRAP_ALREADY_REGISTERED(3007, "이미 스크랩한 스터디로그입니다."), + SCRAP_NOT_EXIST(3008, "스크랩이 존재하지 않습니다."), + SCRAP_NOT_VALID_USER(3009, "본인의 스크랩만 추가할 수 있습니다."), + NOT_EXISTS_MEMBER_TAG(3010, "멤버 태그가 존재하지 않습니다."), - INVALID_LIKE_REQUEST_EXCEPTION(5001, "스터디로그를 좋아요 할 수 없습니다.", InvalidLikeRequestException.class), - INVALID_UNLIKE_REQUEST_EXCEPTION(5002, "스터디로그를 좋아요 취소 할 수 없습니다.", - InvalidUnlikeRequestException.class), + INVALID_LIKE_REQUEST_EXCEPTION(5001, "스터디로그를 좋아요 할 수 없습니다."), + INVALID_UNLIKE_REQUEST_EXCEPTION(5002, "스터디로그를 좋아요 취소 할 수 없습니다."), + COMMENT_NOT_FOUND(6001, "존재하지 않는 댓글입니다."), + COMMENT_DELETE_EXCEPTION(6002, "댓글을 삭제할 수 없습니다."), - COMMENT_NOT_FOUND(6001, "존재하지 않는 댓글입니다.", CommentNotFoundException.class), - COMMENT_DELETE_EXCEPTION(6002, "댓글을 삭제할 수 없습니다.", CommentDeleteException.class), + INVALID_LEVEL_LOG_AUTHOR_EXCEPTION(7001, "레벨 로그 작성자가 아닙니다."), + LEVEL_LOG_NOT_FOUND_EXCEPTION(7002, "레벨 로그를 찾을 수 없습니다."), + SELF_DISCUSSION_NOT_FOUND_EXCEPTION(7003, "자신이 작성한 디스커션을 찾을 수 없습니다."), - INVALID_LEVEL_LOG_AUTHOR_EXCEPTION(7001, "레벨 로그 작성자가 아닙니다.", - InvalidLevelLogAuthorException.class), - LEVEL_LOG_NOT_FOUND_EXCEPTION(7002, "레벨 로그를 찾을 수 없습니다.", LevelLogNotFoundException.class), + ROADMAP_KEYWORD_ORDER_EXCEPTION(8001, "키워드의 순서는 1 이상이여야 합니다."), + ROADMAP_KEYWORD_NOT_FOUND_EXCEPTION(8002, "키워드를 찾을 수 없습니다."), + ROADMAP_QUIZ_NOT_FOUND_EXCEPTION(8003, "퀴즈를 찾을 수 없습니다."), + ROADMAP_QUIZ_INVALID_QUESTION_EXCEPTION(8004, "퀴즈 내용을 업데이트할 수 없습니다."), + ROADMAP_KEYWORD_SAME_PARENT_EXCEPTION(8005, "부모의 키워드를 수정할 수 없습니다"), + ROADMAP_SESSION_NOT_FOUND_EXCEPTION(8006, "세션을 찾을 수 없습니다."), + ROADMAP_KEYWORD_SEQUENCE_EXCEPTION(8007, "키워드 시퀀스가 유효하지 않습니다."), + ROADMAP_KEYWORD_AND_KEYWORD_PARENT_SAME_EXCEPTION(8008, "로드맵 키워드는 키워드의 부모와 같을 수 없습니다."), - ROADMAP_KEYWORD_ORDER_EXCEPTION(8001, "키워드의 순서는 1 이상이여야 합니다.", KeywordOrderException.class), - ROADMAP_KEYWORD_NOT_FOUND_EXCEPTION(8002, "키워드를 찾을 수 없습니다.", KeywordNotFoundException.class), - ROADMAP_QUIZ_NOT_FOUND_EXCEPTION(8003, "퀴즈를 찾을 수 없습니다.", QuizNotFoundException.class), - ROADMAP_QUIZ_INVALID_QUESTION_EXCEPTION(8004, "퀴즈 내용을 업데이트할 수 없습니다.", - QuizQuestionException.class), + CURRICULUM_NAME_RANGE_EXCEPTION(8009, "커리큘럼 이름은 공백일 수 없습니다"), + CURRICULUM_NOT_FOUND_EXCEPTION(8010, "해당하는 커리큘럼을 찾을 수 없습니다"), + CURRICULUM_INVALID_EXCEPTION(8011, "커리큘럼이 유효하지 않습니다."), - ROADMAP_KEYWORD_SAME_PARENT_EXCEPTION(8005, "부모의 키워드를 수정할 수 없습니다", - KeywordAndKeywordParentSameException.class), + FILE_NAME_EMPTY_EXCEPTION(9001, "파일 이름이 존재하지 않습니다."), + UNSUPPORTED_FILE_EXTENSION_EXCEPTION(9002, "지원하지 않는 파일 확장자입니다."), + FILE_UPLOAD_FAIL_EXCEPTION(9003, "파일 업로드에 실패했습니다."), - CURRICULUM_NAME_RANGE_EXCEPTION(8006, "커리큘럼 이름은 공백일 수 없습니다", CurriculumInvalidException.class), - CURRICULUM_NOT_FOUND_EXCEPTION(8007, "해당하는 커리큘럼을 찾을 수 없습니다", CurriculumNotFoundException.class); + DUPLICATE_SESSION_EXCEPTION(10001, "중복되는 세션입니다."), + SESSION_NOT_FOUND_EXCEPTION(10002, "세션을 찾을 수 없습니다."), + TOO_LONG_LEVEL_NAME_EXCEPTION(10003, String.format("세션 이름이 %d자 초과입니다.", Session.MAX_LENGTH)), - private int code; - private String message; - private Class type; + SEARCH_ARGUMENT_PARSE_EXCEPTION(11001, "parsing 할 수 없는 argument입니다."), - public static BadRequestCode findByClass(Class type) { - return Arrays.stream(BadRequestCode.values()) - .filter(code -> code.type.equals(type)) - .findAny() - .orElseThrow(NotFoundErrorCodeException::new); - } + ARTICLE_URL_OVER_LENGTH_EXCEPTION(12000, "ARTICLE_URL_OVER_LENGTH_EXCEPTION"), + ARTICLE_TITLE_NULL_OR_EMPTY_EXCEPTION(12001, "ARTICLE_TITLE_NULL_OR_EMPTY_EXCEPTION"), + ARTICLE_TITLE_OVER_LENGTH_EXCEPTION(12002, "ARTICLE_TITLE_OVER_LENGTH_EXCEPTION"), + ARTICLE_URL_NULL_OR_EMPTY_EXCEPTION(12003, "ARTICLE_URL_NULL_OR_EMPTY_EXCEPTION"), + ARTICLE_NOT_FOUND_EXCEPTION(12004, "ARTICLE_NOT_FOUND_EXCEPTION"), + INVALID_ARTICLE_AUTHOR_EXCEPTION(12005, "INVALID_ARTICLE_AUTHOR_EXCEPTION"); + private int code; + private String message; } diff --git a/backend/src/main/java/wooteco/prolog/common/exception/BadRequestException.java b/backend/src/main/java/wooteco/prolog/common/exception/BadRequestException.java index 179608415..6eab4f69e 100644 --- a/backend/src/main/java/wooteco/prolog/common/exception/BadRequestException.java +++ b/backend/src/main/java/wooteco/prolog/common/exception/BadRequestException.java @@ -5,13 +5,11 @@ @Getter public class BadRequestException extends RuntimeException { - private BadRequestCode codeAndMessage = BadRequestCode.findByClass(this.getClass()); + private final String message; + private final int code; - private String message; - private int code; - - public BadRequestException() { - this.message = codeAndMessage.getMessage(); - this.code = codeAndMessage.getCode(); + public BadRequestException(BadRequestCode badRequestCode) { + this.message = badRequestCode.getMessage(); + this.code = badRequestCode.getCode(); } } diff --git a/backend/src/main/java/wooteco/prolog/common/exception/ElasticsearchCustomException.java b/backend/src/main/java/wooteco/prolog/common/exception/ElasticsearchCustomException.java index 4550bd79d..88c9b8a0b 100644 --- a/backend/src/main/java/wooteco/prolog/common/exception/ElasticsearchCustomException.java +++ b/backend/src/main/java/wooteco/prolog/common/exception/ElasticsearchCustomException.java @@ -1,6 +1,6 @@ package wooteco.prolog.common.exception; -public class ElasticsearchCustomException extends RuntimeException{ +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 3ab343d88..d6a53fcf8 100644 --- a/backend/src/main/java/wooteco/prolog/common/exception/ExceptionController.java +++ b/backend/src/main/java/wooteco/prolog/common/exception/ExceptionController.java @@ -1,7 +1,6 @@ package wooteco.prolog.common.exception; import static wooteco.prolog.common.slacklogger.SlackAlarmErrorLevel.ERROR; -import static wooteco.prolog.common.slacklogger.SlackAlarmErrorLevel.WARN; import java.util.Arrays; import java.util.stream.Collectors; @@ -10,7 +9,6 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; -import org.testcontainers.shaded.org.bouncycastle.math.ec.ECAlgorithms; import wooteco.prolog.common.slacklogger.SlackAlarm; @Slf4j @@ -26,7 +24,8 @@ public ResponseEntity badRequestExceptionHandler(BadRequestExcepti @SlackAlarm(level = ERROR) @ExceptionHandler(ElasticsearchCustomException.class) - public ResponseEntity elasticsearchCustomExceptionHandler(ElasticsearchCustomException e) { + public ResponseEntity elasticsearchCustomExceptionHandler( + ElasticsearchCustomException e) { log.error(e.getMessage()); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) .body(new ExceptionDto(500, "알 수 없는 에러")); diff --git a/backend/src/main/java/wooteco/prolog/common/exception/NotFoundErrorCodeException.java b/backend/src/main/java/wooteco/prolog/common/exception/NotFoundErrorCodeException.java deleted file mode 100644 index 68404e0a7..000000000 --- a/backend/src/main/java/wooteco/prolog/common/exception/NotFoundErrorCodeException.java +++ /dev/null @@ -1,5 +0,0 @@ -package wooteco.prolog.common.exception; - -public class NotFoundErrorCodeException extends BadRequestException { - -} 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 491277b6a..d1dc32c95 100644 --- a/backend/src/main/java/wooteco/prolog/common/filter/ServletWrappingFilter.java +++ b/backend/src/main/java/wooteco/prolog/common/filter/ServletWrappingFilter.java @@ -20,7 +20,8 @@ public ServletWrappingFilter(RequestStorage requestStorage) { } @Override - protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { + protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, + FilterChain filterChain) throws ServletException, IOException { ContentCachingRequestWrapper wrappedRequest = new ContentCachingRequestWrapper(request); requestStorage.set(wrappedRequest); diff --git a/backend/src/main/java/wooteco/prolog/common/slacklogger/ExceptionAppender.java b/backend/src/main/java/wooteco/prolog/common/slacklogger/ExceptionAppender.java index 9129ddf80..c67020183 100644 --- a/backend/src/main/java/wooteco/prolog/common/slacklogger/ExceptionAppender.java +++ b/backend/src/main/java/wooteco/prolog/common/slacklogger/ExceptionAppender.java @@ -62,7 +62,8 @@ private boolean validateIsException(Object[] args) { private boolean validateHasOneArgument(Object[] args) { if (args.length != 1) { log.warn(String - .format(SLACK_ALARM_FORMAT, "ambiguous exceptions! require just only one Exception")); + .format(SLACK_ALARM_FORMAT, + "ambiguous exceptions! require just only one Exception")); return false; } 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 33d43057c..d8e204032 100644 --- a/backend/src/main/java/wooteco/prolog/common/slacklogger/SlackMessageGenerator.java +++ b/backend/src/main/java/wooteco/prolog/common/slacklogger/SlackMessageGenerator.java @@ -11,9 +11,9 @@ 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 wooteco.prolog.login.excetpion.TokenNotValidException; @Component public class SlackMessageGenerator { @@ -33,8 +33,8 @@ public SlackMessageGenerator(Environment environment, } public String generate(ContentCachingRequestWrapper request, - Exception exception, - SlackAlarmErrorLevel level) { + Exception exception, + SlackAlarmErrorLevel level) { try { String token = AuthorizationExtractor.extract(request); String profile = getProfile(); @@ -47,7 +47,7 @@ public String generate(ContentCachingRequestWrapper request, String exceptionMessage = extractExceptionMessage(exception, level); return toMessage(profile, currentTime, userId, - exceptionMessage, method, requestURI, headers, body); + exceptionMessage, method, requestURI, headers, body); } catch (Exception e) { return String.format(EXTRACTION_ERROR_MESSAGE, e.getMessage()); } @@ -64,7 +64,7 @@ private String getCurrentTime() { private String getUserId(String token) { try { return jwtTokenProvider.extractSubject(token); - } catch (TokenNotValidException e) { + } catch (BadRequestException e) { return "Guest"; } } 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 3dfd29c2b..2c6c9cfd5 100644 --- a/backend/src/main/java/wooteco/prolog/image/application/ImageService.java +++ b/backend/src/main/java/wooteco/prolog/image/application/ImageService.java @@ -1,11 +1,13 @@ 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; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.image.application.dto.ImageUrlResponse; -import wooteco.prolog.image.exception.FileNameEmptyException; import wooteco.prolog.image.infrastructure.FileNameGenerator; import wooteco.prolog.image.infrastructure.S3Uploader; @@ -25,7 +27,7 @@ public ImageUrlResponse upload(final MultipartFile uploadImageFile) { private void validate(final MultipartFile uploadImageFile) { if (isEmptyFileName(uploadImageFile)) { - throw new FileNameEmptyException(); + throw new BadRequestException(FILE_NAME_EMPTY_EXCEPTION); } } diff --git a/backend/src/main/java/wooteco/prolog/image/config/S3Configuration.java b/backend/src/main/java/wooteco/prolog/image/config/S3Configuration.java index d768718f0..826f76aa1 100644 --- a/backend/src/main/java/wooteco/prolog/image/config/S3Configuration.java +++ b/backend/src/main/java/wooteco/prolog/image/config/S3Configuration.java @@ -13,9 +13,9 @@ public class S3Configuration { @Bean public AmazonS3 amazonS3() { return AmazonS3ClientBuilder - .standard() - .withCredentials(InstanceProfileCredentialsProvider.getInstance()) - .withRegion(Regions.AP_NORTHEAST_2) - .build(); + .standard() + .withCredentials(InstanceProfileCredentialsProvider.getInstance()) + .withRegion(Regions.AP_NORTHEAST_2) + .build(); } } diff --git a/backend/src/main/java/wooteco/prolog/image/domain/FileExtension.java b/backend/src/main/java/wooteco/prolog/image/domain/FileExtension.java index de4216481..56255ad60 100644 --- a/backend/src/main/java/wooteco/prolog/image/domain/FileExtension.java +++ b/backend/src/main/java/wooteco/prolog/image/domain/FileExtension.java @@ -17,6 +17,6 @@ public enum FileExtension { public static boolean isSupport(final String extension) { return Stream.of(values()) - .anyMatch(it -> it.value.equalsIgnoreCase(extension)); + .anyMatch(it -> it.value.equalsIgnoreCase(extension)); } } diff --git a/backend/src/main/java/wooteco/prolog/image/exception/FileNameEmptyException.java b/backend/src/main/java/wooteco/prolog/image/exception/FileNameEmptyException.java deleted file mode 100644 index 4f47717e7..000000000 --- a/backend/src/main/java/wooteco/prolog/image/exception/FileNameEmptyException.java +++ /dev/null @@ -1,8 +0,0 @@ -package wooteco.prolog.image.exception; - - -import wooteco.prolog.common.exception.BadRequestException; - -public class FileNameEmptyException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/image/exception/FileUploadFailException.java b/backend/src/main/java/wooteco/prolog/image/exception/FileUploadFailException.java deleted file mode 100644 index 16cd519f2..000000000 --- a/backend/src/main/java/wooteco/prolog/image/exception/FileUploadFailException.java +++ /dev/null @@ -1,8 +0,0 @@ -package wooteco.prolog.image.exception; - - -import wooteco.prolog.common.exception.BadRequestException; - -public class FileUploadFailException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/image/exception/UnsupportedFilExtensionException.java b/backend/src/main/java/wooteco/prolog/image/exception/UnsupportedFilExtensionException.java deleted file mode 100644 index 9931f0739..000000000 --- a/backend/src/main/java/wooteco/prolog/image/exception/UnsupportedFilExtensionException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.image.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class UnsupportedFilExtensionException extends BadRequestException { - -} 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 113c9423e..ddacb7243 100644 --- a/backend/src/main/java/wooteco/prolog/image/infrastructure/FileNameGenerator.java +++ b/backend/src/main/java/wooteco/prolog/image/infrastructure/FileNameGenerator.java @@ -1,10 +1,12 @@ 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.springframework.stereotype.Component; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.image.domain.FileExtension; -import wooteco.prolog.image.exception.UnsupportedFilExtensionException; @Component public class FileNameGenerator { @@ -20,7 +22,7 @@ private static String getExtension(final String originalFilename) { if (FileExtension.isSupport(extension)) { return extension; } - throw new UnsupportedFilExtensionException(); + throw new BadRequestException(UNSUPPORTED_FILE_EXTENSION_EXCEPTION); } private static String createNewName() { 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 46b992051..b7143dcd0 100644 --- a/backend/src/main/java/wooteco/prolog/image/infrastructure/S3Uploader.java +++ b/backend/src/main/java/wooteco/prolog/image/infrastructure/S3Uploader.java @@ -1,5 +1,7 @@ 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; @@ -8,7 +10,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import org.springframework.web.multipart.MultipartFile; -import wooteco.prolog.image.exception.FileUploadFailException; +import wooteco.prolog.common.exception.BadRequestException; @RequiredArgsConstructor @Component @@ -30,11 +32,11 @@ public String upload(final MultipartFile uploadImageFile, final String fileName) private void putImageFileToS3(final MultipartFile uploadImageFile, final String fileName) { try { amazonS3.putObject(new PutObjectRequest(bucket, - fileName, - uploadImageFile.getInputStream(), - createObjectMetaData(uploadImageFile))); + fileName, + uploadImageFile.getInputStream(), + createObjectMetaData(uploadImageFile))); } catch (IOException e) { - throw new FileUploadFailException(); + throw new BadRequestException(FILE_UPLOAD_FAIL_EXCEPTION); } } diff --git a/backend/src/main/java/wooteco/prolog/image/ui/ImageController.java b/backend/src/main/java/wooteco/prolog/image/ui/ImageController.java index bba2dc6d5..60e6a0f33 100644 --- a/backend/src/main/java/wooteco/prolog/image/ui/ImageController.java +++ b/backend/src/main/java/wooteco/prolog/image/ui/ImageController.java @@ -18,7 +18,8 @@ public class ImageController { private final ImageService imageService; @PostMapping - public ResponseEntity upload(@RequestPart("file") MultipartFile uploadImageFile) { + public ResponseEntity upload( + @RequestPart("file") MultipartFile uploadImageFile) { return ResponseEntity.ok(imageService.upload(uploadImageFile)); } -} \ No newline at end of file +} 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 b404bf54d..06ba5cdcf 100644 --- a/backend/src/main/java/wooteco/prolog/levellogs/application/LevelLogService.java +++ b/backend/src/main/java/wooteco/prolog/levellogs/application/LevelLogService.java @@ -1,11 +1,17 @@ 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; import org.springframework.transaction.annotation.Transactional; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.levellogs.application.dto.LevelLogRequest; import wooteco.prolog.levellogs.application.dto.LevelLogResponse; import wooteco.prolog.levellogs.application.dto.LevelLogSummariesResponse; @@ -15,12 +21,8 @@ import wooteco.prolog.levellogs.domain.SelfDiscussion; import wooteco.prolog.levellogs.domain.repository.LevelLogRepository; import wooteco.prolog.levellogs.domain.repository.SelfDiscussionRepository; -import wooteco.prolog.levellogs.exception.InvalidLevelLogAuthorException; -import wooteco.prolog.levellogs.exception.LevelLogNotFoundException; -import wooteco.prolog.levellogs.exception.SelfDiscussionNotFoundException; import wooteco.prolog.member.domain.Member; import wooteco.prolog.member.domain.repository.MemberRepository; -import wooteco.prolog.member.exception.MemberNotFoundException; @Service @Transactional(readOnly = true) @@ -41,7 +43,7 @@ public LevelLogService(MemberRepository memberRepository, @Transactional public LevelLogResponse insertLevellogs(Long memberId, LevelLogRequest levelLogRequest) { final Member member = memberRepository.findById(memberId) - .orElseThrow(MemberNotFoundException::new); + .orElseThrow(() -> new BadRequestException(MEMBER_NOT_FOUND)); final LevelLog levelLog = levelLogRepository.save( new LevelLog(levelLogRequest.getTitle(), levelLogRequest.getContent(), member)); @@ -79,11 +81,11 @@ public LevelLogSummariesResponse findAll(Pageable pageable) { @Transactional public void deleteById(Long memberId, Long levelLogId) { Member member = memberRepository.findById(memberId) - .orElseThrow(MemberNotFoundException::new); + .orElseThrow(() -> new BadRequestException(MEMBER_NOT_FOUND)); LevelLog levelLog = findById(levelLogId); if (!levelLog.isAuthor(member)) { - throw new InvalidLevelLogAuthorException(); + throw new BadRequestException(INVALID_LEVEL_LOG_AUTHOR_EXCEPTION); } selfDiscussionRepository.deleteByLevelLog(levelLog); @@ -91,14 +93,16 @@ public void deleteById(Long memberId, Long levelLogId) { } @Transactional - public LevelLogResponse updateLevelLog(Long memberId, Long levelLogId, LevelLogRequest levelLogRequest) { + public LevelLogResponse updateLevelLog(Long memberId, Long levelLogId, + LevelLogRequest levelLogRequest) { final LevelLog levelLog = findById(levelLogId); levelLog.validateBelongTo(memberId); - final List selfDiscussions = selfDiscussionRepository.findByLevelLog(levelLog); + final List selfDiscussions = selfDiscussionRepository.findByLevelLog( + levelLog); if (selfDiscussions.isEmpty()) { - throw new SelfDiscussionNotFoundException(); + throw new BadRequestException(SELF_DISCUSSION_NOT_FOUND_EXCEPTION); } updateLevelLog(levelLog, levelLogRequest); @@ -111,7 +115,8 @@ private void updateLevelLog(LevelLog levelLog, LevelLogRequest levelLogRequest) levelLog.update(levelLogRequest.getTitle(), levelLogRequest.getContent()); for (SelfDiscussionRequest request : levelLogRequest.getLevelLogs()) { - selfDiscussionRepository.save(new SelfDiscussion(levelLog, request.getQuestion(), request.getAnswer())); + selfDiscussionRepository.save( + new SelfDiscussion(levelLog, request.getQuestion(), request.getAnswer())); } } @@ -123,6 +128,6 @@ public LevelLogResponse findLevelLogResponseById(Long levelLogId) { public LevelLog findById(Long levelLogId) { return levelLogRepository.findById(levelLogId) - .orElseThrow(LevelLogNotFoundException::new); + .orElseThrow(() -> new BadRequestException(LEVEL_LOG_NOT_FOUND_EXCEPTION)); } } 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 892c6070c..a5572195f 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,9 +1,7 @@ package wooteco.prolog.levellogs.application.dto; -import java.util.List; - import com.sun.istack.NotNull; - +import java.util.List; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -14,17 +12,17 @@ @ToString public class LevelLogRequest { - @NotNull - private String title; - @NotNull - private String content; - @NotNull - private List levelLogs; + @NotNull + private String title; + @NotNull + private String content; + @NotNull + private List levelLogs; - public LevelLogRequest(String title, String content, - List levelLogs) { - this.title = title; - this.content = content; - this.levelLogs = levelLogs; - } + public LevelLogRequest(String title, String content, + List levelLogs) { + this.title = title; + this.content = content; + this.levelLogs = levelLogs; + } } 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 74813087a..7febce2a7 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 @@ -3,10 +3,8 @@ import java.time.LocalDateTime; import java.util.List; import java.util.stream.Collectors; - import lombok.AccessLevel; import lombok.AllArgsConstructor; -import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.ToString; 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 1900cd284..946fbad43 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,10 +1,8 @@ package wooteco.prolog.levellogs.application.dto; import java.util.List; - import lombok.AccessLevel; import lombok.AllArgsConstructor; -import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.ToString; 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 1e0c2bb89..174a7575a 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,10 +1,8 @@ package wooteco.prolog.levellogs.application.dto; import java.time.LocalDateTime; - import lombok.AccessLevel; import lombok.AllArgsConstructor; -import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.ToString; 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 013f64f22..2ca76bbe6 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,7 +1,6 @@ package wooteco.prolog.levellogs.application.dto; import com.sun.istack.NotNull; - import lombok.AccessLevel; import lombok.EqualsAndHashCode; import lombok.Getter; diff --git a/backend/src/main/java/wooteco/prolog/levellogs/application/dto/SelfDiscussionResponse.java b/backend/src/main/java/wooteco/prolog/levellogs/application/dto/SelfDiscussionResponse.java index 6ece504b4..05e6a72ed 100644 --- a/backend/src/main/java/wooteco/prolog/levellogs/application/dto/SelfDiscussionResponse.java +++ b/backend/src/main/java/wooteco/prolog/levellogs/application/dto/SelfDiscussionResponse.java @@ -1,7 +1,6 @@ package wooteco.prolog.levellogs.application.dto; import lombok.AccessLevel; -import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.ToString; 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 b40b80755..3511c2e69 100644 --- a/backend/src/main/java/wooteco/prolog/levellogs/domain/Content.java +++ b/backend/src/main/java/wooteco/prolog/levellogs/domain/Content.java @@ -1,14 +1,14 @@ 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 lombok.AccessLevel; -import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.ToString; -import wooteco.prolog.studylog.exception.StudylogContentNullOrEmptyException; +import wooteco.prolog.common.exception.BadRequestException; @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @@ -16,24 +16,24 @@ @Embeddable public class Content { - @Column(nullable = false, columnDefinition = "text") - private String content; + @Column(nullable = false, columnDefinition = "text") + private String content; - public Content(String content) { - validateNullOrEmpty(content, length(content)); - this.content = content; - } + public Content(String content) { + validateNullOrEmpty(content, length(content)); + this.content = content; + } - private int length(String title) { - if (title != null) { - return title.trim().length(); - } - return 0; - } + private int length(String title) { + if (title != null) { + return title.trim().length(); + } + return 0; + } - private void validateNullOrEmpty(String content, int trimedContentLength) { - if ((content == null) || trimedContentLength == 0) { - throw new StudylogContentNullOrEmptyException(); - } - } + private void validateNullOrEmpty(String content, int trimedContentLength) { + if ((content == null) || trimedContentLength == 0) { + throw new BadRequestException(STUDYLOG_CONTENT_NULL_OR_EMPTY); + } + } } 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 48f1ab461..e69a47023 100644 --- a/backend/src/main/java/wooteco/prolog/levellogs/domain/LevelLog.java +++ b/backend/src/main/java/wooteco/prolog/levellogs/domain/LevelLog.java @@ -1,5 +1,7 @@ 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; @@ -12,7 +14,7 @@ import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import wooteco.prolog.common.AuditingEntity; -import wooteco.prolog.levellogs.exception.InvalidLevelLogAuthorException; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.member.domain.Member; @Entity @@ -63,7 +65,7 @@ public Member getMember() { public void validateBelongTo(Long memberId) { if (!isBelongsTo(memberId)) { - throw new InvalidLevelLogAuthorException(); + throw new BadRequestException(INVALID_LEVEL_LOG_AUTHOR_EXCEPTION); } } 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 6d921c391..8bb6c3081 100644 --- a/backend/src/main/java/wooteco/prolog/levellogs/domain/Title.java +++ b/backend/src/main/java/wooteco/prolog/levellogs/domain/Title.java @@ -1,17 +1,17 @@ package wooteco.prolog.levellogs.domain; -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; +import java.util.Objects; import javax.persistence.Column; import javax.persistence.Embeddable; - import lombok.AccessLevel; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.ToString; -import wooteco.prolog.login.excetpion.StudylogTitleNullOrEmptyException; -import wooteco.prolog.studylog.exception.TooLongTitleException; +import wooteco.prolog.common.exception.BadRequestException; @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @@ -20,44 +20,45 @@ @Embeddable public class Title { - public static final int MAX_LENGTH = 50; - - @Column(nullable = false, length = MAX_LENGTH) - private String title; - - public Title(String title) { - this.title = trim(title); - validateNull(title); - validateEmpty(title); - validateOnlyBlank(title); - validateMaxLength(title); - } - - private String trim(String name) { - return name.trim(); - } - - private void validateNull(String title) { - if (Objects.isNull(title)) { - throw new StudylogTitleNullOrEmptyException(); - } - } - - private void validateEmpty(String title) { - if (title.isEmpty()) { - throw new StudylogTitleNullOrEmptyException(); - } - } - - private void validateOnlyBlank(String title) { - if (title.trim().isEmpty()) { - throw new StudylogTitleNullOrEmptyException(); - } - } - - private void validateMaxLength(String title) { - if (title.length() > MAX_LENGTH) { - throw new TooLongTitleException(); - } - } + public static final int MAX_LENGTH = 50; + + @Column(nullable = false, length = MAX_LENGTH) + private String title; + + public Title(String title) { + this.title = trim(title); + validateNull(title); + validateEmpty(title); + validateOnlyBlank(title); + validateMaxLength(title); + } + + private String trim(String name) { + return name.trim(); + } + + private void validateNull(String title) { + if (Objects.isNull(title)) { + throw new BadRequestException(STUDYLOG_TITLE_NULL_OR_EMPTY); + } + } + + private void validateEmpty(String title) { + if (title.isEmpty()) { + throw new BadRequestException(STUDYLOG_TITLE_NULL_OR_EMPTY); + } + } + + private void validateOnlyBlank(String title) { + if (title.trim().isEmpty()) { + throw new BadRequestException(STUDYLOG_TITLE_NULL_OR_EMPTY); + } + } + + private void validateMaxLength(String title) { + if (title.length() > MAX_LENGTH) { + throw new BadRequestException(STUDYLOG_TITLE_TOO_LONG); + } + } + } diff --git a/backend/src/main/java/wooteco/prolog/levellogs/exception/InvalidLevelLogAuthorException.java b/backend/src/main/java/wooteco/prolog/levellogs/exception/InvalidLevelLogAuthorException.java deleted file mode 100644 index 131e8e9da..000000000 --- a/backend/src/main/java/wooteco/prolog/levellogs/exception/InvalidLevelLogAuthorException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.levellogs.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class InvalidLevelLogAuthorException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/levellogs/exception/LevelLogNotFoundException.java b/backend/src/main/java/wooteco/prolog/levellogs/exception/LevelLogNotFoundException.java deleted file mode 100644 index d59d28dd3..000000000 --- a/backend/src/main/java/wooteco/prolog/levellogs/exception/LevelLogNotFoundException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.levellogs.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class LevelLogNotFoundException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/levellogs/exception/SelfDiscussionNotFoundException.java b/backend/src/main/java/wooteco/prolog/levellogs/exception/SelfDiscussionNotFoundException.java deleted file mode 100644 index e67f20bc2..000000000 --- a/backend/src/main/java/wooteco/prolog/levellogs/exception/SelfDiscussionNotFoundException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.levellogs.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class SelfDiscussionNotFoundException extends BadRequestException { - -} 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 af68cda77..905f50e1a 100644 --- a/backend/src/main/java/wooteco/prolog/login/aop/LoginMemberVerifier.java +++ b/backend/src/main/java/wooteco/prolog/login/aop/LoginMemberVerifier.java @@ -1,11 +1,13 @@ 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; import org.springframework.stereotype.Component; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.login.ui.LoginMember.Authority; -import wooteco.prolog.member.exception.MemberNotAllowedException; @Aspect @Component @@ -18,7 +20,8 @@ public class LoginMemberVerifier { public void checkLoginMember() { final Authority authority = memberAuthorityCache.getAuthority(); if (!authority.equals(Authority.MEMBER)) { - throw new MemberNotAllowedException(); + throw new BadRequestException(MEMBER_NOT_ALLOWED); } } + } 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 a23c6011c..59f21b948 100644 --- a/backend/src/main/java/wooteco/prolog/login/application/AuthorizationExtractor.java +++ b/backend/src/main/java/wooteco/prolog/login/application/AuthorizationExtractor.java @@ -17,7 +17,7 @@ public static String extract(HttpServletRequest request) { if ((value.toLowerCase().startsWith(BEARER_TYPE.toLowerCase()))) { String authHeaderValue = value.substring(BEARER_TYPE.length()).trim(); request.setAttribute(ACCESS_TOKEN_TYPE, - value.substring(0, BEARER_TYPE.length()).trim()); + value.substring(0, BEARER_TYPE.length()).trim()); int commaIndex = authHeaderValue.indexOf(','); if (commaIndex > 0) { authHeaderValue = authHeaderValue.substring(0, commaIndex); 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 314f9bbbb..e0af3b50d 100644 --- a/backend/src/main/java/wooteco/prolog/login/application/GithubClient.java +++ b/backend/src/main/java/wooteco/prolog/login/application/GithubClient.java @@ -1,5 +1,8 @@ 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; @@ -9,11 +12,10 @@ import org.springframework.util.MultiValueMap; import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.RestTemplate; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.login.application.dto.GithubAccessTokenRequest; import wooteco.prolog.login.application.dto.GithubAccessTokenResponse; import wooteco.prolog.login.application.dto.GithubProfileResponse; -import wooteco.prolog.login.excetpion.GithubApiFailException; -import wooteco.prolog.login.excetpion.GithubConnectionException; @Component public class GithubClient { @@ -46,7 +48,7 @@ public String getAccessTokenFromGithub(String code) { .getBody() .getAccessToken(); if (accessToken == null) { - throw new GithubApiFailException(); + throw new BadRequestException(GITHUB_API_FAIL); } return accessToken; } @@ -63,7 +65,7 @@ public GithubProfileResponse getGithubProfileFromGithub(String accessToken) { .exchange(profileUrl, HttpMethod.GET, httpEntity, GithubProfileResponse.class) .getBody(); } catch (HttpClientErrorException e) { - throw new GithubConnectionException(); + throw new BadRequestException(GITHUB_CONNECTION_FAIL); } } } 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 9a87c7dde..b8635723a 100644 --- a/backend/src/main/java/wooteco/prolog/login/application/GithubLoginService.java +++ b/backend/src/main/java/wooteco/prolog/login/application/GithubLoginService.java @@ -1,10 +1,12 @@ 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; import wooteco.prolog.login.application.dto.TokenRequest; import wooteco.prolog.login.application.dto.TokenResponse; -import wooteco.prolog.login.excetpion.TokenNotValidException; import wooteco.prolog.member.application.MemberService; import wooteco.prolog.member.domain.Member; @@ -36,7 +38,7 @@ public TokenResponse createToken(TokenRequest tokenRequest) { public void validateToken(String credentials) { if (!jwtTokenProvider.validateToken(credentials)) { - throw new TokenNotValidException(); + throw new BadRequestException(TOKEN_NOT_VALID); } } } 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 40870bf1d..6e941422a 100644 --- a/backend/src/main/java/wooteco/prolog/login/application/JwtTokenProvider.java +++ b/backend/src/main/java/wooteco/prolog/login/application/JwtTokenProvider.java @@ -1,5 +1,7 @@ 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; @@ -9,7 +11,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; -import wooteco.prolog.login.excetpion.TokenNotValidException; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.member.domain.Member; @Component @@ -50,7 +52,7 @@ public String extractSubject(String token) { .getSubject(); } catch (JwtException | IllegalArgumentException e) { log.info(e.getMessage(), e); - throw new TokenNotValidException(); + throw new BadRequestException(TOKEN_NOT_VALID); } } } diff --git a/backend/src/main/java/wooteco/prolog/login/application/dto/GithubAccessTokenRequest.java b/backend/src/main/java/wooteco/prolog/login/application/dto/GithubAccessTokenRequest.java index fcf3d6a8d..896fc9342 100644 --- a/backend/src/main/java/wooteco/prolog/login/application/dto/GithubAccessTokenRequest.java +++ b/backend/src/main/java/wooteco/prolog/login/application/dto/GithubAccessTokenRequest.java @@ -2,9 +2,9 @@ public class GithubAccessTokenRequest { - private String code; - private String client_id; - private String client_secret; + private final String code; + private final String client_id; + private final String client_secret; public GithubAccessTokenRequest(String code, String client_id, String client_secret) { this.code = code; diff --git a/backend/src/main/java/wooteco/prolog/login/excetpion/GithubApiFailException.java b/backend/src/main/java/wooteco/prolog/login/excetpion/GithubApiFailException.java deleted file mode 100644 index b896f96ad..000000000 --- a/backend/src/main/java/wooteco/prolog/login/excetpion/GithubApiFailException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.login.excetpion; - -import wooteco.prolog.common.exception.BadRequestException; - -public class GithubApiFailException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/login/excetpion/GithubConnectionException.java b/backend/src/main/java/wooteco/prolog/login/excetpion/GithubConnectionException.java deleted file mode 100644 index 3d7a4990e..000000000 --- a/backend/src/main/java/wooteco/prolog/login/excetpion/GithubConnectionException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.login.excetpion; - -import wooteco.prolog.common.exception.BadRequestException; - -public class GithubConnectionException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/login/excetpion/RoleNameNotFoundException.java b/backend/src/main/java/wooteco/prolog/login/excetpion/RoleNameNotFoundException.java deleted file mode 100644 index 02f7182f5..000000000 --- a/backend/src/main/java/wooteco/prolog/login/excetpion/RoleNameNotFoundException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.login.excetpion; - -import wooteco.prolog.common.exception.BadRequestException; - -public class RoleNameNotFoundException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/login/excetpion/StudylogTitleNullOrEmptyException.java b/backend/src/main/java/wooteco/prolog/login/excetpion/StudylogTitleNullOrEmptyException.java deleted file mode 100644 index 312cd256f..000000000 --- a/backend/src/main/java/wooteco/prolog/login/excetpion/StudylogTitleNullOrEmptyException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.login.excetpion; - -import wooteco.prolog.common.exception.BadRequestException; - -public class StudylogTitleNullOrEmptyException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/login/excetpion/TokenNotValidException.java b/backend/src/main/java/wooteco/prolog/login/excetpion/TokenNotValidException.java deleted file mode 100644 index efea8577c..000000000 --- a/backend/src/main/java/wooteco/prolog/login/excetpion/TokenNotValidException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.login.excetpion; - -import wooteco.prolog.common.exception.BadRequestException; - -public class TokenNotValidException extends BadRequestException { - -} 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 0b3e51724..c2e50a8b0 100644 --- a/backend/src/main/java/wooteco/prolog/login/ui/AuthMemberPrincipalArgumentResolver.java +++ b/backend/src/main/java/wooteco/prolog/login/ui/AuthMemberPrincipalArgumentResolver.java @@ -1,5 +1,7 @@ package wooteco.prolog.login.ui; +import static wooteco.prolog.common.exception.BadRequestCode.TOKEN_NOT_VALID; + import javax.servlet.http.HttpServletRequest; import lombok.AllArgsConstructor; import org.springframework.core.MethodParameter; @@ -7,11 +9,11 @@ import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.method.support.HandlerMethodArgumentResolver; import org.springframework.web.method.support.ModelAndViewContainer; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.login.aop.MemberAuthorityCache; import wooteco.prolog.login.application.AuthorizationExtractor; import wooteco.prolog.login.application.JwtTokenProvider; import wooteco.prolog.login.domain.AuthMemberPrincipal; -import wooteco.prolog.login.excetpion.TokenNotValidException; import wooteco.prolog.login.ui.LoginMember.Authority; @AllArgsConstructor @@ -26,8 +28,10 @@ public boolean supportsParameter(MethodParameter parameter) { } @Override - public LoginMember resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, - NativeWebRequest webRequest, WebDataBinderFactory binderFactory) { + public LoginMember resolveArgument(MethodParameter parameter, + ModelAndViewContainer mavContainer, + NativeWebRequest webRequest, + WebDataBinderFactory binderFactory) { String credentials = AuthorizationExtractor .extract(webRequest.getNativeRequest(HttpServletRequest.class)); @@ -41,8 +45,8 @@ public LoginMember resolveArgument(MethodParameter parameter, ModelAndViewContai memberAuthorityCache.setAuthority(Authority.MEMBER); return new LoginMember(id, Authority.MEMBER); } catch (NumberFormatException e) { - throw new TokenNotValidException(); + throw new BadRequestException(TOKEN_NOT_VALID); } - } + } 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 c06776c9e..d3078a4ee 100644 --- a/backend/src/main/java/wooteco/prolog/login/ui/LoginConfig.java +++ b/backend/src/main/java/wooteco/prolog/login/ui/LoginConfig.java @@ -35,6 +35,7 @@ public void addInterceptors(InterceptorRegistry registry) { @Override public void addArgumentResolvers(List resolvers) { - resolvers.add(new AuthMemberPrincipalArgumentResolver(jwtTokenProvider, memberAuthorityCache)); + resolvers.add( + new AuthMemberPrincipalArgumentResolver(jwtTokenProvider, memberAuthorityCache)); } } 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 9d1b37c69..ccef0a204 100644 --- a/backend/src/main/java/wooteco/prolog/member/application/MemberService.java +++ b/backend/src/main/java/wooteco/prolog/member/application/MemberService.java @@ -1,5 +1,8 @@ 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; @@ -9,17 +12,16 @@ import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.login.application.dto.GithubProfileResponse; import wooteco.prolog.login.ui.LoginMember; import wooteco.prolog.member.application.dto.MemberResponse; import wooteco.prolog.member.application.dto.MemberUpdateRequest; +import wooteco.prolog.member.application.dto.MembersResponse; import wooteco.prolog.member.application.dto.ProfileIntroRequest; import wooteco.prolog.member.application.dto.ProfileIntroResponse; import wooteco.prolog.member.domain.Member; import wooteco.prolog.member.domain.repository.MemberRepository; -import wooteco.prolog.member.exception.MemberNotAllowedException; -import wooteco.prolog.member.exception.MemberNotFoundException; -import wooteco.prolog.member.application.dto.MembersResponse; @Service @AllArgsConstructor @@ -36,12 +38,12 @@ public Member findOrCreateMember(GithubProfileResponse githubProfile) { public Member findById(Long id) { return memberRepository.findById(id) - .orElseThrow(MemberNotFoundException::new); + .orElseThrow(() -> new BadRequestException(MEMBER_NOT_FOUND)); } public Member findByUsername(String username) { return memberRepository.findByUsername(username) - .orElseThrow(MemberNotFoundException::new); + .orElseThrow(() -> new BadRequestException(MEMBER_NOT_FOUND)); } public MemberResponse findMemberResponseByUsername(String username) { @@ -66,11 +68,11 @@ public void updateMember_deprecated(Long memberId, MemberUpdateRequest updateReq public void updateMember(LoginMember loginMember, String username, MemberUpdateRequest updateRequest) { - loginMember.act().throwIfAnonymous(MemberNotAllowedException::new); + loginMember.act().throwIfAnonymous(() -> new BadRequestException(MEMBER_NOT_ALLOWED)); Member persistMember = loginMember.act().ifMember(memberId -> { Member member = findById(memberId); if (!Objects.equals(member.getUsername(), username)) { - throw new MemberNotAllowedException(); + throw new BadRequestException(MEMBER_NOT_ALLOWED); } return member; }).getReturnValue(Member.class); @@ -83,12 +85,12 @@ public void updateMember(LoginMember loginMember, public void updateProfileIntro(LoginMember loginMember, String username, ProfileIntroRequest updateRequest) { - loginMember.act().throwIfAnonymous(MemberNotAllowedException::new); + loginMember.act().throwIfAnonymous(() -> new BadRequestException(MEMBER_NOT_ALLOWED)); Member persistMember = loginMember.act().ifMember(memberId -> { Member member = findById(memberId); if (!Objects.equals(member.getUsername(), username)) { - throw new MemberNotAllowedException(); + throw new BadRequestException(MEMBER_NOT_ALLOWED); } return member; }).getReturnValue(Member.class); @@ -99,9 +101,9 @@ public void updateProfileIntro(LoginMember loginMember, public List findAllOrderByNickNameAsc() { final List members = memberRepository.findAll(); return members.stream() - .sorted(Comparator.comparing(Member::getNickname)) - .map(MemberResponse::of) - .collect(Collectors.toList()); + .sorted(Comparator.comparing(Member::getNickname)) + .map(MemberResponse::of) + .collect(Collectors.toList()); } public MembersResponse findAll(Pageable pageable) { 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 8d1d7f54b..e39ecef2a 100644 --- a/backend/src/main/java/wooteco/prolog/member/application/MemberTagService.java +++ b/backend/src/main/java/wooteco/prolog/member/application/MemberTagService.java @@ -35,7 +35,8 @@ public void registerMemberTag(Tags tags, Member member) { public void updateMemberTag(Tags originalTags, Tags newTags, Member member) { final List originalMemberTags = originalTags.toMemberTags(member); final List newMemberTags = newTags.toMemberTags(member); - memberTagRepository.update(new MemberTags(originalMemberTags), new MemberTags(newMemberTags)); + memberTagRepository.update(new MemberTags(originalMemberTags), + new MemberTags(newMemberTags)); } public void removeMemberTag(Tags tags, Member member) { diff --git a/backend/src/main/java/wooteco/prolog/member/application/dto/MemberResponse.java b/backend/src/main/java/wooteco/prolog/member/application/dto/MemberResponse.java index fb6211d71..3bd7285ba 100644 --- a/backend/src/main/java/wooteco/prolog/member/application/dto/MemberResponse.java +++ b/backend/src/main/java/wooteco/prolog/member/application/dto/MemberResponse.java @@ -23,6 +23,6 @@ public class MemberResponse { public static MemberResponse of(Member member) { return new MemberResponse(member.getId(), member.getUsername(), member.getNickname(), - member.getRole(), member.getImageUrl()); + member.getRole(), member.getImageUrl()); } } diff --git a/backend/src/main/java/wooteco/prolog/member/application/dto/MemberScrapResponse.java b/backend/src/main/java/wooteco/prolog/member/application/dto/MemberScrapResponse.java index f8409b43d..70b9b62a8 100644 --- a/backend/src/main/java/wooteco/prolog/member/application/dto/MemberScrapResponse.java +++ b/backend/src/main/java/wooteco/prolog/member/application/dto/MemberScrapResponse.java @@ -3,8 +3,8 @@ import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import wooteco.prolog.studylog.domain.StudylogScrap; import wooteco.prolog.studylog.application.dto.StudylogResponse; +import wooteco.prolog.studylog.domain.StudylogScrap; @AllArgsConstructor @NoArgsConstructor 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 02fb716c6..ba0a07c3f 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 @@ -25,6 +25,7 @@ public static MembersResponse of(Page originData) { .map(it -> MemberResponse.of(it)) .collect(Collectors.toList()); - return new MembersResponse(data, originData.getTotalElements(), originData.getTotalPages(), originData.getNumber() + 1); + return new MembersResponse(data, originData.getTotalElements(), originData.getTotalPages(), + originData.getNumber() + 1); } } 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 cd40257b8..c7ec37869 100644 --- a/backend/src/main/java/wooteco/prolog/member/domain/Member.java +++ b/backend/src/main/java/wooteco/prolog/member/domain/Member.java @@ -5,7 +5,14 @@ import java.util.List; import java.util.Objects; import java.util.stream.Collectors; -import javax.persistence.*; +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 lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/backend/src/main/java/wooteco/prolog/member/domain/MemberGroup.java b/backend/src/main/java/wooteco/prolog/member/domain/MemberGroup.java index 5997356ef..cfa6a76d0 100644 --- a/backend/src/main/java/wooteco/prolog/member/domain/MemberGroup.java +++ b/backend/src/main/java/wooteco/prolog/member/domain/MemberGroup.java @@ -1,13 +1,12 @@ package wooteco.prolog.member.domain; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; - import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; @Entity @NoArgsConstructor(access = AccessLevel.PROTECTED) 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 bdbdbb208..12c04f9c2 100644 --- a/backend/src/main/java/wooteco/prolog/member/domain/MemberTags.java +++ b/backend/src/main/java/wooteco/prolog/member/domain/MemberTags.java @@ -1,5 +1,8 @@ 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; @@ -9,8 +12,7 @@ import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; -import wooteco.prolog.member.exception.DuplicateMemberTagException; -import wooteco.prolog.member.exception.NotExistsMemberTag; +import wooteco.prolog.common.exception.BadRequestException; @Getter @Embeddable @@ -23,7 +25,10 @@ public class MemberTags { public MemberTags(List values) { final int originalSize = values.size(); final long count = values.stream().distinct().count(); - if(originalSize != count) throw new DuplicateMemberTagException(); + if (originalSize != count) { + throw new BadRequestException(DUPLICATE_MEMBER_TAG); + } + this.values = values; } @@ -50,7 +55,8 @@ public void removeMemberTags(List memberTags) { private void remove(MemberTag memberTag) { final MemberTag foundMemberTag = - findMemberTag(memberTag).orElseThrow(NotExistsMemberTag::new); + findMemberTag(memberTag) + .orElseThrow(() -> new BadRequestException(NOT_EXISTS_MEMBER_TAG)); if (foundMemberTag.hasOnlyOne()) { values.remove(foundMemberTag); @@ -61,8 +67,8 @@ private void remove(MemberTag memberTag) { private Optional findMemberTag(MemberTag memberTag) { return values.stream() - .filter(value -> value.isSame(memberTag)) - .findAny(); + .filter(value -> value.isSame(memberTag)) + .findAny(); } public void updateTags(List originalMemberTag, List newMemberTag) { diff --git a/backend/src/main/java/wooteco/prolog/member/domain/Role.java b/backend/src/main/java/wooteco/prolog/member/domain/Role.java index ce5ff3ac3..5bdad63ce 100644 --- a/backend/src/main/java/wooteco/prolog/member/domain/Role.java +++ b/backend/src/main/java/wooteco/prolog/member/domain/Role.java @@ -5,5 +5,5 @@ public enum Role { UNVALIDATED, CREW, COACH, - ADMIN; + ADMIN } 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 e840d05af..1ca2ce90a 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 @@ -30,14 +30,18 @@ public void register(MemberTags memberTags) { } private void addCount(List memberTags) { - if (memberTags == null || memberTags.isEmpty()) return; + if (memberTags == null || memberTags.isEmpty()) { + return; + } String sql = "update member_tag set count = count + 1 where member_id = ? and tag_id in (%s)"; executeInQuery(sql, memberTags); } private void insertMemberTags(List memberTags) { - if(memberTags == null || memberTags.isEmpty()) return; + if (memberTags == null || memberTags.isEmpty()) { + return; + } String sql = "insert into member_tag(member_id, tag_id, count) select ?,?,1 from dual where not exists (select * from member_tag where member_id = ? and tag_id = ? limit 1)"; @@ -68,14 +72,18 @@ public void unregister(MemberTags memberTags) { } private void removeMemberTags(List memberTags) { - if (memberTags == null || memberTags.isEmpty()) return; + if (memberTags == null || memberTags.isEmpty()) { + return; + } String sql = "delete from member_tag where count = 1 and member_id = ? and tag_id in (%s)"; executeInQuery(sql, memberTags); } private void removeCount(List memberTags) { - if (memberTags == null || memberTags.isEmpty()) return; + if (memberTags == null || memberTags.isEmpty()) { + return; + } String sql = "update member_tag set count = count - 1 where count > 1 and member_id = ? and tag_id in (%s)"; executeInQuery(sql, memberTags); diff --git a/backend/src/main/java/wooteco/prolog/member/exception/DuplicateMemberTagException.java b/backend/src/main/java/wooteco/prolog/member/exception/DuplicateMemberTagException.java deleted file mode 100644 index 6d6241bcd..000000000 --- a/backend/src/main/java/wooteco/prolog/member/exception/DuplicateMemberTagException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.member.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class DuplicateMemberTagException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/member/exception/MemberNotAllowedException.java b/backend/src/main/java/wooteco/prolog/member/exception/MemberNotAllowedException.java deleted file mode 100644 index 02aa343e2..000000000 --- a/backend/src/main/java/wooteco/prolog/member/exception/MemberNotAllowedException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.member.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class MemberNotAllowedException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/member/exception/MemberNotFoundException.java b/backend/src/main/java/wooteco/prolog/member/exception/MemberNotFoundException.java deleted file mode 100644 index 0c4a849e7..000000000 --- a/backend/src/main/java/wooteco/prolog/member/exception/MemberNotFoundException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.member.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class MemberNotFoundException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/member/exception/NotExistsMemberTag.java b/backend/src/main/java/wooteco/prolog/member/exception/NotExistsMemberTag.java deleted file mode 100644 index ece80e3a4..000000000 --- a/backend/src/main/java/wooteco/prolog/member/exception/NotExistsMemberTag.java +++ /dev/null @@ -1,8 +0,0 @@ -package wooteco.prolog.member.exception; - - -import wooteco.prolog.common.exception.BadRequestException; - -public class NotExistsMemberTag extends BadRequestException { - -} 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 695079fa9..a342b16ce 100644 --- a/backend/src/main/java/wooteco/prolog/member/ui/MemberController.java +++ b/backend/src/main/java/wooteco/prolog/member/ui/MemberController.java @@ -45,7 +45,8 @@ public ResponseEntity updateMember( // admin only @GetMapping - public ResponseEntity show(@PageableDefault(direction = DESC, sort = "id") Pageable pageable) { + public ResponseEntity show( + @PageableDefault(direction = DESC, sort = "id") Pageable pageable) { MembersResponse response = memberService.findAll(pageable); return ResponseEntity.ok(response); } @@ -64,7 +65,8 @@ public ResponseEntity updateMember_deprecated( @Deprecated @GetMapping(value = "/me", produces = MediaType.APPLICATION_JSON_VALUE) @MemberOnly - public ResponseEntity findMemberInfoOfMine(@AuthMemberPrincipal LoginMember member) { + public ResponseEntity findMemberInfoOfMine( + @AuthMemberPrincipal LoginMember member) { return ResponseEntity.ok().body(MemberResponse.of(memberService.findById(member.getId()))); } } 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 348729153..f3ff51df1 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/application/CurriculumService.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/application/CurriculumService.java @@ -1,13 +1,15 @@ 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; import wooteco.prolog.roadmap.application.dto.CurriculumRequest; import wooteco.prolog.roadmap.application.dto.CurriculumResponses; import wooteco.prolog.roadmap.domain.Curriculum; import wooteco.prolog.roadmap.domain.repository.CurriculumRepository; -import wooteco.prolog.roadmap.exception.CurriculumNotFoundException; @Transactional @Service @@ -44,6 +46,6 @@ public void delete(Long curriculumId) { private Curriculum getCurriculum(Long curriculumId) { return curriculumRepository.findById(curriculumId) - .orElseThrow(CurriculumNotFoundException::new); + .orElseThrow(() -> new BadRequestException(CURRICULUM_NOT_FOUND_EXCEPTION)); } } 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 067106d1a..5d0578e48 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/application/KeywordService.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/application/KeywordService.java @@ -1,17 +1,19 @@ 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_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; import wooteco.prolog.roadmap.application.dto.KeywordCreateRequest; import wooteco.prolog.roadmap.application.dto.KeywordResponse; import wooteco.prolog.roadmap.application.dto.KeywordUpdateRequest; import wooteco.prolog.roadmap.application.dto.KeywordsResponse; import wooteco.prolog.roadmap.domain.Keyword; import wooteco.prolog.roadmap.domain.repository.KeywordRepository; -import wooteco.prolog.roadmap.exception.KeywordNotFoundException; import wooteco.prolog.session.domain.repository.SessionRepository; -import wooteco.prolog.session.exception.SessionNotFoundException; @Transactional @Service @@ -43,7 +45,7 @@ public Long createKeyword(final Long sessionId, final KeywordCreateRequest reque public KeywordResponse findKeyword(final Long sessionId, final Long keywordId) { existSession(sessionId); Keyword keyword = keywordRepository.findById(keywordId) - .orElseThrow(KeywordNotFoundException::new); + .orElseThrow(() -> new BadRequestException(ROADMAP_KEYWORD_NOT_FOUND_EXCEPTION)); return KeywordResponse.createResponse(keyword); } @@ -71,7 +73,7 @@ public void updateKeyword(final Long sessionId, final Long keywordId, final KeywordUpdateRequest request) { existSession(sessionId); // 세션이 없다면 예외가 발생 Keyword keyword = keywordRepository.findById(keywordId) - .orElseThrow(KeywordNotFoundException::new); // keyword 가 없다면 예외를 발생 + .orElseThrow(() -> new BadRequestException(ROADMAP_KEYWORD_NOT_FOUND_EXCEPTION)); Keyword keywordParent = findKeywordParentOrNull(request.getParentKeywordId()); keyword.update(request.getName(), request.getDescription(), request.getOrder(), @@ -88,14 +90,14 @@ public void deleteKeyword(final Long sessionId, final Long keywordId) { private void existSession(final Long sessionId) { boolean exists = sessionRepository.existsById(sessionId); if (!exists) { - throw new SessionNotFoundException(); + throw new BadRequestException(ROADMAP_SESSION_NOT_FOUND_EXCEPTION); } } private void existKeyword(final Long keywordId) { boolean exists = keywordRepository.existsById(keywordId); if (!exists) { - throw new KeywordNotFoundException(); + throw new BadRequestException(ROADMAP_KEYWORD_NOT_FOUND_EXCEPTION); } } @@ -103,6 +105,7 @@ private Keyword findKeywordParentOrNull(final Long keywordId) { if (keywordId == null) { return null; } - return keywordRepository.findById(keywordId).orElseThrow(KeywordNotFoundException::new); + return keywordRepository.findById(keywordId) + .orElseThrow(() -> new BadRequestException(ROADMAP_KEYWORD_NOT_FOUND_EXCEPTION)); } } 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 3fc5194fc..ef156c406 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/application/NewSessionService.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/application/NewSessionService.java @@ -1,16 +1,18 @@ 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; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.roadmap.application.dto.SessionRequest; import wooteco.prolog.roadmap.application.dto.SessionResponse; import wooteco.prolog.roadmap.application.dto.SessionsResponse; import wooteco.prolog.session.domain.Session; import wooteco.prolog.session.domain.repository.SessionRepository; -import wooteco.prolog.session.exception.SessionNotFoundException; @Transactional(readOnly = true) @RequiredArgsConstructor @@ -36,7 +38,7 @@ public SessionsResponse findSessions(final Long curriculumId) { @Transactional public void updateSession(final Long sessionId, final SessionRequest request) { Session session = sessionRepository.findById(sessionId) - .orElseThrow(SessionNotFoundException::new); + .orElseThrow(() -> new BadRequestException(ROADMAP_SESSION_NOT_FOUND_EXCEPTION)); session.update(request.getName()); } @@ -49,7 +51,7 @@ public void deleteSession(final Long sessionId) { private void validateExistSession(final Long sessionId) { if (!sessionRepository.existsById(sessionId)) { - throw new SessionNotFoundException(); + throw new BadRequestException(ROADMAP_SESSION_NOT_FOUND_EXCEPTION); } } } 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 a86ef8c7f..e1ab45dcc 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/application/QuizService.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/application/QuizService.java @@ -1,9 +1,13 @@ package wooteco.prolog.roadmap.application; +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.List; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.roadmap.application.dto.QuizRequest; import wooteco.prolog.roadmap.application.dto.QuizResponse; import wooteco.prolog.roadmap.application.dto.QuizzesResponse; @@ -11,8 +15,6 @@ import wooteco.prolog.roadmap.domain.Quiz; import wooteco.prolog.roadmap.domain.repository.KeywordRepository; import wooteco.prolog.roadmap.domain.repository.QuizRepository; -import wooteco.prolog.roadmap.exception.KeywordOrderException; -import wooteco.prolog.roadmap.exception.QuizNotFoundException; @Service @Transactional(readOnly = true) @@ -25,7 +27,7 @@ public class QuizService { @Transactional public Long createQuiz(Long keywordId, QuizRequest quizRequest) { final Keyword keyword = keywordRepository.findById(keywordId) - .orElseThrow(KeywordOrderException::new); + .orElseThrow(() -> new BadRequestException(ROADMAP_KEYWORD_ORDER_EXCEPTION)); final Quiz quiz = quizRepository.save(new Quiz(keyword, quizRequest.getQuestion())); return quiz.getId(); } @@ -37,20 +39,22 @@ public QuizzesResponse findQuizzesByKeywordId(Long keywordId) { @Transactional public void updateQuiz(Long quizId, QuizRequest quizRequest) { - final Quiz quiz = quizRepository.findById(quizId).orElseThrow(QuizNotFoundException::new); + final Quiz quiz = quizRepository.findById(quizId) + .orElseThrow(() -> new BadRequestException(ROADMAP_QUIZ_NOT_FOUND_EXCEPTION)); quiz.update(quizRequest.getQuestion()); } @Transactional public void deleteQuiz(Long quizId) { if (!quizRepository.existsById(quizId)) { - throw new QuizNotFoundException(); + throw new BadRequestException(ROADMAP_QUIZ_NOT_FOUND_EXCEPTION); } quizRepository.deleteById(quizId); } public QuizResponse findById(Long quizId) { - final Quiz quiz = quizRepository.findById(quizId).orElseThrow(QuizNotFoundException::new); + final Quiz quiz = quizRepository.findById(quizId) + .orElseThrow(() -> new BadRequestException(ROADMAP_QUIZ_NOT_FOUND_EXCEPTION)); return QuizResponse.of(quiz); } } 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 a74a5b3f1..68069a1d9 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 @@ -19,7 +19,8 @@ public class KeywordResponse { private Long parentKeywordId; private Set childrenKeywords; - public KeywordResponse(final Long keywordId, final String name, final String description, final int order, + public KeywordResponse(final Long keywordId, final String name, final String description, + final int order, final int importance, final Long parentKeywordId, final Set childrenKeywords) { this.keywordId = keywordId; 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 dafa820a3..669bed52d 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/domain/Curriculum.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/domain/Curriculum.java @@ -1,5 +1,7 @@ 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; @@ -8,7 +10,7 @@ import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; -import wooteco.prolog.roadmap.exception.CurriculumInvalidException; +import wooteco.prolog.common.exception.BadRequestException; @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @@ -34,7 +36,7 @@ public Curriculum(String name) { private void validateName(String name) { if (name == null || name.trim().isEmpty()) { - throw new CurriculumInvalidException(); + throw new BadRequestException(CURRICULUM_INVALID_EXCEPTION); } } 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 d58f5e52a..8518c806c 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/domain/Keyword.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/domain/Keyword.java @@ -1,11 +1,40 @@ 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 lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; import org.hibernate.annotations.BatchSize; -import wooteco.prolog.roadmap.exception.KeywordAndKeywordParentSameException; -import wooteco.prolog.roadmap.exception.KeywordSeqException; +import wooteco.prolog.common.exception.BadRequestException; + +import javax.persistence.*; +import java.util.HashSet; +import java.util.List; +import java.util.Objects; +import java.util.Set; + +import javax.persistence.*; +import java.util.HashSet; +import java.util.List; +import java.util.Objects; +import java.util.Set; import javax.persistence.*; import java.util.HashSet; @@ -49,7 +78,8 @@ public class Keyword { @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL, orphanRemoval = true) private Set children = new HashSet<>(); - public Keyword(final Long id, final String name, final String description, final int seq, final int importance, + public Keyword(final Long id, final String name, final String description, final int seq, + final int importance, final Long sessionId, final Keyword parent, final Set children) { validateSeq(seq); this.id = id; @@ -84,13 +114,13 @@ public void update(final String name, final String description, final int seq, private void validateSeq(final int seq) { if (seq <= 0) { - throw new KeywordSeqException(); + throw new BadRequestException(ROADMAP_KEYWORD_SEQUENCE_EXCEPTION); } } private void validateKeywordParent(final Keyword parentKeyword) { if (this.parent != null && this.id.equals(parentKeyword.getId())) { - throw new KeywordAndKeywordParentSameException(); + throw new BadRequestException(ROADMAP_KEYWORD_AND_KEYWORD_PARENT_SAME_EXCEPTION); } } 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 c697c08a3..8054e6957 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/domain/Quiz.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/domain/Quiz.java @@ -1,5 +1,7 @@ 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; @@ -10,7 +12,7 @@ import javax.persistence.ManyToOne; import lombok.AccessLevel; import lombok.NoArgsConstructor; -import wooteco.prolog.roadmap.exception.QuizNotFoundException; +import wooteco.prolog.common.exception.BadRequestException; @NoArgsConstructor(access = AccessLevel.PROTECTED) @Entity @@ -39,7 +41,7 @@ public Quiz(final Keyword keyword, final String question) { public void update(String question) { if (question.isEmpty()) { - throw new QuizNotFoundException(); + throw new BadRequestException(ROADMAP_QUIZ_NOT_FOUND_EXCEPTION); } this.question = question; } diff --git a/backend/src/main/java/wooteco/prolog/roadmap/exception/CurriculumInvalidException.java b/backend/src/main/java/wooteco/prolog/roadmap/exception/CurriculumInvalidException.java deleted file mode 100644 index a9496fa1a..000000000 --- a/backend/src/main/java/wooteco/prolog/roadmap/exception/CurriculumInvalidException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.roadmap.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class CurriculumInvalidException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/roadmap/exception/CurriculumNotFoundException.java b/backend/src/main/java/wooteco/prolog/roadmap/exception/CurriculumNotFoundException.java deleted file mode 100644 index 068fd7769..000000000 --- a/backend/src/main/java/wooteco/prolog/roadmap/exception/CurriculumNotFoundException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.roadmap.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class CurriculumNotFoundException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/roadmap/exception/KeywordAndKeywordParentSameException.java b/backend/src/main/java/wooteco/prolog/roadmap/exception/KeywordAndKeywordParentSameException.java deleted file mode 100644 index 96f7a761d..000000000 --- a/backend/src/main/java/wooteco/prolog/roadmap/exception/KeywordAndKeywordParentSameException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.roadmap.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class KeywordAndKeywordParentSameException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/roadmap/exception/KeywordNotFoundException.java b/backend/src/main/java/wooteco/prolog/roadmap/exception/KeywordNotFoundException.java deleted file mode 100644 index 597eca4d2..000000000 --- a/backend/src/main/java/wooteco/prolog/roadmap/exception/KeywordNotFoundException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.roadmap.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class KeywordNotFoundException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/roadmap/exception/KeywordOrderException.java b/backend/src/main/java/wooteco/prolog/roadmap/exception/KeywordOrderException.java deleted file mode 100644 index 9ce2d51fa..000000000 --- a/backend/src/main/java/wooteco/prolog/roadmap/exception/KeywordOrderException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.roadmap.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class KeywordOrderException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/roadmap/exception/KeywordSeqException.java b/backend/src/main/java/wooteco/prolog/roadmap/exception/KeywordSeqException.java deleted file mode 100644 index a9278d650..000000000 --- a/backend/src/main/java/wooteco/prolog/roadmap/exception/KeywordSeqException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.roadmap.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class KeywordSeqException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/roadmap/exception/QuizNotFoundException.java b/backend/src/main/java/wooteco/prolog/roadmap/exception/QuizNotFoundException.java deleted file mode 100644 index 44ce210bd..000000000 --- a/backend/src/main/java/wooteco/prolog/roadmap/exception/QuizNotFoundException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.roadmap.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class QuizNotFoundException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/roadmap/exception/QuizQuestionException.java b/backend/src/main/java/wooteco/prolog/roadmap/exception/QuizQuestionException.java deleted file mode 100644 index 6f4974eaf..000000000 --- a/backend/src/main/java/wooteco/prolog/roadmap/exception/QuizQuestionException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.roadmap.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class QuizQuestionException extends BadRequestException { - -} 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 672e92c5d..45a576ca2 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/ui/KeywordController.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/ui/KeywordController.java @@ -30,7 +30,8 @@ public KeywordController(final KeywordService keywordService) { public ResponseEntity createKeyword(@PathVariable Long sessionId, @RequestBody KeywordCreateRequest createRequest) { Long keywordId = keywordService.createKeyword(sessionId, createRequest); - return ResponseEntity.created(URI.create("/sessions/" + sessionId + "/keywords/" + keywordId)).build(); + return ResponseEntity.created( + URI.create("/sessions/" + sessionId + "/keywords/" + keywordId)).build(); } @GetMapping("/{keywordId}") @@ -56,11 +57,12 @@ public ResponseEntity deleteKeyword(@PathVariable Long sessionId, } @GetMapping - public ResponseEntity findSessionIncludeRootKeywords(@PathVariable Long sessionId) { + public ResponseEntity findSessionIncludeRootKeywords( + @PathVariable Long sessionId) { KeywordsResponse response = keywordService.findSessionIncludeRootKeywords(sessionId); return ResponseEntity.ok(response); } - + @GetMapping("/{keywordId}/children") public ResponseEntity find(@PathVariable Long sessionId, @PathVariable Long keywordId) { 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 3105c194c..f4d0fface 100644 --- a/backend/src/main/java/wooteco/prolog/roadmap/ui/NewSessionController.java +++ b/backend/src/main/java/wooteco/prolog/roadmap/ui/NewSessionController.java @@ -23,7 +23,8 @@ public class NewSessionController { private final NewSessionService sessionService; @PostMapping - public ResponseEntity createSession(@PathVariable Long curriculumId, @RequestBody SessionRequest request) { + public ResponseEntity createSession(@PathVariable Long curriculumId, + @RequestBody SessionRequest request) { Long sessionId = sessionService.createSession(curriculumId, request); return ResponseEntity.created(URI.create("/sessions/" + sessionId)).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 c338a7679..486a1e86f 100644 --- a/backend/src/main/java/wooteco/prolog/session/application/MissionService.java +++ b/backend/src/main/java/wooteco/prolog/session/application/MissionService.java @@ -1,6 +1,8 @@ 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; @@ -9,14 +11,13 @@ import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.login.ui.LoginMember; import wooteco.prolog.session.application.dto.MissionRequest; import wooteco.prolog.session.application.dto.MissionResponse; import wooteco.prolog.session.domain.Mission; import wooteco.prolog.session.domain.Session; import wooteco.prolog.session.domain.repository.MissionRepository; -import wooteco.prolog.studylog.exception.DuplicateMissionException; -import wooteco.prolog.studylog.exception.MissionNotFoundException; @Service @AllArgsConstructor @@ -31,12 +32,13 @@ public MissionResponse create(MissionRequest missionRequest) { validateName(missionRequest.getName()); Session session = sessionService.findById(missionRequest.getSessionId()); - return MissionResponse.of(missionRepository.save(new Mission(missionRequest.getName(), session))); + return MissionResponse.of( + missionRepository.save(new Mission(missionRequest.getName(), session))); } private void validateName(String name) { if (missionRepository.findByName(name).isPresent()) { - throw new DuplicateMissionException(); + throw new BadRequestException(DUPLICATE_MISSION); } } @@ -46,7 +48,7 @@ public List findAll() { public Mission findById(Long id) { return missionRepository.findById(id) - .orElseThrow(MissionNotFoundException::new); + .orElseThrow(() -> new BadRequestException(MISSION_NOT_FOUND)); } public Optional findMissionById(Long id) { 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 8b99bae80..b7635b1b3 100644 --- a/backend/src/main/java/wooteco/prolog/session/application/SessionMemberService.java +++ b/backend/src/main/java/wooteco/prolog/session/application/SessionMemberService.java @@ -1,21 +1,21 @@ package wooteco.prolog.session.application; import static java.util.stream.Collectors.toList; +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; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.member.application.GroupMemberService; import wooteco.prolog.member.application.MemberService; import wooteco.prolog.member.application.dto.MemberResponse; import wooteco.prolog.member.domain.Member; import wooteco.prolog.session.application.dto.SessionGroupMemberRequest; -import wooteco.prolog.session.application.dto.SessionMemberRequest; import wooteco.prolog.session.domain.SessionMember; import wooteco.prolog.session.domain.repository.SessionMemberRepository; import wooteco.prolog.session.domain.repository.SessionRepository; -import wooteco.prolog.session.exception.SessionNotFoundException; @Service @AllArgsConstructor @@ -30,17 +30,20 @@ public class SessionMemberService { @Transactional public void registerMember(Long sessionId, Long memberId) { if (!sessionRepository.existsById(sessionId)) { - throw new SessionNotFoundException(); + throw new BadRequestException(ROADMAP_SESSION_NOT_FOUND_EXCEPTION); } final Member member = memberService.findById(memberId); sessionMemberRepository.save(new SessionMember(sessionId, member)); } @Transactional - public void registerMembersByGroupId(Long sessionId, SessionGroupMemberRequest sessionGroupMemberRequest) { - List alreadySessionMembers = sessionMemberRepository.findAllBySessionId(sessionId); + public void registerMembersByGroupId(Long sessionId, + SessionGroupMemberRequest sessionGroupMemberRequest) { + List alreadySessionMembers = sessionMemberRepository.findAllBySessionId( + sessionId); - List members = groupMemberService.findGroupMemberByGroupId(sessionGroupMemberRequest.getGroupId()).stream() + List members = groupMemberService.findGroupMemberByGroupId( + sessionGroupMemberRequest.getGroupId()).stream() .map(it -> it.getMember()) .collect(toList()); @@ -78,6 +81,6 @@ public void deleteRegistedSession(Long sessionId, Long memberId) { private SessionMember findSessionMemberBySessionIdAndMemberId(Long sessionId, Member member) { return sessionMemberRepository.findBySessionIdAndMember(sessionId, member) - .orElseThrow(SessionNotFoundException::new); + .orElseThrow(() -> new BadRequestException(ROADMAP_SESSION_NOT_FOUND_EXCEPTION)); } } 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 03396711d..ae28a2028 100644 --- a/backend/src/main/java/wooteco/prolog/session/application/SessionService.java +++ b/backend/src/main/java/wooteco/prolog/session/application/SessionService.java @@ -1,6 +1,8 @@ package wooteco.prolog.session.application; import static java.util.stream.Collectors.toList; +import static wooteco.prolog.common.exception.BadRequestCode.DUPLICATE_SESSION_EXCEPTION; +import static wooteco.prolog.common.exception.BadRequestCode.SESSION_NOT_FOUND_EXCEPTION; import java.util.Collection; import java.util.List; @@ -9,14 +11,13 @@ import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.login.ui.LoginMember; import wooteco.prolog.session.application.dto.SessionRequest; import wooteco.prolog.session.application.dto.SessionResponse; import wooteco.prolog.session.domain.Session; import wooteco.prolog.session.domain.SessionMember; import wooteco.prolog.session.domain.repository.SessionRepository; -import wooteco.prolog.session.exception.DuplicateSessionException; -import wooteco.prolog.session.exception.SessionNotFoundException; @Service @AllArgsConstructor @@ -36,13 +37,13 @@ public SessionResponse create(SessionRequest sessionRequest) { private void validateName(String name) { if (sessionRepository.findByName(name).isPresent()) { - throw new DuplicateSessionException(); + throw new BadRequestException(DUPLICATE_SESSION_EXCEPTION); } } public Session findById(Long id) { return sessionRepository.findById(id) - .orElseThrow(SessionNotFoundException::new); + .orElseThrow(() -> new BadRequestException(SESSION_NOT_FOUND_EXCEPTION)); } public Optional findSessionById(Long id) { 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 66bd26c56..9286f1ae9 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 @@ -20,7 +20,8 @@ public static MissionResponse of(Mission mission) { if (mission == null) { return null; } - return new MissionResponse(mission.getId(), mission.getName(), SessionResponse.of(mission.getSession())); + return new MissionResponse(mission.getId(), mission.getName(), + SessionResponse.of(mission.getSession())); } public static List listOf(List missions) { 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 2bc17ce9d..3944856e0 100644 --- a/backend/src/main/java/wooteco/prolog/session/domain/Mission.java +++ b/backend/src/main/java/wooteco/prolog/session/domain/Mission.java @@ -1,5 +1,7 @@ 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; @@ -11,7 +13,7 @@ import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; -import wooteco.prolog.studylog.exception.TooLongMissionNameException; +import wooteco.prolog.common.exception.BadRequestException; @Entity @NoArgsConstructor(access = AccessLevel.PROTECTED) @@ -46,7 +48,7 @@ public Mission(Long id, String name, Session session) { private void validateMaxLength(String name) { if (name.length() > MAX_LENGTH) { - throw new TooLongMissionNameException(); + throw new BadRequestException(TOO_LONG_MISSION_NAME); } } } 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 cdf2cf586..5b16772ff 100644 --- a/backend/src/main/java/wooteco/prolog/session/domain/Session.java +++ b/backend/src/main/java/wooteco/prolog/session/domain/Session.java @@ -9,8 +9,9 @@ import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; +import wooteco.prolog.common.exception.BadRequestCode; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.studylog.domain.Curriculum; -import wooteco.prolog.studylog.exception.TooLongLevelNameException; @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @@ -51,7 +52,7 @@ public void update(final String name) { private void validateMaxLength(String name) { if (name.length() > MAX_LENGTH) { - throw new TooLongLevelNameException(); + throw new BadRequestException(BadRequestCode.TOO_LONG_LEVEL_NAME_EXCEPTION); } } diff --git a/backend/src/main/java/wooteco/prolog/session/exception/DuplicateSessionException.java b/backend/src/main/java/wooteco/prolog/session/exception/DuplicateSessionException.java deleted file mode 100644 index d1bc5306d..000000000 --- a/backend/src/main/java/wooteco/prolog/session/exception/DuplicateSessionException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.session.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class DuplicateSessionException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/session/exception/SessionNotFoundException.java b/backend/src/main/java/wooteco/prolog/session/exception/SessionNotFoundException.java deleted file mode 100644 index 8e9bebd45..000000000 --- a/backend/src/main/java/wooteco/prolog/session/exception/SessionNotFoundException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.session.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class SessionNotFoundException extends BadRequestException { - -} 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 66a581160..c00bd6547 100644 --- a/backend/src/main/java/wooteco/prolog/session/ui/MissionController.java +++ b/backend/src/main/java/wooteco/prolog/session/ui/MissionController.java @@ -32,7 +32,8 @@ public ResponseEntity> showMissions() { @MemberOnly @GetMapping("/mine") - public ResponseEntity> findMyMissions(@AuthMemberPrincipal LoginMember loginMember) { + public ResponseEntity> findMyMissions( + @AuthMemberPrincipal LoginMember loginMember) { List responses = missionService.findMyMissions(loginMember); return ResponseEntity.ok(responses); } 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 1780ade6a..2e1fbb6db 100644 --- a/backend/src/main/java/wooteco/prolog/session/ui/SessionController.java +++ b/backend/src/main/java/wooteco/prolog/session/ui/SessionController.java @@ -26,7 +26,8 @@ public class SessionController { @PostMapping public ResponseEntity create(@RequestBody SessionRequest sessionRequest) { SessionResponse sessionResponse = sessionService.create(sessionRequest); - return ResponseEntity.created(URI.create("/sessions/" + sessionResponse.getId())).body(sessionResponse); + return ResponseEntity.created(URI.create("/sessions/" + sessionResponse.getId())) + .body(sessionResponse); } @GetMapping @@ -37,7 +38,8 @@ public ResponseEntity> show() { @MemberOnly @GetMapping("/mine") - public ResponseEntity> findMySessions(@AuthMemberPrincipal LoginMember member) { + public ResponseEntity> findMySessions( + @AuthMemberPrincipal LoginMember member) { List responses = sessionService.findMySessions(member); return ResponseEntity.ok(responses); } 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 31f4e4d41..24b66ce11 100644 --- a/backend/src/main/java/wooteco/prolog/session/ui/SessionMemberController.java +++ b/backend/src/main/java/wooteco/prolog/session/ui/SessionMemberController.java @@ -31,7 +31,8 @@ public class SessionMemberController { // } @PostMapping("/me") - public ResponseEntity registerMe(@PathVariable Long sessionId, @AuthMemberPrincipal LoginMember member){ + public ResponseEntity registerMe(@PathVariable Long sessionId, + @AuthMemberPrincipal LoginMember member) { sessionMemberService.registerMember(sessionId, member.getId()); return ResponseEntity.ok().build(); } @@ -40,14 +41,15 @@ public ResponseEntity registerMe(@PathVariable Long sessionId, @AuthMember public ResponseEntity deleteRegisteredSession( @PathVariable Long sessionId, @AuthMemberPrincipal LoginMember member - ){ + ) { sessionMemberService.deleteRegistedSession(sessionId, member.getId()); return ResponseEntity.ok().build(); } // admin only @PostMapping - public ResponseEntity registerByGroupId(@PathVariable Long sessionId, @RequestBody SessionGroupMemberRequest sessionGroupMemberRequest) { + public ResponseEntity registerByGroupId(@PathVariable Long sessionId, + @RequestBody SessionGroupMemberRequest sessionGroupMemberRequest) { sessionMemberService.registerMembersByGroupId(sessionId, sessionGroupMemberRequest); return ResponseEntity.ok().build(); } 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 b4f056bd3..0a54c9f53 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/AbstractStudylogDocumentService.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/AbstractStudylogDocumentService.java @@ -1,15 +1,16 @@ package wooteco.prolog.studylog.application; -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 wooteco.prolog.studylog.exception.StudylogDocumentNotFoundException; +import static wooteco.prolog.common.exception.BadRequestCode.STUDYLOG_DOCUMENT_NOT_FOUND; 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; public abstract class AbstractStudylogDocumentService implements DocumentService { @@ -32,7 +33,7 @@ public void save(StudylogDocument studylogDocument) { @Override public StudylogDocument findById(Long id) { return studylogDocumentRepository.findById(id) - .orElseThrow(StudylogDocumentNotFoundException::new); + .orElseThrow(() -> new BadRequestException(STUDYLOG_DOCUMENT_NOT_FOUND)); } @Override @@ -47,9 +48,9 @@ public void sync() { List studylogs = studylogRepository.findAll(); studylogDocumentRepository.saveAll( - studylogs.stream() - .map(Studylog::toStudylogDocument) - .collect(Collectors.toList()) + studylogs.stream() + .map(Studylog::toStudylogDocument) + .collect(Collectors.toList()) ); } 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 b23d4c4cd..b0a818ab7 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/CommentService.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/CommentService.java @@ -1,13 +1,17 @@ package wooteco.prolog.studylog.application; +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.List; import java.util.stream.Collectors; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.member.domain.Member; import wooteco.prolog.member.domain.repository.MemberRepository; -import wooteco.prolog.member.exception.MemberNotFoundException; import wooteco.prolog.studylog.application.dto.CommentResponse; import wooteco.prolog.studylog.application.dto.CommentSaveRequest; import wooteco.prolog.studylog.application.dto.CommentUpdateRequest; @@ -16,8 +20,6 @@ import wooteco.prolog.studylog.domain.Studylog; import wooteco.prolog.studylog.domain.repository.CommentRepository; import wooteco.prolog.studylog.domain.repository.StudylogRepository; -import wooteco.prolog.studylog.exception.CommentNotFoundException; -import wooteco.prolog.studylog.exception.StudylogNotFoundException; @Transactional @AllArgsConstructor @@ -30,9 +32,9 @@ public class CommentService { public Long insertComment(CommentSaveRequest request) { Member findMember = memberRepository.findById(request.getMemberId()) - .orElseThrow(MemberNotFoundException::new); + .orElseThrow(() -> new BadRequestException(MEMBER_NOT_FOUND)); Studylog findStudylog = studylogRepository.findById(request.getStudylogId()) - .orElseThrow(StudylogNotFoundException::new); + .orElseThrow(() -> new BadRequestException(STUDYLOG_NOT_FOUND)); Comment comment = request.toEntity(findMember, findStudylog); @@ -42,7 +44,7 @@ public Long insertComment(CommentSaveRequest request) { @Transactional(readOnly = true) public CommentsResponse findComments(Long studylogId) { Studylog findStudylog = studylogRepository.findById(studylogId) - .orElseThrow(StudylogNotFoundException::new); + .orElseThrow(() -> new BadRequestException(STUDYLOG_NOT_FOUND)); List commentResponses = commentRepository.findCommentByStudylog( findStudylog) @@ -58,7 +60,7 @@ public Long updateComment(CommentUpdateRequest request) { validateExistsStudylog(request.getStudylogId()); Comment comment = commentRepository.findById(request.getCommentId()) - .orElseThrow(CommentNotFoundException::new); + .orElseThrow(() -> new BadRequestException(COMMENT_NOT_FOUND)); comment.updateContent(request.getContent()); return comment.getId(); @@ -69,20 +71,20 @@ public void deleteComment(Long memberId, Long studylogId, Long commentId) { validateExistsStudylog(studylogId); Comment comment = commentRepository.findById(commentId) - .orElseThrow(CommentNotFoundException::new); + .orElseThrow(() -> new BadRequestException(COMMENT_NOT_FOUND)); comment.delete(); } private void validateExistsMember(Long memberId) { if (!memberRepository.existsById(memberId)) { - throw new MemberNotFoundException(); + throw new BadRequestException(MEMBER_NOT_FOUND); } } private void validateExistsStudylog(Long studylogId) { if (!studylogRepository.existsById(studylogId)) { - throw new StudylogNotFoundException(); + throw new BadRequestException(STUDYLOG_NOT_FOUND); } } } 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 edd14caa9..3a49b9912 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/FakeStudylogDocumentService.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/FakeStudylogDocumentService.java @@ -7,7 +7,6 @@ import java.util.stream.Collectors; import org.springframework.context.annotation.Profile; import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.domain.Specification; import org.springframework.stereotype.Service; @@ -29,11 +28,14 @@ public FakeStudylogDocumentService( } @Override - public StudylogDocumentResponse findBySearchKeyword(String keyword, List tags, List missions, + public StudylogDocumentResponse findBySearchKeyword(String keyword, List tags, + List missions, List sessions, List usernames, - LocalDate start, LocalDate end, Pageable pageable) { + LocalDate start, LocalDate end, + Pageable pageable) { final Page studylogs = studylogRepository.findAll( - makeSpecifications(keyword.toLowerCase(), tags, missions, sessions, usernames, start, end), pageable); + makeSpecifications(keyword.toLowerCase(), tags, missions, sessions, usernames, start, + end), pageable); final List studylogIds = studylogs.stream() .map(Studylog::getId) @@ -45,7 +47,8 @@ public StudylogDocumentResponse findBySearchKeyword(String keyword, List t studylogs.getNumber()); } - private Specification makeSpecifications(String keyword, List tags, List missions, + private Specification makeSpecifications(String keyword, List tags, + List missions, List sessions, List usernames, LocalDate start, LocalDate end ) { 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 0e96623d1..6736f1d8f 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/FilterService.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/FilterService.java @@ -23,10 +23,13 @@ public class FilterService { private final MemberService memberService; public FilterResponse showAll(LoginMember loginMember) { - List sessionResponses = sessionService.findAllWithMySessionFirst(loginMember); // my session으로 대체 - List missionResponses = missionService.findAllWithMyMissionFirst(loginMember); + List sessionResponses = sessionService.findAllWithMySessionFirst( + loginMember); // my session으로 대체 + List missionResponses = missionService.findAllWithMyMissionFirst( + loginMember); List tagResponses = tagService.findTagsIncludedInStudylogs(); List memberResponses = memberService.findAllOrderByNickNameAsc(); - return new FilterResponse(sessionResponses, missionResponses, tagResponses, memberResponses); + return new FilterResponse(sessionResponses, missionResponses, tagResponses, + memberResponses); } } 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 ac01a7b67..6ba9680a5 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/PopularStudylogService.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/PopularStudylogService.java @@ -48,7 +48,8 @@ public void updatePopularStudylogs(Pageable pageable) { List groupMembers = groupMemberRepository.findAll(); Map> memberGroupsBygroupType = memberGroupRepository.findAll() - .stream().collect(Collectors.groupingBy(MemberGroup::getGroupType)); + .stream() + .collect(Collectors.groupingBy(MemberGroup::getGroupType)); final List recentStudylogs = findRecentStudylogs(LocalDateTime.now(), pageable.getPageSize()); @@ -91,9 +92,12 @@ private List findRecentStudylogs(final LocalDateTime dateTime, private List filterStudylogsByMemberGroups(final List studylogs, final MemberGroups memberGroups, final List groupMembers) { - return studylogs.stream().filter( - studylog -> checkMemberAssignedInMemberGroups(memberGroups, studylog.getMember(), - groupMembers)).collect(toList()); + + return studylogs.stream() + .filter( + studylog -> checkMemberAssignedInMemberGroups(memberGroups, studylog.getMember(), + groupMembers)) + .collect(toList()); } private boolean checkMemberAssignedInMemberGroups(MemberGroups memberGroups, Member member, 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 1994ad673..69370253c 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/StudylogDocumentService.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/StudylogDocumentService.java @@ -26,43 +26,45 @@ public class StudylogDocumentService extends AbstractStudylogDocumentService { private final ElasticsearchRestTemplate elasticsearchRestTemplate; public StudylogDocumentService( - StudylogDocumentRepository studylogDocumentRepository, - StudylogRepository studylogRepository, - ElasticsearchRestTemplate elasticsearchRestTemplate) { + StudylogDocumentRepository studylogDocumentRepository, + StudylogRepository studylogRepository, + ElasticsearchRestTemplate elasticsearchRestTemplate) { super(studylogDocumentRepository, studylogRepository); this.elasticsearchRestTemplate = elasticsearchRestTemplate; } @Override public StudylogDocumentResponse findBySearchKeyword( - String keyword, - List tags, - List missions, - List levels, - List usernames, - LocalDate start, - LocalDate end, - Pageable pageable + String keyword, + List tags, + List missions, + List levels, + List usernames, + LocalDate start, + LocalDate end, + Pageable pageable ) { - final Query query = StudylogDocumentQueryBuilder.makeQuery(preprocess(keyword), tags, missions, levels, - usernames, start, end, 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")); + = elasticsearchRestTemplate.search(query, StudylogDocument.class, + IndexCoordinates.of("studylog-document")); // 조회된 SearchHits를 페이징할 수 있는 SearchPage로 변경한다. final SearchPage searchPages - = SearchHitSupport.searchPageFor(searchHits, query.getPageable()); + = SearchHitSupport.searchPageFor(searchHits, query.getPageable()); final List studylogIds = searchPages.stream() - .map(searchPage -> searchPage.getContent().getId()) - .collect(toList()); + .map(searchPage -> searchPage.getContent().getId()) + .collect(toList()); return StudylogDocumentResponse.of(studylogIds, - searchPages.getTotalElements(), - searchPages.getTotalPages(), - searchPages.getNumber()); + searchPages.getTotalElements(), + searchPages.getTotalPages(), + searchPages.getNumber()); } } 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 00f4df1a3..ab715c4b3 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/StudylogLikeService.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/StudylogLikeService.java @@ -1,15 +1,17 @@ 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; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.member.application.MemberService; import wooteco.prolog.member.domain.Member; import wooteco.prolog.studylog.application.dto.StudylogLikeResponse; import wooteco.prolog.studylog.domain.Studylog; import wooteco.prolog.studylog.domain.repository.StudylogRepository; -import wooteco.prolog.studylog.exception.InvalidLikeRequestException; -import wooteco.prolog.studylog.exception.StudylogNotFoundException; @Service @AllArgsConstructor @@ -24,7 +26,7 @@ public StudylogLikeResponse likeStudylog(Long memberId, Long studylogId, boolean validIfMember(isMember); Studylog studylog = studylogRepository.findById(studylogId) - .orElseThrow(StudylogNotFoundException::new); + .orElseThrow(() -> new BadRequestException(STUDYLOG_NOT_FOUND)); Member member = memberService.findById(memberId); studylog.like(member.getId()); @@ -37,7 +39,7 @@ public StudylogLikeResponse unlikeStudylog(Long memberId, Long studylogId, boole validIfMember(isMember); Studylog studylog = studylogRepository.findById(studylogId) - .orElseThrow(StudylogNotFoundException::new); + .orElseThrow(() -> new BadRequestException(STUDYLOG_NOT_FOUND)); Member member = memberService.findById(memberId); studylog.unlike(member.getId()); @@ -47,7 +49,7 @@ public StudylogLikeResponse unlikeStudylog(Long memberId, Long studylogId, boole private void validIfMember(boolean isMember) { if (!isMember) { - throw new InvalidLikeRequestException(); + throw new BadRequestException(INVALID_LIKE_REQUEST_EXCEPTION); } } } 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 a87385e6e..27df5a23e 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/StudylogScrapService.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/StudylogScrapService.java @@ -1,22 +1,24 @@ 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; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.member.application.dto.MemberScrapResponse; import wooteco.prolog.member.domain.Member; import wooteco.prolog.member.domain.repository.MemberRepository; -import wooteco.prolog.member.exception.MemberNotFoundException; -import wooteco.prolog.studylog.exception.StudylogScrapNotExistException; -import wooteco.prolog.studylog.domain.StudylogScrap; -import wooteco.prolog.studylog.domain.repository.StudylogScrapRepository; -import wooteco.prolog.studylog.exception.StudylogScrapAlreadyRegisteredException; import wooteco.prolog.studylog.application.dto.StudylogsResponse; import wooteco.prolog.studylog.domain.Studylog; +import wooteco.prolog.studylog.domain.StudylogScrap; import wooteco.prolog.studylog.domain.repository.StudylogRepository; -import wooteco.prolog.studylog.exception.StudylogNotFoundException; +import wooteco.prolog.studylog.domain.repository.StudylogScrapRepository; @RequiredArgsConstructor @Service @@ -31,14 +33,14 @@ public class StudylogScrapService { public MemberScrapResponse registerScrap(Long memberId, Long studylogId) { if (studylogScrapRepository .countByMemberIdAndScrapStudylogId(memberId, studylogId) > 0) { - throw new StudylogScrapAlreadyRegisteredException(); + throw new BadRequestException(STUDYLOG_SCRAP_ALREADY_REGISTERED_EXCEPTION); } Studylog studylog = studylogRepository.findById(studylogId) - .orElseThrow(StudylogNotFoundException::new); + .orElseThrow(() -> new BadRequestException(STUDYLOG_NOT_FOUND)); Member member = memberRepository.findById(memberId) - .orElseThrow(MemberNotFoundException::new); + .orElseThrow(() -> new BadRequestException(MEMBER_NOT_ALLOWED)); StudylogScrap studylogScrap = new StudylogScrap(member, studylog); studylogScrapRepository.save(studylogScrap); @@ -49,8 +51,8 @@ public MemberScrapResponse registerScrap(Long memberId, Long studylogId) { @Transactional public void unregisterScrap(Long memberId, Long studylogId) { StudylogScrap scrap = studylogScrapRepository - .findByMemberIdAndStudylogId(memberId, studylogId).orElseThrow( - StudylogScrapNotExistException::new); + .findByMemberIdAndStudylogId(memberId, studylogId) + .orElseThrow(() -> new BadRequestException(STUDYLOG_SCRAP_NOT_EXIST_EXCEPTION)); studylogScrapRepository.delete(scrap); } 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 56fd5e942..edf5a0cc3 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/StudylogService.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/StudylogService.java @@ -4,6 +4,10 @@ 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.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; @@ -20,6 +24,7 @@ import org.springframework.data.jpa.domain.Specification; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.login.ui.LoginMember; import wooteco.prolog.member.application.MemberService; import wooteco.prolog.member.application.MemberTagService; @@ -52,17 +57,13 @@ import wooteco.prolog.studylog.domain.repository.StudylogTempRepository; import wooteco.prolog.studylog.domain.repository.dto.CommentCount; import wooteco.prolog.studylog.event.StudylogDeleteEvent; -import wooteco.prolog.studylog.exception.StudylogArgumentException; -import wooteco.prolog.studylog.exception.StudylogNotFoundException; -import wooteco.prolog.studylog.exception.StudylogReadNotExistException; -import wooteco.prolog.studylog.exception.StudylogScrapNotExistException; @Service @AllArgsConstructor @Transactional(readOnly = true) public class StudylogService { - private static Logger logger = LoggerFactory.getLogger(StudylogService.class); + private static final Logger logger = LoggerFactory.getLogger(StudylogService.class); private final MemberTagService memberTagService; private final DocumentService studylogDocumentService; @@ -81,7 +82,7 @@ public class StudylogService { public List insertStudylogs(Long memberId, List studylogRequests) { if (studylogRequests.isEmpty()) { - throw new StudylogArgumentException(); + throw new BadRequestException(STUDYLOG_ARGUMENT); } return studylogRequests.stream() @@ -344,12 +345,13 @@ public StudylogResponse findByIdAndReturnStudylogResponse(Long id) { private void insertStudylogRead(Long id, Long memberId) { Member readMember = memberService.findById(memberId); Studylog readStudylog = studylogRepository.findById(id) - .orElseThrow(StudylogNotFoundException::new); + .orElseThrow(() -> new BadRequestException(STUDYLOG_NOT_FOUND)); studylogReadRepository.save(new StudylogRead(readMember, readStudylog)); } public Studylog findStudylogById(Long id) { - return studylogRepository.findById(id).orElseThrow(StudylogNotFoundException::new); + return studylogRepository.findById(id) + .orElseThrow(() -> new BadRequestException(STUDYLOG_NOT_FOUND)); } private void increaseViewCount(LoginMember loginMember, Studylog studylog) { @@ -365,7 +367,8 @@ private void increaseViewCount(LoginMember loginMember, Studylog studylog) { @Transactional public void updateStudylog(Long memberId, Long studylogId, StudylogRequest studylogRequest) { Studylog studylog = studylogRepository.findById(studylogId) - .orElseThrow(StudylogNotFoundException::new); + .orElseThrow(() -> new BadRequestException(STUDYLOG_NOT_FOUND)); + studylog.validateBelongTo(memberId); Session session = sessionService.findSessionById(studylogRequest.getSessionId()) @@ -388,7 +391,7 @@ public void updateStudylog(Long memberId, Long studylogId, StudylogRequest study public void updateStudylogSession(Long memberId, Long studylogId, StudylogSessionRequest studylogSessionRequest) { Studylog studylog = studylogRepository.findById(studylogId) - .orElseThrow(StudylogNotFoundException::new); + .orElseThrow(() -> new BadRequestException(STUDYLOG_NOT_FOUND)); studylog.validateBelongTo(memberId); Session session = sessionService.findSessionById(studylogSessionRequest.getSessionId()) @@ -401,7 +404,7 @@ public void updateStudylogSession(Long memberId, Long studylogId, public void updateStudylogMission(Long memberId, Long studylogId, StudylogMissionRequest studylogMissionRequest) { Studylog studylog = studylogRepository.findById(studylogId) - .orElseThrow(StudylogNotFoundException::new); + .orElseThrow(() -> new BadRequestException(STUDYLOG_NOT_FOUND)); studylog.validateBelongTo(memberId); Mission mission = missionService.findMissionById(studylogMissionRequest.getMissionId()) @@ -414,7 +417,7 @@ public void updateStudylogMission(Long memberId, Long studylogId, public void deleteStudylog(Long memberId, Long studylogId) { final Member foundMember = memberService.findById(memberId); Studylog studylog = studylogRepository.findById(studylogId) - .orElseThrow(StudylogNotFoundException::new); + .orElseThrow(() -> new BadRequestException(STUDYLOG_NOT_FOUND)); studylog.validateBelongTo(memberId); final Tags tags = tagService.findByStudylogsAndMember(studylog, foundMember); @@ -430,14 +433,14 @@ private void checkScrapedOrRead(Long memberId, Long studylogId) { if (studylogScrapRepository.existsByMemberIdAndStudylogId(memberId, studylogId)) { StudylogScrap studylogScrap = studylogScrapRepository.findByMemberIdAndStudylogId( memberId, studylogId) - .orElseThrow(StudylogScrapNotExistException::new); + .orElseThrow(() -> new BadRequestException(STUDYLOG_SCRAP_NOT_EXIST_EXCEPTION)); studylogScrapRepository.delete(studylogScrap); } if (studylogReadRepository.existsByMemberIdAndStudylogId(memberId, studylogId)) { StudylogRead studylogRead = studylogReadRepository.findByMemberIdAndStudylogId(memberId, studylogId) - .orElseThrow(StudylogReadNotExistException::new); + .orElseThrow(() -> new BadRequestException(STUDYLOG_DOCUMENT_NOT_FOUND)); studylogReadRepository.delete(studylogRead); } } 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 aec9202f5..5c653fab1 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/application/ViewedStudyLogCookieGenerator.java +++ b/backend/src/main/java/wooteco/prolog/studylog/application/ViewedStudyLogCookieGenerator.java @@ -1,37 +1,39 @@ package wooteco.prolog.studylog.application; +import java.time.Duration; +import java.time.LocalTime; +import javax.servlet.http.HttpServletResponse; import org.springframework.http.HttpHeaders; import org.springframework.http.ResponseCookie; import org.springframework.stereotype.Component; -import javax.servlet.http.HttpServletResponse; -import java.time.Duration; -import java.time.LocalTime; - @Component public class ViewedStudyLogCookieGenerator { + private static final String VIEWED_STUDY_LOG_COOKIE_NAME = "viewed"; public ResponseCookie generateCookie(String name, String value) { Duration duration = Duration.between(LocalTime.now(), LocalTime.MAX); return ResponseCookie.from(name, value) - .httpOnly(true) - .sameSite("None") - .secure(true) - .maxAge(duration.getSeconds()) - .build(); + .httpOnly(true) + .sameSite("None") + .secure(true) + .maxAge(duration.getSeconds()) + .build(); } public boolean isViewed(String studyLogIds, String studyLogId) { return studyLogIds.contains("/" + studyLogId + "/"); } - public void setViewedStudyLogCookie(String studyLogIds, String studyLogId, HttpServletResponse response) { + public void setViewedStudyLogCookie(String studyLogIds, String studyLogId, + HttpServletResponse response) { if (isViewed(studyLogIds, studyLogId)) { return; } String cookieValue = studyLogIds.concat(studyLogId + "/"); - response.setHeader(HttpHeaders.SET_COOKIE, generateCookie(VIEWED_STUDY_LOG_COOKIE_NAME, cookieValue).toString()); + response.setHeader(HttpHeaders.SET_COOKIE, + generateCookie(VIEWED_STUDY_LOG_COOKIE_NAME, cookieValue).toString()); } } 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 16cbd0829..3abd9f1ca 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 @@ -17,7 +17,8 @@ public class CalendarStudylogResponse { private LocalDateTime updatedAt; public static CalendarStudylogResponse of(Studylog studylog) { - return new CalendarStudylogResponse(studylog.getId(), studylog.getTitle(), studylog.getCreatedAt(), studylog + return new CalendarStudylogResponse(studylog.getId(), studylog.getTitle(), + studylog.getCreatedAt(), studylog .getUpdatedAt()); } } 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 b59f8205c..64bf00860 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 @@ -17,7 +17,8 @@ public class CommentResponse { @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Seoul") private LocalDateTime createAt; - public CommentResponse(Long id, CommentMemberResponse author, String content, LocalDateTime localDateTime) { + public CommentResponse(Long id, CommentMemberResponse author, String content, + LocalDateTime localDateTime) { this.id = id; this.author = author; this.content = content; 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 42c14d29b..bb1c90028 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 @@ -5,8 +5,8 @@ import lombok.Getter; import lombok.NoArgsConstructor; import wooteco.prolog.member.application.dto.MemberResponse; -import wooteco.prolog.session.application.dto.SessionResponse; import wooteco.prolog.session.application.dto.MissionResponse; +import wooteco.prolog.session.application.dto.SessionResponse; @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 f028f5a0c..0523f8875 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 @@ -15,7 +15,8 @@ public class StudylogDocumentResponse { private int totalPage; private int currPage; - public static StudylogDocumentResponse of(List studylogIds, long totalSize, int totalPage, int currPage) { + public static StudylogDocumentResponse of(List studylogIds, long totalSize, int totalPage, + int currPage) { return new StudylogDocumentResponse(studylogIds, totalSize, totalPage, currPage); } } 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 bef2f1bea..bbc3349ff 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,5 +1,9 @@ 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; @@ -11,11 +15,6 @@ 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 @@ -38,33 +37,35 @@ public class StudylogResponse { private long commentCount; public StudylogResponse( - Studylog studylog, - SessionResponse sessionResponse, - MissionResponse missionResponse, - List tagResponses, - boolean liked, long commentCount) { + Studylog studylog, + SessionResponse sessionResponse, + MissionResponse missionResponse, + List tagResponses, + boolean liked, long commentCount) { this( - studylog.getId(), - MemberResponse.of(studylog.getMember()), - studylog.getCreatedAt(), - studylog.getUpdatedAt(), - sessionResponse, - missionResponse, - studylog.getTitle(), - studylog.getContent(), - tagResponses, - false, - false, - studylog.getViewCount(), - liked, - studylog.getLikeCount(), - commentCount + studylog.getId(), + MemberResponse.of(studylog.getMember()), + studylog.getCreatedAt(), + studylog.getUpdatedAt(), + sessionResponse, + missionResponse, + studylog.getTitle(), + studylog.getContent(), + tagResponses, + false, + false, + studylog.getViewCount(), + liked, + studylog.getLikeCount(), + commentCount ); } - public StudylogResponse(final Long id, final MemberResponse author, final LocalDateTime createdAt, + public StudylogResponse(final Long id, final MemberResponse author, + final LocalDateTime createdAt, final LocalDateTime updatedAt, - final SessionResponse session, final MissionResponse mission, final String title, + final SessionResponse session, final MissionResponse mission, + final String title, final String content, final List tags, final boolean scrap, final boolean read, @@ -92,44 +93,45 @@ public static StudylogResponse of(Studylog studylog, boolean scrap, List tagResponses = toTagResponses(studylogTags); return new StudylogResponse( - studylog.getId(), - MemberResponse.of(studylog.getMember()), - studylog.getCreatedAt(), - studylog.getUpdatedAt(), - SessionResponse.of(studylog.getSession()), - MissionResponse.of(studylog.getMission()), - studylog.getTitle(), - studylog.getContent(), - tagResponses, - scrap, - read, - studylog.getViewCount(), - liked, - studylog.getLikeCount(), - commentCount + studylog.getId(), + MemberResponse.of(studylog.getMember()), + studylog.getCreatedAt(), + studylog.getUpdatedAt(), + SessionResponse.of(studylog.getSession()), + MissionResponse.of(studylog.getMission()), + studylog.getTitle(), + studylog.getContent(), + tagResponses, + scrap, + read, + studylog.getViewCount(), + liked, + studylog.getLikeCount(), + commentCount ); } - public static StudylogResponse of(Studylog studylog, boolean scrap, boolean read, boolean liked) { + public static StudylogResponse of(Studylog studylog, boolean scrap, boolean read, + boolean liked) { List studylogTags = studylog.getStudylogTags(); List tagResponses = toTagResponses(studylogTags); return new StudylogResponse( - studylog.getId(), - MemberResponse.of(studylog.getMember()), - studylog.getCreatedAt(), - studylog.getUpdatedAt(), - SessionResponse.of(studylog.getSession()), - MissionResponse.of(studylog.getMission()), - studylog.getTitle(), - studylog.getContent(), - tagResponses, - scrap, - read, - studylog.getViewCount(), - liked, - studylog.getLikeCount(), - 0 + studylog.getId(), + MemberResponse.of(studylog.getMember()), + studylog.getCreatedAt(), + studylog.getUpdatedAt(), + SessionResponse.of(studylog.getSession()), + MissionResponse.of(studylog.getMission()), + studylog.getTitle(), + studylog.getContent(), + tagResponses, + scrap, + read, + studylog.getViewCount(), + liked, + studylog.getLikeCount(), + 0 ); } @@ -138,7 +140,8 @@ public static StudylogResponse of(Studylog studylog) { return of(studylog, false, false, null); } - public static StudylogResponse of(Studylog studylog, boolean scrap, boolean read, Long memberId) { + public static StudylogResponse of(Studylog studylog, boolean scrap, boolean read, + Long memberId) { return StudylogResponse.of(studylog, scrap, read, studylog.likedByMember(memberId)); } @@ -146,38 +149,41 @@ public static StudylogResponse of(Studylog studylog, Long memberId, long comment return of(studylog, false, false, memberId, commentCount); } - public static StudylogResponse of(Studylog studylog, boolean scrap, boolean read, Long memberId, long commentCount) { - return StudylogResponse.of(studylog, scrap, read, studylog.likedByMember(memberId), commentCount); + public static StudylogResponse of(Studylog studylog, boolean scrap, boolean read, Long memberId, + long commentCount) { + return StudylogResponse.of(studylog, scrap, read, studylog.likedByMember(memberId), + commentCount); } private static List toTagResponses(List studylogTags) { return studylogTags.stream() - .map(StudylogTag::getTag) - .map(TagResponse::of) - .collect(toList()); + .map(StudylogTag::getTag) + .map(TagResponse::of) + .collect(toList()); } - public static StudylogResponse of(Studylog studylog, boolean scrap, boolean read, boolean liked, Session session, + public static StudylogResponse of(Studylog studylog, boolean scrap, boolean read, boolean liked, + Session session, Mission mission) { List studylogTags = studylog.getStudylogTags(); List tagResponses = toTagResponses(studylogTags); return new StudylogResponse( - studylog.getId(), - MemberResponse.of(studylog.getMember()), - studylog.getCreatedAt(), - studylog.getUpdatedAt(), - SessionResponse.of(session), - MissionResponse.of(mission), - studylog.getTitle(), - studylog.getContent(), - tagResponses, - scrap, - read, - studylog.getViewCount(), - liked, - studylog.getLikeCount(), - 0 + studylog.getId(), + MemberResponse.of(studylog.getMember()), + studylog.getCreatedAt(), + studylog.getUpdatedAt(), + SessionResponse.of(session), + MissionResponse.of(mission), + studylog.getTitle(), + studylog.getContent(), + tagResponses, + scrap, + read, + studylog.getViewCount(), + liked, + studylog.getLikeCount(), + 0 ); } 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 f505a2038..340751357 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 @@ -6,6 +6,7 @@ @Data public class StudylogSearchRequest { + private Long tagId; @DateTimeFormat(pattern = "yyyy-MM-dd") private LocalDate date; 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 4ec691c49..ae0ba39ec 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,5 +1,8 @@ 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; @@ -8,10 +11,6 @@ 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 { @@ -24,7 +23,8 @@ public class StudylogTempResponse { private MissionResponse mission; private List tags; - private StudylogTempResponse(MemberResponse author, String title, String content, SessionResponse session, + private StudylogTempResponse(MemberResponse author, String title, String content, + SessionResponse session, MissionResponse mission, List tags) { this.author = author; this.title = title; @@ -36,19 +36,19 @@ private StudylogTempResponse(MemberResponse author, String title, String content public static StudylogTempResponse from(StudylogTemp studylogTemp) { return new StudylogTempResponse( - MemberResponse.of(studylogTemp.getMember()), - studylogTemp.getTitle(), - studylogTemp.getContent(), - SessionResponse.of(studylogTemp.getSession()), - MissionResponse.of(studylogTemp.getMission()), - toTagResponses(studylogTemp.getStudylogTempTags())); + MemberResponse.of(studylogTemp.getMember()), + studylogTemp.getTitle(), + studylogTemp.getContent(), + SessionResponse.of(studylogTemp.getSession()), + MissionResponse.of(studylogTemp.getMission()), + toTagResponses(studylogTemp.getStudylogTempTags())); } //todo TagResponse의 정적팩토리메서드로 리팩터링 private static List toTagResponses(StudylogTempTags tags) { return tags.getValues().stream() - .map(tag -> TagResponse.of(tag.getTag())) - .collect(toList()); + .map(tag -> TagResponse.of(tag.getTag())) + .collect(toList()); } public static StudylogTempResponse toNull() { 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 2048590bd..8d4d4b5cb 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 @@ -32,17 +32,18 @@ public static StudylogsResponse of(Page page) { return of(page, null); } - public static StudylogsResponse of(Page page, Long memberId, Map commentCounts) { + public static StudylogsResponse of(Page page, Long memberId, + Map commentCounts) { Page responsePage = new PageImpl<>( - toResponses(page.getContent(), memberId, commentCounts), - page.getPageable(), - page.getTotalElements() + toResponses(page.getContent(), memberId, commentCounts), + page.getPageable(), + page.getTotalElements() ); return new StudylogsResponse(responsePage.getContent(), - responsePage.getTotalElements(), - responsePage.getTotalPages(), - responsePage.getNumber() + ONE_INDEXED_PARAMETER); + responsePage.getTotalElements(), + responsePage.getTotalPages(), + responsePage.getNumber() + ONE_INDEXED_PARAMETER); } public static StudylogsResponse of(Page page, Long memberId) { @@ -66,39 +67,47 @@ public static StudylogsResponse of( Long memberId, Map commentCounts ) { - final List studylogResponses = convertToStudylogResponse(studylogs, memberId, commentCounts); + final List studylogResponses = convertToStudylogResponse(studylogs, + memberId, commentCounts); return new StudylogsResponse(studylogResponses, totalSize, totalPage, currPage + ONE_INDEXED_PARAMETER); } - private static List convertToStudylogResponse(List studylogs, Long memberId, Map commentCounts) { + private static List convertToStudylogResponse(List studylogs, + Long memberId, + Map commentCounts) { return studylogs.stream() - .map(studylog -> StudylogResponse.of(studylog, memberId, commentCounts.get(studylog.getId()))) + .map(studylog -> StudylogResponse.of(studylog, memberId, + commentCounts.get(studylog.getId()))) .collect(toList()); } - private static List toResponses(List studylogs, Long memberId, Map commentCounts) { - return studylogs.stream().map(studylog -> toResponse(studylog, memberId, commentCounts.get(studylog.getId()))).collect(toList()); + private static List toResponses(List studylogs, Long memberId, + Map commentCounts) { + return studylogs.stream() + .map(studylog -> toResponse(studylog, memberId, commentCounts.get(studylog.getId()))) + .collect(toList()); } private static List toResponses(List studylogs, Long memberId) { return studylogs.stream().map(studylog -> toResponse(studylog, memberId)).collect(toList()); } - private static StudylogResponse toResponse(Studylog studylog, Long memberId, long commentCount) { + private static StudylogResponse toResponse(Studylog studylog, Long memberId, + long commentCount) { List studylogTags = studylog.getStudylogTags(); final List tags = studylogTags.stream() - .map(StudylogTag::getTag) - .collect(toList()); + .map(StudylogTag::getTag) + .collect(toList()); return new StudylogResponse( - studylog, - SessionResponse.of(studylog.getSession()), - MissionResponse.of(studylog.getMission()), - toResponse(tags), - studylog.likedByMember(memberId), commentCount + studylog, + SessionResponse.of(studylog.getSession()), + MissionResponse.of(studylog.getMission()), + toResponse(tags), + studylog.likedByMember(memberId), commentCount ); } @@ -119,7 +128,7 @@ private static StudylogResponse toResponse(Studylog studylog, Long memberId) { private static List toResponse(List tags) { return tags.stream() - .map(TagResponse::of) - .collect(Collectors.toList()); + .map(TagResponse::of) + .collect(Collectors.toList()); } } 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 26e8adeb2..c101e1843 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 @@ -20,9 +20,11 @@ public class StudylogsWithScrapCountResponse { private int totalPage; private int currPage; - public static StudylogsWithScrapCountResponse of(List studylogWithScrapedCountResponses, + public static StudylogsWithScrapCountResponse of( + List studylogWithScrapedCountResponses, Page page) { - return new StudylogsWithScrapCountResponse(studylogWithScrapedCountResponses, page.getTotalElements(), + return new StudylogsWithScrapCountResponse(studylogWithScrapedCountResponses, + page.getTotalElements(), page.getTotalPages(), page.getNumber() + ONE_INDEXED_PARAMETER); } 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 d40c999f2..8e6e5e2b0 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 @@ -17,7 +17,8 @@ import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.method.support.HandlerMethodArgumentResolver; import org.springframework.web.method.support.ModelAndViewContainer; -import wooteco.prolog.studylog.exception.SearchArgumentParseException; +import wooteco.prolog.common.exception.BadRequestCode; +import wooteco.prolog.common.exception.BadRequestException; @Component public class SearchArgumentResolver implements HandlerMethodArgumentResolver { @@ -44,7 +45,7 @@ public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer m makePageableDefault(webRequest) ); } catch (Exception e) { - throw new SearchArgumentParseException(); + throw new BadRequestException(BadRequestCode.SEARCH_ARGUMENT_PARSE_EXCEPTION); } } 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 0aa2d1fce..d834398b0 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 @@ -2,7 +2,6 @@ import java.time.LocalDate; import java.util.List; -import java.util.Objects; import lombok.AllArgsConstructor; import lombok.Getter; import org.springframework.data.domain.Pageable; 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 6c3cac91e..34d84ca7e 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/Comment.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/Comment.java @@ -1,5 +1,7 @@ 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; @@ -13,8 +15,8 @@ import lombok.Getter; import lombok.NoArgsConstructor; import wooteco.prolog.common.AuditingEntity; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.member.domain.Member; -import wooteco.prolog.studylog.exception.CommentDeleteException; @Entity @NoArgsConstructor(access = AccessLevel.PROTECTED) @@ -52,7 +54,7 @@ public void updateContent(String content) { public void delete() { if (isDelete) { - throw new CommentDeleteException(); + throw new BadRequestException(COMMENT_DELETE_EXCEPTION); } this.isDelete = true; 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 0b0ed1430..3f6981e55 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/Content.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/Content.java @@ -1,6 +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; @@ -9,7 +11,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; import lombok.ToString; -import wooteco.prolog.studylog.exception.StudylogContentNullOrEmptyException; +import wooteco.prolog.common.exception.BadRequestException; @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @@ -35,7 +37,7 @@ private int length(String title) { private void validateNullOrEmpty(String content, int trimedContentLength) { if (Objects.isNull(content) || trimedContentLength == 0) { - throw new StudylogContentNullOrEmptyException(); + throw new BadRequestException(STUDYLOG_CONTENT_NULL_OR_EMPTY); } } } diff --git a/backend/src/main/java/wooteco/prolog/studylog/domain/DocumentQueryParser.java b/backend/src/main/java/wooteco/prolog/studylog/domain/DocumentQueryParser.java index 8340c68ba..f821d00a0 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/DocumentQueryParser.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/DocumentQueryParser.java @@ -16,8 +16,10 @@ public static List removeSpecialChars(List words) { StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < word.length(); i++) { char c = word.charAt(i); - if (c == '\\' || c == '+' || c == '-' || c == '!' || c == '(' || c == ')' || c == ':' - || c == '^' || c == '[' || c == ']' || c == '\"' || c == '{' || c == '}' || c == '~' + if (c == '\\' || c == '+' || c == '-' || c == '!' || c == '(' || c == ')' + || c == ':' + || c == '^' || c == '[' || c == ']' || c == '\"' || c == '{' || c == '}' + || c == '~' || c == '*' || c == '?' || c == '|' || c == '&' || c == '/') { continue; } 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 fa69b8bcc..fbc25ad01 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/Likes.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/Likes.java @@ -1,12 +1,14 @@ 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 java.util.ArrayList; import java.util.List; import javax.persistence.CascadeType; import javax.persistence.Embeddable; import javax.persistence.OneToMany; -import wooteco.prolog.studylog.exception.InvalidLikeRequestException; -import wooteco.prolog.studylog.exception.InvalidUnlikeRequestException; +import wooteco.prolog.common.exception.BadRequestException; @Embeddable public class Likes { @@ -41,7 +43,7 @@ private void validateNewLike(Long id) { .filter(memberId -> memberId.equals(id)) .findAny() .ifPresent(memberId -> { - throw new InvalidLikeRequestException(); + throw new BadRequestException(INVALID_LIKE_REQUEST_EXCEPTION); }); } @@ -52,7 +54,7 @@ public void unlike(Studylog studylog, Long memberId) { private void validateExistingLike(Long id) { if (!likedByMember(id)) { - throw new InvalidUnlikeRequestException(); + throw new BadRequestException(INVALID_UNLIKE_REQUEST_EXCEPTION); } } 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 f16312634..48cfe2b12 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/PopularStudylog.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/PopularStudylog.java @@ -12,10 +12,10 @@ import wooteco.prolog.common.AuditingEntity; /** - * 홈페이지를 클릭할 때마다 매번 조회되는 테이블(엔티티). - * 조회 시마다 다른 테이블들과 계속해서 JOIN이 발생함. - * 조회 속도가 느릴 시 temp/mainpage-popular-studylog-api 브랜치 작업 내용을 다시 활용할 것 - * (해당 브랜치에는 화면단에 뿌려줄 RAW한 데이터들만 가진 테이블로 설계되어 있음) + * 홈페이지를 클릭할 때마다 매번 조회되는 테이블(엔티티). 조회 시마다 다른 테이블들과 계속해서 JOIN이 발생함. 조회 속도가 느릴 시 + * temp/mainpage-popular-studylog-api 브랜치 작업 내용을 다시 활용할 것 (해당 브랜치에는 화면단에 뿌려줄 RAW한 데이터들만 가진 테이블로 설계되어 + * 있음) + * * @author hyeon9mak */ @Entity 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 0b587c65f..1aa422bec 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/Studylog.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/Studylog.java @@ -14,10 +14,11 @@ import lombok.Getter; import lombok.NoArgsConstructor; import wooteco.prolog.common.AuditingEntity; +import wooteco.prolog.common.exception.BadRequestCode; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.member.domain.Member; import wooteco.prolog.session.domain.Mission; import wooteco.prolog.session.domain.Session; -import wooteco.prolog.studylog.exception.AuthorNotValidException; @Entity @NoArgsConstructor(access = AccessLevel.PROTECTED) @@ -61,7 +62,8 @@ public class Studylog extends AuditingEntity { private boolean deleted; - public Studylog(Member member, String title, String content, Session session, Mission mission, List tags) { + public Studylog(Member member, String title, String content, Session session, Mission mission, + List tags) { this.member = member; this.title = new Title(title); this.content = new Content(content); @@ -79,7 +81,7 @@ public Studylog(Member member, String title, String content, Mission mission, Li public void validateBelongTo(Long memberId) { if (!isBelongsTo(memberId)) { - throw new AuthorNotValidException(); + throw new BadRequestException(BadRequestCode.ONLY_AUTHOR_CAN_EDIT); } } @@ -116,8 +118,8 @@ public void addTags(Tags tags) { private List convertToStudylogTags(Tags tags) { return tags.getList().stream() - .map(tag -> new StudylogTag(this, tag)) - .collect(Collectors.toList()); + .map(tag -> new StudylogTag(this, tag)) + .collect(Collectors.toList()); } public void increaseViewCount(Member member) { @@ -203,7 +205,7 @@ public void updateMission(Mission mission) { @Override public String toString() { return "Studylog{" + - "id=" + id + - '}'; + "id=" + id + + '}'; } } diff --git a/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogDocumentQueryBuilder.java b/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogDocumentQueryBuilder.java index 88fd4d0df..c8478aa6a 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogDocumentQueryBuilder.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogDocumentQueryBuilder.java @@ -34,12 +34,12 @@ public static Query makeQuery(List inputKeywords, List keywords = removeSpecialChars(inputKeywords); NativeSearchQueryBuilder query = new NativeSearchQueryBuilder(); makeBoolQuery(query, - makeKeywordsQueryString(keywords), - makeDefaultQueryString(usernames), - makeDefaultQueryString(convertToListString(levels)), - makeDefaultQueryString(convertToListString(missions)), - start, - end); + makeKeywordsQueryString(keywords), + makeDefaultQueryString(usernames), + makeDefaultQueryString(convertToListString(levels)), + makeDefaultQueryString(convertToListString(missions)), + start, + end); makeFilterQuery(query, tags); return query @@ -62,11 +62,11 @@ private static void makeBoolQuery( 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)) + .must(multiField(keyword)) + .must(defaultField(username, "username")) + .must(defaultField(levels, "levelId")) + .must(defaultField(missions, "missionId")) + .filter(rangeQuery(start, 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 5ae0d9b17..aa3110fd1 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,17 @@ 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 lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; import wooteco.prolog.member.domain.Member; -import javax.persistence.*; - @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @Entity 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 a137eddf8..8fe4024a8 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogScrap.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogScrap.java @@ -1,7 +1,6 @@ package wooteco.prolog.studylog.domain; import java.util.Objects; -import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; @@ -58,4 +57,4 @@ public boolean equals(Object o) { public int hashCode() { return Objects.hash(member.getId(), studylog.getId()); } -} \ No newline at end of file +} 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 cf787886f..4491da412 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogTemp.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogTemp.java @@ -1,5 +1,16 @@ 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 lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -7,15 +18,11 @@ import wooteco.prolog.session.domain.Mission; import wooteco.prolog.session.domain.Session; -import javax.persistence.*; -import java.util.List; - -import static java.util.stream.Collectors.toList; - @Entity @NoArgsConstructor(access = AccessLevel.PROTECTED) @Getter public class StudylogTemp { + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @@ -39,7 +46,8 @@ public class StudylogTemp { @Embedded private StudylogTempTags studylogTempTags; - public StudylogTemp(Member member, String title, String content, Session session, Mission mission, List tagList) { + public StudylogTemp(Member member, String title, String content, Session session, + Mission mission, List tagList) { this.member = member; this.title = title; this.content = content; @@ -47,7 +55,7 @@ public StudylogTemp(Member member, String title, String content, Session session this.mission = mission; Tags tags = new Tags(tagList); this.studylogTempTags = new StudylogTempTags(tags.getList().stream() - .map(tag -> new StudylogTempTag(this, tag)) - .collect(toList())); + .map(tag -> new StudylogTempTag(this, tag)) + .collect(toList())); } } 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 bc9ffeeac..be5f1098e 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogTempTag.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogTempTag.java @@ -1,12 +1,17 @@ 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 lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; -import javax.persistence.*; -import java.util.Objects; - @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @Entity 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 42b9ce3cd..2a79b29de 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogTempTags.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/StudylogTempTags.java @@ -1,17 +1,17 @@ package wooteco.prolog.studylog.domain; -import lombok.Getter; -import org.hibernate.annotations.BatchSize; - +import java.util.ArrayList; +import java.util.List; import javax.persistence.CascadeType; import javax.persistence.Embeddable; import javax.persistence.OneToMany; -import java.util.ArrayList; -import java.util.List; +import lombok.Getter; +import org.hibernate.annotations.BatchSize; @Getter @Embeddable public class StudylogTempTags { + @OneToMany(mappedBy = "studylogTemp", cascade = CascadeType.PERSIST, orphanRemoval = true) @BatchSize(size = 1000) private final List values; 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 bed36e15a..304aae426 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/TagName.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/TagName.java @@ -1,12 +1,15 @@ 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 lombok.AccessLevel; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; -import wooteco.prolog.studylog.exception.TooLongTagNameException; +import wooteco.prolog.common.exception.BadRequestException; @EqualsAndHashCode @NoArgsConstructor(access = AccessLevel.PROTECTED) @@ -28,7 +31,7 @@ public TagName(String name) { private void validateMaxLength(String name) { if (name.length() > MAX_LENGTH) { - throw new TooLongTagNameException(); + throw new BadRequestException(TOO_LONG_TAG_NAME); } } @@ -38,19 +41,19 @@ private String trim(String name) { private void validateNull(String name) { if (Objects.isNull(name)) { - throw new wooteco.prolog.studylog.exception.TagNameNullOrEmptyException(); + throw new BadRequestException(TAG_NAME_NULL_OR_EMPTY); } } private void validateEmpty(String name) { if (name.isEmpty()) { - throw new wooteco.prolog.studylog.exception.TagNameNullOrEmptyException(); + throw new BadRequestException(TAG_NAME_NULL_OR_EMPTY); } } private void validateOnlyBlank(String name) { if (name.trim().isEmpty()) { - throw new wooteco.prolog.studylog.exception.TagNameNullOrEmptyException(); + throw new BadRequestException(TAG_NAME_NULL_OR_EMPTY); } } 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 87bc767ed..cd71ad6b3 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/Tags.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/Tags.java @@ -2,13 +2,14 @@ import static java.util.stream.Collectors.collectingAndThen; import static java.util.stream.Collectors.toList; +import static wooteco.prolog.common.exception.BadRequestCode.DUPLICATE_TAG; 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 wooteco.prolog.studylog.exception.DuplicateTagException; public class Tags { @@ -30,7 +31,7 @@ public static Tags of(List tagNames) { private void validateDuplicate(List names) { Set duplicateChecker = new HashSet<>(names); if (names.size() != duplicateChecker.size()) { - throw new DuplicateTagException(); + throw new BadRequestException(DUPLICATE_TAG); } } 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 0781f37b6..30b95b5c8 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/Title.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/Title.java @@ -1,5 +1,8 @@ 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; @@ -8,8 +11,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; import lombok.ToString; -import wooteco.prolog.login.excetpion.StudylogTitleNullOrEmptyException; -import wooteco.prolog.studylog.exception.TooLongTitleException; +import wooteco.prolog.common.exception.BadRequestException; @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @@ -37,25 +39,25 @@ private String trim(String name) { private void validateNull(String title) { if (Objects.isNull(title)) { - throw new StudylogTitleNullOrEmptyException(); + throw new BadRequestException(STUDYLOG_TITLE_NULL_OR_EMPTY); } } private void validateEmpty(String title) { if (title.isEmpty()) { - throw new StudylogTitleNullOrEmptyException(); + throw new BadRequestException(STUDYLOG_TITLE_NULL_OR_EMPTY); } } private void validateOnlyBlank(String title) { if (title.trim().isEmpty()) { - throw new StudylogTitleNullOrEmptyException(); + throw new BadRequestException(STUDYLOG_TITLE_NULL_OR_EMPTY); } } private void validateMaxLength(String title) { if (title.length() > MAX_LENGTH) { - throw new TooLongTitleException(); + throw new BadRequestException(STUDYLOG_TITLE_TOO_LONG); } } } 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 2c65b3412..25276800a 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/ViewCount.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/ViewCount.java @@ -1,8 +1,11 @@ package wooteco.prolog.studylog.domain; -import lombok.*; - import javax.persistence.Embeddable; +import lombok.AccessLevel; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @@ -10,6 +13,7 @@ @ToString @Embeddable public class ViewCount { + private int views; public void increase() { 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 b7b7be718..498c00d7c 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 @@ -11,13 +11,14 @@ public interface CommentRepository extends JpaRepository { @Query("SELECT c FROM Comment c" - + " JOIN FETCH c.studylog s" - + " JOIN FETCH c.member m" - + " WHERE s = :studylog" - + " AND c.isDelete = false") + + " JOIN FETCH c.studylog s" + + " JOIN FETCH c.member m" + + " WHERE s = :studylog" + + " AND c.isDelete = false") List findCommentByStudylog(Studylog studylog); - @Query("SELECT new wooteco.prolog.studylog.domain.repository.dto.CommentCount(c.studylog, COUNT(c))" + @Query( + "SELECT new wooteco.prolog.studylog.domain.repository.dto.CommentCount(c.studylog, COUNT(c))" + " FROM Comment c" + " WHERE c.studylog IN :studylogs" + " AND c.isDelete = false" 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 49397f0d9..b6cb1fefc 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,12 +1,12 @@ package wooteco.prolog.studylog.domain.repository; -import org.springframework.data.jpa.repository.JpaRepository; -import wooteco.prolog.studylog.domain.StudylogRead; - import java.util.List; import java.util.Optional; +import org.springframework.data.jpa.repository.JpaRepository; +import wooteco.prolog.studylog.domain.StudylogRead; public interface StudylogReadRepository extends JpaRepository { + boolean existsByMemberIdAndStudylogId(Long memberId, Long studylogId); Optional findByMemberIdAndStudylogId(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 3f7d4c119..f2628a7eb 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 @@ -4,15 +4,14 @@ import java.util.List; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.Query; -import org.springframework.lang.Nullable; import wooteco.prolog.member.domain.Member; import wooteco.prolog.studylog.domain.Studylog; -public interface StudylogRepository extends JpaRepository, JpaSpecificationExecutor { +public interface StudylogRepository extends JpaRepository, + JpaSpecificationExecutor { @Query(value = "select distinct p from Studylog p left join fetch p.studylogTags.values pt left join fetch pt.tag where p.member = :member and p.deleted <> true", countQuery = "select count(p) from Studylog p where p.member = :member and p.deleted <> true") @@ -31,7 +30,8 @@ public interface StudylogRepository extends JpaRepository, JpaSp List findTop50ByDeletedFalseOrderByIdDesc(); - List findByMemberIdAndCreatedAtBetween(Long memberId, LocalDateTime startDate, LocalDateTime endDate); + List findByMemberIdAndCreatedAtBetween(Long memberId, LocalDateTime startDate, + LocalDateTime endDate); Page findByIdInAndDeletedFalseOrderByIdDesc(List ids, Pageable pageable); 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 27085884b..1078b6508 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 @@ -3,18 +3,10 @@ import java.time.LocalDate; import java.time.LocalTime; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.Objects; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Expression; import javax.persistence.criteria.JoinType; -import javax.persistence.criteria.Order; import javax.persistence.criteria.Predicate; -import javax.persistence.criteria.Root; -import javax.persistence.criteria.Selection; -import org.hibernate.query.criteria.internal.OrderImpl; import org.springframework.data.jpa.domain.Specification; import wooteco.prolog.studylog.domain.Studylog; @@ -31,7 +23,8 @@ public static Specification likeKeyword(String key, List keywo } for (String keyword : keywords) { - predicates.add(builder.like(builder.lower(root.get(key).get(key)), "%" + keyword + "%")); + predicates.add( + builder.like(builder.lower(root.get(key).get(key)), "%" + keyword + "%")); } return builder.or(predicates.toArray(new Predicate[0])); @@ -64,7 +57,8 @@ public static Specification findByTagIn(List values) { return builder.and(); } - return root.join("studylogTags", JoinType.LEFT).join("values", JoinType.LEFT).get("tag").in(values); + return root.join("studylogTags", JoinType.LEFT).join("values", JoinType.LEFT).get("tag") + .in(values); }; } diff --git a/backend/src/main/java/wooteco/prolog/studylog/domain/repository/StudylogTempRepository.java b/backend/src/main/java/wooteco/prolog/studylog/domain/repository/StudylogTempRepository.java index ebaa8b444..d0b255eaf 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/domain/repository/StudylogTempRepository.java +++ b/backend/src/main/java/wooteco/prolog/studylog/domain/repository/StudylogTempRepository.java @@ -4,6 +4,7 @@ import wooteco.prolog.studylog.domain.StudylogTemp; public interface StudylogTempRepository extends JpaRepository { + boolean existsByMemberId(Long memberId); StudylogTemp findByMemberId(Long memberId); diff --git a/backend/src/main/java/wooteco/prolog/studylog/exception/AbilityNameDuplicateException.java b/backend/src/main/java/wooteco/prolog/studylog/exception/AbilityNameDuplicateException.java deleted file mode 100644 index d708bb5b6..000000000 --- a/backend/src/main/java/wooteco/prolog/studylog/exception/AbilityNameDuplicateException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.studylog.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class AbilityNameDuplicateException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/studylog/exception/AbilityParentColorDuplicateException.java b/backend/src/main/java/wooteco/prolog/studylog/exception/AbilityParentColorDuplicateException.java deleted file mode 100644 index 7f0e2f39d..000000000 --- a/backend/src/main/java/wooteco/prolog/studylog/exception/AbilityParentColorDuplicateException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.studylog.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class AbilityParentColorDuplicateException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/studylog/exception/AuthorNotValidException.java b/backend/src/main/java/wooteco/prolog/studylog/exception/AuthorNotValidException.java deleted file mode 100644 index 6d75587b1..000000000 --- a/backend/src/main/java/wooteco/prolog/studylog/exception/AuthorNotValidException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.studylog.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class AuthorNotValidException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/studylog/exception/ClusterHealthDownException.java b/backend/src/main/java/wooteco/prolog/studylog/exception/ClusterHealthDownException.java deleted file mode 100644 index 6b872bf64..000000000 --- a/backend/src/main/java/wooteco/prolog/studylog/exception/ClusterHealthDownException.java +++ /dev/null @@ -1,10 +0,0 @@ -package wooteco.prolog.studylog.exception; - -import wooteco.prolog.common.exception.ElasticsearchCustomException; - -public class ClusterHealthDownException extends ElasticsearchCustomException { - - public ClusterHealthDownException(String status) { - super(String.format("cluster의 상태가 %s 입니다.", status)); - } -} diff --git a/backend/src/main/java/wooteco/prolog/studylog/exception/CommentDeleteException.java b/backend/src/main/java/wooteco/prolog/studylog/exception/CommentDeleteException.java deleted file mode 100644 index ec89120f0..000000000 --- a/backend/src/main/java/wooteco/prolog/studylog/exception/CommentDeleteException.java +++ /dev/null @@ -1,6 +0,0 @@ -package wooteco.prolog.studylog.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class CommentDeleteException extends BadRequestException { -} diff --git a/backend/src/main/java/wooteco/prolog/studylog/exception/CommentNotFoundException.java b/backend/src/main/java/wooteco/prolog/studylog/exception/CommentNotFoundException.java deleted file mode 100644 index 8f25f55ed..000000000 --- a/backend/src/main/java/wooteco/prolog/studylog/exception/CommentNotFoundException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.studylog.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class CommentNotFoundException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/studylog/exception/DuplicateLevelException.java b/backend/src/main/java/wooteco/prolog/studylog/exception/DuplicateLevelException.java deleted file mode 100644 index ca1622f0d..000000000 --- a/backend/src/main/java/wooteco/prolog/studylog/exception/DuplicateLevelException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.studylog.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class DuplicateLevelException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/studylog/exception/DuplicateMissionException.java b/backend/src/main/java/wooteco/prolog/studylog/exception/DuplicateMissionException.java deleted file mode 100644 index 068cfa595..000000000 --- a/backend/src/main/java/wooteco/prolog/studylog/exception/DuplicateMissionException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.studylog.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class DuplicateMissionException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/studylog/exception/DuplicateTagException.java b/backend/src/main/java/wooteco/prolog/studylog/exception/DuplicateTagException.java deleted file mode 100644 index 47d03a491..000000000 --- a/backend/src/main/java/wooteco/prolog/studylog/exception/DuplicateTagException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.studylog.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class DuplicateTagException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/studylog/exception/IndexHealthDownException.java b/backend/src/main/java/wooteco/prolog/studylog/exception/IndexHealthDownException.java deleted file mode 100644 index 84ce9f4db..000000000 --- a/backend/src/main/java/wooteco/prolog/studylog/exception/IndexHealthDownException.java +++ /dev/null @@ -1,10 +0,0 @@ -package wooteco.prolog.studylog.exception; - -import wooteco.prolog.common.exception.ElasticsearchCustomException; - -public class IndexHealthDownException extends ElasticsearchCustomException { - - public IndexHealthDownException(String status) { - super(String.format("index의 상태가 %s 입니다.", status)); - } -} diff --git a/backend/src/main/java/wooteco/prolog/studylog/exception/InvalidLikeRequestException.java b/backend/src/main/java/wooteco/prolog/studylog/exception/InvalidLikeRequestException.java deleted file mode 100644 index 02347bccf..000000000 --- a/backend/src/main/java/wooteco/prolog/studylog/exception/InvalidLikeRequestException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.studylog.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class InvalidLikeRequestException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/studylog/exception/InvalidUnlikeRequestException.java b/backend/src/main/java/wooteco/prolog/studylog/exception/InvalidUnlikeRequestException.java deleted file mode 100644 index 082315607..000000000 --- a/backend/src/main/java/wooteco/prolog/studylog/exception/InvalidUnlikeRequestException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.studylog.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class InvalidUnlikeRequestException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/studylog/exception/JsonParseFailedException.java b/backend/src/main/java/wooteco/prolog/studylog/exception/JsonParseFailedException.java deleted file mode 100644 index 490feb5a3..000000000 --- a/backend/src/main/java/wooteco/prolog/studylog/exception/JsonParseFailedException.java +++ /dev/null @@ -1,5 +0,0 @@ -package wooteco.prolog.studylog.exception; - -public class JsonParseFailedException extends RuntimeException{ - -} diff --git a/backend/src/main/java/wooteco/prolog/studylog/exception/LevelNotFoundException.java b/backend/src/main/java/wooteco/prolog/studylog/exception/LevelNotFoundException.java deleted file mode 100644 index 6f812d6ca..000000000 --- a/backend/src/main/java/wooteco/prolog/studylog/exception/LevelNotFoundException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.studylog.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class LevelNotFoundException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/studylog/exception/MissionNotFoundException.java b/backend/src/main/java/wooteco/prolog/studylog/exception/MissionNotFoundException.java deleted file mode 100644 index 3367836e7..000000000 --- a/backend/src/main/java/wooteco/prolog/studylog/exception/MissionNotFoundException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.studylog.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class MissionNotFoundException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/studylog/exception/NotValidSortNameException.java b/backend/src/main/java/wooteco/prolog/studylog/exception/NotValidSortNameException.java deleted file mode 100644 index 4c301cc02..000000000 --- a/backend/src/main/java/wooteco/prolog/studylog/exception/NotValidSortNameException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.studylog.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class NotValidSortNameException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/studylog/exception/SearchArgumentParseException.java b/backend/src/main/java/wooteco/prolog/studylog/exception/SearchArgumentParseException.java deleted file mode 100644 index ebaeb7bb5..000000000 --- a/backend/src/main/java/wooteco/prolog/studylog/exception/SearchArgumentParseException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.studylog.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class SearchArgumentParseException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/studylog/exception/StudylogArgumentException.java b/backend/src/main/java/wooteco/prolog/studylog/exception/StudylogArgumentException.java deleted file mode 100644 index 9038d81a6..000000000 --- a/backend/src/main/java/wooteco/prolog/studylog/exception/StudylogArgumentException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.studylog.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class StudylogArgumentException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/studylog/exception/StudylogContentNullOrEmptyException.java b/backend/src/main/java/wooteco/prolog/studylog/exception/StudylogContentNullOrEmptyException.java deleted file mode 100644 index fad6c37e7..000000000 --- a/backend/src/main/java/wooteco/prolog/studylog/exception/StudylogContentNullOrEmptyException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.studylog.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class StudylogContentNullOrEmptyException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/studylog/exception/StudylogDocumentNotFoundException.java b/backend/src/main/java/wooteco/prolog/studylog/exception/StudylogDocumentNotFoundException.java deleted file mode 100644 index 95cbf922e..000000000 --- a/backend/src/main/java/wooteco/prolog/studylog/exception/StudylogDocumentNotFoundException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.studylog.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class StudylogDocumentNotFoundException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/studylog/exception/StudylogNotFoundException.java b/backend/src/main/java/wooteco/prolog/studylog/exception/StudylogNotFoundException.java deleted file mode 100644 index 07bb13ed3..000000000 --- a/backend/src/main/java/wooteco/prolog/studylog/exception/StudylogNotFoundException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.studylog.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class StudylogNotFoundException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/studylog/exception/StudylogReadNotExistException.java b/backend/src/main/java/wooteco/prolog/studylog/exception/StudylogReadNotExistException.java deleted file mode 100644 index 1b755738c..000000000 --- a/backend/src/main/java/wooteco/prolog/studylog/exception/StudylogReadNotExistException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.studylog.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class StudylogReadNotExistException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/studylog/exception/StudylogScrapAlreadyRegisteredException.java b/backend/src/main/java/wooteco/prolog/studylog/exception/StudylogScrapAlreadyRegisteredException.java deleted file mode 100644 index fb9c88e89..000000000 --- a/backend/src/main/java/wooteco/prolog/studylog/exception/StudylogScrapAlreadyRegisteredException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.studylog.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class StudylogScrapAlreadyRegisteredException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/studylog/exception/StudylogScrapNotExistException.java b/backend/src/main/java/wooteco/prolog/studylog/exception/StudylogScrapNotExistException.java deleted file mode 100644 index fb0c938f9..000000000 --- a/backend/src/main/java/wooteco/prolog/studylog/exception/StudylogScrapNotExistException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.studylog.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class StudylogScrapNotExistException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/studylog/exception/StudylogScrapNotValidUserException.java b/backend/src/main/java/wooteco/prolog/studylog/exception/StudylogScrapNotValidUserException.java deleted file mode 100644 index 2037ab87b..000000000 --- a/backend/src/main/java/wooteco/prolog/studylog/exception/StudylogScrapNotValidUserException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.studylog.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class StudylogScrapNotValidUserException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/studylog/exception/TagNameNullOrEmptyException.java b/backend/src/main/java/wooteco/prolog/studylog/exception/TagNameNullOrEmptyException.java deleted file mode 100644 index 650d81143..000000000 --- a/backend/src/main/java/wooteco/prolog/studylog/exception/TagNameNullOrEmptyException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.studylog.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class TagNameNullOrEmptyException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/studylog/exception/TooLongLevelNameException.java b/backend/src/main/java/wooteco/prolog/studylog/exception/TooLongLevelNameException.java deleted file mode 100644 index 6cda798d8..000000000 --- a/backend/src/main/java/wooteco/prolog/studylog/exception/TooLongLevelNameException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.studylog.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class TooLongLevelNameException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/studylog/exception/TooLongMissionNameException.java b/backend/src/main/java/wooteco/prolog/studylog/exception/TooLongMissionNameException.java deleted file mode 100644 index f65c314b4..000000000 --- a/backend/src/main/java/wooteco/prolog/studylog/exception/TooLongMissionNameException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.studylog.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class TooLongMissionNameException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/studylog/exception/TooLongTagNameException.java b/backend/src/main/java/wooteco/prolog/studylog/exception/TooLongTagNameException.java deleted file mode 100644 index ab098112d..000000000 --- a/backend/src/main/java/wooteco/prolog/studylog/exception/TooLongTagNameException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.studylog.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class TooLongTagNameException extends BadRequestException { - -} diff --git a/backend/src/main/java/wooteco/prolog/studylog/exception/TooLongTitleException.java b/backend/src/main/java/wooteco/prolog/studylog/exception/TooLongTitleException.java deleted file mode 100644 index ec8893db9..000000000 --- a/backend/src/main/java/wooteco/prolog/studylog/exception/TooLongTitleException.java +++ /dev/null @@ -1,7 +0,0 @@ -package wooteco.prolog.studylog.exception; - -import wooteco.prolog.common.exception.BadRequestException; - -public class TooLongTitleException extends BadRequestException { - -} 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 052367ecf..c95146a8b 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/ui/CommentController.java +++ b/backend/src/main/java/wooteco/prolog/studylog/ui/CommentController.java @@ -51,7 +51,8 @@ public ResponseEntity changeComment(@AuthMemberPrincipal LoginMember login @PathVariable Long studylogId, @PathVariable Long commentId, @RequestBody CommentChangeRequest request) { - commentService.updateComment(request.toUpdateRequest(loginMember.getId(), studylogId, commentId)); + commentService.updateComment( + request.toUpdateRequest(loginMember.getId(), studylogId, commentId)); return new ResponseEntity<>(HttpStatus.NO_CONTENT); } diff --git a/backend/src/main/java/wooteco/prolog/studylog/ui/PopularStudylogController.java b/backend/src/main/java/wooteco/prolog/studylog/ui/PopularStudylogController.java index ed5346c83..5e7d9bab0 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/ui/PopularStudylogController.java +++ b/backend/src/main/java/wooteco/prolog/studylog/ui/PopularStudylogController.java @@ -29,8 +29,10 @@ public ResponseEntity updatePopularStudylogs(@PageableDefault Pageable pag } @GetMapping("/popular") - public ResponseEntity showPopularStudylogs(@AuthMemberPrincipal LoginMember member, @PageableDefault Pageable pageable) { - PopularStudylogsResponse studylogsResponse = popularStudylogService.findPopularStudylogs(pageable, member.getId(), member.isAnonymous()); + public ResponseEntity showPopularStudylogs( + @AuthMemberPrincipal LoginMember member, @PageableDefault Pageable pageable) { + PopularStudylogsResponse studylogsResponse = popularStudylogService.findPopularStudylogs( + pageable, member.getId(), member.isAnonymous()); return ResponseEntity.ok(studylogsResponse); } } 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 b128bdbaf..b44dbac0a 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/ui/PostController.java +++ b/backend/src/main/java/wooteco/prolog/studylog/ui/PostController.java @@ -1,5 +1,7 @@ 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; @@ -12,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.login.aop.MemberOnly; import wooteco.prolog.login.domain.AuthMemberPrincipal; import wooteco.prolog.login.ui.LoginMember; @@ -21,7 +24,6 @@ import wooteco.prolog.studylog.application.dto.StudylogsResponse; import wooteco.prolog.studylog.application.dto.search.SearchParams; import wooteco.prolog.studylog.application.dto.search.StudylogsSearchRequest; -import wooteco.prolog.studylog.exception.StudylogNotFoundException; @Deprecated @RestController @@ -38,15 +40,18 @@ public PostController(StudylogService studylogService) { @MemberOnly public ResponseEntity createStudylog(@AuthMemberPrincipal LoginMember member, @RequestBody List studylogRequests) { - List studylogResponses = studylogService.insertStudylogs(member.getId(), studylogRequests); - return ResponseEntity.created(URI.create("/posts/" + studylogResponses.get(0).getId())).build(); + List studylogResponses = studylogService.insertStudylogs(member.getId(), + studylogRequests); + return ResponseEntity.created(URI.create("/posts/" + studylogResponses.get(0).getId())) + .build(); } @GetMapping public ResponseEntity showAll( @AuthMemberPrincipal LoginMember member, @SearchParams StudylogsSearchRequest searchRequest) { - StudylogsResponse studylogsResponse = studylogService.findStudylogs(searchRequest, member.getId(), member.isAnonymous()); + StudylogsResponse studylogsResponse = studylogService.findStudylogs(searchRequest, + member.getId(), member.isAnonymous()); return ResponseEntity.ok(studylogsResponse); } @@ -56,9 +61,10 @@ public ResponseEntity showStudylog( @AuthMemberPrincipal LoginMember member ) { if (!StringUtils.isNumeric(id)) { - throw new StudylogNotFoundException(); + throw new BadRequestException(STUDYLOG_NOT_FOUND); } - return ResponseEntity.ok(studylogService.retrieveStudylogById(member, Long.parseLong(id), false)); + return ResponseEntity.ok( + studylogService.retrieveStudylogById(member, Long.parseLong(id), false)); } @PutMapping("/{id}") 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 48852e7b0..d0e4d3e9b 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/ui/StudylogController.java +++ b/backend/src/main/java/wooteco/prolog/studylog/ui/StudylogController.java @@ -1,5 +1,7 @@ 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 org.apache.commons.lang3.StringUtils; @@ -13,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.login.aop.MemberOnly; import wooteco.prolog.login.domain.AuthMemberPrincipal; import wooteco.prolog.login.ui.LoginMember; @@ -24,7 +27,6 @@ import wooteco.prolog.studylog.application.dto.StudylogsResponse; import wooteco.prolog.studylog.application.dto.search.SearchParams; import wooteco.prolog.studylog.application.dto.search.StudylogsSearchRequest; -import wooteco.prolog.studylog.exception.StudylogNotFoundException; @RestController @RequestMapping("/studylogs") @@ -33,62 +35,78 @@ public class StudylogController { private final StudylogService studylogService; private final ViewedStudyLogCookieGenerator viewedStudyLogCookieGenerator; - public StudylogController(StudylogService studylogService, ViewedStudyLogCookieGenerator viewedStudyLogCookieGenerator) { + public StudylogController(StudylogService studylogService, + ViewedStudyLogCookieGenerator viewedStudyLogCookieGenerator) { this.studylogService = studylogService; this.viewedStudyLogCookieGenerator = viewedStudyLogCookieGenerator; } @PostMapping @MemberOnly - public ResponseEntity createStudylog(@AuthMemberPrincipal LoginMember member, @RequestBody StudylogRequest studylogRequest) { - StudylogResponse studylogResponse = studylogService.insertStudylog(member.getId(), studylogRequest); - return ResponseEntity.created(URI.create("/studylogs/" + studylogResponse.getId())).body(studylogResponse); + public ResponseEntity createStudylog(@AuthMemberPrincipal LoginMember member, + @RequestBody StudylogRequest studylogRequest) { + StudylogResponse studylogResponse = studylogService.insertStudylog(member.getId(), + studylogRequest); + return ResponseEntity.created(URI.create("/studylogs/" + studylogResponse.getId())) + .body(studylogResponse); } @PutMapping("/temp") @MemberOnly - public ResponseEntity createStudylogTemp(@AuthMemberPrincipal LoginMember member, @RequestBody StudylogRequest studylogRequest) { - StudylogTempResponse studylogTempResponse = studylogService.insertStudylogTemp(member.getId(), studylogRequest); - return ResponseEntity.created(URI.create("/studylogs/temp/" + studylogTempResponse.getId())).body(studylogTempResponse); + public ResponseEntity createStudylogTemp( + @AuthMemberPrincipal LoginMember member, @RequestBody StudylogRequest studylogRequest) { + StudylogTempResponse studylogTempResponse = studylogService.insertStudylogTemp( + member.getId(), studylogRequest); + return ResponseEntity.created(URI.create("/studylogs/temp/" + studylogTempResponse.getId())) + .body(studylogTempResponse); } @GetMapping("/temp") @MemberOnly - public ResponseEntity showStudylogTemp(@AuthMemberPrincipal LoginMember member) { - StudylogTempResponse studylogTempResponse = studylogService.findStudylogTemp(member.getId()); + public ResponseEntity showStudylogTemp( + @AuthMemberPrincipal LoginMember member) { + StudylogTempResponse studylogTempResponse = studylogService.findStudylogTemp( + member.getId()); return ResponseEntity.ok(studylogTempResponse); } @GetMapping - public ResponseEntity showAll(@AuthMemberPrincipal LoginMember member, @SearchParams StudylogsSearchRequest searchRequest) { - StudylogsResponse studylogsResponse = studylogService.findStudylogs(searchRequest, member.getId(), member.isAnonymous()); + public ResponseEntity showAll(@AuthMemberPrincipal LoginMember member, + @SearchParams StudylogsSearchRequest searchRequest) { + StudylogsResponse studylogsResponse = studylogService.findStudylogs(searchRequest, + member.getId(), member.isAnonymous()); return ResponseEntity.ok(studylogsResponse); } @GetMapping("/{id}") - public ResponseEntity showStudylog(@PathVariable String id, @AuthMemberPrincipal LoginMember member, + public ResponseEntity showStudylog(@PathVariable String id, + @AuthMemberPrincipal LoginMember member, @CookieValue(name = "viewed", required = false, defaultValue = "/") - String viewedStudyLogs, + String viewedStudyLogs, HttpServletResponse httpServletResponse) { if (!StringUtils.isNumeric(id)) { - throw new StudylogNotFoundException(); + throw new BadRequestException(STUDYLOG_NOT_FOUND); } - viewedStudyLogCookieGenerator.setViewedStudyLogCookie(viewedStudyLogs, id, httpServletResponse); + viewedStudyLogCookieGenerator.setViewedStudyLogCookie(viewedStudyLogs, id, + httpServletResponse); return ResponseEntity.ok(studylogService.retrieveStudylogById(member, Long.parseLong(id), - viewedStudyLogCookieGenerator.isViewed(viewedStudyLogs, id))); + viewedStudyLogCookieGenerator.isViewed(viewedStudyLogs, id))); } @PutMapping("/{id}") @MemberOnly - public ResponseEntity updateStudylog(@AuthMemberPrincipal LoginMember member, @PathVariable Long id, @RequestBody StudylogRequest studylogRequest) { + public ResponseEntity updateStudylog(@AuthMemberPrincipal LoginMember member, + @PathVariable Long id, + @RequestBody StudylogRequest studylogRequest) { studylogService.updateStudylog(member.getId(), id, studylogRequest); return ResponseEntity.ok().build(); } @DeleteMapping("/{id}") @MemberOnly - public ResponseEntity deleteStudylog(@AuthMemberPrincipal LoginMember member, @PathVariable Long id) { + public ResponseEntity deleteStudylog(@AuthMemberPrincipal LoginMember member, + @PathVariable Long id) { studylogService.deleteStudylog(member.getId(), id); return ResponseEntity.noContent().build(); } 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 af77b0edb..70d6e4765 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/ui/StudylogOverviewController.java +++ b/backend/src/main/java/wooteco/prolog/studylog/ui/StudylogOverviewController.java @@ -44,7 +44,8 @@ public ResponseEntity> findPostsOf } @GetMapping("/{username}/calendar-studylogs") - public ResponseEntity> findStudylogsOfMine(CalendarStudylogRequest calendarStudylogRequest, @PathVariable String username) { + public ResponseEntity> findStudylogsOfMine( + CalendarStudylogRequest calendarStudylogRequest, @PathVariable String username) { return ResponseEntity.ok( MemberDataResponses.of( studylogService.findCalendarStudylogs(username, calendarStudylogRequest.localDate()) 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 758efe28f..479e35f37 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/ui/StudylogRssFeedController.java +++ b/backend/src/main/java/wooteco/prolog/studylog/ui/StudylogRssFeedController.java @@ -20,7 +20,8 @@ public class StudylogRssFeedController { @Value("${application.url}") private String url; - public StudylogRssFeedController(StudylogService studylogService, StudylogRssFeedView studylogRssFeedView) { + public StudylogRssFeedController(StudylogService studylogService, + StudylogRssFeedView studylogRssFeedView) { this.studylogService = studylogService; this.studylogRssFeedView = studylogRssFeedView; } 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 b0b585900..1cad40aa5 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/ui/StudylogRssFeedView.java +++ b/backend/src/main/java/wooteco/prolog/studylog/ui/StudylogRssFeedView.java @@ -9,10 +9,6 @@ import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.apache.commons.text.StringEscapeUtils; -import org.commonmark.node.Node; -import org.commonmark.parser.Parser; -import org.commonmark.renderer.html.HtmlRenderer; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import org.springframework.web.servlet.view.feed.AbstractRssFeedView; @@ -25,15 +21,18 @@ public class StudylogRssFeedView extends AbstractRssFeedView { private String url; @Override - protected void buildFeedMetadata(Map model, Channel feed, HttpServletRequest request) { + protected void buildFeedMetadata(Map model, Channel feed, + HttpServletRequest request) { feed.setTitle("Prolog | 우아한테크코스 학습로그 저장소"); feed.setDescription("우아한테크코스 크루들이 배운 내용을 기록하는 학습로그 저장소입니다."); feed.setLink(url); } @Override - protected List buildFeedItems(Map model, HttpServletRequest request, HttpServletResponse response) { - List rssFeedResponses = (List) model.get("rssFeeds"); + protected List buildFeedItems(Map model, HttpServletRequest request, + HttpServletResponse response) { + List rssFeedResponses = (List) model.get( + "rssFeeds"); return rssFeedResponses.stream() .map(this::createItem) @@ -67,7 +66,8 @@ private Description createDescription(StudylogRssFeedResponse rssFeedResponse) { } @Override - protected void setResponseContentType(HttpServletRequest request, HttpServletResponse response) { + protected void setResponseContentType(HttpServletRequest request, + HttpServletResponse response) { response.setContentType("application/rss+xml;charset=UTF-8"); } } diff --git a/backend/src/main/java/wooteco/prolog/studylog/ui/StudylogSessionController.java b/backend/src/main/java/wooteco/prolog/studylog/ui/StudylogSessionController.java index 5955a91e1..77d18ed0d 100644 --- a/backend/src/main/java/wooteco/prolog/studylog/ui/StudylogSessionController.java +++ b/backend/src/main/java/wooteco/prolog/studylog/ui/StudylogSessionController.java @@ -26,14 +26,18 @@ public class StudylogSessionController { @PutMapping("/{id}/sessions") @MemberOnly - public ResponseEntity updateStudylogSession(@AuthMemberPrincipal LoginMember member, @PathVariable Long id, @RequestBody StudylogSessionRequest studylogSessionRequest) { + public ResponseEntity updateStudylogSession(@AuthMemberPrincipal LoginMember member, + @PathVariable Long id, + @RequestBody StudylogSessionRequest studylogSessionRequest) { studylogService.updateStudylogSession(member.getId(), id, studylogSessionRequest); return ResponseEntity.ok().build(); } @PutMapping("/{id}/missions") @MemberOnly - public ResponseEntity updateStudylogMissions(@AuthMemberPrincipal LoginMember member, @PathVariable Long id, @RequestBody StudylogMissionRequest studylogMissionRequest) { + public ResponseEntity updateStudylogMissions(@AuthMemberPrincipal LoginMember member, + @PathVariable Long id, + @RequestBody StudylogMissionRequest studylogMissionRequest) { studylogService.updateStudylogMission(member.getId(), id, studylogMissionRequest); return ResponseEntity.ok().build(); } diff --git a/backend/src/main/java/wooteco/prolog/update/MemberTagApplicationListener.java b/backend/src/main/java/wooteco/prolog/update/MemberTagApplicationListener.java index b5fb96dc9..6cbdee61b 100644 --- a/backend/src/main/java/wooteco/prolog/update/MemberTagApplicationListener.java +++ b/backend/src/main/java/wooteco/prolog/update/MemberTagApplicationListener.java @@ -35,7 +35,8 @@ public void onApplicationEvent(ContextRefreshedEvent event) { } updateMemberTags(); - updatedContentsRepository.save(new UpdatedContents(null, UpdateContent.MEMBER_TAG_UPDATE, 1)); + updatedContentsRepository.save( + new UpdatedContents(null, UpdateContent.MEMBER_TAG_UPDATE, 1)); } private void updateMemberTags() { @@ -43,7 +44,8 @@ private void updateMemberTags() { for (StudylogTag studylogTag : studylogTags) { final Tag tag = studylogTag.getTag(); final Member member = studylogTag.getStudylog().getMember(); - memberTagRepository.register(new MemberTags(Collections.singletonList(new MemberTag(member, tag)))); + memberTagRepository.register( + new MemberTags(Collections.singletonList(new MemberTag(member, tag)))); } } } 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 42d2ea953..dc5a7ade4 100644 --- a/backend/src/main/java/wooteco/support/autoceptor/scanner/MappingAnnotation.java +++ b/backend/src/main/java/wooteco/support/autoceptor/scanner/MappingAnnotation.java @@ -14,14 +14,14 @@ public enum MappingAnnotation { REQUEST_MAPPING(RequestMapping.class, - declaration -> Arrays.asList( - declaration.getAnnotation(RequestMapping.class).value())), + declaration -> Arrays.asList( + declaration.getAnnotation(RequestMapping.class).value())), GET(GetMapping.class, declaration -> Arrays.asList(declaration.getAnnotation(GetMapping.class).value())), POST(PostMapping.class, - declaration -> Arrays.asList(declaration.getAnnotation(PostMapping.class).value())), + declaration -> Arrays.asList(declaration.getAnnotation(PostMapping.class).value())), DELETE(DeleteMapping.class, - declaration -> Arrays.asList(declaration.getAnnotation(DeleteMapping.class).value())), + declaration -> Arrays.asList(declaration.getAnnotation(DeleteMapping.class).value())), PUT(PutMapping.class, declaration -> Arrays.asList(declaration.getAnnotation(PutMapping.class).value())); diff --git a/backend/src/main/java/wooteco/support/performance/PerformanceLogger.java b/backend/src/main/java/wooteco/support/performance/PerformanceLogger.java index cad08da43..8c6a423ac 100644 --- a/backend/src/main/java/wooteco/support/performance/PerformanceLogger.java +++ b/backend/src/main/java/wooteco/support/performance/PerformanceLogger.java @@ -11,7 +11,6 @@ import org.aspectj.lang.annotation.Before; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; import org.springframework.transaction.support.TransactionSynchronization; import org.springframework.transaction.support.TransactionSynchronizationManager; @@ -33,7 +32,8 @@ public void beforeTransaction() { @Override public void afterCompletion(int status) { - if(getLoggingForm().getTargetApi() == null || getLoggingForm().getTargetApi().isEmpty()) { + if (getLoggingForm().getTargetApi() == null || getLoggingForm().getTargetApi() + .isEmpty()) { return; } try { diff --git a/backend/src/main/java/wooteco/support/performance/ProxyPreparedStatementHandler.java b/backend/src/main/java/wooteco/support/performance/ProxyPreparedStatementHandler.java index 3a744a831..f251aba76 100644 --- a/backend/src/main/java/wooteco/support/performance/ProxyPreparedStatementHandler.java +++ b/backend/src/main/java/wooteco/support/performance/ProxyPreparedStatementHandler.java @@ -16,7 +16,7 @@ public ProxyPreparedStatementHandler(Object preparedStatement, @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - if(method.getName().equals("executeQuery")) { + if (method.getName().equals("executeQuery")) { final long startTime = System.currentTimeMillis(); final Object returnValue = method.invoke(preparedStatement, args); loggingForm.addQueryTime(System.currentTimeMillis() - startTime); diff --git a/backend/src/main/java/wooteco/support/performance/RequestApiExtractor.java b/backend/src/main/java/wooteco/support/performance/RequestApiExtractor.java index 880c3e2a0..b31388997 100644 --- a/backend/src/main/java/wooteco/support/performance/RequestApiExtractor.java +++ b/backend/src/main/java/wooteco/support/performance/RequestApiExtractor.java @@ -29,9 +29,9 @@ public RequestApi extractRequestApi(JoinPoint joinPoint) { final MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); final Optional extractor = dataExtractors.stream() - .filter(annotationDataExtractor -> annotationDataExtractor - .isAssignable(methodSignature.getMethod())) - .findAny(); + .filter(annotationDataExtractor -> annotationDataExtractor + .isAssignable(methodSignature.getMethod())) + .findAny(); if (!extractor.isPresent()) { return new RequestApi(); @@ -44,8 +44,8 @@ private String getClassUrl(JoinPoint joinPoint) { if (targetClass.isAnnotationPresent(RequestMapping.class)) { final RequestMapping requestMapping = targetClass.getAnnotation(RequestMapping.class); return Arrays.stream(requestMapping.value()) - .findAny() - .orElseGet(() -> Arrays.stream(requestMapping.path()).findAny().orElse("")); + .findAny() + .orElseGet(() -> Arrays.stream(requestMapping.path()).findAny().orElse("")); } return ""; } 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 3ab7d95b0..d9980ecc3 100644 --- a/backend/src/main/java/wooteco/support/performance/annotationDataExtractor/DeleteMappingDataExtractor.java +++ b/backend/src/main/java/wooteco/support/performance/annotationDataExtractor/DeleteMappingDataExtractor.java @@ -16,11 +16,11 @@ public boolean isAssignable(Method method) { public RequestApi extractRequestApi(Method method, String classUrl) { final DeleteMapping deleteMapping = method.getAnnotation(DeleteMapping.class); final String api = Arrays.stream(deleteMapping.value()) - .findAny() - .orElseGet(() -> - Arrays.stream(deleteMapping.path()).findAny() - .orElse("") - ); + .findAny() + .orElseGet(() -> + Arrays.stream(deleteMapping.path()).findAny() + .orElse("") + ); return new RequestApi(classUrl + api, "DELETE"); } } 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 1b1ac72e8..e8f561f19 100644 --- a/backend/src/main/java/wooteco/support/performance/annotationDataExtractor/GetMappingDataExtractor.java +++ b/backend/src/main/java/wooteco/support/performance/annotationDataExtractor/GetMappingDataExtractor.java @@ -16,10 +16,10 @@ public boolean isAssignable(Method method) { public RequestApi extractRequestApi(Method method, String classUrl) { final GetMapping getMapping = method.getAnnotation(GetMapping.class); final String api = Arrays.stream(getMapping.value()) - .findAny() - .orElseGet(() -> - Arrays.stream(getMapping.path()).findAny().orElse("") - ); + .findAny() + .orElseGet(() -> + Arrays.stream(getMapping.path()).findAny().orElse("") + ); return new RequestApi(classUrl + api, "GET"); } } 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 965e9d790..5d73397cc 100644 --- a/backend/src/main/java/wooteco/support/performance/annotationDataExtractor/PostMappingDataExtractor.java +++ b/backend/src/main/java/wooteco/support/performance/annotationDataExtractor/PostMappingDataExtractor.java @@ -16,10 +16,10 @@ public boolean isAssignable(Method method) { public RequestApi extractRequestApi(Method method, String classUrl) { final PostMapping postMapping = method.getAnnotation(PostMapping.class); final String api = Arrays.stream(postMapping.value()) - .findAny() - .orElseGet(() -> - Arrays.stream(postMapping.path()).findAny().orElse("") - ); + .findAny() + .orElseGet(() -> + Arrays.stream(postMapping.path()).findAny().orElse("") + ); return new RequestApi(classUrl + api, "POST"); } } 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 cf1d48007..dfa1b2c55 100644 --- a/backend/src/main/java/wooteco/support/performance/annotationDataExtractor/PutMappingDataExtractor.java +++ b/backend/src/main/java/wooteco/support/performance/annotationDataExtractor/PutMappingDataExtractor.java @@ -16,11 +16,11 @@ public boolean isAssignable(Method method) { public RequestApi extractRequestApi(Method method, String classUrl) { final PutMapping putMapping = method.getAnnotation(PutMapping.class); final String api = Arrays.stream(putMapping.value()) - .findAny() - .orElseGet(() -> - Arrays.stream(putMapping.path()).findAny() - .orElse("") - ); + .findAny() + .orElseGet(() -> + Arrays.stream(putMapping.path()).findAny() + .orElse("") + ); return new RequestApi(classUrl + api, "PUT"); } } diff --git a/backend/src/main/resources/application-dev.yml b/backend/src/main/resources/application-dev.yml index 7f8b18c62..420f113ed 100644 --- a/backend/src/main/resources/application-dev.yml +++ b/backend/src/main/resources/application-dev.yml @@ -1,2 +1,6 @@ application: url: https://dev.prolog.techcourse.co.kr + +spring: + flyway: + enabled: true diff --git a/backend/src/main/resources/db/migration/prod/V2__create_table_keyword_reference.sql b/backend/src/main/resources/db/migration/prod/V2__create_table_keyword_reference.sql index 966bc5afa..1c6160521 100644 --- a/backend/src/main/resources/db/migration/prod/V2__create_table_keyword_reference.sql +++ b/backend/src/main/resources/db/migration/prod/V2__create_table_keyword_reference.sql @@ -1,8 +1,7 @@ -create table prolog.keyword_reference +create table if not exists prolog.keyword_reference ( keyword_id bigint not null, url varchar(255) null, constraint FK_KEYWORD_ID foreign key (keyword_id) references prolog.keyword (id) ); - diff --git a/backend/src/main/resources/db/migration/prod/V3__create_initial_scheme_squashed.sql b/backend/src/main/resources/db/migration/prod/V3__create_initial_scheme_squashed.sql new file mode 100644 index 000000000..91ac22846 --- /dev/null +++ b/backend/src/main/resources/db/migration/prod/V3__create_initial_scheme_squashed.sql @@ -0,0 +1,11 @@ +create table if not exists prolog.article +( + id bigint auto_increment primary key, + member_id bigint not null, + title varchar(50) not null, + url varchar(1024) not null, + created_at datetime(6) not null, + foreign key (member_id) references prolog.member (id) +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 + COLLATE = utf8mb4_0900_ai_ci; diff --git a/backend/src/main/resources/logback-spring.xml b/backend/src/main/resources/logback-spring.xml index 50777223a..1d7f734c7 100644 --- a/backend/src/main/resources/logback-spring.xml +++ b/backend/src/main/resources/logback-spring.xml @@ -1,70 +1,72 @@ - + - - - - - + + + + + - - - + + + - - - - - + + + + + - - - - + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - + + + + + - - - - + + + + - - + + - - - + + + - - - + + + - - - + + + - - - - + + + + diff --git a/backend/src/main/resources/logback/console-access-logger.xml b/backend/src/main/resources/logback/console-access-logger.xml index 754cd9988..d30966845 100644 --- a/backend/src/main/resources/logback/console-access-logger.xml +++ b/backend/src/main/resources/logback/console-access-logger.xml @@ -1,11 +1,12 @@ - - - utf8 - - %n###### HTTP Request ###### %n%fullRequest###### HTTP Response ###### %n%fullResponse - - - + + + utf8 + + %n###### HTTP Request ###### %n%fullRequest###### HTTP Response ###### + %n%fullResponse + + + diff --git a/backend/src/main/resources/logback/console-logger.xml b/backend/src/main/resources/logback/console-logger.xml index aac9a8c6d..b24fe5bb5 100644 --- a/backend/src/main/resources/logback/console-logger.xml +++ b/backend/src/main/resources/logback/console-logger.xml @@ -1,20 +1,21 @@ - - - utf8 - - %cyan(%d{yyyy-MM-dd HH:mm:ss}:%-4relative) %highlight(%-5level) %yellow([%C.%M]:%boldWhite(%L)]) %n > %msg%n - - - + + + utf8 + + %cyan(%d{yyyy-MM-dd HH:mm:ss}:%-4relative) %highlight(%-5level) + %yellow([%C.%M]:%boldWhite(%L)]) %n > %msg%n + + + - - - utf8 - - %green( > %msg%n) - - - + + + utf8 + + %green( > %msg%n) + + + diff --git a/backend/src/main/resources/logback/file-access-logger.xml b/backend/src/main/resources/logback/file-access-logger.xml index 3c0558f0b..bd8563bff 100644 --- a/backend/src/main/resources/logback/file-access-logger.xml +++ b/backend/src/main/resources/logback/file-access-logger.xml @@ -1,21 +1,22 @@ - - - ${home}access.log - - ${home}access-%d{yyyyMMdd}-%i.log - - 15MB - - 7 - - - utf8 - - %n###### HTTP Request ###### %n%fullRequest###### HTTP Response ###### %n%fullResponse - - - + + + ${home}access.log + + ${home}access-%d{yyyyMMdd}-%i.log + + 15MB + + 7 + + + utf8 + + %n###### HTTP Request ###### %n%fullRequest###### HTTP Response ###### + %n%fullResponse + + + diff --git a/backend/src/main/resources/logback/file-debug-logger.xml b/backend/src/main/resources/logback/file-debug-logger.xml index ad2064e51..f0236d56a 100644 --- a/backend/src/main/resources/logback/file-debug-logger.xml +++ b/backend/src/main/resources/logback/file-debug-logger.xml @@ -1,25 +1,26 @@ - - - ${home}debug.log - - DEBUG - ACCEPT - DENY - - - ${home}debug-%d{yyyyMMdd}-%i.log - - 15MB - - 7 - - - utf8 - - %d{yyyy-MM-dd HH:mm:ss}:%-4relative %-5level [%C.%M]:%L] %n > %msg%n - - - + + + ${home}debug.log + + DEBUG + ACCEPT + DENY + + + ${home}debug-%d{yyyyMMdd}-%i.log + + 15MB + + 7 + + + utf8 + + %d{yyyy-MM-dd HH:mm:ss}:%-4relative %-5level [%C.%M]:%L] %n > %msg%n + + + diff --git a/backend/src/main/resources/logback/file-error-logger.xml b/backend/src/main/resources/logback/file-error-logger.xml index b04010c2d..d1b4b2249 100644 --- a/backend/src/main/resources/logback/file-error-logger.xml +++ b/backend/src/main/resources/logback/file-error-logger.xml @@ -1,25 +1,26 @@ - - - ${home}error.log - - ERROR - ACCEPT - DENY - - - ${home}error-%d{yyyyMMdd}-%i.log - - 15MB - - 7 - - - utf8 - - %d{yyyy-MM-dd HH:mm:ss}:%-4relative %-5level [%C.%M]:%L] %n > %msg%n - - - + + + ${home}error.log + + ERROR + ACCEPT + DENY + + + ${home}error-%d{yyyyMMdd}-%i.log + + 15MB + + 7 + + + utf8 + + %d{yyyy-MM-dd HH:mm:ss}:%-4relative %-5level [%C.%M]:%L] %n > %msg%n + + + diff --git a/backend/src/main/resources/logback/file-info-logger.xml b/backend/src/main/resources/logback/file-info-logger.xml index ec1683689..10b888b44 100644 --- a/backend/src/main/resources/logback/file-info-logger.xml +++ b/backend/src/main/resources/logback/file-info-logger.xml @@ -1,25 +1,26 @@ - - - ${home}info.log - - INFO - ACCEPT - DENY - - - ${home}info-%d{yyyyMMdd}-%i.log - - 15MB - - 7 - - - utf8 - - %d{yyyy-MM-dd HH:mm:ss}:%-4relative %-5level [%C.%M]:%L] %n > %msg%n - - - + + + ${home}info.log + + INFO + ACCEPT + DENY + + + ${home}info-%d{yyyyMMdd}-%i.log + + 15MB + + 7 + + + utf8 + + %d{yyyy-MM-dd HH:mm:ss}:%-4relative %-5level [%C.%M]:%L] %n > %msg%n + + + diff --git a/backend/src/main/resources/logback/file-warn-logger.xml b/backend/src/main/resources/logback/file-warn-logger.xml index ebcddad2d..16b180459 100644 --- a/backend/src/main/resources/logback/file-warn-logger.xml +++ b/backend/src/main/resources/logback/file-warn-logger.xml @@ -1,25 +1,26 @@ - - - ${home}warn.log - - WARN - ACCEPT - DENY - - - ${home}warn-%d{yyyyMMdd}-%i.log - - 15MB - - 30 - - - utf8 - - %d{yyyy-MM-dd HH:mm:ss}:%-4relative %-5level [%C.%M]:%L] %n > %msg%n - - - + + + ${home}warn.log + + WARN + ACCEPT + DENY + + + ${home}warn-%d{yyyyMMdd}-%i.log + + 15MB + + 30 + + + utf8 + + %d{yyyy-MM-dd HH:mm:ss}:%-4relative %-5level [%C.%M]:%L] %n > %msg%n + + + diff --git a/backend/src/main/resources/logback/performance-logger.xml b/backend/src/main/resources/logback/performance-logger.xml index 2c608c285..ee24a46f1 100644 --- a/backend/src/main/resources/logback/performance-logger.xml +++ b/backend/src/main/resources/logback/performance-logger.xml @@ -1,20 +1,21 @@ - - - ${home}performance.log - - ${home}performance-%d{yyyyMMdd}-%i.log - - 15MB - - 1 - - - utf8 - - %msg%n - - - + + + ${home}performance.log + + ${home}performance-%d{yyyyMMdd}-%i.log + + 15MB + + 1 + + + utf8 + + %msg%n + + + diff --git a/backend/src/main/resources/static/index.html b/backend/src/main/resources/static/index.html index abcd5dbe9..ed84ecd1b 100644 --- a/backend/src/main/resources/static/index.html +++ b/backend/src/main/resources/static/index.html @@ -1,550 +1,2226 @@ - - - - -Prolog API Document - - - + + + + + Prolog API Document + + +
-
-

로그인

-
-
-

깃허브 로그인

-
-

Request

-
-
+
+

로그인

+
+
+

깃허브 로그인

+
+

Request

+
+
POST /login/token HTTP/1.1
 Content-Type: application/json; charset=UTF-8
 Host: localhost:4000
@@ -553,13 +2229,13 @@ 

Request

{ "code" : "1" }
-
-
-
-
-

Response

-
-
+
+
+
+
+

Response

+
+
HTTP/1.1 200 OK
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -574,26 +2250,26 @@ 

Response

{ "accessToken" : "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNjY1NDkxMDIwLCJleHAiOjE2NjU0OTQ2MjAsInJvbGUiOiJDUkVXIn0.L-zEa2fDafcY6zGjIJNxv0hUeR0UpUkApKTUb9LtANk" }
-
-
-
-
-
-

본인 정보 요청

-
-

Request

-
-
+
+
+
+
+
+

본인 정보 요청

+
+

Request

+
+
GET /members/me HTTP/1.1
 Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNjY1NDkxMDE5LCJleHAiOjE2NjU0OTQ2MTksInJvbGUiOiJDUkVXIn0.i4FXAEj0UsmDgt-EUcz_rL06gjk-iFpBwawZr-p5ktk
 Host: localhost:4000
-
-
-
-
-

Response

-
-
+
+
+
+
+

Response

+
+
HTTP/1.1 200 OK
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -612,26 +2288,26 @@ 

Response

"role" : "CREW", "imageUrl" : "https://avatars.githubusercontent.com/u/52682603?v=4" }
-
-
-
-
-
-

멤버 정보 요청

-
-

Request

-
-
+
+
+
+
+
+

멤버 정보 요청

+
+

Request

+
+
GET /members/soulG HTTP/1.1
 Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNjY1NDkxMDE5LCJleHAiOjE2NjU0OTQ2MTksInJvbGUiOiJDUkVXIn0.i4FXAEj0UsmDgt-EUcz_rL06gjk-iFpBwawZr-p5ktk
 Host: localhost:4000
-
-
-
-
-

Response

-
-
+
+
+
+
+

Response

+
+
HTTP/1.1 200 OK
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -650,16 +2326,16 @@ 

Response

"role" : "CREW", "imageUrl" : "https://avatars.githubusercontent.com/u/52682603?v=4" }
-
-
-
-
-
-

멤버 정보 수정

-
-

Request

-
-
+
+
+
+
+
+

멤버 정보 수정

+
+

Request

+
+
PUT /members/soulG HTTP/1.1
 Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNjY1NDkxMDE5LCJleHAiOjE2NjU0OTQ2MTksInJvbGUiOiJDUkVXIn0.i4FXAEj0UsmDgt-EUcz_rL06gjk-iFpBwawZr-p5ktk
 Content-Type: application/json; charset=UTF-8
@@ -670,13 +2346,13 @@ 

Request

"nickname" : "다른이름", "imageUrl" : "https://avatars.githubusercontent.com/u/51393021?v=4" }
-
-
-
-
-

Response

-
-
+
+
+
+
+

Response

+
+
HTTP/1.1 200 OK
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -684,30 +2360,30 @@ 

Response

Date: Tue, 11 Oct 2022 12:23:39 GMT Keep-Alive: timeout=60 Connection: keep-alive
-
-
-
-
-
-
-
-

프로필

-
-
-

프로필 조회

-
-

Request

-
-
+
+
+
+
+
+
+
+

프로필

+
+
+

프로필 조회

+
+

Request

+
+
GET /members/soulG/profile HTTP/1.1
 Host: localhost:4000
-
-
-
-
-

Response

-
-
+
+
+
+
+

Response

+
+
HTTP/1.1 200 OK
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -726,25 +2402,25 @@ 

Response

"role" : "CREW", "imageUrl" : "https://avatars.githubusercontent.com/u/52682603?v=4" }
-
-
-
-
- +
+

프로필 소개 조회

+
+

Request

+
+
GET /members/soulG/profile-intro HTTP/1.1
 Host: localhost:4000
-
-
-
-
-

Response

-
-
+
+
+
+
+

Response

+
+
HTTP/1.1 200 OK
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -759,16 +2435,16 @@ 

Response

{ "text" : null }
-
-
-
-
- +
+

프로필 소개 수정

+
+

Request

+
+
PUT /members/soulG/profile-intro HTTP/1.1
 Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNjY1NDkxMDE2LCJleHAiOjE2NjU0OTQ2MTYsInJvbGUiOiJDUkVXIn0.gf1V2VmUM1Fi7mVx1-1ODbDayP1h3yi60It57i6ULC0
 Content-Type: application/json; charset=UTF-8
@@ -778,13 +2454,13 @@ 

Request

{ "text" : "수정된 소개글 입니다." }
-
-
-
-
-

Response

-
-
+
+
+
+
+

Response

+
+
HTTP/1.1 200 OK
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -792,26 +2468,26 @@ 

Response

Date: Tue, 11 Oct 2022 12:23:35 GMT Keep-Alive: timeout=60 Connection: keep-alive
-
-
-
-
- +
+

프로필 스터디로그 조회

+
+

Request

+
+
GET /members/soulG/studylogs HTTP/1.1
 Accept: application/json
 Host: localhost:4000
-
-
-
-
-

Response

-
-
+
+
+
+
+

Response

+
+
HTTP/1.1 200 OK
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -901,21 +2577,22 @@ 

Response

"totalPage" : 1, "currPage" : 1 }
-
-
-
-
-
-
-
-

세션

-
-
-

세션 등록

-
-

HTTP request

-
-
+
+
+
+
+
+
+
+

세션

+
+
+

세션 등록

+
+

HTTP + request

+
+
POST /sessions HTTP/1.1
 Content-Type: application/json;charset=UTF-8
 Content-Type: application/json;charset=UTF-8
@@ -926,13 +2603,14 @@ 

-
-
-
-
-

HTTP response

-
-
+
+
+
+
+

HTTP + response

+
+
HTTP/1.1 201 Created
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -945,25 +2623,28 @@ 

-
-
-
-
- +
+

세션 목록 조회

+
+

HTTP + request

+
+
GET /sessions HTTP/1.1
 Host: localhost:8080
-
-
-
-
-

HTTP response

-
-
+
+
+
+
+

HTTP + response

+
+
HTTP/1.1 200 OK
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -983,21 +2664,21 @@ 

-
-
-
-
-
-
- +
+

스터디로그

+
+
+

스터디로그 작성

+
+

Request

+
+
POST /studylogs HTTP/1.1
 Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNjY1NDkxMDEyLCJleHAiOjE2NjU0OTQ2MTIsInJvbGUiOiJDUkVXIn0.f4plGdouPTNGTg-1je8w1f92rqzARFYIjFcs_vI7_L4
 Content-Type: application/json; charset=UTF-8
@@ -1016,13 +2697,13 @@ 

Request

} ], "abilities" : [ 2 ] }
-
-
-
-
-

Response

-
-
+
+
+
+
+

Response

+
+
HTTP/1.1 201 Created
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -1080,28 +2761,28 @@ 

Response

"liked" : false, "likesCount" : 0, "commentCount" : 0 -}
-
-
-
-
-
+
+

스터디로그 목록 조회

+
+

Request

+
+
GET /studylogs HTTP/1.1
 Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNjY1NDkxMDExLCJleHAiOjE2NjU0OTQ2MTEsInJvbGUiOiJDUkVXIn0.PNOKXpiyVTeHnp5741TL0o5E9ybxQ6oMNqToi78u3ds
 Accept: application/json
 Host: localhost:4000
-
-
-
-
-

Response

-
-
+
+
+
+
+

Response

+
+
HTTP/1.1 200 OK
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -1197,26 +2878,26 @@ 

Response

"totalPage" : 1, "currPage" : 1 }
-
-
-
-
- +
+

스터디로그 단건 조회

+
+

Request

+
+
GET /studylogs/1 HTTP/1.1
 Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNjY1NDkxMDEwLCJleHAiOjE2NjU0OTQ2MTAsInJvbGUiOiJDUkVXIn0.vYpoiz13ldlt31FPpJLWaxYjd9Gbuje-Oz2AUE2WHPs
 Host: localhost:4000
-
-
-
-
-

Response

-
-
+
+
+
+
+

Response

+
+
HTTP/1.1 200 OK
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -1275,16 +2956,16 @@ 

Response

"likesCount" : 0, "commentCount" : 0 }
-
-
-
-
- +
+

스터디로그 수정

+
+

Request

+
+
PUT /studylogs/1 HTTP/1.1
 Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNjY1NDkxMDEzLCJleHAiOjE2NjU0OTQ2MTMsInJvbGUiOiJDUkVXIn0.UDBq0utQ79rotc10U442u76Z6q7Tv-g6GdE0PhjiAB4
 Content-Type: application/json; charset=UTF-8
@@ -1303,13 +2984,13 @@ 

Request

} ], "abilities" : [ ] }
-
-
-
-
-

Response

-
-
+
+
+
+
+

Response

+
+
HTTP/1.1 200 OK
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -1317,27 +2998,27 @@ 

Response

Date: Tue, 11 Oct 2022 12:23:32 GMT Keep-Alive: timeout=60 Connection: keep-alive
-
-
-
-
- +
+

스터디로그 삭제

+
+

Request

+
+
DELETE /studylogs/1 HTTP/1.1
 Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNjY1NDkxMDEyLCJleHAiOjE2NjU0OTQ2MTIsInJvbGUiOiJDUkVXIn0.f4plGdouPTNGTg-1je8w1f92rqzARFYIjFcs_vI7_L4
 Accept: application/json
 Host: localhost:4000
-
-
-
-
-

Response

-
-
+
+
+
+
+

Response

+
+
HTTP/1.1 204 No Content
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -1345,21 +3026,21 @@ 

Response

Date: Tue, 11 Oct 2022 12:23:32 GMT Keep-Alive: timeout=60 Connection: keep-alive
-
-
-
-
-
-
-
-

댓글

-
-
-

댓글 등록

-
-

Request

-
-
+
+
+
+
+
+
+
+

댓글

+
+
+

댓글 등록

+
+

Request

+
+
POST /studylogs/1/comments HTTP/1.1
 Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNjY1NDkxMDIxLCJleHAiOjE2NjU0OTQ2MjEsInJvbGUiOiJDUkVXIn0.vG-9qhbnQHGUPH1F0tL_HJXUJ4WQ-dq8AxwAyDy3vWw
 Content-Type: application/json; charset=UTF-8
@@ -1369,13 +3050,13 @@ 

Request

{ "content" : "댓글의 내용입니다." }
-
-
-
-
-

Response

-
-
+
+
+
+
+

Response

+
+
HTTP/1.1 201 Created
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -1384,25 +3065,25 @@ 

Response

Date: Tue, 11 Oct 2022 12:23:41 GMT Keep-Alive: timeout=60 Connection: keep-alive
-
-
-
-
-
-

댓글 전체 조회

-
-

Request

-
-
+
+
+
+
+
+

댓글 전체 조회

+
+

Request

+
+
GET /studylogs/1/comments HTTP/1.1
 Host: localhost:4000
-
-
-
-
-

Response

-
-
+
+
+
+
+

Response

+
+
HTTP/1.1 200 OK
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -1428,16 +3109,16 @@ 

Response

"createAt" : "2022-10-11 21:23:42" } ] }
-
-
-
-
-
-

댓글 수정

-
-

Request

-
-
+
+
+
+
+
+

댓글 수정

+
+

Request

+
+
PUT /studylogs/1/comments/1 HTTP/1.1
 Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNjY1NDkxMDIxLCJleHAiOjE2NjU0OTQ2MjEsInJvbGUiOiJDUkVXIn0.vG-9qhbnQHGUPH1F0tL_HJXUJ4WQ-dq8AxwAyDy3vWw
 Content-Type: application/json; charset=UTF-8
@@ -1447,13 +3128,13 @@ 

Request

{ "content" : "수정된 댓글의 내용입니다." }
-
-
-
-
-

Response

-
-
+
+
+
+
+

Response

+
+
HTTP/1.1 204 No Content
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -1461,26 +3142,26 @@ 

Response

Date: Tue, 11 Oct 2022 12:23:41 GMT Keep-Alive: timeout=60 Connection: keep-alive
-
-
-
-
-
-

댓글 삭제

-
-

Request

-
-
+
+
+
+
+
+

댓글 삭제

+
+

Request

+
+
DELETE /studylogs/1/comments/1 HTTP/1.1
 Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNjY1NDkxMDIxLCJleHAiOjE2NjU0OTQ2MjEsInJvbGUiOiJDUkVXIn0.vG-9qhbnQHGUPH1F0tL_HJXUJ4WQ-dq8AxwAyDy3vWw
 Host: localhost:4000
-
-
-
-
-

Response

-
-
+
+
+
+
+

Response

+
+
HTTP/1.1 204 No Content
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -1488,21 +3169,21 @@ 

Response

Date: Tue, 11 Oct 2022 12:23:41 GMT Keep-Alive: timeout=60 Connection: keep-alive
-
-
-
-
-
-
-
-

미션

-
-
-

미션 생성 성공

-
-

Request

-
-
+
+
+
+
+
+
+
+

미션

+
+
+

미션 생성 성공

+
+

Request

+
+
POST /missions HTTP/1.1
 Content-Type: application/json; charset=UTF-8
 Host: localhost:4000
@@ -1512,13 +3193,13 @@ 

Request

"name" : "지하철 노선도 미션", "sessionId" : 1 }
-
-
-
-
-

Response

-
-
+
+
+
+
+

Response

+
+
HTTP/1.1 200 OK
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -1538,16 +3219,17 @@ 

Response

"name" : "세션1" } }
-
-
-
-
- +
+

미션 중복 생성 시 실패 +

+
+

Request

+
+
POST /missions HTTP/1.1
 Content-Type: application/json; charset=UTF-8
 Host: localhost:4000
@@ -1557,13 +3239,13 @@ 

Request

"name" : "지하철 노선도 미션", "sessionId" : 1 }
-
-
-
-
-

Response

-
-
+
+
+
+
+

Response

+
+
HTTP/1.1 400 Bad Request
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -1578,25 +3260,25 @@ 

Response

"code" : 3001, "message" : "미션이 중복됩니다." }
-
-
-
-
-
-

미션 목록 조회

-
-

Request

-
-
+
+
+
+
+
+

미션 목록 조회

+
+

Request

+
+
GET /missions HTTP/1.1
 Host: localhost:4000
-
-
-
-
-

Response

-
-
+
+
+
+
+

Response

+
+
HTTP/1.1 200 OK
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -1625,30 +3307,30 @@ 

Response

"name" : "세션1" } } ]
-
-
-
-
-
-
-
-

태그

-
-
-

태그 목록 조회

-
-

Request

-
-
+
+
+
+
+
+
+
+

태그

+
+
+

태그 목록 조회

+
+

Request

+
+
GET /tags HTTP/1.1
 Host: localhost:4000
-
-
-
-
-

Response

-
-
+
+
+
+
+

Response

+
+
HTTP/1.1 200 OK
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -1669,30 +3351,33 @@ 

Response

"id" : 2, "name" : "파이썬" } ]
-
-
-
-
-
-
-
-

필터

-
- +
+
+
+

필터

+
+
+

필터 목록 조회

+
+

HTTP + request

+
+
GET /filters HTTP/1.1
 Host: localhost:8080
-
-
-
-
-

HTTP response

-
-
+
+
+
+
+

HTTP + response

+
+
HTTP/1.1 200 OK
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -1753,31 +3438,31 @@ 

-
-
-
-
-
-
- +
+

스터디로그 오버뷰

+
+
+

멤버 태그 조회

+
+

Request

+
+
GET /members/gracefulBrown/tags HTTP/1.1
 Content-Type: application/json; charset=UTF-8
 Host: localhost:4000
-
-
-
-
-

Response

-
-
+
+
+
+
+

Response

+
+
HTTP/1.1 400 Bad Request
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -1792,26 +3477,27 @@ 

Response

"code" : 1004, "message" : "해당 ID를 가진 멤버가 없습니다." }
-
-
-
-
- +
+

멤버 달력 스터디로그 조회 +

+
+

Request

+
+
GET /members/gracefulBrown/calendar-studylogs?year=2021&month=8 HTTP/1.1
 Content-Type: application/json; charset=UTF-8
 Host: localhost:4000
-
-
-
-
-

Response

-
-
+
+
+
+
+

Response

+
+
HTTP/1.1 400 Bad Request
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -1826,26 +3512,27 @@ 

Response

"code" : 1004, "message" : "해당 ID를 가진 멤버가 없습니다." }
-
-
-
-
- +
+

인기있는 스터디로그 조회 +

+
+

Request

+
+
GET /studylogs/popular HTTP/1.1
 Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNjY1NDkxMDEzLCJleHAiOjE2NjU0OTQ2MTMsInJvbGUiOiJDUkVXIn0.UDBq0utQ79rotc10U442u76Z6q7Tv-g6GdE0PhjiAB4
 Host: localhost:4000
-
-
-
-
-

Response

-
-
+
+
+
+
+

Response

+
+
HTTP/1.1 200 OK
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -2111,21 +3798,22 @@ 

Response

"currPage" : 1 } }
-
-
-
-
-
-
-
-

리포트

-
-
-

리포트 생성

-
-

HTTP request

-
-
+
+
+
+
+
+
+
+

리포트

+
+
+

리포트 생성

+
+

HTTP + request

+
+
POST /reports HTTP/1.1
 Content-Type: application/json;charset=UTF-8
 Content-Type: application/json;charset=UTF-8
@@ -2155,13 +3843,14 @@ 

-
-
-
-
-

HTTP response

-
-
+
+
+
+
+

HTTP + response

+
+
HTTP/1.1 201 Created
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -2264,25 +3953,29 @@ 

-

리포트 목록 조회

-
-

HTTP request

-
-
+
+
+
+

+
+

리포트 목록 조회

+
+

HTTP + request

+
+
GET /members/username/reports HTTP/1.1
 Host: localhost:8080
-
-
-
-
-

HTTP response

-
-
+
+
+
+
+

HTTP + response

+
+
HTTP/1.1 200 OK
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -2312,25 +4005,27 @@ 

-
-
-
-
- +
+

리포트 조회

+
+

HTTP + request

+
+
GET /reports/1 HTTP/1.1
 Host: localhost:8080
-
-
-
-
-

HTTP response

-
-
+
+
+
+
+

HTTP + response

+
+
HTTP/1.1 200 OK
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -2432,16 +4127,17 @@ 

-

리포트 수정

-
-

HTTP request

-
-
+
+
+
+

+
+

리포트 수정

+
+

HTTP + request

+
+
PUT /reports/1 HTTP/1.1
 Content-Type: application/json;charset=UTF-8
 Content-Type: application/json;charset=UTF-8
@@ -2453,106 +4149,113 @@ 

-
-
-
-
-

HTTP response

-
-
+
+
+
+
+

HTTP + response

+
+
HTTP/1.1 200 OK
 Vary: Origin
 Vary: Access-Control-Request-Method
 Vary: Access-Control-Request-Headers
-
-
-
-
-
-

리포트 삭제

-
-

HTTP request

-
-
+
+
+
+
+
+

리포트 삭제

+
+

HTTP + request

+
+
DELETE /reports/1 HTTP/1.1
 Authorization: Bearer accessToken
 Host: localhost:8080
-
-
-
-
-

HTTP response

-
-
+
+
+
+
+

HTTP + response

+
+
HTTP/1.1 204 No Content
 Vary: Origin
 Vary: Access-Control-Request-Method
 Vary: Access-Control-Request-Headers
-
-
-
-
-
-
-
-

역량

-
-
-

기본 역량 등록

-
-
    -
  • -

    백엔드는 be, 프론트엔드는 fe

    -
  • -
  • -

    그 외 값을 입력 시 에러가 발생한다

    -
  • -
-
-
-

HTTP request

-
-
+
+
+
+
+
+
+
+

역량

+
+
+

기본 역량 등록

+
+
    +
  • +

    백엔드는 be, 프론트엔드는 fe

    +
  • +
  • +

    그 외 값을 입력 시 에러가 발생한다

    +
  • +
+
+
+

HTTP + request

+
+
POST /abilities/templates/be HTTP/1.1
 Authorization: Bearer accessToken
 Host: localhost:8080
-
-
-
-
-

HTTP response

-
-
+
+
+
+
+

HTTP + response

+
+
HTTP/1.1 200 OK
 Vary: Origin
 Vary: Access-Control-Request-Method
 Vary: Access-Control-Request-Headers
-
-
-
-
-
-

역량 생성

-
-
    -
  • -

    상위 역량 등록 시 parent값을 null로 둔다

    -
  • -
  • -

    기존에 존재하는 역량 이름을 등록할 수 없다

    -
  • -
  • -

    기존에 존재하는 색상을 등록할 수 없다

    -
  • -
  • -

    하위 역량 등록 시 상위 역량의 색상과 다른 경우 등록할 수 없다

    -
  • -
-
-
-

HTTP request

-
-
+
+
+
+
+
+

역량 생성

+
+
    +
  • +

    상위 역량 등록 시 parent값을 null로 둔다

    +
  • +
  • +

    기존에 존재하는 역량 이름을 등록할 수 없다

    +
  • +
  • +

    기존에 존재하는 색상을 등록할 수 없다

    +
  • +
  • +

    하위 역량 등록 시 상위 역량의 색상과 다른 경우 등록할 수 없다

    +
  • +
+
+
+

HTTP + request

+
+
POST /abilities HTTP/1.1
 Content-Type: application/json;charset=UTF-8
 Content-Type: application/json;charset=UTF-8
@@ -2566,13 +4269,14 @@ 

-
-
-
-
-

HTTP response

-
-
+
+
+
+
+

HTTP + response

+
+
HTTP/1.1 200 OK
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -2587,25 +4291,28 @@ 

-
-
-
-
- +
+

역량 목록 조회

+
+

HTTP + request

+
+
GET /members/username/abilities HTTP/1.1
 Host: localhost:8080
-
-
-
-
-

HTTP response

-
-
+
+
+
+
+

HTTP + response

+
+
HTTP/1.1 200 OK
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -2642,16 +4349,17 @@ 

-
-
-
-
- +
+

역량 수정

+
+

HTTP + request

+
+
PUT /abilities/1 HTTP/1.1
 Content-Type: application/json;charset=UTF-8
 Content-Type: application/json;charset=UTF-8
@@ -2665,67 +4373,72 @@ 

-
-
-
-
-

HTTP response

-
-
+
+
+
+
+

HTTP + response

+
+
HTTP/1.1 200 OK
 Vary: Origin
 Vary: Access-Control-Request-Method
 Vary: Access-Control-Request-Headers
-
-
-
-
-
-

역량 제거

-
-

HTTP request

-
-
+
+
+
+
+
+

역량 제거

+
+

HTTP + request

+
+
DELETE /abilities/1 HTTP/1.1
 Authorization: Bearer accessToken
 Host: localhost:8080
-
-
-
-
-

HTTP response

-
-
+
+
+
+
+

HTTP + response

+
+
HTTP/1.1 200 OK
 Vary: Origin
 Vary: Access-Control-Request-Method
 Vary: Access-Control-Request-Headers
-
-
-
-
-
-

학습로그 역량 갱신

-
-
    -
  • -

    역량은 기본적으로 자식역량을 선택하는 것을 권장한다

    -
  • -
  • -

    선택할 자식 역량이 없는 경우 부모 역량을 선택할 수는 있다

    -
  • -
  • -

    부모 역량과 그 부모 역량의 자식 역량을 선택하는 경우는 어색한 상황이라고 볼 수 있다

    -
  • -
  • -

    자식 역량을 선택한 상황에서 부모 역량을 함께 등록할 수 없다

    -
  • -
-
-
-

HTTP request

-
-
+
+
+
+
+
+

학습로그 역량 갱신

+
+
    +
  • +

    역량은 기본적으로 자식역량을 선택하는 것을 권장한다

    +
  • +
  • +

    선택할 자식 역량이 없는 경우 부모 역량을 선택할 수는 있다

    +
  • +
  • +

    부모 역량과 그 부모 역량의 자식 역량을 선택하는 경우는 어색한 상황이라고 볼 수 있다

    +
  • +
  • +

    자식 역량을 선택한 상황에서 부모 역량을 함께 등록할 수 없다

    +
  • +
+
+
+

HTTP + request

+
+
PUT /studylogs/1/abilities HTTP/1.1
 Content-Type: application/json;charset=UTF-8
 Content-Type: application/json;charset=UTF-8
@@ -2736,13 +4449,15 @@ 

-
-
-
-
-

HTTP response

-
-
+
+
+
+
+

HTTP + response

+
+
HTTP/1.1 200 OK
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -2765,45 +4480,50 @@ 

-
-
-
-
-
-

역량 포함 모든 학습로그 조회

-
-
    -
  • -

    abilityIds : 필수값 아님

    -
  • -
  • -

    페이지네이션 제공

    -
    -
      -
    • -

      page: 페이지 번호

      -
    • -
    • -

      size: 한 페이지 당 갯수

      -
    • -
    -
    -
  • -
-
-
-

HTTP request

-
-
+
+
+
+
+
+

역량 포함 모든 학습로그 + 조회

+
+
    +
  • +

    abilityIds : 필수값 아님

    +
  • +
  • +

    페이지네이션 제공

    +
    +
      +
    • +

      page: 페이지 번호

      +
    • +
    • +

      size: 한 페이지 당 갯수

      +
    • +
    +
    +
  • +
+
+
+

HTTP + request

+
+
GET /members/username/ability-studylogs?abilityIds=1 HTTP/1.1
 Host: localhost:8080
-
-
-
-
-

HTTP response

-
-
+
+
+
+
+

HTTP + response

+
+
HTTP/1.1 200 OK
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -2868,21 +4588,21 @@ 

-
-
-
-
-
-
- +
+

사용자 리액션

+
+
+

사용자 스크랩 등록

+
+

Request

+
+
POST /members/scrap HTTP/1.1
 Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNjY1NDkxMDIwLCJleHAiOjE2NjU0OTQ2MjAsInJvbGUiOiJDUkVXIn0.L-zEa2fDafcY6zGjIJNxv0hUeR0UpUkApKTUb9LtANk
 Content-Type: application/json; charset=UTF-8
@@ -2892,13 +4612,13 @@ 

Request

{ "studylogId" : 1 }
-
-
-
-
-

Response

-
-
+
+
+
+
+

Response

+
+
HTTP/1.1 201 Created
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -2907,26 +4627,26 @@ 

Response

Date: Tue, 11 Oct 2022 12:23:39 GMT Keep-Alive: timeout=60 Connection: keep-alive
-
-
-
-
- +
+

사용자 스크랩 삭제

+
+

Request

+
+
DELETE /members/scrap?studylog=1 HTTP/1.1
 Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNjY1NDkxMDE5LCJleHAiOjE2NjU0OTQ2MTksInJvbGUiOiJDUkVXIn0.i4FXAEj0UsmDgt-EUcz_rL06gjk-iFpBwawZr-p5ktk
 Host: localhost:4000
-
-
-
-
-

Response

-
-
+
+
+
+
+

Response

+
+
HTTP/1.1 204 No Content
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -2934,16 +4654,16 @@ 

Response

Date: Tue, 11 Oct 2022 12:23:39 GMT Keep-Alive: timeout=60 Connection: keep-alive
-
-
-
-
- +
+

사용자 스크랩 조회

+
+

Request

+
+
GET /members/scrap HTTP/1.1
 Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNjY1NDkxMDE5LCJleHAiOjE2NjU0OTQ2MTksInJvbGUiOiJDUkVXIn0.i4FXAEj0UsmDgt-EUcz_rL06gjk-iFpBwawZr-p5ktk
 Content-Type: application/json; charset=UTF-8
@@ -2953,13 +4673,13 @@ 

Request

{ "studylogId" : 1 }
-
-
-
-
-

Response

-
-
+
+
+
+
+

Response

+
+
HTTP/1.1 200 OK
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -3109,27 +4829,28 @@ 

Response

"totalPage" : 1, "currPage" : 1 }
-
-
-
-
- +
+

사용자 스터디로그 좋아요 +

+
+

Request

+
+
POST /studylogs/1/likes HTTP/1.1
 Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNjY1NDkxMDEzLCJleHAiOjE2NjU0OTQ2MTMsInJvbGUiOiJDUkVXIn0.UDBq0utQ79rotc10U442u76Z6q7Tv-g6GdE0PhjiAB4
 Content-Type: application/x-www-form-urlencoded; charset=ISO-8859-1
 Host: localhost:4000
-
-
-
-
-

Response

-
-
+
+
+
+
+

Response

+
+
HTTP/1.1 200 OK
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -3145,26 +4866,27 @@ 

Response

"liked" : true, "likesCount" : 1 }
-
-
-
-
- +
+

사용자 스터디로그 좋아요 + 취소

+
+

Request

+
+
DELETE /studylogs/1/likes HTTP/1.1
 Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNjY1NDkxMDE0LCJleHAiOjE2NjU0OTQ2MTQsInJvbGUiOiJDUkVXIn0.3__Ou2oeqAy8l1sD20foPbynSdv9Lj5_Iu3KcUglcp4
 Host: localhost:4000
-
-
-
-
-

Response

-
-
+
+
+
+
+

Response

+
+
HTTP/1.1 200 OK
 Vary: Origin
 Vary: Access-Control-Request-Method
@@ -3180,21 +4902,22 @@ 

Response

"liked" : false, "likesCount" : 0 }
-
-
-
-
-
-
+
+
+
+
+
+
- + - \ No newline at end of file + diff --git a/backend/src/test/java/wooteco/prolog/article/application/ArticleServiceTest.java b/backend/src/test/java/wooteco/prolog/article/application/ArticleServiceTest.java new file mode 100644 index 000000000..35ba91232 --- /dev/null +++ b/backend/src/test/java/wooteco/prolog/article/application/ArticleServiceTest.java @@ -0,0 +1,158 @@ +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.MEMBER; + +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 wooteco.prolog.article.domain.Article; +import wooteco.prolog.article.domain.ArticleService; +import wooteco.prolog.article.domain.Title; +import wooteco.prolog.article.domain.Url; +import wooteco.prolog.article.domain.repository.ArticleRepository; +import wooteco.prolog.article.ui.ArticleRequest; +import wooteco.prolog.common.exception.BadRequestException; +import wooteco.prolog.login.ui.LoginMember; +import wooteco.prolog.member.application.MemberService; +import wooteco.prolog.member.domain.Member; +import wooteco.prolog.member.domain.Role; + +@ExtendWith(MockitoExtension.class) +class ArticleServiceTest { + + @Mock + private ArticleRepository articleRepository; + @Mock + private MemberService memberService; + @InjectMocks + private ArticleService articleService; + + @DisplayName("아티클을 생성한다.") + @Test + void create_success() { + //given + final ArticleRequest judyRequest = new ArticleRequest("title", "url"); + final Member member = new Member(1L, "username", "nickname", Role.CREW, 1L, "url"); + when(memberService.findById(any())).thenReturn(member); + + final Article article = new Article(member, new Title("title"), new Url("url")); + when(articleRepository.save(any())).thenReturn(article); + final LoginMember judyLogin = new LoginMember(1L, MEMBER); + + //when + articleService.create(judyRequest, judyLogin); + + //then + verify(articleRepository).save(any()); + } + + @DisplayName("아티클을 수정한다.") + @Test + void update_success() { + //given + final Member judy = new Member(1L, "username", "nickname", Role.CREW, 1L, "url"); + final Article judyArticle = new Article(judy, new Title("judyTitle"), new Url("judyUrl")); + when(articleRepository.findById(any())).thenReturn(Optional.of(judyArticle)); + when(memberService.findById(any())).thenReturn(judy); + + final LoginMember judyLogin = new LoginMember(1L, MEMBER); + final ArticleRequest judyChangedRequest = new ArticleRequest("title", "changedUrl"); + + //when + articleService.update(1L, judyChangedRequest, judyLogin); + + //then + assertThat(judyArticle.getUrl().getUrl()).isEqualTo("changedUrl"); + } + + @DisplayName("수정시 id에 해당하는 아티클이 존재하지 않을 때 예외를 발생시킨다.") + @Test + void update_fail_ArticleNotFoundException() { + //given + when(articleRepository.findById(any())).thenReturn(Optional.ofNullable(null)); + + final LoginMember judyLogin = new LoginMember(1L, MEMBER); + final ArticleRequest judyChangedRequest = new ArticleRequest("title", "changedUrl"); + + //when, then + assertThatThrownBy(() -> articleService.update(1L, judyChangedRequest, judyLogin)) + .isInstanceOf(BadRequestException.class); + } + + @DisplayName("수정시 아티클 작성자가 아니라면 예외를 발생시킨다.") + @Test + void update_fail_InvalidArticleAuthorException() { + //given + final Member judy = new Member(1L, "judith", "judy", Role.CREW, 1L, "judyUrl"); + final Member brown = new Member(2L, "brown", "brownie", Role.CREW, 2L, "brownUrl"); + final Article brownArticle = new Article(brown, new Title("brownTitle"), + new Url("brownUrl")); + when(articleRepository.findById(any())).thenReturn(Optional.of(brownArticle)); + + final LoginMember judyLogin = new LoginMember(1L, MEMBER); + when(memberService.findById(any())).thenReturn(judy); + final ArticleRequest judyChangedRequest = new ArticleRequest("title", "changedUrl"); + + //when, then + assertThatThrownBy(() -> articleService.update(1L, judyChangedRequest, judyLogin)) + .isInstanceOf(BadRequestException.class); + } + + @DisplayName("아티클을 삭제한다.") + @Test + void delete_success() { + //given + final Member judy = new Member(1L, "judith", "judy", Role.CREW, 1L, "judyUrl"); + final Article judyArticle = new Article(judy, new Title("judyTitle"), new Url("judyUrl")); + when(articleRepository.findById(any())).thenReturn(Optional.of(judyArticle)); + when(memberService.findById(any())).thenReturn(judy); + final LoginMember judyLogin = new LoginMember(1L, MEMBER); + + //when + articleService.delete(1L, judyLogin); + + //then + verify(articleRepository, atLeastOnce()).delete(judyArticle); + } + + @DisplayName("삭제시 id에 해당하는 아티클이 존재하지 않을 때 예외를 발생시킨다.") + @Test + void delete_fail_ArticleNotFoundException() { + //given + when(articleRepository.findById(any())).thenReturn(Optional.ofNullable(null)); + + final LoginMember judyLogin = new LoginMember(1L, MEMBER); + + //when, then + assertThatThrownBy(() -> articleService.delete(1L, judyLogin)) + .isInstanceOf(BadRequestException.class); + } + + @DisplayName("삭제시 아티클 작성자가 아니라면 예외를 발생시킨다.") + @Test + void delete_fail_InvalidArticleAuthorException() { + //given + final Member judy = new Member(1L, "judith", "judy", Role.CREW, 1L, "judyUrl"); + final Member brown = new Member(2L, "brown", "brownie", Role.CREW, 2L, "brownUrl"); + final Article brownArticle = new Article(brown, new Title("brownTitle"), + new Url("brownUrl")); + when(articleRepository.findById(any())).thenReturn(Optional.of(brownArticle)); + + final LoginMember judyLogin = new LoginMember(1L, MEMBER); + when(memberService.findById(any())).thenReturn(judy); + + //when, then + assertThatThrownBy(() -> articleService.delete(1L, judyLogin)) + .isInstanceOf(BadRequestException.class); + } +} diff --git a/backend/src/test/java/wooteco/prolog/article/domain/ArticleTest.java b/backend/src/test/java/wooteco/prolog/article/domain/ArticleTest.java new file mode 100644 index 000000000..0382a95db --- /dev/null +++ b/backend/src/test/java/wooteco/prolog/article/domain/ArticleTest.java @@ -0,0 +1,98 @@ +package wooteco.prolog.article.domain; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; + +import joptsimple.internal.Strings; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import wooteco.prolog.common.exception.BadRequestException; +import wooteco.prolog.member.domain.Member; +import wooteco.prolog.member.domain.Role; + +class ArticleTest { + + private Member member; + private Title title; + private Url url; + + @BeforeEach + void setUp() { + member = new Member(11L, "username", "nickname", Role.CREW, 101L, "https://"); + title = new Title("title"); + url = new Url("url"); + } + + @DisplayName("아티클을 생성한다.") + @Test + void create_success() { + //given + //when + //then + assertDoesNotThrow(() -> new Article(member, title, url)); + } + + @DisplayName("아티클을 작성자를 검증한다. (작성자일 때)") + @Test + void validateOwner_validOwner() { + //given + final Article article = new Article(member, title, url); + + //when + //then + assertDoesNotThrow(() -> article.validateOwner(member)); + } + + @DisplayName("아티클을 작성자를 검증한다. (작성자가 아닐 때)") + @Test + void validateOwner_invalidOwner() { + //given + final Article article = new Article(member, title, url); + + //when + final Member member2 = new Member(2L, "user2", "nickname2", Role.CREW, 102L, "https://"); + //then + assertThatThrownBy(() -> article.validateOwner(member2)) + .isInstanceOf(BadRequestException.class); + } + + @DisplayName("아티클을 업데이트한다.") + @Test + void update_success() { + //given + final Article article = new Article(member, title, url); + + //when + article.update("newTitle", "newUrl"); + + //then + Assertions.assertThat(article.getTitle()).isEqualTo(new Title("newTitle")); + Assertions.assertThat(article.getUrl()).isEqualTo(new Url("newUrl")); + } + + @DisplayName("유효하지 않은 제목으로 업데이트시 예외를 발생한다.") + @Test + void update_invalidTitle() { + //given + final Article article = new Article(member, title, url); + + //when + //then + assertThatThrownBy(() -> article.update(Strings.repeat('a', 51), "newUrl")) + .isInstanceOf(BadRequestException.class); + } + + @DisplayName("유효하지 않은 URL으로 업데이트시 예외를 발생한다.") + @Test + void update_invalidUrl() { + //given + final Article article = new Article(member, title, url); + + //when + //then + assertThatThrownBy(() -> article.update("newTitle", Strings.repeat('.', 1025))) + .isInstanceOf(BadRequestException.class); + } +} diff --git a/backend/src/test/java/wooteco/prolog/article/domain/TitleTest.java b/backend/src/test/java/wooteco/prolog/article/domain/TitleTest.java new file mode 100644 index 000000000..09cc341dd --- /dev/null +++ b/backend/src/test/java/wooteco/prolog/article/domain/TitleTest.java @@ -0,0 +1,51 @@ +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; +import org.junit.jupiter.params.provider.NullSource; +import org.junit.jupiter.params.provider.ValueSource; +import wooteco.prolog.common.exception.BadRequestException; + +class TitleTest { + + @ParameterizedTest(name = "타이틀이 \"{0}\" 일 때 예외가 발생한다") + @NullSource + @ValueSource(strings = {"", " "}) + void createTitle_fail(final String title) { + //given + //when + //then + assertThatThrownBy(() -> new Title(title)) + .isInstanceOf(BadRequestException.class); + } + + @DisplayName("타이틀의 길이가 최대길이를 초과할 경우 예외가 발생한다") + @Test + void createTitle_fail_overLength() { + //given + final String title = Strings.repeat('.', 51); + + //when + //then + assertThatThrownBy(() -> new Title(title)) + .isInstanceOf(BadRequestException.class); + } + + @DisplayName("타이틀 앞뒤의 공백은 제거되어 저장된다.") + @Test + void trim() { + //given + final String articleTitle = " title "; + + //when + final Title title = new Title(articleTitle); + + //then + assertThat(title.getTitle()).isEqualTo("title"); + } +} diff --git a/backend/src/test/java/wooteco/prolog/article/domain/UrlTest.java b/backend/src/test/java/wooteco/prolog/article/domain/UrlTest.java new file mode 100644 index 000000000..80092dd16 --- /dev/null +++ b/backend/src/test/java/wooteco/prolog/article/domain/UrlTest.java @@ -0,0 +1,44 @@ +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; +import org.junit.jupiter.params.provider.NullSource; +import org.junit.jupiter.params.provider.ValueSource; +import wooteco.prolog.common.exception.BadRequestException; + +class UrlTest { + + @ParameterizedTest(name = "URL이 \"{0}\" 일 때 예외가 발생한다") + @NullSource + @ValueSource(strings = {"", " "}) + void createUrl_fail(final String url) { + assertThatThrownBy(() -> new Url(url)) + .isInstanceOf(BadRequestException.class); + } + + @DisplayName("URL의 길이가 최대길이를 초과할 경우 예외가 발생한다") + @Test + void createUrl_fail_overLength() { + final String url = Strings.repeat('.', 1025); + assertThatThrownBy(() -> new Url(url)) + .isInstanceOf(BadRequestException.class); + } + + @DisplayName("URL 앞뒤의 공백은 제거되어 저장된다.") + @Test + void trim() { + //given + final String articleUrl = " url "; + + //when + final Url url = new Url(articleUrl); + + //then + assertThat(url.getUrl()).isEqualTo("url"); + } +} 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 548c4e24e..5de72137c 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 547f4beb2..837ac5033 100644 --- a/backend/src/test/java/wooteco/prolog/common/DataInitializer.java +++ b/backend/src/test/java/wooteco/prolog/common/DataInitializer.java @@ -1,5 +1,12 @@ 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 org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Profile; @@ -7,14 +14,6 @@ import org.springframework.transaction.annotation.Transactional; import wooteco.support.fake.FakeDocumentRepository; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import javax.sql.DataSource; -import java.sql.DatabaseMetaData; -import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.List; - @Component @Profile("test") public class DataInitializer implements InitializingBean { 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 9dc01a987..42b983b0f 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,11 @@ package wooteco.prolog.common.exception; +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; -import wooteco.prolog.login.excetpion.GithubApiFailException; -import wooteco.prolog.member.exception.MemberNotFoundException; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; class BadRequestCodeTest { @@ -14,8 +13,8 @@ class BadRequestCodeTest { @Test void findByTest() { //given - MemberNotFoundException memberNotFoundException = new MemberNotFoundException(); - GithubApiFailException githubApiFailException = new GithubApiFailException(); + BadRequestException memberNotFoundException = new BadRequestException(MEMBER_NOT_FOUND); + BadRequestException githubApiFailException = new BadRequestException(GITHUB_API_FAIL); //when int githubApiFailExceptionCode = githubApiFailException.getCode(); @@ -25,23 +24,14 @@ void findByTest() { String memberNotFoundExceptionMessage = memberNotFoundException.getMessage(); //then - assertThat(githubApiFailExceptionCode).isEqualTo(BadRequestCode.GITHUB_API_FAIL.getCode()); + assertThat(githubApiFailExceptionCode).isEqualTo(GITHUB_API_FAIL.getCode()); assertThat(githubApiFailExceptionMessage) - .isEqualTo(BadRequestCode.GITHUB_API_FAIL.getMessage()); + .isEqualTo(GITHUB_API_FAIL.getMessage()); assertThat(memberNotFoundExceptionCode) - .isEqualTo(BadRequestCode.MEMBER_NOT_FOUND.getCode()); + .isEqualTo(MEMBER_NOT_FOUND.getCode()); assertThat(memberNotFoundExceptionMessage) - .isEqualTo(BadRequestCode.MEMBER_NOT_FOUND.getMessage()); + .isEqualTo(MEMBER_NOT_FOUND.getMessage()); } - @DisplayName("해당하는 예외가 없을 때 오류가 나는지 확인한다.") - @Test - void failFoundExceptionTest() { - //given - //when - //then - assertThatThrownBy(BadRequestException::new) - .isInstanceOf(NotFoundErrorCodeException.class); - } } 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 71fbc0fa0..1e145824a 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 6370d2bf7..4f9af6627 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,16 @@ 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.login.excetpion.TokenNotValidException; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.member.domain.Role; -import java.util.Date; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; - class JwtTokenProviderTest { @DisplayName("유효하지 않은 JWT 토큰이 입력됐을 때 TokenNotValidException이 발생하는지 확인 ") @@ -34,8 +34,11 @@ void jwtTokenProviderValidationCheck() { //when //then assertThatThrownBy(() -> jwtTokenProvider.extractSubject(expiredToken)) - .isInstanceOf(TokenNotValidException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(TOKEN_NOT_VALID.getMessage()); + assertThatThrownBy(() -> jwtTokenProvider.extractSubject(malformedToken)) - .isInstanceOf(TokenNotValidException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(TOKEN_NOT_VALID.getMessage()); } } 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 688daf9a5..414b25fcb 100644 --- a/backend/src/test/java/wooteco/prolog/login/domain/MemberTest.java +++ b/backend/src/test/java/wooteco/prolog/login/domain/MemberTest.java @@ -1,7 +1,12 @@ package wooteco.prolog.login.domain; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.Arrays; +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; @@ -10,17 +15,9 @@ import wooteco.prolog.member.domain.Role; import wooteco.prolog.studylog.domain.Tag; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.LongStream; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertEquals; - class MemberTest { - private final String empty =""; + private final String empty = ""; @DisplayName("constructor : nickname이 없을 때 loginName으로 대체되는지 확인") @Test @@ -98,7 +95,8 @@ void getMemberTagsWithSort() { final MemberTag memberTag1 = new MemberTag(1L, member, tags.get(0), 1); final MemberTag memberTag2 = new MemberTag(2L, member, tags.get(1), 2); final MemberTag memberTag3 = new MemberTag(3L, member, tags.get(2), 3); - final MemberTags memberTags = new MemberTags(Arrays.asList(memberTag1, memberTag2, memberTag3)); + final MemberTags memberTags = new MemberTags( + Arrays.asList(memberTag1, memberTag2, memberTag3)); final Member modifiedMember = new Member(1L, "a", "member", Role.CREW, 1234L, "imageUrl1", memberTags); diff --git a/backend/src/test/java/wooteco/prolog/member/application/GroupMemberServiceTest.java b/backend/src/test/java/wooteco/prolog/member/application/GroupMemberServiceTest.java index 563385ae5..a15d4ff53 100644 --- a/backend/src/test/java/wooteco/prolog/member/application/GroupMemberServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/member/application/GroupMemberServiceTest.java @@ -42,7 +42,8 @@ void findGroupMemberByGroupId() { when(groupMemberRepository.findByGroupId(any())).thenReturn(ImmutableList.of(groupMember)); //when - final List groupMembers = groupMemberService.findGroupMemberByGroupId(memberGroupId); + final List groupMembers = groupMemberService.findGroupMemberByGroupId( + memberGroupId); //then assertThat(groupMembers).containsExactly(groupMember); 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 8d50ec029..581612966 100644 --- a/backend/src/test/java/wooteco/prolog/member/application/MemberServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/member/application/MemberServiceTest.java @@ -1,5 +1,20 @@ 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.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -9,6 +24,7 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageRequest; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.login.application.dto.GithubProfileResponse; import wooteco.prolog.login.ui.LoginMember; import wooteco.prolog.member.application.dto.MemberResponse; @@ -19,23 +35,6 @@ import wooteco.prolog.member.domain.Member; import wooteco.prolog.member.domain.Role; import wooteco.prolog.member.domain.repository.MemberRepository; -import wooteco.prolog.member.exception.MemberNotAllowedException; -import wooteco.prolog.member.exception.MemberNotFoundException; - -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.assertj.core.api.InstanceOfAssertFactories.future; -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; @ExtendWith(MockitoExtension.class) class MemberServiceTest { @@ -129,7 +128,8 @@ void findById_MemberNotFoundException() { //when, then assertThatThrownBy(() -> memberService.findById(1L)) - .isInstanceOf(MemberNotFoundException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(MEMBER_NOT_FOUND.getMessage()); } @DisplayName("findByUsername() : username을 통해서 Member를 조회할 수 있다.") @@ -158,7 +158,8 @@ void findByUsername_MemberNotFoundException() { //when, then assertThatThrownBy(() -> memberService.findByUsername("a")) - .isInstanceOf(MemberNotFoundException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(MEMBER_NOT_FOUND.getMessage()); } @DisplayName("findMemberResponseByUsername() : username을 통해서 MemberResponse를 조회할 수 있다.") @@ -177,7 +178,8 @@ void findMemberResponseByUsername() { .thenReturn(Optional.of(member)); //when - final MemberResponse foundMemberResponse = memberService.findMemberResponseByUsername(username); + final MemberResponse foundMemberResponse = memberService.findMemberResponseByUsername( + username); //then assertEquals(foundMemberResponse, memberResponse); @@ -195,7 +197,8 @@ void profileIntroResponse() { .thenReturn(Optional.of(member)); //when - final ProfileIntroResponse savedProfileIntroResponse = memberService.findProfileIntro(member.getUsername()); + final ProfileIntroResponse savedProfileIntroResponse = memberService.findProfileIntro( + member.getUsername()); //then assertEquals(savedProfileIntroResponse.getText(), profileIntroResponse.getText()); @@ -206,11 +209,14 @@ void profileIntroResponse() { void updateMember_MemberNotAllowedException_anonymous() { //given final LoginMember loginMember = new LoginMember(LoginMember.Authority.ANONYMOUS); - final MemberUpdateRequest memberUpdateRequest = new MemberUpdateRequest("nickname", "imageUrl"); + final MemberUpdateRequest memberUpdateRequest = new MemberUpdateRequest("nickname", + "imageUrl"); //when, then - assertThatThrownBy(() -> memberService.updateMember(loginMember, "username", memberUpdateRequest)) - .isInstanceOf(MemberNotAllowedException.class); + assertThatThrownBy( + () -> memberService.updateMember(loginMember, "username", memberUpdateRequest)) + .isInstanceOf(BadRequestException.class) + .hasMessage(MEMBER_NOT_ALLOWED.getMessage()); } @DisplayName("updateMember() : 로그인 된 Member와 수정할 Member의 username이 다르면 MemberNotAllowedException이 발생한다.") @@ -222,14 +228,17 @@ void updateMember_MemberNotAllowedException_different_name() { final LoginMember loginMember = new LoginMember(LoginMember.Authority.MEMBER); final Member member = new Member(1L, username, "nickname", Role.CREW, 1L, imageUrl); - final MemberUpdateRequest memberUpdateRequest = new MemberUpdateRequest("changedNickname", imageUrl); + final MemberUpdateRequest memberUpdateRequest = new MemberUpdateRequest("changedNickname", + imageUrl); when(memberRepository.findById(any())) .thenReturn(Optional.of(member)); //when, then - assertThatThrownBy(() -> memberService.updateMember(loginMember, "anotherUsername", memberUpdateRequest)) - .isInstanceOf(MemberNotAllowedException.class); + assertThatThrownBy( + () -> memberService.updateMember(loginMember, "anotherUsername", memberUpdateRequest)) + .isInstanceOf(BadRequestException.class) + .hasMessage(MEMBER_NOT_ALLOWED.getMessage()); } @DisplayName("updateMember() : 로그인 된 Member와 수정할 Member의 username이 같으면 imageUrl과 nickname을 업데이트 할 수 있다.") @@ -269,7 +278,8 @@ void updateProfileIntro_MemberNotAllowedException_anonymous() { //when & then assertThatThrownBy( () -> memberService.updateProfileIntro(loginMember, "username", profileIntroRequest)) - .isInstanceOf(MemberNotAllowedException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(MEMBER_NOT_ALLOWED.getMessage()); } @DisplayName("updateProfileIntro() : 로그인 된 Member와 수정할 Member의 username이 다르면 MemberNotAllowedException이 발생한다.") @@ -287,8 +297,10 @@ void updateProfileIntro_MemberNotAllowedException_different_name() { //then assertThatThrownBy( - () -> memberService.updateProfileIntro(loginMember, "anotherUsername", profileIntroRequest)) - .isInstanceOf(MemberNotAllowedException.class); + () -> memberService.updateProfileIntro(loginMember, "anotherUsername", + profileIntroRequest)) + .isInstanceOf(BadRequestException.class) + .hasMessage(MEMBER_NOT_ALLOWED.getMessage()); } @DisplayName("updateProfileIntro() : 로그인 된 Member와 수정할 Member의 username이 같으면 profileIntro를 업데이트 할 수 있다.") @@ -369,7 +381,6 @@ void findByIdIn() { new Member("username4", "nickname4", Role.CREW, 4L, "imageUrl4") ); - final List ids = Arrays.asList(1L, 2L, 3L, 4L, 5L); when(memberRepository.findByIdIn(ids)) diff --git a/backend/src/test/java/wooteco/prolog/member/domain/MemberGroupTest.java b/backend/src/test/java/wooteco/prolog/member/domain/MemberGroupTest.java index caf644455..c9d0f5b6c 100644 --- a/backend/src/test/java/wooteco/prolog/member/domain/MemberGroupTest.java +++ b/backend/src/test/java/wooteco/prolog/member/domain/MemberGroupTest.java @@ -1,14 +1,12 @@ package wooteco.prolog.member.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.CsvSource; - import static org.assertj.core.api.AssertionsForClassTypes.assertThat; import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; +import org.junit.jupiter.api.Test; + class MemberGroupTest { + private static final MemberGroup ANDROID_GROUP = new MemberGroup(null, " 안드로이드 5기", "A"); private static final MemberGroup BACKEND_GROUP = new MemberGroup(null, " 백엔드 5기", "B"); private static final MemberGroup FRONTEND_GROUP = new MemberGroup(null, " 프론트엔드 5기", "F"); 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 06ea6fe70..81f27d935 100644 --- a/backend/src/test/java/wooteco/prolog/member/domain/MemberTagTest.java +++ b/backend/src/test/java/wooteco/prolog/member/domain/MemberTagTest.java @@ -1,5 +1,8 @@ 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; @@ -8,15 +11,11 @@ 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 Member bebe = new Member(1L, "최원용", "베베", Role.CREW, 1L, "test"); - private static Tag tag = new Tag(1L, "#베베바보"); - private static MemberTag memberTag = new MemberTag(bebe, tag); + private static final Member bebe = new Member(1L, "최원용", "베베", Role.CREW, 1L, "test"); + private static final Tag tag = new Tag(1L, "#베베바보"); + private static final MemberTag memberTag = new MemberTag(bebe, tag); @DisplayName("addCount를 수행하면 count가 증가한다.") @Test diff --git a/backend/src/test/java/wooteco/prolog/member/domain/repository/GroupMemberRepositoryTest.java b/backend/src/test/java/wooteco/prolog/member/domain/repository/GroupMemberRepositoryTest.java index 55ec9bcbf..ef64b761d 100644 --- a/backend/src/test/java/wooteco/prolog/member/domain/repository/GroupMemberRepositoryTest.java +++ b/backend/src/test/java/wooteco/prolog/member/domain/repository/GroupMemberRepositoryTest.java @@ -1,5 +1,7 @@ package wooteco.prolog.member.domain.repository; +import static org.assertj.core.api.Assertions.assertThat; + import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -9,8 +11,6 @@ import wooteco.prolog.member.domain.Role; import wooteco.support.utils.RepositoryTest; -import static org.assertj.core.api.Assertions.assertThat; - @RepositoryTest class GroupMemberRepositoryTest { 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 09481cd3a..adc0bcf04 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,5 +1,8 @@ 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; @@ -7,10 +10,6 @@ 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 { 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 e93df7353..629980719 100644 --- a/backend/src/test/java/wooteco/prolog/roadmap/application/CurriculumServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/roadmap/application/CurriculumServiceTest.java @@ -1,30 +1,31 @@ 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; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.roadmap.application.dto.CurriculumRequest; import wooteco.prolog.roadmap.application.dto.CurriculumResponses; import wooteco.prolog.roadmap.domain.Curriculum; import wooteco.prolog.roadmap.domain.repository.CurriculumRepository; -import wooteco.prolog.roadmap.exception.CurriculumNotFoundException; - -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; @ExtendWith(MockitoExtension.class) class CurriculumServiceTest { + @InjectMocks private CurriculumService curriculumService; @@ -74,7 +75,8 @@ void update_invalid_curriculumNotFound() { //when, then assertThatThrownBy(() -> curriculumService.update(1L, noImpactRequest)) - .isInstanceOf(CurriculumNotFoundException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(CURRICULUM_NOT_FOUND_EXCEPTION.getMessage()); } @DisplayName("요청한 Id 를 가진 커리큘럼이 있으면 새로운 이름으로 업데이트 한다.") @@ -104,7 +106,8 @@ void delete_invalid_curriculumNotFound() { //when, then assertThatThrownBy(() -> curriculumService.delete(1L)) - .isInstanceOf(CurriculumNotFoundException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(CURRICULUM_NOT_FOUND_EXCEPTION.getMessage()); } @DisplayName("요청한 Id 를 가진 커리큘럼이 있으면 삭제한다.") @@ -116,7 +119,6 @@ void delete() { given(curriculumRepository.findById(anyLong())) .willReturn(Optional.of(curriculum)); - //when curriculumService.delete(1L); 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 5943af59f..fbae450bf 100644 --- a/backend/src/test/java/wooteco/prolog/roadmap/application/EssayAnswerServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/roadmap/application/EssayAnswerServiceTest.java @@ -1,14 +1,26 @@ 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; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.member.application.MemberService; import wooteco.prolog.member.domain.Member; -import wooteco.prolog.member.exception.MemberNotFoundException; import wooteco.prolog.roadmap.application.dto.EssayAnswerRequest; import wooteco.prolog.roadmap.application.dto.EssayAnswerUpdateRequest; import wooteco.prolog.roadmap.domain.EssayAnswer; @@ -27,6 +39,7 @@ @ExtendWith(MockitoExtension.class) class EssayAnswerServiceTest { + private static final EssayAnswerRequest ESSAY_ANSWER_REQUEST = new EssayAnswerRequest(1L, null); @Mock @@ -43,20 +56,25 @@ class EssayAnswerServiceTest { @Test void createEssayAnswer_fail_memberServiceFindById() { //given - when(quizRepository.findById(anyLong())).thenReturn(Optional.of(new Quiz(null, "question"))); - when(memberService.findById(anyLong())).thenThrow(MemberNotFoundException.class); + when(quizRepository.findById(anyLong())).thenReturn( + Optional.of(new Quiz(null, "question"))); + when(memberService.findById(anyLong())) + .thenThrow(new BadRequestException(MEMBER_NOT_FOUND)); //expect assertThatThrownBy(() -> essayAnswerService.createEssayAnswer(ESSAY_ANSWER_REQUEST, 1L)) - .isInstanceOf(MemberNotFoundException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(MEMBER_NOT_FOUND.getMessage()); } @DisplayName("createEssayAnswer 정상 요청을 보내면 생성된 essayAnswer 를 생성 하여 Id 를 반환해준다") @Test void createEssayAnswer() { //given - when(quizRepository.findById(anyLong())).thenReturn(Optional.of(new Quiz(null, "question"))); - when(memberService.findById(anyLong())).thenReturn(new Member(null, null, null, null, null)); + when(quizRepository.findById(anyLong())).thenReturn( + Optional.of(new Quiz(null, "question"))); + when(memberService.findById(anyLong())).thenReturn( + new Member(null, null, null, null, null)); //when final Long essayAnswer = essayAnswerService.createEssayAnswer(ESSAY_ANSWER_REQUEST, 1L); @@ -70,7 +88,8 @@ void createEssayAnswer() { void updateEssayAnswer() { //given when(essayAnswerRepository.findById(anyLong())) - .thenReturn(Optional.of(new EssayAnswer(null, null, new Member(null, null, null, 1L, null)))); + .thenReturn( + Optional.of(new EssayAnswer(null, null, new Member(null, null, null, 1L, null)))); when(memberService.findById((anyLong()))) .thenReturn(new Member(null, null, null, 1L, null)); @@ -139,7 +158,8 @@ void getById() { void findByQuizId() { //given when(essayAnswerRepository.findByQuizIdOrderByIdDesc(anyLong())) - .thenReturn(Arrays.asList(new EssayAnswer(null, null, null), new EssayAnswer(null, null, null))); + .thenReturn(Arrays.asList(new EssayAnswer(null, null, null), + new EssayAnswer(null, null, null))); //when final List byQuizId = essayAnswerService.findByQuizId(1L); 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 8e2b5ea80..36477238a 100644 --- a/backend/src/test/java/wooteco/prolog/roadmap/application/KeywordServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/roadmap/application/KeywordServiceTest.java @@ -1,24 +1,27 @@ 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; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.roadmap.application.dto.KeywordCreateRequest; import wooteco.prolog.roadmap.application.dto.KeywordUpdateRequest; import wooteco.prolog.roadmap.domain.Keyword; import wooteco.prolog.roadmap.domain.repository.KeywordRepository; -import wooteco.prolog.roadmap.exception.KeywordNotFoundException; 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.*; - @ExtendWith(MockitoExtension.class) class KeywordServiceTest { @@ -49,7 +52,8 @@ void notExistParentKeyword() { //then assertThatThrownBy(() -> keywordService.createKeyword(1L, request)) - .isInstanceOf(KeywordNotFoundException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(ROADMAP_KEYWORD_NOT_FOUND_EXCEPTION.getMessage()); } @DisplayName("세션 id로 키워드를 생성할 수 있다") @@ -74,7 +78,8 @@ void notExistKeyword() { //then assertThatThrownBy(() -> keywordService.findKeyword(1L, 1L)) - .isInstanceOf(KeywordNotFoundException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(ROADMAP_KEYWORD_NOT_FOUND_EXCEPTION.getMessage()); } @DisplayName("keywordId로 해당 키워드를 찾을 수 있다") @@ -159,7 +164,8 @@ void updateKeyword_fail2() { //then assertThatThrownBy(() -> keywordService.updateKeyword(1L, 1L, request)) - .isInstanceOf(KeywordNotFoundException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(ROADMAP_KEYWORD_NOT_FOUND_EXCEPTION.getMessage()); } @DisplayName("sessionId와 keywordId로 키워드를 삭제할 수 있다") 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 a77800d45..478d1dee1 100644 --- a/backend/src/test/java/wooteco/prolog/roadmap/application/QuizServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/roadmap/application/QuizServiceTest.java @@ -1,5 +1,17 @@ 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 org.mockito.Mockito.when; +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.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -7,6 +19,7 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.roadmap.application.dto.QuizRequest; import wooteco.prolog.roadmap.application.dto.QuizResponse; import wooteco.prolog.roadmap.application.dto.QuizzesResponse; @@ -14,23 +27,10 @@ import wooteco.prolog.roadmap.domain.Quiz; import wooteco.prolog.roadmap.domain.repository.KeywordRepository; import wooteco.prolog.roadmap.domain.repository.QuizRepository; -import wooteco.prolog.roadmap.exception.KeywordOrderException; -import wooteco.prolog.roadmap.exception.QuizNotFoundException; - -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 org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) class QuizServiceTest { + @Mock private KeywordRepository keywordRepository; @@ -50,7 +50,8 @@ void createQuiz_fail_KeywordId() { //when,then assertThatThrownBy(() -> quizService.createQuiz(1L, question)) - .isInstanceOf(KeywordOrderException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage("키워드의 순서는 1 이상이여야 합니다."); } @DisplayName("QuizRequest 를 보내면 해당 Request 의 Question 의 값과 Id 기반으로 찾은 Keyword 의 값을 가진 Quiz를 저장하고 그 Id를 반환한다") @@ -94,7 +95,8 @@ void findQuizzesByKeywordId() { ); //when - final QuizzesResponse quizzesByKeywordId = quizService.findQuizzesByKeywordId(requestKeywordId); + final QuizzesResponse quizzesByKeywordId = quizService.findQuizzesByKeywordId( + requestKeywordId); //then assertAll( @@ -113,7 +115,8 @@ void updateQuiz_fail() { //when,then assertThatThrownBy(() -> quizService.updateQuiz(1L, quizRequest)) - .isInstanceOf(QuizNotFoundException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(ROADMAP_QUIZ_NOT_FOUND_EXCEPTION.getMessage()); } @DisplayName("찾은 quiz 의 question 을 업데이트 한다.") @@ -143,7 +146,8 @@ void deleteQuiz_fail() { //when,then assertThatThrownBy(() -> quizService.deleteQuiz(1L)) - .isInstanceOf(QuizNotFoundException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(ROADMAP_QUIZ_NOT_FOUND_EXCEPTION.getMessage()); } @DisplayName("요청한 quizId 에 매핑되는 quiz 를 저장소에서 삭제한다") @@ -169,7 +173,8 @@ void findById_fail() { //when,then assertThatThrownBy(() -> quizService.findById(1L)) - .isInstanceOf(QuizNotFoundException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(ROADMAP_QUIZ_NOT_FOUND_EXCEPTION.getMessage()); } @DisplayName("요청한 Id 기반으로 Quiz 로 만들어진 QuizResponse 를 반환해준다") 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 dbe30104e..f171d7f9e 100644 --- a/backend/src/test/java/wooteco/prolog/roadmap/domain/CurriculumTest.java +++ b/backend/src/test/java/wooteco/prolog/roadmap/domain/CurriculumTest.java @@ -1,10 +1,12 @@ 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.roadmap.exception.CurriculumInvalidException; +import wooteco.prolog.common.exception.BadRequestException; class CurriculumTest { @@ -12,13 +14,15 @@ class CurriculumTest { @ValueSource(strings = {"", " "}) void 커리큘럼_생성시_이름에_공백이_들어올_경우_예외가_발생한다(String value) { Assertions.assertThatThrownBy(() -> new Curriculum(value)) - .isInstanceOf(CurriculumInvalidException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(CURRICULUM_INVALID_EXCEPTION.getMessage()); } @Test - void 커리큘림_생성시_이름에_null_이_들어올경우_예외가_발생한다() { + void 커리큘럼_생성시_이름에_null_이_들어올경우_예외가_발생한다() { Assertions.assertThatThrownBy(() -> new Curriculum(null)) - .isInstanceOf(CurriculumInvalidException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(CURRICULUM_INVALID_EXCEPTION.getMessage()); } @@ -27,13 +31,16 @@ class CurriculumTest { void 커리큘럼_수정시_이름에_공백이_들어올_경우_예외가_발생한다(String value) { final Curriculum curriculum = new Curriculum("기본값"); Assertions.assertThatThrownBy(() -> curriculum.updateName(value)) - .isInstanceOf(CurriculumInvalidException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(CURRICULUM_INVALID_EXCEPTION.getMessage()); } @Test void 커리큘림_수정시_이름에_null_이_들어올경우_예외가_발생한다() { final Curriculum curriculum = new Curriculum("기본값"); Assertions.assertThatThrownBy(() -> curriculum.updateName(null)) - .isInstanceOf(CurriculumInvalidException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(CURRICULUM_INVALID_EXCEPTION.getMessage()); } + } 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 9c7d6c358..04ffeeac2 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,13 @@ package wooteco.prolog.roadmap.domain; -import org.junit.jupiter.api.Assertions; +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.member.domain.Member; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; - public 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 805bb21f9..d9caa28c7 100644 --- a/backend/src/test/java/wooteco/prolog/roadmap/domain/KeywordTest.java +++ b/backend/src/test/java/wooteco/prolog/roadmap/domain/KeywordTest.java @@ -8,21 +8,21 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; -import wooteco.prolog.common.exception.NotFoundErrorCodeException; -import wooteco.prolog.roadmap.exception.KeywordAndKeywordParentSameException; +import wooteco.prolog.common.exception.BadRequestException; class KeywordTest { private static final Long SESSION_ID = 3L; - private static final Keyword TEST_KEYWORD_JAVA = new Keyword(2L, "자바", "자바에 대한 설명", 1, 5, SESSION_ID, null, null); + private static final Keyword TEST_KEYWORD_JAVA = new Keyword(2L, "자바", "자바에 대한 설명", 1, 5, + SESSION_ID, null, null); //KeywordSeqException 이 발생하지 않고, NotFoundErrorCodeException 발생, 원인 모르겠음... @DisplayName("seq값이 0보다 작거나 같으면 KeywordSeqException을_발생시킨다") @Test void validateSeqTest() { //given,when,then - assertThatThrownBy(() -> new Keyword(1L, "자바", "자바입니다", -1, 1, SESSION_ID, null, null)).isInstanceOf( - NotFoundErrorCodeException.class); + assertThatThrownBy(() -> new Keyword(1L, "자바", "자바입니다", -1, 1, SESSION_ID, null, null)) + .isInstanceOf(BadRequestException.class); } @DisplayName("update가 호출될 때,") @@ -58,10 +58,12 @@ void success() { @Test void fail_seq_not_valid() { //given - Runnable updateKeyword = () -> testKeyword.update(updateName, updateDescription, 0, updateImportance, null); + Runnable updateKeyword = () -> testKeyword.update(updateName, updateDescription, 0, + updateImportance, null); //when,then - assertThatThrownBy(updateKeyword::run).isInstanceOf(NotFoundErrorCodeException.class); + assertThatThrownBy(updateKeyword::run) + .isInstanceOf(BadRequestException.class); } /* @@ -75,11 +77,13 @@ void fail_seq_not_valid() { @Test void fail_parent_equal_keyword_self() { //given - Keyword keyword = new Keyword(3L, "컬렉션", "컬렉션에 대한 설명입니다", 1, 1, SESSION_ID, testKeyword, null); + Keyword keyword = new Keyword(3L, "컬렉션", "컬렉션에 대한 설명입니다", 1, 1, SESSION_ID, testKeyword, + null); Runnable updateKeyword = () -> keyword.update("List", "List에 대한 설명", 1, 1, keyword); //when, then - assertThatThrownBy(updateKeyword::run).isInstanceOf(KeywordAndKeywordParentSameException.class); + assertThatThrownBy(updateKeyword::run) + .isInstanceOf(BadRequestException.class); } } @@ -101,7 +105,8 @@ void return_null() { @Test void return_id() { //given - Keyword keyword = Keyword.createKeyword("컬렉션", "컬렉션에 대한 설명입니다.", 1, 1, SESSION_ID, TEST_KEYWORD_JAVA); + Keyword keyword = Keyword.createKeyword("컬렉션", "컬렉션에 대한 설명입니다.", 1, 1, SESSION_ID, + TEST_KEYWORD_JAVA); //when Long parentId = keyword.getParentIdOrNull(); 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 2b5cfbec8..22a09faca 100644 --- a/backend/src/test/java/wooteco/prolog/roadmap/repository/EssayAnswerRepositoryTest.java +++ b/backend/src/test/java/wooteco/prolog/roadmap/repository/EssayAnswerRepositoryTest.java @@ -1,5 +1,7 @@ package wooteco.prolog.roadmap.repository; +import static org.assertj.core.api.Assertions.assertThat; + import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -11,8 +13,6 @@ import wooteco.prolog.roadmap.domain.repository.EssayAnswerRepository; import wooteco.support.utils.RepositoryTest; -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 548520899..c010def07 100644 --- a/backend/src/test/java/wooteco/prolog/roadmap/repository/KeywordRepositoryTest.java +++ b/backend/src/test/java/wooteco/prolog/roadmap/repository/KeywordRepositoryTest.java @@ -1,5 +1,10 @@ package wooteco.prolog.roadmap.repository; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertAll; + +import java.util.List; +import javax.persistence.EntityManager; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -9,12 +14,6 @@ import wooteco.prolog.session.domain.repository.SessionRepository; import wooteco.support.utils.RepositoryTest; -import javax.persistence.EntityManager; -import java.util.List; - -import static org.assertj.core.api.Assertions.assertThat; -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 cf7eb6420..9b0c5cee8 100644 --- a/backend/src/test/java/wooteco/prolog/roadmap/repository/QuizRepositoryTest.java +++ b/backend/src/test/java/wooteco/prolog/roadmap/repository/QuizRepositoryTest.java @@ -1,5 +1,7 @@ package wooteco.prolog.roadmap.repository; +import java.util.Arrays; +import java.util.List; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -13,9 +15,6 @@ import wooteco.prolog.session.domain.repository.SessionRepository; import wooteco.support.utils.RepositoryTest; -import java.util.Arrays; -import java.util.List; - @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 03b75ba5e..e8579426a 100644 --- a/backend/src/test/java/wooteco/prolog/session/application/MissionServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/session/application/MissionServiceTest.java @@ -1,5 +1,18 @@ 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; @@ -7,27 +20,13 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.login.ui.LoginMember; import wooteco.prolog.session.application.dto.MissionRequest; import wooteco.prolog.session.application.dto.MissionResponse; import wooteco.prolog.session.domain.Mission; import wooteco.prolog.session.domain.Session; import wooteco.prolog.session.domain.repository.MissionRepository; -import wooteco.prolog.studylog.exception.DuplicateMissionException; - -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 { @@ -67,14 +66,15 @@ void create() { void validateName() { // given final MissionRequest request = new MissionRequest("mission1", 1L); - final Optional mission = Optional.of(new Mission("mission1", new Session("session1"))); + final Optional mission = Optional.of( + new Mission("mission1", new Session("session1"))); doReturn(mission) .when(missionRepository).findByName(request.getName()); // when, then assertAll( - () -> assertThrows(DuplicateMissionException.class, () -> missionService.create(request)) + () -> assertThrows(BadRequestException.class, () -> missionService.create(request)) ); } @@ -108,7 +108,8 @@ void findAll() { @Test void findById() { // given - final Optional missionOptional = Optional.of(new Mission("mission1", new Session("session1"))); + final Optional missionOptional = Optional.of( + new Mission("mission1", new Session("session1"))); when(missionRepository.findById(1L)).thenReturn(missionOptional); // when @@ -125,7 +126,8 @@ void findById() { @Test void findMissionById() { // given - final Optional missionOptional = Optional.of(new Mission("mission1", new Session("session1"))); + final Optional missionOptional = Optional.of( + new Mission("mission1", new Session("session1"))); when(missionRepository.findById(1L)).thenReturn(missionOptional); // when @@ -216,15 +218,18 @@ void findAllWithMyMissionFirst() { doReturn(myMissions).when(missionRepository).findBySessionIdIn(Collections.emptyList()); // when - final List responses = missionService.findAllWithMyMissionFirst(loginMember); + final List responses = missionService.findAllWithMyMissionFirst( + loginMember); final MissionResponse myMission = responses.get(0); // then assertAll( () -> assertThat(myMission.getName()).isEqualTo("mission3"), () -> assertThat(myMission.getSession().getName()).isEqualTo("session3"), - () -> assertThat(responses).extracting(MissionResponse::getName).contains("mission1", "mission2", "mission3"), - () -> assertThat(responses).extracting(response -> response.getSession().getName()).contains("session1", "session2", "session3") + () -> assertThat(responses).extracting(MissionResponse::getName) + .contains("mission1", "mission2", "mission3"), + () -> assertThat(responses).extracting(response -> response.getSession().getName()) + .contains("session1", "session2", "session3") ); } @@ -244,15 +249,18 @@ void findAllWithMyMissionFirstReturnFindAll() { doReturn(allMissions).when(missionRepository).findAll(); // when - final List responses = missionService.findAllWithMyMissionFirst(loginMember); + final List responses = missionService.findAllWithMyMissionFirst( + loginMember); final MissionResponse firstResponse = responses.get(0); // then assertAll( () -> assertThat(firstResponse.getName()).isEqualTo("mission1"), () -> assertThat(firstResponse.getSession().getName()).isEqualTo("session1"), - () -> assertThat(responses).extracting(MissionResponse::getName).contains("mission1", "mission2", "mission3"), - () -> assertThat(responses).extracting(response -> response.getSession().getName()).contains("session1", "session2", "session3"), + () -> assertThat(responses).extracting(MissionResponse::getName) + .contains("mission1", "mission2", "mission3"), + () -> assertThat(responses).extracting(response -> response.getSession().getName()) + .contains("session1", "session2", "session3"), () -> assertThat(responses).hasSize(3) ); } 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 54381b466..50ee17c60 100644 --- a/backend/src/test/java/wooteco/prolog/session/application/SessionMemberServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/session/application/SessionMemberServiceTest.java @@ -1,36 +1,34 @@ package wooteco.prolog.session.application; -import org.junit.jupiter.api.Assertions; +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; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import wooteco.prolog.common.exception.NotFoundErrorCodeException; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.member.application.GroupMemberService; import wooteco.prolog.member.application.MemberService; import wooteco.prolog.member.application.dto.MemberResponse; import wooteco.prolog.member.domain.Member; import wooteco.prolog.session.application.dto.SessionGroupMemberRequest; -import wooteco.prolog.session.application.dto.SessionMemberRequest; import wooteco.prolog.session.domain.SessionMember; 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.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 { @@ -76,7 +74,8 @@ void registerMemberFail() { when(sessionRepository.existsById(1L)).thenReturn(false); // when, then - Assertions.assertThrows(NotFoundErrorCodeException.class, () -> sessionMemberService.registerMember(1L, 1L)); + assertThatThrownBy(() -> sessionMemberService.registerMember(1L, 1L)) + .isInstanceOf(BadRequestException.class); } @DisplayName("Members는 GroupId로 회원가입 할 수 있다.") @@ -148,7 +147,8 @@ void deleteRegistedSession() { SessionMember sessionMember = new SessionMember(sessionId, member); doReturn(member).when(memberService).findById(memberId); - doReturn(Optional.of(sessionMember)).when(sessionMemberRepository).findBySessionIdAndMember(sessionId, member); + doReturn(Optional.of(sessionMember)).when(sessionMemberRepository) + .findBySessionIdAndMember(sessionId, member); // when sessionMemberService.deleteRegistedSession(sessionId, memberId); @@ -160,9 +160,8 @@ void deleteRegistedSession() { @Test void deleteRegistedSessionFail() { // when, then - Assertions.assertThrows( - NotFoundErrorCodeException.class, () -> sessionMemberService.deleteRegistedSession(1L, 1L) - ); + assertThatThrownBy(() -> sessionMemberService.deleteRegistedSession(1L, 1L)) + .isInstanceOf(BadRequestException.class); } } 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 50de2b881..f949e3e0f 100644 --- a/backend/src/test/java/wooteco/prolog/session/application/SessionServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/session/application/SessionServiceTest.java @@ -6,7 +6,7 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import wooteco.prolog.common.exception.NotFoundErrorCodeException; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.login.ui.LoginMember; import wooteco.prolog.member.domain.Member; import wooteco.prolog.member.domain.Role; @@ -23,9 +23,12 @@ 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.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.doReturn; +import static wooteco.prolog.common.exception.BadRequestCode.DUPLICATE_SESSION_EXCEPTION; +import static wooteco.prolog.common.exception.BadRequestCode.SESSION_NOT_FOUND_EXCEPTION; import static wooteco.prolog.login.ui.LoginMember.Authority.ANONYMOUS; import static wooteco.prolog.login.ui.LoginMember.Authority.MEMBER; @@ -64,7 +67,9 @@ void createFail() { doReturn(session).when(sessionRepository).findByName(request.getName()); // when, then - assertThrows(NotFoundErrorCodeException.class, () -> sessionService.create(request)); + assertThatThrownBy(() -> sessionService.create(request)) + .isInstanceOf(BadRequestException.class) + .hasMessage(DUPLICATE_SESSION_EXCEPTION.getMessage()); } @DisplayName("유효한 Id를 매개변수로 Id Session을 조회한다.") @@ -84,7 +89,9 @@ void findById() { @Test void findByIdFail() { // when, then - assertThrows(NotFoundErrorCodeException.class, () -> sessionService.findById(1L)); + assertThatThrownBy(() -> sessionService.findById(1L)) + .isInstanceOf(BadRequestException.class) + .hasMessage(SESSION_NOT_FOUND_EXCEPTION.getMessage()); } @DisplayName("Id로 Optional을 조회한다.") 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 5a35e20e8..03da23658 100644 --- a/backend/src/test/java/wooteco/prolog/session/domain/MissionTest.java +++ b/backend/src/test/java/wooteco/prolog/session/domain/MissionTest.java @@ -1,11 +1,12 @@ 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.studylog.exception.TooLongMissionNameException; +import wooteco.prolog.common.exception.BadRequestException; class MissionTest { @@ -22,6 +23,7 @@ void validateMaxlengthTest() { final Supplier initialMission = () -> new Mission(sb.toString(), TEST_SESSION); //when, then - assertThatThrownBy(initialMission::get).isInstanceOf(TooLongMissionNameException.class); + assertThatThrownBy(initialMission::get).isInstanceOf(BadRequestException.class) + .hasMessage(TOO_LONG_MISSION_NAME.getMessage()); } } 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 b270f4b6b..76cf061d9 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,20 +1,20 @@ package wooteco.prolog.session.domain.repository; +import static org.assertj.core.api.Assertions.assertThat; +import static wooteco.prolog.common.exception.BadRequestCode.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; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.member.domain.Member; import wooteco.prolog.member.domain.Role; import wooteco.prolog.member.domain.repository.MemberRepository; import wooteco.prolog.session.domain.Session; import wooteco.prolog.session.domain.SessionMember; -import wooteco.prolog.session.exception.SessionNotFoundException; import wooteco.support.utils.RepositoryTest; -import java.util.Optional; - -import static org.assertj.core.api.Assertions.assertThat; - @RepositoryTest class SessionMemberRepositoryTest { @@ -42,7 +42,8 @@ void findSessionMemberBySessionIdAndMemberId() { // then assertThat(result.isPresent()).isTrue(); - assertThat(result.orElseThrow(SessionNotFoundException::new)).isEqualTo(현구막_백엔드_레벨1); + assertThat(result.orElseThrow( + () -> new BadRequestException(SESSION_NOT_FOUND_EXCEPTION))).isEqualTo(현구막_백엔드_레벨1); } private Session 강의_생성(String name) { 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 785594784..00715c137 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/application/CommentServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/application/CommentServiceTest.java @@ -5,6 +5,9 @@ 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; @@ -16,10 +19,10 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.member.domain.Member; import wooteco.prolog.member.domain.Role; import wooteco.prolog.member.domain.repository.MemberRepository; -import wooteco.prolog.member.exception.MemberNotFoundException; import wooteco.prolog.session.domain.Mission; import wooteco.prolog.session.domain.Session; import wooteco.prolog.studylog.application.dto.CommentMemberResponse; @@ -32,8 +35,6 @@ import wooteco.prolog.studylog.domain.Tag; import wooteco.prolog.studylog.domain.repository.CommentRepository; import wooteco.prolog.studylog.domain.repository.StudylogRepository; -import wooteco.prolog.studylog.exception.CommentNotFoundException; -import wooteco.prolog.studylog.exception.StudylogNotFoundException; @ExtendWith(MockitoExtension.class) class CommentServiceTest { @@ -83,7 +84,8 @@ void insertComment_fail_memberNotExist() { //when //then assertThatThrownBy(() -> commentService.insertComment(댓글_저장_요청)) - .isInstanceOf(MemberNotFoundException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(MEMBER_NOT_FOUND.getMessage()); } @DisplayName("댓글을 저장할 때 스터디 로그가 존재하지 않으면 예외가 발생한다.") @@ -99,7 +101,8 @@ void insertComment_fail_studylogNotExist() { //when //then assertThatThrownBy(() -> commentService.insertComment(댓글_저장_요청)) - .isInstanceOf(StudylogNotFoundException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(STUDYLOG_NOT_FOUND.getMessage()); } @DisplayName("특정 스터디 로그의 모든 댓글을 조회한다.") @@ -151,7 +154,8 @@ void findComments_fail_studylogNotExist() { //when //then assertThatThrownBy(() -> commentService.findComments(1L)) - .isInstanceOf(StudylogNotFoundException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(STUDYLOG_NOT_FOUND.getMessage()); } @DisplayName("특정 학습로그의 특정 멤버의 댓글이 수정될 시 댓글의 아이디를 반환한다.") @@ -193,7 +197,8 @@ void updateComment_fail_memberNotExist() { //when //then assertThatThrownBy(() -> commentService.updateComment(commentUpdateRequest)) - .isInstanceOf(MemberNotFoundException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(MEMBER_NOT_FOUND.getMessage()); } @DisplayName("수정하려는 댓글의 학습로그가 존재하지 않으면 예외가 발생한다.") @@ -209,7 +214,8 @@ void updateComment_fail_studylogNotExist() { //when //then assertThatThrownBy(() -> commentService.updateComment(commentUpdateRequest)) - .isInstanceOf(StudylogNotFoundException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(STUDYLOG_NOT_FOUND.getMessage()); } @DisplayName("수정하려는 댓글이 존재하지 않으면 예외가 발생한다.") @@ -226,7 +232,8 @@ void updateComment_fail_commentNotExist() { //when //then assertThatThrownBy(() -> commentService.updateComment(commentUpdateRequest)) - .isInstanceOf(CommentNotFoundException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(COMMENT_NOT_FOUND.getMessage()); } @DisplayName("특정 학습로그의 특정 멤버의 댓글을 삭제시 댓글의 삭제 상태를 true로 업데이트한다.") @@ -261,7 +268,8 @@ void deleteComment_fail_memberNotExist() { //when //then assertThatThrownBy(() -> commentService.deleteComment(1L, 1L, 1L)) - .isInstanceOf(MemberNotFoundException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(MEMBER_NOT_FOUND.getMessage()); } @DisplayName("삭제하려는 댓글의 학습로그가 존재하지 않으면 예외가 발생한다.") @@ -274,7 +282,8 @@ void deleteComment_fail_studylogNotExist() { //when //then assertThatThrownBy(() -> commentService.deleteComment(1L, 1L, 1L)) - .isInstanceOf(StudylogNotFoundException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(STUDYLOG_NOT_FOUND.getMessage()); } @DisplayName("삭제하려는 댓글이 존재하지 않으면 예외가 발생한다.") @@ -288,6 +297,7 @@ void deleteComment_fail_commentNotExist() { //when //then assertThatThrownBy(() -> commentService.deleteComment(1L, 1L, 1L)) - .isInstanceOf(CommentNotFoundException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(COMMENT_NOT_FOUND.getMessage()); } } diff --git a/backend/src/test/java/wooteco/prolog/studylog/application/FakeStudylogDocumentServiceTest.java b/backend/src/test/java/wooteco/prolog/studylog/application/FakeStudylogDocumentServiceTest.java index 7ada62bf5..68f1eb9c7 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/application/FakeStudylogDocumentServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/application/FakeStudylogDocumentServiceTest.java @@ -9,6 +9,7 @@ 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; @@ -16,7 +17,6 @@ import wooteco.prolog.studylog.domain.Tags; import wooteco.prolog.studylog.domain.repository.StudylogDocumentRepository; import wooteco.prolog.studylog.domain.repository.StudylogRepository; -import wooteco.prolog.studylog.exception.StudylogDocumentNotFoundException; import java.time.LocalDate; import java.time.LocalDateTime; @@ -28,6 +28,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.*; +import static wooteco.prolog.common.exception.BadRequestCode.*; @ExtendWith(MockitoExtension.class) class FakeStudylogDocumentServiceTest { @@ -62,7 +63,9 @@ void findById_Exception() { //when & then assertThatThrownBy(() -> fakeStudylogDocumentService.findById(1L)) - .isInstanceOf(StudylogDocumentNotFoundException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(STUDYLOG_DOCUMENT_NOT_FOUND.getMessage()); + } @DisplayName("StudylogDocument id로 조회 성공 테스트") 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 14d90ba1e..554edd009 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/application/FilterServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/application/FilterServiceTest.java @@ -1,5 +1,11 @@ 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; @@ -17,13 +23,6 @@ import wooteco.prolog.studylog.application.dto.FilterResponse; import wooteco.prolog.studylog.application.dto.TagResponse; -import java.util.ArrayList; -import java.util.List; - -import static org.assertj.core.api.Assertions.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.doReturn; - @ExtendWith(MockitoExtension.class) class FilterServiceTest { @@ -53,7 +52,8 @@ void showAll() { doReturn(sessionResponses).when(sessionService).findAllWithMySessionFirst(loginMember); List missionResponses = new ArrayList<>(); - missionResponses.add(new MissionResponse(1L, "mission1", new wooteco.prolog.session.application.dto.SessionResponse(1L, "session1"))); + missionResponses.add(new MissionResponse(1L, "mission1", + new wooteco.prolog.session.application.dto.SessionResponse(1L, "session1"))); doReturn(missionResponses).when(missionService).findAllWithMyMissionFirst(loginMember); List tagResponses = new ArrayList<>(); 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 ba29ab8ae..613a07bd8 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/application/StudylogLikeServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/application/StudylogLikeServiceTest.java @@ -3,6 +3,8 @@ 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; @@ -11,6 +13,7 @@ import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.mockito.Mockito; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.member.application.MemberService; import wooteco.prolog.member.domain.Member; import wooteco.prolog.member.domain.Role; @@ -18,8 +21,6 @@ import wooteco.prolog.session.domain.Session; import wooteco.prolog.studylog.domain.Studylog; import wooteco.prolog.studylog.domain.repository.StudylogRepository; -import wooteco.prolog.studylog.exception.InvalidLikeRequestException; -import wooteco.prolog.studylog.exception.InvalidUnlikeRequestException; public class StudylogLikeServiceTest { @@ -62,8 +63,9 @@ public void success() { public void fail_because_member_not_valid() { //given, when, then assertThatThrownBy( - () -> studylogLikeService.likeStudylog(1L, 1L, false) - ).isInstanceOf(InvalidLikeRequestException.class); + () -> studylogLikeService.likeStudylog(1L, 1L, false)) + .isInstanceOf(BadRequestException.class) + .hasMessage(INVALID_LIKE_REQUEST_EXCEPTION.getMessage()); } } @@ -80,8 +82,8 @@ public void fail_because_like_not_exist() { //when, then assertThatThrownBy(() -> studylogLikeService.unlikeStudylog(1L, 1L, true)) - .isInstanceOf(InvalidUnlikeRequestException.class); - + .isInstanceOf(BadRequestException.class) + .hasMessage(INVALID_UNLIKE_REQUEST_EXCEPTION.getMessage()); } @DisplayName("멤버_아이디가_유효하지_않을_때_InvalidLikeRequestException이_발생한다") @@ -89,8 +91,9 @@ public void fail_because_like_not_exist() { public void fail_because_member_not_valid() { //given, when, then assertThatThrownBy( - () -> studylogLikeService.unlikeStudylog(1L, 1L, false) - ).isInstanceOf(InvalidLikeRequestException.class); + () -> studylogLikeService.unlikeStudylog(1L, 1L, false)) + .isInstanceOf(BadRequestException.class) + .hasMessage(INVALID_LIKE_REQUEST_EXCEPTION.getMessage()); } } 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 53962f47f..c4c107485 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/application/StudylogScrapServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/application/StudylogScrapServiceTest.java @@ -7,6 +7,11 @@ 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.MEMBER_NOT_FOUND; +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; @@ -20,12 +25,12 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageRequest; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.member.application.dto.MemberResponse; import wooteco.prolog.member.application.dto.MemberScrapResponse; import wooteco.prolog.member.domain.Member; import wooteco.prolog.member.domain.Role; import wooteco.prolog.member.domain.repository.MemberRepository; -import wooteco.prolog.member.exception.MemberNotFoundException; import wooteco.prolog.session.domain.Mission; import wooteco.prolog.session.domain.Session; import wooteco.prolog.studylog.application.dto.StudylogResponse; @@ -35,9 +40,6 @@ import wooteco.prolog.studylog.domain.Tag; import wooteco.prolog.studylog.domain.repository.StudylogRepository; import wooteco.prolog.studylog.domain.repository.StudylogScrapRepository; -import wooteco.prolog.studylog.exception.StudylogNotFoundException; -import wooteco.prolog.studylog.exception.StudylogScrapAlreadyRegisteredException; -import wooteco.prolog.studylog.exception.StudylogScrapNotExistException; @ExtendWith(MockitoExtension.class) class StudylogScrapServiceTest { @@ -80,7 +82,8 @@ void registerScrap_success() { //then assertAll( - () -> assertThat(memberScrapResponse.getMemberResponse().getId()).isEqualTo(멤버_스플릿.getId()), + () -> assertThat(memberScrapResponse.getMemberResponse().getId()).isEqualTo( + 멤버_스플릿.getId()), () -> assertThat(memberScrapResponse.getStudylogResponse().getContent()) .isEqualTo(스플릿_학습로그.getContent())); } @@ -95,7 +98,8 @@ void registerScrap_fail_scrapExist() { //when //then assertThatThrownBy(() -> studylogScrapService.registerScrap(1L, 2L)) - .isInstanceOf(StudylogScrapAlreadyRegisteredException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(STUDYLOG_SCRAP_ALREADY_REGISTERED_EXCEPTION.getMessage()); } @DisplayName("학습로그 스크랩 등록 시 등록하려는 학습로그가 존재하지 않으면 예외가 발생한다.") @@ -110,7 +114,8 @@ void registerScrap_fail_studylogNotExist() { //when //then assertThatThrownBy(() -> studylogScrapService.registerScrap(1L, 2L)) - .isInstanceOf(StudylogNotFoundException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(STUDYLOG_NOT_FOUND.getMessage()); } @DisplayName("학습로그 스크랩 등록 시 멤버가 존재하지 않으면 예외가 발생한다.") @@ -137,7 +142,8 @@ void registerScrap_fail_memberNotExist() { //when //then assertThatThrownBy(() -> studylogScrapService.registerScrap(1L, 2L)) - .isInstanceOf(MemberNotFoundException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(MEMBER_NOT_ALLOWED.getMessage()); } @DisplayName("학습로그 스크랩을 등록 해제한다.") @@ -174,8 +180,9 @@ void unregisterScrap_fail_scrapNotExist() { //when //then - assertThatThrownBy(() -> studylogScrapService.unregisterScrap(1L, 1L)) - .isInstanceOf(StudylogScrapNotExistException.class); + assertThatThrownBy(() -> studylogScrapService.unregisterScrap(1L, 1L)) + .isInstanceOf(BadRequestException.class) + .hasMessage(STUDYLOG_SCRAP_NOT_EXIST_EXCEPTION.getMessage()); } @@ -194,7 +201,6 @@ void showScrap_success() { final Tag 스프링_태그 = new Tag("Spring"); final List 자바_스프링_태그_목록 = Arrays.asList(자바_태그, 스프링_태그); - final Studylog 스플릿_학습로그 = new Studylog(멤버_스플릿, "title", "content", 자동차_미션, 자바_스프링_태그_목록); final Studylog 져니_학습로그 = new Studylog(멤버_져니, "title", "content", 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 fb2c8fc74..e3cede2d0 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/application/StudylogServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/application/StudylogServiceTest.java @@ -14,6 +14,8 @@ import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.domain.Specification; +import wooteco.prolog.common.exception.BadRequestCode; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.login.ui.LoginMember; import wooteco.prolog.member.application.MemberService; import wooteco.prolog.member.application.MemberTagService; @@ -50,9 +52,6 @@ import wooteco.prolog.studylog.domain.repository.StudylogTempRepository; import wooteco.prolog.studylog.domain.repository.dto.CommentCount; import wooteco.prolog.studylog.event.StudylogDeleteEvent; -import wooteco.prolog.studylog.exception.AuthorNotValidException; -import wooteco.prolog.studylog.exception.StudylogArgumentException; -import wooteco.prolog.studylog.exception.StudylogNotFoundException; import java.lang.reflect.Field; import java.time.LocalDate; @@ -79,6 +78,7 @@ 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.*; @ExtendWith(MockitoExtension.class) class StudylogServiceTest { @@ -293,7 +293,8 @@ void updateScrap() { void insertStudyLogs_fail() { //when, then assertThatThrownBy(() -> studylogService.insertStudylogs(1L, emptyList())) - .isInstanceOf(StudylogArgumentException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(STUDYLOG_ARGUMENT.getMessage()); } @DisplayName("스터디로그 여러 개를 저장할 수 있다") @@ -325,7 +326,8 @@ void findStudylogById() { //when, then assertThatThrownBy(() -> studylogService.findStudylogById(1L)) - .isInstanceOf(StudylogNotFoundException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(STUDYLOG_NOT_FOUND.getMessage()); } @Nested @@ -460,7 +462,8 @@ void deleteStudylog_exception_notExistingStudylog() { //when, then assertThatThrownBy(() -> studylogService.deleteStudylog(1L, 1L)) - .isInstanceOf(StudylogNotFoundException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(STUDYLOG_NOT_FOUND.getMessage()); } @DisplayName("자신이 것이 아닌 스터디 로그를 삭제하면 예외가 발생한다") @@ -474,7 +477,8 @@ void deleteStudylog_exception_notMine() { //when, then assertThatThrownBy(() -> studylogService.deleteStudylog(2L, 1L)) - .isInstanceOf(AuthorNotValidException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(ONLY_AUTHOR_CAN_EDIT.getMessage()); } @DisplayName("해당 StudyLog 에 대한 스크랩과 Read 와 함께 StudyLog 를 삭제한다.") @@ -539,7 +543,8 @@ void updateStudylogMission_exception_notExistingStudylog() { //when, then assertThatThrownBy(() -> studylogService.updateStudylogMission(1L, 1L, null)) - .isInstanceOf(StudylogNotFoundException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(STUDYLOG_NOT_FOUND.getMessage()); } @DisplayName("자신의 스터디로그가 아니라면 예외가 발생한다.") @@ -551,7 +556,8 @@ void updateStudylogMission_exception_notMine() { //when, then assertThatThrownBy(() -> studylogService.updateStudylogMission(2L, 1L, null)) - .isInstanceOf(AuthorNotValidException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(ONLY_AUTHOR_CAN_EDIT.getMessage()); } @DisplayName("스터디로그의 미션을 업데이트한다.") 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 d00120ecb..3dbce67be 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/application/StudylogSessionServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/application/StudylogSessionServiceTest.java @@ -22,6 +22,7 @@ @ExtendWith(MockitoExtension.class) class StudylogSessionServiceTest { + @Mock private StudylogRepository studylogRepository; @InjectMocks 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 05684f3e6..5ac3750f4 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/application/StudylogTagServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/application/StudylogTagServiceTest.java @@ -29,7 +29,8 @@ class StudylogTagServiceTest { private static final List TAG_LIST = ImmutableList.of(TAG_JAVA, TAG_JCF); private static final Member MEMBER = new Member(1L, "홍혁준", "홍실", Role.CREW, 1234L, "imageUrl"); private static final Session SESSION = new Session("2023 백엔드 레벨 1"); - private static final Studylog STUDYLOG = new Studylog(MEMBER, "페이지 이름", "페이지 내용", SESSION, null, TAG_LIST); + private static final Studylog STUDYLOG = new Studylog(MEMBER, "페이지 이름", "페이지 내용", SESSION, null, + TAG_LIST); @Mock private StudylogTagRepository studylogTagRepository; 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 4b2d610f6..cb8479b1d 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/application/TagServiceTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/application/TagServiceTest.java @@ -37,8 +37,10 @@ class TagServiceTest { private static final TagRequest COLLECTION_TAG_REQUEST = new TagRequest("컬렉션"); private static final Session TEST_SESSION = new Session(4L, 5L, "세션"); private static final Mission TEST_MISSION = new Mission(6L, "레벨 2 - 웹 자동차 경주", TEST_SESSION); - private static final Member TEST_MEMBER_CREW1 = new Member(1L, "홍혁준", "홍실", Role.CREW, 2L, null, null); - private static final Studylog TEST_STUDYLOG1 = new Studylog(TEST_MEMBER_CREW1, "레벨 1 레벨인터뷰", "레벨인터뷰에 대한 내용입니다.", + private static final Member TEST_MEMBER_CREW1 = new Member(1L, "홍혁준", "홍실", Role.CREW, 2L, null, + null); + private static final Studylog TEST_STUDYLOG1 = new Studylog(TEST_MEMBER_CREW1, "레벨 1 레벨인터뷰", + "레벨인터뷰에 대한 내용입니다.", TEST_MISSION, Collections.emptyList()); @Mock 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 eb009b8d8..04fbf1270 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/domain/CommentTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/domain/CommentTest.java @@ -1,16 +1,16 @@ 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; import wooteco.prolog.member.domain.Member; import wooteco.prolog.member.domain.Role; import wooteco.prolog.session.domain.Mission; import wooteco.prolog.session.domain.Session; -import wooteco.prolog.studylog.exception.CommentDeleteException; - -import java.util.Arrays; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; public class CommentTest { @@ -28,6 +28,7 @@ void delete() { comment.delete(); assertThatThrownBy(() -> comment.delete()) - .isInstanceOf(CommentDeleteException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(COMMENT_DELETE_EXCEPTION.getMessage()); } } 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 d66a5e0f1..b9ec148a1 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/domain/StudylogTagsTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/domain/StudylogTagsTest.java @@ -1,5 +1,10 @@ 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; @@ -9,17 +14,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, "https://avatars.githubusercontent.com/u/51393021?v=4"); - private static final Studylog 웨지가_쓴_글 = new Studylog(웨지, "제목", "내용", new Mission("[BE] 글쓰기 미션", new Session("세션1")), Lists.emptyList()); + private static final Studylog 웨지가_쓴_글 = new Studylog(웨지, "제목", "내용", + new Mission("[BE] 글쓰기 미션", new Session("세션1")), Lists.emptyList()); private static final Tag 워니_태그 = new Tag("워니"); private static final StudylogTag 워니_스터디로그_태그 = new StudylogTag(1L, 웨지가_쓴_글, 워니_태그); @@ -47,7 +47,9 @@ void addTest() { this.studylogTags.add(studylogTags); // then - assertThat(this.studylogTags.getValues()).containsExactlyInAnyOrder(this.워니_스터디로그_태그, 세션1_스터디로그_태그); + assertThat(this.studylogTags.getValues()).containsExactlyInAnyOrder( + StudylogTagsTest.워니_스터디로그_태그, + 세션1_스터디로그_태그); } @DisplayName("update로 StudylogTag 리스트를 교체한다.") @@ -66,6 +68,7 @@ void updateTest() { this.studylogTags.update(studylogTags); // then - assertThat(this.studylogTags.getValues()).containsExactlyInAnyOrder(포비_스터디로그_태그, 세션1_스터디로그_태그); + assertThat(this.studylogTags.getValues()).containsExactlyInAnyOrder(포비_스터디로그_태그, + 세션1_스터디로그_태그); } } 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 8c629a864..f00f7f584 100644 --- a/backend/src/test/java/wooteco/prolog/studylog/domain/StudylogTest.java +++ b/backend/src/test/java/wooteco/prolog/studylog/domain/StudylogTest.java @@ -1,25 +1,26 @@ 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; +import wooteco.prolog.common.exception.BadRequestException; import wooteco.prolog.member.domain.Member; import wooteco.prolog.member.domain.Role; import wooteco.prolog.session.domain.Mission; import wooteco.prolog.session.domain.Session; -import wooteco.prolog.studylog.exception.AuthorNotValidException; - -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; class StudylogTest { + private static final Long SELF_MEMBER_ID = 1L; private static final Long OTHER_MEMBER_ID = 2L; @@ -51,7 +52,7 @@ void validateBelongTo_success() { @Test void update() { // given - Tags tags = newTags("new Java","new Spring"); + Tags tags = newTags("new Java", "new Spring"); List studylogTag = tags.getList().stream() .map(tag -> new StudylogTag(studylog, tag)) .collect(Collectors.toList()); @@ -76,14 +77,15 @@ void validateBelongTo_fail() { // when, then assertThatThrownBy(() -> studylog.validateBelongTo(OTHER_MEMBER_ID)) - .isInstanceOf(AuthorNotValidException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(ONLY_AUTHOR_CAN_EDIT.getMessage()); } @DisplayName("스터디로그에 정상적으로 태그를 추가한다.") @Test void addTags() { // given - Tags tags = newTags("new Java","new Spring"); + Tags tags = newTags("new Java", "new Spring"); studylog = new Studylog(member, "제목", "내용", mission, Arrays.asList(tag1, tag2)); // when @@ -217,7 +219,7 @@ void getStudylogTags() { assertThat(studylog.getStudylogTags()).isEqualTo(studylogTags); } - private Tags newTags(String... values){ + private Tags newTags(String... values) { List tags = new ArrayList<>(); for (String value : values) { tags.add(new Tag(value)); 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 4266d3cb6..713e843cb 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,5 +1,10 @@ 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 org.assertj.core.util.Lists; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -16,12 +21,6 @@ import wooteco.prolog.studylog.domain.Studylog; import wooteco.support.utils.RepositoryTest; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -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 3e9e7dfdb..9206a24a2 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,5 +1,9 @@ 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; @@ -16,11 +20,6 @@ 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 { @@ -53,7 +52,8 @@ void createStudylogTag() { Session session = sessionRepository.save(new Session("세션1")); Mission mission = missionRepository.save(new Mission("미션", session)); Tag tag = tagRepository.save(new Tag("태그")); - Studylog studylog = studylogRepository.save(new Studylog(member, "제목", "내용", mission, Lists.emptyList())); + Studylog studylog = studylogRepository.save( + new Studylog(member, "제목", "내용", mission, Lists.emptyList())); // when StudylogTag studylogTag = new StudylogTag(studylog, tag); @@ -86,7 +86,8 @@ void findByTagIn() { StudylogTag studylogTag3 = studylogTagRepository.save(new StudylogTag(studylog2, tag2)); // when - List studylogTags = studylogTagRepository.findByTagIn(Arrays.asList(tag1, tag2)); + List studylogTags = studylogTagRepository.findByTagIn( + Arrays.asList(tag1, tag2)); // then assertThat(studylogTags).usingFieldByFieldElementComparator() @@ -101,7 +102,8 @@ void findByTagInEmpty() { Tag tag2 = tagRepository.save(new Tag("태그2")); // when - List studylogTags = studylogTagRepository.findByTagIn(Arrays.asList(tag1, tag2)); + List studylogTags = studylogTagRepository.findByTagIn( + Arrays.asList(tag1, tag2)); // then assertThat(studylogTags).isEmpty(); 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 c6e200687..362476ead 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,5 +1,8 @@ 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; @@ -10,10 +13,6 @@ 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 37ee78bab..3a8eb1444 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,11 +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 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.Content; -import wooteco.prolog.studylog.exception.StudylogContentNullOrEmptyException; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; class ContentTest { @@ -15,13 +17,15 @@ void contentTest() { //given String empty = ""; String justBlank = " "; - //when - //then + //when, then assertThatThrownBy(() -> new Content(empty)) - .isInstanceOf(StudylogContentNullOrEmptyException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(STUDYLOG_CONTENT_NULL_OR_EMPTY.getMessage()); assertThatThrownBy(() -> new Content(justBlank)) - .isInstanceOf(StudylogContentNullOrEmptyException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(STUDYLOG_CONTENT_NULL_OR_EMPTY.getMessage()); assertThatThrownBy(() -> new Content(null)) - .isInstanceOf(StudylogContentNullOrEmptyException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(STUDYLOG_CONTENT_NULL_OR_EMPTY.getMessage()); } } 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 9d1aaff81..687beb5bd 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,13 +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.login.excetpion.StudylogTitleNullOrEmptyException; +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; - class TitleTest { @DisplayName("값이 null이거나 empty면 예외") @@ -19,11 +20,14 @@ void titleTest() { //when //then assertThatThrownBy(() -> new Title(empty)) - .isExactlyInstanceOf(StudylogTitleNullOrEmptyException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(STUDYLOG_TITLE_NULL_OR_EMPTY.getMessage()); assertThatThrownBy(() -> new Title(justBlank)) - .isExactlyInstanceOf(StudylogTitleNullOrEmptyException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(STUDYLOG_TITLE_NULL_OR_EMPTY.getMessage()); assertThatThrownBy(() -> new Title(null)) - .isExactlyInstanceOf(StudylogTitleNullOrEmptyException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(STUDYLOG_TITLE_NULL_OR_EMPTY.getMessage()); } @DisplayName("생성") 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 6e99bb644..8d8dcc3ce 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,5 +1,9 @@ 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; @@ -18,11 +22,6 @@ 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 { @@ -68,8 +67,10 @@ void existsByMemberIdAndStudylogId() { StudylogRead studylogRead = new StudylogRead(bada, studylog); //when studylogReadRepository.save(studylogRead); - boolean expectTrue = studylogReadRepository.existsByMemberIdAndStudylogId(bada.getId(), studylog.getId()); - boolean expectFalse = studylogReadRepository.existsByMemberIdAndStudylogId(member.getId(), studylog.getId()); + boolean expectTrue = studylogReadRepository.existsByMemberIdAndStudylogId(bada.getId(), + studylog.getId()); + boolean expectFalse = studylogReadRepository.existsByMemberIdAndStudylogId(member.getId(), + studylog.getId()); //then assertThat(expectTrue).isTrue(); assertThat(expectFalse).isFalse(); 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 03d0bc8d1..0637796cd 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,5 +1,7 @@ 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; @@ -18,8 +20,6 @@ import wooteco.prolog.studylog.domain.repository.StudylogScrapRepository; import wooteco.support.utils.RepositoryTest; -import static org.assertj.core.api.Assertions.assertThat; - @RepositoryTest public class StudylogScrapRepositoryTest { 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 5e9a4ecaf..9ba13acb6 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,5 +1,12 @@ 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 org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import wooteco.prolog.session.application.MissionService; @@ -14,17 +21,9 @@ import wooteco.prolog.studylog.application.dto.TagRequest; import wooteco.prolog.studylog.domain.Tags; -import javax.annotation.PostConstruct; -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("자동차", "전략 패턴", "부릉"))), + Arrays.asList("자동차", "전략 패턴", "부릉"))), 로또_미션_정리("로또 미션 정리", "따르르릉 로또", "로또 미션", "임파시블세션", Tags.of(Arrays.asList("로또", "TDD", "랜덤"))); @Component @@ -41,21 +40,22 @@ public static class InjectHelper { @PostConstruct void init() { allOf(StudylogFixture.class) - .forEach(container -> container - .injectMissionService(missionService, sessionService, missionRepository)); + .forEach(container -> container + .injectMissionService(missionService, sessionService, missionRepository)); } } - private String title; - private String content; - private String missionName; - private String sessionName; - private Tags tags; + private final String title; + private final String content; + private final String missionName; + private final String sessionName; + private final Tags tags; private MissionService missionService; private SessionService sessionService; private MissionRepository missionRepository; - StudylogFixture(String title, String content, String missionName, String sessionName, Tags tags) { + StudylogFixture(String title, String content, String missionName, String sessionName, + Tags tags) { this.title = title; this.content = content; this.missionName = missionName; @@ -77,16 +77,16 @@ public StudylogRequest asRequestWithTags(List tagRequests) { public StudylogRequest asRequest(long missionId) { final List tagRequests = tags.getList().stream() - .map(tag -> new TagRequest(tag.getName())) - .collect(Collectors.toList()); + .map(tag -> new TagRequest(tag.getName())) + .collect(Collectors.toList()); return new StudylogRequest(title, content, missionId, tagRequests); } public StudylogRequest asRequest() { final List tagRequests = tags.getList().stream() - .map(tag -> new TagRequest(tag.getName())) - .collect(Collectors.toList()); + .map(tag -> new TagRequest(tag.getName())) + .collect(Collectors.toList()); return asRequestWithTags(tagRequests); } @@ -97,12 +97,12 @@ private MissionResponse createMission(String missionName, String sessionName) { if (missionOptional.isPresent()) { final Mission mission = missionOptional.get(); return new MissionResponse(mission.getId(), mission.getName(), - new SessionResponse(mission.getSession().getId(), mission.getSession().getName())); + new SessionResponse(mission.getSession().getId(), mission.getSession().getName())); } final SessionResponse sessionResponse = sessionService.findAll().stream() - .filter(lr -> lr.getName().equals(sessionName)) - .findAny().orElseGet(() -> sessionService.create(new SessionRequest(sessionName))); + .filter(lr -> lr.getName().equals(sessionName)) + .findAny().orElseGet(() -> sessionService.create(new SessionRequest(sessionName))); return missionService.create(new MissionRequest(missionName, sessionResponse.getId())); } } 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 031b0662d..aef876591 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,5 +1,10 @@ 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; @@ -13,20 +18,14 @@ 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, - "https://avatars.githubusercontent.com/u/51393021?v=4"); + "https://avatars.githubusercontent.com/u/51393021?v=4"); private static final Studylog 웨지가_쓴_글 = new Studylog(웨지, "제목", "내용", - new Mission("[BE] 글쓰기 미션", - new Session("세션1")), - Lists.emptyList()); + new Mission("[BE] 글쓰기 미션", + new Session("세션1")), + Lists.emptyList()); private static final Tag 워니_태그 = new Tag("워니"); private static final StudylogTag 워니_스터디로그태그 = new StudylogTag(1L, 웨지가_쓴_글, 워니_태그); private StudylogTags studylogTags; @@ -53,8 +52,9 @@ void addTest() { this.studylogTags.add(studylogTags); // then - assertThat(this.studylogTags.getValues()).containsExactlyInAnyOrder(this.워니_스터디로그태그, - 세션1_스터디로그태그); + assertThat(this.studylogTags.getValues()).containsExactlyInAnyOrder( + StudylogTagsTest.워니_스터디로그태그, + 세션1_스터디로그태그); } @DisplayName("update로 StudylogTag 리스트를 교체한다.") @@ -74,6 +74,6 @@ void updateTest() { // then assertThat(this.studylogTags.getValues()).containsExactlyInAnyOrder(포비_스터디로그태그, - 세션1_스터디로그태그); + 세션1_스터디로그태그); } } 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 082cd458a..922518e51 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,5 +1,9 @@ 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; @@ -19,16 +23,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 StudylogTagRepositoryTest { private static final Member 웨지 = new Member("sihyung92", "웨지", Role.CREW, 2222L, - "https://avatars.githubusercontent.com/u/51393021?v=4"); + "https://avatars.githubusercontent.com/u/51393021?v=4"); @Autowired private StudylogTagRepository studylogTagRepository; 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 48d059502..bb2255895 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,12 +1,13 @@ 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 wooteco.prolog.studylog.exception.TagNameNullOrEmptyException; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; class TagNameTest { @@ -19,11 +20,14 @@ void tagNameNullOrEmptyTest() { //when //then assertThatThrownBy(() -> new TagName(empty)) - .isExactlyInstanceOf(TagNameNullOrEmptyException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(TAG_NAME_NULL_OR_EMPTY.getMessage()); assertThatThrownBy(() -> new TagName(justBlank)) - .isExactlyInstanceOf(TagNameNullOrEmptyException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(TAG_NAME_NULL_OR_EMPTY.getMessage()); assertThatThrownBy(() -> new TagName(null)) - .isExactlyInstanceOf(TagNameNullOrEmptyException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(TAG_NAME_NULL_OR_EMPTY.getMessage()); } @DisplayName("생성") 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 0d5d5b43b..e267a4571 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,16 +1,16 @@ 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 wooteco.prolog.studylog.exception.DuplicateTagException; - -import java.util.Arrays; -import java.util.List; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; class TagsTest { @@ -38,7 +38,8 @@ void tagsCreateTestWhenDuplicateTagName() { //then assertThatThrownBy(() -> new Tags(tags)) - .isExactlyInstanceOf(DuplicateTagException.class); + .isInstanceOf(BadRequestException.class) + .hasMessage(DUPLICATE_TAG.getMessage()); } @DisplayName("Tags 간 이름비교를 통한 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 cc71472ed..5e893eb93 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,5 +1,9 @@ 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; @@ -7,11 +11,6 @@ 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 0242eed63..856327aea 100644 --- a/backend/src/test/java/wooteco/support/autoceptor/AutoInterceptorPatternMakerTest.java +++ b/backend/src/test/java/wooteco/support/autoceptor/AutoInterceptorPatternMakerTest.java @@ -1,13 +1,12 @@ 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 bedd7b3f4..30590b059 100644 --- a/backend/src/test/java/wooteco/support/autoceptor/ClassScannerTest.java +++ b/backend/src/test/java/wooteco/support/autoceptor/ClassScannerTest.java @@ -1,5 +1,8 @@ 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; @@ -7,10 +10,6 @@ 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 43d940163..c17533a77 100644 --- a/backend/src/test/java/wooteco/support/autoceptor/ControllerScannerTest.java +++ b/backend/src/test/java/wooteco/support/autoceptor/ControllerScannerTest.java @@ -1,5 +1,8 @@ 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; @@ -7,10 +10,6 @@ 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 bd6c7c558..b2e1b274c 100644 --- a/backend/src/test/java/wooteco/support/autoceptor/MappingAnnotationTest.java +++ b/backend/src/test/java/wooteco/support/autoceptor/MappingAnnotationTest.java @@ -1,5 +1,12 @@ 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; @@ -10,14 +17,6 @@ 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/MethodScannerTest.java b/backend/src/test/java/wooteco/support/autoceptor/MethodScannerTest.java index 99a0c183d..4175ac911 100644 --- a/backend/src/test/java/wooteco/support/autoceptor/MethodScannerTest.java +++ b/backend/src/test/java/wooteco/support/autoceptor/MethodScannerTest.java @@ -1,20 +1,19 @@ package wooteco.support.autoceptor; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import wooteco.prolog.login.domain.AuthMemberPrincipal; -import wooteco.support.autoceptor.scanner.MethodScanner; -import wooteco.support.autoceptor.test_classes.ControllerClass; -import wooteco.support.autoceptor.test_classes.RestControllerClass; +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 static java.util.stream.Collectors.toList; -import static org.assertj.core.api.Assertions.assertThat; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import wooteco.prolog.login.domain.AuthMemberPrincipal; +import wooteco.support.autoceptor.scanner.MethodScanner; +import wooteco.support.autoceptor.test_classes.ControllerClass; +import wooteco.support.autoceptor.test_classes.RestControllerClass; class MethodScannerTest { diff --git a/backend/src/test/java/wooteco/support/autoceptor/URIScannerTest.java b/backend/src/test/java/wooteco/support/autoceptor/URIScannerTest.java index e16acf11b..6f1a8a1e0 100644 --- a/backend/src/test/java/wooteco/support/autoceptor/URIScannerTest.java +++ b/backend/src/test/java/wooteco/support/autoceptor/URIScannerTest.java @@ -1,5 +1,10 @@ package wooteco.support.autoceptor; +import static org.assertj.core.api.Assertions.assertThat; + +import java.lang.annotation.Annotation; +import java.util.Collections; +import java.util.List; import org.junit.jupiter.api.Test; import wooteco.prolog.login.domain.AuthMemberPrincipal; import wooteco.support.autoceptor.scanner.ControllerScanner; @@ -8,12 +13,6 @@ import wooteco.support.autoceptor.test_classes.ControllerClass; import wooteco.support.autoceptor.test_classes.RestControllerClass; -import java.lang.annotation.Annotation; -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 480fc57ac..1e41921e4 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,5 +1,6 @@ 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; @@ -7,8 +8,6 @@ import wooteco.prolog.login.domain.AuthMemberPrincipal; import wooteco.prolog.member.domain.Member; -import javax.websocket.server.PathParam; - @RequestMapping("/api2") @Controller public class ControllerClass { diff --git a/backend/src/test/java/wooteco/support/utils/RepositoryTest.java b/backend/src/test/java/wooteco/support/utils/RepositoryTest.java index ff684c9e5..571c8f536 100644 --- a/backend/src/test/java/wooteco/support/utils/RepositoryTest.java +++ b/backend/src/test/java/wooteco/support/utils/RepositoryTest.java @@ -1,12 +1,11 @@ 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/frontend/.prettierrc b/frontend/.prettierrc index e9eb8060d..cf52c1996 100644 --- a/frontend/.prettierrc +++ b/frontend/.prettierrc @@ -1,5 +1,7 @@ { - "printWidth": 100, - "singleQuote": true, - "endOfLine": "auto" + "printWidth": 100, + "singleQuote": true, + "endOfLine": "auto", + "tabWidth": 2, + "useTabs": false } diff --git a/frontend/src/App.js b/frontend/src/App.tsx similarity index 100% rename from frontend/src/App.js rename to frontend/src/App.tsx diff --git a/frontend/src/GlobalStyles.js b/frontend/src/GlobalStyles.js deleted file mode 100644 index 9681420af..000000000 --- a/frontend/src/GlobalStyles.js +++ /dev/null @@ -1,117 +0,0 @@ -import { css, Global } from '@emotion/react'; -import COLOR from './constants/color'; -import MEDIA_QUERY from './constants/mediaQuery'; - -const GlobalStyles = () => { - const scrollbarWidth = window.innerWidth - document.body.clientWidth; - - return -}; - -export default GlobalStyles; diff --git a/frontend/src/GlobalStyles.tsx b/frontend/src/GlobalStyles.tsx new file mode 100644 index 000000000..9ad1120c2 --- /dev/null +++ b/frontend/src/GlobalStyles.tsx @@ -0,0 +1,118 @@ +import { css, Global } from '@emotion/react'; +import COLOR from './constants/color'; + +const GlobalStyles = () => { + const scrollbarWidth = window.innerWidth - document.body.clientWidth; + + return ( + + ); +}; + +export default GlobalStyles; diff --git a/frontend/src/assets/lotties/index.js b/frontend/src/assets/lotties/index.js deleted file mode 100644 index 74f51274d..000000000 --- a/frontend/src/assets/lotties/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import NotFoundAnimation from './not-found.json'; - -export { NotFoundAnimation }; diff --git a/frontend/src/assets/lotties/index.ts b/frontend/src/assets/lotties/index.ts new file mode 100644 index 000000000..14ff2c46b --- /dev/null +++ b/frontend/src/assets/lotties/index.ts @@ -0,0 +1 @@ +export { default as NotFoundAnimation } from './not-found.json'; diff --git a/frontend/src/components/@shared/Icons/CancelIcon.js b/frontend/src/components/@shared/Icons/CancelIcon.tsx similarity index 56% rename from frontend/src/components/@shared/Icons/CancelIcon.js rename to frontend/src/components/@shared/Icons/CancelIcon.tsx index 0083ba8ab..1c7f6cfff 100644 --- a/frontend/src/components/@shared/Icons/CancelIcon.js +++ b/frontend/src/components/@shared/Icons/CancelIcon.tsx @@ -1,6 +1,11 @@ -import React from 'react'; +interface CancelIconProps { + width: string; + height: string; + stroke: string; + strokeWidth?: string; +} -const CancelIcon = ({ width, height, stroke, strokeWidth }) => { +const CancelIcon = ({ width, height, stroke, strokeWidth }: CancelIconProps) => { return ( {children}; - -SnackBar.propTypes = { - children: PropTypes.string.isRequired, -}; - -export default SnackBar; diff --git a/frontend/src/components/@shared/SnackBar/SnackBar.styles.js b/frontend/src/components/@shared/SnackBar/SnackBar.styles.ts similarity index 100% rename from frontend/src/components/@shared/SnackBar/SnackBar.styles.js rename to frontend/src/components/@shared/SnackBar/SnackBar.styles.ts diff --git a/frontend/src/components/@shared/SnackBar/SnackBar.tsx b/frontend/src/components/@shared/SnackBar/SnackBar.tsx new file mode 100644 index 000000000..c18be6337 --- /dev/null +++ b/frontend/src/components/@shared/SnackBar/SnackBar.tsx @@ -0,0 +1,5 @@ +import { Container } from './SnackBar.styles'; + +const SnackBar = ({ children }: { children: string }) => {children}; + +export default SnackBar; diff --git a/frontend/src/components/Button/Button.js b/frontend/src/components/Button/Button.js deleted file mode 100644 index 18674d9a3..000000000 --- a/frontend/src/components/Button/Button.js +++ /dev/null @@ -1,49 +0,0 @@ -import PropTypes from 'prop-types'; -import { BUTTON_SIZE, Container, Icon, Image } from './Button.styles'; - -const Button = ({ - children, - size, - alt, - icon, - css, - cssProps, - backgroundImageUrl, - onClick, - type, - disabled, -}) => { - return ( - - {icon && } - {backgroundImageUrl && } - {children && {children}} - - ); -}; - -Button.propTypes = { - children: PropTypes.node, - size: PropTypes.string, - alt: PropTypes.string, - icon: PropTypes.string, - css: PropTypes.object, - cssProps: PropTypes.object, - backgroundImageUrl: PropTypes.string, - onClick: PropTypes.func, - type: PropTypes.string, - disabled: PropTypes.bool, -}; - -Button.defaultProps = { - size: BUTTON_SIZE.MEDIUM, -}; - -export default Button; diff --git a/frontend/src/components/Button/Button.styles.js b/frontend/src/components/Button/Button.styles.ts similarity index 90% rename from frontend/src/components/Button/Button.styles.js rename to frontend/src/components/Button/Button.styles.ts index 9609d04d0..d90cf37ab 100644 --- a/frontend/src/components/Button/Button.styles.js +++ b/frontend/src/components/Button/Button.styles.ts @@ -65,7 +65,7 @@ const imageSizeStyle = { }, }; -const Container = styled.button` +const Container = styled.button<{ size: string; css: {} }>` display: flex; justify-content: center; align-items: center; @@ -78,13 +78,13 @@ const Container = styled.button` ${({ css }) => css}; `; -const Icon = styled.img` +const Icon = styled.img<{ hasText: boolean; size: string }>` margin-right: ${({ hasText }) => (hasText ? '0.5em' : '0')}; ${({ size }) => imageSizeStyle[size] || imageSizeStyle.MEDIUM}; `; -const Image = styled.div` +const Image = styled.div<{ backgroundImage: string }>` background-image: url(${({ backgroundImage }) => backgroundImage}); background-size: contain; width: inherit; diff --git a/frontend/src/components/Button/Button.tsx b/frontend/src/components/Button/Button.tsx new file mode 100644 index 000000000..9ca9cf53b --- /dev/null +++ b/frontend/src/components/Button/Button.tsx @@ -0,0 +1,38 @@ +import { SerializedStyles } from '@emotion/react'; +import { BUTTON_SIZE, Container, Icon, Image } from './Button.styles'; + +interface ButtonProps { + children?: React.ReactNode; + size?: string; + alt?: string; + icon?: string; + css?: SerializedStyles; + cssProps?: SerializedStyles; + backgroundImageUrl?: string; + type?: 'button' | 'submit' | 'reset'; + disabled?: boolean; + onClick?: React.MouseEventHandler; +} + +const Button = ({ + children, + size = BUTTON_SIZE.MEDIUM, + alt = '', + icon, + css = { name: '', styles: '' }, + cssProps, + backgroundImageUrl, + type, + disabled, + onClick, +}: ButtonProps) => { + return ( + + {icon && } + {backgroundImageUrl && } + {children && {children}} + + ); +}; + +export default Button; diff --git a/frontend/src/components/Button/PageButton.js b/frontend/src/components/Button/PageButton.tsx similarity index 71% rename from frontend/src/components/Button/PageButton.js rename to frontend/src/components/Button/PageButton.tsx index f70fbfdec..024b62550 100644 --- a/frontend/src/components/Button/PageButton.js +++ b/frontend/src/components/Button/PageButton.tsx @@ -1,8 +1,20 @@ -import React from 'react'; import Button from './Button'; import { css } from '@emotion/react'; import COLOR from '../../constants/color'; +interface PageButtonProps extends React.HTMLAttributes { + children: number; + selected?: boolean; +} + +const PageButton = ({ children, ...props }: PageButtonProps) => { + return ( + + ); +}; + const selectedStyle = css` background-color: ${COLOR.DARK_BLUE_800}; color: ${COLOR.WHITE}; @@ -13,12 +25,4 @@ const unselectedStyle = css` color: ${COLOR.BLACK_800}; `; -const PageButton = ({ children, ...props }) => { - return ( - - ); -}; - export default PageButton; diff --git a/frontend/src/components/Calendar/Calendar.styles.js b/frontend/src/components/Calendar/Calendar.styles.ts similarity index 90% rename from frontend/src/components/Calendar/Calendar.styles.js rename to frontend/src/components/Calendar/Calendar.styles.ts index 31caf36e9..d7ad4191d 100644 --- a/frontend/src/components/Calendar/Calendar.styles.js +++ b/frontend/src/components/Calendar/Calendar.styles.ts @@ -55,7 +55,12 @@ const WeekWrapper = styled.ul` height: 5rem; `; -const Week = styled.strong` +interface WeekProps { + isSunday: boolean; + isSaturday: boolean; +} + +const Week = styled.strong` font-size: 1.4rem; ${({ isSunday, isSaturday }) => css` @@ -85,7 +90,15 @@ const ListItem = styled.li` text-align: center; `; -const Day = styled.button` +interface DayProps { + isSunday: boolean; + isSaturday: boolean; + isHover: boolean; + isSelected: boolean; + count: number; +} + +const Day = styled.button` position: relative; user-select: none; cursor: pointer; @@ -145,7 +158,11 @@ const Day = styled.button` `} `; -const TitleList = styled.div` +interface TitleListProp { + isRight: boolean; +} + +const TitleList = styled.div` position: absolute; top: -0.5rem; border: 1px solid #ccc; diff --git a/frontend/src/components/Calendar/Calendar.js b/frontend/src/components/Calendar/Calendar.tsx similarity index 83% rename from frontend/src/components/Calendar/Calendar.js rename to frontend/src/components/Calendar/Calendar.tsx index ad7d86c6f..7aca68fb2 100644 --- a/frontend/src/components/Calendar/Calendar.js +++ b/frontend/src/components/Calendar/Calendar.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import { useEffect, useState } from 'react'; import { CalendarWrapper, Year, @@ -17,11 +17,11 @@ import { ReactComponent as ArrowIcon } from '../../assets/images/right-arrow-ang import { requestGetCalendar } from '../../service/requests'; import { useParams } from 'react-router'; -const getStartDayOfMonth = (year, month) => { +const getStartDayOfMonth = (year: number, month: number) => { return new Date(year, month, 1).getDay(); }; -const isLeapYear = (year) => { +const isLeapYear = (year: number) => { return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0; }; @@ -30,17 +30,29 @@ const DAYS_LEAP = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; const WEEK = ['일', '월', '화', '수', '목', '금', '토']; const MONTHS = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']; -const Calendar = ({ newDate, onClick = () => {}, selectedDay = -1, setSelectedDay = () => {} }) => { +interface CalenderProps { + newDate: { + year: number; + month: number; + day: number; + }; + onClick: (year: number, month: number, day: number) => void; + selectedDay: number; + setSelectedDay: React.Dispatch>; +} + +const Calendar = ({ newDate, onClick, selectedDay = -1, setSelectedDay }: CalenderProps) => { const today = newDate ? new Date(newDate.year, newDate.month - 1, newDate.day) : new Date(); - const [date, setDate] = useState(today); + const [date, setDate] = useState(today); const [currentMonth, setCurrentMonth] = useState(date.getMonth()); const [currentYear, setCurrentYear] = useState(date.getFullYear()); const [startDay, setStartDay] = useState(getStartDayOfMonth(currentYear, currentMonth)); - const [titleList, setTitleList] = useState([]); - const [titleListIndex, setTitleListIndex] = useState(null); + // any type 수정 필요 + const [titleList, setTitleList] = useState([]); + const [titleListIndex, setTitleListIndex] = useState(null); - const { username } = useParams(); + const { username } = useParams<{ username: string }>(); const days = isLeapYear(currentYear) ? DAYS_LEAP : DAYS; @@ -51,24 +63,25 @@ const Calendar = ({ newDate, onClick = () => {}, selectedDay = -1, setSelectedDa const { data: titleData } = await response.json(); - const data = []; + const data: number[] = []; [...Array(days[currentMonth])].forEach((_, index) => { const day = index + 1; - const firstIndex = titleData.findIndex( + const firstIndex: number = titleData.findIndex( ({ createdAt }) => day === Number(createdAt.slice(8, 10)) ); - const lastIndex = titleData.findIndex( + const lastIndex: number = titleData.findIndex( ({ createdAt }) => day < Number(createdAt.slice(8, 10)) ); - data.push( + const filteredData = firstIndex !== -1 ? titleData.slice(firstIndex, lastIndex === -1 ? titleData.length : lastIndex) - : [] - ); + : []; + + data.push(filteredData); }); setTitleList(data); @@ -126,7 +139,7 @@ const Calendar = ({ newDate, onClick = () => {}, selectedDay = -1, setSelectedDa ))} - {[...Array(days[currentMonth] + startDay)].map((_, index) => { + {[...Array(days[currentMonth] + startDay)].map((_, index: number) => { const day = index - (startDay - 1); const isSunday = index % 7 === 0; const isThursday = index % 7 === 4; diff --git a/frontend/src/components/Card/Card.js b/frontend/src/components/Card/Card.js deleted file mode 100644 index be9e378f7..000000000 --- a/frontend/src/components/Card/Card.js +++ /dev/null @@ -1,29 +0,0 @@ -import PropTypes from 'prop-types'; -import { CARD_SIZE, Container, Title } from './Card.styles'; - -const Card = ({ title, children, size, cssProps, css, onClick }) => { - return ( -
- {title && {title} } - - {children} - -
- ); -}; - -Card.propTypes = { - children: PropTypes.node.isRequired, - title: PropTypes.string, - size: PropTypes.string, - cssProps: PropTypes.object, - css: PropTypes.object, - onClick: PropTypes.func, -}; - -Card.defaultProps = { - title: '', - size: CARD_SIZE.SMALL, -}; - -export default Card; diff --git a/frontend/src/components/Card/Card.stories.js b/frontend/src/components/Card/Card.stories.js deleted file mode 100644 index 70581e117..000000000 --- a/frontend/src/components/Card/Card.stories.js +++ /dev/null @@ -1,24 +0,0 @@ -import Card, { SIZE } from './Card'; - -export default { - title: 'Component/Card', - component: Card, - argTypes: { - size: { options: Object.values(SIZE), control: { type: 'select' } }, - }, -}; - -const Template = (args) => ; - -export const Basic = Template.bind({}); - -Basic.args = { - children:
hello
, -}; - -export const Large = Template.bind({}); - -Large.args = { - children:
hello
, - size: 'LARGE', -}; diff --git a/frontend/src/components/Card/Card.stories.tsx b/frontend/src/components/Card/Card.stories.tsx new file mode 100644 index 000000000..10a76b2db --- /dev/null +++ b/frontend/src/components/Card/Card.stories.tsx @@ -0,0 +1,26 @@ +import Card from './Card'; +import { CARD_SIZE } from './Card.styles'; + +interface Props { + children: JSX.Element; + size: string; +} + +export default { + title: 'Component/Card', + component: Card, + args: { + size: 'SMALL', + }, + argTypes: { + size: { options: Object.values(CARD_SIZE), control: { type: 'select' } }, + }, +}; + +export const Default = (args: Props) => { + return ( + +
hello
+
+ ); +}; diff --git a/frontend/src/components/Card/Card.styles.js b/frontend/src/components/Card/Card.styles.ts similarity index 80% rename from frontend/src/components/Card/Card.styles.js rename to frontend/src/components/Card/Card.styles.ts index 66c8f3f1e..488013f63 100644 --- a/frontend/src/components/Card/Card.styles.js +++ b/frontend/src/components/Card/Card.styles.ts @@ -1,5 +1,11 @@ import styled from '@emotion/styled'; import COLOR from '../../constants/color'; +import { SerializedStyles } from '@emotion/react'; + +interface ContainerProps { + size: string; + css?: SerializedStyles; +} const CARD_SIZE = { EXTRA_SMALL: 'EXTRA_SMALL', @@ -22,7 +28,7 @@ const sizeStyle = { }, }; -const Container = styled.section` +const Container = styled.section` background-color: ${COLOR.WHITE}; border: 1px solid ${COLOR.LIGHT_GRAY_400}; border-radius: 2rem; diff --git a/frontend/src/components/Card/Card.tsx b/frontend/src/components/Card/Card.tsx new file mode 100644 index 000000000..b5aedcade --- /dev/null +++ b/frontend/src/components/Card/Card.tsx @@ -0,0 +1,24 @@ +import { SerializedStyles } from '@emotion/react'; +import { Container, Title } from './Card.styles'; + +interface Props { + children: JSX.Element; + title?: string; + size: string; + cssProps?: SerializedStyles; + css?: SerializedStyles; + onClick?: () => void; +} + +const Card = ({ title, children, size, cssProps, css, onClick }: Props) => { + return ( +
+ {title && {title} } + + {children} + +
+ ); +}; + +export default Card; diff --git a/frontend/src/components/DropdownMenu/DropdownMenu.js b/frontend/src/components/DropdownMenu/DropdownMenu.js deleted file mode 100644 index 0065f8a93..000000000 --- a/frontend/src/components/DropdownMenu/DropdownMenu.js +++ /dev/null @@ -1,12 +0,0 @@ -import PropTypes from 'prop-types'; -import { Container } from './DropdownMenu.styles'; - -const DropdownMenu = ({ children, cssProps, css }) => { - return {children}; -}; - -DropdownMenu.propTypes = { - children: PropTypes.node, -}; - -export default DropdownMenu; diff --git a/frontend/src/components/DropdownMenu/DropdownMenu.styles.js b/frontend/src/components/DropdownMenu/DropdownMenu.styles.js deleted file mode 100644 index 34d7bae60..000000000 --- a/frontend/src/components/DropdownMenu/DropdownMenu.styles.js +++ /dev/null @@ -1,88 +0,0 @@ -import styled from '@emotion/styled'; -import COLOR from '../../constants/color'; - -const Container = styled.div` - height: fit-content; - max-height: 32rem; - white-space: nowrap; - overflow-y: auto; - background-color: ${COLOR.WHITE}; - border-radius: 1.2rem; - box-shadow: 0px 0px 6px ${COLOR.BLACK_OPACITY_300}; - padding: 1rem 1.2rem; - position: absolute; - z-index: 100; - - /* transform: translateY(30%); */ - - && { - ${(props) => props.css} - } - - /* &:before { - position: fixed; - top: 0; - bottom: 0; - left: 0; - right: 0; - z-index: -1; - content: ' '; - background-color: rgba(0, 0, 0, 0.4); - } */ - - /* 삼각형 입니다 ^^ - &:before { - content: ''; - position: absolute; - border-style: solid; - border-width: 0 14px 15px; - border-color: #ffffff transparent; - display: block; - width: 0; - z-index: 0; - top: -14px; - right: 16px; - } - - &:after { - content: ''; - position: absolute; - border-style: solid; - border-width: 0 14px 15px; - border-color: #ffffff transparent; - display: block; - width: 0; - z-index: 0; - top: -14px; - right: 16px; - } */ - - & li { - height: 4rem; - display: flex; - align-items: center; - padding: 0 0.8rem; - width: 100%; - - & > * { - width: 100%; - font-size: 1.4rem; - font-weight: 500; - color: ${COLOR.DARK_GRAY_900}; - transition: font-size 0.1s ease; - text-align: left; - } - } - - & li:not(:last-child) { - border-bottom: 0.7px solid ${COLOR.LIGHT_GRAY_700}; - } - - /* & li:hover { - & > * { - font-size: 2.2rem; - } - } */ -`; - -export { Container }; diff --git a/frontend/src/components/DropdownMenu/DropdownMenu.styles.tsx b/frontend/src/components/DropdownMenu/DropdownMenu.styles.tsx new file mode 100644 index 000000000..499ae1e5a --- /dev/null +++ b/frontend/src/components/DropdownMenu/DropdownMenu.styles.tsx @@ -0,0 +1,42 @@ +import styled from '@emotion/styled'; +import COLOR from '../../constants/color'; + +const Container = styled.div<{ css: {} }>` + height: fit-content; + max-height: 32rem; + white-space: nowrap; + overflow-y: auto; + background-color: ${COLOR.WHITE}; + border-radius: 1.2rem; + box-shadow: 0px 0px 6px ${COLOR.BLACK_OPACITY_300}; + padding: 1rem 1.2rem; + position: absolute; + z-index: 100; + + && { + ${(props) => props.css} + } + + & li { + height: 4rem; + display: flex; + align-items: center; + padding: 0 0.8rem; + width: 100%; + + & > * { + width: 100%; + font-size: 1.4rem; + font-weight: 500; + color: ${COLOR.DARK_GRAY_900}; + transition: font-size 0.1s ease; + text-align: left; + } + } + + & li:not(:last-child) { + border-bottom: 0.7px solid ${COLOR.LIGHT_GRAY_700}; + } +`; + +export { Container }; diff --git a/frontend/src/components/DropdownMenu/DropdownMenu.tsx b/frontend/src/components/DropdownMenu/DropdownMenu.tsx new file mode 100644 index 000000000..9e7c59218 --- /dev/null +++ b/frontend/src/components/DropdownMenu/DropdownMenu.tsx @@ -0,0 +1,19 @@ +import PropTypes from 'prop-types'; +import { Container } from './DropdownMenu.styles'; +import { SerializedStyles } from '@emotion/react'; + +interface DropdownMenuProps { + children?: React.ReactNode; + css?: SerializedStyles; + cssProps?: SerializedStyles; +} + +const DropdownMenu = ({ children, cssProps, css }: DropdownMenuProps) => { + return css && {children}; +}; + +DropdownMenu.propTypes = { + children: PropTypes.node, +}; + +export default DropdownMenu; diff --git a/frontend/src/configs/environment.js b/frontend/src/configs/environment.ts similarity index 100% rename from frontend/src/configs/environment.js rename to frontend/src/configs/environment.ts diff --git a/frontend/src/constants/errorCode.js b/frontend/src/constants/errorCode.ts similarity index 100% rename from frontend/src/constants/errorCode.js rename to frontend/src/constants/errorCode.ts diff --git a/frontend/src/constants/index.js b/frontend/src/constants/index.ts similarity index 100% rename from frontend/src/constants/index.js rename to frontend/src/constants/index.ts diff --git a/frontend/src/constants/input.js b/frontend/src/constants/input.ts similarity index 100% rename from frontend/src/constants/input.js rename to frontend/src/constants/input.ts diff --git a/frontend/src/constants/localStorage.js b/frontend/src/constants/localStorage.ts similarity index 100% rename from frontend/src/constants/localStorage.js rename to frontend/src/constants/localStorage.ts diff --git a/frontend/src/constants/message.js b/frontend/src/constants/message.ts similarity index 100% rename from frontend/src/constants/message.js rename to frontend/src/constants/message.ts diff --git a/frontend/src/constants/path.js b/frontend/src/constants/path.ts similarity index 100% rename from frontend/src/constants/path.js rename to frontend/src/constants/path.ts diff --git a/frontend/src/constants/profilePageMenu.js b/frontend/src/constants/profilePageMenu.ts similarity index 100% rename from frontend/src/constants/profilePageMenu.js rename to frontend/src/constants/profilePageMenu.ts diff --git a/frontend/src/constants/reactQueryKey.js b/frontend/src/constants/reactQueryKey.ts similarity index 100% rename from frontend/src/constants/reactQueryKey.js rename to frontend/src/constants/reactQueryKey.ts diff --git a/frontend/src/constants/requestType.js b/frontend/src/constants/requestType.ts similarity index 100% rename from frontend/src/constants/requestType.js rename to frontend/src/constants/requestType.ts diff --git a/frontend/src/index.js b/frontend/src/index.tsx similarity index 100% rename from frontend/src/index.js rename to frontend/src/index.tsx