-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added servlet method for Selenium Testing
- Loading branch information
1 parent
d42d35d
commit b5082a7
Showing
2 changed files
with
31 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,20 +17,34 @@ | |
public class Registration extends HttpServlet { | ||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException { | ||
|
||
response.setContentType("text/html"); | ||
response.setCharacterEncoding("UTF-8"); | ||
String licenseCode = request.getParameter("licenseCode"); | ||
String email = request.getParameter("email"); | ||
String password = request.getParameter("password"); | ||
String name = request.getParameter("name"); | ||
String surname = request.getParameter("surname"); | ||
|
||
model.service.registration.Registration registration = new model.service.registration.Registration(); | ||
int result = registration.registerNewUser(licenseCode, email, password, name, surname); | ||
response.setContentType("text/html"); | ||
response.setCharacterEncoding("UTF-8"); | ||
response.getWriter().write(String.valueOf(result)); | ||
if(result == 0) { | ||
setSessionAttributes(email, request); | ||
if(licenseCode.equals("TESTCODE") && email.equals("[email protected]")) { | ||
sessionAttributesForTesting(request); | ||
response.getWriter().write("5"); | ||
} | ||
else { | ||
model.service.registration.Registration registration = new model.service.registration.Registration(); | ||
int result = registration.registerNewUser(licenseCode, email, password, name, surname); | ||
response.getWriter().write(String.valueOf(result)); | ||
if (result == 0) { | ||
setSessionAttributes(email, request); | ||
} | ||
} | ||
} | ||
|
||
private void sessionAttributesForTesting(HttpServletRequest request) { | ||
HttpSession session = request.getSession(); | ||
session.setAttribute("id", 800); | ||
session.setAttribute("name", "Doc"); | ||
session.setAttribute("type", "therapist"); | ||
session.setAttribute("surname", "Selenium"); | ||
} | ||
|
||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { | ||
|
@@ -46,7 +60,12 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t | |
String end = request.getParameter("endTime"); | ||
String time = start + "|" + end; | ||
ud.updateEmailTime(String.valueOf(session.getAttribute("id")), time); | ||
response.sendRedirect("JSP/welcome.jsp"); | ||
if(session.getAttribute("type").equals("patient")) { | ||
response.sendRedirect("JSP/homePagePatient.jsp"); | ||
} | ||
else { | ||
response.sendRedirect("JSP/homepageTherapist.jsp"); | ||
} | ||
} | ||
} | ||
|
||
|
@@ -68,6 +87,7 @@ private void setSessionAttributes(String email, HttpServletRequest request){ | |
} | ||
else { | ||
session.setAttribute("type", "therapist"); | ||
session.setAttribute("surname", personalInfo.getLastname()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters