package edu.duke.cabig.c3pr.domain;

import java.sql.Timestamp;
import java.util.Date;

import edu.duke.cabig.c3pr.AbstractTestCase;
import edu.duke.cabig.c3pr.utils.UserCreationHelper;

public class UserTestCase extends AbstractTestCase{
	
	private User user ;
	private UserCreationHelper userCreationHelper = new UserCreationHelper();
	public void setUserCreationHelper(UserCreationHelper userCreationHelper) {
		this.userCreationHelper = userCreationHelper;
	}

	@Override
	protected void setUp() throws Exception {
		super.setUp();
		user = userCreationHelper.buildBasicResearchStaffUser();
	}
	
	public void testResetToken(){
		Timestamp timestamp = new Timestamp(200);
		user.setTokenTime(timestamp);
		user.resetToken();
		assertNotEquals("after reset token time, time stamp should be differnt then earlier", timestamp, user.getTokenTime());
	}
	
	public void testGetPasswordAge(){
        Timestamp timestamp = new Timestamp(new Date().getTime() - 1000);
		user.setPasswordLastSet(timestamp);
		System.out.println("######## : " + user.getPasswordAge());
		assertEquals("password age is 1000 miliseconds", 1000, user.getPasswordAge());
	}
	
	public void testAddPasswordToHistory(){
		assertEquals("password history size is 0", 0, user.getPasswordHistory().size());
		user.addPasswordToHistory("testpasswd", 1)	;
		assertEquals("password history size is 1", 1, user.getPasswordHistory().size());
	}
	
	public void testAddPasswordToHistory1(){
		assertEquals("password history size is 0", 0, user.getPasswordHistory().size());
		user.addPasswordToHistory("testpasswd", 1)	;
		user.addPasswordToHistory("testpasswd2", 1)	;
		assertEquals("password history size is 1", 1, user.getPasswordHistory().size());
		assertEquals("last stored password should be testpasswd2", "testpasswd2", user.getPasswordHistory().get(user.getPasswordHistory().size() -1));
	}
	
	public void testGetLastFirst(){
		assertEquals("getLastFirst should evaluate to Scott, John","Scott, John",user.getLastFirst());
	}
	
	public void testGetFullName(){
		assertEquals("getLastFirst should evaluate to John Scott","John Scott",user.getFullName());
	}
	
}

@@ -180,16 +180,83 @@
 elper;%0A%0A
+// TODO: Auto-generated Javadoc%0A/**%0A * The Class UserTestCase.%0A */%0A
 public c
@@ -301,16 +301,34 @@
 Case%7B%0A%09%0A
+%09/** The user. */%0A
 %09private
@@ -340,16 +340,52 @@
  user ;%0A
+%09%0A%09/** The user creation helper. */%0A
 %09private
@@ -451,16 +451,127 @@
 lper();%0A
+%09%0A%09/**%0A%09 * Sets the user creation helper.%0A%09 * %0A%09 * @param userCreationHelper the new user creation helper%0A%09 */%0A
 %09public 
@@ -690,16 +690,108 @@
 er;%0A%09%7D%0A%0A
+%09/* (non-Javadoc)%0A%09 * @see edu.nwu.bioinformatics.commons.testing.CoreTestCase#setUp()%0A%09 */%0A
 %09@Overri
@@ -909,32 +909,64 @@
 affUser();%0A%09%7D%0A%09%0A
+%09/**%0A%09 * Test reset token.%0A%09 */%0A
 %09public void tes
@@ -1195,32 +1195,69 @@
 enTime());%0A%09%7D%0A%09%0A
+%09/**%0A%09 * Test get password age.%0A%09 */%0A
 %09public void tes
@@ -1526,32 +1526,76 @@
 ordAge());%0A%09%7D%0A%09%0A
+%09/**%0A%09 * Test add password to history.%0A%09 */%0A
 %09public void tes
@@ -1829,32 +1829,77 @@
 ).size());%0A%09%7D%0A%09%0A
+%09/**%0A%09 * Test add password to history1.%0A%09 */%0A
 %09public void tes
@@ -2327,32 +2327,67 @@
 ze() -1));%0A%09%7D%0A%09%0A
+%09/**%0A%09 * Test get last first.%0A%09 */%0A
 %09public void tes
@@ -2503,18 +2503,52 @@
 ());%0A%09%7D%0A
-
 %09%0A
+%09/**%0A%09 * Test get full name.%0A%09 */%0A
 %09public 

test case coverage improvement