Skip to content
This repository has been archived by the owner on Nov 6, 2023. It is now read-only.

Initial changes #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ out/
# Ignore Gradle GUI config
gradle-app.setting

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

Original file line number Diff line number Diff line change
@@ -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<VideoPublished> {

private TwitterRepository twitterAPI;

public SendNotificationTwitter(TwitterRepository twitterAPI) {
this.twitterAPI = twitterAPI;
}

@Override
public Class<VideoPublished> 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);
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package tv.codely.mooc.twitter.domain;

import tv.codely.mooc.twitter.application.TwitterRequestDto;

public interface TwitterRepository {

void create(TwitterRequestDto twit);

}
Original file line number Diff line number Diff line change
@@ -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());
}
}