Skip to content

Instantly share code, notes, and snippets.

@adavis adavis/RightVideo.java
Last active Jan 9, 2016

Embed
What would you like to do?
Sample demonstrating using Builder Pattern for VO
package info.adavis.sample.models;
/**
* Sample Domain Object used for demonstration
*
* @author Annyce Davis
*/
public class Video {
private long id;
private String url;
private String displayDate;
private double duration;
public long getId() {
return id;
}
public Video setId(long id) {
this.id = id;
return this;
}
public String getUrl() {
return url;
}
public Video setUrl(String url) {
this.url = url;
return this;
}
public String getDisplayDate() {
return displayDate;
}
public Video setDisplayDate(String displayDate) {
this.displayDate = displayDate;
return this;
}
public double getDuration() {
return duration;
}
public Video setDuration(double duration) {
this.duration = duration;
return this;
}
}
package info.adavis.sample.services;
import org.junit.Before;
import org.junit.Test;
import info.adavis.sample.models.Video;
import static org.junit.Assert.assertEquals;
/**
* @author Annyce Davis
*/
public class VideoPlaybackServiceTest {
private VideoPlaybackService playbackService;
@Before
public void setUp() {
playbackService = new VideoPlaybackService();
}
@Test
public void shouldReceiveCurrentUrlWhenVideoAvailable() {
String url = "http://www.my_video.mp4";
playbackService.setCurrentVideo(new Video().setUrl(url));
String actualUrl = playbackService.playCurrentVideo();
assertEquals("the urls are not the same", url, actualUrl);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.