-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feat: 나의 웹툰 조회 기능 구현
- Loading branch information
Showing
4 changed files
with
83 additions
and
0 deletions.
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
4 changes: 4 additions & 0 deletions
4
src/main/java/yjh/devtoon/webtoon/infrastructure/WebtoonRepository.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,9 +1,13 @@ | ||
package yjh.devtoon.webtoon.infrastructure; | ||
|
||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import yjh.devtoon.webtoon.domain.WebtoonEntity; | ||
import java.util.Optional; | ||
|
||
public interface WebtoonRepository extends JpaRepository<WebtoonEntity, Long> { | ||
Optional<WebtoonEntity> findByTitle(String title); | ||
|
||
Page<WebtoonEntity> findAllByWriterName(Pageable pageable, String name); | ||
} |
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 |
---|---|---|
|
@@ -24,9 +24,15 @@ | |
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.mock.web.MockMultipartFile; | ||
import org.springframework.security.crypto.password.PasswordEncoder; | ||
import org.springframework.security.test.context.support.WithMockUser; | ||
import org.springframework.test.web.servlet.MockMvc; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import yjh.devtoon.member.domain.Authority; | ||
import yjh.devtoon.member.domain.MemberEntity; | ||
import yjh.devtoon.member.domain.MembershipStatus; | ||
import yjh.devtoon.member.domain.Role; | ||
import yjh.devtoon.member.infrastructure.MemberRepository; | ||
import yjh.devtoon.webtoon.domain.Genre; | ||
import yjh.devtoon.webtoon.domain.WebtoonEntity; | ||
import yjh.devtoon.webtoon.dto.request.WebtoonCreateRequest; | ||
|
@@ -36,6 +42,7 @@ | |
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
import java.util.stream.Stream; | ||
|
||
@DisplayName("통합 테스트 [Webtoon]") | ||
|
@@ -46,6 +53,12 @@ public class WebtoonIntegrationTest { | |
|
||
private static final String NULL = null; | ||
|
||
@Autowired | ||
private MemberRepository memberRepository; | ||
|
||
@Autowired | ||
private PasswordEncoder passwordEncoder; | ||
|
||
@Autowired | ||
private ObjectMapper objectMapper; | ||
|
||
|
@@ -349,4 +362,46 @@ void retrieveAllWebtoon_successfully() throws Exception { | |
} | ||
} | ||
|
||
@WithMockUser(username = "[email protected]", password = "password", authorities = {"MEMBER"}) | ||
@Nested | ||
@DisplayName("나의 웹툰 전체 조회 테스트") | ||
class WebtoonRetrieveAllMyTests { | ||
|
||
@DisplayName("나의 웹툰 전체 조회 성공") | ||
@Test | ||
void retrieveAllWebtoon_successfully() throws Exception { | ||
// given | ||
MemberEntity member = MemberEntity.builder() | ||
.name("카레곰") | ||
.email("[email protected]") | ||
.password(passwordEncoder.encode("password")) | ||
.membershipStatus(MembershipStatus.GENERAL) | ||
.authorities(Set.of(new Authority(Role.MEMBER))) | ||
.build(); | ||
memberRepository.save(member); | ||
|
||
WebtoonEntity webtoonEntity1 = WebtoonEntity.builder() | ||
.title("쿠베라") | ||
.writerName("카레곰") | ||
.genre(Genre.HORROR) | ||
.build(); | ||
webtoonRepository.save(webtoonEntity1); | ||
|
||
WebtoonEntity webtoonEntity2 = WebtoonEntity.builder() | ||
.title("기기괴괴") | ||
.writerName("오성대") | ||
.genre(Genre.HORROR) | ||
.build(); | ||
webtoonRepository.save(webtoonEntity2); | ||
|
||
// when | ||
mockMvc.perform(get("/v1/webtoons/my") | ||
.contentType(MediaType.APPLICATION_JSON)) | ||
.andExpect(status().isOk()) | ||
.andExpect(jsonPath("$.statusMessage").value("성공")) | ||
.andExpect(jsonPath("$.data.content").isArray()) | ||
.andExpect(jsonPath("$.data.content[0].title").value("쿠베라")); | ||
} | ||
} | ||
|
||
} |