-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BE] feat: 유저가 참여중인 방 리스트 조회 기능 구현(#29) #60
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 9 additions & 6 deletions
15
backend/src/main/java/corea/room/dto/RoomCreateRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,28 @@ | ||
package corea.room.dto; | ||
|
||
import corea.member.domain.Member; | ||
import corea.room.domain.Room; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
public record RoomCreateRequest( | ||
String title, | ||
String content, | ||
long memberId, | ||
Member manager, | ||
String repositoryLink, | ||
String thumbnailLink, | ||
int matchingSize, | ||
String keyword, | ||
long currentParticipantsSize, | ||
long limitedParticipantsSize, | ||
LocalDateTime submissionDeadline, | ||
int currentParticipantsSize, | ||
int limitedParticipantsSize, | ||
LocalDateTime recruitmentDeadline, | ||
LocalDateTime reviewDeadline | ||
) { | ||
|
||
//TODO 해당 객체를 사용한다면 반영 | ||
public Room toEntity() { | ||
return null; | ||
return new Room(title, content, matchingSize, | ||
repositoryLink, thumbnailLink, keyword, | ||
currentParticipantsSize, limitedParticipantsSize, manager, | ||
recruitmentDeadline, reviewDeadline); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,17 @@ | ||
package corea.room.dto; | ||
|
||
import corea.room.domain.Room; | ||
|
||
import java.util.List; | ||
|
||
import static java.util.stream.Collectors.collectingAndThen; | ||
import static java.util.stream.Collectors.toList; | ||
|
||
public record RoomResponses(List<RoomResponse> rooms) { | ||
|
||
public static RoomResponses from(List<Room> rooms) { | ||
return rooms.stream() | ||
.map(RoomResponse::from) | ||
.collect(collectingAndThen(toList(), RoomResponses::new)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
backend/src/test/java/corea/room/acceptance/RoomAcceptanceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package corea.room.acceptance; | ||
|
||
import corea.matching.dto.ParticipationRequest; | ||
import corea.matching.service.ParticipationService; | ||
import corea.member.domain.Member; | ||
import corea.member.repository.MemberRepository; | ||
import corea.room.dto.RoomResponse; | ||
import corea.room.dto.RoomResponses; | ||
import corea.room.fixture.MemberFixture; | ||
import corea.room.fixture.RoomFixture; | ||
import corea.room.service.RoomService; | ||
import io.restassured.RestAssured; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.boot.test.web.server.LocalServerPort; | ||
|
||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||
class RoomAcceptanceTest { | ||
|
||
@LocalServerPort | ||
int port; | ||
|
||
@Autowired | ||
RoomService roomService; | ||
|
||
@Autowired | ||
MemberRepository memberRepository; | ||
|
||
@Autowired | ||
ParticipationService participationService; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
RestAssured.port = port; | ||
} | ||
|
||
@Test | ||
@DisplayName("현재 로그인한 멤버가 참여 중인 방을 보여준다.") | ||
void participatedRooms() { | ||
Member pororo = memberRepository.save(MemberFixture.MEMBER_PORORO()); | ||
Member ash = memberRepository.save(MemberFixture.MEMBER_ASH()); | ||
RoomResponse roomResponse = roomService.create(RoomFixture.ROOM_CREATE_REQUEST(ash)); | ||
participationService.participate(new ParticipationRequest(roomResponse.id(), pororo.getId())); | ||
|
||
RoomResponses response = RestAssured.given().log().all() | ||
.header("Authorization", "[email protected]") | ||
.when().get("/rooms/participated") | ||
.then().log().all() | ||
.statusCode(200) | ||
.extract().as(RoomResponses.class); | ||
|
||
List<RoomResponse> rooms = response.rooms(); | ||
assertThat(rooms).hasSize(1); | ||
assertThat(rooms.get(0).author()).isEqualTo("박민아"); | ||
} | ||
Comment on lines
+44
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 현재 방을 생성하고, 방을 입장하는 API를 구현하지 않았기 때문에, 일단은 repository와 service를 가져와서 구현했습니다. 추후 RestAssured로 수정하겠습니다. |
||
} |
14 changes: 14 additions & 0 deletions
14
backend/src/test/java/corea/room/fixture/MemberFixture.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package corea.room.fixture; | ||
|
||
import corea.member.domain.Member; | ||
|
||
public class MemberFixture { | ||
|
||
public static Member MEMBER_PORORO() { | ||
return new Member("jcoding-play", null, "조경찬", "[email protected]", true, 5f); | ||
} | ||
|
||
public static Member MEMBER_ASH() { | ||
return new Member("ashsty", null, "박민아", null, false, 1.5f); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
코드 보면서 생각난 부분인데
어차피 동적으로 생성해서 정적인 값을 사용하지 않는다면
이렇게 하는건 어떤지?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋은것 같은데??
애초에 나는 원래 에러 메시지 자세하게 적는거 좋아해서 대부분 동적으로 생성하긴 할거라 좋을듯?? 👍
근데 이것도 한가지 걸리는 점은, 매번 예외 메세지를 작성할 때 필요한
args
를 확인해야 한다는 단점도 생각나긴 하는 것 같네용이거는 다같이 얘기해보면 좋을 것 같습니다~