-
Notifications
You must be signed in to change notification settings - Fork 28
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
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
backend/src/test/java/wooteco/prolog/roadmap/domain/RecommendedPostTest.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 wooteco.prolog.roadmap.domain; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.SoftAssertions.assertSoftly; | ||
|
||
class RecommendedPostTest { | ||
|
||
@Test | ||
@DisplayName("삭제 기능 테스트") | ||
void remove() { | ||
//given | ||
final RecommendedPost recommendedPost = new RecommendedPost(1L, "https://example.com", null); | ||
final Keyword keyword = Keyword.createKeyword("이름", "설명", 1, 1, 1L, null); | ||
recommendedPost.addKeyword(keyword); | ||
|
||
//when | ||
final Keyword before = recommendedPost.getKeyword(); | ||
recommendedPost.remove(); | ||
final Keyword after = recommendedPost.getKeyword(); | ||
|
||
//then | ||
Assertions.assertAll( | ||
() -> assertThat(before).isNotNull(), | ||
() -> assertThat(after).isNull() | ||
); | ||
|
||
} | ||
|
||
@Test | ||
@DisplayName("소속 키워드를 추가한다") | ||
void addKeyword() { | ||
//given | ||
final RecommendedPost post = new RecommendedPost("http://연어"); | ||
final Keyword keyword = Keyword.createKeyword("name", "description", 1, 1, 1L, null); | ||
|
||
//when | ||
post.addKeyword(keyword); | ||
|
||
//then | ||
assertSoftly(soft -> { | ||
assertThat(post.getKeyword()).isEqualTo(keyword); | ||
assertThat(keyword.getRecommendedPosts()).containsExactly(post); | ||
}); | ||
} | ||
} |