Skip to content
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

[FEATURE] - {FEEDBACK} 피드백 서비스 테스트 및 기능 구현 #12

Merged
merged 5 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Subak-Uncle marked this conversation as resolved.
Show resolved Hide resolved
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 {
}
Subak-Uncle marked this conversation as resolved.
Show resolved Hide resolved
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() {
//
// }
}
Loading