// Path: acmeair-customer-common/src/main/java/com/acmeair/entities/CustomerAddress.java
// public interface CustomerAddress {
// 
// 	
// 	String getStreetAddress1();
// 	void setStreetAddress1(String streetAddress1);
// 	String getStreetAddress2();
// 	void setStreetAddress2(String streetAddress2);
// 	String getCity();
// 	void setCity(String city);
// 	String getStateProvince();
// 	void setStateProvince(String stateProvince);
// 	String getCountry();
// 	void setCountry(String country);
// 	String getPostalCode();
// 	void setPostalCode(String postalCode);
// 		
// }
// 
// Path: acmeair-customer-common/src/main/java/com/acmeair/entities/CustomerSession.java
// public interface CustomerSession {
// 
// 	String SESSIONID_COOKIE_NAME = "sessionid";
// 
// 	String getId();
// 
// 
// 	String getCustomerid();
// 
// 
// 	Date getLastAccessedTime();
// 	
// 
// 	Date getTimeoutTime();
// 
// 	
// }
// 
// Path: acmeair-customer-service/src/main/java/com/acmeair/morphia/repositories/CustomerRepository.java
// public interface CustomerRepository extends CrudRepository<CustomerImpl, String> {
// 
// }
// 
// Path: acmeair-customer-service/src/main/java/com/acmeair/morphia/repositories/CustomerSessionRepository.java
// public interface CustomerSessionRepository extends CrudRepository<CustomerSessionImpl, String> {
// 
// }


import br.com.six2six.fixturefactory.Fixture;
import br.com.six2six.fixturefactory.loader.FixtureFactoryLoader;
import com.acmeair.entities.Customer;
import com.acmeair.entities.CustomerAddress;
import com.acmeair.entities.CustomerSession;
import com.acmeair.morphia.entities.CustomerAddressImpl;
import com.acmeair.morphia.entities.CustomerImpl;
import com.acmeair.morphia.entities.CustomerSessionImpl;
import com.acmeair.morphia.repositories.CustomerRepository;
import com.acmeair.morphia.repositories.CustomerSessionRepository;
import com.acmeair.service.KeyGenerator;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import java.util.Date;
import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
        when(customerRepository.findOne(customer.getCustomerId())).thenReturn(this.customer);

        boolean isValid = customerService.validateCustomer(customer.getUsername(), uniquify("wrong password"));

        assertThat(isValid, is(false));
    }

    @Test
    public void inValidCustomerIfUserDoesNotExist() {
        boolean isValid = customerService.validateCustomer(uniquify("unknown user"), uniquify("wrong password"));

        assertThat(isValid, is(false));
    }

    @Test
    public void savesSessionIntoDatabase() {
        CustomerSession session = customerService.createSession(customer.getCustomerId());

        Date now = new Date();

        assertThat(session.getId(), is(sessionId));
        assertThat(session.getCustomerid(), is(customer.getCustomerId()));
        assertThat(session.getTimeoutTime().after(now), is(true));
        verify(sessionRepository).save((CustomerSessionImpl) session);
    }

    @Test
    public void deletesSessionFromDatabaseWhenInvalidated() {
        customerService.invalidateSession(sessionId);

// Path: acmeair-customer-common/src/main/java/com/acmeair/entities/CustomerAddress.java
// public interface CustomerAddress {
// 
// 	
// 	String getStreetAddress1();
// 	void setStreetAddress1(String streetAddress1);
// 	String getStreetAddress2();
// 	void setStreetAddress2(String streetAddress2);
// 	String getCity();
// 	void setCity(String city);
// 	String getStateProvince();
// 	void setStateProvince(String stateProvince);
// 	String getCountry();
// 	void setCountry(String country);
// 	String getPostalCode();
// 	void setPostalCode(String postalCode);
// 		
// }
// 
// Path: acmeair-customer-common/src/main/java/com/acmeair/entities/CustomerSession.java
// public interface CustomerSession {
// 
// 	String SESSIONID_COOKIE_NAME = "sessionid";
// 
// 	String getId();
// 
// 
// 	String getCustomerid();
// 
// 
// 	Date getLastAccessedTime();
// 	
// 
// 	Date getTimeoutTime();
// 
// 	
// }
// 
// Path: acmeair-customer-service/src/main/java/com/acmeair/morphia/repositories/CustomerRepository.java
// public interface CustomerRepository extends CrudRepository<CustomerImpl, String> {
// 
// }
// 
// Path: acmeair-customer-service/src/main/java/com/acmeair/morphia/repositories/CustomerSessionRepository.java
// public interface CustomerSessionRepository extends CrudRepository<CustomerSessionImpl, String> {
// 
// }


// Path: acmeair-customer-service/src/test/java/com/acmeair/morphia/services/CustomerServiceImplTest.java
import br.com.six2six.fixturefactory.Fixture;
import br.com.six2six.fixturefactory.loader.FixtureFactoryLoader;
import com.acmeair.entities.Customer;
import com.acmeair.entities.CustomerAddress;
import com.acmeair.entities.CustomerSession;
import com.acmeair.morphia.entities.CustomerAddressImpl;
import com.acmeair.morphia.entities.CustomerImpl;
import com.acmeair.morphia.entities.CustomerSessionImpl;
import com.acmeair.morphia.repositories.CustomerRepository;
import com.acmeair.morphia.repositories.CustomerSessionRepository;
import com.acmeair.service.KeyGenerator;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import java.util.Date;
import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

        when(customerRepository.findOne(customer.getCustomerId())).thenReturn(this.customer);

        boolean isValid = customerService.validateCustomer(customer.getUsername(), uniquify("wrong password"));

        assertThat(isValid, is(false));
    }

    @Test
    public void inValidCustomerIfUserDoesNotExist() {
        boolean isValid = customerService.validateCustomer(uniquify("unknown user"), uniquify("wrong password"));

        assertThat(isValid, is(false));
    }

    @Test
    public void savesSessionIntoDatabase() {
        CustomerSession session = customerService.createSession(customer.getCustomerId());

        Date now = new Date();

        assertThat(session.getId(), is(sessionId));
        assertThat(session.getCustomerid(), is(customer.getCustomerId()));
        assertThat(session.getTimeoutTime().after(now), is(true));
        verify(sessionRepository).save((CustomerSessionImpl) session);
    }

    @Test
    public void deletesSessionFromDatabaseWhenInvalidated() {
        customerService.invalidateSession(sessionId);

        verify(sessionRepository).delete(sessionId);