-
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
1 parent
9c72207
commit 09a9649
Showing
10 changed files
with
234 additions
and
2 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
30 changes: 30 additions & 0 deletions
30
domain/src/main/java/kusitms/duduk/domain/global/Count.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 kusitms.duduk.domain.global; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class Count { | ||
|
||
private static final int ZERO = 0; | ||
private int Count; | ||
|
||
private Count(int Count) { | ||
this.Count = Count; | ||
} | ||
|
||
public static Count initial() { | ||
return new Count(ZERO); | ||
} | ||
|
||
public static Count from(int Count) { | ||
return new Count(Count); | ||
} | ||
|
||
public void increase() { | ||
this.Count++; | ||
} | ||
|
||
public void decrease() { | ||
this.Count--; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
domain/src/main/java/kusitms/duduk/domain/newsletter/NewsLetter.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,32 @@ | ||
package kusitms.duduk.domain.newsletter; | ||
|
||
import java.util.List; | ||
import kusitms.duduk.domain.global.Category; | ||
import kusitms.duduk.domain.global.Count; | ||
import kusitms.duduk.domain.global.Id; | ||
import kusitms.duduk.domain.newsletter.vo.Content; | ||
import kusitms.duduk.domain.newsletter.vo.Keywords; | ||
import kusitms.duduk.domain.newsletter.vo.Summary; | ||
import kusitms.duduk.domain.newsletter.vo.Thumbnail; | ||
import kusitms.duduk.domain.newsletter.vo.Title; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@Builder(toBuilder = true) | ||
public class NewsLetter { | ||
|
||
private Id newsLetterId; | ||
private Id editorId; | ||
private Thumbnail thumbnail; | ||
private Title title; | ||
private Content content; | ||
private Keywords keywords; | ||
private Category category; | ||
private Summary summary; | ||
private Count viewCount; | ||
private Count scrapCount; | ||
} |
21 changes: 21 additions & 0 deletions
21
domain/src/main/java/kusitms/duduk/domain/newsletter/vo/Content.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,21 @@ | ||
package kusitms.duduk.domain.newsletter.vo; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class Content { | ||
|
||
private String content; | ||
|
||
private Content(String content) { | ||
this.content = content; | ||
} | ||
|
||
public static Content from(String content) { | ||
return new Content(content); | ||
} | ||
|
||
public void revise(String content) { | ||
this.content = content; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
domain/src/main/java/kusitms/duduk/domain/newsletter/vo/Keywords.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,31 @@ | ||
package kusitms.duduk.domain.newsletter.vo; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class Keywords { | ||
|
||
List<String> words; | ||
|
||
private Keywords(List<String> words) { | ||
this.words = words; | ||
} | ||
|
||
public static Keywords from(String sentence) { | ||
List<String> list = new ArrayList<>(); | ||
for (String keyword : sentence.split(",")) { | ||
list.add(keyword); | ||
} | ||
return new Keywords(list); | ||
} | ||
|
||
public void add(String keyword) { | ||
words.add(keyword); | ||
} | ||
|
||
public void remove(String keyword) { | ||
words.remove(keyword); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
domain/src/main/java/kusitms/duduk/domain/newsletter/vo/Summary.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 kusitms.duduk.domain.newsletter.vo; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class Summary { | ||
|
||
private List<String> sentences; | ||
|
||
private Summary(List<String> sentences) { | ||
this.sentences = sentences; | ||
} | ||
|
||
public static Summary from(String summary) { | ||
List<String> list = new ArrayList<>(); | ||
for (String sentence : summary.split("\n")) { | ||
list.add(sentence); | ||
} | ||
return new Summary(list); | ||
} | ||
|
||
public void revise(int index, String sentence) { | ||
// todo : 이렇게 하면 덮어쓰나? | ||
sentences.set(index, sentence); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
domain/src/main/java/kusitms/duduk/domain/newsletter/vo/Thumbnail.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 kusitms.duduk.domain.newsletter.vo; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class Thumbnail { | ||
|
||
private String url; | ||
|
||
private Thumbnail(String url) { | ||
this.url = url; | ||
} | ||
|
||
public static Thumbnail from(String url) { | ||
return new Thumbnail(url); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
domain/src/main/java/kusitms/duduk/domain/newsletter/vo/Title.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,21 @@ | ||
package kusitms.duduk.domain.newsletter.vo; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class Title { | ||
|
||
private String title; | ||
|
||
private Title(String title) { | ||
this.title = title; | ||
} | ||
|
||
public static Title from(String title) { | ||
return new Title(title); | ||
} | ||
|
||
public void revise(String title) { | ||
this.title = title; | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
domain/src/test/java/kusitms/duduk/domain/newsletter/NewsLetterTest.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,50 @@ | ||
package kusitms.duduk.domain.newsletter; | ||
|
||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat; | ||
|
||
import kusitms.duduk.domain.global.Category; | ||
import kusitms.duduk.domain.global.Count; | ||
import kusitms.duduk.domain.newsletter.vo.Content; | ||
import kusitms.duduk.domain.newsletter.vo.Keywords; | ||
import kusitms.duduk.domain.newsletter.vo.Summary; | ||
import kusitms.duduk.domain.newsletter.vo.Thumbnail; | ||
import kusitms.duduk.domain.newsletter.vo.Title; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
@DisplayName("NewsLetter 테스트") | ||
class NewsLetterTest { | ||
|
||
@Test | ||
void 뉴스_레터_객체를_생성한다() { | ||
// given | ||
String title = "title"; | ||
String content = "content"; | ||
String thumbnail = "thumbnail"; | ||
String keywords = "keyword1,keyword2,keyword3"; | ||
String stock = "주식"; | ||
String summary = "summary\nsummary\nsummary"; | ||
|
||
// when | ||
NewsLetter newsLetter = NewsLetter.builder() | ||
.title(Title.from(title)) | ||
.content(Content.from(content)) | ||
.thumbnail(Thumbnail.from(thumbnail)) | ||
.keywords(Keywords.from(keywords)) | ||
.category(Category.from(stock)) | ||
.summary(Summary.from(summary)) | ||
.viewCount(Count.initial()) | ||
.scrapCount(Count.from(6)) | ||
.build(); | ||
|
||
// then | ||
assertThat(newsLetter.getTitle().getTitle()).isEqualTo(title); | ||
assertThat(newsLetter.getContent().getContent()).isEqualTo(content); | ||
assertThat(newsLetter.getThumbnail().getUrl()).isEqualTo(thumbnail); | ||
assertThat(newsLetter.getKeywords().getWords().size()).isEqualTo(3); | ||
assertThat(newsLetter.getCategory().getDescription()).isEqualTo(stock); | ||
assertThat(newsLetter.getSummary().getSentences().size()).isEqualTo(3); | ||
assertThat(newsLetter.getViewCount().getCount()).isEqualTo(0); | ||
assertThat(newsLetter.getScrapCount().getCount()).isEqualTo(6); | ||
} | ||
} |
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