-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
53ecc0a
commit 5b4cf73
Showing
23 changed files
with
412 additions
and
41 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
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
29 changes: 29 additions & 0 deletions
29
be/src/main/java/com/example/be/core/application/member/GoalService.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,29 @@ | ||
package com.example.be.core.application.member; | ||
|
||
import com.example.be.core.application.dto.response.GoalResponse; | ||
import com.example.be.core.domain.member.goal.Goal; | ||
import com.example.be.core.repository.member.goal.GoalRepository; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@Transactional(readOnly = true) | ||
public class GoalService { | ||
|
||
private final GoalRepository goalRepository; | ||
|
||
public GoalService(GoalRepository goalRepository) { | ||
this.goalRepository = goalRepository; | ||
} | ||
|
||
|
||
public List<GoalResponse> findAll() { | ||
|
||
List<Goal> goals = goalRepository.findAll(); | ||
return goals.stream() | ||
.map(GoalResponse::of) | ||
.collect(Collectors.toList()); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...le/be/core/application/MemberService.java → ...ore/application/member/MemberService.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
28 changes: 28 additions & 0 deletions
28
be/src/main/java/com/example/be/core/application/member/SubjectService.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,28 @@ | ||
package com.example.be.core.application.member; | ||
|
||
import com.example.be.core.application.dto.response.SubjectResponse; | ||
import com.example.be.core.domain.member.subject.Subject; | ||
import com.example.be.core.repository.member.subject.SubjectRepository; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@Transactional(readOnly = true) | ||
public class SubjectService { | ||
|
||
private final SubjectRepository subjectRepository; | ||
|
||
public SubjectService(SubjectRepository subjectRepository) { | ||
this.subjectRepository = subjectRepository; | ||
} | ||
|
||
public List<SubjectResponse> findAll() { | ||
List<Subject> subjects = subjectRepository.findAll(); | ||
return subjects.stream() | ||
.map(SubjectResponse::of) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
} |
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
30 changes: 30 additions & 0 deletions
30
be/src/main/java/com/example/be/core/web/member/GoalController.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.example.be.core.web.member; | ||
|
||
import static com.example.be.common.response.ResponseCodeAndMessages.FIND_ALL_GOALS_SUCCESS; | ||
|
||
import com.example.be.common.response.BaseResponse; | ||
import com.example.be.core.application.member.GoalService; | ||
import com.example.be.core.application.dto.response.GoalResponse; | ||
import io.swagger.annotations.ApiOperation; | ||
import java.util.List; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/goal") | ||
public class GoalController { | ||
|
||
private final GoalService goalService; | ||
|
||
public GoalController(GoalService goalService) { | ||
this.goalService = goalService; | ||
} | ||
|
||
@GetMapping | ||
@ApiOperation(value = "목표 전체 조회입니다.") | ||
public BaseResponse<List<GoalResponse>> findAll() { | ||
List<GoalResponse> response = goalService.findAll(); | ||
return new BaseResponse<>(FIND_ALL_GOALS_SUCCESS, response); | ||
} | ||
} |
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
30 changes: 30 additions & 0 deletions
30
be/src/main/java/com/example/be/core/web/member/SubjectController.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.example.be.core.web.member; | ||
|
||
import static com.example.be.common.response.ResponseCodeAndMessages.FIND_ALL_SUBJECTS_SUCCESS; | ||
|
||
import com.example.be.common.response.BaseResponse; | ||
import com.example.be.core.application.dto.response.SubjectResponse; | ||
import com.example.be.core.application.member.SubjectService; | ||
import io.swagger.annotations.ApiOperation; | ||
import java.util.List; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/subject") | ||
public class SubjectController { | ||
|
||
private final SubjectService subjectService; | ||
|
||
public SubjectController(SubjectService subjectService) { | ||
this.subjectService = subjectService; | ||
} | ||
|
||
@GetMapping | ||
@ApiOperation(value = "주제 전체 조회입니다.") | ||
public BaseResponse<List<SubjectResponse>> findAll() { | ||
List<SubjectResponse> response = subjectService.findAll(); | ||
return new BaseResponse<>(FIND_ALL_SUBJECTS_SUCCESS, response); | ||
} | ||
} |
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
45 changes: 45 additions & 0 deletions
45
be/src/test/java/com/example/be/core/application/goal_subject/GoalFindAllTest.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,45 @@ | ||
package com.example.be.core.application.goal_subject; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import com.example.be.core.application.member.GoalService; | ||
import com.example.be.core.application.InitServiceTest; | ||
import com.example.be.core.application.dto.response.GoalResponse; | ||
import java.util.List; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Nested; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
@DisplayName("서비스 테스트 : Goal 전체 조회") | ||
class GoalFindAllTest extends InitServiceTest { | ||
|
||
@Autowired | ||
private GoalService goalService; | ||
|
||
@Nested | ||
@DisplayName("목표를 전체 조회할 때") | ||
class FindAllTest { | ||
|
||
@Nested | ||
@DisplayName("정상적인 요청이라면") | ||
class NormalTest { | ||
|
||
@Test | ||
void find_all_goals_test(){ | ||
//given & when | ||
List<GoalResponse> goals = goalService.findAll(); | ||
|
||
//then | ||
assertThat(goals).hasSize(5); | ||
assertThat(goals.get(0).getGoalId()).isEqualTo(1L); | ||
assertThat(goals.get(1).getGoalId()).isEqualTo(2L); | ||
assertThat(goals.get(2).getGoalId()).isEqualTo(3L); | ||
assertThat(goals.get(3).getGoalId()).isEqualTo(4L); | ||
assertThat(goals.get(4).getGoalId()).isEqualTo(5L); | ||
assertThat(goals.get(1).getContent()).isEqualTo("다른 사람들의 피드백!"); | ||
} | ||
} | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
be/src/test/java/com/example/be/core/application/goal_subject/SubjectFindAllTest.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,47 @@ | ||
package com.example.be.core.application.goal_subject; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import com.example.be.core.application.InitServiceTest; | ||
import com.example.be.core.application.dto.response.SubjectResponse; | ||
import com.example.be.core.application.member.SubjectService; | ||
import java.util.List; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Nested; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
@DisplayName("서비스 테스트 : Subject 전체 조회") | ||
class SubjectFindAllTest extends InitServiceTest { | ||
|
||
@Autowired | ||
private SubjectService subjectService; | ||
|
||
@Nested | ||
@DisplayName("주제를 전체 조회할 때") | ||
class FindAllTest { | ||
|
||
@Nested | ||
@DisplayName("정상적인 요청이라면") | ||
class NormalTest { | ||
|
||
@Test | ||
void find_all_subjects_test() { | ||
//give & when | ||
List<SubjectResponse> subjects = subjectService.findAll(); | ||
|
||
//then | ||
assertThat(subjects).hasSize(9); | ||
assertThat(subjects.get(0).getSubjectId()).isEqualTo(1L); | ||
assertThat(subjects.get(1).getSubjectId()).isEqualTo(2L); | ||
assertThat(subjects.get(2).getSubjectId()).isEqualTo(3L); | ||
assertThat(subjects.get(3).getSubjectId()).isEqualTo(4L); | ||
assertThat(subjects.get(4).getSubjectId()).isEqualTo(5L); | ||
assertThat(subjects.get(5).getSubjectId()).isEqualTo(6L); | ||
assertThat(subjects.get(6).getSubjectId()).isEqualTo(7L); | ||
assertThat(subjects.get(7).getSubjectId()).isEqualTo(8L); | ||
assertThat(subjects.get(8).getSubjectId()).isEqualTo(9L); | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.