Last active
January 9, 2016 17:44
-
-
Save adavis/06ccb9a097259d3fa3fa to your computer and use it in GitHub Desktop.
Sample demonstrating using Builder Pattern for VO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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