This repository was archived by the owner on Nov 6, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 8 files changed +67
-23
lines changed
main/java/tv/codely/context/video/module/video
context/video/module/video/application/publish Expand file tree Collapse file tree 8 files changed +67
-23
lines changed Original file line number Diff line number Diff line change 3030}
3131
3232application {
33- mainClassName = " tv.codely.Starter "
33+ mainClassName = " tv.codely.context.video.module.video.infrastructure.VideoPublisherCliController "
3434}
Original file line number Diff line number Diff line change 11package tv .codely .context .video .module .video .application .publish ;
22
33import tv .codely .context .video .module .video .domain .Video ;
4+ import tv .codely .context .video .module .video .domain .VideoDescription ;
5+ import tv .codely .context .video .module .video .domain .VideoTitle ;
46import tv .codely .shared .domain .EventBus ;
57
68public final class VideoPublisher {
@@ -10,10 +12,12 @@ public VideoPublisher(EventBus eventBus) {
1012 this .eventBus = eventBus ;
1113 }
1214
13- public void publish (String title , String description ) {
15+ public void publish (String rawTitle , String rawDescription ) {
16+ final var title = new VideoTitle (rawTitle );
17+ final var description = new VideoDescription (rawDescription );
18+
1419 final var video = Video .publish (title , description );
1520
1621 eventBus .publish (video .pullDomainEvents ());
1722 }
18-
1923}
Original file line number Diff line number Diff line change 33import tv .codely .shared .domain .AggregateRoot ;
44
55public final class Video extends AggregateRoot {
6- private final String title ;
7- private final String description ;
6+ private final VideoTitle title ;
7+ private final VideoDescription description ;
88
9- private Video (String title , String description ) {
9+ private Video (VideoTitle title , VideoDescription description ) {
1010 this .title = title ;
1111 this .description = description ;
1212 }
1313
14- public static Video publish (String title , String description ) {
14+ public static Video publish (VideoTitle title , VideoDescription description ) {
1515 var video = new Video (title , description );
1616
17- var videoCreated = new VideoPublished (title , description );
17+ var videoCreated = new VideoPublished (title . value () , description . value () );
1818
1919 video .record (videoCreated );
2020
Original file line number Diff line number Diff line change 1+ package tv .codely .context .video .module .video .domain ;
2+
3+ public final class VideoDescription {
4+ private final String value ;
5+
6+ public VideoDescription (final String value ) {
7+ this .value = value ;
8+ }
9+
10+ public String value () {
11+ return value ;
12+ }
13+ }
Original file line number Diff line number Diff line change 1+ package tv .codely .context .video .module .video .domain ;
2+
3+ public final class VideoTitle {
4+ private final String value ;
5+
6+ public VideoTitle (String value ) {
7+ this .value = value ;
8+ }
9+
10+ public String value () {
11+ return value ;
12+ }
13+ }
Original file line number Diff line number Diff line change 1- package tv .codely ;
1+ package tv .codely . context . video . module . video . infrastructure ;
22
33import tv .codely .context .notification .module .push .application .create .SendPushToSubscribersOnVideoPublished ;
44import tv .codely .context .video .module .video .application .publish .VideoPublisher ;
88
99import java .util .Set ;
1010
11- public class Starter {
11+ public class VideoPublisherCliController {
1212 public static void main (String [] args ) {
1313 final Set <DomainEventSubscriber > subscribers = Set .of (
1414 new SendPushToSubscribersOnVideoPublished ()
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ package tv .codely .context .video .module .video .application .publish ;
2+
3+ import org .junit .jupiter .api .Test ;
4+ import tv .codely .context .notification .module .push .application .create .SendPushToSubscribersOnVideoPublished ;
5+ import tv .codely .shared .application .DomainEventSubscriber ;
6+ import tv .codely .shared .domain .EventBus ;
7+ import tv .codely .shared .infrastructure .bus .ReactorEventBus ;
8+
9+ import java .util .Set ;
10+
11+ final class VideoPublisherShould {
12+ @ Test
13+ void publish_the_video_published_domain_event () {
14+ final Set <DomainEventSubscriber > subscribers = Set .of (
15+ new SendPushToSubscribersOnVideoPublished ()
16+ );
17+ final EventBus eventBus = new ReactorEventBus (subscribers );
18+ final var videoPublisher = new VideoPublisher (eventBus );
19+
20+ final var videoTitle = "\uD83C \uDF89 New YouTube.com/CodelyTV video title" ;
21+ final var videoDescription = "This should be the video description \uD83D \uDE42 " ;
22+
23+ videoPublisher .publish (videoTitle , videoDescription );
24+
25+ }
26+
27+ }
You can’t perform that action at this time.
0 commit comments