ChangeScript implements Comparable { public String getContent() { return getFileContents(false); } ChangeScript(long id);  ChangeScript(long id, String description);  ChangeScript(long id, File file, String encoding); File getFile(); long getId(); String getDescription(); int compareTo(Object o); @Override String toString(); String getContent(); String getUndoContent();  }
@Test public void shouldReturnContentsOfFile() throws Exception { File file = createTemporaryFileWithContent("Hello\nThere!\n"); ChangeScript changeScript = new ChangeScript(5, file, "UTF-8"); assertThat(changeScript.getContent(), is("Hello\nThere!\n")); }
@Test public void contentsOfFileShouldExcludeAnythingAfterAnUndoMarker() throws Exception { File file = createTemporaryFileWithContent( "Hello\n" + "There!\n" + "-- "This is after the undo marker!\n"); ChangeScript changeScript = new ChangeScript(5, file, "UTF-8"); assertThat(changeScript.getContent(), is("Hello\nThere!\n")); }
@Test public void contentsOfFileShouldExcludeAnythingAfterAnUndoMarkerEvenWhenThatMarkerHasSomeWhitespaceAtTheEnd() throws Exception { File file = createTemporaryFileWithContent( "Hello\n" + "There!\n" + "-- "This is after the undo marker!\n"); ChangeScript changeScript = new ChangeScript(5, file, "UTF-8"); assertThat(changeScript.getContent(), is("Hello\nThere!\n")); }