Skip to content

Instantly share code, notes, and snippets.

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

Embed
What would you like to do?
Demonstrates needless data being created inside test method
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 void setId(long id) {
this.id = id;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getDisplayDate() {
return displayDate;
}
public void setDisplayDate(String displayDate) {
this.displayDate = displayDate;
}
public double getDuration() {
return duration;
}
public void setDuration(double duration) {
this.duration = duration;
}
}
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";
String displayDate = "Jan. 08, 2016";
double duration = 0.30;
playbackService.setCurrentVideo(createVideo(url, displayDate, duration));
String actualUrl = playbackService.playCurrentVideo();
assertEquals("the urls are not the same", url, actualUrl);
}
private Video createVideo(String url, String displayDate, double duration) {
Video video = new Video();
video.setUrl(url);
video.setDisplayDate(displayDate);
video.setDuration(duration);
return video;
}
}
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.