Skip to content
Snippets Groups Projects
Commit ee5b3d70 authored by Tim Miller's avatar Tim Miller
Browse files

UPDATE: Bugfix on access admin data.

parent bf566ebd
No related branches found
No related tags found
No related merge requests found
...@@ -56,6 +56,7 @@ public class FotBot ...@@ -56,6 +56,7 @@ public class FotBot
* Constructs a new FotBot server with no users * Constructs a new FotBot server with no users
*/ */
public FotBot() public FotBot()
throws DuplicateUserException, InvalidUsernameException, InvalidPasswordException
{ {
passwords = new HashMap<String, String>(); passwords = new HashMap<String, String>();
stepData = new HashMap<String, List<Integer>>(); stepData = new HashMap<String, List<Integer>>();
...@@ -64,6 +65,9 @@ public class FotBot ...@@ -64,6 +65,9 @@ public class FotBot
currentDay = new Date(1, 1, 2021); currentDay = new Date(1, 1, 2021);
passwords.put(ADMIN_USERNAME, ADMIN_PASSWORD); passwords.put(ADMIN_USERNAME, ADMIN_PASSWORD);
stepData.put(ADMIN_USERNAME, new ArrayList<Integer>());
latestUpdate.put(ADMIN_USERNAME, currentDay.copy());
friends.put(ADMIN_USERNAME, new HashSet<String>());
} }
/** /**
...@@ -150,7 +154,7 @@ public class FotBot ...@@ -150,7 +154,7 @@ public class FotBot
* Assumption: the length of 'steps' is always less than or equal * Assumption: the length of 'steps' is always less than or equal
* to numbers of days since the last update * to numbers of days since the last update
* *
* Assumption: username and password are non-null * Assumption: username, password, and steps are non-null
* *
* Assumption: 'steps' records the order of the days from oldest * Assumption: 'steps' records the order of the days from oldest
* (at index 0) to most recent (at index steps.length - 1) * (at index 0) to most recent (at index steps.length - 1)
...@@ -191,6 +195,9 @@ public class FotBot ...@@ -191,6 +195,9 @@ public class FotBot
* *
* @throws NoSuchUserException if the user does not have an account * @throws NoSuchUserException if the user does not have an account
* @throws IncorrectPasswordException if the password is incorrect for this user * @throws IncorrectPasswordException if the password is incorrect for this user
*
* Assumption: username, password, and friendUsername are non-null
* Assumption: friendUsername is a registered user.
*/ */
public void addFriend(String username, String password, String friendUsername) public void addFriend(String username, String password, String friendUsername)
throws NoSuchUserException, IncorrectPasswordException throws NoSuchUserException, IncorrectPasswordException
...@@ -220,6 +227,8 @@ public class FotBot ...@@ -220,6 +227,8 @@ public class FotBot
* *
* @throws NoSuchUserException if either user ('username' or 'user') does not have an account * @throws NoSuchUserException if either user ('username' or 'user') does not have an account
* @throws IncorrectPasswordException if the password is incorrect for username * @throws IncorrectPasswordException if the password is incorrect for username
*
* Assumption: username, password, and targetUser are non-null
*/ */
public List<Integer> getStepData(String username, String password, String targetUser) public List<Integer> getStepData(String username, String password, String targetUser)
throws NoSuchUserException, IncorrectPasswordException throws NoSuchUserException, IncorrectPasswordException
...@@ -237,7 +246,6 @@ public class FotBot ...@@ -237,7 +246,6 @@ public class FotBot
return result; return result;
} }
/** /**
* Increment the current day by a number of days * Increment the current day by a number of days
*/ */
......
...@@ -56,6 +56,7 @@ public class FotBot ...@@ -56,6 +56,7 @@ public class FotBot
* Constructs a new FotBot server with no users * Constructs a new FotBot server with no users
*/ */
public FotBot() public FotBot()
throws DuplicateUserException, InvalidUsernameException, InvalidPasswordException
{ {
passwords = new HashMap<String, String>(); passwords = new HashMap<String, String>();
stepData = new HashMap<String, List<Integer>>(); stepData = new HashMap<String, List<Integer>>();
...@@ -64,6 +65,9 @@ public class FotBot ...@@ -64,6 +65,9 @@ public class FotBot
currentDay = new Date(1, 1, 2021); currentDay = new Date(1, 1, 2021);
passwords.put(ADMIN_USERNAME, ADMIN_PASSWORD); passwords.put(ADMIN_USERNAME, ADMIN_PASSWORD);
stepData.put(ADMIN_USERNAME, new ArrayList<Integer>());
latestUpdate.put(ADMIN_USERNAME, currentDay.copy());
friends.put(ADMIN_USERNAME, new HashSet<String>());
} }
/** /**
...@@ -150,7 +154,7 @@ public class FotBot ...@@ -150,7 +154,7 @@ public class FotBot
* Assumption: the length of 'steps' is always less than or equal * Assumption: the length of 'steps' is always less than or equal
* to numbers of days since the last update * to numbers of days since the last update
* *
* Assumption: username and password are non-null * Assumption: username, password, and steps are non-null
* *
* Assumption: 'steps' records the order of the days from oldest * Assumption: 'steps' records the order of the days from oldest
* (at index 0) to most recent (at index steps.length - 1) * (at index 0) to most recent (at index steps.length - 1)
...@@ -191,6 +195,9 @@ public class FotBot ...@@ -191,6 +195,9 @@ public class FotBot
* *
* @throws NoSuchUserException if the user does not have an account * @throws NoSuchUserException if the user does not have an account
* @throws IncorrectPasswordException if the password is incorrect for this user * @throws IncorrectPasswordException if the password is incorrect for this user
*
* Assumption: username, password, and friendUsername are non-null
* Assumption: friendUsername is a registered user.
*/ */
public void addFriend(String username, String password, String friendUsername) public void addFriend(String username, String password, String friendUsername)
throws NoSuchUserException, IncorrectPasswordException throws NoSuchUserException, IncorrectPasswordException
...@@ -220,6 +227,8 @@ public class FotBot ...@@ -220,6 +227,8 @@ public class FotBot
* *
* @throws NoSuchUserException if either user ('username' or 'user') does not have an account * @throws NoSuchUserException if either user ('username' or 'user') does not have an account
* @throws IncorrectPasswordException if the password is incorrect for username * @throws IncorrectPasswordException if the password is incorrect for username
*
* Assumption: username, password, and targetUser are non-null
*/ */
public List<Integer> getStepData(String username, String password, String targetUser) public List<Integer> getStepData(String username, String password, String targetUser)
throws NoSuchUserException, IncorrectPasswordException throws NoSuchUserException, IncorrectPasswordException
...@@ -237,7 +246,6 @@ public class FotBot ...@@ -237,7 +246,6 @@ public class FotBot
return result; return result;
} }
/** /**
* Increment the current day by a number of days * Increment the current day by a number of days
*/ */
......
...@@ -56,6 +56,7 @@ public class FotBot ...@@ -56,6 +56,7 @@ public class FotBot
* Constructs a new FotBot server with no users * Constructs a new FotBot server with no users
*/ */
public FotBot() public FotBot()
throws DuplicateUserException, InvalidUsernameException, InvalidPasswordException
{ {
passwords = new HashMap<String, String>(); passwords = new HashMap<String, String>();
stepData = new HashMap<String, List<Integer>>(); stepData = new HashMap<String, List<Integer>>();
...@@ -64,6 +65,9 @@ public class FotBot ...@@ -64,6 +65,9 @@ public class FotBot
currentDay = new Date(1, 1, 2021); currentDay = new Date(1, 1, 2021);
passwords.put(ADMIN_USERNAME, ADMIN_PASSWORD); passwords.put(ADMIN_USERNAME, ADMIN_PASSWORD);
stepData.put(ADMIN_USERNAME, new ArrayList<Integer>());
latestUpdate.put(ADMIN_USERNAME, currentDay.copy());
friends.put(ADMIN_USERNAME, new HashSet<String>());
} }
/** /**
...@@ -150,7 +154,7 @@ public class FotBot ...@@ -150,7 +154,7 @@ public class FotBot
* Assumption: the length of 'steps' is always less than or equal * Assumption: the length of 'steps' is always less than or equal
* to numbers of days since the last update * to numbers of days since the last update
* *
* Assumption: username and password are non-null * Assumption: username, password, and steps are non-null
* *
* Assumption: 'steps' records the order of the days from oldest * Assumption: 'steps' records the order of the days from oldest
* (at index 0) to most recent (at index steps.length - 1) * (at index 0) to most recent (at index steps.length - 1)
...@@ -191,6 +195,9 @@ public class FotBot ...@@ -191,6 +195,9 @@ public class FotBot
* *
* @throws NoSuchUserException if the user does not have an account * @throws NoSuchUserException if the user does not have an account
* @throws IncorrectPasswordException if the password is incorrect for this user * @throws IncorrectPasswordException if the password is incorrect for this user
*
* Assumption: username, password, and friendUsername are non-null
* Assumption: friendUsername is a registered user.
*/ */
public void addFriend(String username, String password, String friendUsername) public void addFriend(String username, String password, String friendUsername)
throws NoSuchUserException, IncorrectPasswordException throws NoSuchUserException, IncorrectPasswordException
...@@ -220,6 +227,8 @@ public class FotBot ...@@ -220,6 +227,8 @@ public class FotBot
* *
* @throws NoSuchUserException if either user ('username' or 'user') does not have an account * @throws NoSuchUserException if either user ('username' or 'user') does not have an account
* @throws IncorrectPasswordException if the password is incorrect for username * @throws IncorrectPasswordException if the password is incorrect for username
*
* Assumption: username, password, and targetUser are non-null
*/ */
public List<Integer> getStepData(String username, String password, String targetUser) public List<Integer> getStepData(String username, String password, String targetUser)
throws NoSuchUserException, IncorrectPasswordException throws NoSuchUserException, IncorrectPasswordException
...@@ -237,7 +246,6 @@ public class FotBot ...@@ -237,7 +246,6 @@ public class FotBot
return result; return result;
} }
/** /**
* Increment the current day by a number of days * Increment the current day by a number of days
*/ */
......
...@@ -56,6 +56,7 @@ public class FotBot ...@@ -56,6 +56,7 @@ public class FotBot
* Constructs a new FotBot server with no users * Constructs a new FotBot server with no users
*/ */
public FotBot() public FotBot()
throws DuplicateUserException, InvalidUsernameException, InvalidPasswordException
{ {
passwords = new HashMap<String, String>(); passwords = new HashMap<String, String>();
stepData = new HashMap<String, List<Integer>>(); stepData = new HashMap<String, List<Integer>>();
...@@ -64,6 +65,9 @@ public class FotBot ...@@ -64,6 +65,9 @@ public class FotBot
currentDay = new Date(1, 1, 2021); currentDay = new Date(1, 1, 2021);
passwords.put(ADMIN_USERNAME, ADMIN_PASSWORD); passwords.put(ADMIN_USERNAME, ADMIN_PASSWORD);
stepData.put(ADMIN_USERNAME, new ArrayList<Integer>());
latestUpdate.put(ADMIN_USERNAME, currentDay.copy());
friends.put(ADMIN_USERNAME, new HashSet<String>());
} }
/** /**
...@@ -150,7 +154,7 @@ public class FotBot ...@@ -150,7 +154,7 @@ public class FotBot
* Assumption: the length of 'steps' is always less than or equal * Assumption: the length of 'steps' is always less than or equal
* to numbers of days since the last update * to numbers of days since the last update
* *
* Assumption: username and password are non-null * Assumption: username, password, and steps are non-null
* *
* Assumption: 'steps' records the order of the days from oldest * Assumption: 'steps' records the order of the days from oldest
* (at index 0) to most recent (at index steps.length - 1) * (at index 0) to most recent (at index steps.length - 1)
...@@ -191,6 +195,9 @@ public class FotBot ...@@ -191,6 +195,9 @@ public class FotBot
* *
* @throws NoSuchUserException if the user does not have an account * @throws NoSuchUserException if the user does not have an account
* @throws IncorrectPasswordException if the password is incorrect for this user * @throws IncorrectPasswordException if the password is incorrect for this user
*
* Assumption: username, password, and friendUsername are non-null
* Assumption: friendUsername is a registered user.
*/ */
public void addFriend(String username, String password, String friendUsername) public void addFriend(String username, String password, String friendUsername)
throws NoSuchUserException, IncorrectPasswordException throws NoSuchUserException, IncorrectPasswordException
...@@ -220,6 +227,8 @@ public class FotBot ...@@ -220,6 +227,8 @@ public class FotBot
* *
* @throws NoSuchUserException if either user ('username' or 'user') does not have an account * @throws NoSuchUserException if either user ('username' or 'user') does not have an account
* @throws IncorrectPasswordException if the password is incorrect for username * @throws IncorrectPasswordException if the password is incorrect for username
*
* Assumption: username, password, and targetUser are non-null
*/ */
public List<Integer> getStepData(String username, String password, String targetUser) public List<Integer> getStepData(String username, String password, String targetUser)
throws NoSuchUserException, IncorrectPasswordException throws NoSuchUserException, IncorrectPasswordException
...@@ -237,7 +246,6 @@ public class FotBot ...@@ -237,7 +246,6 @@ public class FotBot
return result; return result;
} }
/** /**
* Increment the current day by a number of days * Increment the current day by a number of days
*/ */
......
...@@ -56,6 +56,7 @@ public class FotBot ...@@ -56,6 +56,7 @@ public class FotBot
* Constructs a new FotBot server with no users * Constructs a new FotBot server with no users
*/ */
public FotBot() public FotBot()
throws DuplicateUserException, InvalidUsernameException, InvalidPasswordException
{ {
passwords = new HashMap<String, String>(); passwords = new HashMap<String, String>();
stepData = new HashMap<String, List<Integer>>(); stepData = new HashMap<String, List<Integer>>();
...@@ -64,6 +65,9 @@ public class FotBot ...@@ -64,6 +65,9 @@ public class FotBot
currentDay = new Date(1, 1, 2021); currentDay = new Date(1, 1, 2021);
passwords.put(ADMIN_USERNAME, ADMIN_PASSWORD); passwords.put(ADMIN_USERNAME, ADMIN_PASSWORD);
stepData.put(ADMIN_USERNAME, new ArrayList<Integer>());
latestUpdate.put(ADMIN_USERNAME, currentDay.copy());
friends.put(ADMIN_USERNAME, new HashSet<String>());
} }
/** /**
...@@ -150,7 +154,7 @@ public class FotBot ...@@ -150,7 +154,7 @@ public class FotBot
* Assumption: the length of 'steps' is always less than or equal * Assumption: the length of 'steps' is always less than or equal
* to numbers of days since the last update * to numbers of days since the last update
* *
* Assumption: username and password are non-null * Assumption: username, password, and steps are non-null
* *
* Assumption: 'steps' records the order of the days from oldest * Assumption: 'steps' records the order of the days from oldest
* (at index 0) to most recent (at index steps.length - 1) * (at index 0) to most recent (at index steps.length - 1)
...@@ -191,6 +195,9 @@ public class FotBot ...@@ -191,6 +195,9 @@ public class FotBot
* *
* @throws NoSuchUserException if the user does not have an account * @throws NoSuchUserException if the user does not have an account
* @throws IncorrectPasswordException if the password is incorrect for this user * @throws IncorrectPasswordException if the password is incorrect for this user
*
* Assumption: username, password, and friendUsername are non-null
* Assumption: friendUsername is a registered user.
*/ */
public void addFriend(String username, String password, String friendUsername) public void addFriend(String username, String password, String friendUsername)
throws NoSuchUserException, IncorrectPasswordException throws NoSuchUserException, IncorrectPasswordException
...@@ -220,6 +227,8 @@ public class FotBot ...@@ -220,6 +227,8 @@ public class FotBot
* *
* @throws NoSuchUserException if either user ('username' or 'user') does not have an account * @throws NoSuchUserException if either user ('username' or 'user') does not have an account
* @throws IncorrectPasswordException if the password is incorrect for username * @throws IncorrectPasswordException if the password is incorrect for username
*
* Assumption: username, password, and targetUser are non-null
*/ */
public List<Integer> getStepData(String username, String password, String targetUser) public List<Integer> getStepData(String username, String password, String targetUser)
throws NoSuchUserException, IncorrectPasswordException throws NoSuchUserException, IncorrectPasswordException
...@@ -237,7 +246,6 @@ public class FotBot ...@@ -237,7 +246,6 @@ public class FotBot
return result; return result;
} }
/** /**
* Increment the current day by a number of days * Increment the current day by a number of days
*/ */
......
...@@ -64,7 +64,10 @@ public class FotBot ...@@ -64,7 +64,10 @@ public class FotBot
friends = new HashMap<String, Set<String>>(); friends = new HashMap<String, Set<String>>();
currentDay = new Date(1, 1, 2021); currentDay = new Date(1, 1, 2021);
this.register(ADMIN_USERNAME, ADMIN_PASSWORD); passwords.put(ADMIN_USERNAME, ADMIN_PASSWORD);
stepData.put(ADMIN_USERNAME, new ArrayList<Integer>());
latestUpdate.put(ADMIN_USERNAME, currentDay.copy());
friends.put(ADMIN_USERNAME, new HashSet<String>());
} }
/** /**
...@@ -194,6 +197,7 @@ public class FotBot ...@@ -194,6 +197,7 @@ public class FotBot
* @throws IncorrectPasswordException if the password is incorrect for this user * @throws IncorrectPasswordException if the password is incorrect for this user
* *
* Assumption: username, password, and friendUsername are non-null * Assumption: username, password, and friendUsername are non-null
* Assumption: friendUsername is a registered user.
*/ */
public void addFriend(String username, String password, String friendUsername) public void addFriend(String username, String password, String friendUsername)
throws NoSuchUserException, IncorrectPasswordException throws NoSuchUserException, IncorrectPasswordException
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment