{
// get the Managers out
ManagerLayer manager = ManagerLayer.getInstance();
UserManager users = manager.getUsers();
SessionManager sessions = manager.getSessions();
ProjectManager projects = manager.getProjects();
String originalSsid = sessions.createSession(u2);
Session originalSession = sessions.getSession(originalSsid);
String projectId = "proj1";
Project p = new Project("wpisuite", projectId);
try
{
projects.makeEntity(originalSession, p.toJSON());
}
catch(ConflictException e)
{
// this is okay because it means the project already exists in the database.
}
String newSsid = sessions.switchToProject(originalSsid, projectId);
Session projectSession = sessions.getSession(newSsid);
assertFalse(sessions.sessionExists(originalSsid));
assertTrue(projectSession != null);
assertTrue(originalSession.getProject() == null);
assertTrue(projectSession.getProject().equals(p));
try
{
projects.deleteEntity(projectSession, p.toJSON());
}
catch(NotFoundException e)
{
// this is okay since we are trying to make the project 'not found'
}