package com.twu.biblioteca;

import java.util.HashMap;

/**
 * Created by qiyuesong on 22/6/15.
 */
public class Authenticator {
    private HashMap<Customer, Credential> customerCredentials;

    public Authenticator(){

    }

    public Authenticator(HashMap<Customer, Credential> customerCredentials){
        this.customerCredentials = customerCredentials;
    }

    public Customer authenticate(String number, String password){
        return null;
    }
}

@@ -52,387 +52,1588 @@
 ap;%0A
-%0A/**%0A * Created by qiyuesong on 22/6/15.%0A */%0Apublic class Authenticator %7B%0A    private HashMap%3CCustomer, Credential%3E customerCredentials;%0A%0A    public Authenticator()%7B%0A%0A    %7D%0A%0A    public Authenticator(HashMap%3CCustomer, Credential%3E customerCredentials)%7B%0A        this.customerCredentials = customerCredentials;%0A    %7D%0A%0A    public Customer authenticate(String number, String password)%7B
+import java.util.Iterator;%0Aimport java.util.Map;%0A%0Aimport static com.twu.biblioteca.PredefinedUserCredentials.*;%0Aimport static com.twu.biblioteca.PredefinedUserDetails.*;%0A%0A/**%0A * Created by qiyuesong on 22/6/15.%0A */%0Apublic class Authenticator %7B%0A    private HashMap%3CCustomer, Credential%3E customerCredentials;%0A%0A    public Authenticator()%7B%0A        // Load all predefined customer credentials.%0A        this.customerCredentials = new HashMap%3CCustomer, Credential%3E();%0A        this.customerCredentials.put(new Customer(CUSTOMER_ONE_NAME, CUSTOMER_ONE_EMAIL, CUSTOMER_ONE_PHONENUMBER), new Credential(CUSTOMER_ONE_LIBRARY_NUMBER, CUSTOMER_ONE_PASSWORD));%0A        this.customerCredentials.put(new Customer(CUSTOMER_TWO_NAME, CUSTOMER_TWO_EMAIL, CUSTOMER_TWO_PHONENUMBER), new Credential(CUSTOMER_TWO_LIBRARY_NUMBER, CUSTOMER_TWO_PASSWORD));%0A    %7D%0A%0A    public Authenticator(HashMap%3CCustomer, Credential%3E customerCredentials)%7B%0A        this.customerCredentials = customerCredentials;%0A    %7D%0A%0A    public Customer authenticate(String number, String password)%7B%0A        this.customerCredentials.values();%0A        Iterator iterator = this.customerCredentials.entrySet().iterator();%0A        while (iterator.hasNext()) %7B%0A            Map.Entry%3CCustomer, Credential%3E pair = (Map.Entry%3CCustomer, Credential%3E)iterator.next();%0A            if(pair.getValue().getLibraryNumber().equals(number) && pair.getValue().getPassword().equals(password))%7B%0A                Customer currentCustomer = pair.getKey();%0A                currentCustomer.login();%0A                return currentCustomer;%0A            %7D%0A        %7D
 %0A   

refactor the authenticator class to pass the tests