NIHVIVO-2279 Fix unit test.
This commit is contained in:
parent
a8b74facd1
commit
63078edb62
3 changed files with 109 additions and 8 deletions
|
@ -20,6 +20,8 @@ import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import stubs.edu.cornell.mannlib.vitro.webapp.dao.UserDaoStub;
|
||||||
|
import stubs.edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactoryStub;
|
||||||
import stubs.javax.servlet.ServletConfigStub;
|
import stubs.javax.servlet.ServletConfigStub;
|
||||||
import stubs.javax.servlet.ServletContextStub;
|
import stubs.javax.servlet.ServletContextStub;
|
||||||
import stubs.javax.servlet.http.HttpServletRequestStub;
|
import stubs.javax.servlet.http.HttpServletRequestStub;
|
||||||
|
@ -40,6 +42,8 @@ public class AuthenticateTest extends AbstractTestClass {
|
||||||
|
|
||||||
private AuthenticatorStub authenticator;
|
private AuthenticatorStub authenticator;
|
||||||
private ServletContextStub servletContext;
|
private ServletContextStub servletContext;
|
||||||
|
private WebappDaoFactoryStub webappDaoFactory;
|
||||||
|
private UserDaoStub userDao;
|
||||||
private ServletConfigStub servletConfig;
|
private ServletConfigStub servletConfig;
|
||||||
private HttpSessionStub session;
|
private HttpSessionStub session;
|
||||||
private HttpServletRequestStub request;
|
private HttpServletRequestStub request;
|
||||||
|
@ -110,7 +114,17 @@ public class AuthenticateTest extends AbstractTestClass {
|
||||||
authenticator.setAssociatedUri(OLD_SELF.username,
|
authenticator.setAssociatedUri(OLD_SELF.username,
|
||||||
"old_self_associated_uri");
|
"old_self_associated_uri");
|
||||||
|
|
||||||
|
userDao = new UserDaoStub();
|
||||||
|
userDao.addUser(createUserFromUserInfo(NEW_DBA));
|
||||||
|
userDao.addUser(createUserFromUserInfo(OLD_DBA));
|
||||||
|
userDao.addUser(createUserFromUserInfo(OLD_SELF));
|
||||||
|
userDao.addUser(createUserFromUserInfo(OLD_STRANGER));
|
||||||
|
|
||||||
|
webappDaoFactory = new WebappDaoFactoryStub();
|
||||||
|
webappDaoFactory.setUserDao(userDao);
|
||||||
|
|
||||||
servletContext = new ServletContextStub();
|
servletContext = new ServletContextStub();
|
||||||
|
servletContext.setAttribute("webappDaoFactory", webappDaoFactory);
|
||||||
|
|
||||||
servletConfig = new ServletConfigStub();
|
servletConfig = new ServletConfigStub();
|
||||||
servletConfig.setServletContext(servletContext);
|
servletConfig.setServletContext(servletContext);
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package stubs.edu.cornell.mannlib.vitro.webapp.dao;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.beans.User;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.UserDao;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO
|
||||||
|
*/
|
||||||
|
public class UserDaoStub implements UserDao {
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Stub infrastructure
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
private final Map<String, User> userByUriMap = new HashMap<String, User>();
|
||||||
|
|
||||||
|
public void addUser(User user) {
|
||||||
|
userByUriMap.put(user.getURI(), user);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Stub methods
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public User getUserByURI(String URI) {
|
||||||
|
return userByUriMap.get(URI);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Un-implemented methods
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public User getUserByUsername(String username) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"UserDaoStub.getUserByUsername() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<User> getAllUsers() {
|
||||||
|
throw new RuntimeException("UserDaoStub.getAllUsers() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateUser(User user) {
|
||||||
|
throw new RuntimeException("UserDaoStub.updateUser() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String insertUser(User user) {
|
||||||
|
throw new RuntimeException("UserDaoStub.insertUser() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteUser(User user) {
|
||||||
|
throw new RuntimeException("UserDaoStub.deleteUser() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getIndividualsUserMayEditAs(String userURI) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"UserDaoStub.getIndividualsUserMayEditAs() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getUserAccountEmails() {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"UserDaoStub.getUserAccountEmails() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUserEmailAddress(String userURI) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"UserDaoStub.getUserEmailAddress() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -12,7 +12,6 @@ import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyStatementDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyStatementDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.DatatypeDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.DatatypeDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.DisplayModelDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.DisplayModelDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.FlagDao;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.KeywordDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.KeywordDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.KeywordIndividualRelationDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.KeywordIndividualRelationDao;
|
||||||
|
@ -59,6 +58,12 @@ public class WebappDaoFactoryStub implements WebappDaoFactory {
|
||||||
this.objectPropertyDao = objectPropertyDao;
|
this.objectPropertyDao = objectPropertyDao;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO This goes away when the UserAccounts stuff is fully implemented -- jb
|
||||||
|
private UserDao userDao;
|
||||||
|
public void setUserDao(UserDao userDao) {
|
||||||
|
this.userDao = userDao;
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Stub methods
|
// Stub methods
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
@ -78,6 +83,12 @@ public class WebappDaoFactoryStub implements WebappDaoFactory {
|
||||||
return this.objectPropertyDao;
|
return this.objectPropertyDao;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO This goes away when the UserAccounts stuff is fully implemented -- jb
|
||||||
|
@Override
|
||||||
|
public UserDao getUserDao() {
|
||||||
|
return this.userDao;
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Un-implemented methods
|
// Un-implemented methods
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
@ -214,13 +225,6 @@ public class WebappDaoFactoryStub implements WebappDaoFactory {
|
||||||
"WebappDaoFactory.getLinktypeDao() not implemented.");
|
"WebappDaoFactory.getLinktypeDao() not implemented.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO This goes away when the UserAccounts stuff is fully implemented -- jb
|
|
||||||
@Override
|
|
||||||
public UserDao getUserDao() {
|
|
||||||
throw new RuntimeException(
|
|
||||||
"WebappDaoFactory.getUserDao() not implemented.");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserAccountsDao getUserAccountsDao() {
|
public UserAccountsDao getUserAccountsDao() {
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue