Skip to content

Commit

Permalink
style: 코드 컨벤션 수정, 누락된 요구사항 명세 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
youngsu5582 committed Aug 14, 2024
1 parent 02835a1 commit 7c57482
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package corea.matching.controller;

import corea.auth.domain.AuthInfo;
import corea.exception.ExceptionType;
import corea.global.annotation.ApiErrorResponses;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.ResponseEntity;

@Tag(name = "Matching", description = "매칭 관련 API")
public interface MacthingControllerSpecification {
@Operation(summary = "매칭을 진행합니다.",
description = "해당 방을 신청한 인원 중에서 리뷰어-리뷰이 페어를 랜덤으로 매칭합니다. <br>" +
"요청 시 `Authorization Header`에 `Bearer JWT token`을 포함시켜야 합니다. " +
"이 토큰을 기반으로 `AuthInfo` 객체가 생성되며 사용자의 정보가 자동으로 주입됩니다. <br>" +
"JWT 토큰에서 추출된 사용자 정보는 피드백 작성에 필요한 인증된 사용자 정보를 제공합니다. " +
"<br><br>**참고:** 이 API를 사용하기 위해서는 유효한 JWT 토큰이 필요하며, " +
"토큰이 없거나 유효하지 않은 경우 인증 오류가 발생합니다.")
@ApiErrorResponses(value = {ExceptionType.MEMBER_NOT_FOUND, ExceptionType.ROOM_NOT_FOUND, ExceptionType.PARTICIPANT_SIZE_LACK})
ResponseEntity<Void> matching(@Parameter(description = "방 아이디", example = "1")
long id,
AuthInfo authInfo);


}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

@RestController
@RequiredArgsConstructor
public class MatchingController {
public class MatchingController implements MacthingControllerSpecification{

private final MatchingService matchingService;
private final RoomService roomService;
Expand Down
2 changes: 1 addition & 1 deletion backend/src/main/java/corea/matching/domain/Pair.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class Pair {
private final Member fromMember;
private final Member toMember;

public String getToMemberGithubId(){
public String getToMemberGithubId() {
return toMember.getGithubUserId();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Objects;
import java.util.stream.Stream;

public record PullRequestData(boolean isLastPage, PullRequestResponse[] pullRequestResponses) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,15 @@ public PullRequestInfo getUntilDeadline(String repositoryLink, LocalDateTime dea
}

/**
*
* LocalDateTime UTC 로 변환 함수
*
* <p>
* 깃허브 서버는 UTC 를 사용, 서버 및 DB 는 Seoul TimeZone 을 사용하므로
* 의도한 대로 해당 시간까지 PR을 조회할 떄 동작하지 않습니다.
* 이로 인해, UTC 로 변환합니다.
*
* @author youngsu5582
* @param localDateTime
* @return
* @author youngsu5582
*/
private LocalDateTime convertUtc(LocalDateTime localDateTime) {
return localDateTime.atZone(SERVER_ZONE_ID)
Expand Down
1 change: 1 addition & 0 deletions backend/src/main/java/corea/room/dto/RoomResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public record RoomResponse(@Schema(description = "방 아이디", example = "1")
@Schema(description = "모집 완료 여부", example = "false")
boolean isClosed
) {

public static RoomResponse of(Room room) {
return RoomResponse.of(room, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import static org.assertj.core.api.Assertions.assertThat;

class PullRequestDataTest {

@Test
@DisplayName("페이지 처음 데이터의 시간보다 주어진 시간이 지났으면 지난 페이지가 된다.")
void some() {
Expand All @@ -22,5 +23,4 @@ void some() {
boolean isAftered = pullRequestData.isAfterPage(LocalDateTime.of(2024, 11, 24, 18, 30));
assertThat(isAftered).isTrue();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ class MatchResultServiceTest {

@BeforeEach
void setUp() {
roomId = roomRepository.save(RoomFixture.ROOM_DOMAIN(createMember(MemberFixture.MEMBER_ROOM_MANAGER_JOYSON()))).getId();
roomId = roomRepository.save(RoomFixture.ROOM_DOMAIN(createMember(MemberFixture.MEMBER_ROOM_MANAGER_JOYSON())))
.getId();
findMemberId = createMember(MemberFixture.MEMBER_YOUNGSU()).getId();
participations.add(new Participation(roomId, findMemberId));
participations.add(new Participation(roomId, createMember(MemberFixture.MEMBER_ASH()).getId()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.springframework.boot.test.mock.mockito.MockBean;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;

import static org.assertj.core.api.Assertions.assertThat;
Expand Down
19 changes: 14 additions & 5 deletions backend/src/test/java/corea/room/service/RoomServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,14 @@ void findParticipatedRooms() {
List<RoomResponse> rooms = response.rooms();

assertSoftly(softly -> {
softly.assertThat(rooms).hasSize(2);
softly.assertThat(rooms.get(0).manager()).isEqualTo("강다빈");
softly.assertThat(rooms.get(1).manager()).isEqualTo("이상엽");
softly.assertThat(rooms)
.hasSize(2);
softly.assertThat(rooms.get(0)
.manager())
.isEqualTo("강다빈");
softly.assertThat(rooms.get(1)
.manager())
.isEqualTo("이상엽");
});
}

Expand Down Expand Up @@ -100,7 +105,9 @@ void isLastPage(int pageNumber, boolean expected) {
void invalidRecruitmentDeadline() {
RoomCreateRequest request = new RoomCreateRequest("title", "content", "repoLink",
"thumLink", 3, null, 3,
LocalDateTime.now().plusMinutes(59), LocalDateTime.now().plusDays(2), RoomClassification.ALL);
LocalDateTime.now()
.plusMinutes(59), LocalDateTime.now()
.plusDays(2), RoomClassification.ALL);

assertThatThrownBy(() -> roomService.create(1, request))
.isInstanceOf(CoreaException.class);
Expand All @@ -111,7 +118,9 @@ void invalidRecruitmentDeadline() {
void invalidReviewDeadline() {
RoomCreateRequest request = new RoomCreateRequest("title", "content", "repoLink",
"thumLink", 3, null, 3,
LocalDateTime.now().plusHours(2), LocalDateTime.now().plusHours(23), RoomClassification.ALL);
LocalDateTime.now()
.plusHours(2), LocalDateTime.now()
.plusHours(23), RoomClassification.ALL);

assertThatThrownBy(() -> roomService.create(1, request))
.isInstanceOf(CoreaException.class);
Expand Down

0 comments on commit 7c57482

Please sign in to comment.