import org.junit.Before;
import org.junit.Test;

import java.io.PrintStream;
import java.util.ArrayList;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;

/*
 * This Java source file was auto generated by running 'gradle init --type java-library'
 * by 'ptang' at '8/4/15 1:34 PM' with Gradle 2.5
 *
 * @author ptang, @date 8/4/15 1:34 PM
 */
public class LibraryTest {
    private Library library;
    private ArrayList<Book> listOfBooks;
    @Before
    public void setup(){
        library = new Library();

        listOfBooks = new ArrayList<>();
        listOfBooks.add(new Book("Catch-22","Joseph Heller", 1961));
        listOfBooks.add(new Book("Harry Potter and the Sorcerer's Stone", "JK Rowling", 1997));
        listOfBooks.add(new Book("Notes from the Underground", "Fyodor Dostoevsky", 1864));
        listOfBooks.add(new Book("Head First Java", "Bert Bates and Kathy Sierra", 2003));
    }

    @Test
    public void shouldProduceWelcomeWhenOpen() {
        assertThat(library.open(), is("Welcome to the Library! Biblioteca is available!"));
    }

    @Test
    public void shouldListNothingWhenLibraryCreatedWithNoBooks(){
        assertThat(library.listAllBooks(), is(""));
    }

    @Test
    public void shouldListAllBooksWhenLibraryCreatedWithBooks() {

        library = new Library(listOfBooks);
        assertThat(library.listAllBooks(), is("Catch-22 | Joseph Heller | 1961\n" +
                "Harry Potter and the Sorcerer's Stone | JK Rowling | 1997\n" +
                "Notes from the Underground | Fyodor Dostoevsky | 1864\n" +
                "Head First Java | Bert Bates and Kathy Sierra | 2003\n"));
    }
}

@@ -574,773 +574,920 @@
 ();%0A
-%0A        listOfBooks = new ArrayList%3C%3E();%0A        listOfBooks.add(new Book(%22Catch-22%22,%22Joseph Heller%22, 1961));%0A        listOfBooks.add(new Book(%22Harry Potter and the Sorcerer's Stone%22, %22JK Rowling%22, 1997));%0A        listOfBooks.add(new Book(%22Notes from the Underground%22, %22Fyodor Dostoevsky%22, 1864));%0A        listOfBooks.add(new Book(%22Head First Java%22, %22Bert Bates and Kathy Sierra%22, 2003));%0A    %7D%0A%0A    @Test%0A    public void shouldProduceWelcomeWhenOpen() %7B%0A        assertThat(library.open(), is(%22Welcome to the Library! Biblioteca is available!%22));%0A    %7D%0A%0A    @Test%0A    public void shouldListNothingWhenLibraryCreatedWithNoBooks()%7B%0A        assertThat(library.listAllBooks(), is(%22%22));%0A    %7D%0A%0A    @Test%0A    public void shouldListAllBooksWhenLibraryCreatedWithBooks() %7B
+    %7D%0A%0A    @Test%0A    public void shouldProduceWelcomeWhenOpen() %7B%0A        assertThat(library.open(), is(%22Welcome to the Library! Biblioteca is available!%22));%0A    %7D%0A%0A    @Test%0A    public void shouldListNothingWhenLibraryCreatedWithNoBooks()%7B%0A        assertThat(library.listAllBooks(), is(%22%22));%0A    %7D%0A%0A    @Test%0A    public void shouldListAllBooksWhenLibraryCreatedWithBooks() %7B%0A        listOfBooks = new ArrayList%3C%3E();%0A        Book book1 = mock(Book.class);%0A        Book book2 = mock(Book.class);%0A        Book book3 = mock(Book.class);%0A        listOfBooks.add(book1);%0A        listOfBooks.add(book2);%0A        listOfBooks.add(book3);%0A%0A        when(book1.toString()).thenReturn(%22Catch-22 %7C Joseph Heller %7C 1961%22);%0A        when(book2.toString()).thenReturn(%22Harry Potter and the Sorcerer's Stone %7C JK Rowling %7C 1997%22);%0A        when(book3.toString()).thenReturn(%22Notes from the Underground %7C Fyodor Dostoevsky %7C 1864%22);
 %0A%0A  
@@ -1769,83 +1769,8 @@
 4%5Cn%22
- +%0A                %22Head First Java %7C Bert Bates and Kathy Sierra %7C 2003%5Cn%22
 ));%0A

Use mocks for testing list books