Skip to content

Commit

Permalink
docs: 자신이 만든 리뷰 그룹 목록 조회 API 문서 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
donghoony committed Dec 19, 2024
1 parent 69b507a commit ebe88bd
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 0 deletions.
4 changes: 4 additions & 0 deletions backend/src/docs/asciidoc/reviewgroup.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ operation::review-group-summary[snippets="curl-request,http-response,response-fi
==== 리뷰 요청 코드, 확인 코드 일치 여부

operation::review-group-check-access[snippets="curl-request,request-fields,http-response,response-cookies"]

==== 자신이 만든 리뷰 그룹 목록 조회

operation::review-group-list[snippets="curl-request,request-cookies,http-response,response-fields"]
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import reviewme.reviewgroup.service.dto.CheckValidAccessRequest;
import reviewme.reviewgroup.service.dto.ReviewGroupCreationRequest;
import reviewme.reviewgroup.service.dto.ReviewGroupCreationResponse;
import reviewme.reviewgroup.service.dto.ReviewGroupListResponse;
import reviewme.reviewgroup.service.dto.ReviewGroupResponse;

@RestController
Expand Down Expand Up @@ -48,4 +49,11 @@ public ResponseEntity<Void> checkGroupAccessCode(
session.setAttribute("reviewRequestCode", request.reviewRequestCode());
return ResponseEntity.noContent().build();
}

@GetMapping("/v2/groups/mine")
public ResponseEntity<ReviewGroupListResponse> getMyReviewGroups() {
// TODO: 세션을 활용한 권한 체계에 따른 추가 조치 필요
ReviewGroupListResponse response = reviewGroupLookupService.getMyReviewGroups();
return ResponseEntity.ok(response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import reviewme.reviewgroup.service.dto.ReviewGroupListResponse;
import reviewme.reviewgroup.service.exception.ReviewGroupNotFoundByReviewRequestCodeException;
import reviewme.reviewgroup.domain.ReviewGroup;
import reviewme.reviewgroup.repository.ReviewGroupRepository;
Expand All @@ -21,4 +22,8 @@ public ReviewGroupResponse getReviewGroupSummary(String reviewRequestCode) {

return new ReviewGroupResponse(reviewGroup.getReviewee(), reviewGroup.getProjectName());
}

public ReviewGroupListResponse getMyReviewGroups() {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package reviewme.reviewgroup.service.dto;

import java.time.LocalDate;

public record ReviewGroupDetailResponse(
String revieweeName,
String projectName,
LocalDate createdAt,
String reviewRequestCode
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package reviewme.reviewgroup.service.dto;

import java.util.List;

public record ReviewGroupListResponse(
boolean isLastPage,
List<ReviewGroupDetailResponse> reviewGroups
) {
}
43 changes: 43 additions & 0 deletions backend/src/test/java/reviewme/api/ReviewGroupApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.springframework.restdocs.cookies.CookieDocumentation.cookieWithName;
import static org.springframework.restdocs.cookies.CookieDocumentation.requestCookies;
import static org.springframework.restdocs.cookies.CookieDocumentation.responseCookies;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
Expand All @@ -12,6 +13,8 @@
import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName;
import static org.springframework.restdocs.request.RequestDocumentation.queryParameters;

import java.time.LocalDate;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.mockito.BDDMockito;
import org.springframework.restdocs.cookies.CookieDescriptor;
Expand All @@ -20,6 +23,8 @@
import org.springframework.restdocs.request.ParameterDescriptor;
import reviewme.reviewgroup.service.dto.ReviewGroupCreationRequest;
import reviewme.reviewgroup.service.dto.ReviewGroupCreationResponse;
import reviewme.reviewgroup.service.dto.ReviewGroupDetailResponse;
import reviewme.reviewgroup.service.dto.ReviewGroupListResponse;
import reviewme.reviewgroup.service.dto.ReviewGroupResponse;

class ReviewGroupApiTest extends ApiTest {
Expand Down Expand Up @@ -121,4 +126,42 @@ class ReviewGroupApiTest extends ApiTest {
.cookie("JSESSIONID")
.statusCode(204);
}

@Test
void 회원이_생성한_프로젝트_목록을_반환한다() {
ReviewGroupListResponse response = new ReviewGroupListResponse(true,
List.of(
new ReviewGroupDetailResponse("아루", "리뷰미", LocalDate.of(2024, 1, 5), "ABCD1234"),
new ReviewGroupDetailResponse("이동훈", "우테코", LocalDate.of(2024, 1, 30), "WOOTECO1")
)
);
BDDMockito.given(reviewGroupLookupService.getMyReviewGroups())
.willReturn(response);

CookieDescriptor[] cookieDescriptors = {
cookieWithName("JSESSIONID").description("세션 ID")
};

FieldDescriptor[] responseFieldDescriptors = {
fieldWithPath("isLastPage").description("마지막 페이지 여부"),
fieldWithPath("reviewGroups[]").description("리뷰 그룹 목록"),
fieldWithPath("reviewGroups[].revieweeName").description("리뷰이 이름"),
fieldWithPath("reviewGroups[].projectName").description("프로젝트 이름"),
fieldWithPath("reviewGroups[].createdAt").description("생성일"),
fieldWithPath("reviewGroups[].reviewRequestCode").description("리뷰 요청 코드")
};

RestDocumentationResultHandler handler = document(
"review-group-list",
responseFields(responseFieldDescriptors),
requestCookies(cookieDescriptors)
);

givenWithSpec().log().all()
.cookie("JSESSIONID", "ABCDEFGHI1234")
.when().get("/v2/groups/mine")
.then().log().all()
.apply(handler)
.statusCode(200);
}
}

0 comments on commit ebe88bd

Please sign in to comment.