-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] - {FEEDBACK} 피드백 서비스 테스트 및 기능 구현 (#12)
* [#1]feat: Feedback Entity 설계 * [#2]setting: 기본 파일 제거 * [#2]setting: 각 서비스 어노테이션 추가 * [#2, #3]feat: 피드백 커맨드 서비스 테스트 케이스, 피드백 Request 및 Response, 피드백 커맨드 서비스 작성
- Loading branch information
Showing
23 changed files
with
265 additions
and
36 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
src/main/java/com/loveloveshot/common/annotation/DomainService.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 com.loveloveshot.common.annotation; | ||
|
||
import org.springframework.context.annotation.Primary; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.lang.annotation.*; | ||
|
||
@Documented | ||
@Target(ElementType.TYPE) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Service | ||
@Primary | ||
public @interface DomainService { | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/loveloveshot/common/annotation/InfraService.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,12 @@ | ||
package com.loveloveshot.common.annotation; | ||
|
||
import org.springframework.stereotype.Service; | ||
|
||
import java.lang.annotation.*; | ||
|
||
@Documented | ||
@Target(ElementType.TYPE) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Service | ||
public @interface InfraService { | ||
} |
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
src/main/java/com/loveloveshot/feedback/command/application/dto/request/FeedbackRequest.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 com.loveloveshot.feedback.command.application.dto.request; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class FeedbackRequest { | ||
private String feedbackContent; | ||
} |
19 changes: 19 additions & 0 deletions
19
...ain/java/com/loveloveshot/feedback/command/application/dto/response/FeedbackResponse.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,19 @@ | ||
package com.loveloveshot.feedback.command.application.dto.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class FeedbackResponse { | ||
private Long feedbackNo; | ||
private String feedbackContent; | ||
|
||
// private Date feedbackDate; | ||
// private String feedbackTitle; | ||
// private FeedbackWriterVO feedbackWriterVO; | ||
} |
4 changes: 0 additions & 4 deletions
4
src/main/java/com/loveloveshot/feedback/command/application/dto/test.java
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
...in/java/com/loveloveshot/feedback/command/application/service/FeedbackCommandService.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,30 @@ | ||
package com.loveloveshot.feedback.command.application.service; | ||
|
||
import com.loveloveshot.feedback.command.application.dto.request.FeedbackRequest; | ||
import com.loveloveshot.feedback.command.application.dto.response.FeedbackResponse; | ||
import com.loveloveshot.feedback.command.domain.aggregate.entity.Feedback; | ||
import com.loveloveshot.feedback.command.domain.repository.FeedbackCommandRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class FeedbackCommandService { | ||
private final FeedbackCommandRepository feedbackCommandRepository; | ||
|
||
@Transactional | ||
public FeedbackResponse submitFeedback(FeedbackRequest feedbackRequest) { | ||
Feedback feedback = new Feedback.Builder() | ||
.feedbackContent(feedbackRequest.getFeedbackContent()) | ||
.build(); | ||
|
||
Feedback savedFeedback = feedbackCommandRepository.saveAndFlush(feedback); | ||
|
||
return new FeedbackResponse( | ||
savedFeedback.getFeedbackNo(), | ||
savedFeedback.getFeedbackContent() | ||
); | ||
} | ||
|
||
} |
4 changes: 0 additions & 4 deletions
4
src/main/java/com/loveloveshot/feedback/command/application/service/test.java
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
src/main/java/com/loveloveshot/feedback/command/domain/aggregate/entity/test.java
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
src/main/java/com/loveloveshot/feedback/command/domain/aggregate/vo/FeedbackWriterVO.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,18 @@ | ||
package com.loveloveshot.feedback.command.domain.aggregate.vo; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Embeddable; | ||
|
||
@Getter | ||
@Embeddable | ||
@AllArgsConstructor | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class FeedbackWriterVO { | ||
@Column | ||
private Long feedbackWriterId; | ||
} |
4 changes: 0 additions & 4 deletions
4
src/main/java/com/loveloveshot/feedback/command/domain/aggregate/vo/test.java
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
...n/java/com/loveloveshot/feedback/command/domain/repository/FeedbackCommandRepository.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,9 @@ | ||
package com.loveloveshot.feedback.command.domain.repository; | ||
|
||
import com.loveloveshot.feedback.command.domain.aggregate.entity.Feedback; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface FeedbackCommandRepository extends JpaRepository<Feedback, Long> { | ||
} |
4 changes: 0 additions & 4 deletions
4
src/main/java/com/loveloveshot/feedback/command/domain/repository/test.java
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
src/main/java/com/loveloveshot/feedback/command/infrastructure/repository/test.java
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
src/main/java/com/loveloveshot/feedback/query/application/service/FeedbackQueryService.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,26 @@ | ||
package com.loveloveshot.feedback.query.application.service; | ||
|
||
import com.loveloveshot.feedback.query.domain.repository.FeedbackQueryRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class FeedbackQueryService { | ||
private final FeedbackQueryRepository feedbackQueryRepository; | ||
|
||
// // 특정 회원 피드백 전체 조회 | ||
// @Transactional(readOnly = true) | ||
// public FeedbackResponse findAllByUserNo() { | ||
// | ||
// return null; | ||
// } | ||
// | ||
// // 모든 회원 피드백 전체 조회 | ||
// @Transactional(readOnly = true) | ||
// public FeedbackResponse findAll() { | ||
// | ||
// return null; | ||
// } | ||
|
||
} |
4 changes: 0 additions & 4 deletions
4
src/main/java/com/loveloveshot/feedback/query/application/service/test.java
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
src/main/java/com/loveloveshot/feedback/query/domain/repository/FeedbackQueryRepository.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,9 @@ | ||
package com.loveloveshot.feedback.query.domain.repository; | ||
|
||
import com.loveloveshot.feedback.command.domain.aggregate.entity.Feedback; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface FeedbackQueryRepository extends JpaRepository<Feedback, Long> { | ||
} |
4 changes: 0 additions & 4 deletions
4
src/main/java/com/loveloveshot/feedback/query/infrastructure/repository/test.java
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
...m/loveloveshot/feedback/command/application/controller/FeedbackCommandControllerTest.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,9 @@ | ||
package com.loveloveshot.feedback.command.application.controller; | ||
|
||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@SpringBootTest | ||
@Transactional | ||
public class FeedbackCommandControllerTest { | ||
} |
63 changes: 63 additions & 0 deletions
63
...ava/com/loveloveshot/feedback/command/application/service/FeedbackCommandServiceTest.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 com.loveloveshot.feedback.command.application.service; | ||
|
||
import com.loveloveshot.feedback.command.application.dto.request.FeedbackRequest; | ||
import com.loveloveshot.feedback.command.domain.aggregate.entity.Feedback; | ||
import com.loveloveshot.feedback.command.domain.repository.FeedbackCommandRepository; | ||
import org.junit.jupiter.api.Assertions; | ||
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.transaction.annotation.Transactional; | ||
|
||
@SpringBootTest | ||
@Transactional | ||
public class FeedbackCommandServiceTest { | ||
FeedbackRequest feedbackRequest = new FeedbackRequest(); | ||
|
||
@Autowired | ||
private FeedbackCommandService feedbackCommandService; | ||
@Autowired | ||
private FeedbackCommandRepository feedbackCommandRepository; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
Feedback feedback = new Feedback.Builder() | ||
.feedbackContent("정말 훌륭합니다.") | ||
.build(); | ||
|
||
feedbackRequest.setFeedbackContent(feedback.getFeedbackContent()); | ||
} | ||
|
||
@Test | ||
@DisplayName("피드백 제출 테스트 : success") | ||
void submitFeedbackTest() { | ||
long before = feedbackCommandRepository.count(); | ||
|
||
feedbackCommandService.submitFeedback(feedbackRequest); | ||
|
||
long after = feedbackCommandRepository.count(); | ||
|
||
Assertions.assertEquals(before + 1, after); | ||
} | ||
|
||
// @Test | ||
// @DisplayName("특정 피드백 삭제 테스트 : ") | ||
// void deleteFeedbackByFeedbackNoTest() { | ||
// | ||
// } | ||
// | ||
// @Test | ||
// @DisplayName("피드백 전체 삭제 테스트 : 특정 회원") | ||
// void deleteFeedbackByUserNoTest() { | ||
// | ||
// } | ||
// | ||
// @Test | ||
// @DisplayName("피드백 전체 삭제 테스트 : 모든 회원") | ||
// void deleteAllFeedbackTest() { | ||
// | ||
// } | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
...va/com/loveloveshot/feedback/command/domain/service/FeedbackCommandDomainServiceTest.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,9 @@ | ||
package com.loveloveshot.feedback.command.domain.service; | ||
|
||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@SpringBootTest | ||
@Transactional | ||
public class FeedbackCommandDomainServiceTest { | ||
} |
9 changes: 9 additions & 0 deletions
9
...a/com/loveloveshot/feedback/query/application/controller/FeedbackQueryControllerTest.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,9 @@ | ||
package com.loveloveshot.feedback.query.application.controller; | ||
|
||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@SpringBootTest | ||
@Transactional | ||
public class FeedbackQueryControllerTest { | ||
} |
24 changes: 24 additions & 0 deletions
24
...st/java/com/loveloveshot/feedback/query/application/service/FeedbackQueryServiceTest.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,24 @@ | ||
package com.loveloveshot.feedback.query.application.service; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@SpringBootTest | ||
@Transactional | ||
public class FeedbackQueryServiceTest { | ||
@Autowired | ||
private FeedbackQueryService feedbackQueryService; | ||
|
||
// @Test | ||
// @DisplayName("피드백 전체 조회 테스트 : 특정 회원") | ||
// public void findAllFeedbackByUserNoTest() { | ||
// | ||
// } | ||
// | ||
// @Test | ||
// @DisplayName("피드백 전체 조회 테스트 : 모든 회원") | ||
// public void findAllFeedbackTest() { | ||
// | ||
// } | ||
} |