Skip to content

Commit

Permalink
[FEATURE] - {FEEDBACK} 피드백 서비스 테스트 및 기능 구현 (#12)
Browse files Browse the repository at this point in the history
* [#1]feat: Feedback Entity 설계

* [#2]setting: 기본 파일 제거

* [#2]setting: 각 서비스 어노테이션 추가

* [#2, #3]feat: 피드백 커맨드 서비스 테스트 케이스, 피드백 Request 및 Response, 피드백 커맨드 서비스 작성
  • Loading branch information
fakerdeft authored Sep 11, 2023
1 parent 61abef7 commit eadbb62
Show file tree
Hide file tree
Showing 23 changed files with 265 additions and 36 deletions.
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 src/main/java/com/loveloveshot/common/annotation/InfraService.java
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 {
}
4 changes: 0 additions & 4 deletions src/main/java/com/loveloveshot/common/annotation/test.java

This file was deleted.

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;
}
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;
}

This file was deleted.

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()
);
}

}

This file was deleted.

This file was deleted.

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;
}

This file was deleted.

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> {
}

This file was deleted.

This file was deleted.

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;
// }

}

This file was deleted.

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> {
}

This file was deleted.

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 {
}
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() {
//
// }

}
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 {
}
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 {
}
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() {
//
// }
}

0 comments on commit eadbb62

Please sign in to comment.