-
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
4 changed files
with
39 additions
and
76 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
|
||
import java.util.stream.IntStream; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
|
@@ -18,37 +19,41 @@ | |
import kgu.developers.domain.user.domain.User; | ||
|
||
public class PostDomainTest { | ||
private Post post; | ||
private User author; | ||
private static final String TITLE = "Valid Title"; | ||
private static final String CONTENT = "This is valid content."; | ||
|
||
@BeforeEach | ||
public void init() { | ||
author = User.create("202411345", | ||
"password", | ||
"홍길동", | ||
"[email protected]", | ||
"010-1234-5678", CSE); | ||
|
||
post = Post.create(TITLE, CONTENT, NEWS, author); | ||
} | ||
|
||
@Test | ||
@DisplayName("POST 객체를 생성할 수 있다") | ||
public void createPost_Success() { | ||
// given | ||
String title = "Valid Title"; | ||
String content = "This is valid content."; | ||
Category category = NEWS; | ||
User user = getUser(); | ||
|
||
// when | ||
Post post = Post.create(title, content, category, user); | ||
|
||
// then | ||
assertNotNull(post); | ||
assertEquals(title, post.getTitle()); | ||
assertEquals(content, post.getContent()); | ||
assertEquals(TITLE, post.getTitle()); | ||
assertEquals(CONTENT, post.getContent()); | ||
assertEquals(0, post.getViews()); | ||
assertFalse(post.isPinned()); | ||
assertEquals(category, post.getCategory()); | ||
assertEquals(user, post.getAuthor()); | ||
assertEquals(NEWS, post.getCategory()); | ||
assertEquals(author, post.getAuthor()); | ||
} | ||
|
||
@Test | ||
@DisplayName("POST 제목을 업데이트할 수 있다") | ||
public void updatePostTitle_Success() { | ||
// given | ||
String title = "Valid Title"; | ||
String content = "This is valid content."; | ||
User user = getUser(); | ||
|
||
Post post = Post.create(title, content, NEWS, user); | ||
String newTitle = "Updated Title"; | ||
|
||
// when | ||
|
@@ -62,11 +67,6 @@ public void updatePostTitle_Success() { | |
@DisplayName("POST 내용을 업데이트할 수 있다") | ||
public void updatePostContent_Success() { | ||
// given | ||
String title = "Valid Title"; | ||
String content = "This is valid content."; | ||
User user = getUser(); | ||
|
||
Post post = Post.create(title, content, NEWS, user); | ||
String newContent = "Updated Content"; | ||
|
||
// when | ||
|
@@ -80,11 +80,6 @@ public void updatePostContent_Success() { | |
@DisplayName("POST 카테고리를 업데이트할 수 있다") | ||
public void updatePostCategory_Success() { | ||
// given | ||
String title = "Valid Title"; | ||
String content = "This is valid content."; | ||
User user = getUser(); | ||
|
||
Post post = Post.create(title, content, NEWS, user); | ||
Category newCategory = NOTIFICATION; | ||
|
||
// when | ||
|
@@ -98,11 +93,6 @@ public void updatePostCategory_Success() { | |
@DisplayName("POST 조회수를 증가시킬 수 있다") | ||
public void increasePostViews_Success() { | ||
// given | ||
String title = "Valid Title"; | ||
String content = "This is valid content."; | ||
User user = getUser(); | ||
|
||
Post post = Post.create(title, content, NEWS, user); | ||
int incrementCount = 5; | ||
|
||
// when | ||
|
@@ -116,12 +106,6 @@ public void increasePostViews_Success() { | |
@Test | ||
@DisplayName("POST 고정 여부를 토글할 수 있다") | ||
public void togglePostPinned_Success() { | ||
// given | ||
String title = "Valid Title"; | ||
String content = "This is valid content."; | ||
User user = getUser(); | ||
|
||
Post post = Post.create(title, content, NEWS, user); | ||
|
||
// when | ||
post.togglePinned(); | ||
|
@@ -133,15 +117,4 @@ public void togglePostPinned_Success() { | |
// then | ||
assertFalse(post.isPinned()); | ||
} | ||
|
||
private User getUser() { | ||
String id = "202411345"; | ||
String password = "password"; | ||
String name = "홍길동"; | ||
String email = "[email protected]"; | ||
String phone = "010-1234-5678"; | ||
|
||
return User.create(id, password, name, email, phone, CSE); | ||
} | ||
|
||
} |
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 |
---|---|---|
|
@@ -5,31 +5,32 @@ | |
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import kgu.developers.domain.professor.domain.Professor; | ||
import kgu.developers.domain.professor.domain.Role; | ||
|
||
public class ProfessorDomainTest { | ||
private Professor professor; | ||
private static final String NAME = "박민준"; | ||
private static final Role ROLE = PROFESSOR; | ||
private static final String CONTACT = "010-1234-5678"; | ||
private static final String EMAIL = "[email protected]"; | ||
private static final String IMAGE = "https://image.com/professor/profile/image"; | ||
private static final String OFFICE_LOC = "8000호"; | ||
|
||
private Professor createTestProfessor() { | ||
return Professor.create(NAME, ROLE, CONTACT, EMAIL, IMAGE, OFFICE_LOC); | ||
@BeforeEach | ||
public void init() { | ||
professor = Professor.create(NAME, ROLE, CONTACT, EMAIL, IMAGE, OFFICE_LOC); | ||
} | ||
|
||
@Test | ||
@DisplayName("PROFESSOR 객체를 생성할 수 있다") | ||
public void createProfessor_Success() { | ||
|
||
// when | ||
Professor professor = createTestProfessor(); | ||
|
||
// then | ||
assertNotNull(professor); | ||
assertEquals(NAME, professor.getName()); | ||
|
@@ -43,8 +44,6 @@ public void createProfessor_Success() { | |
@Test | ||
@DisplayName("PROFESSOR 객체의 이름을 수정할 수 있다") | ||
public void updateName_Success() { | ||
// given | ||
Professor professor = createTestProfessor(); | ||
|
||
// when | ||
String newName = "이신행"; | ||
|
@@ -57,8 +56,6 @@ public void updateName_Success() { | |
@Test | ||
@DisplayName("PROFESSOR 객체의 역할을 수정할 수 있다") | ||
public void updateRole_Success() { | ||
// given | ||
Professor professor = createTestProfessor(); | ||
|
||
// when | ||
Role newRole = ASSISTANT; | ||
|
@@ -71,8 +68,6 @@ public void updateRole_Success() { | |
@Test | ||
@DisplayName("PROFESSOR 객체의 연락처를 수정할 수 있다") | ||
public void updateContact_Success() { | ||
// given | ||
Professor professor = createTestProfessor(); | ||
|
||
// when | ||
String newContact = "010-1234-8765"; | ||
|
@@ -85,8 +80,6 @@ public void updateContact_Success() { | |
@Test | ||
@DisplayName("PROFESSOR 객체의 메일을 수정할 수 있다") | ||
public void updateEmail_Success() { | ||
// given | ||
Professor professor = createTestProfessor(); | ||
|
||
// when | ||
String newEmail = "[email protected]"; | ||
|