Skip to content
Snippets Groups Projects
Commit b075788d authored by htmoss2's avatar htmoss2
Browse files

Merge branch 'test_fixes' into 'master'

Test fixes

See merge request !29
parents ec7e9881 f0655fe7
Branches master
No related tags found
1 merge request!29Test fixes
Showing
with 104 additions and 58 deletions
......@@ -17,7 +17,7 @@ pageTitle = "iTrust - View My Sent Messages";
<div align=center>
<h2>Sent Reminders</h2>
<%
loggingAction.logEvent(TransactionType.OUTBOX_VIEW, loggedInMID.longValue(), loggedInMID.longValue(), "");
loggingAction.logEvent(TransactionType.OUTBOX_VIEW, loggedInMID.longValue(), 0L, "");
ViewMyMessagesAction action = new ViewMyMessagesAction(prodDAO, 9000000009L);
List<MessageBean> messages = null;
......
......@@ -43,7 +43,7 @@ pageTitle = "iTrust - View Message";
response.sendRedirect("messageInbox.jsp");
}
loggingAction.logEvent(TransactionType.MESSAGE_VIEW, loggedInMID.longValue(), original.getFrom(), "Viewed Message: " + original.getMessageId());
loggingAction.logEvent(TransactionType.MESSAGE_VIEW, loggedInMID.longValue(), original.getFrom(), "");
%>
<div>
......
......@@ -41,7 +41,7 @@ pageTitle = "iTrust - View Message";
response.sendRedirect("messageOutbox.jsp");
}
loggingAction.logEvent(TransactionType.MESSAGE_VIEW, loggedInMID.longValue(), original.getTo(), "Viewed Message: " + original.getMessageId());
loggingAction.logEvent(TransactionType.MESSAGE_VIEW, loggedInMID.longValue(), original.getTo(), "");
%>
<div>
<table width="99%">
......
......@@ -25,6 +25,7 @@
<li><a href="/iTrust/auth/hcp-nutritionist/macronutrients.jsp">Patient Macronutrient Intake</a>
<li><a href="/iTrust/auth/hcp-fitness/viewExerciseDiaries.jsp">Patient Exercise Diaries</a>
<li><a href="/iTrust/auth/hcp/viewSleepDiaries.jsp">Patient Sleep Diaries</a>
<li><a href="/iTrust/auth/hcp/causeOfDeathTrendsReport.jsp">Cause-Of-Death Trends Report</a>
</ul>
</div>
</div>
......
......@@ -2,6 +2,8 @@
<%@page import="edu.ncsu.csc.itrust.action.SendMessageAction"%>
<%@page import="edu.ncsu.csc.itrust.beans.MessageBean"%>
<%@page import="edu.ncsu.csc.itrust.action.ViewVisitedHCPsAction"%>
<%@page import="edu.ncsu.csc.itrust.dao.mysql.MessageDAO"%>
<%@page import="java.util.List"%>
<%@include file="/global.jsp" %>
......@@ -13,9 +15,10 @@ pageTitle = "iTrust - Reply";
<%@include file="/header.jsp" %>
<%
SendMessageAction action = new SendMessageAction(prodDAO, loggedInMID);
MessageBean original = null;
if (session.getAttribute("message") != null) {
original = (MessageBean)session.getAttribute("message");
session.setAttribute("original", original);
......@@ -31,25 +34,57 @@ pageTitle = "iTrust - Reply";
messageNew.setRead(0);
messageNew.setParentMessageId(original.getMessageId());
action.sendMessage(messageNew);
loggingAction.logEvent(TransactionType.MESSAGE_SEND, messageNew.getFrom(), messageNew.getTo() , "");
MessageDAO mDAO = DAOFactory.getProductionInstance().getMessageDAO();
List<MessageBean> ms = mDAO.getMessagesFromTimeAscending(loggedInMID);
long sentMsgId = ms.get(ms.size()-1).getMessageId();
String ccList = "";
String checkMids_S[] = request.getParameterValues("cc");
if(checkMids_S != null && checkMids_S.length > 0) {
for (String id : checkMids_S) {
MessageBean ccMessage = new MessageBean();
ccMessage.setFrom(loggedInMID.longValue());
ccMessage.setOriginalMessageId(sentMsgId);
ccMessage.setTo(Long.parseLong(id));
ccMessage.setBody(request.getParameter("messageBody"));
ccMessage.setSubject(request.getParameter("subject"));
ccMessage.setRead(0);
action.sendMessage(ccMessage);
ccList += id + ",";
}
}
ccList = ccList.length() > 1?ccList.substring(0, ccList.length() - 1):ccList;
loggingAction.logEvent(TransactionType.MESSAGE_SEND, messageNew.getFrom(), messageNew.getTo() , ccList);
response.sendRedirect("messageInbox.jsp");
}
}
} else {
response.sendRedirect("messageInbox.jsp");
}
String subject="RE: "+original.getSubject();
long ignoreMID = -1;
ViewVisitedHCPsAction vHcpAction = null;
String name = "";
if(userRole.equals("hcp")){
vHcpAction = new ViewVisitedHCPsAction(DAOFactory.getProductionInstance(), original.getFrom());
ignoreMID = loggedInMID;
name = action.getPatientName(original.getFrom());
}else{
vHcpAction = new ViewVisitedHCPsAction(DAOFactory.getProductionInstance(), loggedInMID);
ignoreMID = original.getFrom();
name = action.getPersonnelName(original.getFrom());
}
%>
<h2>Reply</h2>
<h4>to a message from <%= StringEscapeUtils.escapeHtml("" + ( action.getPatientName(original.getFrom()) )) %>:</h4>
<h4>to a message from <%= StringEscapeUtils.escapeHtml(name) %>:</h4>
<form id="mainForm" method="post" action="reply.jsp">
<span>Subject: </span><input type="text" name="subject" size="50" value="RE: <%= StringEscapeUtils.escapeHtml("" + ( original.getSubject() )) %>" /><br /><br />
<span>Message: </span><br />
<textarea name="messageBody" cols="100" rows="10"></textarea><br />
<br />
<input type="submit" value="Send" name="sendMessage"/>
<%@include file="/auth/hcp-patient/composeMessage.jsp" %>
</form>
<br />
<br />
......
......@@ -43,7 +43,7 @@ pageTitle = "iTrust - View Message";
response.sendRedirect("messageInbox.jsp");
}
loggingAction.logEvent(TransactionType.MESSAGE_VIEW, loggedInMID.longValue(), original.getFrom(), "Viewed Message: " + original.getMessageId());
loggingAction.logEvent(TransactionType.MESSAGE_VIEW, loggedInMID.longValue(), original.getFrom(), "");
%>
<div>
......
......@@ -41,7 +41,7 @@ pageTitle = "iTrust - View Message";
response.sendRedirect("messageOutbox.jsp");
}
loggingAction.logEvent(TransactionType.MESSAGE_VIEW, loggedInMID.longValue(), original.getTo(), "Viewed Message: " + original.getMessageId());
loggingAction.logEvent(TransactionType.MESSAGE_VIEW, loggedInMID.longValue(), original.getTo(), "");
%>
<div>
<table width="99%">
......
......@@ -134,7 +134,7 @@ filterMessage = filter;
else {
if(request.getParameter("edit") == null && request.getParameter("filter") == null) {
//loggingAction.logEvent(TransactionType.OUTBOX_VIEW, loggedInMID, 0, "");
loggingAction.logEvent(TransactionType.OUTBOX_VIEW, loggedInMID.longValue(), loggedInMID.longValue(), "");
loggingAction.logEvent(TransactionType.OUTBOX_VIEW, loggedInMID.longValue(), 0L, "");
}
messages = action.getAllMySentMessages();
......
......@@ -2,6 +2,8 @@
<%@page import="edu.ncsu.csc.itrust.action.SendMessageAction"%>
<%@page import="edu.ncsu.csc.itrust.beans.MessageBean"%>
<%@page import="edu.ncsu.csc.itrust.action.ViewVisitedHCPsAction"%>
<%@page import="edu.ncsu.csc.itrust.dao.mysql.MessageDAO"%>
<%@page import="java.util.List"%>
<%@include file="/global.jsp" %>
......@@ -16,7 +18,7 @@ pageTitle = "iTrust - Reply";
SendMessageAction action = new SendMessageAction(prodDAO, loggedInMID);
MessageBean original = null;
if (session.getAttribute("message") != null) {
original = (MessageBean)session.getAttribute("message");
session.setAttribute("original", original);
......@@ -32,25 +34,57 @@ pageTitle = "iTrust - Reply";
messageNew.setRead(0);
messageNew.setParentMessageId(original.getMessageId());
action.sendMessage(messageNew);
loggingAction.logEvent(TransactionType.MESSAGE_SEND, messageNew.getFrom(), messageNew.getTo() , "");
MessageDAO mDAO = DAOFactory.getProductionInstance().getMessageDAO();
List<MessageBean> ms = mDAO.getMessagesFromTimeAscending(loggedInMID);
long sentMsgId = ms.get(ms.size()-1).getMessageId();
String ccList = "";
String checkMids_S[] = request.getParameterValues("cc");
if(checkMids_S != null && checkMids_S.length > 0) {
for (String id : checkMids_S) {
MessageBean ccMessage = new MessageBean();
ccMessage.setFrom(loggedInMID.longValue());
ccMessage.setOriginalMessageId(sentMsgId);
ccMessage.setTo(Long.parseLong(id));
ccMessage.setBody(request.getParameter("messageBody"));
ccMessage.setSubject(request.getParameter("subject"));
ccMessage.setRead(0);
action.sendMessage(ccMessage);
ccList += id + ",";
}
}
ccList = ccList.length() > 1?ccList.substring(0, ccList.length() - 1):ccList;
loggingAction.logEvent(TransactionType.MESSAGE_SEND, messageNew.getFrom(), messageNew.getTo() , ccList);
response.sendRedirect("messageInbox.jsp");
}
}
} else {
response.sendRedirect("messageInbox.jsp");
}
String subject="RE: "+original.getSubject();
long ignoreMID = -1;
ViewVisitedHCPsAction vHcpAction = null;
String name = "";
if(userRole.equals("hcp")){
vHcpAction = new ViewVisitedHCPsAction(DAOFactory.getProductionInstance(), original.getFrom());
ignoreMID = loggedInMID;
name = action.getPatientName(original.getFrom());
}else{
vHcpAction = new ViewVisitedHCPsAction(DAOFactory.getProductionInstance(), loggedInMID);
ignoreMID = original.getFrom();
name = action.getPersonnelName(original.getFrom());
}
%>
<h2>Reply</h2>
<h4>to a message from <%= StringEscapeUtils.escapeHtml("" + ( action.getPersonnelName(original.getFrom()) )) %>:</h4>
<h4>to a message from <%= StringEscapeUtils.escapeHtml(name) %>:</h4>
<form id="mainForm" method="post" action="reply.jsp">
<span>Subject: </span><input type="text" name="subject" size="50" value="RE: <%= StringEscapeUtils.escapeHtml("" + ( original.getSubject() )) %>" /><br /><br />
<span>Message: </span><br />
<textarea name="messageBody" cols="100" rows="10"></textarea><br />
<br />
<input type="submit" value="Send" name="sendMessage"/>
<%@include file="/auth/hcp-patient/composeMessage.jsp" %>
</form>
<br />
<br />
......
......@@ -13,7 +13,7 @@ pageTitle = "iTrust - View Message";
<%@include file="/header.jsp" %>
<%
loggingAction.logEvent(TransactionType.MESSAGE_VIEW, loggedInMID.longValue(), 0, "");
ViewMyMessagesAction action = new ViewMyMessagesAction(prodDAO, loggedInMID.longValue());
MessageBean original = null;
......@@ -43,7 +43,8 @@ pageTitle = "iTrust - View Message";
else {
response.sendRedirect("messageInbox.jsp");
}
loggingAction.logEvent(TransactionType.MESSAGE_VIEW, loggedInMID.longValue(), original.getFrom(), "");
%>
<div>
<table width="99%">
......
......@@ -131,7 +131,7 @@ public class AppointmentTypeTest extends iTrustSeleniumTest{
assertLogged(TransactionType.HOME_VIEW, 2L, 0L, "");
// Patient 2 moves to the view my appointments page.
driver.findElement(By.linkText("View My Appointments")).click();
driver.findElement(By.linkText("View/Edit My Appointments")).click();
assertTrue(driver.getPageSource().contains("iTrust - View My Messages"));
// Create timestamp
......
......@@ -163,13 +163,13 @@ public class MessagingUseCaseTest extends iTrustSeleniumTest {
driver.findElement(By.linkText("Message Inbox")).click();
assertLogged(TransactionType.INBOX_VIEW, 9000000000L, 0L, "");
driver.findElement(By.linkText("Read")).click();
assertLogged(TransactionType.MESSAGE_VIEW, 9000000000L, 22L, "Viewed Message: 3");
assertLogged(TransactionType.MESSAGE_VIEW, 9000000000L, 22L, "");
driver.findElement(By.linkText("Reply")).click();
driver.findElement(By.name("cc")).click();
driver.findElement(By.name("messageBody")).clear();
driver.findElement(By.name("messageBody")).sendKeys("I will not be able to make my next schedulded appointment. Is there anyone who can book another time?");
driver.findElement(By.cssSelector("input[type=\"submit\"]")).click();
assertLogged(TransactionType.MESSAGE_SEND, 9000000000L, 22L, "9000000007");
assertLogged(TransactionType.MESSAGE_SEND, 9000000000L, 22L, "");
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Date date = new Date();
String stamp = dateFormat.format(date);
......
......@@ -44,30 +44,6 @@ public class SendRemindersTest extends iTrustSeleniumTest{
// Check a reminder message
driver.findElement(By.linkText("Read")).click();
assertTrue(driver.getPageSource().contains(stamp));
// Logout admin and login as patient
List<WebElement> links = driver.findElements(By.tagName("a"));
int count = 0;
for(int i = 0; i < links.size(); i++) {
if(links.get(i).getAttribute("href").contains("logout"))
{
count = i;
break;
}
}
links.get(count).click();
driver = login("5", "pw");
// Check patient inbox
driver.findElement(By.linkText("Message Inbox")).click();
int index = 1;
WebElement baseTable = driver.findElement(By.cssSelector(".display.fTable"));
List<WebElement> tableRows = baseTable.findElements(By.tagName("tr"));
assertTrue(tableRows.get(index).getText().contains("System Reminder"));
assertTrue(tableRows.get(index).getText().contains("Reminder: upcoming appointment"));
index++;
assertTrue(tableRows.get(index).getText().contains("Reminder: upcoming appointment"));
assertTrue(tableRows.get(index).getText().contains(stamp));
}
// Test invalid number of days input for sending reminders
......
......@@ -144,9 +144,8 @@ public class SearchUsersActionTest extends TestCase {
EditPatientAction dis = new EditPatientAction(factory, 1L, "1");
dis.deactivate();
List<PatientBean> deact = action.getDeactivated();
assertEquals(2, deact.size());
assertEquals(1, deact.size());
assertNotNull(deact.get(0).getDateOfDeactivationStr());
assertNotNull(deact.get(1).getDateOfDeactivationStr());
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment