-
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.
Merge pull request #202 from bucket-back/OMCT-380-feed-modifier-test
[OMCT-380] 피드 수정 테스트 기능 추가
- Loading branch information
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
...rc/test/java/com/programmers/bucketback/domains/feed/implementation/FeedModifierTest.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,49 @@ | ||
package com.programmers.bucketback.domains.feed.implementation; | ||
|
||
import static org.assertj.core.api.Assertions.*; | ||
import static org.mockito.BDDMockito.*; | ||
|
||
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 com.programmers.bucketback.domains.feed.FeedBuilder; | ||
import com.programmers.bucketback.domains.feed.domain.Feed; | ||
import com.programmers.bucketback.domains.feed.domain.FeedContent; | ||
import com.programmers.bucketback.domains.feed.model.FeedUpdateServiceRequest; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class FeedModifierTest { | ||
|
||
@Mock | ||
private FeedReader feedReader; | ||
|
||
@InjectMocks | ||
private FeedModifier feedModifier; | ||
|
||
@Test | ||
@DisplayName("피드를 수정한다.") | ||
void modify() { | ||
// given | ||
Long memberId = 1L; | ||
Feed feed = FeedBuilder.build(); | ||
String expectedContent = "수정된 피드"; | ||
|
||
given(feedReader.read(feed.getId(), memberId)) | ||
.willReturn(feed); | ||
|
||
FeedUpdateServiceRequest updateServiceRequest = new FeedUpdateServiceRequest(expectedContent); | ||
|
||
// when | ||
feedModifier.modify(memberId, feed.getId(), updateServiceRequest); | ||
|
||
// then | ||
FeedContent content = feed.getContent(); | ||
String actualFeedContent = content.getContent(); | ||
|
||
assertThat(actualFeedContent).isEqualTo(expectedContent); | ||
} | ||
} |