<commit_before>package com.twu.biblioteca;

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

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

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

/**
 * Created by jessieleung on 31/12/14.
 */
public class BibliotecaUserTests {

    BibliotecaApp app;
    UsersList users;
    private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
    private final ByteArrayOutputStream errContent = new ByteArrayOutputStream();

    public void setUp(){
        app = new BibliotecaApp();
        users = app.getUsers();
        users.add(new Customer("<NAME>","<EMAIL>","94123456","123-4567","Scarhead"));
        users.add(new Customer("Voldemort","<EMAIL>","93413233","666-0000","EvilnessIsAwesome"));
        users.add(new Customer("Gandalf","<EMAIL>","93231233","0123-4123","YouShallNotPass"));
        users.add(new Librarian("94567823","369-1357"));
    }

    @Before
    public void setUpStreams() {
        System.setOut(new PrintStream(outContent));
        System.setErr(new PrintStream(errContent));
        setUp();
    }

    @After
    public void cleanUpStreams() {
        System.setOut(null);
        System.setErr(null);
    }


    @Test
    public void shouldHaveCorrectUserWhenRetrievingUser(){
        Customer chosenUser = (Customer) users.get(1);
        assertEquals("Voldemort",chosenUser.getName());
        assertEquals("<EMAIL>",chosenUser.getEmail());
        assertEquals("93413233",chosenUser.getContactNumber());
        assertEquals("666-0000",chosenUser.getLibraryNumber());
        assertEquals("EvilnessIsAwesome",chosenUser.getPassword());
    }

    @Test
    public void shouldDisplayMessageOnSuccessfulLogin(){
        Boolean result = app.requestLogin("666-0000","EvilnessIsAwesome");
        assertTrue(result);
        assertEquals("You are now logged in.\n", outContent.toString());
    }

    @Test
    public void shouldDisplayMessageOnUnsuccessfulLoginWrongPassword(){
        Boolean result = app.requestLogin("666-0000","EvilnessIsNotAwesome");
        assertFalse(result);
        assertEquals("Unsuccessful login.\n", outContent.toString());
    }

    @Test
    public void shouldDisplayMessageOnUnsuccessfulLoginUserDoesNotExist(){
        Boolean result = app.requestLogin("666-1234","NotEvenAUser");
        assertFalse(result);
        assertEquals("Unsuccessful login.\n", outContent.toString());
    }

    @Test
    public void shouldDisplayCustomerOnBookListOnlyForLibraries(){

    }

    @Test
    public void shouldDisplayCustomerDetailsWhenLoggedIn(){

    }

}<commit_msg>Adding in new test - attach current customer to the book checked out<commit_after>package com.twu.biblioteca;

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

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

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

/**
 * Created by jessieleung on 31/12/14.
 */
public class BibliotecaUserTests {

    BibliotecaApp app;
    BookCollection library;
    UsersList users;
    private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
    private final ByteArrayOutputStream errContent = new ByteArrayOutputStream();

    public void setUp(){
        app = new BibliotecaApp();
        users = app.getUsers();
        users.add(new Customer("<NAME>","<EMAIL>","94123456","123-4567","Scarhead"));
        users.add(new Customer("Voldemort","<EMAIL>","93413233","666-0000","EvilnessIsAwesome"));
        users.add(new Customer("Gandalf","<EMAIL>","93231233","0123-4123","YouShallNotPass"));
        users.add(new Librarian("94567823","369-1357"));
        library = app.getBookCollection();
        library.add("<NAME> and the Philosopher's Stone", "<NAME>", "1997");
        library.add("World War Z", "<NAME>", "2006");
        library.add("Artificial Intelligence", "<NAME> and <NAME>", "1994");
    }

    @Before
    public void setUpStreams() {
        System.setOut(new PrintStream(outContent));
        System.setErr(new PrintStream(errContent));
        setUp();
    }

    @After
    public void cleanUpStreams() {
        System.setOut(null);
        System.setErr(null);
    }


    @Test
    public void shouldHaveCorrectUserWhenRetrievingUser(){
        Customer chosenUser = (Customer) users.get(1);
        assertEquals("Voldemort",chosenUser.getName());
        assertEquals("<EMAIL>",chosenUser.getEmail());
        assertEquals("93413233",chosenUser.getContactNumber());
        assertEquals("666-0000",chosenUser.getLibraryNumber());
        assertEquals("EvilnessIsAwesome",chosenUser.getPassword());
    }

    @Test
    public void shouldDisplayMessageOnSuccessfulLogin(){
        Boolean result = app.requestLogin("666-0000","EvilnessIsAwesome");
        assertTrue(result);
        assertEquals("You are now logged in.\n", outContent.toString());
    }

    @Test
    public void shouldDisplayMessageOnUnsuccessfulLoginWrongPassword(){
        Boolean result = app.requestLogin("666-0000","EvilnessIsNotAwesome");
        assertFalse(result);
        assertEquals("Unsuccessful login.\n", outContent.toString());
    }

    @Test
    public void shouldDisplayMessageOnUnsuccessfulLoginUserDoesNotExist(){
        Boolean result = app.requestLogin("666-1234","NotEvenAUser");
        assertFalse(result);
        assertEquals("Unsuccessful login.\n", outContent.toString());
    }

    @Test
    public void shouldHaveCustomerAssociatedWithBookTheyHaveCheckedOut(){
        app.setCurrentUser("<NAME>");
        Book thisBook = (Book) library.checkoutItem(1);
        assertEquals("<NAME>",thisBook.getCurrentBorrower());
    }

    @Test
    public void shouldDisplayCustomerOnBookListOnlyForLibrarians(){

    }

    @Test
    public void shouldDisplayCustomerDetailsWhenLoggedIn(){

    }

}
{'fraction_non_alphanumeric': 0.12727568270481143, 'fraction_numerical': 0.03592327698309493, 'mean_word_length': 3.8258823529411763, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1783230', 'n_tokens_mistral': 1885, 'n_tokens_neox': 1733, 'n_words': 317}