diff --git a/iTrust/WebRoot/auth/patient/cancelApptPatient.jsp b/iTrust/WebRoot/auth/patient/cancelApptPatient.jsp index 1da59f1cb5bfd884eaaad7aeda5e88dbec300466..e515680dbb16bd005aa3eee00f5f7493803cddd5 100644 --- a/iTrust/WebRoot/auth/patient/cancelApptPatient.jsp +++ b/iTrust/WebRoot/auth/patient/cancelApptPatient.jsp @@ -1,24 +1,17 @@ <%@page import="java.text.ParseException"%> -<%@page import="java.sql.Timestamp"%> <%@page import="java.util.Date"%> +<%@page import="java.text.DateFormat"%> <%@page import="java.text.SimpleDateFormat"%> <%@page import="edu.ncsu.csc.itrust.action.EditApptAction"%> <%@page import="edu.ncsu.csc.itrust.action.EditApptTypeAction"%> <%@page import="edu.ncsu.csc.itrust.beans.ApptBean"%> <%@page import="edu.ncsu.csc.itrust.beans.ApptTypeBean"%> <%@page import="edu.ncsu.csc.itrust.dao.mysql.ApptTypeDAO"%> -<%@page import="edu.ncsu.csc.itrust.beans.HCPVisitBean"%> -<%@page import="edu.ncsu.csc.itrust.action.ViewVisitedHCPsAction"%> -<%@page import="edu.ncsu.csc.itrust.beans.PersonnelBean"%> <%@page errorPage="/auth/exceptionHandler.jsp"%> -<%@page import="edu.ncsu.csc.itrust.action.AddApptRequestAction"%> -<%@page import="edu.ncsu.csc.itrust.beans.ApptRequestBean"%> <%@page import="java.util.List"%> - <%@page import="edu.ncsu.csc.itrust.action.ViewMyApptsAction"%> <%@page import="edu.ncsu.csc.itrust.exception.FormValidationException"%> <%@page import="edu.ncsu.csc.itrust.exception.ITrustException"%> -<%@page import="java.text.DateFormat"%> <%@include file="/global.jsp"%> @@ -28,14 +21,7 @@ <%@include file="/header.jsp"%> <% EditApptAction editAction = new EditApptAction(prodDAO, loggedInMID.longValue()); - AddApptRequestAction action = new AddApptRequestAction(prodDAO); //ViewAppt in HCP - ViewVisitedHCPsAction hcpAction = new ViewVisitedHCPsAction( - prodDAO, loggedInMID.longValue()); //ViewAppt in HCP - - List<HCPVisitBean> visits = hcpAction.getVisitedHCPs(); - ApptTypeDAO apptTypeDAO = prodDAO.getApptTypeDAO(); - List<ApptTypeBean> apptTypes = apptTypeDAO.getApptTypes(); String msg = ""; long hcpid = 0L; String comment = ""; @@ -46,23 +32,21 @@ String apptType = ""; String prompt = ""; - EditApptTypeAction types = new EditApptTypeAction(prodDAO, loggedInMID.longValue()); - ViewMyApptsAction viewAction = new ViewMyApptsAction(prodDAO, loggedInMID.longValue()); ApptBean original = null; String aptParameter = ""; if (request.getParameter("apt") != null) { aptParameter = request.getParameter("apt"); try { - int apptID = Integer.parseInt(aptParameter); - original = editAction.getAppt(apptID); - if (original == null){ - response.sendRedirect("viewMyAppts.jsp"); - } + int apptID = Integer.parseInt(aptParameter); + original = editAction.getAppt(apptID); + if (original == null){ + response.sendRedirect("viewMyAppts.jsp"); + } } catch (NullPointerException npe) { - response.sendRedirect("viewMyAppts.jsp"); + response.sendRedirect("viewMyAppts.jsp"); } catch (NumberFormatException e) { - // Handle Exception - response.sendRedirect("viewMyAppts.jsp"); + // Handle Exception + response.sendRedirect("viewMyAppts.jsp"); } } else { response.sendRedirect("viewMyAppts.jsp"); @@ -73,9 +57,9 @@ String pidString = (String) session.getAttribute("pid"); patientID = Long.parseLong(pidString); try { - editAction.getName(patientID); + editAction.getName(patientID); } catch (ITrustException ite) { - patientID = 0L; + patientID = 0L; } } @@ -104,27 +88,24 @@ // Delete the appointment ApptBean appt = new ApptBean(); appt.setApptID(Integer.parseInt(request.getParameter("apptID"))); - headerMessage = editAction.removeAppt(appt); if(headerMessage.startsWith("Success")) { hideForm = true; session.removeAttribute("pid"); - loggingAction.logEvent(TransactionType.APPOINTMENT_REMOVE, loggedInMID.longValue(), original.getPatient(), ""+original.getApptID()); - %> + loggingAction.logEvent(TransactionType.APPOINTMENT_REMOVE, + loggedInMID.longValue(), original.getPatient(), ""+original.getApptID()); +%> <div align=center> <span class="iTrustMessage"><%=StringEscapeUtils.escapeHtml(headerMessage)%></span> </div> - <% +<% } else { - - %> - <div align=center> - <span class="iTrustError"><%=StringEscapeUtils.escapeHtml(headerMessage)%></span> - </div> - <% +%> + <div align=center> + <span class="iTrustError"><%=StringEscapeUtils.escapeHtml(headerMessage)%></span> + </div> +<% } - - } } %> @@ -132,17 +113,18 @@ <% if (msg.contains("ERROR")) { %> -<span class="iTrustError"><%=msg%></span> + <span class="iTrustError"><%=msg%></span> <% } else { %> -<span class="iTrustMessage"><%=msg%></span> + <span class="iTrustMessage"><%=msg%></span> <% } %> <%=prompt%> -<%Date d = new Date(original.getDate().getTime()); -DateFormat format = new SimpleDateFormat("MM/dd/yyyy hh:mm a"); +<% + Date d = new Date(original.getDate().getTime()); + DateFormat format = new SimpleDateFormat("MM/dd/yyyy hh:mm a"); %> <div> <h4>The following appointment will be canceled by pressing the "Cancel Appointment" button.</h4> @@ -152,15 +134,14 @@ DateFormat format = new SimpleDateFormat("MM/dd/yyyy hh:mm a"); <p><b>Date/Time:</b> <%= StringEscapeUtils.escapeHtml("" + ( format.format(d) )) %></p> <p><b>Duration:</b> <%= StringEscapeUtils.escapeHtml("" + ( apptTypeDAO.getApptType(original.getApptType()).getDuration()+" minutes" )) %></p> </div> - <% -if(!hideForm){ + if(!hideForm){ +%> + <form id="mainForm" type="hidden" method="post" action="cancelApptPatient.jsp?apt=<%=aptParameter %>&apptID=<%=original.getApptID() %>"> + <input type="submit" value="Cancel Appointment" name="editApptButton" id="removeButton" onClick="document.getElementById('editAppt').value='Remove';"/> + <input type="hidden" id="editAppt" name="editAppt" value=""/> + </form> +<% + } %> -<form id="mainForm" type="hidden" method="post" action="cancelApptPatient.jsp?apt=<%=aptParameter %>&apptID=<%=original.getApptID() %>"> - <input type="submit" value="Cancel Appointment" name="editApptButton" id="removeButton" onClick="document.getElementById('editAppt').value='Remove';"/> - - <input type="hidden" id="editAppt" name="editAppt" value=""/> - -</form> -<%}%> <%@include file="/footer.jsp"%> diff --git a/iTrust/WebRoot/auth/patient/editApptPatient.jsp b/iTrust/WebRoot/auth/patient/editApptPatient.jsp index 7dfe0a8943ba729bde0078a45d7eb8e937bc497d..d78f3ea6c08e4ed252bee5228c87e9561eae597b 100644 --- a/iTrust/WebRoot/auth/patient/editApptPatient.jsp +++ b/iTrust/WebRoot/auth/patient/editApptPatient.jsp @@ -1,24 +1,21 @@ <%@page import="java.text.ParseException"%> <%@page import="java.sql.Timestamp"%> <%@page import="java.util.Date"%> +<%@page import="java.text.DateFormat"%> <%@page import="java.text.SimpleDateFormat"%> <%@page import="edu.ncsu.csc.itrust.action.EditApptAction"%> -<%@page import="edu.ncsu.csc.itrust.action.EditApptTypeAction"%> <%@page import="edu.ncsu.csc.itrust.beans.ApptBean"%> <%@page import="edu.ncsu.csc.itrust.beans.ApptTypeBean"%> <%@page import="edu.ncsu.csc.itrust.dao.mysql.ApptTypeDAO"%> <%@page import="edu.ncsu.csc.itrust.beans.HCPVisitBean"%> <%@page import="edu.ncsu.csc.itrust.action.ViewVisitedHCPsAction"%> -<%@page import="edu.ncsu.csc.itrust.beans.PersonnelBean"%> <%@page errorPage="/auth/exceptionHandler.jsp"%> <%@page import="edu.ncsu.csc.itrust.action.AddApptRequestAction"%> <%@page import="edu.ncsu.csc.itrust.beans.ApptRequestBean"%> <%@page import="java.util.List"%> - <%@page import="edu.ncsu.csc.itrust.action.ViewMyApptsAction"%> <%@page import="edu.ncsu.csc.itrust.exception.FormValidationException"%> <%@page import="edu.ncsu.csc.itrust.exception.ITrustException"%> -<%@page import="java.text.DateFormat"%> <%@include file="/global.jsp"%> @@ -31,7 +28,6 @@ AddApptRequestAction action = new AddApptRequestAction(prodDAO); //ViewAppt in HCP ViewVisitedHCPsAction hcpAction = new ViewVisitedHCPsAction( prodDAO, loggedInMID.longValue()); //ViewAppt in HCP - List<HCPVisitBean> visits = hcpAction.getVisitedHCPs(); ApptTypeDAO apptTypeDAO = prodDAO.getApptTypeDAO(); @@ -46,23 +42,22 @@ String apptType = ""; String prompt = ""; - EditApptTypeAction types = new EditApptTypeAction(prodDAO, loggedInMID.longValue()); ViewMyApptsAction viewAction = new ViewMyApptsAction(prodDAO, loggedInMID.longValue()); ApptBean original = null; String aptParameter = ""; if (request.getParameter("apt") != null) { aptParameter = request.getParameter("apt"); try { - int apptID = Integer.parseInt(aptParameter); - original = editAction.getAppt(apptID); - if (original == null){ - response.sendRedirect("viewMyApptsPatient.jsp"); - } + int apptID = Integer.parseInt(aptParameter); + original = editAction.getAppt(apptID); + if (original == null){ + response.sendRedirect("viewMyApptsPatient.jsp"); + } } catch (NullPointerException npe) { - response.sendRedirect("viewMyApptsPatient.jsp"); + response.sendRedirect("viewMyApptsPatient.jsp"); } catch (NumberFormatException e) { - // Handle Exception - response.sendRedirect("viewMyApptsPatient.jsp"); + // Handle Exception + response.sendRedirect("viewMyApptsPatient.jsp"); } } else { response.sendRedirect("viewMyApptsPatient.jsp"); @@ -73,16 +68,15 @@ String pidString = (String) session.getAttribute("pid"); patientID = Long.parseLong(pidString); try { - editAction.getName(patientID); + editAction.getName(patientID); } catch (ITrustException ite) { - patientID = 0L; + patientID = 0L; } } boolean hideForm = false; - - boolean error = false; - String hidden = ""; + //boolean error = false; + //String hidden = ""; Date oldDate = new Date(original.getDate().getTime()); DateFormat dFormat = new SimpleDateFormat("MM/dd/yyyy"); @@ -102,15 +96,13 @@ if (request.getParameter("editAppt") != null && request.getParameter("apptID") != null) { String headerMessage = ""; if (request.getParameter("editAppt").equals("Request")) { - ApptBean appt = new ApptBean(); appt.setPatient(loggedInMID); hcpid = Long.parseLong(request.getParameter("lhcp")); appt.setHcp(hcpid); comment = request.getParameter("comment"); appt.setComment(comment); - SimpleDateFormat frmt = new SimpleDateFormat( - "MM/dd/yyyy hh:mm a"); + SimpleDateFormat frmt = new SimpleDateFormat("MM/dd/yyyy hh:mm a"); date = request.getParameter("startDate"); date = date.trim(); hourI = request.getParameter("time1"); @@ -118,150 +110,174 @@ tod = request.getParameter("time3"); apptType = request.getParameter("apptType"); appt.setApptType(apptType); - try { + try { if(date.length() == 10){ - Date d = frmt.parse(date + " " + hourI + ":" + minuteI - + " " + tod); + Date d = frmt.parse(date + " " + hourI + ":" + minuteI + " " + tod); appt.setDate(new Timestamp(d.getTime())); - ApptRequestBean req = new ApptRequestBean(); - req.setRequestedAppt(appt); - msg = action.addApptRequest(req); - if (msg.contains("conflicts")) { - msg = "ERROR: " + msg; - frmt = new SimpleDateFormat("MM/dd/yyyy hh:mm a"); - List<ApptBean> open = action.getNextAvailableAppts(3, appt); - prompt="<br/>The following nearby time slots are available:<br/>"; - int index = 0; - for(ApptBean possible : open) { - index++; - String newDate = frmt.format(possible.getDate()); - prompt += "<div style='padding:5px;margin:5px;float:left;border:1px solid black;'><b>Option " + index+ "</b><br/>"+ frmt.format(possible.getDate()); - prompt+="<form action='appointmentRequests.jsp' method='post'>" - +"<input type='hidden' name='lhcp' value='"+hcpid+"'/>" - +"<input type='hidden' name='apptType' value='"+apptType+"'/> " - +"<input type='hidden' name='startDate' value='"+newDate.substring(0,10)+"'/>" - +"<input type='hidden' name='time1' value='"+newDate.substring(11,13)+"'/>" - +"<input type='hidden' name='time2' value='"+newDate.substring(14,16)+"'/>" - +"<input type='hidden' name='time3' value='"+newDate.substring(17)+"'/>" - +"<input type='hidden' name='comment' value='"+comment+"'/>" - +"<input type='submit' name='request' value='Select this time'/>" - +"</form></div>"; - - } - prompt+="<div style='clear:both;'><br/></div>"; - } else { - loggingAction.logEvent( + if(appt.getDate().before(new Timestamp(System.currentTimeMillis()))){ + msg = "ERROR: The scheduled date of this appointment has already passed."; + } + else { + ApptRequestBean req = new ApptRequestBean(); + req.setRequestedAppt(appt); + msg = action.addApptRequest(req); + if (msg.contains("conflicts")) { + msg = "ERROR: " + msg; + frmt = new SimpleDateFormat("MM/dd/yyyy hh:mm a"); + List<ApptBean> open = action.getNextAvailableAppts(3, appt); + prompt="<br/>The following nearby time slots are available:<br/>"; + int index = 0; + for(ApptBean possible : open) { + index++; + String newDate = frmt.format(possible.getDate()); + prompt += "<div style='padding:5px;margin:5px;float:left;border:1px solid black;'><b>Option "; + prompt += index+ "</b><br/>"+ frmt.format(possible.getDate()); + prompt +="<form action='appointmentRequests.jsp' method='post'>" + +"<input type='hidden' name='lhcp' value='"+hcpid+"'/>" + +"<input type='hidden' name='apptType' value='"+apptType+"'/> " + +"<input type='hidden' name='startDate' value='"+newDate.substring(0,10)+"'/>" + +"<input type='hidden' name='time1' value='"+newDate.substring(11,13)+"'/>" + +"<input type='hidden' name='time2' value='"+newDate.substring(14,16)+"'/>" + +"<input type='hidden' name='time3' value='"+newDate.substring(17)+"'/>" + +"<input type='hidden' name='comment' value='"+comment+"'/>" + +"<input type='submit' name='request' value='Select this time'/>" + +"</form></div>"; + } + prompt+="<div style='clear:both;'><br/></div>"; + } else { + loggingAction.logEvent( TransactionType.APPOINTMENT_REQUEST_SUBMITTED, loggedInMID, hcpid, ""); + } } - }else{ + } else { msg = "ERROR: Date must by in the format: MM/dd/yyyy"; } } catch (ParseException e) { msg = "ERROR: Date must by in the format: MM/dd/yyyy"; } + } } -} %> <h1>Request a New Appointment</h1> <% if (msg.contains("ERROR")) { %> -<span class="iTrustError"><%=msg%></span> + <span class="iTrustError"><%=msg%></span> <% } else { %> -<span class="iTrustMessage"><%=msg%></span> + <span class="iTrustMessage"><%=msg%></span> <% } %> <%=prompt%> -<%Date d = new Date(original.getDate().getTime()); -DateFormat format = new SimpleDateFormat("MM/dd/yyyy hh:mm a"); +<% + Date d = new Date(original.getDate().getTime()); + DateFormat format = new SimpleDateFormat("MM/dd/yyyy hh:mm a"); %> - <form id="mainForm" type="hidden" method="post" action="editApptPatient.jsp?apt=<%=aptParameter %>&apptID=<%=original.getApptID() %>"> <p>HCP:</p> <select name="lhcp"> - <% - -for(HCPVisitBean visit : visits){ - if (visit.getHCPMID() == original.getHcp()){ %> +<% + for(HCPVisitBean visit : visits){ + if (visit.getHCPMID() == original.getHcp()){ +%> <option selected="selected" value="<%=visit.getHCPMID()%>"><%=visit.getHCPName()%></option> - <%}else { %> +<% + } else { +%> <option value="<%=visit.getHCPMID()%>"><%=visit.getHCPName()%></option> - <%} } - - %> +<% + } + } +%> </select> <p>Appointment Type:</p> <select name="apptType"> - <% - for (ApptTypeBean appt : apptTypes) { - - if (appt.getName().equals(original.getApptType())){ %> +<% + for (ApptTypeBean appt : apptTypes) { + if (appt.getName().equals(original.getApptType())) { +%> <option selected="selected" value="<%=appt.getName()%>"><%=appt.getName()%></option> - <%}else { %> - <option value="<%=appt.getName()%>"><%=appt.getName()%></option> - <%} } - +<% + } else { +%> + <option value="<%=appt.getName()%>"><%=appt.getName()%></option> +<% + } + } String startDate = ""; - %> +%> </select> <p>Date:</p> <%DateFormat format_1 = new SimpleDateFormat("MM/dd/yyyy");%> <input name="startDate" value="<%=StringEscapeUtils.escapeHtml("" + ( format_1.format(d) )) %>"> - <input type=button value="Select Date" onclick="displayDatePicker('startDate');"> - + <p>Time:</p> <%DateFormat format_hour = new SimpleDateFormat("hh");%> <%DateFormat format_minute = new SimpleDateFormat("mm");%> <%DateFormat format_ampm = new SimpleDateFormat("a");%> <select name="time1"> - <% +<% String hour = ""; for (int i = 1; i <= 12; i++) { if (i < 10) hour = "0" + i; else hour = i + ""; - if (hour.equals((format_hour.format(d) ))) { %> + if (hour.equals((format_hour.format(d) ))) { +%> <option selected="selected" value="<%=hour%>"><%=StringEscapeUtils.escapeHtml("" + (hour))%></option> - <%}else { %> +<% + } else { +%> <option value="<%=hour%>"><%=StringEscapeUtils.escapeHtml("" + (hour))%></option> - <% +<% + } } - }%> +%> </select>:<select name="time2"> - <% +<% String min = ""; for (int i = 0; i < 60; i += 5) { if (i < 10) min = "0" + i; else min = i + ""; - if (min.equals((format_minute.format(d) ))) { %> + if (min.equals((format_minute.format(d) ))) { +%> <option selected="selected" value="<%=min%>"><%=StringEscapeUtils.escapeHtml("" + (min))%></option> - <%}else { %> +<% + } else { +%> <option value="<%=min%>"><%=StringEscapeUtils.escapeHtml("" + (min))%></option> - <% +<% + } } - }%> +%> </select> <select name="time3"> - <% if (format_ampm.format(d).equals("AM")){ %> +<% + if (format_ampm.format(d).equals("AM")){ +%> <option value="PM">PM</option> <option selected="selected" value="AM">AM</option> - <%}else { %> +<% + } else { +%> <option value="AM">AM</option> <option selected="selected" value="PM">PM</option> - <% }%> +<% + } +%> </select> <p>Comment:</p> <textarea name="comment" cols="100" rows="5"><%=StringEscapeUtils.escapeHtml("" + (comment))%></textarea> - <br /> <br /> + <br /> + <br /> <input type="hidden" id="editAppt" name="editAppt" value=""/> <input type="submit" name="request" value="Request" onClick="document.getElementById('editAppt').value='Request'"/> - </form> + <%@include file="/footer.jsp"%> diff --git a/iTrust/WebRoot/auth/patient/viewMyApptsPatient.jsp b/iTrust/WebRoot/auth/patient/viewMyApptsPatient.jsp index f00a8ecd9f5ca2b63248b31c0a977ac3478e80a3..84417ce546b84386d5fe740d262135bdd2e40a69 100644 --- a/iTrust/WebRoot/auth/patient/viewMyApptsPatient.jsp +++ b/iTrust/WebRoot/auth/patient/viewMyApptsPatient.jsp @@ -30,13 +30,15 @@ pageTitle = "iTrust - View My Messages"; session.setAttribute("appts", appts); if (appts.size() > 0) { %> <table class="fTable"> - <tr> + <tr style="width:100%"> <th>HCP</th> <th>Appointment Type</th> <th>Appointment Date/Time</th> <th>Duration</th> <th>Comments</th> <th>Change</th> + <th></th> + <th></th> </tr> <% List<ApptBean>conflicts = action.getAllConflicts(loggedInMID.longValue()); @@ -60,9 +62,9 @@ pageTitle = "iTrust - View My Messages"; <td><%= StringEscapeUtils.escapeHtml("" + ( format.format(d) )) %></td> <td><%= StringEscapeUtils.escapeHtml("" + ( apptTypeDAO.getApptType(a.getApptType()).getDuration()+" minutes" )) %></td> <td><%= comment %></td> - <td style="display:inline"><% if(d.after(now)){ %><a href="editApptPatient.jsp?apt=<%=a.getApptID() %>">Edit</a> <% } %></td> - <td style="display:inline">|</td> - <td style="display:inline"><% if(d.after(now)){ %><a href="cancelApptPatient.jsp?apt=<%=a.getApptID() %>">Cancel Appointment</a> <% } %></td> + <td style="text-align:center;"><% if(d.after(now)){ %><a href="editApptPatient.jsp?apt=<%=a.getApptID() %>">Edit</a> <% } %></td> + <td style="text-align:center;">|</td> + <td style="text-align:center;"><% if(d.after(now)){ %><a href="cancelApptPatient.jsp?apt=<%=a.getApptID() %>">Cancel Appointment</a><%}%></td> </tr> <% index ++; diff --git a/iTrust/test/edu/ncsu/csc/itrust/selenium/EditApptPatientTest.java b/iTrust/test/edu/ncsu/csc/itrust/selenium/EditApptPatientTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c25e640dadffb4805953ac164df7bcb3d4269347 --- /dev/null +++ b/iTrust/test/edu/ncsu/csc/itrust/selenium/EditApptPatientTest.java @@ -0,0 +1,84 @@ +package edu.ncsu.csc.itrust.selenium; + +import java.util.List; +import java.util.concurrent.TimeUnit; + +import org.junit.*; +import org.openqa.selenium.*; +import org.openqa.selenium.htmlunit.HtmlUnitDriver; + +import edu.ncsu.csc.itrust.enums.TransactionType; + +public class EditApptPatientTest extends iTrustSeleniumTest{ + private HtmlUnitDriver driver; + private StringBuffer verificationErrors = new StringBuffer(); + + @Before + public void setUp() throws Exception { + super.setUp(); + gen.clearAllTables(); + gen.standardData(); + driver = new HtmlUnitDriver(); + driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); + } + + @Test + public void testSetPassedDate() throws Exception { + gen.uc22(); + driver = (HtmlUnitDriver)login("1", "pw"); + driver.setJavascriptEnabled(true); + assertEquals("iTrust - Patient Home", driver.getTitle()); + driver.findElement(By.linkText("View/Edit My Appointments")).click(); + assertLogged(TransactionType.APPOINTMENT_ALL_VIEW, 1L, 1L, ""); + driver.findElements(By.tagName("td")).get(35).findElement(By.tagName("a")).click(); + driver.findElement(By.name("schedDate")).clear(); + driver.findElement(By.name("schedDate")).sendKeys("10/10/2009"); + driver.findElement(By.id("changeButton")).click(); + assertTrue(driver.getPageSource().contains("The scheduled date of this appointment")); + assertTrue(driver.getPageSource().contains("has already passed")); + assertNotLogged(TransactionType.APPOINTMENT_EDIT, 1L, 100L, ""); + } + + @Test + public void testRemoveAppt() throws Exception { + gen.uc22(); + driver = (HtmlUnitDriver)login("1", "pw"); + driver.setJavascriptEnabled(true); + assertEquals("iTrust - Patient Home", driver.getTitle()); + driver.findElement(By.linkText("View/Edit My Appointments")).click(); + assertLogged(TransactionType.APPOINTMENT_ALL_VIEW, 1L, 1L, ""); + driver.findElements(By.tagName("td")).get(23).findElement(By.tagName("a")).click(); + driver.findElement(By.id("removeButton")).click(); + assertTrue(driver.getPageSource().contains("Success: Appointment removed")); + assertLoggedNoSecondary(TransactionType.APPOINTMENT_REMOVE, 1L, 1L, ""); + } + + @Test + public void testEditAppt() throws Exception { + driver = (HtmlUnitDriver)login("1", "pw"); + driver.setJavascriptEnabled(true); + assertEquals("iTrust - Patient Home", driver.getTitle()); + driver.findElement(By.linkText("View/Edit My Appointments")).click(); + assertLogged(TransactionType.APPOINTMENT_ALL_VIEW, 1L, 1L, ""); + List<WebElement> rows = driver.findElements(By.tagName("td")); + //should be the last one + WebElement mine = rows.get(rows.size() - 1); + mine.findElement(By.tagName("a")).click(); + assertTrue(driver.getPageSource().contains("Andy Programmer")); + driver.findElement(By.name("comment")).clear(); + driver.findElement(By.name("comment")).sendKeys("New comment!"); + driver.findElement(By.id("changeButton")).click(); + assertTrue(driver.getPageSource().contains("Success: Appointment changed")); + assertLogged(TransactionType.APPOINTMENT_EDIT, 1L, 2L, ""); + } + + + @After + public void tearDown() throws Exception { + driver.quit(); + String verificationErrorString = verificationErrors.toString(); + if (!"".equals(verificationErrorString)) { + fail(verificationErrorString); + } + } +} \ No newline at end of file