From c5ad5f9d2e3fa21632f3ba576132942697aa726c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Arellano?= Date: Sun, 15 May 2022 21:08:35 -0500 Subject: [PATCH] Initial changes --- .gitignore | 6 ++++ .../application/SendNotificationTwitter.java | 27 ++++++++++++++++ .../application/TwitterRequestDto.java | 31 +++++++++++++++++++ .../twitter/domain/TwitterRepository.java | 9 ++++++ .../infrastructure/TwitterController.java | 13 ++++++++ 5 files changed, 86 insertions(+) create mode 100644 src/mooc/main/tv/codely/mooc/twitter/application/SendNotificationTwitter.java create mode 100644 src/mooc/main/tv/codely/mooc/twitter/application/TwitterRequestDto.java create mode 100644 src/mooc/main/tv/codely/mooc/twitter/domain/TwitterRepository.java create mode 100644 src/mooc/main/tv/codely/mooc/twitter/infrastructure/TwitterController.java diff --git a/.gitignore b/.gitignore index dc57c96..d767ddb 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,9 @@ out/ # Ignore Gradle GUI config gradle-app.setting +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + diff --git a/src/mooc/main/tv/codely/mooc/twitter/application/SendNotificationTwitter.java b/src/mooc/main/tv/codely/mooc/twitter/application/SendNotificationTwitter.java new file mode 100644 index 0000000..809f845 --- /dev/null +++ b/src/mooc/main/tv/codely/mooc/twitter/application/SendNotificationTwitter.java @@ -0,0 +1,27 @@ +package tv.codely.mooc.twitter.application; + +import tv.codely.mooc.twitter.domain.TwitterRepository; +import tv.codely.mooc.video.domain.VideoPublished; +import tv.codely.shared.application.DomainEventSubscriber; + +public class SendNotificationTwitter implements DomainEventSubscriber { + + private TwitterRepository twitterAPI; + + public SendNotificationTwitter(TwitterRepository twitterAPI) { + this.twitterAPI = twitterAPI; + } + + @Override + public Class subscribedTo() { + return VideoPublished.class; + } + + @Override + public void consume(VideoPublished event) { + TwitterRequestDto twit = new TwitterRequestDto( + String.format("Hey! A new video is published: <%s>", event.title()) + ); + twitterAPI.create(twit); + } +} diff --git a/src/mooc/main/tv/codely/mooc/twitter/application/TwitterRequestDto.java b/src/mooc/main/tv/codely/mooc/twitter/application/TwitterRequestDto.java new file mode 100644 index 0000000..af86a1a --- /dev/null +++ b/src/mooc/main/tv/codely/mooc/twitter/application/TwitterRequestDto.java @@ -0,0 +1,31 @@ +package tv.codely.mooc.twitter.application; + +public class TwitterRequestDto { + private String id; + private String text; + + public TwitterRequestDto(String id, String text) { + this.id = id; + this.text = text; + } + + public TwitterRequestDto(String text) { + this.text = text; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } +} diff --git a/src/mooc/main/tv/codely/mooc/twitter/domain/TwitterRepository.java b/src/mooc/main/tv/codely/mooc/twitter/domain/TwitterRepository.java new file mode 100644 index 0000000..139ffed --- /dev/null +++ b/src/mooc/main/tv/codely/mooc/twitter/domain/TwitterRepository.java @@ -0,0 +1,9 @@ +package tv.codely.mooc.twitter.domain; + +import tv.codely.mooc.twitter.application.TwitterRequestDto; + +public interface TwitterRepository { + + void create(TwitterRequestDto twit); + +} diff --git a/src/mooc/main/tv/codely/mooc/twitter/infrastructure/TwitterController.java b/src/mooc/main/tv/codely/mooc/twitter/infrastructure/TwitterController.java new file mode 100644 index 0000000..a034f37 --- /dev/null +++ b/src/mooc/main/tv/codely/mooc/twitter/infrastructure/TwitterController.java @@ -0,0 +1,13 @@ +package tv.codely.mooc.twitter.infrastructure; + + +import tv.codely.mooc.twitter.application.TwitterRequestDto; +import tv.codely.mooc.twitter.domain.TwitterRepository; + +public class TwitterController implements TwitterRepository { + + @Override + public void create(TwitterRequestDto twit) { + System.out.println(twit.getText()); + } +}