Skip to content

Instantly share code, notes, and snippets.

@adavis
Last active January 9, 2016 17:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adavis/06ccb9a097259d3fa3fa to your computer and use it in GitHub Desktop.
Save adavis/06ccb9a097259d3fa3fa to your computer and use it in GitHub Desktop.
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