-
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.
- Loading branch information
Showing
15 changed files
with
247 additions
and
13 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
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
44 changes: 44 additions & 0 deletions
44
smeem-api/src/test/java/com/smeem/diary/service/DiaryCommandServiceTest.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,44 @@ | ||
package com.smeem.diary.service; | ||
|
||
import com.smeem.api.diary.service.DiaryCommandService; | ||
import com.smeem.api.diary.service.dto.request.DiaryModifyServiceRequest; | ||
import com.smeem.domain.diary.adapter.DiaryFinder; | ||
import com.smeem.support.fixture.DiaryFixture; | ||
import lombok.val; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.Mockito.doReturn; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
public class DiaryCommandServiceTest { | ||
|
||
@InjectMocks | ||
private DiaryCommandService diaryService; | ||
|
||
@Mock | ||
private DiaryFinder diaryFinder; | ||
|
||
@Test | ||
@DisplayName("[성공] 유효한 일기를 수정할 수 있다.") | ||
void modifyValidDiary() { | ||
// given | ||
val contentBeforeModified = "content"; | ||
val contentAfterModified = "modifiedContent"; | ||
val diary = DiaryFixture.diary().id(1L).content(contentBeforeModified).build(); | ||
val request = new DiaryModifyServiceRequest(diary.getId(), contentAfterModified); | ||
|
||
doReturn(diary).when(diaryFinder).findById(diary.getId()); | ||
|
||
// when | ||
diaryService.modifyDiary(request); | ||
|
||
// then | ||
assertThat(diary.getContent()).isEqualTo(contentAfterModified); | ||
} | ||
} |
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
79 changes: 79 additions & 0 deletions
79
smeem-api/src/test/java/com/smeem/goal/service/GoalServiceIntegrationTest.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,79 @@ | ||
package com.smeem.goal.service; | ||
|
||
import com.smeem.api.goal.service.GoalService; | ||
import com.smeem.api.goal.service.dto.request.GoalGetServiceRequest; | ||
import com.smeem.api.goal.service.dto.response.GoalGetServiceResponse; | ||
import com.smeem.domain.goal.model.Goal; | ||
import com.smeem.domain.goal.model.GoalType; | ||
import com.smeem.domain.goal.repository.GoalRepository; | ||
import com.smeem.support.ServiceIntegrationTest; | ||
import com.smeem.support.fixture.GoalFixture; | ||
import lombok.val; | ||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
import java.util.List; | ||
|
||
public class GoalServiceIntegrationTest extends ServiceIntegrationTest { | ||
|
||
@Autowired | ||
GoalService goalService; | ||
|
||
@Autowired | ||
GoalRepository goalRepository; | ||
|
||
@AfterEach | ||
void tearDown() { | ||
goalRepository.deleteAllInBatch(); | ||
} | ||
|
||
@Test | ||
@DisplayName("[성공] 모든 학습 목표를 조회할 수 있다.") | ||
void getAllGoals() throws Exception { | ||
// given | ||
val goal1 = GoalFixture.goal().type(GoalType.DEVELOP).build(); | ||
val goal2 = GoalFixture.goal().type(GoalType.APPLY).build(); | ||
val goal3 = GoalFixture.goal().type(GoalType.BUSINESS).build(); | ||
val goal4 = GoalFixture.goal().type(GoalType.EXAM).build(); | ||
val goal5 = GoalFixture.goal().type(GoalType.NONE).build(); | ||
val goal6 = GoalFixture.goal().type(GoalType.HOBBY).build(); | ||
goalRepository.saveAll(List.of(goal1, goal2, goal3, goal4, goal5, goal6)); | ||
|
||
// when | ||
val response = goalService.getAllGoals(); | ||
|
||
// then | ||
Assertions.assertThat(response.goals()) | ||
.extracting("goalType", "goalDescription") | ||
.containsExactlyInAnyOrder( | ||
Assertions.tuple(GoalType.DEVELOP.name(), GoalType.DEVELOP.getDescription()), | ||
Assertions.tuple(GoalType.APPLY.name(), GoalType.APPLY.getDescription()), | ||
Assertions.tuple(GoalType.EXAM.name(), GoalType.EXAM.getDescription()), | ||
Assertions.tuple(GoalType.BUSINESS.name(), GoalType.BUSINESS.getDescription()), | ||
Assertions.tuple(GoalType.NONE.name(), GoalType.NONE.getDescription()), | ||
Assertions.tuple(GoalType.HOBBY.name(), GoalType.HOBBY.getDescription()) | ||
); | ||
} | ||
|
||
@Test | ||
@DisplayName("[성공] 학습 목표 유형으로 학습 목표를 조회할 수 있다.") | ||
void getByType() throws Exception { | ||
// given | ||
|
||
goalRepository.save(GoalFixture.goal().type(GoalType.DEVELOP).build()); | ||
|
||
val request = GoalGetServiceRequest.of(GoalType.DEVELOP); | ||
|
||
// when | ||
final GoalGetServiceResponse response = goalService.getByType(request); | ||
|
||
// then | ||
Assertions.assertThat(response) | ||
.extracting("goalType", "way", "detail") | ||
.containsExactly(GoalType.DEVELOP, "test-goal-way", "test-goal-detail"); | ||
|
||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
smeem-api/src/test/java/com/smeem/support/fixture/DiaryFixture.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,35 @@ | ||
package com.smeem.support.fixture; | ||
|
||
import com.smeem.domain.diary.model.Diary; | ||
import com.smeem.domain.member.model.LangType; | ||
import lombok.NoArgsConstructor; | ||
|
||
import static com.smeem.domain.member.model.LangType.en; | ||
import static lombok.AccessLevel.PRIVATE; | ||
|
||
@NoArgsConstructor(access = PRIVATE) | ||
public class DiaryFixture { | ||
|
||
private Long id; | ||
private String content; | ||
private final LangType targetLang = en; | ||
private final boolean isPublic = false; | ||
|
||
public static DiaryFixture diary() { | ||
return new DiaryFixture(); | ||
} | ||
|
||
public DiaryFixture id(Long id) { | ||
this.id = id; | ||
return this; | ||
} | ||
|
||
public DiaryFixture content(String content) { | ||
this.content = content; | ||
return this; | ||
} | ||
|
||
public Diary build() { | ||
return new Diary(id, content, targetLang, isPublic); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
smeem-api/src/test/java/com/smeem/support/fixture/GoalFixture.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.smeem.support.fixture; | ||
|
||
import com.smeem.domain.goal.model.Goal; | ||
import com.smeem.domain.goal.model.GoalType; | ||
|
||
public class GoalFixture { | ||
|
||
private GoalType type; | ||
|
||
private String way = "test-goal-way"; | ||
private String detail = "test-goal-detail"; | ||
|
||
public static GoalFixture goal() { | ||
return new GoalFixture(); | ||
} | ||
|
||
public GoalFixture type(GoalType type) { | ||
this.type = type; | ||
return this; | ||
} | ||
|
||
public Goal build() { | ||
return Goal.builder() | ||
.type(type) | ||
.way(way) | ||
.detail(detail) | ||
.build(); | ||
} | ||
|
||
} |
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
17 changes: 17 additions & 0 deletions
17
smeem-domain/src/main/java/com/smeem/domain/visit/adapter/VisitDeleter.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,17 @@ | ||
package com.smeem.domain.visit.adapter; | ||
|
||
import com.smeem.domain.member.model.Member; | ||
import com.smeem.domain.support.RepositoryAdapter; | ||
import com.smeem.domain.visit.repository.VisitRepository; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RepositoryAdapter | ||
@RequiredArgsConstructor | ||
public class VisitDeleter { | ||
|
||
private final VisitRepository visitRepository; | ||
|
||
public void deleteByMember(Member member) { | ||
visitRepository.deleteByMember(member); | ||
} | ||
} |
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